polymer-paper-elements-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
- data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
- data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
- data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icons/av-icons.html +73 -0
- data/app/assets/components/iron-icons/communication-icons.html +59 -0
- data/app/assets/components/iron-icons/device-icons.html +94 -0
- data/app/assets/components/iron-icons/editor-icons.html +70 -0
- data/app/assets/components/iron-icons/hardware-icons.html +61 -0
- data/app/assets/components/iron-icons/hero.svg +35 -0
- data/app/assets/components/iron-icons/image-icons.html +164 -0
- data/app/assets/components/iron-icons/iron-icons.html +303 -0
- data/app/assets/components/iron-icons/maps-icons.html +71 -0
- data/app/assets/components/iron-icons/notification-icons.html +62 -0
- data/app/assets/components/iron-icons/social-icons.html +40 -0
- data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-media-query/hero.svg +29 -0
- data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
- data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
- data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
- data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
- data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
- data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
- data/app/assets/components/iron-selector/iron-selectable.html +307 -0
- data/app/assets/components/iron-selector/iron-selection.html +115 -0
- data/app/assets/components/iron-selector/iron-selector.html +71 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
- data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
- data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
- data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
- data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
- data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
- data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
- data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
- data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
- data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
- data/app/assets/components/neon-animation/neon-animatable.html +54 -0
- data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
- data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
- data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
- data/app/assets/components/neon-animation/neon-animation.html +17 -0
- data/app/assets/components/neon-animation/neon-animations.html +25 -0
- data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
- data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
- data/app/assets/components/neon-animation/web-animations.html +11 -0
- data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
- data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
- data/app/assets/components/paper-button/paper-button.html +177 -0
- data/app/assets/components/paper-checkbox/metadata.html +17 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
- data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
- data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
- data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
- data/app/assets/components/paper-dialog/hero.svg +58 -0
- data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
- data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
- data/app/assets/components/paper-fab/paper-fab.html +159 -0
- data/app/assets/components/paper-header-panel/hero.svg +38 -0
- data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +100 -0
- data/app/assets/components/paper-item/all-imports.html +13 -0
- data/app/assets/components/paper-item/paper-icon-item.html +86 -0
- data/app/assets/components/paper-item/paper-item-body.html +93 -0
- data/app/assets/components/paper-item/paper-item-shared.css +19 -0
- data/app/assets/components/paper-item/paper-item.html +95 -0
- data/app/assets/components/paper-material/paper-material.html +98 -0
- data/app/assets/components/paper-menu/hero.svg +35 -0
- data/app/assets/components/paper-menu/paper-menu.html +133 -0
- data/app/assets/components/paper-progress/hero.svg +21 -0
- data/app/assets/components/paper-progress/paper-progress.html +199 -0
- data/app/assets/components/paper-radio-button/hero.svg +22 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
- data/app/assets/components/paper-radio-group/hero.svg +25 -0
- data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
- data/app/assets/components/paper-ripple/hero.svg +30 -0
- data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
- data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
- data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
- data/app/assets/components/paper-slider/hero.svg +20 -0
- data/app/assets/components/paper-slider/paper-slider.css +252 -0
- data/app/assets/components/paper-slider/paper-slider.html +449 -0
- data/app/assets/components/paper-spinner/hero.svg +27 -0
- data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
- data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/paper-tabs/hero.svg +23 -0
- data/app/assets/components/paper-tabs/paper-tab.html +158 -0
- data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
- data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
- data/app/assets/components/paper-toast/hero.svg +20 -0
- data/app/assets/components/paper-toast/paper-toast.html +164 -0
- data/app/assets/components/paper-toggle-button/hero.svg +22 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
- data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
- data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
- data/app/assets/components/polymer-gestures/banner.txt +9 -0
- data/app/assets/components/polymer-gestures/build.json +17 -0
- data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
- data/app/assets/components/polymer-gestures/package.json +20 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
- data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
- data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
- data/app/assets/components/polymer-gestures/src/hold.js +129 -0
- data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
- data/app/assets/components/polymer-gestures/src/ms.js +80 -0
- data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
- data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
- data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
- data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
- data/app/assets/components/polymer-gestures/src/scope.js +10 -0
- data/app/assets/components/polymer-gestures/src/tap.js +103 -0
- data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
- data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
- data/app/assets/components/polymer-gestures/src/touch.js +341 -0
- data/app/assets/components/polymer-gestures/src/track.js +230 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-paper-elements-rails.rb +2 -0
- data/lib/polymer-paper-elements-rails/engine.rb +4 -0
- data/lib/polymer-paper-elements-rails/version.rb +3 -0
- metadata +272 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
4
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
5
|
+
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
|
6
|
+
<g id="background" display="none">
|
|
7
|
+
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
|
8
|
+
</g>
|
|
9
|
+
<g id="label">
|
|
10
|
+
</g>
|
|
11
|
+
<g id="art">
|
|
12
|
+
<path d="M173,99H91V41h82V99z M93,97h78V43H93V97z"/>
|
|
13
|
+
<path d="M77,89H51V42h26V89z M53,87h22V44H53V87z"/>
|
|
14
|
+
<rect x="52" y="56" width="24" height="2"/>
|
|
15
|
+
<rect x="92" y="58" width="80" height="2"/>
|
|
16
|
+
<path d="M65.3,42h-2c0-10,8.7-18.7,18.7-18.7v2C73,25.3,65.3,33,65.3,42z"/>
|
|
17
|
+
<path d="M105.3,42h-2c0-9-7.3-16.7-16.3-16.7v-2C97,23.3,105.3,32,105.3,42z"/>
|
|
18
|
+
<circle cx="84.3" cy="24.3" r="4"/>
|
|
19
|
+
<circle cx="69.3" cy="80.3" r="4"/>
|
|
20
|
+
<circle cx="160.3" cy="59.3" r="4"/>
|
|
21
|
+
<path d="M49,41v49c0,1.1,0.9,2,2,2h26c1.1,0,2-0.9,2-2V41c0-1.1-0.9-2-2-2H51C49.9,39,49,39.9,49,41z M76,88H52V43h24V88z"/>
|
|
22
|
+
<path d="M88.9,40.7v59c0,1.1,0.9,2,2,2h82c1.1,0,2-0.9,2-2v-59c0-1.1-0.9-2-2-2h-82C89.8,38.7,88.9,39.6,88.9,40.7z M172,98H93V42
|
|
23
|
+
h79V98z"/>
|
|
24
|
+
<g id="ic_x5F_add_x0D_">
|
|
25
|
+
</g>
|
|
26
|
+
</g>
|
|
27
|
+
<g id="Guides">
|
|
28
|
+
</g>
|
|
29
|
+
</svg>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
Code distributed by Google as part of the polymer project is also
|
|
7
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<link rel="import" href="../polymer/polymer.html">
|
|
11
|
+
|
|
12
|
+
<!--
|
|
13
|
+
`iron-media-query` can be used to data bind to a CSS media query.
|
|
14
|
+
The `query` property is a bare CSS media query.
|
|
15
|
+
The `queryMatches` property is a boolean representing if the page matches that media query.
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
|
|
19
|
+
<iron-media-query query="(min-width: 600px)" queryMatches="{{queryMatches}}"></iron-media-query>
|
|
20
|
+
|
|
21
|
+
@group Iron Elements
|
|
22
|
+
@demo demo/index.html
|
|
23
|
+
@hero hero.svg
|
|
24
|
+
@element iron-media-query
|
|
25
|
+
-->
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
|
|
29
|
+
Polymer({
|
|
30
|
+
|
|
31
|
+
is: 'iron-media-query',
|
|
32
|
+
|
|
33
|
+
properties: {
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The Boolean return value of the media query.
|
|
37
|
+
*
|
|
38
|
+
* @attribute queryMatches
|
|
39
|
+
* @type Boolean
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
queryMatches: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
value: false,
|
|
45
|
+
readOnly: true,
|
|
46
|
+
notify: true
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The CSS media query to evaluate.
|
|
51
|
+
*
|
|
52
|
+
* @attribute query
|
|
53
|
+
* @type String
|
|
54
|
+
*/
|
|
55
|
+
query: {
|
|
56
|
+
type: String,
|
|
57
|
+
observer: 'queryChanged'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
created: function() {
|
|
63
|
+
this._mqHandler = this.queryHandler.bind(this);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
queryChanged: function(query) {
|
|
67
|
+
if (this._mq) {
|
|
68
|
+
this._mq.removeListener(this._mqHandler);
|
|
69
|
+
}
|
|
70
|
+
if (query[0] !== '(') {
|
|
71
|
+
query = '(' + query + ')';
|
|
72
|
+
}
|
|
73
|
+
this._mq = window.matchMedia(query);
|
|
74
|
+
this._mq.addListener(this._mqHandler);
|
|
75
|
+
this.queryHandler(this._mq);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
queryHandler: function(mq) {
|
|
79
|
+
this._setQueryMatches(mq.matches);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
</script>
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
|
12
|
+
<link rel="import" href="../iron-selector/iron-multi-selectable.html">
|
|
13
|
+
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `Polymer.IronMenuBehavior` implements accessible menu behavior.
|
|
19
|
+
*
|
|
20
|
+
* @demo demo/index.html
|
|
21
|
+
* @polymerBehavior Polymer.IronMenuBehavior
|
|
22
|
+
*/
|
|
23
|
+
Polymer.IronMenuBehaviorImpl = {
|
|
24
|
+
|
|
25
|
+
properties: {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the currently focused item.
|
|
29
|
+
*
|
|
30
|
+
* @attribute focusedItem
|
|
31
|
+
* @type Object
|
|
32
|
+
*/
|
|
33
|
+
focusedItem: {
|
|
34
|
+
observer: '_focusedItemChanged',
|
|
35
|
+
readOnly: true,
|
|
36
|
+
type: Object
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The attribute to use on menu items to look up the item title. Typing the first
|
|
41
|
+
* letter of an item when the menu is open focuses that item. If unset, `textContent`
|
|
42
|
+
* will be used.
|
|
43
|
+
*
|
|
44
|
+
* @attribute attrForItemTitle
|
|
45
|
+
* @type String
|
|
46
|
+
*/
|
|
47
|
+
attrForItemTitle: {
|
|
48
|
+
type: String
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
hostAttributes: {
|
|
53
|
+
'role': 'menu',
|
|
54
|
+
'tabindex': '0'
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
observers: [
|
|
58
|
+
'_updateMultiselectable(multi)'
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
listeners: {
|
|
62
|
+
'focus': '_onFocus',
|
|
63
|
+
'keydown': '_onKeydown'
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
keyBindings: {
|
|
67
|
+
'up': '_onUpKey',
|
|
68
|
+
'down': '_onDownKey',
|
|
69
|
+
'esc': '_onEscKey',
|
|
70
|
+
'enter': '_onEnterKey',
|
|
71
|
+
'shift+tab:keydown': '_onShiftTabDown'
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
_updateMultiselectable: function(multi) {
|
|
75
|
+
if (multi) {
|
|
76
|
+
this.setAttribute('aria-multiselectable', 'true');
|
|
77
|
+
} else {
|
|
78
|
+
this.removeAttribute('aria-multiselectable');
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
_onShiftTabDown: function() {
|
|
83
|
+
var oldTabIndex;
|
|
84
|
+
|
|
85
|
+
Polymer.IronMenuBehaviorImpl._shiftTabPressed = true;
|
|
86
|
+
|
|
87
|
+
oldTabIndex = this.getAttribute('tabindex');
|
|
88
|
+
|
|
89
|
+
this.setAttribute('tabindex', '-1');
|
|
90
|
+
|
|
91
|
+
this.async(function() {
|
|
92
|
+
this.setAttribute('tabindex', oldTabIndex);
|
|
93
|
+
Polymer.IronMenuBehaviorImpl._shiftTabPressed = false;
|
|
94
|
+
// Note: polymer/polymer#1305
|
|
95
|
+
}, 1);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
_applySelection: function(item, isSelected) {
|
|
99
|
+
if (isSelected) {
|
|
100
|
+
item.setAttribute('aria-selected', 'true');
|
|
101
|
+
} else {
|
|
102
|
+
item.removeAttribute('aria-selected');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Polymer.IronSelectableBehavior._applySelection.apply(this, arguments);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
_focusedItemChanged: function(focusedItem, old) {
|
|
109
|
+
old && old.setAttribute('tabindex', '-1');
|
|
110
|
+
if (focusedItem) {
|
|
111
|
+
focusedItem.setAttribute('tabindex', '0');
|
|
112
|
+
focusedItem.focus();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
select: function(value) {
|
|
117
|
+
if (this._defaultFocusAsync) {
|
|
118
|
+
this.cancelAsync(this._defaultFocusAsync);
|
|
119
|
+
this._defaultFocusAsync = null;
|
|
120
|
+
}
|
|
121
|
+
var item = this._valueToItem(value);
|
|
122
|
+
this._setFocusedItem(item);
|
|
123
|
+
Polymer.IronMultiSelectableBehaviorImpl.select.apply(this, arguments);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
_onFocus: function(event) {
|
|
127
|
+
if (Polymer.IronMenuBehaviorImpl._shiftTabPressed) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// do not focus the menu itself
|
|
131
|
+
this.blur();
|
|
132
|
+
// clear the cached focus item
|
|
133
|
+
this._setFocusedItem(null);
|
|
134
|
+
this._defaultFocusAsync = this.async(function() {
|
|
135
|
+
// focus the selected item when the menu receives focus, or the first item
|
|
136
|
+
// if no item is selected
|
|
137
|
+
var selectedItem = this.multi ? (this.selectedItems && this.selectedItems[0]) : this.selectedItem;
|
|
138
|
+
if (selectedItem) {
|
|
139
|
+
this._setFocusedItem(selectedItem);
|
|
140
|
+
} else {
|
|
141
|
+
this._setFocusedItem(this.items[0]);
|
|
142
|
+
}
|
|
143
|
+
// async 100ms to wait for `select` to get called from `_itemActivate`
|
|
144
|
+
}, 100);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
_onUpKey: function() {
|
|
148
|
+
// up and down arrows moves the focus
|
|
149
|
+
this._focusPrevious();
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
_onDownKey: function() {
|
|
153
|
+
this._focusNext();
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
_onEscKey: function() {
|
|
157
|
+
// esc blurs the control
|
|
158
|
+
this.focusedItem.blur();
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
_onEnterKey: function(event) {
|
|
162
|
+
// enter activates the item unless it is disabled
|
|
163
|
+
this._activateFocused(event.detail.keyboardEvent);
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
_onKeydown: function(event) {
|
|
167
|
+
if (this.keyboardEventMatchesKeys(event, 'up down esc enter')) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// all other keys focus the menu item starting with that character
|
|
172
|
+
this._focusWithKeyboardEvent(event);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
_focusWithKeyboardEvent: function(event) {
|
|
176
|
+
for (var i = 0, item; item = this.items[i]; i++) {
|
|
177
|
+
var attr = this.attrForItemTitle || 'textContent';
|
|
178
|
+
var title = item[attr] || item.getAttribute(attr);
|
|
179
|
+
if (title && title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.keyCode).toLowerCase()) {
|
|
180
|
+
this._setFocusedItem(item);
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
_activateFocused: function(event) {
|
|
187
|
+
if (!this.focusedItem.hasAttribute('disabled')) {
|
|
188
|
+
this._activateHandler(event);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
_focusPrevious: function() {
|
|
193
|
+
var length = this.items.length;
|
|
194
|
+
var index = (Number(this.indexOf(this.focusedItem)) - 1 + length) % length;
|
|
195
|
+
this._setFocusedItem(this.items[index]);
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
_focusNext: function() {
|
|
199
|
+
var index = (Number(this.indexOf(this.focusedItem)) + 1) % this.items.length;
|
|
200
|
+
this._setFocusedItem(this.items[index]);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
Polymer.IronMenuBehaviorImpl._shiftTabPressed = false;
|
|
206
|
+
|
|
207
|
+
/** @polymerBehavior Polymer.IronMenuBehavior */
|
|
208
|
+
Polymer.IronMenuBehavior = [
|
|
209
|
+
Polymer.IronMultiSelectableBehavior,
|
|
210
|
+
Polymer.IronA11yKeysBehavior,
|
|
211
|
+
Polymer.IronMenuBehaviorImpl
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
|
12
|
+
<link rel="import" href="iron-menu-behavior.html">
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `Polymer.IronMenubarBehavior` implements accessible menubar behavior.
|
|
18
|
+
*
|
|
19
|
+
* @polymerBehavior Polymer.IronMenubarBehavior
|
|
20
|
+
*/
|
|
21
|
+
Polymer.IronMenubarBehaviorImpl = {
|
|
22
|
+
|
|
23
|
+
hostAttributes: {
|
|
24
|
+
'role': 'menubar'
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
keyBindings: {
|
|
28
|
+
'left': '_onLeftKey',
|
|
29
|
+
'right': '_onRightKey'
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
_onUpKey: function(event) {
|
|
33
|
+
this._activateFocused(event.detail.keyboardEvent);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
_onDownKey: function(event) {
|
|
37
|
+
this._activateFocused(event.detail.keyboardEvent);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
_onLeftKey: function() {
|
|
41
|
+
this._focusPrevious();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
_onRightKey: function() {
|
|
45
|
+
this._focusNext();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
_onKeydown: function(event) {
|
|
49
|
+
if (this.keyboardEventMatchesKeys(event, 'up down left right esc enter')) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// all other keys focus the menu item starting with that character
|
|
54
|
+
this._focusWithKeyboardEvent(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** @polymerBehavior Polymer.IronMenubarBehavior */
|
|
60
|
+
Polymer.IronMenubarBehavior = [
|
|
61
|
+
Polymer.IronMenuBehavior,
|
|
62
|
+
Polymer.IronMenubarBehaviorImpl
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
4
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
5
|
+
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
|
6
|
+
<g id="background" display="none">
|
|
7
|
+
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
|
8
|
+
</g>
|
|
9
|
+
<g id="label">
|
|
10
|
+
</g>
|
|
11
|
+
<g id="art">
|
|
12
|
+
<circle cx="22" cy="85" r="4"/>
|
|
13
|
+
<circle cx="88" cy="98" r="4"/>
|
|
14
|
+
<path d="M87.5,100c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7
|
|
15
|
+
c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7c-3.8-0.3-5.5-2.8-7-5
|
|
16
|
+
c-1.4-2.1-2.7-3.9-5.5-4.2l0.2-2c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7
|
|
17
|
+
c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7c3.8,0.3,5.5,2.8,7,5
|
|
18
|
+
c1.4,2.1,2.7,3.9,5.5,4.2L87.5,100z"/>
|
|
19
|
+
<circle cx="96" cy="86" r="4"/>
|
|
20
|
+
<circle cx="162" cy="98" r="4"/>
|
|
21
|
+
<rect x="95.5" y="91" transform="matrix(0.9839 0.1789 -0.1789 0.9839 18.5382 -21.5923)" width="67.1" height="2"/>
|
|
22
|
+
<g>
|
|
23
|
+
<path d="M27,41.5l4.5,13.4l4.9-13.4h5.4v32h-4.4V61l0.4-13.4l-5.4,14.5h-2L25.6,48L26,61v12.5h-4.4v-32H27z"/>
|
|
24
|
+
<path d="M67.5,58.7H53.4V70h16.4v3.5H49v-32h20.6V45H53.4v10.2h14.2V58.7z"/>
|
|
25
|
+
<path d="M98.5,45H88.3v28.5h-4.4V45H73.6v-3.5h24.9V45z"/>
|
|
26
|
+
<path d="M116.2,65.3H105l-2.6,8.2h-4.5l10.9-32h3.8l10.6,32h-4.5L116.2,65.3z M106.2,61.6h8.9l-4.4-14.2L106.2,61.6z"/>
|
|
27
|
+
</g>
|
|
28
|
+
<g id="ic_x5F_add_x0D_">
|
|
29
|
+
</g>
|
|
30
|
+
</g>
|
|
31
|
+
<g id="Guides">
|
|
32
|
+
</g>
|
|
33
|
+
</svg>
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
|
12
|
+
|
|
13
|
+
<!--
|
|
14
|
+
`iron-meta` is a generic element you can use for sharing information across the DOM tree.
|
|
15
|
+
It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
|
|
16
|
+
instance of iron-meta has access to the shared
|
|
17
|
+
information. You can use `iron-meta` to share whatever you want (or create an extension
|
|
18
|
+
[like x-meta] for enhancements).
|
|
19
|
+
|
|
20
|
+
The `iron-meta` instances containing your actual data can be loaded in an import,
|
|
21
|
+
or constructed in any way you see fit. The only requirement is that you create them
|
|
22
|
+
before you try to access them.
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
|
|
26
|
+
If I create an instance like this:
|
|
27
|
+
|
|
28
|
+
<iron-meta key="info" keyUrl="foo/bar"></iron-meta>
|
|
29
|
+
|
|
30
|
+
Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
|
|
31
|
+
attributes or use child nodes to define additional metadata.
|
|
32
|
+
|
|
33
|
+
Now I can access that element (and it's metadata) from any iron-meta instance
|
|
34
|
+
via the byKey method, e.g.
|
|
35
|
+
|
|
36
|
+
meta.byKey('info').getAttribute('keyUrl').
|
|
37
|
+
|
|
38
|
+
Pure imperative form would be like:
|
|
39
|
+
|
|
40
|
+
document.createElement('iron-meta').byKey('info').getAttribute('keyUrl');
|
|
41
|
+
|
|
42
|
+
Or, in a Polymer element, you can include a meta in your template:
|
|
43
|
+
|
|
44
|
+
<iron-meta id="meta"></iron-meta>
|
|
45
|
+
...
|
|
46
|
+
this.$.meta.byKey('info').getAttribute('keyUrl');
|
|
47
|
+
|
|
48
|
+
@group Iron Elements
|
|
49
|
+
@demo demo/index.html
|
|
50
|
+
@hero hero.svg
|
|
51
|
+
@element iron-meta
|
|
52
|
+
-->
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
|
|
56
|
+
(function() {
|
|
57
|
+
|
|
58
|
+
// monostate data
|
|
59
|
+
var metaDatas = {};
|
|
60
|
+
var metaArrays = {};
|
|
61
|
+
|
|
62
|
+
Polymer.IronMeta = Polymer({
|
|
63
|
+
|
|
64
|
+
is: 'iron-meta',
|
|
65
|
+
|
|
66
|
+
properties: {
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The type of meta-data. All meta-data of the same type is stored
|
|
70
|
+
* together.
|
|
71
|
+
*
|
|
72
|
+
* @attribute type
|
|
73
|
+
* @type String
|
|
74
|
+
* @default 'default'
|
|
75
|
+
*/
|
|
76
|
+
type: {
|
|
77
|
+
type: String,
|
|
78
|
+
value: 'default',
|
|
79
|
+
observer: '_typeChanged'
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The key used to store `value` under the `type` namespace.
|
|
84
|
+
*
|
|
85
|
+
* @attribute key
|
|
86
|
+
* @type String
|
|
87
|
+
* @default ''
|
|
88
|
+
*/
|
|
89
|
+
key: {
|
|
90
|
+
type: String,
|
|
91
|
+
observer: '_keyChanged'
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The meta-data to store or retrieve.
|
|
96
|
+
*
|
|
97
|
+
* @attribute value
|
|
98
|
+
* @type *
|
|
99
|
+
* @default this
|
|
100
|
+
*/
|
|
101
|
+
value: {
|
|
102
|
+
type: Object,
|
|
103
|
+
notify: true,
|
|
104
|
+
observer: '_valueChanged'
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* If true, `value` is set to the iron-meta instance itself.
|
|
109
|
+
*
|
|
110
|
+
* @attribute self
|
|
111
|
+
* @type Boolean
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
self: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
observer: '_selfChanged'
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Array of all meta-data values for the given type.
|
|
121
|
+
*
|
|
122
|
+
* @property list
|
|
123
|
+
* @type Array
|
|
124
|
+
*/
|
|
125
|
+
list: {
|
|
126
|
+
type: Array,
|
|
127
|
+
notify: true
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Only runs if someone invokes the factory/constructor directly
|
|
134
|
+
* e.g. `new Polymer.IronMeta()`
|
|
135
|
+
*/
|
|
136
|
+
factoryImpl: function(config) {
|
|
137
|
+
if (config) {
|
|
138
|
+
for (var n in config) {
|
|
139
|
+
switch(n) {
|
|
140
|
+
case 'type':
|
|
141
|
+
case 'key':
|
|
142
|
+
case 'value':
|
|
143
|
+
this[n] = config[n];
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
created: function() {
|
|
151
|
+
// TODO(sjmiles): good for debugging?
|
|
152
|
+
this._metaDatas = metaDatas;
|
|
153
|
+
this._metaArrays = metaArrays;
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
_keyChanged: function(key, old) {
|
|
157
|
+
this._resetRegistration(old);
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
_valueChanged: function(value) {
|
|
161
|
+
this._resetRegistration(this.key);
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
_selfChanged: function(self) {
|
|
165
|
+
if (self) {
|
|
166
|
+
this.value = this;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
_typeChanged: function(type) {
|
|
171
|
+
this._unregisterKey(this.key);
|
|
172
|
+
if (!metaDatas[type]) {
|
|
173
|
+
metaDatas[type] = {};
|
|
174
|
+
}
|
|
175
|
+
this._metaData = metaDatas[type];
|
|
176
|
+
if (!metaArrays[type]) {
|
|
177
|
+
metaArrays[type] = [];
|
|
178
|
+
}
|
|
179
|
+
this.list = metaArrays[type];
|
|
180
|
+
this._registerKeyValue(this.key, this.value);
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves meta data value by key.
|
|
185
|
+
*
|
|
186
|
+
* @method byKey
|
|
187
|
+
* @param {String} key The key of the meta-data to be returned.
|
|
188
|
+
* @returns *
|
|
189
|
+
*/
|
|
190
|
+
byKey: function(key) {
|
|
191
|
+
return this._metaData && this._metaData[key];
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
_resetRegistration: function(oldKey) {
|
|
195
|
+
this._unregisterKey(oldKey);
|
|
196
|
+
this._registerKeyValue(this.key, this.value);
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
_unregisterKey: function(key) {
|
|
200
|
+
this._unregister(key, this._metaData, this.list);
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
_registerKeyValue: function(key, value) {
|
|
204
|
+
this._register(key, value, this._metaData, this.list);
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
_register: function(key, value, data, list) {
|
|
208
|
+
if (key && data && value !== undefined) {
|
|
209
|
+
data[key] = value;
|
|
210
|
+
list.push(value);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
_unregister: function(key, data, list) {
|
|
215
|
+
if (key && data) {
|
|
216
|
+
if (key in data) {
|
|
217
|
+
var value = data[key];
|
|
218
|
+
delete data[key];
|
|
219
|
+
this.arrayDelete(list, value);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
`iron-meta-query` can be used to access infomation stored in `iron-meta`.
|
|
228
|
+
|
|
229
|
+
Examples:
|
|
230
|
+
|
|
231
|
+
If I create an instance like this:
|
|
232
|
+
|
|
233
|
+
<iron-meta key="info" value="foo/bar"></iron-meta>
|
|
234
|
+
|
|
235
|
+
Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
|
|
236
|
+
attributes or use child nodes to define additional metadata.
|
|
237
|
+
|
|
238
|
+
Now I can access that element (and it's metadata) from any `iron-meta-query` instance:
|
|
239
|
+
|
|
240
|
+
var value = new Polymer.IronMetaQuery({key: 'info'}).value;
|
|
241
|
+
|
|
242
|
+
@group Polymer Iron Elements
|
|
243
|
+
@element iron-meta-query
|
|
244
|
+
*/
|
|
245
|
+
Polymer.IronMetaQuery = Polymer({
|
|
246
|
+
|
|
247
|
+
is: 'iron-meta-query',
|
|
248
|
+
|
|
249
|
+
properties: {
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The type of meta-data. All meta-data of the same type is stored
|
|
253
|
+
* together.
|
|
254
|
+
*
|
|
255
|
+
* @attribute type
|
|
256
|
+
* @type String
|
|
257
|
+
* @default 'default'
|
|
258
|
+
*/
|
|
259
|
+
type: {
|
|
260
|
+
type: String,
|
|
261
|
+
value: 'default',
|
|
262
|
+
observer: '_typeChanged'
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Specifies a key to use for retrieving `value` from the `type`
|
|
267
|
+
* namespace.
|
|
268
|
+
*
|
|
269
|
+
* @attribute key
|
|
270
|
+
* @type String
|
|
271
|
+
*/
|
|
272
|
+
key: {
|
|
273
|
+
type: String,
|
|
274
|
+
observer: '_keyChanged'
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The meta-data to store or retrieve.
|
|
279
|
+
*
|
|
280
|
+
* @attribute value
|
|
281
|
+
* @type *
|
|
282
|
+
* @default this
|
|
283
|
+
*/
|
|
284
|
+
value: {
|
|
285
|
+
type: Object,
|
|
286
|
+
notify: true,
|
|
287
|
+
readOnly: true
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Array of all meta-data values for the given type.
|
|
292
|
+
*
|
|
293
|
+
* @property list
|
|
294
|
+
* @type Array
|
|
295
|
+
*/
|
|
296
|
+
list: {
|
|
297
|
+
type: Array,
|
|
298
|
+
notify: true
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Actually a factory method, not a true constructor. Only runs if
|
|
305
|
+
* someone invokes it directly (via `new Polymer.IronMeta()`);
|
|
306
|
+
*/
|
|
307
|
+
constructor: function(config) {
|
|
308
|
+
if (config) {
|
|
309
|
+
for (var n in config) {
|
|
310
|
+
switch(n) {
|
|
311
|
+
case 'type':
|
|
312
|
+
case 'key':
|
|
313
|
+
this[n] = config[n];
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
created: function() {
|
|
321
|
+
// TODO(sjmiles): good for debugging?
|
|
322
|
+
this._metaDatas = metaDatas;
|
|
323
|
+
this._metaArrays = metaArrays;
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
_keyChanged: function(key) {
|
|
327
|
+
this._setValue(this._metaData && this._metaData[key]);
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
_typeChanged: function(type) {
|
|
331
|
+
this._metaData = metaDatas[type];
|
|
332
|
+
this.list = metaArrays[type];
|
|
333
|
+
if (this.key) {
|
|
334
|
+
this._keyChanged(this.key);
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Retrieves meta data value by key.
|
|
340
|
+
*
|
|
341
|
+
* @method byKey
|
|
342
|
+
* @param {String} key The key of the meta-data to be returned.
|
|
343
|
+
* @returns *
|
|
344
|
+
*/
|
|
345
|
+
byKey: function(key) {
|
|
346
|
+
return this._metaData && this._metaData[key];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
})();
|
|
352
|
+
</script>
|