You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

11 lines
5.2 KiB

/*!
* # Semantic UI 2.0.0 - Nag
* http://github.com/semantic-org/semantic-ui/
*
*
* Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(e,o,n,t){"use strict";e.fn.nag=function(n){var i,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,g=[].slice.call(arguments,1);return a.each(function(){{var a,d=e.isPlainObject(n)?e.extend(!0,{},e.fn.nag.settings,n):e.extend({},e.fn.nag.settings),m=(d.className,d.selector),f=d.error,p=d.namespace,h="."+p,b=p+"-module",v=e(this),y=(v.find(m.close),e(d.context?d.context:"body")),k=this,w=v.data(b);o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||o.msRequestAnimationFrame||function(e){setTimeout(e,0)}}a={initialize:function(){a.verbose("Initializing element"),v.on("click"+h,m.close,a.dismiss).data(b,a),d.detachable&&v.parent()[0]!==y[0]&&v.detach().prependTo(y),d.displayTime>0&&setTimeout(a.hide,d.displayTime),a.show()},destroy:function(){a.verbose("Destroying instance"),v.removeData(b).off(h)},show:function(){a.should.show()&&!v.is(":visible")&&(a.debug("Showing nag",d.animation.show),"fade"==d.animation.show?v.fadeIn(d.duration,d.easing):v.slideDown(d.duration,d.easing))},hide:function(){a.debug("Showing nag",d.animation.hide),"fade"==d.animation.show?v.fadeIn(d.duration,d.easing):v.slideUp(d.duration,d.easing)},onHide:function(){a.debug("Removing nag",d.animation.hide),v.remove(),d.onHide&&d.onHide()},dismiss:function(e){d.storageMethod&&a.storage.set(d.key,d.value),a.hide(),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return d.persist?(a.debug("Persistent nag is set, can show nag"),!0):a.storage.get(d.key)!=d.value.toString()?(a.debug("Stored value is not set, can show nag",a.storage.get(d.key)),!0):(a.debug("Stored value is set, cannot show nag",a.storage.get(d.key)),!1)}},get:{storageOptions:function(){var e={};return d.expires&&(e.expires=d.expires),d.domain&&(e.domain=d.domain),d.path&&(e.path=d.path),e}},clear:function(){a.storage.remove(d.key)},storage:{set:function(n,i){var r=a.get.storageOptions();if("localstorage"==d.storageMethod&&o.localStorage!==t)o.localStorage.setItem(n,i),a.debug("Value stored using local storage",n,i);else{if(e.cookie===t)return void a.error(f.noCookieStorage);e.cookie(n,i,r),a.debug("Value stored using cookie",n,i,r)}},get:function(n,i){var r;return"localstorage"==d.storageMethod&&o.localStorage!==t?r=o.localStorage.getItem(n):e.cookie!==t?r=e.cookie(n):a.error(f.noCookieStorage),("undefined"==r||"null"==r||r===t||null===r)&&(r=t),r},remove:function(n){var i=a.get.storageOptions();"local"==d.storageMethod&&o.store!==t?o.localStorage.removeItem(n):e.cookie!==t?e.removeCookie(n,i):a.error(f.noStorage)}},setting:function(o,n){if(a.debug("Changing setting",o,n),e.isPlainObject(o))e.extend(!0,d,o);else{if(n===t)return d[o];d[o]=n}},internal:function(o,n){if(e.isPlainObject(o))e.extend(!0,a,o);else{if(n===t)return a[o];a[o]=n}},debug:function(){d.debug&&(d.performance?a.performance.log(arguments):(a.debug=Function.prototype.bind.call(console.info,console,d.name+":"),a.debug.apply(console,arguments)))},verbose:function(){d.verbose&&d.debug&&(d.performance?a.performance.log(arguments):(a.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),a.verbose.apply(console,arguments)))},error:function(){a.error=Function.prototype.bind.call(console.error,console,d.name+":"),a.error.apply(console,arguments)},performance:{log:function(e){var o,n,t;d.performance&&(o=(new Date).getTime(),t=s||o,n=o-t,s=o,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:k,"Execution Time":n})),clearTimeout(a.performance.timer),a.performance.timer=setTimeout(a.performance.display,500)},display:function(){var o=d.name+":",n=0;s=!1,clearTimeout(a.performance.timer),e.each(c,function(e,o){n+=o["Execution Time"]}),o+=" "+n+"ms",r&&(o+=" '"+r+"'"),(console.group!==t||console.table!==t)&&c.length>0&&(console.groupCollapsed(o),console.table?console.table(c):e.each(c,function(e,o){console.log(o.Name+": "+o["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(o,n,r){var s,c,l,u=w;return n=n||g,r=k||r,"string"==typeof o&&u!==t&&(o=o.split(/[\. ]/),s=o.length-1,e.each(o,function(n,i){var r=n!=s?i+o[n+1].charAt(0).toUpperCase()+o[n+1].slice(1):o;if(e.isPlainObject(u[r])&&n!=s)u=u[r];else{if(u[r]!==t)return c=u[r],!1;if(!e.isPlainObject(u[i])||n==s)return u[i]!==t?(c=u[i],!1):(a.error(f.method,o),!1);u=u[i]}})),e.isFunction(c)?l=c.apply(r,n):c!==t&&(l=c),e.isArray(i)?i.push(l):i!==t?i=[i,l]:l!==t&&(i=l),c}},u?(w===t&&a.initialize(),a.invoke(l)):(w!==t&&w.invoke("destroy"),a.initialize())}),i!==t?i:this},e.fn.nag.settings={name:"Nag",debug:!1,verbose:!1,performance:!0,namespace:"Nag",persist:!1,displayTime:0,animation:{show:"slide",hide:"slide"},context:!1,detachable:!1,expires:30,domain:!1,path:"/",storageMethod:"cookie",key:"nag",value:"dismiss",error:{noCookieStorage:"$.cookie is not included. A storage solution is required.",noStorage:"Neither $.cookie or store is defined. A storage solution is required for storing state",method:"The method you called is not defined."},className:{bottom:"bottom",fixed:"fixed"},selector:{close:".close.icon"},speed:500,easing:"easeOutQuad",onHide:function(){}}}(jQuery,window,document);