updated show function
This commit is contained in:
Vendored
+31
-14
@@ -30,7 +30,7 @@ styles = {
|
|||||||
},
|
},
|
||||||
bootstrap: {
|
bootstrap: {
|
||||||
html: "<div class=\"alert alert-error " + className + "Bootstrap\">\n <strong data-notify=\"text\"></strong>\n</div>",
|
html: "<div class=\"alert alert-error " + className + "Bootstrap\">\n <strong data-notify=\"text\"></strong>\n</div>",
|
||||||
css: "." + className + "Bootstrap {\n white-space: nowrap;\n margin-bottom: 5px !important;\n padding-left: 25px !important;\n background-repeat: no-repeat;\n background-position: 3px 7px;\n background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=);\n}",
|
css: "." + className + "Bootstrap {\n white-space: nowrap;\n margin: 5px !important;\n padding-left: 25px !important;\n background-repeat: no-repeat;\n background-position: 3px 7px;\n background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=);\n}",
|
||||||
colors: {
|
colors: {
|
||||||
red: '#eed3d7'
|
red: '#eed3d7'
|
||||||
}
|
}
|
||||||
@@ -154,22 +154,27 @@ Notification = (function() {
|
|||||||
return this.text.addClass("" + className + "Text");
|
return this.text.addClass("" + className + "Text");
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification.prototype.show = function(show) {
|
Notification.prototype.show = function(show, callback) {
|
||||||
var elems, hidden;
|
var args, elems, fn, hidden;
|
||||||
|
if (callback == null) {
|
||||||
|
callback = $.noop;
|
||||||
|
}
|
||||||
hidden = this.container.parent().parents(':hidden').length > 0;
|
hidden = this.container.parent().parents(':hidden').length > 0;
|
||||||
elems = this.container.add(this.arrow);
|
elems = this.container.add(this.arrow);
|
||||||
|
args = [];
|
||||||
if (hidden && show) {
|
if (hidden && show) {
|
||||||
elems.show();
|
fn = 'show';
|
||||||
}
|
} else if (hidden && !show) {
|
||||||
if (hidden && !show) {
|
fn = 'hide';
|
||||||
elems.hide();
|
} else if (!hidden && show) {
|
||||||
}
|
fn = this.options.showAnimation;
|
||||||
if (!hidden && show) {
|
args.push(this.options.showDuration);
|
||||||
elems[this.options.showAnimation](this.options.showDuration);
|
} else if (!hidden && !show) {
|
||||||
}
|
fn = this.options.hideAnimation;
|
||||||
if (!hidden && !show) {
|
args.push(this.options.hideDuration);
|
||||||
return elems[this.options.hideAnimation](this.options.hideDuration);
|
|
||||||
}
|
}
|
||||||
|
args.push(callback);
|
||||||
|
return elems[fn].apply(elems, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification.prototype.updatePosition = function() {
|
Notification.prototype.updatePosition = function() {
|
||||||
@@ -299,6 +304,13 @@ Notification = (function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Notification.prototype.destroy = function() {
|
||||||
|
var _this = this;
|
||||||
|
return this.show(false, function() {
|
||||||
|
return _this.wrapper.remove();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return Notification;
|
return Notification;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -317,8 +329,13 @@ $(function() {
|
|||||||
return $(document).on('click', "." + className + "Wrapper", function() {
|
return $(document).on('click', "." + className + "Wrapper", function() {
|
||||||
var inst;
|
var inst;
|
||||||
inst = $(this).data(className);
|
inst = $(this).data(className);
|
||||||
if (inst) {
|
if (!inst) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (inst.elem) {
|
||||||
return inst.show(false);
|
return inst.show(false);
|
||||||
|
} else {
|
||||||
|
return inst.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+27
-9
@@ -103,7 +103,7 @@ styles =
|
|||||||
css: """
|
css: """
|
||||||
.#{className}Bootstrap {
|
.#{className}Bootstrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
margin-bottom: 5px !important;
|
margin: 5px !important;
|
||||||
padding-left: 25px !important;
|
padding-left: 25px !important;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: 3px 7px;
|
background-position: 3px 7px;
|
||||||
@@ -225,17 +225,27 @@ class Notification
|
|||||||
throw "style: #{name} HTML is missing the: data-notify='text' attribute"
|
throw "style: #{name} HTML is missing the: data-notify='text' attribute"
|
||||||
@text.addClass "#{className}Text"
|
@text.addClass "#{className}Text"
|
||||||
|
|
||||||
show: (show) ->
|
show: (show, callback = $.noop) ->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hidden = @container.parent().parents(':hidden').length > 0
|
hidden = @container.parent().parents(':hidden').length > 0
|
||||||
|
|
||||||
elems = @container.add @arrow
|
elems = @container.add @arrow
|
||||||
elems.show() if hidden and show
|
args = []
|
||||||
elems.hide() if hidden and not show
|
|
||||||
elems[@options.showAnimation] @options.showDuration if not hidden and show
|
if hidden and show
|
||||||
elems[@options.hideAnimation] @options.hideDuration if not hidden and not show
|
fn = 'show'
|
||||||
|
else if hidden and not show
|
||||||
|
fn = 'hide'
|
||||||
|
else if not hidden and show
|
||||||
|
fn = @options.showAnimation
|
||||||
|
args.push @options.showDuration
|
||||||
|
else if not hidden and not show
|
||||||
|
fn = @options.hideAnimation
|
||||||
|
args.push @options.hideDuration
|
||||||
|
|
||||||
|
args.push callback
|
||||||
|
|
||||||
|
elems[fn].apply elems, callback
|
||||||
|
|
||||||
updatePosition: ->
|
updatePosition: ->
|
||||||
return unless @elem
|
return unless @elem
|
||||||
@@ -358,6 +368,10 @@ class Notification
|
|||||||
@show false
|
@show false
|
||||||
, @options.autoHideDelay
|
, @options.autoHideDelay
|
||||||
|
|
||||||
|
destroy: ->
|
||||||
|
@show false, =>
|
||||||
|
@wrapper.remove()
|
||||||
|
|
||||||
#when ready
|
#when ready
|
||||||
$ ->
|
$ ->
|
||||||
#corner notification container
|
#corner notification container
|
||||||
@@ -376,7 +390,11 @@ $ ->
|
|||||||
#watch all notifications clicks
|
#watch all notifications clicks
|
||||||
$(document).on 'click', ".#{className}Wrapper", ->
|
$(document).on 'click', ".#{className}Wrapper", ->
|
||||||
inst = $(@).data className
|
inst = $(@).data className
|
||||||
inst.show false if inst
|
return unless inst
|
||||||
|
if inst.elem
|
||||||
|
inst.show false
|
||||||
|
else
|
||||||
|
inst.destroy()
|
||||||
|
|
||||||
# publicise jquery plugin
|
# publicise jquery plugin
|
||||||
# return alert "$.#{pluginName} already defined" if $[pluginName]?
|
# return alert "$.#{pluginName} already defined" if $[pluginName]?
|
||||||
|
|||||||
Reference in New Issue
Block a user