equal
deleted
inserted
replaced
69 // call superclass initializer |
69 // call superclass initializer |
70 Control.prototype.init.call(this, id, caption); |
70 Control.prototype.init.call(this, id, caption); |
71 |
71 |
72 // the control defaults to enabled |
72 // the control defaults to enabled |
73 this.enabled = true; |
73 this.enabled = true; |
74 } |
74 }; |
75 |
75 |
76 // Common event listeners hookup function called from subclasses. |
76 // Common event listeners hookup function called from subclasses. |
77 ActionControl.prototype.bindActionControlListeners = function() { |
77 ActionControl.prototype.bindActionControlListeners = function() { |
78 var self = this; |
78 var self = this; |
79 this.linkElement.addEventListener("focus", function() { self.focusStateChanged(true); }, false); |
79 this.linkElement.addEventListener("focus", function() { self.focusStateChanged(true); }, false); |
91 self.controlClicked(); |
91 self.controlClicked(); |
92 event.stopPropagation(); |
92 event.stopPropagation(); |
93 event.preventDefault(); |
93 event.preventDefault(); |
94 } |
94 } |
95 }, true); |
95 }, true); |
96 } |
96 }; |
97 |
97 |
98 // Returns the enabled state. |
98 // Returns the enabled state. |
99 ActionControl.prototype.isEnabled = function() { |
99 ActionControl.prototype.isEnabled = function() { |
100 return this.enabled; |
100 return this.enabled; |
101 } |
101 }; |
102 |
102 |
103 // Sets the enabled state. |
103 // Sets the enabled state. |
104 ActionControl.prototype.setEnabled = function(enabled) { |
104 ActionControl.prototype.setEnabled = function(enabled) { |
105 uiLogger.debug("ActionControl.setEnabled(" + enabled + ")"); |
105 uiLogger.debug("ActionControl.setEnabled(" + enabled + ")"); |
106 // switch the state |
106 // switch the state |
107 this.enabled = enabled; |
107 this.enabled = enabled; |
108 } |
108 }; |
109 |
109 |
110 // Sets the focused state for the control. |
110 // Sets the focused state for the control. |
111 // Note: This may not always succeed. |
111 // Note: This may not always succeed. |
112 ActionControl.prototype.setFocused = function(focused) { |
112 ActionControl.prototype.setFocused = function(focused) { |
113 uiLogger.debug("ActionControl.setFocused(" + focused + ")"); |
113 uiLogger.debug("ActionControl.setFocused(" + focused + ")"); |
116 this.linkElement.focus(); |
116 this.linkElement.focus(); |
117 } else { |
117 } else { |
118 this.linkElement.blur(); |
118 this.linkElement.blur(); |
119 } |
119 } |
120 } |
120 } |
121 } |
121 }; |
122 |
122 |
123 // Callback for clicks. |
123 // Callback for clicks. |
124 ActionControl.prototype.controlClicked = function(event) { |
124 ActionControl.prototype.controlClicked = function(event) { |
125 uiLogger.debug("ActionControl.controlClicked()"); |
125 uiLogger.debug("ActionControl.controlClicked()"); |
126 |
126 |
132 } |
132 } |
133 |
133 |
134 // notify event listeners |
134 // notify event listeners |
135 this.actionPerformed(event); |
135 this.actionPerformed(event); |
136 } |
136 } |
137 } |
137 }; |
138 |
138 |
139 // Callback for action performed events. |
139 // Callback for action performed events. |
140 ActionControl.prototype.actionPerformed = function(event) { |
140 ActionControl.prototype.actionPerformed = function(event) { |
141 uiLogger.debug("ActionControl.actionPerformed()"); |
141 uiLogger.debug("ActionControl.actionPerformed()"); |
142 // notify event listeners |
142 // notify event listeners |
143 this.fireEvent(this.createEvent("ActionPerformed", event)); |
143 this.fireEvent(this.createEvent("ActionPerformed", event)); |
144 } |
144 }; |