vendor/assets/javascripts/noty/jquery.noty.js in noty-rails-2.2.9 vs vendor/assets/javascripts/noty/jquery.noty.js in noty-rails-2.3.4
- old
+ new
@@ -1,27 +1,25 @@
/*!
@package noty - jQuery Notification Plugin
- @version version: 2.2.9
+ @version version: 2.3.4
@contributors https://github.com/needim/noty/graphs/contributors
@documentation Examples and Documentation - http://needim.github.com/noty/
@license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php
*/
-if(typeof Object.create !== 'function') {
- Object.create = function(o) {
- function F() {
- }
+ if(typeof Object.create !== 'function') {
+ Object.create = function(o) {
+ function F() {
+ }
- F.prototype = o;
- return new F();
- };
-}
+ F.prototype = o;
+ return new F();
+ };
+ }
-(function($) {
-
var NotyObject = {
init: function(options) {
// Mix in the passed in options with the default options
@@ -74,13 +72,13 @@
var self = this;
$.each(this.options.buttons, function(i, button) {
var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text).attr('id', button.id ? button.id : 'button-' + i)
.appendTo(self.$bar.find('.noty_buttons'))
- .on('click', function() {
+ .on('click', function(event) {
if($.isFunction(button.onClick)) {
- button.onClick.call($button, self);
+ button.onClick.call($button, self, event);
}
});
});
}
@@ -137,20 +135,30 @@
self.$closeButton.remove();
if(self.options.callback.onShow)
self.options.callback.onShow.apply(self);
- self.$bar.animate(
- self.options.animation.open,
- self.options.animation.speed,
- self.options.animation.easing,
- function() {
+ if (typeof self.options.animation.open == 'string') {
+ self.$bar.css('height', self.$bar.innerHeight());
+ self.$bar.show().addClass(self.options.animation.open).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
if(self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
self.showing = false;
self.shown = true;
});
+ } else {
+ self.$bar.animate(
+ self.options.animation.open,
+ self.options.animation.speed,
+ self.options.animation.easing,
+ function() {
+ if(self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
+ self.showing = false;
+ self.shown = true;
+ });
+ }
+
// If noty is have a timeout option
if(self.options.timeout)
self.$bar.delay(self.options.timeout).promise().done(function() {
self.close();
});
@@ -173,12 +181,10 @@
}
);
return;
}
- this.$bar.dequeue();
-
if(!this.shown && !this.showing) { // If we are still waiting in the queue just delete from queue
var queue = [];
$.each($.noty.queue, function(i, n) {
if(n.options.id != self.options.id) {
queue.push(n);
@@ -192,58 +198,86 @@
if(self.options.callback.onClose) {
self.options.callback.onClose.apply(self);
}
- self.$bar.clearQueue().stop().animate(
- self.options.animation.close,
- self.options.animation.speed,
- self.options.animation.easing,
- function() {
+ if (typeof self.options.animation.close == 'string') {
+ self.$bar.addClass(self.options.animation.close).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
if(self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
- })
- .promise().done(function() {
+ self.closeCleanUp();
+ });
+ } else {
+ self.$bar.clearQueue().stop().animate(
+ self.options.animation.close,
+ self.options.animation.speed,
+ self.options.animation.easing,
+ function() {
+ if(self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
+ })
+ .promise().done(function() {
+ self.closeCleanUp();
+ });
+ }
- // Modal Cleaning
- if(self.options.modal) {
- $.notyRenderer.setModalCount(-1);
- if($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function() {
- $(this).remove();
- });
- }
+ }, // end close
- // Layout Cleaning
- $.notyRenderer.setLayoutCountFor(self, -1);
- if($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
+ closeCleanUp: function() {
- // Make sure self.$bar has not been removed before attempting to remove it
- if(typeof self.$bar !== 'undefined' && self.$bar !== null) {
+ var self = this;
+
+ // Modal Cleaning
+ if(self.options.modal) {
+ $.notyRenderer.setModalCount(-1);
+ if($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function() {
+ $(this).remove();
+ });
+ }
+
+ // Layout Cleaning
+ $.notyRenderer.setLayoutCountFor(self, -1);
+ if($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
+
+ // Make sure self.$bar has not been removed before attempting to remove it
+ if(typeof self.$bar !== 'undefined' && self.$bar !== null) {
+
+ if (typeof self.options.animation.close == 'string') {
+ self.$bar.css('transition', 'all 100ms ease').css('border', 0).css('margin', 0).height(0);
+ self.$bar.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
self.$bar.remove();
self.$bar = null;
self.closed = true;
- }
- delete $.noty.store[self.options.id]; // deleting noty from store
+ if(self.options.theme.callback && self.options.theme.callback.onClose) {
+ self.options.theme.callback.onClose.apply(self);
+ }
+ });
+ } else {
+ self.$bar.remove();
+ self.$bar = null;
+ self.closed = true;
+ }
+ }
- if(self.options.theme.callback && self.options.theme.callback.onClose) {
- self.options.theme.callback.onClose.apply(self);
- }
+ delete $.noty.store[self.options.id]; // deleting noty from store
- if(!self.options.dismissQueue) {
- // Queue render
- $.noty.ontap = true;
+ if(self.options.theme.callback && self.options.theme.callback.onClose) {
+ self.options.theme.callback.onClose.apply(self);
+ }
- $.notyRenderer.render();
- }
+ if(!self.options.dismissQueue) {
+ // Queue render
+ $.noty.ontap = true;
- if(self.options.maxVisible > 0 && self.options.dismissQueue) {
- $.notyRenderer.render();
- }
- })
+ $.notyRenderer.render();
+ }
- }, // end close
+ if(self.options.maxVisible > 0 && self.options.dismissQueue) {
+ $.notyRenderer.render();
+ }
+ }, // end close clean up
+
setText: function(text) {
if(!this.closed) {
this.options.text = text;
this.$bar.find('.noty_text').html(text);
}
@@ -492,11 +526,9 @@
$.each($.noty.layouts, function(index, layout) {
layout.container.style.apply($(layout.container.selector));
});
});
-})(jQuery);
-
-// Helpers
-window.noty = function noty(options) {
- return jQuery.notyRenderer.init(options);
-};
+ // Helpers
+ window.noty = function noty(options) {
+ return jQuery.notyRenderer.init(options);
+ };
\ No newline at end of file