Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!-- | 1 <!-- |
| 2 -- Copyright 2013 The Chromium Authors. All rights reserved. | 2 -- Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 -- Use of this source code is governed by a BSD-style license that can be | 3 -- Use of this source code is governed by a BSD-style license that can be |
| 4 -- found in the LICENSE file. | 4 -- found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" | 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" |
| 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" | 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" |
| 9 on-pointerdown="down" on-enable-sel="enableSel" | 9 on-pointerdown="down" on-enable-sel="enableSel" |
| 10 on-enable-dbl="enableDbl" attributes="keyset layout rows capsLocked"> | 10 on-enable-dbl="enableDbl" attributes="keyset layout rows capsLocked"> |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 * keyset for the new layout. | 472 * keyset for the new layout. |
| 473 */ | 473 */ |
| 474 layoutChanged: function() { | 474 layoutChanged: function() { |
| 475 if (!this.selectDefaultKeyset()) { | 475 if (!this.selectDefaultKeyset()) { |
| 476 // Keyset selection fails if the keysets have not been loaded yet. | 476 // Keyset selection fails if the keysets have not been loaded yet. |
| 477 var keysets = document.querySelector('#' + this.layout); | 477 var keysets = document.querySelector('#' + this.layout); |
| 478 if (keysets) { | 478 if (keysets) { |
| 479 keyboard.appendChild(flattenKeysets(keysets.content)); | 479 keyboard.appendChild(flattenKeysets(keysets.content)); |
| 480 this.selectDefaultKeyset(); | 480 this.selectDefaultKeyset(); |
| 481 } else { | 481 } else { |
| 482 console.error('Unable to find layout ' + this.layout); | 482 // Add link for the keysets if missing from the document. Force |
| 483 // a layout change after resolving the import of the link. | |
| 484 var query = 'link[id=' + this.layout + ']'; | |
| 485 if (!document.querySelector(query)) { | |
| 486 // Layout has not beeen loaded yet. | |
| 487 var link = document.createElement('link'); | |
| 488 link.id = this.layout; | |
| 489 link.setAttribute('rel', 'import'); | |
| 490 link.setAttribute('href', 'layouts/' + this.layout + '.html'); | |
| 491 document.head.appendChild(link); | |
| 492 | |
| 493 // Load content for the new link element. | |
| 494 var self = this; | |
| 495 HTMLImports.importer.load(document, function() { | |
| 496 HTMLImports.parser.parseLink(link); | |
|
bshe
2013/09/06 21:12:21
would it enter infinite loop if failed to load?
kevers
2013/09/09 15:44:04
We do a check for an existing link element before
| |
| 497 self.layoutChanged(); | |
| 498 }); | |
| 499 } | |
| 483 } | 500 } |
| 484 } | 501 } |
| 485 this.classList.remove('caps-locked'); | 502 this.classList.remove('caps-locked'); |
| 486 this.cacheCapsLock(); | 503 this.cacheCapsLock(); |
| 487 }, | 504 }, |
| 488 | 505 |
| 489 /** | 506 /** |
| 490 * Caches the keyset transitions required when caps lock is enabled. | 507 * Caches the keyset transitions required when caps lock is enabled. |
| 491 */ | 508 */ |
| 492 cacheCapsLock: function() { | 509 cacheCapsLock: function() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 } | 547 } |
| 531 } | 548 } |
| 532 if (keysetsLoaded) | 549 if (keysetsLoaded) |
| 533 console.error('No default keyset found for ' + this.layout); | 550 console.error('No default keyset found for ' + this.layout); |
| 534 return false; | 551 return false; |
| 535 } | 552 } |
| 536 }); | 553 }); |
| 537 </script> | 554 </script> |
| 538 </polymer-element> | 555 </polymer-element> |
| 539 | 556 |
| OLD | NEW |