diff options
Diffstat (limited to 'ui/keyboard')
-rw-r--r-- | ui/keyboard/resources/elements/kb-key-base.html | 47 | ||||
-rw-r--r-- | ui/keyboard/resources/elements/kb-key.html | 21 | ||||
-rw-r--r-- | ui/keyboard/resources/elements/kb-shift-key.html | 10 |
3 files changed, 50 insertions, 28 deletions
diff --git a/ui/keyboard/resources/elements/kb-key-base.html b/ui/keyboard/resources/elements/kb-key-base.html index fc876ce..991384a 100644 --- a/ui/keyboard/resources/elements/kb-key-base.html +++ b/ui/keyboard/resources/elements/kb-key-base.html @@ -109,11 +109,7 @@ } }, down: function(event) { - var detail = this.populateDetails(); - if (this.keysetRules && this.keysetRules.down != undefined) { - detail.toKeyset = this.keysetRules.down[TO_KEYSET - OFFSET]; - detail.nextKeyset = this.keysetRules.down[NEXT_KEYSET - OFFSET]; - } + var detail = this.populateDetails('down'); this.fire('key-down', detail); this.longPressTimer = this.generateLongPressTimer(); }, @@ -123,11 +119,7 @@ }, up: function(event) { clearTimeout(this.longPressTimer); - var detail = this.populateDetails(); - if (this.keysetRules && this.keysetRules.up != undefined) { - detail.toKeyset = this.keysetRules.up[TO_KEYSET - OFFSET]; - detail.nextKeyset = this.keysetRules.up[NEXT_KEYSET - OFFSET]; - } + var detail = this.populateDetails('up'); this.fire('key-up', detail); }, @@ -149,12 +141,35 @@ return this.invert? (this.char || this.textContent) : this.hintText; }, - populateDetails: function() { - return { - char: this.charValue, - toLayout: this.toLayout, - repeat: this.repeat - }; + /** + * Returns a subset of the key attributes. + * @param {string} caller The id of the function which called + * populateDetails. + */ + populateDetails: function(caller) { + var detail = { + char: this.charValue, + toLayout: this.toLayout, + repeat: this.repeat + }; + + switch (caller) { + case ('up'): + if (this.keysetRules && this.keysetRules.up != undefined) { + detail.toKeyset = this.keysetRules.up[TO_KEYSET - OFFSET]; + detail.nextKeyset = this.keysetRules.up[NEXT_KEYSET - OFFSET]; + } + break; + case ('down'): + if (this.keysetRules && this.keysetRules.down != undefined) { + detail.toKeyset = this.keysetRules.down[TO_KEYSET - OFFSET]; + detail.nextKeyset = this.keysetRules.down[NEXT_KEYSET - OFFSET]; + } + break; + default: + break; + } + return detail; }, generateLongPressTimer: function() { diff --git a/ui/keyboard/resources/elements/kb-key.html b/ui/keyboard/resources/elements/kb-key.html index 7adbe23..bc1011a 100644 --- a/ui/keyboard/resources/elements/kb-key.html +++ b/ui/keyboard/resources/elements/kb-key.html @@ -43,10 +43,12 @@ /** * Returns a subset of the key attributes. + * @param {string} caller The id of the function that called + * populateDetails. * @return {Object} Mapping of attributes for the key element. */ - populateDetails: function() { - var details = this.super(); + populateDetails: function(caller) { + var details = this.super([caller]); details.keyCode = this.keyCode; details.shiftModifier = this.shiftModifier; return details; @@ -60,11 +62,16 @@ extends="kb-key"> <script> Polymer('kb-abc-key', { - // TODO(rsadam@): Move this logic into populateDetails. - down: function(event) { - var detail = this.populateDetails(); - detail.relegateToShift = true; - this.fire('key-down', detail); + populateDetails: function(caller) { + var detail = this.super([caller]); + switch (caller) { + case ('down'): + detail.relegateToShift = true; + break; + default: + break; + } + return detail; } }); </script> diff --git a/ui/keyboard/resources/elements/kb-shift-key.html b/ui/keyboard/resources/elements/kb-shift-key.html index 7099147..9c81edc 100644 --- a/ui/keyboard/resources/elements/kb-shift-key.html +++ b/ui/keyboard/resources/elements/kb-shift-key.html @@ -64,14 +64,14 @@ else return; } - this.super(); + this.super([event]); }, out: function(event) { // Sliding off the shift key while chording is treated as a key-up. if (state == KEY_STATES.CHORDING && event.pointerId == chordingId) { state = KEY_STATES.UNLOCKED; - var detail = this.populateDetails(); + var detail = this.populateDetails('out'); this.fire("key-out", detail); } }, @@ -98,7 +98,7 @@ } chordingId = event.pointerId; // Trigger parent behaviour. - this.super(); + this.super([event]); this.fire('enable-sel'); // Populate double click transition details. var detail = {}; @@ -163,8 +163,8 @@ return detail; }, - populateDetails: function() { - var detail = this.super(); + populateDetails: function(caller) { + var detail = this.super([caller]); switch(state) { case(KEY_STATES.LOCKED): detail.toKeyset = this.upperCaseKeysetId; |