added text new line to <br> conversion option
This commit is contained in:
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
File diff suppressed because one or more lines are too long
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
File diff suppressed because one or more lines are too long
+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