From: <cos...@us...> - 2010-08-19 18:32:22
|
Revision: 4689 http://jaffa.svn.sourceforge.net/jaffa/?rev=4689&view=rev Author: cosbor11 Date: 2010-08-19 18:32:15 +0000 (Thu, 19 Aug 2010) Log Message: ----------- override of setRawValue so that textonly fields are set when initialized -See Bug 14171 Modified Paths: -------------- tags/JAFFA_5_6_0_FINAL/JaffaRIA/source/html/js/extjs/ext-extensions.js Modified: tags/JAFFA_5_6_0_FINAL/JaffaRIA/source/html/js/extjs/ext-extensions.js =================================================================== --- tags/JAFFA_5_6_0_FINAL/JaffaRIA/source/html/js/extjs/ext-extensions.js 2010-08-19 01:13:21 UTC (rev 4688) +++ tags/JAFFA_5_6_0_FINAL/JaffaRIA/source/html/js/extjs/ext-extensions.js 2010-08-19 18:32:15 UTC (rev 4689) @@ -1,6 +1,6 @@ /** Declare Extension and Jaffa Name Spaces */ Ext.namespace("Ext.ux","Ext.ux.form","Ext.ux.grid","Ext.ux.plugins", - "Jaffa","Jaffa.component","Jaffa.data","Jaffa.finder", + "Jaffa","Jaffa.component","Jaffa.data","Jaffa.finder","Jaffa.attachment", "Jaffa.form","Jaffa.grid","Jaffa.maintenance","Jaffa.maintenance.plugins","Jaffa.state","Jaffa.tree","Jaffa.util"); /** @@ -199,8 +199,59 @@ } }, - /** + * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}. + * @param {Mixed} value The value to set + * @return {Mixed} value The field value that is set + */ + setRawValue : function(v){ + if (!this.textOnly || this.xtype == 'htmleditor' || this.xtype == 'xhtmleditor') { + return this.rendered ? (this.el.dom.value = (Ext.isEmpty(v) ? '' : v)) : ''; + } else { + this.value = v; + if (this.rendered) { + this.el.dom.value = (v === null || v === undefined ? '' : v); + if (document.getElementById(this.id + "-text")) { + if (this.xtype == 'datefield') { + var w = v ? new Date(Date.parseDate(v, this.format)) : null; + if (w) document.getElementById(this.id + "-text").innerHTML = Ext.util.Format.date(w); + } + else if (this.xtype == 'xdatetime') { + var w = v ? new Date(Date.parseDate(v, this.format || Ext.util.Format.defaultDateTimeLayout)) : null; + if (w) document.getElementById(this.id + "-text").innerHTML = Ext.util.Format.datetime(w); + } + else if (this.xtype == 'currencyfield') { + if (v || v == 0) document.getElementById(this.id + "-text").innerHTML = Ext.util.Format.money(v); + else document.getElementById(this.id + "-text").innerHTML = ''; + } + else document.getElementById(this.id + "-text").innerHTML = (v === null || v === undefined ? '' : v); + } + else { + this.hide(); + var txt = document.createElement('div'); + txt.setAttribute("id", this.id + "-text"); + txt.setAttribute("class", "x-form-textonly"); + if (this.xtype == 'datefield') txt.appendChild(document.createTextNode(Ext.util.Format.date(this.getEl().getValue()))); + else if (this.xtype == 'xdatetime') { + var w = this.dateValue; + if (w) txt.appendChild(document.createTextNode(Ext.util.Format.datetime(w))); + } + else if (this.xtype == 'currencyfield') { + var w = this.getValue(); + if (w !== null) txt.appendChild(document.createTextNode(Ext.util.Format.money(w))); + else txt.appendChild(document.createTextNode('')); + } + else txt.appendChild(document.createTextNode(this.getEl().getValue())); + var formEl = document.getElementById("x-form-el-" + this.id); + if (formEl) { + formEl.appendChild(txt); + } + } + } + } + }, + + /** * Sets a data value into the field and validates it. * To set the value directly without validation see {@link #setRawValue}. * @@ -313,24 +364,26 @@ initValue : function(){ if(this.value !== undefined){ - this.setValue(this.value); + this.setRawValue(this.value); }else if(this.el.getValue().length > 0){ - this.setValue(this.el.getValue()); + this.setRawValue(this.el.getValue()); } }, - setValue : function(v){ - Ext.form.HtmlEditor.superclass.setValue.call(this, v); - if (this.rendered && this.wrap && this.wrap._mask){ - var roMask = this.wrap._mask.dom; - roMask.innerHTML = v; - if (roMask.childNodes && roMask.childNodes.length > 0) - for (var i=0; i<roMask.childNodes.length; i++) { - if (roMask.childNodes[i].href && roMask.childNodes[i].href != '') - roMask.childNodes[i].target = '_blank'; - }; - } - }, + setValue : function(v){ + Ext.form.HtmlEditor.superclass.setValue.call(this, v); + if (this.rendered && this.wrap && this.wrap.dom && this.wrap.isMasked()){ + var roMask = Ext.Element.data(this.wrap.dom, 'mask'); + if(roMask && roMask.dom){ + roMask.dom.innerHTML = v; + if (roMask.childNodes && roMask.childNodes.length > 0) + for (var i=0; i<roMask.childNodes.length; i++) { + if (roMask.childNodes[i].href && roMask.childNodes[i].href != '') + roMask.childNodes[i].target = '_blank'; + }; + } + } + }, /** * Set a textonly mask over the editor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |