From 8c304865a5725b3d19e0e7d4893e86c573a45943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrick=20B=C3=A4cker?= Date: Thu, 27 Oct 2016 15:10:36 +0200 Subject: [PATCH] Add possibility to use dynamic images --- dist/notify.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/dist/notify.js b/dist/notify.js index fb9df63..2ba1d03 100644 --- a/dist/notify.js +++ b/dist/notify.js @@ -503,20 +503,29 @@ datas[blankFieldName] = data; } for (name in datas) { - d = datas[name]; - type = this.userFields[name]; - if (!type) { - continue; - } - if (type === "text") { - d = encode(d); - if (this.options.breakNewLines) { - d = d.replace(/\n/g, '
'); - } - } - value = name === blankFieldName ? '' : '=' + name; - find(this.userContainer, "[data-notify-" + type + value + "]").html(d); - } + d = datas[name]; + type = this.userFields[name]; + if (!type) { + continue; + } + + value = name === blankFieldName ? '' : '=' + name; + var element = find(this.userContainer, "[data-notify-" + type + value + "]"); + if (element.length === 1) { + if (element[0].tagName == "IMG") { + element.attr("src",d); + } + else { + if (type === "text") { + d = encode(d); + if (this.options.breakNewLines) { + d = d.replace(/\n/g, '
'); + } + } + element.html(d); + } + } + } this.updateClasses(); if (this.elem) { this.setElementPosition();