From a46f7b1c286248455ae7dad074ed02027029d96f Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 23 Sep 2022 11:26:00 +0800 Subject: [PATCH] roojs-ui.js roojs-ui-debug.js roojs-all.js roojs-debug.js --- roojs-all.js | 3 ++- roojs-debug.js | 42 +++++++++++++++++++++++++++++++++++++++++- roojs-ui-debug.js | 42 +++++++++++++++++++++++++++++++++++++++++- roojs-ui.js | 3 ++- 4 files changed, 86 insertions(+), 4 deletions(-) diff --git a/roojs-all.js b/roojs-all.js index fb17d0e680..27aaaf86cf 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1852,7 +1852,8 @@ this.el.on('DOMAttrModified',this.setFromHidden,this);this.el.on('propertychange // Roo/form/Radio.js Roo.form.Radio=function(){Roo.form.Radio.superclass.constructor.apply(this,arguments);};Roo.extend(Roo.form.Radio,Roo.form.Checkbox,{inputType:'radio',getGroupValue:function(){return this.el.up('form').child('input[name='+this.el.dom.name+']:checked',true).value; },onRender:function(ct,A){Roo.form.Checkbox.superclass.onRender.call(this,ct,A);if(this.inputValue!==undefined){this.el.dom.value=this.inputValue;}this.wrap=this.el.wrap({cls:"x-form-check-wrap"});if(this.boxLabel){this.wrap.createChild({tag:'label',htmlFor:this.el.id,cls:'x-form-cb-label',html:this.boxLabel} -);}if(this.checked){this.el.dom.checked='checked';}}}); +);}if(this.checked){this.el.dom.checked='checked';}},setValue:function(v,A){this.setChecked(String(v)===String(this.inputValue),A);this.el.dom.form[this.name]=v;},setChecked:function(A,B){if(this.inSetChecked){this.checked=A;return;}if(this.wrap){this.wrap[A?'addClass':'removeClass']('x-menu-item-checked'); +}this.checked=A;if(B!==true){this.fireEvent('check',this,A);}this.inSetChecked=true;this.inSetChecked=false;}}); // Roo/rtf/namespace.js Roo.rtf={}; // Roo/rtf/Hex.js diff --git a/roojs-debug.js b/roojs-debug.js index 05c20435e7..c9d160cc19 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -45118,8 +45118,48 @@ Roo.extend(Roo.form.Radio, Roo.form.Checkbox, { this.el.dom.checked = 'checked' ; } - } + }, + /** + * Sets the checked state of the checkbox. + * On is always based on a string comparison between inputValue and the param. + * @param {Boolean/String} value - the value to set + * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event. + */ + setValue : function(v,suppressEvent){ + + + //this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on'); + //if(this.el && this.el.dom){ + // this.el.dom.checked = this.checked; + // this.el.dom.defaultChecked = this.checked; + //} + this.setChecked(String(v) === String(this.inputValue), suppressEvent); + this.el.dom.form[this.name] = v; + //this.fireEvent("check", this, this.checked); + }, + // private.. + setChecked : function(state,suppressEvent) + { + if (this.inSetChecked) { + this.checked = state; + return; + } + + if(this.wrap){ + this.wrap[state ? 'addClass' : 'removeClass']('x-menu-item-checked'); + } + this.checked = state; + if(suppressEvent !== true){ + this.fireEvent('check', this, state); + } + this.inSetChecked = true; + + + this.inSetChecked = false; + + } + });Roo.rtf = {}; // namespace Roo.rtf.Hex = function(hex) diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 90a8382866..d01af81e23 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -20619,8 +20619,48 @@ Roo.extend(Roo.form.Radio, Roo.form.Checkbox, { this.el.dom.checked = 'checked' ; } - } + }, + /** + * Sets the checked state of the checkbox. + * On is always based on a string comparison between inputValue and the param. + * @param {Boolean/String} value - the value to set + * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event. + */ + setValue : function(v,suppressEvent){ + + + //this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on'); + //if(this.el && this.el.dom){ + // this.el.dom.checked = this.checked; + // this.el.dom.defaultChecked = this.checked; + //} + this.setChecked(String(v) === String(this.inputValue), suppressEvent); + this.el.dom.form[this.name] = v; + //this.fireEvent("check", this, this.checked); + }, + // private.. + setChecked : function(state,suppressEvent) + { + if (this.inSetChecked) { + this.checked = state; + return; + } + + if(this.wrap){ + this.wrap[state ? 'addClass' : 'removeClass']('x-menu-item-checked'); + } + this.checked = state; + if(suppressEvent !== true){ + this.fireEvent('check', this, state); + } + this.inSetChecked = true; + + + this.inSetChecked = false; + + } + });Roo.rtf = {}; // namespace Roo.rtf.Hex = function(hex) diff --git a/roojs-ui.js b/roojs-ui.js index e71f01c047..11fbf788d8 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -905,7 +905,8 @@ this.el.on('DOMAttrModified',this.setFromHidden,this);this.el.on('propertychange // Roo/form/Radio.js Roo.form.Radio=function(){Roo.form.Radio.superclass.constructor.apply(this,arguments);};Roo.extend(Roo.form.Radio,Roo.form.Checkbox,{inputType:'radio',getGroupValue:function(){return this.el.up('form').child('input[name='+this.el.dom.name+']:checked',true).value; },onRender:function(ct,A){Roo.form.Checkbox.superclass.onRender.call(this,ct,A);if(this.inputValue!==undefined){this.el.dom.value=this.inputValue;}this.wrap=this.el.wrap({cls:"x-form-check-wrap"});if(this.boxLabel){this.wrap.createChild({tag:'label',htmlFor:this.el.id,cls:'x-form-cb-label',html:this.boxLabel} -);}if(this.checked){this.el.dom.checked='checked';}}}); +);}if(this.checked){this.el.dom.checked='checked';}},setValue:function(v,A){this.setChecked(String(v)===String(this.inputValue),A);this.el.dom.form[this.name]=v;},setChecked:function(A,B){if(this.inSetChecked){this.checked=A;return;}if(this.wrap){this.wrap[A?'addClass':'removeClass']('x-menu-item-checked'); +}this.checked=A;if(B!==true){this.fireEvent('check',this,A);}this.inSetChecked=true;this.inSetChecked=false;}}); // Roo/rtf/namespace.js Roo.rtf={}; // Roo/rtf/Hex.js -- 2.39.2