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,107 @@
|
|
|
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
|
+
<script>
|
|
14
|
+
|
|
15
|
+
Polymer.IronOverlayManager = (function() {
|
|
16
|
+
|
|
17
|
+
var overlays = [];
|
|
18
|
+
var DEFAULT_Z = 10;
|
|
19
|
+
var backdrops = [];
|
|
20
|
+
|
|
21
|
+
// track overlays for z-index and focus managemant
|
|
22
|
+
function addOverlay(overlay) {
|
|
23
|
+
var z0 = currentOverlayZ();
|
|
24
|
+
overlays.push(overlay);
|
|
25
|
+
var z1 = currentOverlayZ();
|
|
26
|
+
if (z1 <= z0) {
|
|
27
|
+
applyOverlayZ(overlay, z0);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function removeOverlay(overlay) {
|
|
32
|
+
var i = overlays.indexOf(overlay);
|
|
33
|
+
if (i >= 0) {
|
|
34
|
+
overlays.splice(i, 1);
|
|
35
|
+
setZ(overlay, '');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function applyOverlayZ(overlay, aboveZ) {
|
|
40
|
+
setZ(overlay, aboveZ + 2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function setZ(element, z) {
|
|
44
|
+
element.style.zIndex = z;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function currentOverlay() {
|
|
48
|
+
return overlays[overlays.length-1];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function currentOverlayZ() {
|
|
52
|
+
var z;
|
|
53
|
+
var current = currentOverlay();
|
|
54
|
+
if (current) {
|
|
55
|
+
var z1 = window.getComputedStyle(current).zIndex;
|
|
56
|
+
if (!isNaN(z1)) {
|
|
57
|
+
z = Number(z1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return z || DEFAULT_Z;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function focusOverlay() {
|
|
64
|
+
var current = currentOverlay();
|
|
65
|
+
// We have to be careful to focus the next overlay _after_ any current
|
|
66
|
+
// transitions are complete (due to the state being toggled prior to the
|
|
67
|
+
// transition). Otherwise, we risk infinite recursion when a transitioning
|
|
68
|
+
// (closed) overlay becomes the current overlay.
|
|
69
|
+
//
|
|
70
|
+
// NOTE: We make the assumption that any overlay that completes a transition
|
|
71
|
+
// will call into focusOverlay to kick the process back off. Currently:
|
|
72
|
+
// transitionend -> _applyFocus -> focusOverlay.
|
|
73
|
+
if (current && !current.transitioning) {
|
|
74
|
+
current._applyFocus();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function trackBackdrop(element) {
|
|
79
|
+
// backdrops contains the overlays with a backdrop that are currently
|
|
80
|
+
// visible
|
|
81
|
+
if (element.opened) {
|
|
82
|
+
backdrops.push(element);
|
|
83
|
+
} else {
|
|
84
|
+
var index = backdrops.indexOf(element);
|
|
85
|
+
if (index >= 0) {
|
|
86
|
+
backdrops.splice(index, 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getBackdrops() {
|
|
92
|
+
return backdrops;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
addOverlay: addOverlay,
|
|
97
|
+
removeOverlay: removeOverlay,
|
|
98
|
+
currentOverlay: currentOverlay,
|
|
99
|
+
currentOverlayZ: currentOverlayZ,
|
|
100
|
+
focusOverlay: focusOverlay,
|
|
101
|
+
trackBackdrop: trackBackdrop,
|
|
102
|
+
getBackdrops: getBackdrops
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
})();
|
|
106
|
+
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
<script>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `iron-range-behavior` provides the behavior for something with a minimum to maximum range.
|
|
17
|
+
*
|
|
18
|
+
* @demo demo/index.html
|
|
19
|
+
* @polymerBehavior
|
|
20
|
+
*/
|
|
21
|
+
Polymer.IronRangeBehavior = {
|
|
22
|
+
|
|
23
|
+
properties: {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The number that represents the current value.
|
|
27
|
+
*/
|
|
28
|
+
value: {
|
|
29
|
+
type: Number,
|
|
30
|
+
value: 0,
|
|
31
|
+
notify: true,
|
|
32
|
+
reflectToAttribute: true
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The number that indicates the minimum value of the range.
|
|
37
|
+
*/
|
|
38
|
+
min: {
|
|
39
|
+
type: Number,
|
|
40
|
+
value: 0,
|
|
41
|
+
notify: true
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The number that indicates the maximum value of the range.
|
|
46
|
+
*/
|
|
47
|
+
max: {
|
|
48
|
+
type: Number,
|
|
49
|
+
value: 100,
|
|
50
|
+
notify: true
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the value granularity of the range's value.
|
|
55
|
+
*/
|
|
56
|
+
step: {
|
|
57
|
+
type: Number,
|
|
58
|
+
value: 1,
|
|
59
|
+
notify: true
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the ratio of the value.
|
|
64
|
+
*/
|
|
65
|
+
ratio: {
|
|
66
|
+
type: Number,
|
|
67
|
+
value: 0,
|
|
68
|
+
readOnly: true,
|
|
69
|
+
notify: true
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
observers: [
|
|
74
|
+
'_update(value, min, max, step)'
|
|
75
|
+
],
|
|
76
|
+
|
|
77
|
+
_calcRatio: function(value) {
|
|
78
|
+
return (this._clampValue(value) - this.min) / (this.max - this.min);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
_clampValue: function(value) {
|
|
82
|
+
return Math.min(this.max, Math.max(this.min, this._calcStep(value)));
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
_calcStep: function(value) {
|
|
86
|
+
return this.step ? (Math.round(value / this.step) / (1 / this.step)) : value;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
_validateValue: function() {
|
|
90
|
+
var v = this._clampValue(this.value);
|
|
91
|
+
this.value = this.oldValue = isNaN(v) ? this.oldValue : v;
|
|
92
|
+
return this.value !== v;
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
_update: function() {
|
|
96
|
+
this._validateValue();
|
|
97
|
+
this._setRatio(this._calcRatio(this.value) * 100);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
};
|
|
101
|
+
</script>
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
<script>
|
|
14
|
+
/**
|
|
15
|
+
* `IronResizableBehavior` is a behavior that can be used in Polymer elements to
|
|
16
|
+
* coordinate the flow of resize events between "resizers" (elements that control the
|
|
17
|
+
* size or hidden state of their children) and "resizables" (elements that need to be
|
|
18
|
+
* notified when they are resized or un-hidden by their parents in order to take
|
|
19
|
+
* action on their new measurements).
|
|
20
|
+
* Elements that perform measurement should add the `IronResizableBehavior` behavior to
|
|
21
|
+
* their element definition and listen for the `iron-resize` event on themselves.
|
|
22
|
+
* This event will be fired when they become showing after having been hidden,
|
|
23
|
+
* when they are resized explicitly by another resizable, or when the window has been
|
|
24
|
+
* resized.
|
|
25
|
+
* Note, the `iron-resize` event is non-bubbling.
|
|
26
|
+
*
|
|
27
|
+
* @polymerBehavior Polymer.IronResizableBehavior
|
|
28
|
+
* @demo demo/index.html
|
|
29
|
+
**/
|
|
30
|
+
Polymer.IronResizableBehavior = {
|
|
31
|
+
properties: {
|
|
32
|
+
_parentResizable: {
|
|
33
|
+
type: Object,
|
|
34
|
+
observer: '_parentResizableChanged'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
listeners: {
|
|
39
|
+
'iron-request-resize-notifications': '_onIronRequestResizeNotifications'
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
created: function() {
|
|
43
|
+
// We don't really need property effects on these, and also we want them
|
|
44
|
+
// to be created before the `_parentResizable` observer fires:
|
|
45
|
+
this._interestedResizables = [];
|
|
46
|
+
this._boundNotifyResize = this.notifyResize.bind(this);
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
attached: function() {
|
|
50
|
+
this.fire('iron-request-resize-notifications', null, {
|
|
51
|
+
node: this,
|
|
52
|
+
bubbles: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (!this._parentResizable) {
|
|
56
|
+
window.addEventListener('resize', this._boundNotifyResize);
|
|
57
|
+
this.notifyResize();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
detached: function() {
|
|
62
|
+
if (this._parentResizable) {
|
|
63
|
+
this._parentResizable.stopResizeNotificationsFor(this);
|
|
64
|
+
} else {
|
|
65
|
+
window.removeEventListener('resize', this._boundNotifyResize);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this._parentResizable = null;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Can be called to manually notify a resizable and its descendant
|
|
73
|
+
* resizables of a resize change.
|
|
74
|
+
*/
|
|
75
|
+
notifyResize: function() {
|
|
76
|
+
if (!this.isAttached) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this._interestedResizables.forEach(function(resizable) {
|
|
81
|
+
// TODO(cdata): Currently behaviors cannot define "abstract" methods..
|
|
82
|
+
if (!this.resizerShouldNotify || this.resizerShouldNotify(resizable)) {
|
|
83
|
+
resizable.notifyResize();
|
|
84
|
+
}
|
|
85
|
+
}, this);
|
|
86
|
+
|
|
87
|
+
this.fire('iron-resize', null, {
|
|
88
|
+
node: this,
|
|
89
|
+
bubbles: false
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Used to assign the closest resizable ancestor to this resizable
|
|
95
|
+
* if the ancestor detects a request for notifications.
|
|
96
|
+
*/
|
|
97
|
+
assignParentResizable: function(parentResizable) {
|
|
98
|
+
this._parentResizable = parentResizable;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Used to remove a resizable descendant from the list of descendants
|
|
103
|
+
* that should be notified of a resize change.
|
|
104
|
+
*/
|
|
105
|
+
stopResizeNotificationsFor: function(target) {
|
|
106
|
+
var index = this._interestedResizables.indexOf(target);
|
|
107
|
+
|
|
108
|
+
if (index > -1) {
|
|
109
|
+
this._interestedResizables.splice(index, 1);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// TODO(cdata): Currently behaviors cannot define "abstract" methods.
|
|
114
|
+
// resizerShouldNotify: function(el) { return true; },
|
|
115
|
+
|
|
116
|
+
_parentResizableChanged: function(parentResizable) {
|
|
117
|
+
if (parentResizable) {
|
|
118
|
+
window.removeEventListener('resize', this._boundNotifyResize);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
_onIronRequestResizeNotifications: function(event) {
|
|
123
|
+
var target = event.path ? event.path[0] : event.target;
|
|
124
|
+
|
|
125
|
+
if (target === this) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (this._interestedResizables.indexOf(target) === -1) {
|
|
130
|
+
this._interestedResizables.push(target);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
target.assignParentResizable(this);
|
|
134
|
+
|
|
135
|
+
event.stopPropagation();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
</script>
|
|
139
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
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-selectable.html">
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
/** @polymerBehavior Polymer.IronMultiSelectableBehavior */
|
|
16
|
+
Polymer.IronMultiSelectableBehaviorImpl = {
|
|
17
|
+
properties: {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* If true, multiple selections are allowed.
|
|
21
|
+
*/
|
|
22
|
+
multi: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
value: false,
|
|
25
|
+
observer: 'multiChanged'
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets or sets the selected elements. This is used instead of `selected` when `multi`
|
|
30
|
+
* is true.
|
|
31
|
+
*/
|
|
32
|
+
selectedValues: {
|
|
33
|
+
type: Array,
|
|
34
|
+
notify: true
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns an array of currently selected items.
|
|
39
|
+
*/
|
|
40
|
+
selectedItems: {
|
|
41
|
+
type: Array,
|
|
42
|
+
readOnly: true,
|
|
43
|
+
notify: true
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
observers: [
|
|
49
|
+
'_updateSelected(attrForSelected, selectedValues)'
|
|
50
|
+
],
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Selects the given value. If the `multi` property is true, then the selected state of the
|
|
54
|
+
* `value` will be toggled; otherwise the `value` will be selected.
|
|
55
|
+
*
|
|
56
|
+
* @method select
|
|
57
|
+
* @param {string} value the value to select.
|
|
58
|
+
*/
|
|
59
|
+
select: function(value) {
|
|
60
|
+
if (this.multi) {
|
|
61
|
+
if (this.selectedValues) {
|
|
62
|
+
this._toggleSelected(value);
|
|
63
|
+
} else {
|
|
64
|
+
this.selectedValues = [value];
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
this.selected = value;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
multiChanged: function(multi) {
|
|
72
|
+
this._selection.multi = multi;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
_updateSelected: function() {
|
|
76
|
+
if (this.multi) {
|
|
77
|
+
this._selectMulti(this.selectedValues);
|
|
78
|
+
} else {
|
|
79
|
+
this._selectSelected(this.selected);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
_selectMulti: function(values) {
|
|
84
|
+
this._selection.clear();
|
|
85
|
+
if (values) {
|
|
86
|
+
for (var i = 0; i < values.length; i++) {
|
|
87
|
+
this._selection.setItemSelected(this._valueToItem(values[i]), true);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
_selectionChange: function() {
|
|
93
|
+
var s = this._selection.get();
|
|
94
|
+
if (this.multi) {
|
|
95
|
+
this._setSelectedItems(s);
|
|
96
|
+
} else {
|
|
97
|
+
this._setSelectedItems([s]);
|
|
98
|
+
this._setSelectedItem(s);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
_toggleSelected: function(value) {
|
|
103
|
+
var i = this.selectedValues.indexOf(value);
|
|
104
|
+
var unselected = i < 0;
|
|
105
|
+
if (unselected) {
|
|
106
|
+
this.selectedValues.push(value);
|
|
107
|
+
} else {
|
|
108
|
+
this.selectedValues.splice(i, 1);
|
|
109
|
+
}
|
|
110
|
+
this._selection.setItemSelected(this._valueToItem(value), unselected);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** @polymerBehavior */
|
|
115
|
+
Polymer.IronMultiSelectableBehavior = [
|
|
116
|
+
Polymer.IronSelectableBehavior,
|
|
117
|
+
Polymer.IronMultiSelectableBehaviorImpl
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
</script>
|