Commit 88d07de9 authored by kevers@chromium.org's avatar kevers@chromium.org

Dynamically load keyboard layouts.

BUG=260278

Review URL: https://chromiumcodereview.appspot.com/23819032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222111 0039d316-1c4b-4281-b951-d872f2087c98
parent f5a807ce
...@@ -479,7 +479,24 @@ ...@@ -479,7 +479,24 @@
keyboard.appendChild(flattenKeysets(keysets.content)); keyboard.appendChild(flattenKeysets(keysets.content));
this.selectDefaultKeyset(); this.selectDefaultKeyset();
} else { } else {
console.error('Unable to find layout ' + this.layout); // Add link for the keysets if missing from the document. Force
// a layout change after resolving the import of the link.
var query = 'link[id=' + this.layout + ']';
if (!document.querySelector(query)) {
// Layout has not beeen loaded yet.
var link = document.createElement('link');
link.id = this.layout;
link.setAttribute('rel', 'import');
link.setAttribute('href', 'layouts/' + this.layout + '.html');
document.head.appendChild(link);
// Load content for the new link element.
var self = this;
HTMLImports.importer.load(document, function() {
HTMLImports.parser.parseLink(link);
self.layoutChanged();
});
}
} }
} }
this.classList.remove('caps-locked'); this.classList.remove('caps-locked');
......
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
<link rel="import" href="elements/kb-keyboard.html"> <link rel="import" href="elements/kb-keyboard.html">
<link rel="import" href="elements/kb-keyset.html"> <link rel="import" href="elements/kb-keyset.html">
<link rel="import" href="elements/kb-row.html"> <link rel="import" href="elements/kb-row.html">
<!-- TODO(kevers|biao): Switch to dynamic loading strategy once supported <link rel="import" href="elements/kb-key-sequence.html">
in Polymer (http://www.crbug.com/260278).--> <link rel="import" href="elements/kb-key-import.html">
<link id="dvorak" rel="import" href="layouts/dvorak.html">
<link id="numeric" rel="import" href="layouts/numeric.html">
<link id="qwerty" rel="import" href="layouts/qwerty.html">
<!--TODO(stevet): Import 'Open Sans' font. --> <!--TODO(stevet): Import 'Open Sans' font. -->
<!-- New layouts are dynamically loaded on demand. The link elements are
-- inserted here.
-->
</head> </head>
<body> <body>
<kb-keyboard id="keyboard" touch-action="none" layout="qwerty"> <kb-keyboard id="keyboard" touch-action="none" layout="qwerty">
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
-- found in the LICENSE file. -- found in the LICENSE file.
--> -->
<link rel="import" href="../elements/kb-key-sequence.html">
<link rel="import" href="../elements/kb-key-import.html">
<link id="spacebar-row" rel="import" href="spacebar-row.html"> <link id="spacebar-row" rel="import" href="spacebar-row.html">
<template> <template>
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
-- found in the LICENSE file. -- found in the LICENSE file.
--> -->
<link rel="import" href="../elements/kb-key-sequence.html">
<link rel="import" href="../elements/kb-key-import.html">
<link id="spacebar-row" rel="import" href="spacebar-row.html">
<template> <template>
<kb-keyset id="numeric-symbol" isDefault=true> <kb-keyset id="numeric-symbol" isDefault=true>
<kb-row> <kb-row>
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
-- found in the LICENSE file. -- found in the LICENSE file.
--> -->
<link rel="import" href="../elements/kb-key-sequence.html">
<link rel="import" href="../elements/kb-key-import.html">
<link id="spacebar-row" rel="import" href="spacebar-row.html"> <link id="spacebar-row" rel="import" href="spacebar-row.html">
<template> <template>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment