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.

10 lines
6.4 KiB

10 years ago
10 years ago
  1. /*
  2. * # Semantic UI
  3. * git://github.com/Semantic-Org/Semantic-UI.git#1.0
  4. *
  5. *
  6. * Copyright 2014 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(e,o,n,t){"use strict";e.fn.nag=function(n){var i,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],u=arguments[0],l="string"==typeof u,d=[].slice.call(arguments,1);return r.each(function(){{var r,g=e.isPlainObject(n)?e.extend(!0,{},e.fn.nag.settings,n):e.extend({},e.fn.nag.settings),m=(g.className,g.selector),f=g.error,p=g.namespace,h="."+p,v=p+"-module",b=e(this),y=b.find(m.close),k=e(g.context?g.context:"body"),x=this,w=b.data(v);o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||o.msRequestAnimationFrame||function(e){setTimeout(e,0)}}r={initialize:function(){r.verbose("Initializing element"),b.data(v,r),y.on("click"+h,r.dismiss),g.detachable&&b.parent()[0]!==k[0]&&b.detach().prependTo(k),g.displayTime>0&&setTimeout(r.hide,g.displayTime),r.show()},destroy:function(){r.verbose("Destroying instance"),b.removeData(v).off(h)},show:function(){r.should.show()&&!b.is(":visible")&&(r.debug("Showing nag",g.animation.show),"fade"==g.animation.show?b.fadeIn(g.duration,g.easing):b.slideDown(g.duration,g.easing))},hide:function(){r.debug("Showing nag",g.animation.hide),"fade"==g.animation.show?b.fadeIn(g.duration,g.easing):b.slideUp(g.duration,g.easing)},onHide:function(){r.debug("Removing nag",g.animation.hide),b.remove(),g.onHide&&g.onHide()},dismiss:function(e){g.storageMethod&&r.storage.set(g.key,g.value),r.hide(),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return g.persist?(r.debug("Persistent nag is set, can show nag"),!0):r.storage.get(g.key)!=g.value.toString()?(r.debug("Stored value is not set, can show nag",r.storage.get(g.key)),!0):(r.debug("Stored value is set, cannot show nag",r.storage.get(g.key)),!1)}},get:{storageOptions:function(){var e={};return g.expires&&(e.expires=g.expires),g.domain&&(e.domain=g.domain),g.path&&(e.path=g.path),e}},clear:function(){r.storage.remove(g.key)},storage:{set:function(n,i){var a=r.get.storageOptions();if("localstorage"==g.storageMethod&&o.localStorage!==t)o.localStorage.setItem(n,i),r.debug("Value stored using local storage",n,i);else{if(e.cookie===t)return void r.error(f.noCookieStorage);e.cookie(n,i,a),r.debug("Value stored using cookie",n,i,a)}},get:function(n){var i;return"localstorage"==g.storageMethod&&o.localStorage!==t?i=o.localStorage.getItem(n):e.cookie!==t?i=e.cookie(n):r.error(f.noCookieStorage),("undefined"==i||"null"==i||i===t||null===i)&&(i=t),i},remove:function(n){var i=r.get.storageOptions();"local"==g.storageMethod&&o.store!==t?o.localStorage.removeItem(n):e.cookie!==t?e.removeCookie(n,i):r.error(f.noStorage)}},setting:function(o,n){if(r.debug("Changing setting",o,n),e.isPlainObject(o))e.extend(!0,g,o);else{if(n===t)return g[o];g[o]=n}},internal:function(o,n){if(e.isPlainObject(o))e.extend(!0,r,o);else{if(n===t)return r[o];r[o]=n}},debug:function(){g.debug&&(g.performance?r.performance.log(arguments):(r.debug=Function.prototype.bind.call(console.info,console,g.name+":"),r.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?r.performance.log(arguments):(r.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),r.verbose.apply(console,arguments)))},error:function(){r.error=Function.prototype.bind.call(console.error,console,g.name+":"),r.error.apply(console,arguments)},performance:{log:function(e){var o,n,t;g.performance&&(o=(new Date).getTime(),t=s||o,n=o-t,s=o,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:x,"Execution Time":n})),clearTimeout(r.performance.timer),r.performance.timer=setTimeout(r.performance.display,100)},display:function(){var o=g.name+":",n=0;s=!1,clearTimeout(r.performance.timer),e.each(c,function(e,o){n+=o["Execution Time"]}),o+=" "+n+"ms",a&&(o+=" '"+a+"'"),(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,a){var s,c,u,l=w;return n=n||d,a=x||a,"string"==typeof o&&l!==t&&(o=o.split(/[\. ]/),s=o.length-1,e.each(o,function(n,i){var a=