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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width | 199 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width |
200 // of keyboard. | 200 // of keyboard. |
201 }, | 201 }, |
202 | 202 |
203 /** | 203 /** |
204 * Candidate is clicked. | 204 * Candidate is clicked. |
205 * @param {number} index The index of the candidate. | 205 * @param {number} index The index of the candidate. |
206 * @return {void} | 206 * @return {void} |
207 */ | 207 */ |
208 candidateClicked: function(index) { | 208 candidateClicked: function(index) { |
209 chrome.experimental.inputUI.candidateClicked(index, 1); | 209 chrome.experimental.input.ui.candidateClicked(index, 1); |
210 }, | 210 }, |
211 | 211 |
212 /** | 212 /** |
213 * Go to the previous page of the lookup table. | 213 * Go to the previous page of the lookup table. |
214 * @return {void} | 214 * @return {void} |
215 */ | 215 */ |
216 pageUp: function() { | 216 pageUp: function() { |
217 chrome.experimental.inputUI.pageUp(); | 217 chrome.experimental.input.ui.pageUp(); |
218 }, | 218 }, |
219 | 219 |
220 /** | 220 /** |
221 * Go to the next page of the lookup table. | 221 * Go to the next page of the lookup table. |
222 * @return {void} | 222 * @return {void} |
223 */ | 223 */ |
224 pageDown: function() { | 224 pageDown: function() { |
225 chrome.experimental.inputUI.pageDown(); | 225 chrome.experimental.input.ui.pageDown(); |
226 }, | 226 }, |
227 }; | 227 }; |
228 | 228 |
229 var imeui = null; | 229 var imeui = null; |
230 | 230 |
231 /** | 231 /** |
232 * Initialize Ime Ui | 232 * Initialize Ime Ui |
233 * @param {Element} element The html element which will contain the ImeUi. | 233 * @param {Element} element The html element which will contain the ImeUi. |
234 * @return {void} | 234 * @return {void} |
235 */ | 235 */ |
236 function initIme(element) { | 236 function initIme(element) { |
237 if (imeui) { | 237 if (imeui) { |
238 // ime ui has been initialized. | 238 // ime ui has been initialized. |
239 return; | 239 return; |
240 } | 240 } |
241 | 241 |
242 try { | 242 try { |
243 // Register self to receive input method UI events. | 243 // Register self to receive input method UI events. |
244 chrome.experimental.inputUI.register(); | 244 chrome.experimental.input.ui.register(); |
245 } catch (e) { | 245 } catch (e) { |
246 // The ime is not enabled in chromium. | 246 // The ime is not enabled in chromium. |
247 return; | 247 return; |
248 } | 248 } |
249 | 249 |
250 imeui = new ImeUi(); | 250 imeui = new ImeUi(); |
251 | 251 |
252 element.appendChild(imeui); | 252 element.appendChild(imeui); |
253 | 253 |
254 // new row | 254 // new row |
255 var clearingDiv = document.createElement('div'); | 255 var clearingDiv = document.createElement('div'); |
256 clearingDiv.style.clear = 'both'; | 256 clearingDiv.style.clear = 'both'; |
257 element.appendChild(clearingDiv); | 257 element.appendChild(clearingDiv); |
258 | 258 |
259 // Install events handlers. | 259 // Install events handlers. |
260 chrome.experimental.inputUI.onSetCursorLocation.addListener( | 260 chrome.experimental.input.ui.onSetCursorLocation.addListener( |
261 function(x, y, w, h) { | 261 function(x, y, w, h) { |
262 imeui.setCursorLocation(x, y, w, h); | 262 imeui.setCursorLocation(x, y, w, h); |
263 }); | 263 }); |
264 chrome.experimental.inputUI.onUpdateAuxiliaryText.addListener( | 264 chrome.experimental.input.ui.onUpdateAuxiliaryText.addListener( |
265 function(text) { | 265 function(text) { |
266 imeui.updateAuxiliaryText(text); | 266 imeui.updateAuxiliaryText(text); |
267 }); | 267 }); |
268 chrome.experimental.inputUI.onUpdateLookupTable.addListener( | 268 chrome.experimental.input.ui.onUpdateLookupTable.addListener( |
269 function(table) { | 269 function(table) { |
270 imeui.updateLookupTable(table); | 270 imeui.updateLookupTable(table); |
271 }); | 271 }); |
272 } | 272 } |
273 | 273 |
274 /** | 274 /** |
275 * Updates Ime Ui. It should be called when window is resized. | 275 * Updates Ime Ui. It should be called when window is resized. |
276 * @return {void} | 276 * @return {void} |
277 */ | 277 */ |
278 function updateIme() { | 278 function updateIme() { |
279 if (imeui) { | 279 if (imeui) { |
280 imeui.update(); | 280 imeui.update(); |
281 } | 281 } |
282 } | 282 } |
OLD | NEW |