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

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

Issue 845283003: Allow on-* event handlers on <sky-element>. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add back attr validation. 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
OLDNEW
1 <!-- 1 <!--
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 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 <import src="/sky/framework/sky-button/sky-button.sky" as="SkyButton" /> 6 <import src="/sky/framework/sky-button/sky-button.sky" as="SkyButton" />
7 7
8 <sky-element name="sky-radio" attributes="selected:boolean, group:string"> 8 <sky-element
9 name="sky-radio"
10 attributes="selected:boolean, group:string"
11 on-mouseup="handleMouseUp">
9 <template> 12 <template>
10 <style> 13 <style>
11 :host { 14 :host {
12 display: inline-block; 15 display: inline-block;
13 -webkit-user-select: none; 16 -webkit-user-select: none;
14 width: 14px; 17 width: 14px;
15 height: 14px; 18 height: 14px;
16 border-radius: 7px; 19 border-radius: 7px;
17 border: 1px solid blue; 20 border: 1px solid blue;
18 margin: 0 5px; 21 margin: 0 5px;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 radio.selected = false; 71 radio.selected = false;
69 }); 72 });
70 } 73 }
71 }; 74 };
72 75
73 module.exports = class extends SkyButton { 76 module.exports = class extends SkyButton {
74 created() { 77 created() {
75 super.created(); 78 super.created();
76 79
77 this.controller = null; 80 this.controller = null;
78
79 this.addEventListener('mouseup', function() {
80 this.selected = true;
81 });
82 } 81 }
83 attached() { 82 attached() {
84 super.attached(); 83 super.attached();
85 this.controller = RadioGroupController.forRadio(this); 84 this.controller = RadioGroupController.forRadio(this);
86 this.controller.addRadio(this); 85 this.controller.addRadio(this);
87 } 86 }
88 detached() { 87 detached() {
89 super.detached(); 88 super.detached();
90 this.controller.removeRadio(this); 89 this.controller.removeRadio(this);
91 this.controller = null; 90 this.controller = null;
92 } 91 }
93 selectedChanged(oldValue, newValue) { 92 selectedChanged(oldValue, newValue) {
94 if (newValue && this.controller) 93 if (newValue && this.controller)
95 this.controller.takeSelectionFromGroup(this); 94 this.controller.takeSelectionFromGroup(this);
96 } 95 }
97 groupChanged(oldValue, newValue) { 96 groupChanged(oldValue, newValue) {
98 if (this.selected && this.controller) 97 if (this.selected && this.controller)
99 this.controller.takeSelectionFromGroup(this); 98 this.controller.takeSelectionFromGroup(this);
100 } 99 }
100 handleMouseUp() {
101 this.selected = true;
102 }
101 }.register(); 103 }.register();
102 </script> 104 </script>
103 </sky-element> 105 </sky-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698