1( function() { 2 var _c=T.CheckBox = function(node, config, container) { 3 this.node = node; 4 this.config = config; 5 this.id = T.uuid(); 6 this.init(); 7 }; 8 T.extend(_c, { 9 getId:function(){ 10 return this.id; 11 }, 12 initCheckbox:function(){ 13 var cb=this.checkbox=T.dc("input"); 14 cb.type="checkbox"; 15 this.node.appendChild(cb); 16 var c=this.config; 17 var self=this; 18 var disabled = c.disabled; 19 if (disabled) { 20 cb.disabled = disabled; 21 } 22 cb.onclick=function(){ 23 return self.onClick(cb); 24 } 25 }, 26 onClick:function(cb){ 27 var self=this; 28 var c=this.config; 29 var readOnly = c.readOnly; 30 if (readOnly) { 31 cb.checked=false; 32 return false; 33 }else{ 34 if(cb.checked){ 35 self.check(); 36 }else{ 37 self.uncheck(); 38 } 39 T.Event.fire(self,"change"); 40 return true; 41 } 42 }, 43 initHidden:function(){ 44 var hidden=this.hidden=T.dc("input"); 45 hidden.type="hidden"; 46 this.node.appendChild(hidden); 47 var c=this.config; 48 hidden.name=c.name||""; 49 hidden.value=c.value||c.uncheckValue||""; 50 hidden.setAttribute("generatedBy",this.id); 51 }, 52 setReadonly:function(ro){ 53 this.config.readOnly=ro; 54 }, 55 check:function(){ 56 this.hidden.value=this.config.checkValue; 57 this.checkbox.checked=true; 58 }, 59 uncheck:function(){ 60 this.hidden.value=this.config.uncheckValue||""; 61 this.checkbox.checked=false; 62 }, 63 disabled:function(){ 64 this.checkbox.setAttribute("disabled",true); 65 }, 66 undisabled:function(){ 67 this.checkbox.disabled = false; 68 }, 69 init : function() { 70 this.initCheckbox(); 71 this.initHidden(); 72 var c = this.config; 73 if(c.checkValue==c.value){ 74 this.check(); 75 }else{ 76 this.uncheck(); 77 } 78 return; 79 }, 80 getValue : function() { 81 return this.hidden.value; 82 }, 83 isChecked:function(){ 84 return this.checkbox.checked; 85 } 86 }); 87 _c.create = function(el, container) { 88 var jsonStr = el.innerHTML; 89 el.innerHTML = ""; 90 var escaped = (el.getAttribute("escaped") || false) == "true"; 91 if (escaped) { 92 jsonStr = unescape(jsonStr); 93 } 94 var config = T.evalJson(jsonStr); 95 T.Css.removeClass(el, "hide"); // æ<span> çéèæ ·å¼å»æ 96 return new _c(el, config, container); 97 }; 98 T.Widget.registerType("checkbox",_c); 99})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.