X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=zouba%2Fmisc%2Frss%2FWRTKit%2FUI%2FTextField.js;fp=zouba%2Fmisc%2Frss%2FWRTKit%2FUI%2FTextField.js;h=f87c02b247167e1b3942e854970ee56567e2d814;hb=416f018d3eadc98e82817b2a36e38ac8b1e451e6;hp=0000000000000000000000000000000000000000;hpb=29fa83d8856e6aedacac394735fea72038630bde;p=ptas diff --git a/zouba/misc/rss/WRTKit/UI/TextField.js b/zouba/misc/rss/WRTKit/UI/TextField.js new file mode 100644 index 0000000..f87c02b --- /dev/null +++ b/zouba/misc/rss/WRTKit/UI/TextField.js @@ -0,0 +1,93 @@ +/* +© Copyright 2008 Nokia Corporation. All rights reserved. + +IMPORTANT: The Nokia software ("WRTKit and Example Widget files") is supplied to you by Nokia +Corporation (“Nokia”) in consideration of your agreement to the following terms. Your use, installation +and/or redistribution of the WRTKit and Example Widget files constitutes acceptance of these terms. If +you do not agree with these terms, please do not use, install, or redistribute the WRTKit and Example +Widget files. + +In consideration of your agreement to abide by the following terms, and subject to these terms, Nokia +grants you a personal, non-exclusive license, under Nokia’s copyrights in the WRTKit and Example +Widget files, to use, reproduce, and redistribute the WRTKit and Example files, in text form (for HTML, +CSS, or JavaScript files) or binary form (for associated images), for the sole purpose of creating S60 +Widgets. + +If you redistribute the WRTKit and Example files, you must retain this entire notice in all such +redistributions of the WRTKit and Example files. + +You may not use the name, trademarks, service marks or logos of Nokia to endorse or promote products +that include the WRTKit and Example files without the prior written explicit agreement with Nokia. +Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by +Nokia herein, including but not limited to any patent rights that may be infringed by your products that +incorporate the WRTKit and Example files or by other works in which the WRTKit and Example files +may be incorporated. + +The WRTKit and Example files are provided on an "AS IS" basis. NOKIA MAKES NO +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED +WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE, REGARDING THE EXAMPLES OR ITS USE AND OPERATION +ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, AND/OR +DISTRIBUTION OF THE EXAMPLES, HOWEVER CAUSED AND WHETHER UNDER THEORY +OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, +EVEN IF NOKIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/////////////////////////////////////////////////////////////////////////////// +// The TextField class implements a single line text entry control. + +// Constructor. +function TextField(id, caption, value, masked) { + if (id != UI_NO_INIT_ID) { + this.init(id, caption, value, masked); + } +} + +// TextField inherits from TextEntryControl. +TextField.prototype = new TextEntryControl(UI_NO_INIT_ID); + +// Initializer - called from constructor. +TextField.prototype.init = function(id, caption, value, masked) { + uiLogger.debug("TextField.init(" + id + ", " + caption + ", " + value + ", " + masked + ")"); + + // call superclass initializer + TextEntryControl.prototype.init.call(this, id, caption); + + // create the peer element + this.peerElement = document.createElement("input"); + this.peerElement.type = masked ? "password" : "text"; + this.controlElement.appendChild(this.peerElement); + + // set the value + this.peerElement.value = (value == null) ? "" : value; + + // bind event listeners + this.bindTextEntryControlListeners(); + + // update the style + this.updateStyleFromState(); +} + +// Updates the style of the control to reflects the state of the control. +TextField.prototype.updateStyleFromState = function() { + uiLogger.debug("TextField.updateStyleFromState()"); + + // determine the state name + var stateName = this.getStyleStateName(); + + // set element class names + this.setClassName(this.rootElement, "Control"); + this.setClassName(this.controlElement, "ControlElement"); + this.setClassName(this.assemblyElement, "ControlAssembly ControlAssembly" + stateName); + this.setClassName(this.captionElement, "ControlCaption ControlCaption" + stateName); + + // set peer element class names + var peerStateName = this.isEnabled() ? stateName : "Disabled"; + this.setClassName(this.peerElement, "TextField TextField" + peerStateName); +}