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

Unified Diff: sky/framework/sky-radio/sky-radio.sky

Issue 874303003: Move sky-box,-button,-checkbox,-radio out of their directories (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/sky-radio.sky ('k') | sky/tests/resources/test-element.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/sky-radio/sky-radio.sky
diff --git a/sky/framework/sky-radio/sky-radio.sky b/sky/framework/sky-radio/sky-radio.sky
deleted file mode 100644
index 687dd5dc8fa9d4f9cc0af79a8a2d24509786b0d9..0000000000000000000000000000000000000000
--- a/sky/framework/sky-radio/sky-radio.sky
+++ /dev/null
@@ -1,105 +0,0 @@
-<!--
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
--->
-<import src="/sky/framework/sky-button/sky-button.sky" as="SkyButton" />
-
-<sky-element
- name="sky-radio"
- attributes="selected:boolean, group:string"
- on-click="handleClick">
-<template>
- <style>
- :host {
- display: inline-block;
- -webkit-user-select: none;
- width: 14px;
- height: 14px;
- border-radius: 7px;
- border: 1px solid blue;
- margin: 0 5px;
- }
- :host([highlight=true]) box {
- background-color: orange;
- }
- dot {
- -webkit-user-select: none;
- width: 10px;
- height: 10px;
- border-radius: 5px;
- background-color: black;
- margin: 2px;
- }
- </style>
- <template if="{{ selected }}">
- <dot />
- </template>
-</template>
-<script>
-const kControllerMap = new WeakMap();
-
-class RadioGroupController {
- static forRadio(radio) {
- var scope = radio.ownerScope;
- var controller = kControllerMap.get(scope);
- if (!controller)
- kControllerMap.set(scope, new RadioGroupController());
- return kControllerMap.get(scope);
- }
- constructor() {
- this.radios = new Set();
- }
- addRadio(radio) {
- this.radios.add(radio);
- // If this new radio is default-selected, take selection from the group.
- if (radio.selected)
- this.takeSelectionFromGroup(radio);
- }
- removeRadio(radio) {
- this.radios.remove(radio);
- }
- takeSelectionFromGroup(selectedRadio) {
- // Emtpy/null/undefined group means an isolated radio.
- if (!selectedRadio.group)
- return;
- this.radios.forEach(function(radio) {
- if (selectedRadio === radio)
- return;
- if (radio.group != selectedRadio.group)
- return;
- radio.selected = false;
- });
- }
-};
-
-module.exports = class extends SkyButton {
- created() {
- super.created();
-
- this.controller = null;
- }
- attached() {
- super.attached();
- this.controller = RadioGroupController.forRadio(this);
- this.controller.addRadio(this);
- }
- detached() {
- super.detached();
- this.controller.removeRadio(this);
- this.controller = null;
- }
- selectedChanged(oldValue, newValue) {
- if (newValue && this.controller)
- this.controller.takeSelectionFromGroup(this);
- }
- groupChanged(oldValue, newValue) {
- if (this.selected && this.controller)
- this.controller.takeSelectionFromGroup(this);
- }
- handleClick() {
- this.selected = true;
- }
-}.register();
-</script>
-</sky-element>
« no previous file with comments | « sky/framework/sky-radio.sky ('k') | sky/tests/resources/test-element.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698