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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pnotify-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/pnotify/index.js +5 -1
  4. data/vendor/assets/javascripts/pnotify/pnotify.animate.js +108 -0
  5. data/vendor/assets/javascripts/pnotify/pnotify.buttons.js +165 -121
  6. data/vendor/assets/javascripts/pnotify/pnotify.callbacks.js +42 -40
  7. data/vendor/assets/javascripts/pnotify/pnotify.confirm.js +145 -139
  8. data/vendor/assets/javascripts/pnotify/pnotify.desktop.js +144 -133
  9. data/vendor/assets/javascripts/pnotify/pnotify.history.js +172 -171
  10. data/vendor/assets/javascripts/pnotify/pnotify.js +873 -0
  11. data/vendor/assets/javascripts/pnotify/pnotify.mobile.js +121 -0
  12. data/vendor/assets/javascripts/pnotify/pnotify.nonblock.js +144 -139
  13. data/vendor/assets/javascripts/pnotify/pnotify.reference.js +131 -116
  14. data/vendor/assets/javascripts/pnotify/pnotify.tooltip.js +15 -0
  15. data/vendor/assets/stylesheets/pnotify/index.css +5 -2
  16. data/vendor/assets/stylesheets/pnotify/pnotify.brighttheme.css +165 -0
  17. data/vendor/assets/stylesheets/pnotify/pnotify.buttons.css +2 -2
  18. data/vendor/assets/stylesheets/pnotify/pnotify.css +112 -0
  19. data/vendor/assets/stylesheets/pnotify/pnotify.history.css +22 -22
  20. data/vendor/assets/stylesheets/pnotify/pnotify.material.css +121 -0
  21. data/vendor/assets/stylesheets/pnotify/pnotify.mobile.css +46 -0
  22. data/vendor/assets/stylesheets/pnotify/pnotify.nonblock.css +7 -0
  23. metadata +12 -6
  24. data/vendor/assets/javascripts/pnotify/pnotify.core.js +0 -778
  25. data/vendor/assets/stylesheets/pnotify/pnotify.core.css +0 -56
  26. data/vendor/assets/stylesheets/pnotify/pnotify.picon.css +0 -11
@@ -0,0 +1,46 @@
1
+ .ui-pnotify-container {
2
+ position: relative;
3
+ left: 0;
4
+ }
5
+ @media (max-width: 480px) {
6
+ /* -- Notice */
7
+ .ui-pnotify-mobile-able.ui-pnotify {
8
+ position: fixed;
9
+ top: 0;
10
+ right: 0;
11
+ left: 0;
12
+ width: auto !important;
13
+ font-size: 1.2em;
14
+ -webkit-font-smoothing: antialiased;
15
+ -moz-font-smoothing: antialiased;
16
+ -ms-font-smoothing: antialiased;
17
+ font-smoothing: antialiased;
18
+ }
19
+ .ui-pnotify-mobile-able.ui-pnotify .ui-pnotify-shadow {
20
+ -webkit-box-shadow: none;
21
+ -moz-box-shadow: none;
22
+ box-shadow: none;
23
+ border-bottom-width: 5px;
24
+ }
25
+ .ui-pnotify-mobile-able .ui-pnotify-container {
26
+ -webkit-border-radius: 0;
27
+ -moz-border-radius: 0;
28
+ border-radius: 0;
29
+ }
30
+ /* Alternate stack initial positioning. */
31
+ .ui-pnotify-mobile-able.ui-pnotify.stack-topleft, .ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft {
32
+ left: 0;
33
+ right: 0;
34
+ }
35
+ .ui-pnotify-mobile-able.ui-pnotify.stack-bottomright, .ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft {
36
+ left: 0;
37
+ right: 0;
38
+ bottom: 0;
39
+ top: auto;
40
+ }
41
+ .ui-pnotify-mobile-able.ui-pnotify.stack-bottomright .ui-pnotify-shadow, .ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft .ui-pnotify-shadow {
42
+ border-top-width: 5px;
43
+ border-bottom-width: 1px;
44
+ }
45
+
46
+ }
@@ -0,0 +1,7 @@
1
+ .ui-pnotify.ui-pnotify-nonblock-fade {
2
+ /*transition: opacity .3s ease;*/
3
+ opacity: .2;
4
+ }
5
+ .ui-pnotify.ui-pnotify-nonblock-hide {
6
+ display: none !important;
7
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pnotify-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Navin Peiris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2016-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,19 +38,25 @@ files:
38
38
  - lib/pnotify-rails/railtie.rb
39
39
  - lib/pnotify-rails/version.rb
40
40
  - vendor/assets/javascripts/pnotify/index.js
41
+ - vendor/assets/javascripts/pnotify/pnotify.animate.js
41
42
  - vendor/assets/javascripts/pnotify/pnotify.buttons.js
42
43
  - vendor/assets/javascripts/pnotify/pnotify.callbacks.js
43
44
  - vendor/assets/javascripts/pnotify/pnotify.confirm.js
44
- - vendor/assets/javascripts/pnotify/pnotify.core.js
45
45
  - vendor/assets/javascripts/pnotify/pnotify.desktop.js
46
46
  - vendor/assets/javascripts/pnotify/pnotify.history.js
47
+ - vendor/assets/javascripts/pnotify/pnotify.js
48
+ - vendor/assets/javascripts/pnotify/pnotify.mobile.js
47
49
  - vendor/assets/javascripts/pnotify/pnotify.nonblock.js
48
50
  - vendor/assets/javascripts/pnotify/pnotify.reference.js
51
+ - vendor/assets/javascripts/pnotify/pnotify.tooltip.js
49
52
  - vendor/assets/stylesheets/pnotify/index.css
53
+ - vendor/assets/stylesheets/pnotify/pnotify.brighttheme.css
50
54
  - vendor/assets/stylesheets/pnotify/pnotify.buttons.css
51
- - vendor/assets/stylesheets/pnotify/pnotify.core.css
55
+ - vendor/assets/stylesheets/pnotify/pnotify.css
52
56
  - vendor/assets/stylesheets/pnotify/pnotify.history.css
53
- - vendor/assets/stylesheets/pnotify/pnotify.picon.css
57
+ - vendor/assets/stylesheets/pnotify/pnotify.material.css
58
+ - vendor/assets/stylesheets/pnotify/pnotify.mobile.css
59
+ - vendor/assets/stylesheets/pnotify/pnotify.nonblock.css
54
60
  homepage: https://github.com/navinpeiris/pnotify-rails
55
61
  licenses:
56
62
  - MIT
@@ -71,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
77
  version: '0'
72
78
  requirements: []
73
79
  rubyforge_project:
74
- rubygems_version: 2.2.2
80
+ rubygems_version: 2.5.1
75
81
  signing_key:
76
82
  specification_version: 4
77
83
  summary: Pines Notify is a JavaScript notification plugin developed by Hunter Perrin
@@ -1,778 +0,0 @@
1
- /*
2
- PNotify 2.0.1 sciactive.com/pnotify/
3
- (C) 2014 Hunter Perrin
4
- license GPL/LGPL/MPL
5
- */
6
- /*
7
- * ====== PNotify ======
8
- *
9
- * http://sciactive.com/pnotify/
10
- *
11
- * Copyright 2009-2014 Hunter Perrin
12
- *
13
- * Triple licensed under the GPL, LGPL, and MPL.
14
- * http://gnu.org/licenses/gpl.html
15
- * http://gnu.org/licenses/lgpl.html
16
- * http://mozilla.org/MPL/MPL-1.1.html
17
- */
18
-
19
- // Uses AMD or browser globals for jQuery.
20
- (function (factory) {
21
- if (typeof define === 'function' && define.amd) {
22
- // AMD. Register as a module.
23
- define('pnotify', ['jquery'], factory);
24
- } else {
25
- // Browser globals
26
- factory(jQuery);
27
- }
28
- }(function($){
29
- var default_stack = {
30
- dir1: "down",
31
- dir2: "left",
32
- push: "bottom",
33
- spacing1: 25,
34
- spacing2: 25,
35
- context: $("body")
36
- };
37
- var timer, // Position all timer.
38
- body,
39
- jwindow = $(window);
40
- // Set global variables.
41
- var do_when_ready = function(){
42
- body = $("body");
43
- PNotify.prototype.options.stack.context = body;
44
- jwindow = $(window);
45
- // Reposition the notices when the window resizes.
46
- jwindow.bind('resize', function(){
47
- if (timer)
48
- clearTimeout(timer);
49
- timer = setTimeout(function(){ PNotify.positionAll(true) }, 10);
50
- });
51
- };
52
- PNotify = function(options){
53
- this.parseOptions(options);
54
- this.init();
55
- };
56
- $.extend(PNotify.prototype, {
57
- // The current version of PNotify.
58
- version: "2.0.1",
59
-
60
- // === Options ===
61
-
62
- // Options defaults.
63
- options: {
64
- // The notice's title.
65
- title: false,
66
- // Whether to escape the content of the title. (Not allow HTML.)
67
- title_escape: false,
68
- // The notice's text.
69
- text: false,
70
- // Whether to escape the content of the text. (Not allow HTML.)
71
- text_escape: false,
72
- // What styling classes to use. (Can be either jqueryui or bootstrap.)
73
- styling: "bootstrap3",
74
- // Additional classes to be added to the notice. (For custom styling.)
75
- addclass: "",
76
- // Class to be added to the notice for corner styling.
77
- cornerclass: "",
78
- // Display the notice when it is created.
79
- auto_display: true,
80
- // Width of the notice.
81
- width: "300px",
82
- // Minimum height of the notice. It will expand to fit content.
83
- min_height: "16px",
84
- // Type of the notice. "notice", "info", "success", or "error".
85
- type: "notice",
86
- // Set icon to true to use the default icon for the selected
87
- // style/type, false for no icon, or a string for your own icon class.
88
- icon: true,
89
- // Opacity of the notice.
90
- opacity: 1,
91
- // The animation to use when displaying and hiding the notice. "none",
92
- // "show", "fade", and "slide" are built in to jQuery. Others require jQuery
93
- // UI. Use an object with effect_in and effect_out to use different effects.
94
- animation: "fade",
95
- // Speed at which the notice animates in and out. "slow", "def" or "normal",
96
- // "fast" or number of milliseconds.
97
- animate_speed: "slow",
98
- // Specify a specific duration of position animation
99
- position_animate_speed: 500,
100
- // Display a drop shadow.
101
- shadow: true,
102
- // After a delay, remove the notice.
103
- hide: true,
104
- // Delay in milliseconds before the notice is removed.
105
- delay: 8000,
106
- // Reset the hide timer if the mouse moves over the notice.
107
- mouse_reset: true,
108
- // Remove the notice's elements from the DOM after it is removed.
109
- remove: true,
110
- // Change new lines to br tags.
111
- insert_brs: true,
112
- // Whether to remove notices from the global array.
113
- destroy: true,
114
- // The stack on which the notices will be placed. Also controls the
115
- // direction the notices stack.
116
- stack: default_stack
117
- },
118
-
119
- // === Modules ===
120
-
121
- // This object holds all the PNotify modules. They are used to provide
122
- // additional functionality.
123
- modules: {},
124
- // This runs an event on all the modules.
125
- runModules: function(event, arg){
126
- var curArg;
127
- for (var module in this.modules) {
128
- curArg = ((typeof arg === "object" && module in arg) ? arg[module] : arg);
129
- if (typeof this.modules[module][event] === 'function')
130
- this.modules[module][event](this, typeof this.options[module] === 'object' ? this.options[module] : {}, curArg);
131
- }
132
- },
133
-
134
- // === Class Variables ===
135
-
136
- state: "initializing", // The state can be "initializing", "opening", "open", "closing", and "closed".
137
- timer: null, // Auto close timer.
138
- styles: null,
139
- elem: null,
140
- container: null,
141
- title_container: null,
142
- text_container: null,
143
- animating: false, // Stores what is currently being animated (in or out).
144
- timerHide: false, // Stores whether the notice was hidden by a timer.
145
-
146
- // === Events ===
147
-
148
- init: function(){
149
- var that = this;
150
-
151
- // First and foremost, we don't want our module objects all referencing the prototype.
152
- this.modules = {};
153
- $.extend(true, this.modules, PNotify.prototype.modules);
154
-
155
- // Get our styling object.
156
- if (typeof this.options.styling === "object") {
157
- this.styles = this.options.styling;
158
- } else {
159
- this.styles = PNotify.styling[this.options.styling];
160
- }
161
-
162
- // Create our widget.
163
- // Stop animation, reset the removal timer when the user mouses over.
164
- this.elem = $("<div />", {
165
- "class": "ui-pnotify "+this.options.addclass,
166
- "css": {"display": "none"},
167
- "mouseenter": function(e){
168
- if (that.options.mouse_reset && that.animating === "out") {
169
- if (!that.timerHide)
170
- return;
171
- that.cancelRemove();
172
- }
173
- // Stop the close timer.
174
- if (that.options.hide && that.options.mouse_reset) that.cancelRemove();
175
- },
176
- "mouseleave": function(e){
177
- // Start the close timer.
178
- if (that.options.hide && that.options.mouse_reset) that.queueRemove();
179
- PNotify.positionAll();
180
- }
181
- });
182
- // Create a container for the notice contents.
183
- this.container = $("<div />", {"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)))})
184
- .appendTo(this.elem);
185
- if (this.options.cornerclass !== "")
186
- this.container.removeClass("ui-corner-all").addClass(this.options.cornerclass);
187
- // Create a drop shadow.
188
- if (this.options.shadow)
189
- this.container.addClass("ui-pnotify-shadow");
190
-
191
-
192
- // Add the appropriate icon.
193
- if (this.options.icon !== false) {
194
- $("<div />", {"class": "ui-pnotify-icon"})
195
- .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}))
196
- .prependTo(this.container);
197
- }
198
-
199
- // Add a title.
200
- this.title_container = $("<h4 />", {
201
- "class": "ui-pnotify-title"
202
- })
203
- .appendTo(this.container);
204
- if (this.options.title === false)
205
- this.title_container.hide();
206
- else if (this.options.title_escape)
207
- this.title_container.text(this.options.title);
208
- else
209
- this.title_container.html(this.options.title);
210
-
211
- // Add text.
212
- this.text_container = $("<div />", {
213
- "class": "ui-pnotify-text"
214
- })
215
- .appendTo(this.container);
216
- if (this.options.text === false)
217
- this.text_container.hide();
218
- else if (this.options.text_escape)
219
- this.text_container.text(this.options.text);
220
- else
221
- this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "<br />") : this.options.text);
222
-
223
- // Set width and min height.
224
- if (typeof this.options.width === "string")
225
- this.elem.css("width", this.options.width);
226
- if (typeof this.options.min_height === "string")
227
- this.container.css("min-height", this.options.min_height);
228
-
229
-
230
- // Add the notice to the notice array.
231
- if (this.options.stack.push === "top")
232
- PNotify.notices = $.merge([this], PNotify.notices);
233
- else
234
- PNotify.notices = $.merge(PNotify.notices, [this]);
235
- // Now position all the notices if they are to push to the top.
236
- if (this.options.stack.push === "top")
237
- this.queuePosition(false, 1);
238
-
239
-
240
-
241
-
242
- // Mark the stack so it won't animate the new notice.
243
- this.options.stack.animation = false;
244
-
245
- // Run the modules.
246
- this.runModules('init');
247
-
248
- // Display the notice.
249
- if (this.options.auto_display)
250
- this.open();
251
- return this;
252
- },
253
-
254
- // This function is for updating the notice.
255
- update: function(options){
256
- // Save old options.
257
- var oldOpts = this.options;
258
- // Then update to the new options.
259
- this.parseOptions(oldOpts, options);
260
- // Update the corner class.
261
- if (this.options.cornerclass !== oldOpts.cornerclass)
262
- this.container.removeClass("ui-corner-all "+oldOpts.cornerclass).addClass(this.options.cornerclass);
263
- // Update the shadow.
264
- if (this.options.shadow !== oldOpts.shadow) {
265
- if (this.options.shadow)
266
- this.container.addClass("ui-pnotify-shadow");
267
- else
268
- this.container.removeClass("ui-pnotify-shadow");
269
- }
270
- // Update the additional classes.
271
- if (this.options.addclass === false)
272
- this.elem.removeClass(oldOpts.addclass);
273
- else if (this.options.addclass !== oldOpts.addclass)
274
- this.elem.removeClass(oldOpts.addclass).addClass(this.options.addclass);
275
- // Update the title.
276
- if (this.options.title === false)
277
- this.title_container.slideUp("fast");
278
- else if (this.options.title !== oldOpts.title) {
279
- if (this.options.title_escape)
280
- this.title_container.text(this.options.title);
281
- else
282
- this.title_container.html(this.options.title);
283
- if (oldOpts.title === false)
284
- this.title_container.slideDown(200)
285
- }
286
- // Update the text.
287
- if (this.options.text === false) {
288
- this.text_container.slideUp("fast");
289
- } else if (this.options.text !== oldOpts.text) {
290
- if (this.options.text_escape)
291
- this.text_container.text(this.options.text);
292
- else
293
- this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "<br />") : this.options.text);
294
- if (oldOpts.text === false)
295
- this.text_container.slideDown(200)
296
- }
297
- // Change the notice type.
298
- if (this.options.type !== oldOpts.type)
299
- this.container.removeClass(
300
- this.styles.error+" "+this.styles.notice+" "+this.styles.success+" "+this.styles.info
301
- ).addClass(this.options.type === "error" ?
302
- this.styles.error :
303
- (this.options.type === "info" ?
304
- this.styles.info :
305
- (this.options.type === "success" ?
306
- this.styles.success :
307
- this.styles.notice
308
- )
309
- )
310
- );
311
- if (this.options.icon !== oldOpts.icon || (this.options.icon === true && this.options.type !== oldOpts.type)) {
312
- // Remove any old icon.
313
- this.container.find("div.ui-pnotify-icon").remove();
314
- if (this.options.icon !== false) {
315
- // Build the new icon.
316
- $("<div />", {"class": "ui-pnotify-icon"})
317
- .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}))
318
- .prependTo(this.container);
319
- }
320
- }
321
- // Update the width.
322
- if (this.options.width !== oldOpts.width)
323
- this.elem.animate({width: this.options.width});
324
- // Update the minimum height.
325
- if (this.options.min_height !== oldOpts.min_height)
326
- this.container.animate({minHeight: this.options.min_height});
327
- // Update the opacity.
328
- if (this.options.opacity !== oldOpts.opacity)
329
- this.elem.fadeTo(this.options.animate_speed, this.options.opacity);
330
- // Update the timed hiding.
331
- if (!this.options.hide)
332
- this.cancelRemove();
333
- else if (!oldOpts.hide)
334
- this.queueRemove();
335
- this.queuePosition(true);
336
-
337
- // Run the modules.
338
- this.runModules('update', oldOpts);
339
- return this;
340
- },
341
-
342
- // Display the notice.
343
- open: function(){
344
- this.state = "opening";
345
- // Run the modules.
346
- this.runModules('beforeOpen');
347
-
348
- var that = this;
349
- // If the notice is not in the DOM, append it.
350
- if (!this.elem.parent().length)
351
- this.elem.appendTo(this.options.stack.context ? this.options.stack.context : body);
352
- // Try to put it in the right position.
353
- if (this.options.stack.push !== "top")
354
- this.position(true);
355
- // First show it, then set its opacity, then hide it.
356
- if (this.options.animation === "fade" || this.options.animation.effect_in === "fade") {
357
- // If it's fading in, it should start at 0.
358
- this.elem.show().fadeTo(0, 0).hide();
359
- } else {
360
- // Or else it should be set to the opacity.
361
- if (this.options.opacity !== 1)
362
- this.elem.show().fadeTo(0, this.options.opacity).hide();
363
- }
364
- this.animateIn(function(){
365
- that.queuePosition(true);
366
-
367
- // Now set it to hide.
368
- if (that.options.hide)
369
- that.queueRemove();
370
-
371
- that.state = "open";
372
-
373
- // Run the modules.
374
- that.runModules('afterOpen');
375
- });
376
-
377
- return this;
378
- },
379
-
380
- // Remove the notice.
381
- remove: function(timer_hide) {
382
- this.state = "closing";
383
- this.timerHide = !!timer_hide; // Make sure it's a boolean.
384
- // Run the modules.
385
- this.runModules('beforeClose');
386
-
387
- var that = this;
388
- if (this.timer) {
389
- window.clearTimeout(this.timer);
390
- this.timer = null;
391
- }
392
- this.animateOut(function(){
393
- that.state = "closed";
394
- // Run the modules.
395
- that.runModules('afterClose');
396
- that.queuePosition(true);
397
- // If we're supposed to remove the notice from the DOM, do it.
398
- if (that.options.remove)
399
- that.elem.detach();
400
- // Run the modules.
401
- that.runModules('beforeDestroy');
402
- // Remove object from PNotify.notices to prevent memory leak (issue #49)
403
- // unless destroy is off
404
- if (that.options.destroy) {
405
- if (PNotify.notices !== null) {
406
- var idx = $.inArray(that,PNotify.notices);
407
- if (idx !== -1) {
408
- PNotify.notices.splice(idx,1);
409
- }
410
- }
411
- }
412
- // Run the modules.
413
- that.runModules('afterDestroy');
414
- });
415
-
416
- return this;
417
- },
418
-
419
- // === Class Methods ===
420
-
421
- // Get the DOM element.
422
- get: function(){ return this.elem; },
423
-
424
- // Put all the options in the right places.
425
- parseOptions: function(options, moreOptions){
426
- this.options = $.extend(true, {}, PNotify.prototype.options);
427
- // This is the only thing that *should* be copied by reference.
428
- this.options.stack = PNotify.prototype.options.stack;
429
- var optArray = [options, moreOptions], curOpts;
430
- for (var curIndex in optArray) {
431
- curOpts = optArray[curIndex];
432
- if (typeof curOpts == "undefined")
433
- break;
434
- if (typeof curOpts !== 'object') {
435
- this.options.text = curOpts;
436
- } else {
437
- for (var option in curOpts) {
438
- if (this.modules[option]) {
439
- // Avoid overwriting module defaults.
440
- $.extend(true, this.options[option], curOpts[option]);
441
- } else {
442
- this.options[option] = curOpts[option];
443
- }
444
- }
445
- }
446
- }
447
- },
448
-
449
- // Animate the notice in.
450
- animateIn: function(callback){
451
- // Declare that the notice is animating in. (Or has completed animating in.)
452
- this.animating = "in";
453
- var animation;
454
- if (typeof this.options.animation.effect_in !== "undefined")
455
- animation = this.options.animation.effect_in;
456
- else
457
- animation = this.options.animation;
458
- if (animation === "none") {
459
- this.elem.show();
460
- callback();
461
- } else if (animation === "show")
462
- this.elem.show(this.options.animate_speed, callback);
463
- else if (animation === "fade")
464
- this.elem.show().fadeTo(this.options.animate_speed, this.options.opacity, callback);
465
- else if (animation === "slide")
466
- this.elem.slideDown(this.options.animate_speed, callback);
467
- else if (typeof animation === "function")
468
- animation("in", callback, this.elem);
469
- else
470
- this.elem.show(animation, (typeof this.options.animation.options_in === "object" ? this.options.animation.options_in : {}), this.options.animate_speed, callback);
471
- if (this.elem.parent().hasClass('ui-effects-wrapper'))
472
- this.elem.parent().css({"position": "fixed", "overflow": "visible"});
473
- if (animation !== "slide")
474
- this.elem.css("overflow", "visible");
475
- this.container.css("overflow", "hidden");
476
- },
477
-
478
- // Animate the notice out.
479
- animateOut: function(callback){
480
- // Declare that the notice is animating out. (Or has completed animating out.)
481
- this.animating = "out";
482
- var animation;
483
- if (typeof this.options.animation.effect_out !== "undefined")
484
- animation = this.options.animation.effect_out;
485
- else
486
- animation = this.options.animation;
487
- if (animation === "none") {
488
- this.elem.hide();
489
- callback();
490
- } else if (animation === "show")
491
- this.elem.hide(this.options.animate_speed, callback);
492
- else if (animation === "fade")
493
- this.elem.fadeOut(this.options.animate_speed, callback);
494
- else if (animation === "slide")
495
- this.elem.slideUp(this.options.animate_speed, callback);
496
- else if (typeof animation === "function")
497
- animation("out", callback, this.elem);
498
- else
499
- this.elem.hide(animation, (typeof this.options.animation.options_out === "object" ? this.options.animation.options_out : {}), this.options.animate_speed, callback);
500
- if (this.elem.parent().hasClass('ui-effects-wrapper'))
501
- this.elem.parent().css({"position": "fixed", "overflow": "visible"});
502
- if (animation !== "slide")
503
- this.elem.css("overflow", "visible");
504
- this.container.css("overflow", "hidden");
505
- },
506
-
507
- // Position the notice. dont_skip_hidden causes the notice to
508
- // position even if it's not visible.
509
- position: function(dontSkipHidden){
510
- // Get the notice's stack.
511
- var s = this.options.stack,
512
- e = this.elem;
513
- if (e.parent().hasClass('ui-effects-wrapper'))
514
- e = this.elem.css({"left": "0", "top": "0", "right": "0", "bottom": "0"}).parent();
515
- if (typeof s.context === "undefined")
516
- s.context = body;
517
- if (!s) return;
518
- if (typeof s.nextpos1 !== "number")
519
- s.nextpos1 = s.firstpos1;
520
- if (typeof s.nextpos2 !== "number")
521
- s.nextpos2 = s.firstpos2;
522
- if (typeof s.addpos2 !== "number")
523
- s.addpos2 = 0;
524
- var hidden = e.css("display") === "none";
525
- // Skip this notice if it's not shown.
526
- if (!hidden || dontSkipHidden) {
527
- var curpos1, curpos2;
528
- // Store what will need to be animated.
529
- var animate = {};
530
- // Calculate the current pos1 value.
531
- var csspos1;
532
- switch (s.dir1) {
533
- case "down":
534
- csspos1 = "top";
535
- break;
536
- case "up":
537
- csspos1 = "bottom";
538
- break;
539
- case "left":
540
- csspos1 = "right";
541
- break;
542
- case "right":
543
- csspos1 = "left";
544
- break;
545
- }
546
- curpos1 = parseInt(e.css(csspos1).replace(/(?:\..*|[^0-9.])/g, ''));
547
- if (isNaN(curpos1))
548
- curpos1 = 0;
549
- // Remember the first pos1, so the first visible notice goes there.
550
- if (typeof s.firstpos1 === "undefined" && !hidden) {
551
- s.firstpos1 = curpos1;
552
- s.nextpos1 = s.firstpos1;
553
- }
554
- // Calculate the current pos2 value.
555
- var csspos2;
556
- switch (s.dir2) {
557
- case "down":
558
- csspos2 = "top";
559
- break;
560
- case "up":
561
- csspos2 = "bottom";
562
- break;
563
- case "left":
564
- csspos2 = "right";
565
- break;
566
- case "right":
567
- csspos2 = "left";
568
- break;
569
- }
570
- curpos2 = parseInt(e.css(csspos2).replace(/(?:\..*|[^0-9.])/g, ''));
571
- if (isNaN(curpos2))
572
- curpos2 = 0;
573
- // Remember the first pos2, so the first visible notice goes there.
574
- if (typeof s.firstpos2 === "undefined" && !hidden) {
575
- s.firstpos2 = curpos2;
576
- s.nextpos2 = s.firstpos2;
577
- }
578
- // Check that it's not beyond the viewport edge.
579
- if ((s.dir1 === "down" && s.nextpos1 + e.height() > (s.context.is(body) ? jwindow.height() : s.context.prop('scrollHeight')) ) ||
580
- (s.dir1 === "up" && s.nextpos1 + e.height() > (s.context.is(body) ? jwindow.height() : s.context.prop('scrollHeight')) ) ||
581
- (s.dir1 === "left" && s.nextpos1 + e.width() > (s.context.is(body) ? jwindow.width() : s.context.prop('scrollWidth')) ) ||
582
- (s.dir1 === "right" && s.nextpos1 + e.width() > (s.context.is(body) ? jwindow.width() : s.context.prop('scrollWidth')) ) ) {
583
- // If it is, it needs to go back to the first pos1, and over on pos2.
584
- s.nextpos1 = s.firstpos1;
585
- s.nextpos2 += s.addpos2 + (typeof s.spacing2 === "undefined" ? 25 : s.spacing2);
586
- s.addpos2 = 0;
587
- }
588
- // Animate if we're moving on dir2.
589
- if (s.animation && s.nextpos2 < curpos2) {
590
- switch (s.dir2) {
591
- case "down":
592
- animate.top = s.nextpos2+"px";
593
- break;
594
- case "up":
595
- animate.bottom = s.nextpos2+"px";
596
- break;
597
- case "left":
598
- animate.right = s.nextpos2+"px";
599
- break;
600
- case "right":
601
- animate.left = s.nextpos2+"px";
602
- break;
603
- }
604
- } else {
605
- if(typeof s.nextpos2 === "number")
606
- e.css(csspos2, s.nextpos2+"px");
607
- }
608
- // Keep track of the widest/tallest notice in the column/row, so we can push the next column/row.
609
- switch (s.dir2) {
610
- case "down":
611
- case "up":
612
- if (e.outerHeight(true) > s.addpos2)
613
- s.addpos2 = e.height();
614
- break;
615
- case "left":
616
- case "right":
617
- if (e.outerWidth(true) > s.addpos2)
618
- s.addpos2 = e.width();
619
- break;
620
- }
621
- // Move the notice on dir1.
622
- if (typeof s.nextpos1 === "number") {
623
- // Animate if we're moving toward the first pos.
624
- if (s.animation && (curpos1 > s.nextpos1 || animate.top || animate.bottom || animate.right || animate.left)) {
625
- switch (s.dir1) {
626
- case "down":
627
- animate.top = s.nextpos1+"px";
628
- break;
629
- case "up":
630
- animate.bottom = s.nextpos1+"px";
631
- break;
632
- case "left":
633
- animate.right = s.nextpos1+"px";
634
- break;
635
- case "right":
636
- animate.left = s.nextpos1+"px";
637
- break;
638
- }
639
- } else
640
- e.css(csspos1, s.nextpos1+"px");
641
- }
642
- // Run the animation.
643
- if (animate.top || animate.bottom || animate.right || animate.left)
644
- e.animate(animate, {duration: this.options.position_animate_speed, queue: false});
645
- // Calculate the next dir1 position.
646
- switch (s.dir1) {
647
- case "down":
648
- case "up":
649
- s.nextpos1 += e.height() + (typeof s.spacing1 === "undefined" ? 25 : s.spacing1);
650
- break;
651
- case "left":
652
- case "right":
653
- s.nextpos1 += e.width() + (typeof s.spacing1 === "undefined" ? 25 : s.spacing1);
654
- break;
655
- }
656
- }
657
- return this;
658
- },
659
- // Queue the position all function so it doesn't run repeatedly and
660
- // use up resources.
661
- queuePosition: function(animate, milliseconds){
662
- if (timer)
663
- clearTimeout(timer);
664
- if (!milliseconds)
665
- milliseconds = 10;
666
- timer = setTimeout(function(){ PNotify.positionAll(animate) }, milliseconds);
667
- return this;
668
- },
669
-
670
-
671
- // Cancel any pending removal timer.
672
- cancelRemove: function(){
673
- if (this.timer)
674
- window.clearTimeout(this.timer);
675
- if (this.state === "closing") {
676
- // If it's animating out, animate back in really quickly.
677
- this.elem.stop(true);
678
- this.state = "open";
679
- this.animating = "in";
680
- this.elem.css("height", "auto").animate({"width": this.options.width, "opacity": this.options.opacity}, "fast");
681
- }
682
- return this;
683
- },
684
- // Queue a removal timer.
685
- queueRemove: function(){
686
- var that = this;
687
- // Cancel any current removal timer.
688
- this.cancelRemove();
689
- this.timer = window.setTimeout(function(){
690
- that.remove(true);
691
- }, (isNaN(this.options.delay) ? 0 : this.options.delay));
692
- return this;
693
- }
694
- });
695
- // These functions affect all notices.
696
- $.extend(PNotify, {
697
- // This holds all the notices.
698
- notices: [],
699
- removeAll: function () {
700
- $.each(PNotify.notices, function(){
701
- if (this.remove)
702
- this.remove();
703
- });
704
- },
705
- positionAll: function (animate) {
706
- // This timer is used for queueing this function so it doesn't run
707
- // repeatedly.
708
- if (timer)
709
- clearTimeout(timer);
710
- timer = null;
711
- // Reset the next position data.
712
- $.each(PNotify.notices, function(){
713
- var s = this.options.stack;
714
- if (!s) return;
715
- s.nextpos1 = s.firstpos1;
716
- s.nextpos2 = s.firstpos2;
717
- s.addpos2 = 0;
718
- s.animation = animate;
719
- });
720
- $.each(PNotify.notices, function(){
721
- this.position();
722
- });
723
- },
724
- styling: {
725
- jqueryui: {
726
- container: "ui-widget ui-widget-content ui-corner-all",
727
- notice: "ui-state-highlight",
728
- // (The actual jQUI notice icon looks terrible.)
729
- notice_icon: "ui-icon ui-icon-info",
730
- info: "",
731
- info_icon: "ui-icon ui-icon-info",
732
- success: "ui-state-default",
733
- success_icon: "ui-icon ui-icon-circle-check",
734
- error: "ui-state-error",
735
- error_icon: "ui-icon ui-icon-alert"
736
- },
737
- bootstrap2: {
738
- container: "alert",
739
- notice: "",
740
- notice_icon: "icon-exclamation-sign",
741
- info: "alert-info",
742
- info_icon: "icon-info-sign",
743
- success: "alert-success",
744
- success_icon: "icon-ok-sign",
745
- error: "alert-error",
746
- error_icon: "icon-warning-sign"
747
- },
748
- bootstrap3: {
749
- container: "alert",
750
- notice: "alert-warning",
751
- notice_icon: "glyphicon glyphicon-exclamation-sign",
752
- info: "alert-info",
753
- info_icon: "glyphicon glyphicon-info-sign",
754
- success: "alert-success",
755
- success_icon: "glyphicon glyphicon-ok-sign",
756
- error: "alert-danger",
757
- error_icon: "glyphicon glyphicon-warning-sign"
758
- }
759
- }
760
- });
761
- /*
762
- * uses icons from http://fontawesome.io/
763
- * version 4.0.3
764
- */
765
- PNotify.styling.fontawesome = $.extend({}, PNotify.styling.bootstrap3);
766
- $.extend(PNotify.styling.fontawesome, {
767
- notice_icon: "fa fa-exclamation-circle",
768
- info_icon: "fa fa-info",
769
- success_icon: "fa fa-check",
770
- error_icon: "fa fa-warning"
771
- });
772
-
773
- if (document.body)
774
- do_when_ready();
775
- else
776
- $(do_when_ready);
777
- return PNotify;
778
- }));