pnotify-rails 2.0.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pnotify-rails/version.rb +1 -1
- data/vendor/assets/javascripts/pnotify/index.js +5 -1
- data/vendor/assets/javascripts/pnotify/pnotify.animate.js +108 -0
- data/vendor/assets/javascripts/pnotify/pnotify.buttons.js +165 -121
- data/vendor/assets/javascripts/pnotify/pnotify.callbacks.js +42 -40
- data/vendor/assets/javascripts/pnotify/pnotify.confirm.js +145 -139
- data/vendor/assets/javascripts/pnotify/pnotify.desktop.js +144 -133
- data/vendor/assets/javascripts/pnotify/pnotify.history.js +172 -171
- data/vendor/assets/javascripts/pnotify/pnotify.js +873 -0
- data/vendor/assets/javascripts/pnotify/pnotify.mobile.js +121 -0
- data/vendor/assets/javascripts/pnotify/pnotify.nonblock.js +144 -139
- data/vendor/assets/javascripts/pnotify/pnotify.reference.js +131 -116
- data/vendor/assets/javascripts/pnotify/pnotify.tooltip.js +15 -0
- data/vendor/assets/stylesheets/pnotify/index.css +5 -2
- data/vendor/assets/stylesheets/pnotify/pnotify.brighttheme.css +165 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.buttons.css +2 -2
- data/vendor/assets/stylesheets/pnotify/pnotify.css +112 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.history.css +22 -22
- data/vendor/assets/stylesheets/pnotify/pnotify.material.css +121 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.mobile.css +46 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.nonblock.css +7 -0
- metadata +12 -6
- data/vendor/assets/javascripts/pnotify/pnotify.core.js +0 -778
- data/vendor/assets/stylesheets/pnotify/pnotify.core.css +0 -56
- data/vendor/assets/stylesheets/pnotify/pnotify.picon.css +0 -11
@@ -1,189 +1,190 @@
|
|
1
1
|
// History
|
2
|
-
|
3
|
-
(function (factory) {
|
2
|
+
(function (root, factory) {
|
4
3
|
if (typeof define === 'function' && define.amd) {
|
5
4
|
// AMD. Register as a module.
|
6
5
|
define('pnotify.history', ['jquery', 'pnotify'], factory);
|
6
|
+
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
7
|
+
// CommonJS
|
8
|
+
module.exports = factory(require('jquery'), require('./pnotify'));
|
7
9
|
} else {
|
8
10
|
// Browser globals
|
9
|
-
factory(jQuery, PNotify);
|
11
|
+
factory(root.jQuery, root.PNotify);
|
10
12
|
}
|
11
|
-
}(function($, PNotify){
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
13
|
+
}(this, function($, PNotify){
|
14
|
+
var history_menu,
|
15
|
+
history_handle_top;
|
16
|
+
$(function(){
|
17
|
+
$("body").on("pnotify.history-all", function(){
|
18
|
+
// Display all notices. (Disregarding non-history notices.)
|
19
|
+
$.each(PNotify.notices, function(){
|
20
|
+
if (this.modules.history.inHistory) {
|
21
|
+
if (this.elem.is(":visible")) {
|
22
|
+
// The hide variable controls whether the history pull down should
|
23
|
+
// queue a removal timer.
|
24
|
+
if (this.options.hide)
|
25
|
+
this.queueRemove();
|
26
|
+
} else if (this.open)
|
27
|
+
this.open();
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}).on("pnotify.history-last", function(){
|
31
|
+
var pushTop = (PNotify.prototype.options.stack.push === "top");
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
// Look up the last history notice, and display it.
|
34
|
+
var i = (pushTop ? 0 : -1);
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
var notice;
|
37
|
+
do {
|
38
|
+
if (i === -1)
|
39
|
+
notice = PNotify.notices.slice(i);
|
40
|
+
else
|
41
|
+
notice = PNotify.notices.slice(i, i+1);
|
42
|
+
if (!notice[0])
|
43
|
+
return false;
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
45
|
+
i = (pushTop ? i + 1 : i - 1);
|
46
|
+
} while (!notice[0].modules.history.inHistory || notice[0].elem.is(":visible"));
|
47
|
+
if (notice[0].open)
|
48
|
+
notice[0].open();
|
49
|
+
});
|
50
|
+
});
|
51
|
+
PNotify.prototype.options.history = {
|
52
|
+
// Place the notice in the history.
|
53
|
+
history: true,
|
54
|
+
// Display a pull down menu to redisplay previous notices.
|
55
|
+
menu: false,
|
56
|
+
// Make the pull down menu fixed to the top of the viewport.
|
57
|
+
fixed: true,
|
58
|
+
// Maximum number of notifications to have onscreen.
|
59
|
+
maxonscreen: Infinity,
|
60
|
+
// The various displayed text, helps facilitating internationalization.
|
61
|
+
labels: {
|
62
|
+
redisplay: "Redisplay",
|
63
|
+
all: "All",
|
64
|
+
last: "Last"
|
65
|
+
}
|
66
|
+
};
|
67
|
+
PNotify.prototype.modules.history = {
|
68
|
+
// The history variable controls whether the notice gets redisplayed
|
69
|
+
// by the history pull down.
|
70
|
+
inHistory: false,
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
init: function(notice, options){
|
73
|
+
// Make sure that no notices get destroyed.
|
74
|
+
notice.options.destroy = false;
|
73
75
|
|
74
|
-
|
76
|
+
this.inHistory = options.history;
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
78
|
+
if (options.menu) {
|
79
|
+
// If there isn't a history pull down, create one.
|
80
|
+
if (typeof history_menu === "undefined") {
|
81
|
+
history_menu = $("<div />", {
|
82
|
+
"class": "ui-pnotify-history-container "+notice.styles.hi_menu,
|
83
|
+
"mouseleave": function(){
|
84
|
+
history_menu.animate({top: "-"+history_handle_top+"px"}, {duration: 100, queue: false});
|
85
|
+
}
|
86
|
+
})
|
87
|
+
.append($("<div />", {"class": "ui-pnotify-history-header", "text": options.labels.redisplay}))
|
88
|
+
.append($("<button />", {
|
89
|
+
"class": "ui-pnotify-history-all "+notice.styles.hi_btn,
|
90
|
+
"text": options.labels.all,
|
91
|
+
"mouseenter": function(){
|
92
|
+
$(this).addClass(notice.styles.hi_btnhov);
|
93
|
+
},
|
94
|
+
"mouseleave": function(){
|
95
|
+
$(this).removeClass(notice.styles.hi_btnhov);
|
96
|
+
},
|
97
|
+
"click": function(){
|
98
|
+
$(this).trigger("pnotify.history-all");
|
99
|
+
return false;
|
100
|
+
}
|
101
|
+
}))
|
102
|
+
.append($("<button />", {
|
103
|
+
"class": "ui-pnotify-history-last "+notice.styles.hi_btn,
|
104
|
+
"text": options.labels.last,
|
105
|
+
"mouseenter": function(){
|
106
|
+
$(this).addClass(notice.styles.hi_btnhov);
|
107
|
+
},
|
108
|
+
"mouseleave": function(){
|
109
|
+
$(this).removeClass(notice.styles.hi_btnhov);
|
110
|
+
},
|
111
|
+
"click": function(){
|
112
|
+
$(this).trigger("pnotify.history-last");
|
113
|
+
return false;
|
114
|
+
}
|
115
|
+
}))
|
116
|
+
.appendTo("body");
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
118
|
+
// Make a handle so the user can pull down the history tab.
|
119
|
+
var handle = $("<span />", {
|
120
|
+
"class": "ui-pnotify-history-pulldown "+notice.styles.hi_hnd,
|
121
|
+
"mouseenter": function(){
|
122
|
+
history_menu.animate({top: "0"}, {duration: 100, queue: false});
|
123
|
+
}
|
124
|
+
})
|
125
|
+
.appendTo(history_menu);
|
124
126
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
history_menu.css({top: "-"+history_handle_top+"px"});
|
127
|
+
// Get the top of the handle.
|
128
|
+
history_handle_top = handle.offset().top + 2;
|
129
|
+
// Hide the history pull down up to the top of the handle.
|
130
|
+
history_menu.css({top: "-"+history_handle_top+"px"});
|
130
131
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
132
|
+
// Apply the fixed styling.
|
133
|
+
if (options.fixed) {
|
134
|
+
history_menu.addClass('ui-pnotify-history-fixed');
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
},
|
139
|
+
update: function(notice, options){
|
140
|
+
// Update values for history menu access.
|
141
|
+
this.inHistory = options.history;
|
142
|
+
if (options.fixed && history_menu) {
|
143
|
+
history_menu.addClass('ui-pnotify-history-fixed');
|
144
|
+
} else if (history_menu) {
|
145
|
+
history_menu.removeClass('ui-pnotify-history-fixed');
|
146
|
+
}
|
147
|
+
},
|
148
|
+
beforeOpen: function(notice, options){
|
149
|
+
// Remove oldest notifications leaving only options.maxonscreen on screen
|
150
|
+
if (PNotify.notices && (PNotify.notices.length > options.maxonscreen)) {
|
151
|
+
// Oldest are normally in front of array, or if stack.push=="top" then
|
152
|
+
// they are at the end of the array! (issue #98)
|
153
|
+
var el;
|
154
|
+
if (notice.options.stack.push !== "top")
|
155
|
+
el = PNotify.notices.slice(0, PNotify.notices.length - options.maxonscreen);
|
156
|
+
else
|
157
|
+
el = PNotify.notices.slice(options.maxonscreen, PNotify.notices.length);
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
159
|
+
$.each(el, function(){
|
160
|
+
if (this.remove)
|
161
|
+
this.remove();
|
162
|
+
});
|
163
|
+
}
|
164
|
+
}
|
165
|
+
};
|
166
|
+
$.extend(PNotify.styling.jqueryui, {
|
167
|
+
hi_menu: "ui-state-default ui-corner-bottom",
|
168
|
+
hi_btn: "ui-state-default ui-corner-all",
|
169
|
+
hi_btnhov: "ui-state-hover",
|
170
|
+
hi_hnd: "ui-icon ui-icon-grip-dotted-horizontal"
|
171
|
+
});
|
172
|
+
$.extend(PNotify.styling.bootstrap2, {
|
173
|
+
hi_menu: "well",
|
174
|
+
hi_btn: "btn",
|
175
|
+
hi_btnhov: "",
|
176
|
+
hi_hnd: "icon-chevron-down"
|
177
|
+
});
|
178
|
+
$.extend(PNotify.styling.bootstrap3, {
|
179
|
+
hi_menu: "well",
|
180
|
+
hi_btn: "btn btn-default",
|
181
|
+
hi_btnhov: "",
|
182
|
+
hi_hnd: "glyphicon glyphicon-chevron-down"
|
183
|
+
});
|
184
|
+
$.extend(PNotify.styling.fontawesome, {
|
185
|
+
hi_menu: "well",
|
186
|
+
hi_btn: "btn btn-default",
|
187
|
+
hi_btnhov: "",
|
188
|
+
hi_hnd: "fa fa-chevron-down"
|
189
|
+
});
|
189
190
|
}));
|
@@ -0,0 +1,873 @@
|
|
1
|
+
/*
|
2
|
+
PNotify 3.0.0 sciactive.com/pnotify/
|
3
|
+
(C) 2015 Hunter Perrin; Google, Inc.
|
4
|
+
license Apache-2.0
|
5
|
+
*/
|
6
|
+
/*
|
7
|
+
* ====== PNotify ======
|
8
|
+
*
|
9
|
+
* http://sciactive.com/pnotify/
|
10
|
+
*
|
11
|
+
* Copyright 2009-2015 Hunter Perrin
|
12
|
+
* Copyright 2015 Google, Inc.
|
13
|
+
*
|
14
|
+
* Licensed under Apache License, Version 2.0.
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
*/
|
17
|
+
|
18
|
+
(function (root, factory) {
|
19
|
+
if (typeof define === 'function' && define.amd) {
|
20
|
+
// AMD. Register as a module.
|
21
|
+
define('pnotify', ['jquery'], function($){
|
22
|
+
return factory($, root);
|
23
|
+
});
|
24
|
+
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
25
|
+
// CommonJS
|
26
|
+
module.exports = factory(require('jquery'), global || root);
|
27
|
+
} else {
|
28
|
+
// Browser globals
|
29
|
+
root.PNotify = factory(root.jQuery, root);
|
30
|
+
}
|
31
|
+
}(this, function($, root){
|
32
|
+
var init = function(root){
|
33
|
+
var default_stack = {
|
34
|
+
dir1: "down",
|
35
|
+
dir2: "left",
|
36
|
+
push: "bottom",
|
37
|
+
spacing1: 36,
|
38
|
+
spacing2: 36,
|
39
|
+
context: $("body"),
|
40
|
+
modal: false
|
41
|
+
};
|
42
|
+
var posTimer, // Position all timer.
|
43
|
+
body,
|
44
|
+
jwindow = $(root);
|
45
|
+
// Set global variables.
|
46
|
+
var do_when_ready = function(){
|
47
|
+
body = $("body");
|
48
|
+
PNotify.prototype.options.stack.context = body;
|
49
|
+
jwindow = $(root);
|
50
|
+
// Reposition the notices when the window resizes.
|
51
|
+
jwindow.bind('resize', function(){
|
52
|
+
if (posTimer) {
|
53
|
+
clearTimeout(posTimer);
|
54
|
+
}
|
55
|
+
posTimer = setTimeout(function(){
|
56
|
+
PNotify.positionAll(true);
|
57
|
+
}, 10);
|
58
|
+
});
|
59
|
+
};
|
60
|
+
var createStackOverlay = function(stack) {
|
61
|
+
var overlay = $("<div />", {"class": "ui-pnotify-modal-overlay"});
|
62
|
+
overlay.prependTo(stack.context);
|
63
|
+
if (stack.overlay_close) {
|
64
|
+
// Close the notices on overlay click.
|
65
|
+
overlay.click(function(){
|
66
|
+
PNotify.removeStack(stack);
|
67
|
+
});
|
68
|
+
}
|
69
|
+
return overlay;
|
70
|
+
};
|
71
|
+
var PNotify = function(options){
|
72
|
+
this.parseOptions(options);
|
73
|
+
this.init();
|
74
|
+
};
|
75
|
+
$.extend(PNotify.prototype, {
|
76
|
+
// The current version of PNotify.
|
77
|
+
version: "3.0.0",
|
78
|
+
|
79
|
+
// === Options ===
|
80
|
+
|
81
|
+
// Options defaults.
|
82
|
+
options: {
|
83
|
+
// The notice's title.
|
84
|
+
title: false,
|
85
|
+
// Whether to escape the content of the title. (Not allow HTML.)
|
86
|
+
title_escape: false,
|
87
|
+
// The notice's text.
|
88
|
+
text: false,
|
89
|
+
// Whether to escape the content of the text. (Not allow HTML.)
|
90
|
+
text_escape: false,
|
91
|
+
// What styling classes to use. (Can be either "brighttheme", "jqueryui", "bootstrap2", "bootstrap3", or "fontawesome".)
|
92
|
+
styling: "brighttheme",
|
93
|
+
// Additional classes to be added to the notice. (For custom styling.)
|
94
|
+
addclass: "",
|
95
|
+
// Class to be added to the notice for corner styling.
|
96
|
+
cornerclass: "",
|
97
|
+
// Display the notice when it is created.
|
98
|
+
auto_display: true,
|
99
|
+
// Width of the notice.
|
100
|
+
width: "300px",
|
101
|
+
// Minimum height of the notice. It will expand to fit content.
|
102
|
+
min_height: "16px",
|
103
|
+
// Type of the notice. "notice", "info", "success", or "error".
|
104
|
+
type: "notice",
|
105
|
+
// Set icon to true to use the default icon for the selected
|
106
|
+
// style/type, false for no icon, or a string for your own icon class.
|
107
|
+
icon: true,
|
108
|
+
// The animation to use when displaying and hiding the notice. "none"
|
109
|
+
// and "fade" are supported through CSS. Others are supported
|
110
|
+
// through the Animate module and Animate.css.
|
111
|
+
animation: "fade",
|
112
|
+
// Speed at which the notice animates in and out. "slow", "normal",
|
113
|
+
// or "fast". Respectively, 600ms, 400ms, 200ms.
|
114
|
+
animate_speed: "normal",
|
115
|
+
// Display a drop shadow.
|
116
|
+
shadow: true,
|
117
|
+
// After a delay, remove the notice.
|
118
|
+
hide: true,
|
119
|
+
// Delay in milliseconds before the notice is removed.
|
120
|
+
delay: 8000,
|
121
|
+
// Reset the hide timer if the mouse moves over the notice.
|
122
|
+
mouse_reset: true,
|
123
|
+
// Remove the notice's elements from the DOM after it is removed.
|
124
|
+
remove: true,
|
125
|
+
// Change new lines to br tags.
|
126
|
+
insert_brs: true,
|
127
|
+
// Whether to remove notices from the global array.
|
128
|
+
destroy: true,
|
129
|
+
// The stack on which the notices will be placed. Also controls the
|
130
|
+
// direction the notices stack.
|
131
|
+
stack: default_stack
|
132
|
+
},
|
133
|
+
|
134
|
+
// === Modules ===
|
135
|
+
|
136
|
+
// This object holds all the PNotify modules. They are used to provide
|
137
|
+
// additional functionality.
|
138
|
+
modules: {},
|
139
|
+
// This runs an event on all the modules.
|
140
|
+
runModules: function(event, arg){
|
141
|
+
var curArg;
|
142
|
+
for (var module in this.modules) {
|
143
|
+
curArg = ((typeof arg === "object" && module in arg) ? arg[module] : arg);
|
144
|
+
if (typeof this.modules[module][event] === 'function') {
|
145
|
+
this.modules[module].notice = this;
|
146
|
+
this.modules[module].options = typeof this.options[module] === 'object' ? this.options[module] : {};
|
147
|
+
this.modules[module][event](this, typeof this.options[module] === 'object' ? this.options[module] : {}, curArg);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
},
|
151
|
+
|
152
|
+
// === Class Variables ===
|
153
|
+
|
154
|
+
state: "initializing", // The state can be "initializing", "opening", "open", "closing", and "closed".
|
155
|
+
timer: null, // Auto close timer.
|
156
|
+
animTimer: null, // Animation timer.
|
157
|
+
styles: null,
|
158
|
+
elem: null,
|
159
|
+
container: null,
|
160
|
+
title_container: null,
|
161
|
+
text_container: null,
|
162
|
+
animating: false, // Stores what is currently being animated (in or out).
|
163
|
+
timerHide: false, // Stores whether the notice was hidden by a timer.
|
164
|
+
|
165
|
+
// === Events ===
|
166
|
+
|
167
|
+
init: function(){
|
168
|
+
var that = this;
|
169
|
+
|
170
|
+
// First and foremost, we don't want our module objects all referencing the prototype.
|
171
|
+
this.modules = {};
|
172
|
+
$.extend(true, this.modules, PNotify.prototype.modules);
|
173
|
+
|
174
|
+
// Get our styling object.
|
175
|
+
if (typeof this.options.styling === "object") {
|
176
|
+
this.styles = this.options.styling;
|
177
|
+
} else {
|
178
|
+
this.styles = PNotify.styling[this.options.styling];
|
179
|
+
}
|
180
|
+
|
181
|
+
// Create our widget.
|
182
|
+
// Stop animation, reset the removal timer when the user mouses over.
|
183
|
+
this.elem = $("<div />", {
|
184
|
+
"class": "ui-pnotify "+this.options.addclass,
|
185
|
+
"css": {"display": "none"},
|
186
|
+
"aria-live": "assertive",
|
187
|
+
"aria-role": "alertdialog",
|
188
|
+
"mouseenter": function(e){
|
189
|
+
if (that.options.mouse_reset && that.animating === "out") {
|
190
|
+
if (!that.timerHide) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
that.cancelRemove();
|
194
|
+
}
|
195
|
+
// Stop the close timer.
|
196
|
+
if (that.options.hide && that.options.mouse_reset) {
|
197
|
+
that.cancelRemove();
|
198
|
+
}
|
199
|
+
},
|
200
|
+
"mouseleave": function(e){
|
201
|
+
// Start the close timer.
|
202
|
+
if (that.options.hide && that.options.mouse_reset && that.animating !== "out") {
|
203
|
+
that.queueRemove();
|
204
|
+
}
|
205
|
+
PNotify.positionAll();
|
206
|
+
}
|
207
|
+
});
|
208
|
+
// Maybe we need to fade in/out.
|
209
|
+
if (this.options.animation === "fade") {
|
210
|
+
this.elem.addClass("ui-pnotify-fade-"+this.options.animate_speed);
|
211
|
+
}
|
212
|
+
// Create a container for the notice contents.
|
213
|
+
this.container = $("<div />", {
|
214
|
+
"class": this.styles.container+" ui-pnotify-container "+(this.options.type === "error" ? this.styles.error : (this.options.type === "info" ? this.styles.info : (this.options.type === "success" ? this.styles.success : this.styles.notice))),
|
215
|
+
"role": "alert"
|
216
|
+
}).appendTo(this.elem);
|
217
|
+
if (this.options.cornerclass !== "") {
|
218
|
+
this.container.removeClass("ui-corner-all").addClass(this.options.cornerclass);
|
219
|
+
}
|
220
|
+
// Create a drop shadow.
|
221
|
+
if (this.options.shadow) {
|
222
|
+
this.container.addClass("ui-pnotify-shadow");
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
// Add the appropriate icon.
|
227
|
+
if (this.options.icon !== false) {
|
228
|
+
$("<div />", {"class": "ui-pnotify-icon"})
|
229
|
+
.append($("<span />", {"class": this.options.icon === true ? (this.options.type === "error" ? this.styles.error_icon : (this.options.type === "info" ? this.styles.info_icon : (this.options.type === "success" ? this.styles.success_icon : this.styles.notice_icon))) : this.options.icon}))
|
230
|
+
.prependTo(this.container);
|
231
|
+
}
|
232
|
+
|
233
|
+
// Add a title.
|
234
|
+
this.title_container = $("<h4 />", {
|
235
|
+
"class": "ui-pnotify-title"
|
236
|
+
})
|
237
|
+
.appendTo(this.container);
|
238
|
+
if (this.options.title === false) {
|
239
|
+
this.title_container.hide();
|
240
|
+
} else if (this.options.title_escape) {
|
241
|
+
this.title_container.text(this.options.title);
|
242
|
+
} else {
|
243
|
+
this.title_container.html(this.options.title);
|
244
|
+
}
|
245
|
+
|
246
|
+
// Add text.
|
247
|
+
this.text_container = $("<div />", {
|
248
|
+
"class": "ui-pnotify-text",
|
249
|
+
"aria-role": "alert"
|
250
|
+
})
|
251
|
+
.appendTo(this.container);
|
252
|
+
if (this.options.text === false) {
|
253
|
+
this.text_container.hide();
|
254
|
+
} else if (this.options.text_escape) {
|
255
|
+
this.text_container.text(this.options.text);
|
256
|
+
} else {
|
257
|
+
this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "<br />") : this.options.text);
|
258
|
+
}
|
259
|
+
|
260
|
+
// Set width and min height.
|
261
|
+
if (typeof this.options.width === "string") {
|
262
|
+
this.elem.css("width", this.options.width);
|
263
|
+
}
|
264
|
+
if (typeof this.options.min_height === "string") {
|
265
|
+
this.container.css("min-height", this.options.min_height);
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
// Add the notice to the notice array.
|
270
|
+
if (this.options.stack.push === "top") {
|
271
|
+
PNotify.notices = $.merge([this], PNotify.notices);
|
272
|
+
} else {
|
273
|
+
PNotify.notices = $.merge(PNotify.notices, [this]);
|
274
|
+
}
|
275
|
+
// Now position all the notices if they are to push to the top.
|
276
|
+
if (this.options.stack.push === "top") {
|
277
|
+
this.queuePosition(false, 1);
|
278
|
+
}
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
// Mark the stack so it won't animate the new notice.
|
284
|
+
this.options.stack.animation = false;
|
285
|
+
|
286
|
+
// Run the modules.
|
287
|
+
this.runModules('init');
|
288
|
+
|
289
|
+
// Display the notice.
|
290
|
+
if (this.options.auto_display) {
|
291
|
+
this.open();
|
292
|
+
}
|
293
|
+
return this;
|
294
|
+
},
|
295
|
+
|
296
|
+
// This function is for updating the notice.
|
297
|
+
update: function(options){
|
298
|
+
// Save old options.
|
299
|
+
var oldOpts = this.options;
|
300
|
+
// Then update to the new options.
|
301
|
+
this.parseOptions(oldOpts, options);
|
302
|
+
// Maybe we need to fade in/out.
|
303
|
+
this.elem.removeClass("ui-pnotify-fade-slow ui-pnotify-fade-normal ui-pnotify-fade-fast");
|
304
|
+
if (this.options.animation === "fade") {
|
305
|
+
this.elem.addClass("ui-pnotify-fade-"+this.options.animate_speed);
|
306
|
+
}
|
307
|
+
// Update the corner class.
|
308
|
+
if (this.options.cornerclass !== oldOpts.cornerclass) {
|
309
|
+
this.container.removeClass("ui-corner-all "+oldOpts.cornerclass).addClass(this.options.cornerclass);
|
310
|
+
}
|
311
|
+
// Update the shadow.
|
312
|
+
if (this.options.shadow !== oldOpts.shadow) {
|
313
|
+
if (this.options.shadow) {
|
314
|
+
this.container.addClass("ui-pnotify-shadow");
|
315
|
+
} else {
|
316
|
+
this.container.removeClass("ui-pnotify-shadow");
|
317
|
+
}
|
318
|
+
}
|
319
|
+
// Update the additional classes.
|
320
|
+
if (this.options.addclass === false) {
|
321
|
+
this.elem.removeClass(oldOpts.addclass);
|
322
|
+
} else if (this.options.addclass !== oldOpts.addclass) {
|
323
|
+
this.elem.removeClass(oldOpts.addclass).addClass(this.options.addclass);
|
324
|
+
}
|
325
|
+
// Update the title.
|
326
|
+
if (this.options.title === false) {
|
327
|
+
this.title_container.slideUp("fast");
|
328
|
+
} else if (this.options.title !== oldOpts.title) {
|
329
|
+
if (this.options.title_escape) {
|
330
|
+
this.title_container.text(this.options.title);
|
331
|
+
} else {
|
332
|
+
this.title_container.html(this.options.title);
|
333
|
+
}
|
334
|
+
if (oldOpts.title === false) {
|
335
|
+
this.title_container.slideDown(200);
|
336
|
+
}
|
337
|
+
}
|
338
|
+
// Update the text.
|
339
|
+
if (this.options.text === false) {
|
340
|
+
this.text_container.slideUp("fast");
|
341
|
+
} else if (this.options.text !== oldOpts.text) {
|
342
|
+
if (this.options.text_escape) {
|
343
|
+
this.text_container.text(this.options.text);
|
344
|
+
} else {
|
345
|
+
this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "<br />") : this.options.text);
|
346
|
+
}
|
347
|
+
if (oldOpts.text === false) {
|
348
|
+
this.text_container.slideDown(200);
|
349
|
+
}
|
350
|
+
}
|
351
|
+
// Change the notice type.
|
352
|
+
if (this.options.type !== oldOpts.type)
|
353
|
+
this.container.removeClass(
|
354
|
+
this.styles.error+" "+this.styles.notice+" "+this.styles.success+" "+this.styles.info
|
355
|
+
).addClass(this.options.type === "error" ?
|
356
|
+
this.styles.error :
|
357
|
+
(this.options.type === "info" ?
|
358
|
+
this.styles.info :
|
359
|
+
(this.options.type === "success" ?
|
360
|
+
this.styles.success :
|
361
|
+
this.styles.notice
|
362
|
+
)
|
363
|
+
)
|
364
|
+
);
|
365
|
+
if (this.options.icon !== oldOpts.icon || (this.options.icon === true && this.options.type !== oldOpts.type)) {
|
366
|
+
// Remove any old icon.
|
367
|
+
this.container.find("div.ui-pnotify-icon").remove();
|
368
|
+
if (this.options.icon !== false) {
|
369
|
+
// Build the new icon.
|
370
|
+
$("<div />", {"class": "ui-pnotify-icon"})
|
371
|
+
.append($("<span />", {"class": this.options.icon === true ? (this.options.type === "error" ? this.styles.error_icon : (this.options.type === "info" ? this.styles.info_icon : (this.options.type === "success" ? this.styles.success_icon : this.styles.notice_icon))) : this.options.icon}))
|
372
|
+
.prependTo(this.container);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
// Update the width.
|
376
|
+
if (this.options.width !== oldOpts.width) {
|
377
|
+
this.elem.animate({width: this.options.width});
|
378
|
+
}
|
379
|
+
// Update the minimum height.
|
380
|
+
if (this.options.min_height !== oldOpts.min_height) {
|
381
|
+
this.container.animate({minHeight: this.options.min_height});
|
382
|
+
}
|
383
|
+
// Update the timed hiding.
|
384
|
+
if (!this.options.hide) {
|
385
|
+
this.cancelRemove();
|
386
|
+
} else if (!oldOpts.hide) {
|
387
|
+
this.queueRemove();
|
388
|
+
}
|
389
|
+
this.queuePosition(true);
|
390
|
+
|
391
|
+
// Run the modules.
|
392
|
+
this.runModules('update', oldOpts);
|
393
|
+
return this;
|
394
|
+
},
|
395
|
+
|
396
|
+
// Display the notice.
|
397
|
+
open: function(){
|
398
|
+
this.state = "opening";
|
399
|
+
// Run the modules.
|
400
|
+
this.runModules('beforeOpen');
|
401
|
+
|
402
|
+
var that = this;
|
403
|
+
// If the notice is not in the DOM, append it.
|
404
|
+
if (!this.elem.parent().length) {
|
405
|
+
this.elem.appendTo(this.options.stack.context ? this.options.stack.context : body);
|
406
|
+
}
|
407
|
+
// Try to put it in the right position.
|
408
|
+
if (this.options.stack.push !== "top") {
|
409
|
+
this.position(true);
|
410
|
+
}
|
411
|
+
this.animateIn(function(){
|
412
|
+
that.queuePosition(true);
|
413
|
+
|
414
|
+
// Now set it to hide.
|
415
|
+
if (that.options.hide) {
|
416
|
+
that.queueRemove();
|
417
|
+
}
|
418
|
+
|
419
|
+
that.state = "open";
|
420
|
+
|
421
|
+
// Run the modules.
|
422
|
+
that.runModules('afterOpen');
|
423
|
+
});
|
424
|
+
|
425
|
+
return this;
|
426
|
+
},
|
427
|
+
|
428
|
+
// Remove the notice.
|
429
|
+
remove: function(timer_hide) {
|
430
|
+
this.state = "closing";
|
431
|
+
this.timerHide = !!timer_hide; // Make sure it's a boolean.
|
432
|
+
// Run the modules.
|
433
|
+
this.runModules('beforeClose');
|
434
|
+
|
435
|
+
var that = this;
|
436
|
+
if (this.timer) {
|
437
|
+
root.clearTimeout(this.timer);
|
438
|
+
this.timer = null;
|
439
|
+
}
|
440
|
+
this.animateOut(function(){
|
441
|
+
that.state = "closed";
|
442
|
+
// Run the modules.
|
443
|
+
that.runModules('afterClose');
|
444
|
+
that.queuePosition(true);
|
445
|
+
// If we're supposed to remove the notice from the DOM, do it.
|
446
|
+
if (that.options.remove) {
|
447
|
+
that.elem.detach();
|
448
|
+
}
|
449
|
+
// Run the modules.
|
450
|
+
that.runModules('beforeDestroy');
|
451
|
+
// Remove object from PNotify.notices to prevent memory leak (issue #49)
|
452
|
+
// unless destroy is off
|
453
|
+
if (that.options.destroy) {
|
454
|
+
if (PNotify.notices !== null) {
|
455
|
+
var idx = $.inArray(that,PNotify.notices);
|
456
|
+
if (idx !== -1) {
|
457
|
+
PNotify.notices.splice(idx,1);
|
458
|
+
}
|
459
|
+
}
|
460
|
+
}
|
461
|
+
// Run the modules.
|
462
|
+
that.runModules('afterDestroy');
|
463
|
+
});
|
464
|
+
|
465
|
+
return this;
|
466
|
+
},
|
467
|
+
|
468
|
+
// === Class Methods ===
|
469
|
+
|
470
|
+
// Get the DOM element.
|
471
|
+
get: function(){
|
472
|
+
return this.elem;
|
473
|
+
},
|
474
|
+
|
475
|
+
// Put all the options in the right places.
|
476
|
+
parseOptions: function(options, moreOptions){
|
477
|
+
this.options = $.extend(true, {}, PNotify.prototype.options);
|
478
|
+
// This is the only thing that *should* be copied by reference.
|
479
|
+
this.options.stack = PNotify.prototype.options.stack;
|
480
|
+
var optArray = [options, moreOptions], curOpts;
|
481
|
+
for (var curIndex=0; curIndex < optArray.length; curIndex++) {
|
482
|
+
curOpts = optArray[curIndex];
|
483
|
+
if (typeof curOpts === "undefined") {
|
484
|
+
break;
|
485
|
+
}
|
486
|
+
if (typeof curOpts !== 'object') {
|
487
|
+
this.options.text = curOpts;
|
488
|
+
} else {
|
489
|
+
for (var option in curOpts) {
|
490
|
+
if (this.modules[option]) {
|
491
|
+
// Avoid overwriting module defaults.
|
492
|
+
$.extend(true, this.options[option], curOpts[option]);
|
493
|
+
} else {
|
494
|
+
this.options[option] = curOpts[option];
|
495
|
+
}
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
},
|
500
|
+
|
501
|
+
// Animate the notice in.
|
502
|
+
animateIn: function(callback){
|
503
|
+
// Declare that the notice is animating in.
|
504
|
+
this.animating = "in";
|
505
|
+
var that = this;
|
506
|
+
callback = (function(){
|
507
|
+
if (that.animTimer) {
|
508
|
+
clearTimeout(that.animTimer);
|
509
|
+
}
|
510
|
+
if (that.animating !== "in") {
|
511
|
+
return;
|
512
|
+
}
|
513
|
+
if (that.elem.is(":visible")) {
|
514
|
+
if (this) {
|
515
|
+
this.call();
|
516
|
+
}
|
517
|
+
// Declare that the notice has completed animating.
|
518
|
+
that.animating = false;
|
519
|
+
} else {
|
520
|
+
that.animTimer = setTimeout(callback, 40);
|
521
|
+
}
|
522
|
+
}).bind(callback);
|
523
|
+
|
524
|
+
if (this.options.animation === "fade") {
|
525
|
+
this.elem.one('webkitTransitionEnd mozTransitionEnd MSTransitionEnd oTransitionEnd transitionend', callback).addClass("ui-pnotify-in");
|
526
|
+
this.elem.css("opacity"); // This line is necessary for some reason. Some notices don't fade without it.
|
527
|
+
this.elem.addClass("ui-pnotify-fade-in");
|
528
|
+
// Just in case the event doesn't fire, call it after 650 ms.
|
529
|
+
this.animTimer = setTimeout(callback, 650);
|
530
|
+
} else {
|
531
|
+
this.elem.addClass("ui-pnotify-in");
|
532
|
+
callback();
|
533
|
+
}
|
534
|
+
},
|
535
|
+
|
536
|
+
// Animate the notice out.
|
537
|
+
animateOut: function(callback){
|
538
|
+
// Declare that the notice is animating out.
|
539
|
+
this.animating = "out";
|
540
|
+
var that = this;
|
541
|
+
callback = (function(){
|
542
|
+
if (that.animTimer) {
|
543
|
+
clearTimeout(that.animTimer);
|
544
|
+
}
|
545
|
+
if (that.animating !== "out") {
|
546
|
+
return;
|
547
|
+
}
|
548
|
+
if (that.elem.css("opacity") == "0" || !that.elem.is(":visible")) {
|
549
|
+
that.elem.removeClass("ui-pnotify-in");
|
550
|
+
if (this) {
|
551
|
+
this.call();
|
552
|
+
}
|
553
|
+
// Declare that the notice has completed animating.
|
554
|
+
that.animating = false;
|
555
|
+
} else {
|
556
|
+
// In case this was called before the notice finished animating.
|
557
|
+
that.animTimer = setTimeout(callback, 40);
|
558
|
+
}
|
559
|
+
}).bind(callback);
|
560
|
+
|
561
|
+
if (this.options.animation === "fade") {
|
562
|
+
this.elem.one('webkitTransitionEnd mozTransitionEnd MSTransitionEnd oTransitionEnd transitionend', callback).removeClass("ui-pnotify-fade-in");
|
563
|
+
// Just in case the event doesn't fire, call it after 650 ms.
|
564
|
+
this.animTimer = setTimeout(callback, 650);
|
565
|
+
} else {
|
566
|
+
this.elem.removeClass("ui-pnotify-in");
|
567
|
+
callback();
|
568
|
+
}
|
569
|
+
},
|
570
|
+
|
571
|
+
// Position the notice. dont_skip_hidden causes the notice to
|
572
|
+
// position even if it's not visible.
|
573
|
+
position: function(dontSkipHidden){
|
574
|
+
// Get the notice's stack.
|
575
|
+
var stack = this.options.stack,
|
576
|
+
elem = this.elem;
|
577
|
+
if (typeof stack.context === "undefined") {
|
578
|
+
stack.context = body;
|
579
|
+
}
|
580
|
+
if (!stack) {
|
581
|
+
return;
|
582
|
+
}
|
583
|
+
if (typeof stack.nextpos1 !== "number") {
|
584
|
+
stack.nextpos1 = stack.firstpos1;
|
585
|
+
}
|
586
|
+
if (typeof stack.nextpos2 !== "number") {
|
587
|
+
stack.nextpos2 = stack.firstpos2;
|
588
|
+
}
|
589
|
+
if (typeof stack.addpos2 !== "number") {
|
590
|
+
stack.addpos2 = 0;
|
591
|
+
}
|
592
|
+
var hidden = !elem.hasClass("ui-pnotify-in");
|
593
|
+
// Skip this notice if it's not shown.
|
594
|
+
if (!hidden || dontSkipHidden) {
|
595
|
+
if (stack.modal) {
|
596
|
+
if (stack.overlay) {
|
597
|
+
stack.overlay.show();
|
598
|
+
} else {
|
599
|
+
stack.overlay = createStackOverlay(stack);
|
600
|
+
}
|
601
|
+
}
|
602
|
+
// Add animate class by default.
|
603
|
+
elem.addClass("ui-pnotify-move");
|
604
|
+
var curpos1, curpos2;
|
605
|
+
// Calculate the current pos1 value.
|
606
|
+
var csspos1;
|
607
|
+
switch (stack.dir1) {
|
608
|
+
case "down":
|
609
|
+
csspos1 = "top";
|
610
|
+
break;
|
611
|
+
case "up":
|
612
|
+
csspos1 = "bottom";
|
613
|
+
break;
|
614
|
+
case "left":
|
615
|
+
csspos1 = "right";
|
616
|
+
break;
|
617
|
+
case "right":
|
618
|
+
csspos1 = "left";
|
619
|
+
break;
|
620
|
+
}
|
621
|
+
curpos1 = parseInt(elem.css(csspos1).replace(/(?:\..*|[^0-9.])/g, ''));
|
622
|
+
if (isNaN(curpos1)) {
|
623
|
+
curpos1 = 0;
|
624
|
+
}
|
625
|
+
// Remember the first pos1, so the first visible notice goes there.
|
626
|
+
if (typeof stack.firstpos1 === "undefined" && !hidden) {
|
627
|
+
stack.firstpos1 = curpos1;
|
628
|
+
stack.nextpos1 = stack.firstpos1;
|
629
|
+
}
|
630
|
+
// Calculate the current pos2 value.
|
631
|
+
var csspos2;
|
632
|
+
switch (stack.dir2) {
|
633
|
+
case "down":
|
634
|
+
csspos2 = "top";
|
635
|
+
break;
|
636
|
+
case "up":
|
637
|
+
csspos2 = "bottom";
|
638
|
+
break;
|
639
|
+
case "left":
|
640
|
+
csspos2 = "right";
|
641
|
+
break;
|
642
|
+
case "right":
|
643
|
+
csspos2 = "left";
|
644
|
+
break;
|
645
|
+
}
|
646
|
+
curpos2 = parseInt(elem.css(csspos2).replace(/(?:\..*|[^0-9.])/g, ''));
|
647
|
+
if (isNaN(curpos2)) {
|
648
|
+
curpos2 = 0;
|
649
|
+
}
|
650
|
+
// Remember the first pos2, so the first visible notice goes there.
|
651
|
+
if (typeof stack.firstpos2 === "undefined" && !hidden) {
|
652
|
+
stack.firstpos2 = curpos2;
|
653
|
+
stack.nextpos2 = stack.firstpos2;
|
654
|
+
}
|
655
|
+
// Check that it's not beyond the viewport edge.
|
656
|
+
if (
|
657
|
+
(stack.dir1 === "down" && stack.nextpos1 + elem.height() > (stack.context.is(body) ? jwindow.height() : stack.context.prop('scrollHeight')) ) ||
|
658
|
+
(stack.dir1 === "up" && stack.nextpos1 + elem.height() > (stack.context.is(body) ? jwindow.height() : stack.context.prop('scrollHeight')) ) ||
|
659
|
+
(stack.dir1 === "left" && stack.nextpos1 + elem.width() > (stack.context.is(body) ? jwindow.width() : stack.context.prop('scrollWidth')) ) ||
|
660
|
+
(stack.dir1 === "right" && stack.nextpos1 + elem.width() > (stack.context.is(body) ? jwindow.width() : stack.context.prop('scrollWidth')) )
|
661
|
+
) {
|
662
|
+
// If it is, it needs to go back to the first pos1, and over on pos2.
|
663
|
+
stack.nextpos1 = stack.firstpos1;
|
664
|
+
stack.nextpos2 += stack.addpos2 + (typeof stack.spacing2 === "undefined" ? 25 : stack.spacing2);
|
665
|
+
stack.addpos2 = 0;
|
666
|
+
}
|
667
|
+
if (typeof stack.nextpos2 === "number") {
|
668
|
+
if (!stack.animation) {
|
669
|
+
elem.removeClass("ui-pnotify-move");
|
670
|
+
elem.css(csspos2, stack.nextpos2+"px");
|
671
|
+
elem.css(csspos2);
|
672
|
+
elem.addClass("ui-pnotify-move");
|
673
|
+
} else {
|
674
|
+
elem.css(csspos2, stack.nextpos2+"px");
|
675
|
+
}
|
676
|
+
}
|
677
|
+
// Keep track of the widest/tallest notice in the column/row, so we can push the next column/row.
|
678
|
+
switch (stack.dir2) {
|
679
|
+
case "down":
|
680
|
+
case "up":
|
681
|
+
if (elem.outerHeight(true) > stack.addpos2) {
|
682
|
+
stack.addpos2 = elem.height();
|
683
|
+
}
|
684
|
+
break;
|
685
|
+
case "left":
|
686
|
+
case "right":
|
687
|
+
if (elem.outerWidth(true) > stack.addpos2) {
|
688
|
+
stack.addpos2 = elem.width();
|
689
|
+
}
|
690
|
+
break;
|
691
|
+
}
|
692
|
+
// Move the notice on dir1.
|
693
|
+
if (typeof stack.nextpos1 === "number") {
|
694
|
+
if (!stack.animation) {
|
695
|
+
elem.removeClass("ui-pnotify-move");
|
696
|
+
elem.css(csspos1, stack.nextpos1+"px");
|
697
|
+
elem.css(csspos1);
|
698
|
+
elem.addClass("ui-pnotify-move");
|
699
|
+
} else {
|
700
|
+
elem.css(csspos1, stack.nextpos1+"px");
|
701
|
+
}
|
702
|
+
}
|
703
|
+
// Calculate the next dir1 position.
|
704
|
+
switch (stack.dir1) {
|
705
|
+
case "down":
|
706
|
+
case "up":
|
707
|
+
stack.nextpos1 += elem.height() + (typeof stack.spacing1 === "undefined" ? 25 : stack.spacing1);
|
708
|
+
break;
|
709
|
+
case "left":
|
710
|
+
case "right":
|
711
|
+
stack.nextpos1 += elem.width() + (typeof stack.spacing1 === "undefined" ? 25 : stack.spacing1);
|
712
|
+
break;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
return this;
|
716
|
+
},
|
717
|
+
// Queue the position all function so it doesn't run repeatedly and
|
718
|
+
// use up resources.
|
719
|
+
queuePosition: function(animate, milliseconds){
|
720
|
+
if (posTimer) {
|
721
|
+
clearTimeout(posTimer);
|
722
|
+
}
|
723
|
+
if (!milliseconds) {
|
724
|
+
milliseconds = 10;
|
725
|
+
}
|
726
|
+
posTimer = setTimeout(function(){
|
727
|
+
PNotify.positionAll(animate);
|
728
|
+
}, milliseconds);
|
729
|
+
return this;
|
730
|
+
},
|
731
|
+
|
732
|
+
|
733
|
+
// Cancel any pending removal timer.
|
734
|
+
cancelRemove: function(){
|
735
|
+
if (this.timer) {
|
736
|
+
root.clearTimeout(this.timer);
|
737
|
+
}
|
738
|
+
if (this.animTimer) {
|
739
|
+
root.clearTimeout(this.animTimer);
|
740
|
+
}
|
741
|
+
if (this.state === "closing") {
|
742
|
+
// If it's animating out, stop it.
|
743
|
+
this.state = "open";
|
744
|
+
this.animating = false;
|
745
|
+
this.elem.addClass("ui-pnotify-in");
|
746
|
+
if (this.options.animation === "fade") {
|
747
|
+
this.elem.addClass("ui-pnotify-fade-in");
|
748
|
+
}
|
749
|
+
}
|
750
|
+
return this;
|
751
|
+
},
|
752
|
+
// Queue a removal timer.
|
753
|
+
queueRemove: function(){
|
754
|
+
var that = this;
|
755
|
+
// Cancel any current removal timer.
|
756
|
+
this.cancelRemove();
|
757
|
+
this.timer = root.setTimeout(function(){
|
758
|
+
that.remove(true);
|
759
|
+
}, (isNaN(this.options.delay) ? 0 : this.options.delay));
|
760
|
+
return this;
|
761
|
+
}
|
762
|
+
});
|
763
|
+
// These functions affect all notices.
|
764
|
+
$.extend(PNotify, {
|
765
|
+
// This holds all the notices.
|
766
|
+
notices: [],
|
767
|
+
reload: init,
|
768
|
+
removeAll: function(){
|
769
|
+
$.each(PNotify.notices, function(){
|
770
|
+
if (this.remove) {
|
771
|
+
this.remove(false);
|
772
|
+
}
|
773
|
+
});
|
774
|
+
},
|
775
|
+
removeStack: function(stack){
|
776
|
+
$.each(PNotify.notices, function(){
|
777
|
+
if (this.remove && this.options.stack === stack) {
|
778
|
+
this.remove(false);
|
779
|
+
}
|
780
|
+
});
|
781
|
+
},
|
782
|
+
positionAll: function(animate){
|
783
|
+
// This timer is used for queueing this function so it doesn't run
|
784
|
+
// repeatedly.
|
785
|
+
if (posTimer) {
|
786
|
+
clearTimeout(posTimer);
|
787
|
+
}
|
788
|
+
posTimer = null;
|
789
|
+
// Reset the next position data.
|
790
|
+
if (PNotify.notices && PNotify.notices.length) {
|
791
|
+
$.each(PNotify.notices, function(){
|
792
|
+
var s = this.options.stack;
|
793
|
+
if (!s) {
|
794
|
+
return;
|
795
|
+
}
|
796
|
+
if (s.overlay) {
|
797
|
+
s.overlay.hide();
|
798
|
+
}
|
799
|
+
s.nextpos1 = s.firstpos1;
|
800
|
+
s.nextpos2 = s.firstpos2;
|
801
|
+
s.addpos2 = 0;
|
802
|
+
s.animation = animate;
|
803
|
+
});
|
804
|
+
$.each(PNotify.notices, function(){
|
805
|
+
this.position();
|
806
|
+
});
|
807
|
+
} else {
|
808
|
+
var s = PNotify.prototype.options.stack;
|
809
|
+
if (s) {
|
810
|
+
delete s.nextpos1;
|
811
|
+
delete s.nextpos2;
|
812
|
+
}
|
813
|
+
}
|
814
|
+
},
|
815
|
+
styling: {
|
816
|
+
brighttheme: {
|
817
|
+
// Bright Theme doesn't require any UI libraries.
|
818
|
+
container: "brighttheme",
|
819
|
+
notice: "brighttheme-notice",
|
820
|
+
notice_icon: "brighttheme-icon-notice",
|
821
|
+
info: "brighttheme-info",
|
822
|
+
info_icon: "brighttheme-icon-info",
|
823
|
+
success: "brighttheme-success",
|
824
|
+
success_icon: "brighttheme-icon-success",
|
825
|
+
error: "brighttheme-error",
|
826
|
+
error_icon: "brighttheme-icon-error"
|
827
|
+
},
|
828
|
+
jqueryui: {
|
829
|
+
container: "ui-widget ui-widget-content ui-corner-all",
|
830
|
+
notice: "ui-state-highlight",
|
831
|
+
// (The actual jQUI notice icon looks terrible.)
|
832
|
+
notice_icon: "ui-icon ui-icon-info",
|
833
|
+
info: "",
|
834
|
+
info_icon: "ui-icon ui-icon-info",
|
835
|
+
success: "ui-state-default",
|
836
|
+
success_icon: "ui-icon ui-icon-circle-check",
|
837
|
+
error: "ui-state-error",
|
838
|
+
error_icon: "ui-icon ui-icon-alert"
|
839
|
+
},
|
840
|
+
bootstrap3: {
|
841
|
+
container: "alert",
|
842
|
+
notice: "alert-warning",
|
843
|
+
notice_icon: "glyphicon glyphicon-exclamation-sign",
|
844
|
+
info: "alert-info",
|
845
|
+
info_icon: "glyphicon glyphicon-info-sign",
|
846
|
+
success: "alert-success",
|
847
|
+
success_icon: "glyphicon glyphicon-ok-sign",
|
848
|
+
error: "alert-danger",
|
849
|
+
error_icon: "glyphicon glyphicon-warning-sign"
|
850
|
+
}
|
851
|
+
}
|
852
|
+
});
|
853
|
+
/*
|
854
|
+
* uses icons from http://fontawesome.io/
|
855
|
+
* version 4.0.3
|
856
|
+
*/
|
857
|
+
PNotify.styling.fontawesome = $.extend({}, PNotify.styling.bootstrap3);
|
858
|
+
$.extend(PNotify.styling.fontawesome, {
|
859
|
+
notice_icon: "fa fa-exclamation-circle",
|
860
|
+
info_icon: "fa fa-info",
|
861
|
+
success_icon: "fa fa-check",
|
862
|
+
error_icon: "fa fa-warning"
|
863
|
+
});
|
864
|
+
|
865
|
+
if (root.document.body) {
|
866
|
+
do_when_ready();
|
867
|
+
} else {
|
868
|
+
$(do_when_ready);
|
869
|
+
}
|
870
|
+
return PNotify;
|
871
|
+
};
|
872
|
+
return init(root);
|
873
|
+
}));
|