author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 16 Mar 2010 18:01:11 -0700 | |
changeset 273 | b1f63c2c240c |
parent 211 | 7b148352159e |
permissions | -rw-r--r-- |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
1 |
/** |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
2 |
* Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
3 |
* All rights reserved. |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
8 |
* |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
9 |
* Initial Contributors: |
273
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
11 |
* |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
12 |
* Contributors: |
273
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
13 |
* |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
14 |
* Description: |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
15 |
* |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
16 |
*/ |
73 | 17 |
|
18 |
/////////////////////////////////////////////////////////////////////////////// |
|
19 |
// The TextEntryControl class is an abstract base class for the single and multi- |
|
20 |
// line text entry controls TextField and TextArea. Don't use TextEntryControl |
|
21 |
// directly. |
|
22 |
||
23 |
// Constructor. |
|
24 |
function TextEntryControl(id, caption) { |
|
25 |
if (id != UI_NO_INIT_ID) { |
|
26 |
this.init(id, caption); |
|
27 |
} |
|
28 |
} |
|
29 |
||
30 |
// TextEntryControl inherits from Control. |
|
31 |
TextEntryControl.prototype = new Control(UI_NO_INIT_ID); |
|
32 |
||
33 |
// Reference to the peer HTML element. |
|
34 |
TextEntryControl.prototype.peerElement = null; |
|
35 |
||
36 |
// Initializer - called from constructor. |
|
37 |
TextEntryControl.prototype.init = function(id, caption) { |
|
38 |
uiLogger.debug("TextEntryControl.init(" + id + ", " + caption + ")"); |
|
39 |
||
40 |
// call superclass initializer |
|
41 |
Control.prototype.init.call(this, id, caption); |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
42 |
}; |
73 | 43 |
|
44 |
// Common event listeners hookup function called from subclasses. |
|
45 |
TextEntryControl.prototype.bindTextEntryControlListeners = function() { |
|
46 |
var self = this; |
|
47 |
this.peerElement.addEventListener("focus", function() { self.focusStateChanged(true); }, false); |
|
48 |
this.peerElement.addEventListener("blur", function() { self.focusStateChanged(false); }, false); |
|
49 |
this.peerElement.addEventListener("mouseover", function() { self.hoverStateChanged(true); }, false); |
|
50 |
this.peerElement.addEventListener("mouseout", function() { self.hoverStateChanged(false); }, false); |
|
51 |
this.peerElement.addEventListener("change", function() { self.valueChanged(); }, false); |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
52 |
}; |
73 | 53 |
|
54 |
// Returns the enabled state. |
|
55 |
// Override this in subclasses as required to implement the state change. |
|
56 |
TextEntryControl.prototype.isEnabled = function() { |
|
57 |
return !this.peerElement.readOnly; |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
58 |
}; |
73 | 59 |
|
60 |
// Sets the enabled state. |
|
61 |
// Override this in subclasses as required to implement the state change. |
|
62 |
TextEntryControl.prototype.setEnabled = function(enabled) { |
|
63 |
uiLogger.debug("TextEntryControl.setEnabled(" + enabled + ")"); |
|
64 |
this.peerElement.readOnly = !enabled; |
|
65 |
// update the style |
|
66 |
this.updateStyleFromState(); |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
67 |
}; |
73 | 68 |
|
69 |
// Returns the control text. |
|
70 |
TextEntryControl.prototype.getText = function() { |
|
71 |
return this.peerElement.value; |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
72 |
}; |
73 | 73 |
|
74 |
// Sets the text for the control. |
|
75 |
TextEntryControl.prototype.setText = function(text) { |
|
76 |
this.peerElement.value = text; |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
77 |
}; |
73 | 78 |
|
79 |
// Returns the focusable state for the control. |
|
80 |
TextEntryControl.prototype.isFocusable = function() { |
|
81 |
// text entry controls are always focusable |
|
82 |
return true; |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
83 |
}; |
73 | 84 |
|
85 |
// Sets the focused state for the control. |
|
86 |
// Note: This may not always succeed. |
|
87 |
TextEntryControl.prototype.setFocused = function(focused) { |
|
88 |
uiLogger.debug("TextEntryControl.setFocused(" + focused + ")"); |
|
89 |
if (focused) { |
|
90 |
this.peerElement.focus(); |
|
91 |
} else { |
|
92 |
this.peerElement.blur(); |
|
93 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
94 |
}; |
73 | 95 |
|
96 |
// Callback for value change events. |
|
97 |
TextEntryControl.prototype.valueChanged = function() { |
|
98 |
uiLogger.debug("TextEntryControl.valueChanged()"); |
|
99 |
// notify event listeners |
|
100 |
this.fireEvent(this.createEvent("ValueChanged", this.peerElement.value)); |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
101 |
}; |