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

Unified Diff: third_party/polymer/components/core-menu/core-submenu.html

Issue 582873003: Polymer elements added to third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
Index: third_party/polymer/components/core-menu/core-submenu.html
diff --git a/third_party/polymer/components/core-menu/core-submenu.html b/third_party/polymer/components/core-menu/core-submenu.html
new file mode 100644
index 0000000000000000000000000000000000000000..42e422a21d6d0ee75dab32cab0732adbaa25994f
--- /dev/null
+++ b/third_party/polymer/components/core-menu/core-submenu.html
@@ -0,0 +1,106 @@
+<!--
+Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
+The complete set of authors may be found at http://polymer.github.io/AUTHORS
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
+-->
+
+<!--
+Use to create nested menus inside of `core-menu` elements.
+
+ <core-menu selected="0">
+
+ <core-submenu icon="settings" label="Topics">
+ <core-item label="Topic 1"></core-item>
+ <core-item label="Topic 2"></core-item>
+ </core-submenu>
+
+ <core-submenu icon="settings" label="Favorites">
+ <core-item label="Favorite 1"></core-item>
+ <core-item label="Favorite 2"></core-item>
+ <core-item label="Favorite 3"></core-item>
+ </core-submenu>
+
+ </core-menu>
+
+There is a margin set on the submenu to indent the items.
+You can override the margin by doing:
+
+ core-submenu::shadow #submenu {
+ margin-left: 20px;
+ }
+
+@group Polymer Core Elements
+@element core-submenu
+@extends core-item
+-->
+
+<link rel="import" href="../core-item/core-item.html">
+<link rel="import" href="../core-menu/core-menu.html">
+<link rel="import" href="../core-collapse/core-collapse.html">
+
+<polymer-element name="core-submenu" attributes="selected selectedItem label icon src valueattr">
+<template>
+
+ <link rel="stylesheet" href="core-submenu.css">
+
+ <core-item src="{{src}}" label="{{label}}" icon="{{icon}}" class="{{ {'core-selected' : active} | tokenList}}" on-tap="{{activate}}">
+ <content select=".item-content"></content>
+ </core-item>
+
+ <core-menu id="submenu" selected="{{selected}}" selectedItem="{{selectedItem}}" valueattr="{{valueattr}}">
+ <content></content>
+ </core-menu>
+
+ <core-collapse target="{{$.submenu}}" opened="{{opened}}"></core-collapse>
+
+</template>
+<script>
+
+ Polymer('core-submenu', {
+
+ publish: {
+ active: {value: false, reflect: true}
+ },
+
+ opened: false,
+
+ get items() {
+ return this.$.submenu.items;
+ },
+
+ hasItems: function() {
+ return !!this.items.length;
+ },
+
+ unselectAllItems: function() {
+ this.$.submenu.selected = null;
+ this.$.submenu.clearSelection();
+ },
+
+ activeChanged: function() {
+ if (this.hasItems()) {
+ this.opened = this.active;
+ }
+ if (!this.active) {
+ this.unselectAllItems();
+ }
+ },
+
+ toggle: function() {
+ this.opened = !this.opened;
+ },
+
+ activate: function() {
+ if (this.hasItems() && this.active) {
+ this.toggle();
+ this.unselectAllItems();
+ }
+ }
+
+ });
+
+</script>
+</polymer-element>
« no previous file with comments | « third_party/polymer/components/core-menu/core-submenu.css ('k') | third_party/polymer/components/core-menu/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698