-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.msgbox.min.js
More file actions
1 lines (1 loc) · 2.35 KB
/
jquery.msgbox.min.js
File metadata and controls
1 lines (1 loc) · 2.35 KB
1
!function(a){a.msgbox=function(b,c){var d={lines:4,timer:5e3,direction:"append",onComplete:null,animate:!0},e=this;e.settings={};var f=a(b),b=b;e.initialize=function(){e.settings=a.extend({},d,c),e.settings.animation=e.settings.animate?"fadeOut":"hide",e.settings.duration=e.settings.animate?400:0,f.addClass("msgbox"),"function"==typeof e.settings.onComplete&&e.settings.onComplete(f)},e.prepend=function(b,c){if("undefined"==typeof b)return window.console.error("cannot prepend undefined element"),0;"undefined"!=typeof b.element&&(b=b.element);var d=a("<span></span>").text(b);f.children("span").length==e.settings.lines?f.children("span").last()[e.settings.animation](e.settings.duration,function(){a(this).detach(),a(this).remove(),d.prependTo(f)}):d.prependTo(f),c&&c(d),e.setDelay(d)},e.append=function(b,c){if("undefined"==typeof b)return window.console.error("cannot append undefined element"),0;"undefined"!=typeof b.element&&(b=b.element);var d=a("<div></div>").text(b);f.children("div").length==e.settings.lines?f.children("div").first()[e.settings.animation](e.settings.duration,function(){a(this).detach(),a(this).remove(),d.appendTo(f)}):d.appendTo(f),c&&c(d),e.setDelay(d)},e.add=function(a,b){"append"==e.settings.direction?e.append(a,b):e.prepend(a,b)},e.setDelay=function(a){null!=e.settings.timer&&setTimeout(function(){"undefined"!=typeof a&&a[e.settings.animation](e.settings.duration,function(){a.remove()})},e.settings.timer)},e.destroy=function(a){e.empty(),f.removeData("msgbox"),f.removeClass("msgbox"),"function"==typeof a&&a(f)},e.empty=function(){f.children().each(function(){a(this).detach(),a(this).remove()})},e.reset=function(){e.destroy(),e.initialize()},jQuery.expr[":"].parents=function(a,b,c){return jQuery(a).parents(c[3]).length<1},e.initialize()},a.fn.msgbox=function(b){if("string"!=typeof b)return this.each(function(){if(void 0==a(this).data("msgbox")){var c=new a.msgbox(this,b);a(this).data("msgbox",c)}else{a(this).data("msgbox").destroy();var c=new a.msgbox(this,b);a(this).data("msgbox",c)}});var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=a.data(this,"msgbox");return d?a.isFunction(d[b])&&"_"!==b.charAt(0)?void d[b].apply(d,c):void window.console.error("no such method '"+b+"' for msgbox instance"):void window.console.error("cannot call methods on msgbox prior to initialization; attempted to call method '"+b+"'")})}}(jQuery);