Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: sky/framework/sky-input.sky

Issue 831353003: Implement <sky-input> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/examples/widgets/index.sky ('k') | sky/tools/debugger/debugger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!--
2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 -->
6 <import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
7
8 <sky-element name="sky-input" attributes="value:string">
9 <template>
10 <style>
11 :host {
12 display: flex;
13 border: 1px solid blue;
14 margin: 5px;
15 padding: 4px;
16 }
17 #control {
18 align-self: center;
19 height: 1.2em;
20 white-space: nowrap;
21 overflow: hidden;
22 }
23 </style>
24 <div id="control" contenteditable on-keydown="handleKeyDown">{{ value }}</div>
25 </template>
26 <script>
27 module.exports = class extends SkyElement {
28 shadowRootReady() {
29 var control = this.shadowRoot.getElementById('control');
30
31 var observer = new MutationObserver(function() {
32 this.value = control.textContent;
33 this.dispatchEvent(new CustomEvent('change', {
34 bubbles: true,
35 }));
36 }.bind(this));
37
38 observer.observe(control, {
39 subtree: true,
40 characterData: true,
41 childList: true,
42 });
43 }
44 handleKeyDown(event) {
45 // TODO(abarth): You can still get newlines if the user pastes them.
46 if (event.keyCode == 0xD)
47 event.preventDefault();
48 }
49 }.register();
50 </script>
51 </sky-element>
OLDNEW
« no previous file with comments | « sky/examples/widgets/index.sky ('k') | sky/tools/debugger/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698