added text new line to <br> conversion option
This commit is contained in:
1 parent
9275312b03
commit
70f18f4be5
5 files changed
+43
-11
No files matched your search
Vendored
+15
-3
@@ -1,11 +1,11 @@
|
|||||||
/** Notify.js - v0.0.1 - 2013/06/12
|
/** Notify.js - v0.0.1 - 2013/06/14
|
||||||
* http://notifyjs.com/
|
* http://notifyjs.com/
|
||||||
* Copyright (c) 2013 Jaime Pillora - MIT
|
* Copyright (c) 2013 Jaime Pillora - MIT
|
||||||
*/
|
*/
|
||||||
(function(window,document,undefined) {
|
(function(window,document,undefined) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Notification, addStyle, coreStyle, createElem, defaults, getAnchorElement, getStyle, globalAnchors, hAligns, incr, inherit, insertCSS, mainPositions, opposites, parsePosition, pluginClassName, pluginName, pluginOptions, positions, realign, stylePrefixes, styles, vAligns,
|
var Notification, addStyle, coreStyle, createElem, defaults, encode, getAnchorElement, getStyle, globalAnchors, hAligns, incr, inherit, insertCSS, mainPositions, opposites, parsePosition, pluginClassName, pluginName, pluginOptions, positions, realign, stylePrefixes, styles, vAligns,
|
||||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||||
|
|
||||||
pluginName = 'notify';
|
pluginName = 'notify';
|
||||||
@@ -125,6 +125,7 @@ pluginOptions = {
|
|||||||
autoHideDelay: 5000,
|
autoHideDelay: 5000,
|
||||||
arrowShow: true,
|
arrowShow: true,
|
||||||
arrowSize: 5,
|
arrowSize: 5,
|
||||||
|
breakNewLines: true,
|
||||||
elementPosition: 'bottom',
|
elementPosition: 'bottom',
|
||||||
globalPosition: 'top right',
|
globalPosition: 'top right',
|
||||||
style: 'bootstrap',
|
style: 'bootstrap',
|
||||||
@@ -199,6 +200,11 @@ realign = function(alignment, inner, outer) {
|
|||||||
throw "Invalid alignment";
|
throw "Invalid alignment";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
encode = function(text) {
|
||||||
|
encode.e = encode.e || createElem("div");
|
||||||
|
return encode.e.text(text).html();
|
||||||
|
};
|
||||||
|
|
||||||
Notification = (function() {
|
Notification = (function() {
|
||||||
|
|
||||||
function Notification(elem, data, options) {
|
function Notification(elem, data, options) {
|
||||||
@@ -427,7 +433,13 @@ Notification = (function() {
|
|||||||
} else if (!this.container && !data) {
|
} else if (!this.container && !data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.text[this.rawHTML ? 'html' : 'text'](data);
|
if (!this.rawHTML) {
|
||||||
|
data = encode(data);
|
||||||
|
if (this.options.breakNewLines) {
|
||||||
|
data = data.replace(/\n/, '<br/>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.text.html(data);
|
||||||
this.updateClasses();
|
this.updateClasses();
|
||||||
if (this.elem) {
|
if (this.elem) {
|
||||||
this.setElementPosition();
|
this.setElementPosition();
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/** Notify.js - v0.0.1 - 2013/06/12
|
/** Notify.js - v0.0.1 - 2013/06/14
|
||||||
* http://notifyjs.com/
|
* http://notifyjs.com/
|
||||||
* Copyright (c) 2013 Jaime Pillora - MIT
|
* Copyright (c) 2013 Jaime Pillora - MIT
|
||||||
*/
|
*/
|
||||||
(function(t,i,n){"use strict";var e,o,r,s,a,l,h,c,p,u,d,A,f,m,w,g,y,b,v,x,C,E,S,H=[].indexOf||function(t){for(var i=0,n=this.length;n>i;i++)if(i in this&&this[i]===t)return i;return-1};y="notify",g=y+"js",v={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},p=["l","c","r"],S=["t","m","b"],f=["t","b","l","r"],m={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},w=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,e){var o;return o=e.toLowerCase().charAt(0),v[o]?i.push(o):n}),i},E={},r={name:"core",html:'<div class="'+g+'-wrapper">\n <div class="'+g+'-arrow"></div>\n <div class="'+g+'-container"></div>\n</div>',css:"."+g+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+g+"-corner ."+g+"-wrapper,\n."+g+"-corner ."+g+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+g+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+g+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+g+"-text {\n position: relative;\n}\n\n."+g+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},C={"border-radius":["-webkit-","-moz-"]},h=function(t){return E[t]},o=function(i,e){var o,r;if(!i)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=E[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+y+": overwriting style '"+i+"'"),E[i].cssElem.remove()),e.name=i,E[i]=e,o="",e.classes&&$.each(e.classes,function(t,i){return o+="."+g+"-"+e.name+"-"+t+" {\n",$.each(i,function(t,i){return C[t]&&$.each(C[t],function(n,e){return o+=" "+e+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=A(o),e.cssElem.attr("id","notify-"+e.name)):n},A=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(n){i[0].styleSheet.cssText=t}return i},b={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},d=function(t,i){var n;return n=function(){},n.prototype=t,$.extend(!0,new n,i)},a=function(t){return $.extend(b,t)},s=function(t){return $("<"+t+"></"+t+">")},c={},l=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=i.first()),t},u=function(t,i,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=v[m[i.charAt(0)]],r=i,t[o]!==n&&(i=v[o.charAt(0)],e=-e),t[i]===n?t[i]=e:t[i]+=e,null},x=function(t,i,n){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return n/2-i/2;if("r"===t||"b"===t)return n-i;throw"Invalid alignment"},e=function(){function t(t,i,n){"string"==typeof n&&(n={className:n}),this.options=d(b,$.isPlainObject(n)?n:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(g,this),this.arrow=this.wrapper.find("."+g+"-arrow"),this.container=this.wrapper.find("."+g+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=l(t),this.elem.data(g,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}return t.prototype.loadHTML=function(){var t;if(t=this.getStyle(),this.userContainer=$(t.html),this.text=this.userContainer.find("[data-notify-text]"),0===this.text.length&&(this.text=this.userContainer.find("[data-notify-html]"),this.rawHTML=!0),0===this.text.length)throw"style: '"+name+"' HTML is missing a: 'data-notify-text' or 'data-notify-html' attribute";return this.text.addClass(""+g+"-text")},t.prototype.show=function(t,i){var e,o,r,s,a,l=this;if(o=function(){return t||l.elem||l.destroy(),i?i():n},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow),e=[],a&&t)s="show";else if(a&&!t)s="hide";else if(!a&&t)s=this.options.showAnimation,e.push(this.options.showDuration);else{if(a||t)return o();s=this.options.hideAnimation,e.push(this.options.hideDuration)}return e.push(o),r[s].apply(r,e)},t.prototype.setGlobalPosition=function(){var t,i,n,e,o,r,a,l;return l=this.getPosition(),a=l[0],r=l[1],o=v[a],t=v[r],e=a+"|"+r,i=c[e],i||(i=c[e]=s("div"),n={},n[o]=0,"middle"===t?n.top="45%":"center"===t?n.left="45%":n[t]=0,i.css(n).addClass(""+g+"-corner"),$("body").append(i)),i.prepend(this.wrapper)},t.prototype.setElementPosition=function(){var t,i,e,o,r,s,a,l,h,c,d,A,w,g,y,b,C,E,M,D,T,k,F,z,B,Q,R,U,P;for(F=this.getPosition(),D=F[0],E=F[1],M=F[2],d=this.elem.position(),l=this.elem.outerHeight(),A=this.elem.outerWidth(),h=this.elem.innerHeight(),c=this.elem.innerWidth(),z=this.wrapper.position(),r=this.container.height(),s=this.container.width(),g=v[D],b=m[D],C=v[b],a={},a[C]="b"===D?l:"r"===D?A:0,u(a,"top",d.top-z.top),u(a,"lefLine truncated
|
(function(t,i,e){"use strict";var n,o,r,s,a,l,h,c,p,u,d,A,f,m,w,g,y,b,v,x,C,E,S,H,M=[].indexOf||function(t){for(var i=0,e=this.length;e>i;i++)if(i in this&&this[i]===t)return i;return-1};b="notify",y=b+"js",x={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},u=["l","c","r"],H=["t","m","b"],m=["t","b","l","r"],w={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},g=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,n){var o;return o=n.toLowerCase().charAt(0),x[o]?i.push(o):e}),i},S={},r={name:"core",html:'<div class="'+y+'-wrapper">\n <div class="'+y+'-arrow"></div>\n <div class="'+y+'-container"></div>\n</div>',css:"."+y+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+y+"-corner ."+y+"-wrapper,\n."+y+"-corner ."+y+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+y+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+y+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+y+"-text {\n position: relative;\n}\n\n."+y+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},E={"border-radius":["-webkit-","-moz-"]},c=function(t){return S[t]},o=function(i,n){var o,r;if(!i)throw"Missing Style name";if(!n)throw"Missing Style definition";return(null!=(r=S[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+b+": overwriting style '"+i+"'"),S[i].cssElem.remove()),n.name=i,S[i]=n,o="",n.classes&&$.each(n.classes,function(t,i){return o+="."+y+"-"+n.name+"-"+t+" {\n",$.each(i,function(t,i){return E[t]&&$.each(E[t],function(e,n){return o+=" "+n+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),n.css&&(o+="/* styles for "+n.name+" */\n"+n.css),o?(n.cssElem=f(o),n.cssElem.attr("id","notify-"+n.name)):e},f=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(e){i[0].styleSheet.cssText=t}return i},v={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,breakNewLines:!0,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},A=function(t,i){var e;return e=function(){},e.prototype=t,$.extend(!0,new e,i)},a=function(t){return $.extend(v,t)},s=function(t){return $("<"+t+"></"+t+">")},p={},h=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,e){return $(e).attr("name")===t.attr("name")}),t=i.first()),t},d=function(t,i,n){var o,r;if("string"==typeof n)n=parseInt(n,10);else if("number"!=typeof n)return;if(!isNaN(n))return o=x[w[i.charAt(0)]],r=i,t[o]!==e&&(i=x[o.charAt(0)],n=-n),t[i]===e?t[i]=n:t[i]+=n,null},C=function(t,i,e){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return e/2-i/2;if("r"===t||"b"===t)return e-i;throw"Invalid alignment"},l=function(t){return l.e=l.e||s("div"),l.e.text(t).html()},n=function(){function t(t,i,e){"string"==typeof e&&(e={className:e}),this.options=A(v,$.isPlainObject(e)?e:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(y,this),this.arrow=this.wrapper.find("."+y+"-arrow"),this.container=this.wrapper.find("."+y+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=h(t),this.elem.data(y,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}return t.prototype.loadHTML=function(){var t;if(t=this.getStyle(),this.userContainer=$(t.html),this.text=this.userContainer.find("[data-notify-text]"),0===this.text.length&&(this.text=this.userContainer.find("[data-notify-html]"),this.rawHTML=!0),0===this.text.length)throw"style: '"+name+"' HTML is missing a: 'data-notify-text' or 'data-notify-html' attribute";return this.text.addClass(""+y+"-text")},t.prototype.show=function(t,i){var n,o,r,s,a,l=this;if(o=function(){return t||l.elem||l.destroy(),i?i():e},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow),n=[],a&&t)s="show";else if(a&&!t)s="hide";else if(!a&&t)s=this.options.showAnimation,n.push(this.options.showDuration);else{if(a||t)return o();s=this.options.hideAnimation,n.push(this.options.hideDuration)}return n.push(o),r[s].apply(r,n)},t.prototype.setGlobalPosition=function(){var t,i,e,n,o,r,a,l;return l=this.getPosition(),a=l[0],r=l[1],o=x[a],t=x[r],n=a+"|"+r,i=p[n],i||(i=p[n]=s("div"),e={},e[o]=0,"middle"===t?e.top="45%":"center"===t?e.left="45%":e[t]=0,i.css(e).addClass(""+y+"-corner"),$("body").append(i)),i.prepend(this.wrapper)},t.prototype.setElementPosition=function(){var t,i,n,o,r,s,a,l,h,c,p,A,f,g,y,b,v,E,S,D,k,T,F,z,B,Q,R,U,N;for(F=this.getPosition(),D=F[0],E=F[1],S=F[2],p=this.elem.position(),l=this.elem.outerHeight(),A=this.elem.outerWidth(),h=this.elem.innerHeight(),c=this.elem.innerWidth(),z=this.wrapper.position(),r=this.container.height(),s=this.container.width(),g=x[D]Line truncated
|
||||||
Vendored
+15
-3
@@ -1,11 +1,11 @@
|
|||||||
/** Notify.js - v0.0.1 - 2013/06/12
|
/** Notify.js - v0.0.1 - 2013/06/14
|
||||||
* http://notifyjs.com/
|
* http://notifyjs.com/
|
||||||
* Copyright (c) 2013 Jaime Pillora - MIT
|
* Copyright (c) 2013 Jaime Pillora - MIT
|
||||||
*/
|
*/
|
||||||
(function(window,document,undefined) {
|
(function(window,document,undefined) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Notification, addStyle, coreStyle, createElem, defaults, getAnchorElement, getStyle, globalAnchors, hAligns, incr, inherit, insertCSS, mainPositions, opposites, parsePosition, pluginClassName, pluginName, pluginOptions, positions, realign, stylePrefixes, styles, vAligns,
|
var Notification, addStyle, coreStyle, createElem, defaults, encode, getAnchorElement, getStyle, globalAnchors, hAligns, incr, inherit, insertCSS, mainPositions, opposites, parsePosition, pluginClassName, pluginName, pluginOptions, positions, realign, stylePrefixes, styles, vAligns,
|
||||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||||
|
|
||||||
pluginName = 'notify';
|
pluginName = 'notify';
|
||||||
@@ -125,6 +125,7 @@ pluginOptions = {
|
|||||||
autoHideDelay: 5000,
|
autoHideDelay: 5000,
|
||||||
arrowShow: true,
|
arrowShow: true,
|
||||||
arrowSize: 5,
|
arrowSize: 5,
|
||||||
|
breakNewLines: true,
|
||||||
elementPosition: 'bottom',
|
elementPosition: 'bottom',
|
||||||
globalPosition: 'top right',
|
globalPosition: 'top right',
|
||||||
style: 'bootstrap',
|
style: 'bootstrap',
|
||||||
@@ -199,6 +200,11 @@ realign = function(alignment, inner, outer) {
|
|||||||
throw "Invalid alignment";
|
throw "Invalid alignment";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
encode = function(text) {
|
||||||
|
encode.e = encode.e || createElem("div");
|
||||||
|
return encode.e.text(text).html();
|
||||||
|
};
|
||||||
|
|
||||||
Notification = (function() {
|
Notification = (function() {
|
||||||
|
|
||||||
function Notification(elem, data, options) {
|
function Notification(elem, data, options) {
|
||||||
@@ -427,7 +433,13 @@ Notification = (function() {
|
|||||||
} else if (!this.container && !data) {
|
} else if (!this.container && !data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.text[this.rawHTML ? 'html' : 'text'](data);
|
if (!this.rawHTML) {
|
||||||
|
data = encode(data);
|
||||||
|
if (this.options.breakNewLines) {
|
||||||
|
data = data.replace(/\n/, '<br/>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.text.html(data);
|
||||||
this.updateClasses();
|
this.updateClasses();
|
||||||
if (this.elem) {
|
if (this.elem) {
|
||||||
this.setElementPosition();
|
this.setElementPosition();
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/** Notify.js - v0.0.1 - 2013/06/12
|
/** Notify.js - v0.0.1 - 2013/06/14
|
||||||
* http://notifyjs.com/
|
* http://notifyjs.com/
|
||||||
* Copyright (c) 2013 Jaime Pillora - MIT
|
* Copyright (c) 2013 Jaime Pillora - MIT
|
||||||
*/
|
*/
|
||||||
(function(t,i,n){"use strict";var e,o,r,s,a,h,l,c,p,u,d,f,m,w,y,g,v,b,x,S,C,H,P,T=[].indexOf||function(t){for(var i=0,n=this.length;n>i;i++)if(i in this&&this[i]===t)return i;return-1};v="notify",g=v+"js",x={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},p=["l","c","r"],P=["t","m","b"],m=["t","b","l","r"],w={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},y=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,e){var o;return o=e.toLowerCase().charAt(0),x[o]?i.push(o):n}),i},H={},r={name:"core",html:'<div class="'+g+'-wrapper">\n <div class="'+g+'-arrow"></div>\n <div class="'+g+'-container"></div>\n</div>',css:"."+g+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+g+"-corner ."+g+"-wrapper,\n."+g+"-corner ."+g+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+g+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+g+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+g+"-text {\n position: relative;\n}\n\n."+g+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},C={"border-radius":["-webkit-","-moz-"]},l=function(t){return H[t]},o=function(i,e){var o,r;if(!i)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=H[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+v+": overwriting style '"+i+"'"),H[i].cssElem.remove()),e.name=i,H[i]=e,o="",e.classes&&$.each(e.classes,function(t,i){return o+="."+g+"-"+e.name+"-"+t+" {\n",$.each(i,function(t,i){return C[t]&&$.each(C[t],function(n,e){return o+=" "+e+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=f(o),e.cssElem.attr("id","notify-"+e.name)):n},f=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(n){i[0].styleSheet.cssText=t}return i},b={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},d=function(t,i){var n;return n=function(){},n.prototype=t,$.extend(!0,new n,i)},a=function(t){return $.extend(b,t)},s=function(t){return $("<"+t+"></"+t+">")},c={},h=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=i.first()),t},u=function(t,i,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=x[w[i.charAt(0)]],r=i,t[o]!==n&&(i=x[o.charAt(0)],e=-e),t[i]===n?t[i]=e:t[i]+=e,null},S=function(t,i,n){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return n/2-i/2;if("r"===t||"b"===t)return n-i;throw"Invalid alignment"},e=function(){function t(t,i,n){"string"==typeof n&&(n={className:n}),this.options=d(b,$.isPlainObject(n)?n:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(g,this),this.arrow=this.wrapper.find("."+g+"-arrow"),this.container=this.wrapper.find("."+g+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=h(t),this.elem.data(g,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}return t.prototype.loadHTML=function(){var t;if(t=this.getStyle(),this.userContainer=$(t.html),this.text=this.userContainer.find("[data-notify-text]"),0===this.text.length&&(this.text=this.userContainer.find("[data-notify-html]"),this.rawHTML=!0),0===this.text.length)throw"style: '"+name+"' HTML is missing a: 'data-notify-text' or 'data-notify-html' attribute";return this.text.addClass(""+g+"-text")},t.prototype.show=function(t,i){var e,o,r,s,a,h=this;if(o=function(){return t||h.elem||h.destroy(),i?i():n},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow),e=[],a&&t)s="show";else if(a&&!t)s="hide";else if(!a&&t)s=this.options.showAnimation,e.push(this.options.showDuration);else{if(a||t)return o();s=this.options.hideAnimation,e.push(this.options.hideDuration)}return e.push(o),r[s].apply(r,e)},t.prototype.setGlobalPosition=function(){var t,i,n,e,o,r,a,h;return h=this.getPosition(),a=h[0],r=h[1],o=x[a],t=x[r],e=a+"|"+r,i=c[e],i||(i=c[e]=s("div"),n={},n[o]=0,"middle"===t?n.top="45%":"center"===t?n.left="45%":n[t]=0,i.css(n).addClass(""+g+"-corner"),$("body").append(i)),i.prepend(this.wrapper)},t.prototype.setElementPosition=function(){var t,i,e,o,r,s,a,h,l,c,d,f,y,g,v,b,C,H,A,M,N,k,z,D,E,L,j,O,I;for(z=this.getPosition(),M=z[0],H=z[1],A=z[2],d=this.elem.position(),h=this.elem.outerHeight(),f=this.elem.outerWidth(),l=this.elem.innerHeight(),c=this.elem.innerWidth(),D=this.wrapper.position(),r=this.container.height(),s=this.container.width(),g=x[M],b=w[M],C=x[b],a={},a[C]="b"===M?h:"r"===M?f:0,u(a,"top",d.top-D.top),u(a,"lefLine truncated
|
(function(t,i,n){"use strict";var e,o,r,s,a,h,l,c,p,u,d,f,m,w,y,g,b,v,x,S,C,H,P,T,N=[].indexOf||function(t){for(var i=0,n=this.length;n>i;i++)if(i in this&&this[i]===t)return i;return-1};v="notify",b=v+"js",S={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},u=["l","c","r"],T=["t","m","b"],w=["t","b","l","r"],y={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},g=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,e){var o;return o=e.toLowerCase().charAt(0),S[o]?i.push(o):n}),i},P={},r={name:"core",html:'<div class="'+b+'-wrapper">\n <div class="'+b+'-arrow"></div>\n <div class="'+b+'-container"></div>\n</div>',css:"."+b+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+b+"-corner ."+b+"-wrapper,\n."+b+"-corner ."+b+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+b+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+b+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+b+"-text {\n position: relative;\n}\n\n."+b+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},H={"border-radius":["-webkit-","-moz-"]},c=function(t){return P[t]},o=function(i,e){var o,r;if(!i)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=P[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+v+": overwriting style '"+i+"'"),P[i].cssElem.remove()),e.name=i,P[i]=e,o="",e.classes&&$.each(e.classes,function(t,i){return o+="."+b+"-"+e.name+"-"+t+" {\n",$.each(i,function(t,i){return H[t]&&$.each(H[t],function(n,e){return o+=" "+e+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=m(o),e.cssElem.attr("id","notify-"+e.name)):n},m=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(n){i[0].styleSheet.cssText=t}return i},x={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,breakNewLines:!0,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},f=function(t,i){var n;return n=function(){},n.prototype=t,$.extend(!0,new n,i)},a=function(t){return $.extend(x,t)},s=function(t){return $("<"+t+"></"+t+">")},p={},l=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=i.first()),t},d=function(t,i,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=S[y[i.charAt(0)]],r=i,t[o]!==n&&(i=S[o.charAt(0)],e=-e),t[i]===n?t[i]=e:t[i]+=e,null},C=function(t,i,n){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return n/2-i/2;if("r"===t||"b"===t)return n-i;throw"Invalid alignment"},h=function(t){return h.e=h.e||s("div"),h.e.text(t).html()},e=function(){function t(t,i,n){"string"==typeof n&&(n={className:n}),this.options=f(x,$.isPlainObject(n)?n:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(b,this),this.arrow=this.wrapper.find("."+b+"-arrow"),this.container=this.wrapper.find("."+b+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=l(t),this.elem.data(b,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}return t.prototype.loadHTML=function(){var t;if(t=this.getStyle(),this.userContainer=$(t.html),this.text=this.userContainer.find("[data-notify-text]"),0===this.text.length&&(this.text=this.userContainer.find("[data-notify-html]"),this.rawHTML=!0),0===this.text.length)throw"style: '"+name+"' HTML is missing a: 'data-notify-text' or 'data-notify-html' attribute";return this.text.addClass(""+b+"-text")},t.prototype.show=function(t,i){var e,o,r,s,a,h=this;if(o=function(){return t||h.elem||h.destroy(),i?i():n},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow),e=[],a&&t)s="show";else if(a&&!t)s="hide";else if(!a&&t)s=this.options.showAnimation,e.push(this.options.showDuration);else{if(a||t)return o();s=this.options.hideAnimation,e.push(this.options.hideDuration)}return e.push(o),r[s].apply(r,e)},t.prototype.setGlobalPosition=function(){var t,i,n,e,o,r,a,h;return h=this.getPosition(),a=h[0],r=h[1],o=S[a],t=S[r],e=a+"|"+r,i=p[e],i||(i=p[e]=s("div"),n={},n[o]=0,"middle"===t?n.top="45%":"center"===t?n.left="45%":n[t]=0,i.css(n).addClass(""+b+"-corner"),$("body").append(i)),i.prepend(this.wrapper)},t.prototype.setElementPosition=function(){var t,i,e,o,r,s,a,h,l,c,p,f,m,g,b,v,x,H,P,k,A,M,L,z,D,E,j,O,I;for(L=this.getPosition(),k=L[0],H=L[1],P=L[2],p=this.elem.position(),h=this.elem.outerHeight(),f=this.elem.outerWidth(),l=this.elem.innerHeight(),c=this.elem.innerWidth(),z=this.wrapper.position(),r=this.container.height(),s=this.container.width(),g=S[k]Line truncated
|
||||||
+9
-1
@@ -164,6 +164,7 @@ pluginOptions =
|
|||||||
autoHideDelay: 5000
|
autoHideDelay: 5000
|
||||||
arrowShow: true
|
arrowShow: true
|
||||||
arrowSize: 5
|
arrowSize: 5
|
||||||
|
breakNewLines: true
|
||||||
elementPosition: 'bottom'
|
elementPosition: 'bottom'
|
||||||
globalPosition: 'top right'
|
globalPosition: 'top right'
|
||||||
style: 'bootstrap'
|
style: 'bootstrap'
|
||||||
@@ -236,6 +237,9 @@ realign = (alignment, inner, outer) ->
|
|||||||
outer - inner
|
outer - inner
|
||||||
throw "Invalid alignment"
|
throw "Invalid alignment"
|
||||||
|
|
||||||
|
encode = (text) ->
|
||||||
|
encode.e = encode.e or createElem "div"
|
||||||
|
encode.e.text(text).html()
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# NOTIFY CLASS
|
# NOTIFY CLASS
|
||||||
@@ -471,8 +475,12 @@ class Notification
|
|||||||
else if not @container and not data
|
else if not @container and not data
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#escape
|
||||||
|
unless @rawHTML
|
||||||
|
data = encode(data)
|
||||||
|
data = data.replace(/\n/,'<br/>') if @options.breakNewLines
|
||||||
#update content
|
#update content
|
||||||
@text[if @rawHTML then 'html' else 'text'](data)
|
@text.html(data)
|
||||||
|
|
||||||
#set styles
|
#set styles
|
||||||
@updateClasses()
|
@updateClasses()
|
||||||
|
|||||||
Reference in new issue
Block a user