scinote-web/vendor/assets/javascripts/eventPause-min.js
2016-02-12 16:52:43 +01:00

8 lines
2.3 KiB
JavaScript

/*
eventPause.js v 1.0.0
Author: sudhanshu yadav
s-yadav.github.com
Copyright (c) 2013 Sudhanshu Yadav.
Dual licensed under the MIT and GPL licenses
*/
(function(e,t,n,r){function s(t){if(e._iwEventPause){var n=e._iwEventPause["assigned"];for(var r=0;r<n.length;r++){return i[t].call(e(n[r]))}}}function o(){if(!e._iwEventPause){e._iwEventPause={};e._iwEventPause["assigned"]=[]}}function a(e){var t=[];if(!e){e=""}if(typeof e=="string"&&e!=""){e=e.split(" ");for(var n=0;n<e.length;n++){if(e[n]=="hover"){t.push("hover");t.push("mouseover");t.push("mouseout")}else if(e[n]=="mouseenter"){t.push("mouseover")}else if(e[n]=="mouseleave"){t.push("mouseoout")}else{t.push(e[n])}}e=t}return e}function f(e,t){for(var n=0;n<e.length;n++){if(e[n]==t){return n}}return-1}function l(t,n){var r=e._data(t,"events");if(r){e.each(r,function(t,r){if(f(n,t)!=-1||n==""){e.each(r,function(t,n){if(n.handler.toString()!=u.toString()){e._iwEventPause["iw-event"+n.guid]=n.handler;n.handler=u}})}})}}function c(t,n){var r=e._data(t,"events");if(r){e.each(r,function(t,r){if(f(n,t)!=-1||n==""){e.each(r,function(t,n){if(n.handler.toString()==u.toString()){n.handler=e._iwEventPause["iw-event"+n.guid]}})}})}}e.fn.eventPause=function(e,t){o();if(!i[e]&&t==null){t=e}t=a(t);if(i[e]){return i[e].call(this,t)}else{return i.pause.call(this,t)}};var i={pause:function(t){return this.each(function(){if(!e(this).data("iw-disable")){e(this).data("iw-eventactive",false);e._iwEventPause["assigned"].push(this);l(this,t)}})},active:function(t){return this.each(function(){if(!e(this).data("iw-disable")){e(this).data("iw-eventactive",true);e._iwEventPause["assigned"].splice(this);c(this,t)}})},pauseChild:function(e){return i["pause"].call(this.add(this.find("*")),e)},activeChild:function(e){return i["active"].call(this.add(this.find("*")),e)},enable:function(){this.data("iw-disable",false)},disable:function(){this.data("iw-disable",true)},toggle:function(e){var t=this.data("iw-eventactive");if(t){return i["active"].call(this,e)}else{return i["pause"].call(this,e)}},state:function(){var e=this.data("iw-disable")?"disabled":"enabled",t=this.data("iw-eventactive")==false?"paused":"active";return t+"-"+e}};e.eventPause={activeAll:function(){s("active")},enableAll:function(){s("enable")},disableAll:function(){s("disable")}};var u=function(){}})(jQuery,window,document)