Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Custom JavaScript Event Manager (CJEM)

, 3 Aug 2011
A Custom JavaScript Event Manager Class Designed to Manage Window, Document and Control Events on a Webpage
calendar.zip
css
js
checkbox.zip
img
checkbox2.png
checkbox1.png
cjem.zip
cjemcompressed.zip
dropdown.zip
movableitem.zip
folder4.png
folder3.png
folder1.png
folder2.png
preventdefault.zip
tabcontrol.zip
var $N={R:function(N){var o=window;var x=false;for(var a=N.split('.');a.length>0;){var s=a.shift();if(a.length==0){if(o[s]){x=true;}}if(!o[s]){o[s]={};}o=o[s];}if(x){return 1;}}};function $O(S){return document.getElementById(S);}function $NU(O){if(O==undefined||O==null){return true;}else{if(typeof(O)=='string'&&O==''){return true;}else{return false;}}}var $CJEM={E:null,Add:function(P,C,T,H,I,W,U){if($NU(this.E)){this.E=new Array();}if($NU(this.E[C])){this.E[C]={};}var A=this.E[C];if($NU(A[T])){A[T]=new Array();}var B=A[T];B.push({'P':P,'C':C,'T':T,'H':H,'I':I,'W':W,'U':U,event:null});$CJEM.Register(C,T);},Remove:function(C,T,H){if($NU(this.E)){return;}var A=this.E[C];if($NU(A)){return;}var B=A[T];if($NU(B)){return;}if(!$NU(H)){for(var i=0;i<B.length;i++){if(H==B[i].H){B[i]=null;B.sort();B.pop();}}}else{B=[];}if(B.length==0){B=null;A[T]=null;delete A[T];$CJEM.UnRegister(C,T);}},UnRegister:function(C,T){switch(C){case 'window':window[T]=null;break;case 'document':document[T]=null;break;default:var A=$O(C);if($NU(A)){return;}A[T]=null;break;}},Register:function(C,T){switch(C){case 'window':window[T]=function(e){$CJEM.Caller(e,C,T);};break;case 'document':document[T]=function(e){$CJEM.Caller(e,C,T);};break;default:var A=$O(C);if($NU(A)){return;}A[T]=function(e){$CJEM.Caller(e,C,T);};break;}},Caller:function(e,C,T){if(!e){e=window.event;}var A=this.E[C];var B=A[T];if($NU(B)){return;}for(var i=0;i<B.length;i++){var D=B[i];D.event=e;if(!$NU(D.I)){if(D.I>0){D.I-=1;}}var F={'ClassObject':B[i].P,'ControlID':B[i].C,'EventType':B[i].T,'TotalInstance':B[i].I,'Wait':B[i].W,'UserObject':B[i].U,event:e};if(!$NU(D.W)){var t=setTimeout(function(){if(D.H(F)){if(navigator.appVersion.indexOf('MSIE')!=-1){e.cancelBubble=true;}else{e.stopPropagation();}}},D.W);}else{if(D.H(F)){if(navigator.appVersion.indexOf('MSIE')!=-1){e.cancelBubble=true;} else {e.stopPropagation();}}}if(D.I==0){$CJEM.Remove(C,T,D.H);}}}};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

M@dHatter
Software Developer (Senior) Codevendor
United States United States
Please visit my personal website http://www.codevendor.com for my latest codes and updates.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 4 Aug 2011
Article Copyright 2011 by M@dHatter
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid