Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview An input method UI implementation | 6 * @fileoverview An input method UI implementation |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Const variables | 10 * Const variables |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 that.appendChild(candidate); | 116 that.appendChild(candidate); |
| 117 candidate.onclick = function() { | 117 candidate.onclick = function() { |
| 118 that.candidateClicked(index); | 118 that.candidateClicked(index); |
| 119 }; | 119 }; |
| 120 } | 120 } |
| 121 for (var i = 0; i < IME_MAX_CANDIDATES; i++) { | 121 for (var i = 0; i < IME_MAX_CANDIDATES; i++) { |
| 122 createCandidateButton(i); | 122 createCandidateButton(i); |
| 123 } | 123 } |
| 124 | 124 |
| 125 this.appendChild(this.pageDown_); | 125 this.appendChild(this.pageDown_); |
| 126 this.update(); | |
| 126 }, | 127 }, |
| 127 | 128 |
| 128 /** | 129 /** |
| 130 * Returns true if Ime Ui is visible. | |
| 131 * @return {boolean} | |
| 132 */ | |
| 133 get visible() { | |
| 134 return this.style.display != 'none'; | |
| 135 }, | |
| 136 | |
| 137 /** | |
| 129 * Sets the input cursor location. | 138 * Sets the input cursor location. |
| 130 * @param {number} x The x of the input cursor coordinates. | 139 * @param {number} x The x of the input cursor coordinates. |
| 131 * @param {number} y The y of the input cursor coordinates. | 140 * @param {number} y The y of the input cursor coordinates. |
| 132 * @param {number} w The width of the input cursor. | 141 * @param {number} w The width of the input cursor. |
| 133 * @param {number} h The height of the input cursor. | 142 * @param {number} h The height of the input cursor. |
| 134 * @return {void} | 143 * @return {void} |
| 135 */ | 144 */ |
| 136 setCursorLocation: function(x, y, w, h) { | 145 setCursorLocation: function(x, y, w, h) { |
| 137 // Currently we do nothing. | 146 // Currently we do nothing. |
| 138 }, | 147 }, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 164 } else { | 173 } else { |
| 165 for (var i = 0; i < this.candidates_.length; i++) { | 174 for (var i = 0; i < this.candidates_.length; i++) { |
| 166 this.candidates_[i].text = ''; | 175 this.candidates_[i].text = ''; |
| 167 } | 176 } |
| 168 } | 177 } |
| 169 this.table_ = table; | 178 this.table_ = table; |
| 170 this.update(); | 179 this.update(); |
| 171 }, | 180 }, |
| 172 | 181 |
| 173 update : function() { | 182 update : function() { |
| 174 // TODO(penghuang) Add API for show and hide ImeUI. | 183 var should_visible = |
|
bryeung
2011/06/03 19:14:52
maybe just visible or visible_now?
Peng
2011/06/03 22:22:10
Done.
| |
| 175 // Currently, ImeUi is always visible. | 184 (this.table_ && this.table_.visible) || this.auxiliary_.text_; |
| 176 if (true || (this.table_ && this.table_.visible) || this.auxiliary_.text_) { | 185 |
| 177 this.style.display = 'block'; | 186 if (should_visible == this.visible) { |
| 178 } else { | 187 return; |
| 179 this.style.display = 'none'; | |
| 180 } | 188 } |
| 181 | 189 |
| 190 if (should_visible) { | |
| 191 chrome.experimental.input.setKeyboardHeight(300 + IME_HEIGHT); | |
| 192 this.style.display = 'inline-block'; | |
| 193 } | |
| 194 else { | |
|
bryeung
2011/06/03 19:14:52
nit: move to line above
Peng
2011/06/03 22:22:10
Done.
| |
| 195 this.style.display = 'none'; | |
| 196 chrome.experimental.input.setKeyboardHeight(300); | |
| 197 } | |
| 182 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width | 198 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width |
| 183 // of keyboard. | 199 // of keyboard. |
| 184 }, | 200 }, |
| 185 | 201 |
| 186 /** | 202 /** |
| 187 * Candidate is clicked. | 203 * Candidate is clicked. |
| 188 * @param {number} index The index of the candidate. | 204 * @param {number} index The index of the candidate. |
| 189 * @return {void} | 205 * @return {void} |
| 190 */ | 206 */ |
| 191 candidateClicked: function(index) { | 207 candidateClicked: function(index) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 272 |
| 257 /** | 273 /** |
| 258 * Updates Ime Ui. It should be called when window is resized. | 274 * Updates Ime Ui. It should be called when window is resized. |
| 259 * @return {void} | 275 * @return {void} |
| 260 */ | 276 */ |
| 261 function updateIme() { | 277 function updateIme() { |
| 262 if (imeui) { | 278 if (imeui) { |
| 263 imeui.update(); | 279 imeui.update(); |
| 264 } | 280 } |
| 265 } | 281 } |
| OLD | NEW |