OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
| 2 // limitations under the License. |
| 3 // See the License for the specific language governing permissions and |
| 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
| 6 // Unless required by applicable law or agreed to in writing, software |
| 7 // |
| 8 // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 // |
| 10 // You may obtain a copy of the License at |
| 11 // you may not use this file except in compliance with the License. |
| 12 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 // |
| 14 goog.provide('i18n.input.chrome.inputview.ReadyState'); |
| 15 |
| 16 |
| 17 |
| 18 goog.scope(function() { |
| 19 /** |
| 20 * The system ready state which mainains a state bit map. |
| 21 * Inputview controller uses this to determine whether the system is ready to |
| 22 * render the UI. |
| 23 * |
| 24 * @constructor |
| 25 */ |
| 26 i18n.input.chrome.inputview.ReadyState = function() { |
| 27 }; |
| 28 var ReadyState = i18n.input.chrome.inputview.ReadyState; |
| 29 |
| 30 |
| 31 /** |
| 32 * The state type. |
| 33 * |
| 34 * @enum {number} |
| 35 */ |
| 36 ReadyState.StateType = { |
| 37 IME_LIST_READY: 1, |
| 38 KEYBOARD_CONFIG_READY: 2, |
| 39 LAYOUT_READY: 4, |
| 40 LAYOUT_CONFIG_READY: 8, |
| 41 M17N_LAYOUT_READY: 16 |
| 42 }; |
| 43 |
| 44 |
| 45 /** |
| 46 * The internal ready state bit map. |
| 47 * |
| 48 * @private {number} |
| 49 */ |
| 50 ReadyState.prototype.state_ = 0; |
| 51 |
| 52 |
| 53 /** |
| 54 * Gets whether the system is ready. |
| 55 * |
| 56 * @return {boolean} Whether the system is ready. |
| 57 */ |
| 58 ReadyState.prototype.isAllReady = function() { |
| 59 return !!(this.state_ & ( |
| 60 ReadyState.StateType.IME_LIST_READY | |
| 61 ReadyState.StateType.KEYBOARD_CONFIG_READY | |
| 62 ReadyState.StateType.LAYOUT_READY | |
| 63 ReadyState.StateType.LAYOUT_CONFIG_READY | |
| 64 ReadyState.StateType.M17N_LAYOUT_READY)); |
| 65 }; |
| 66 |
| 67 |
| 68 /** |
| 69 * Gets whether a specific state type is ready. |
| 70 * |
| 71 * @param {ReadyState.StateType} stateType . |
| 72 * @return {boolean} Whether is ready. |
| 73 */ |
| 74 ReadyState.prototype.isReady = function(stateType) { |
| 75 return !!(this.state_ & stateType); |
| 76 }; |
| 77 |
| 78 |
| 79 /** |
| 80 * Sets state ready for the given state type. |
| 81 * |
| 82 * @param {ReadyState.StateType} stateType . |
| 83 */ |
| 84 ReadyState.prototype.markStateReady = function(stateType) { |
| 85 this.state_ |= stateType; |
| 86 }; |
| 87 }); // goog.scope |
OLD | NEW |