1 /** |
|
2 * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 /////////////////////////////////////////////////////////////////////////////// |
|
19 // The TextArea class implements a multi line text entry control. |
|
20 |
|
21 // Constructor. |
|
22 function TextArea(id, caption, value, rows) { |
|
23 if (id != UI_NO_INIT_ID) { |
|
24 this.init(id, caption, value, rows); |
|
25 } |
|
26 } |
|
27 |
|
28 // TextArea inherits from TextEntryControl. |
|
29 TextArea.prototype = new TextEntryControl(UI_NO_INIT_ID); |
|
30 |
|
31 // Initializer - called from constructor. |
|
32 TextArea.prototype.init = function(id, caption, value, rows) { |
|
33 uiLogger.debug("TextArea.init(" + id + ", " + caption + ", " + value + ", " + rows + ")"); |
|
34 |
|
35 // call superclass initializer |
|
36 TextEntryControl.prototype.init.call(this, id, caption); |
|
37 |
|
38 // create the peer element |
|
39 this.peerElement = document.createElement("textarea"); |
|
40 // default rowcount is 3 if not defined |
|
41 // width always comes from style but is a required attribute |
|
42 this.peerElement.rows = (rows != null) ? rows : 3; |
|
43 this.peerElement.cols = 20; |
|
44 this.controlElement.appendChild(this.peerElement); |
|
45 |
|
46 // set the value |
|
47 this.peerElement.value = (value == null) ? "" : value; |
|
48 |
|
49 // bind event listeners |
|
50 this.bindTextEntryControlListeners(); |
|
51 |
|
52 // update the style |
|
53 this.updateStyleFromState(); |
|
54 }; |
|
55 |
|
56 // Updates the style of the control to reflects the state of the control. |
|
57 TextArea.prototype.updateStyleFromState = function() { |
|
58 uiLogger.debug("TextArea.updateStyleFromState()"); |
|
59 |
|
60 // determine the state name |
|
61 var stateName = this.getStyleStateName(); |
|
62 |
|
63 // set element class names |
|
64 this.setClassName(this.rootElement, "Control"); |
|
65 this.setClassName(this.controlElement, "ControlElement"); |
|
66 this.setClassName(this.assemblyElement, "ControlAssembly ControlAssembly" + stateName); |
|
67 this.setClassName(this.captionElement, "ControlCaption ControlCaption" + stateName); |
|
68 |
|
69 // set peer element class names |
|
70 var peerStateName = this.isEnabled() ? stateName : "Disabled"; |
|
71 this.setClassName(this.peerElement, "TextArea TextArea" + stateName); |
|
72 }; |
|