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

Side by Side Diff: pkg/polymer/lib/elements/polymer-ui-menu-button/polymer-ui-menu-button.html

Issue 175443005: [polymer] import all elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated from bower Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright 2013 The Polymer Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style
4 license that can be found in the LICENSE file.
5 -->
6 <!--
7 /**
8 * @module Polymer Elements
9 */
10 /**
11 * polymer-ui-menu-button is a polymer-ui-icon-button with a drop down menu
12 * that allows the user to select an option. The drop down menu is styled with
13 * an arrow pointing to the button, and can be positioned to the top or the
14 * bottom of the button with the valign property. The valign property aligns
15 * the menu to the left or right edge of the button.
16 *
17 * Example:
18 *
19 * <polymer-ui-menu-button selected="0">
20 * <polymer-ui-menu-item icon="settings" label="Settings"></polymer-ui-men u-item>
21 * <polymer-ui-menu-item icon="dialog" label="Dialog"></polymer-ui-menu-it em>
22 * <polymer-ui-menu-item icon="search" label="Search"></polymer-ui-menu-it em>
23 * </polymer-ui-menu-button>
24 *
25 * @class polymer-ui-menu-button
26 */
27 -->
28 <link rel="import" href="../polymer/polymer.html">
29 <link rel="import" href="../polymer-anchor-point/polymer-anchor-point.html">
30 <link rel="import" href="../polymer-media-query/polymer-media-query.html">
31 <link rel="import" href="../polymer-overlay/polymer-overlay.html">
32 <link rel="import" href="../polymer-ui-icon-button/polymer-ui-icon-button.html">
33 <link rel="import" href="../polymer-ui-menu/polymer-ui-menu.html">
34 <link rel="import" href="../polymer-ui-arrow/polymer-ui-arrow.html">
35
36 <polymer-element name="polymer-ui-menu-button" attributes="src icon opened respo nsive halign valign selected selectedItem selectedClass valueattr multi parallax ">
37 <template>
38 <link rel="stylesheet" href="polymer-ui-menu-button.css">
39 <polymer-ui-icon-button id="button" on-tap="{{toggle}}" src="{{src}}" icon=" {{icon}}" active="{{opened}}" anchor-point="{{valign}}"></polymer-ui-icon-button >
40 <div id="overlay" halign="{{halign}}" valign="{{valign}}">
41 <div id="overlayBackdrop" pseudo="x-backdrop" overlay-toggle></div>
42 <div id="overlayMenu">
43 <polymer-ui-menu id="menu" selected="{{selected}}" selectedItem="{{selec tedItem}}" selectedClass="{{selectedClass}}" valueattr="{{valueattr}}" multi="{{ multi}}" on-polymer-select="{{closeAction}}">
44 <content select="*"></content>
45 </polymer-ui-menu>
46 </div>
47 <polymer-ui-arrow id="arrow" size="9" direction="{{valign == 'top' ? 'down ' : 'up'}}" anchor-point="center center"></polymer-ui-arrow>
48 </div>
49 <polymer-media-query query="{{mediaQuery}}" on-polymer-mediachange="{{mediaC hangeAction}}"></polymer-media-query>
50 <polymer-anchor-point id="arrowPositionHelper" target="{{$.arrow}}" anchor=" {{$.button}}"></polymer-anchor-point>
51 <polymer-overlay target="{{$.overlay}}" opened="{{opened}}"></polymer-overla y>
52 </template>
53 <script>
54 Polymer('polymer-ui-menu-button', {
55 /**
56 * The icon to display.
57 * @attribute icon
58 * @type string
59 */
60 icon: 'dots',
61 src: '',
62 /**
63 * The index of the selected menu item.
64 * @attribute selected
65 * @type number
66 */
67 selected: '',
68 /**
69 * Set to true to open the menu.
70 * @attribute opened
71 * @type boolean
72 */
73 opened: false,
74 /**
75 * Horizontally align the overlay with the button. Accepted values are
76 * ["left", "center", "right"].
77 * @attribute halign
78 * @type string
79 */
80 halign: 'center',
81 /**
82 * Display the overlay on top or below the button. Accepted values are
83 * ["top", "bottom"].
84 * @attribute valign
85 * @type string
86 */
87 valign: 'bottom',
88 multi: false,
89 parallax: false,
90 mediaQuery: 'max-width: 800px',
91 ready: function() {
92 this.boundParallaxAction = this.parallaxAction.bind(this);
93 },
94 openedChanged: function() {
95 this.async(function() {
96 this.$.arrowPositionHelper.apply();
97 this.tilt = null;
98 if (this.parallax) {
99 window.addEventListener('deviceorientation',
100 this.boundParallaxAction, false);
101 } else {
102 window.removeEventListener('deviceorientation',
103 this.boundParallaxAction, false);
104 }
105 });
106 },
107 parallaxAction: function(e) {
108 var tiltLR = Math.round(e.gamma);
109 var tiltTB = Math.round(e.beta);
110 if (!this.tilt) {
111 this.tilt = {
112 lr: tiltLR,
113 tb: tiltTB
114 };
115 } else {
116 var transX = ((tiltLR - this.tilt.lr) % 90) / 90 * 8;
117 var transY = ((tiltTB - this.tilt.tb) % 90) / 90 * 13;
118 this.$.overlayMenu.style['-webkit-transform'] = 'translate3d(' +
119 transX + 'px,' + transY + 'px,0)';
120 this.$.arrow.style['-webkit-transform'] = 'translate3d(' +
121 transX + 'px,' + transY + 'px,0)';
122 }
123 },
124 mediaChangeAction: function(e) {
125 if (e.detail.matches) {
126 this.classList.add('fullwidth');
127 } else {
128 this.classList.remove('fullwidth');
129 }
130 },
131 closeAction: function() {
132 this.opened = false;
133 },
134 /**
135 * Toggle the opened state of the dropdown.
136 * @method toggle
137 */
138 toggle: function() {
139 this.opened = !this.opened;
140 },
141 /**
142 * The selected menu item.
143 * @property selection
144 * @type Node
145 */
146 get selection() {
147 return this.$.menu.selection;
148 }
149 });
150 </script>
151 </polymer-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698