polymer-core-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +82 -0
- data/Rakefile +2 -0
- data/app/assets/components/core-ajax/core-ajax.html.erb +320 -0
- data/app/assets/components/core-ajax/core-xhr.html.erb +112 -0
- data/app/assets/components/core-animated-pages/core-animated-pages.css +18 -0
- data/app/assets/components/core-animated-pages/core-animated-pages.html.erb +413 -0
- data/app/assets/components/core-animated-pages/transitions/cascade-transition.html +138 -0
- data/app/assets/components/core-animated-pages/transitions/core-transition-pages.html.erb +173 -0
- data/app/assets/components/core-animated-pages/transitions/cross-fade.html.erb +173 -0
- data/app/assets/components/core-animated-pages/transitions/hero-transition.css +12 -0
- data/app/assets/components/core-animated-pages/transitions/hero-transition.html.erb +267 -0
- data/app/assets/components/core-animated-pages/transitions/list-cascade.html +58 -0
- data/app/assets/components/core-animated-pages/transitions/scale-up.html +37 -0
- data/app/assets/components/core-animated-pages/transitions/slide-down.html +55 -0
- data/app/assets/components/core-animated-pages/transitions/slide-from-bottom.html +31 -0
- data/app/assets/components/core-animated-pages/transitions/slide-from-right.html +35 -0
- data/app/assets/components/core-animated-pages/transitions/slide-up.html +82 -0
- data/app/assets/components/core-animated-pages/transitions/tile-cascade.html +101 -0
- data/app/assets/components/core-animation/core-animation-group.html.erb +168 -0
- data/app/assets/components/core-animation/core-animation.html.erb +523 -0
- data/app/assets/components/core-animation/web-animations.html.erb +1 -0
- data/app/assets/components/core-collapse/core-collapse.css +16 -0
- data/app/assets/components/core-collapse/core-collapse.html.erb +247 -0
- data/app/assets/components/core-drag-drop/core-drag-drop.html +109 -0
- data/app/assets/components/core-drawer-panel/core-drawer-panel.css +162 -0
- data/app/assets/components/core-drawer-panel/core-drawer-panel.html.erb +150 -0
- data/app/assets/components/core-field/core-field.css +38 -0
- data/app/assets/components/core-field/core-field.html.erb +32 -0
- data/app/assets/components/core-header-panel/core-header-panel.css +75 -0
- data/app/assets/components/core-header-panel/core-header-panel.html.erb +196 -0
- data/app/assets/components/core-icon/core-icon.css +25 -0
- data/app/assets/components/core-icon/core-icon.html.erb +126 -0
- data/app/assets/components/core-icon-button/core-icon-button.css +70 -0
- data/app/assets/components/core-icon-button/core-icon-button.html.erb +83 -0
- data/app/assets/components/core-icons/core-icons.html +14 -0
- data/app/assets/components/core-iconset/core-iconset.html.erb +236 -0
- data/app/assets/components/core-iconset-svg/core-iconset-svg.html +170 -0
- data/app/assets/components/core-input/core-input.css +35 -0
- data/app/assets/components/core-input/core-input.html.erb +311 -0
- data/app/assets/components/core-item/core-item.css +31 -0
- data/app/assets/components/core-item/core-item.html.erb +80 -0
- data/app/assets/components/core-list/core-list.css +20 -0
- data/app/assets/components/core-list/core-list.html.erb +403 -0
- data/app/assets/components/core-localstorage/core-localstorage.html +126 -0
- data/app/assets/components/core-media-query/core-media-query.html +86 -0
- data/app/assets/components/core-menu/core-menu.css +18 -0
- data/app/assets/components/core-menu/core-menu.html.erb +62 -0
- data/app/assets/components/core-menu/core-submenu.css +29 -0
- data/app/assets/components/core-menu/core-submenu.html.erb +106 -0
- data/app/assets/components/core-menu-button/core-menu-button.css +10 -0
- data/app/assets/components/core-menu-button/core-menu-button.html.erb +139 -0
- data/app/assets/components/core-meta/core-meta.html +143 -0
- data/app/assets/components/core-overlay/core-key-helper.html +17 -0
- data/app/assets/components/core-overlay/core-overlay-layer.html +112 -0
- data/app/assets/components/core-overlay/core-overlay.html.erb +661 -0
- data/app/assets/components/core-pages/core-pages.css +30 -0
- data/app/assets/components/core-pages/core-pages.html.erb +43 -0
- data/app/assets/components/core-range/core-range.html +107 -0
- data/app/assets/components/core-scaffold/core-scaffold.html.erb +147 -0
- data/app/assets/components/core-scroll-header-panel/core-scroll-header-panel.css +57 -0
- data/app/assets/components/core-scroll-header-panel/core-scroll-header-panel.html.erb +257 -0
- data/app/assets/components/core-selection/core-selection.html +148 -0
- data/app/assets/components/core-selector/core-selector.html.erb +423 -0
- data/app/assets/components/core-shared-lib/core-shared-lib.html +150 -0
- data/app/assets/components/core-signals/core-signals.html +83 -0
- data/app/assets/components/core-splitter/core-splitter.css.erb +27 -0
- data/app/assets/components/core-splitter/core-splitter.html.erb +159 -0
- data/app/assets/components/core-splitter/handle-h.svg +4 -0
- data/app/assets/components/core-splitter/handle.svg +4 -0
- data/app/assets/components/core-style/core-style.html +385 -0
- data/app/assets/components/core-toolbar/core-toolbar.css +126 -0
- data/app/assets/components/core-toolbar/core-toolbar.html.erb +73 -0
- data/app/assets/components/core-tooltip/core-tooltip.css +103 -0
- data/app/assets/components/core-tooltip/core-tooltip.html.erb +144 -0
- data/app/assets/components/core-transition/core-transition-css.html.erb +76 -0
- data/app/assets/components/core-transition/core-transition-overlay.css +46 -0
- data/app/assets/components/core-transition/core-transition.html.erb +44 -0
- data/app/assets/components/web-animations-js/web-animations.js +5666 -0
- data/lib/polymer-core-rails/engine.rb +4 -0
- data/lib/polymer-core-rails/version.rb +3 -0
- data/lib/polymer-core-rails.rb +2 -0
- metadata +167 -0
@@ -0,0 +1,247 @@
|
|
1
|
+
<!--
|
2
|
+
Copyright (c) 2014 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
|
+
<!--
|
11
|
+
`core-collapse` creates a collapsible block of content. By default, the content
|
12
|
+
will be collapsed. Use `opened` to show/hide the content.
|
13
|
+
|
14
|
+
<button on-click="{{toggle}}">toggle collapse</button>
|
15
|
+
|
16
|
+
<core-collapse id="collapse"></core-collapse>
|
17
|
+
...
|
18
|
+
</core-collapse>
|
19
|
+
|
20
|
+
...
|
21
|
+
|
22
|
+
toggle: function() {
|
23
|
+
this.$.collapse.toggle();
|
24
|
+
}
|
25
|
+
|
26
|
+
@group Polymer Core Elements
|
27
|
+
@element core-collapse
|
28
|
+
-->
|
29
|
+
<%= stylesheet_link_tag "core-collapse/core-collapse", 'shim-shadowdom' => true%>
|
30
|
+
|
31
|
+
<polymer-element name="core-collapse" attributes="target horizontal opened duration fixedSize">
|
32
|
+
<template>
|
33
|
+
|
34
|
+
<content></content>
|
35
|
+
|
36
|
+
</template>
|
37
|
+
<script>
|
38
|
+
|
39
|
+
Polymer('core-collapse', {
|
40
|
+
/**
|
41
|
+
* Fired when the target element has been resized as a result of the opened
|
42
|
+
* state changing.
|
43
|
+
*
|
44
|
+
* @event core-resize
|
45
|
+
*/
|
46
|
+
|
47
|
+
/**
|
48
|
+
* The target element.
|
49
|
+
*
|
50
|
+
* @attribute target
|
51
|
+
* @type object
|
52
|
+
* @default null
|
53
|
+
*/
|
54
|
+
target: null,
|
55
|
+
|
56
|
+
/**
|
57
|
+
* If true, the orientation is horizontal; otherwise is vertical.
|
58
|
+
*
|
59
|
+
* @attribute horizontal
|
60
|
+
* @type boolean
|
61
|
+
* @default false
|
62
|
+
*/
|
63
|
+
horizontal: false,
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Set opened to true to show the collapse element and to false to hide it.
|
67
|
+
*
|
68
|
+
* @attribute opened
|
69
|
+
* @type boolean
|
70
|
+
* @default false
|
71
|
+
*/
|
72
|
+
opened: false,
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Collapsing/expanding animation duration in second.
|
76
|
+
*
|
77
|
+
* @attribute duration
|
78
|
+
* @type number
|
79
|
+
* @default 0.33
|
80
|
+
*/
|
81
|
+
duration: 0.33,
|
82
|
+
|
83
|
+
/**
|
84
|
+
* If true, the size of the target element is fixed and is set
|
85
|
+
* on the element. Otherwise it will try to
|
86
|
+
* use auto to determine the natural size to use
|
87
|
+
* for collapsing/expanding.
|
88
|
+
*
|
89
|
+
* @attribute fixedSize
|
90
|
+
* @type boolean
|
91
|
+
* @default false
|
92
|
+
*/
|
93
|
+
fixedSize: false,
|
94
|
+
|
95
|
+
created: function() {
|
96
|
+
this.transitionEndListener = this.transitionEnd.bind(this);
|
97
|
+
},
|
98
|
+
|
99
|
+
ready: function() {
|
100
|
+
this.target = this.target || this;
|
101
|
+
},
|
102
|
+
|
103
|
+
domReady: function() {
|
104
|
+
this.async(function() {
|
105
|
+
this.afterInitialUpdate = true;
|
106
|
+
});
|
107
|
+
},
|
108
|
+
|
109
|
+
detached: function() {
|
110
|
+
if (this.target) {
|
111
|
+
this.removeListeners(this.target);
|
112
|
+
}
|
113
|
+
},
|
114
|
+
|
115
|
+
targetChanged: function(old) {
|
116
|
+
if (old) {
|
117
|
+
this.removeListeners(old);
|
118
|
+
}
|
119
|
+
if (!this.target) {
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
this.isTargetReady = !!this.target;
|
123
|
+
this.classList.toggle('core-collapse-closed', this.target !== this);
|
124
|
+
this.target.style.overflow = 'hidden';
|
125
|
+
this.horizontalChanged();
|
126
|
+
this.addListeners(this.target);
|
127
|
+
// set core-collapse-closed class initially to hide the target
|
128
|
+
this.toggleClosedClass(true);
|
129
|
+
this.update();
|
130
|
+
},
|
131
|
+
|
132
|
+
addListeners: function(node) {
|
133
|
+
node.addEventListener('transitionend', this.transitionEndListener);
|
134
|
+
},
|
135
|
+
|
136
|
+
removeListeners: function(node) {
|
137
|
+
node.removeEventListener('transitionend', this.transitionEndListener);
|
138
|
+
},
|
139
|
+
|
140
|
+
horizontalChanged: function() {
|
141
|
+
this.dimension = this.horizontal ? 'width' : 'height';
|
142
|
+
},
|
143
|
+
|
144
|
+
openedChanged: function() {
|
145
|
+
this.update();
|
146
|
+
},
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Toggle the opened state.
|
150
|
+
*
|
151
|
+
* @method toggle
|
152
|
+
*/
|
153
|
+
toggle: function() {
|
154
|
+
this.opened = !this.opened;
|
155
|
+
},
|
156
|
+
|
157
|
+
setTransitionDuration: function(duration) {
|
158
|
+
var s = this.target.style;
|
159
|
+
s.transition = duration ? (this.dimension + ' ' + duration + 's') : null;
|
160
|
+
if (duration === 0) {
|
161
|
+
this.async('transitionEnd');
|
162
|
+
}
|
163
|
+
},
|
164
|
+
|
165
|
+
transitionEnd: function() {
|
166
|
+
if (this.opened && !this.fixedSize) {
|
167
|
+
this.updateSize('auto', null);
|
168
|
+
}
|
169
|
+
this.setTransitionDuration(null);
|
170
|
+
this.toggleClosedClass(!this.opened);
|
171
|
+
this.asyncFire('core-resize', null, this.target);
|
172
|
+
},
|
173
|
+
|
174
|
+
toggleClosedClass: function(closed) {
|
175
|
+
this.hasClosedClass = closed;
|
176
|
+
this.target.classList.toggle('core-collapse-closed', closed);
|
177
|
+
},
|
178
|
+
|
179
|
+
updateSize: function(size, duration, forceEnd) {
|
180
|
+
this.setTransitionDuration(duration);
|
181
|
+
this.calcSize();
|
182
|
+
var s = this.target.style;
|
183
|
+
var nochange = s[this.dimension] === size;
|
184
|
+
s[this.dimension] = size;
|
185
|
+
// transitonEnd will not be called if the size has not changed
|
186
|
+
if (forceEnd && nochange) {
|
187
|
+
this.transitionEnd();
|
188
|
+
}
|
189
|
+
},
|
190
|
+
|
191
|
+
update: function() {
|
192
|
+
if (!this.target) {
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
if (!this.isTargetReady) {
|
196
|
+
this.targetChanged();
|
197
|
+
}
|
198
|
+
this.horizontalChanged();
|
199
|
+
this[this.opened ? 'show' : 'hide']();
|
200
|
+
},
|
201
|
+
|
202
|
+
calcSize: function() {
|
203
|
+
return this.target.getBoundingClientRect()[this.dimension] + 'px';
|
204
|
+
},
|
205
|
+
|
206
|
+
getComputedSize: function() {
|
207
|
+
return getComputedStyle(this.target)[this.dimension];
|
208
|
+
},
|
209
|
+
|
210
|
+
show: function() {
|
211
|
+
this.toggleClosedClass(false);
|
212
|
+
// for initial update, skip the expanding animation to optimize
|
213
|
+
// performance e.g. skip calcSize
|
214
|
+
if (!this.afterInitialUpdate) {
|
215
|
+
this.transitionEnd();
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
if (!this.fixedSize) {
|
219
|
+
this.updateSize('auto', null);
|
220
|
+
var s = this.calcSize();
|
221
|
+
this.updateSize(0, null);
|
222
|
+
}
|
223
|
+
this.async(function() {
|
224
|
+
this.updateSize(this.size || s, this.duration, true);
|
225
|
+
});
|
226
|
+
},
|
227
|
+
|
228
|
+
hide: function() {
|
229
|
+
// don't need to do anything if it's already hidden
|
230
|
+
if (this.hasClosedClass && !this.fixedSize) {
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
if (this.fixedSize) {
|
234
|
+
// save the size before hiding it
|
235
|
+
this.size = this.getComputedSize();
|
236
|
+
} else {
|
237
|
+
this.updateSize(this.calcSize(), null);
|
238
|
+
}
|
239
|
+
this.async(function() {
|
240
|
+
this.updateSize(0, this.duration);
|
241
|
+
});
|
242
|
+
}
|
243
|
+
|
244
|
+
});
|
245
|
+
|
246
|
+
</script>
|
247
|
+
</polymer-element>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
<!--
|
2
|
+
Copyright (c) 2014 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
|
+
<style>
|
11
|
+
core-drag-avatar {
|
12
|
+
position: fixed;
|
13
|
+
left: 0;
|
14
|
+
top: 0;
|
15
|
+
display: block;
|
16
|
+
pointer-events: none;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
|
20
|
+
<!--
|
21
|
+
@group Polymer Core Elements
|
22
|
+
@element core-drag-drop
|
23
|
+
@homepage github.io
|
24
|
+
-->
|
25
|
+
|
26
|
+
<polymer-element name="core-drag-drop">
|
27
|
+
<script>
|
28
|
+
|
29
|
+
Polymer('core-drag-drop', {
|
30
|
+
|
31
|
+
observe: {
|
32
|
+
'x y': 'coordinatesChanged'
|
33
|
+
},
|
34
|
+
|
35
|
+
ready: function() {
|
36
|
+
if (!this.__proto__.avatar) {
|
37
|
+
this.__proto__.avatar = document.createElement('core-drag-avatar');
|
38
|
+
document.body.appendChild(this.avatar);
|
39
|
+
}
|
40
|
+
this.dragging = false;
|
41
|
+
},
|
42
|
+
|
43
|
+
draggingChanged: function() {
|
44
|
+
this.avatar.style.display = this.dragging ? '' : 'none';
|
45
|
+
},
|
46
|
+
|
47
|
+
coordinatesChanged: function() {
|
48
|
+
var x = this.x, y = this.y;
|
49
|
+
this.avatar.style.transform =
|
50
|
+
this.avatar.style.webkitTransform =
|
51
|
+
'translate(' + x + 'px, ' + y + 'px)';
|
52
|
+
},
|
53
|
+
|
54
|
+
attached: function() {
|
55
|
+
var listen = function(event, handler) {
|
56
|
+
this.parentNode.addEventListener(event, this[handler].bind(this));
|
57
|
+
}.bind(this);
|
58
|
+
//
|
59
|
+
listen('trackstart', 'trackStart');
|
60
|
+
listen('track', 'track');
|
61
|
+
listen('trackend', 'trackEnd');
|
62
|
+
//
|
63
|
+
var host = this.parentNode.host || this.parentNode;
|
64
|
+
host.setAttribute('touch-action', 'none');
|
65
|
+
host.style.cssText += '; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;';
|
66
|
+
},
|
67
|
+
|
68
|
+
trackStart: function(event) {
|
69
|
+
this.avatar.style.cssText = '';
|
70
|
+
this.dragInfo = {
|
71
|
+
event: event,
|
72
|
+
avatar: this.avatar
|
73
|
+
};
|
74
|
+
this.fire('drag-start', this.dragInfo);
|
75
|
+
// flaw #1: what if user doesn't need `drag()`?
|
76
|
+
this.dragging = Boolean(this.dragInfo.drag);
|
77
|
+
},
|
78
|
+
|
79
|
+
track: function(event) {
|
80
|
+
if (this.dragging) {
|
81
|
+
this.x = event.pageX;
|
82
|
+
this.y = event.pageY;
|
83
|
+
this.dragInfo.event = event;
|
84
|
+
this.dragInfo.p = {x : this.x, y: this.y};
|
85
|
+
this.dragInfo.drag(this.dragInfo);
|
86
|
+
}
|
87
|
+
},
|
88
|
+
|
89
|
+
trackEnd: function(event) {
|
90
|
+
if (this.dragging) {
|
91
|
+
this.dragging = false;
|
92
|
+
if (this.dragInfo.drop) {
|
93
|
+
this.dragInfo.framed = this.framed(event.relatedTarget);
|
94
|
+
this.dragInfo.event = event;
|
95
|
+
this.dragInfo.drop(this.dragInfo);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
this.dragInfo = null;
|
99
|
+
},
|
100
|
+
|
101
|
+
framed: function(node) {
|
102
|
+
var local = node.getBoundingClientRect();
|
103
|
+
return {x: this.x - local.left, y: this.y - local.top};
|
104
|
+
}
|
105
|
+
|
106
|
+
});
|
107
|
+
|
108
|
+
</script>
|
109
|
+
</polymer-element>
|
@@ -0,0 +1,162 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2014 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
|
+
:host {
|
11
|
+
display: block;
|
12
|
+
position: absolute;
|
13
|
+
top: 0;
|
14
|
+
left: 0;
|
15
|
+
width: 100%;
|
16
|
+
height: 100%;
|
17
|
+
overflow-x: hidden;
|
18
|
+
}
|
19
|
+
|
20
|
+
#drawer {
|
21
|
+
position: absolute;
|
22
|
+
top: 0;
|
23
|
+
left: 0;
|
24
|
+
/* FIXME(ffu): remove hard-coded drawer panel width */
|
25
|
+
width: 256px;
|
26
|
+
height: 100%;
|
27
|
+
box-sizing: border-box;
|
28
|
+
-mox-box-sizing: border-box;
|
29
|
+
}
|
30
|
+
|
31
|
+
.transition #drawer {
|
32
|
+
transition: -webkit-transform ease-in-out 0.3s, width ease-in-out 0.3s;
|
33
|
+
transition: transform ease-in-out 0.3s, width ease-in-out 0.3s;
|
34
|
+
}
|
35
|
+
|
36
|
+
/*
|
37
|
+
right-drawer: make drawer on the right side
|
38
|
+
*/
|
39
|
+
:host(.right-drawer) #drawer {
|
40
|
+
left: auto;
|
41
|
+
right: 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
:host(.right-drawer) .transition #drawer {
|
45
|
+
transition: -webkit-transform ease-in-out 0.3s, width ease-in-out 0.3s;
|
46
|
+
transition: transform ease-in-out 0.3s, width ease-in-out 0.3s;
|
47
|
+
}
|
48
|
+
|
49
|
+
polyfill-next-selector { content: ':host [drawer]'; }
|
50
|
+
::content[select="[drawer]"] > * {
|
51
|
+
position: absolute;
|
52
|
+
top: 0;
|
53
|
+
left: 0;
|
54
|
+
width: 100%;
|
55
|
+
height: 100%;
|
56
|
+
box-sizing: border-box;
|
57
|
+
-moz-box-sizing: border-box;
|
58
|
+
}
|
59
|
+
|
60
|
+
#main {
|
61
|
+
position: absolute;
|
62
|
+
top: 0;
|
63
|
+
right: 0;
|
64
|
+
bottom: 0;
|
65
|
+
left: 256px;
|
66
|
+
overflow: auto;
|
67
|
+
}
|
68
|
+
|
69
|
+
.transition #main {
|
70
|
+
transition: left ease-in-out 0.3s, padding ease-in-out 0.3s;
|
71
|
+
}
|
72
|
+
|
73
|
+
:host(.right-drawer) #main {
|
74
|
+
left: 0;
|
75
|
+
right: 256px;
|
76
|
+
}
|
77
|
+
|
78
|
+
:host(.right-drawer) .transition #main {
|
79
|
+
transition: right ease-in-out 0.3s, padding ease-in-out 0.3s;
|
80
|
+
}
|
81
|
+
|
82
|
+
polyfill-next-selector { content: '#main > [main]'; }
|
83
|
+
::content[select="[main]"] > * {
|
84
|
+
height: 100%;
|
85
|
+
}
|
86
|
+
|
87
|
+
#scrim {
|
88
|
+
position: absolute;
|
89
|
+
top: 0;
|
90
|
+
right: 0;
|
91
|
+
bottom: 0;
|
92
|
+
left: 0;
|
93
|
+
background-color: rgba(0, 0, 0, 0.3);
|
94
|
+
visibility: hidden;
|
95
|
+
opacity: 0;
|
96
|
+
transition: opacity ease-in-out 0.38s, visibility ease-in-out 0.38s;
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
no-peek: helper class to make drawer panel 100% width in narrow layout
|
101
|
+
*/
|
102
|
+
:host(.no-peek) .narrow-layout > #drawer {
|
103
|
+
width: 100%;
|
104
|
+
}
|
105
|
+
|
106
|
+
:host(.no-peek) .narrow-layout > #drawer:not(.core-selected) {
|
107
|
+
left: -100%;
|
108
|
+
}
|
109
|
+
|
110
|
+
:host(.no-peek.right-drawer) .narrow-layout > #drawer:not(.core-selected) {
|
111
|
+
left: auto;
|
112
|
+
right: -100%;
|
113
|
+
}
|
114
|
+
|
115
|
+
/*
|
116
|
+
narrow layout
|
117
|
+
*/
|
118
|
+
.narrow-layout > #drawer.core-selected {
|
119
|
+
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.15);
|
120
|
+
}
|
121
|
+
|
122
|
+
polyfill-next-selector { content: ':host .narrow-layout > #drawer > [drawer]'; }
|
123
|
+
.narrow-layout > #drawer > ::content[select="[drawer]"] > * {
|
124
|
+
border: 0;
|
125
|
+
}
|
126
|
+
|
127
|
+
.narrow-layout > #drawer:not(.core-selected) {
|
128
|
+
-webkit-transform: translate3d(-100%, 0, 0);
|
129
|
+
transform: translate3d(-100%, 0, 0);
|
130
|
+
}
|
131
|
+
|
132
|
+
:host(.right-drawer) .narrow-layout > #drawer:not(.core-selected) {
|
133
|
+
left: auto;
|
134
|
+
-webkit-transform: translate3d(100%, 0, 0);
|
135
|
+
transform: translate3d(100%, 0, 0);
|
136
|
+
}
|
137
|
+
|
138
|
+
.narrow-layout > #main {
|
139
|
+
left: 0 !important;
|
140
|
+
padding: 0;
|
141
|
+
}
|
142
|
+
|
143
|
+
:host(.right-drawer) .narrow-layout > #main {
|
144
|
+
left: 0;
|
145
|
+
right: 0;
|
146
|
+
padding: 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
.narrow-layout > #main:not(.core-selected) #scrim {
|
150
|
+
visibility: visible;
|
151
|
+
opacity: 1;
|
152
|
+
}
|
153
|
+
|
154
|
+
polyfill-next-selector { content: ':host .narrow-layout > #main > [main]'; }
|
155
|
+
.narrow-layout > #main > ::content[select="[main]"] > * {
|
156
|
+
margin: 0;
|
157
|
+
min-height: 100%;
|
158
|
+
left: 0;
|
159
|
+
right: 0;
|
160
|
+
box-sizing: border-box;
|
161
|
+
-moz-box-sizing: border-box;
|
162
|
+
}
|
@@ -0,0 +1,150 @@
|
|
1
|
+
<!--
|
2
|
+
Copyright (c) 2014 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
|
+
<!--
|
11
|
+
`core-drawer-panel` contains a drawer panel and a main panel. The drawer
|
12
|
+
and the main panel are side-by-side with drawer on the left. When browser
|
13
|
+
window size is smaller than the `responsiveWidth`, `core-drawer-panel`
|
14
|
+
changes to narrow layout. In narrow layout, the drawer will be stacked on top
|
15
|
+
of the main panel. The drawer will be slided in/out to hide/reveal the main
|
16
|
+
panel.
|
17
|
+
|
18
|
+
Use the attribute `drawer` to indicate the element is a drawer panel and
|
19
|
+
`main` to indicate is a main panel.
|
20
|
+
|
21
|
+
Example:
|
22
|
+
|
23
|
+
<core-drawer-panel>
|
24
|
+
<div drawer> Drawer panel... </div>
|
25
|
+
<div main> Main panel... </div>
|
26
|
+
</core-drawer-panel>
|
27
|
+
|
28
|
+
To position the drawer to the right, add `right-drawer` to the class list.
|
29
|
+
|
30
|
+
<core-drawer-panel class="right-drawer">
|
31
|
+
<div drawer> Drawer panel... </div>
|
32
|
+
<div main> Main panel... </div>
|
33
|
+
</core-drawer-panel>
|
34
|
+
|
35
|
+
@group Polymer Core Elements
|
36
|
+
@element core-drawer-panel
|
37
|
+
@homepage github.io
|
38
|
+
-->
|
39
|
+
|
40
|
+
<%= html_import_tag "core-media-query/core-media-query" %>
|
41
|
+
<%= html_import_tag "core-selector/core-selector" %>
|
42
|
+
|
43
|
+
<polymer-element name="core-drawer-panel">
|
44
|
+
<template>
|
45
|
+
|
46
|
+
<%= stylesheet_link_tag "core-drawer-panel/core-drawer-panel" %>
|
47
|
+
|
48
|
+
<core-media-query query="max-width: {{responsiveWidth}}" queryMatches="{{queryMatches}}"></core-media-query>
|
49
|
+
|
50
|
+
<core-selector class="{{ {'narrow-layout' : queryMatches, transition : transition} | tokenList }}" valueattr="id" selected="{{selected}}">
|
51
|
+
|
52
|
+
<div id="main" >
|
53
|
+
<content select="[main]"></content>
|
54
|
+
<div id="scrim" on-tap="{{togglePanel}}"></div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div id="drawer">
|
58
|
+
<content select="[drawer]"></content>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
</core-selector>
|
62
|
+
|
63
|
+
</template>
|
64
|
+
<script>
|
65
|
+
|
66
|
+
Polymer('core-drawer-panel', {
|
67
|
+
/**
|
68
|
+
* Fired when the narrow layout changes.
|
69
|
+
*
|
70
|
+
* @event core-responsive-change
|
71
|
+
* @param {Object} detail
|
72
|
+
* @param {boolean} detail.narrow true if the panel is in narrow layout.
|
73
|
+
*/
|
74
|
+
|
75
|
+
publish: {
|
76
|
+
/**
|
77
|
+
* Max-width when the panel changes to narrow layout.
|
78
|
+
*
|
79
|
+
* @attribute responsiveWidth
|
80
|
+
* @type string
|
81
|
+
* @default '640px'
|
82
|
+
*/
|
83
|
+
responsiveWidth: '640px',
|
84
|
+
|
85
|
+
/**
|
86
|
+
* The panel that is being selected. `drawer` for the drawer panel and
|
87
|
+
* `main` for the main panel.
|
88
|
+
*
|
89
|
+
* @attribute selected
|
90
|
+
* @type string
|
91
|
+
* @default null
|
92
|
+
*/
|
93
|
+
selected: {value: null, reflect: true},
|
94
|
+
|
95
|
+
/**
|
96
|
+
* The panel to be selected when `core-drawer-panel` changes to narrow
|
97
|
+
* layout.
|
98
|
+
*
|
99
|
+
* @attribute defaultSelected
|
100
|
+
* @type string
|
101
|
+
* @default 'main'
|
102
|
+
*/
|
103
|
+
defaultSelected: 'main',
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Returns true if the panel is in narrow layout. This is useful if you
|
107
|
+
* need to show/hide elements based on the layout.
|
108
|
+
*
|
109
|
+
* @attribute narrow
|
110
|
+
* @type boolean
|
111
|
+
* @default false
|
112
|
+
*/
|
113
|
+
narrow: {value: false, reflect: true}
|
114
|
+
},
|
115
|
+
|
116
|
+
transition: false,
|
117
|
+
|
118
|
+
domReady: function() {
|
119
|
+
// to avoid transition at the beginning e.g. page loads
|
120
|
+
// NOTE: domReady is already raf delayed and delaying another frame
|
121
|
+
// ensures a layout has occurred.
|
122
|
+
this.async(function() {
|
123
|
+
this.transition = true;
|
124
|
+
});
|
125
|
+
},
|
126
|
+
|
127
|
+
togglePanel: function() {
|
128
|
+
this.selected = this.selected === 'main' ? 'drawer' : 'main';
|
129
|
+
},
|
130
|
+
|
131
|
+
openDrawer: function() {
|
132
|
+
this.selected = 'drawer';
|
133
|
+
},
|
134
|
+
|
135
|
+
closeDrawer: function() {
|
136
|
+
this.selected = 'main';
|
137
|
+
},
|
138
|
+
|
139
|
+
queryMatchesChanged: function() {
|
140
|
+
if (this.queryMatches) {
|
141
|
+
this.selected = this.defaultSelected;
|
142
|
+
}
|
143
|
+
this.narrow = this.queryMatches;
|
144
|
+
this.fire('core-responsive-change', {narrow: this.narrow});
|
145
|
+
}
|
146
|
+
|
147
|
+
});
|
148
|
+
|
149
|
+
</script>
|
150
|
+
</polymer-element>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
2
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
3
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
4
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
5
|
+
Code distributed by Google as part of the polymer project is also
|
6
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */
|
7
|
+
|
8
|
+
|
9
|
+
:host {
|
10
|
+
display: block;
|
11
|
+
color: #333;
|
12
|
+
font-size: 14px;
|
13
|
+
}
|
14
|
+
|
15
|
+
polyfill-next-selector { content: ':host > core-icon'; }
|
16
|
+
::content > core-icon {
|
17
|
+
margin: 8px;
|
18
|
+
}
|
19
|
+
|
20
|
+
polyfill-next-selector { content: ':host input'; }
|
21
|
+
::content input {
|
22
|
+
background: transparent;
|
23
|
+
border: 0;
|
24
|
+
padding: 0;
|
25
|
+
margin: 0 4px;
|
26
|
+
color: #333;
|
27
|
+
font-size: 14px;
|
28
|
+
}
|
29
|
+
|
30
|
+
polyfill-next-selector { content: ':host input:focus'; }
|
31
|
+
::content input:focus {
|
32
|
+
outline: none;
|
33
|
+
}
|
34
|
+
|
35
|
+
polyfill-next-selector { content: ':host input::placeholder'; }
|
36
|
+
::content input::placeholder {
|
37
|
+
color: #b3b3b3;
|
38
|
+
}
|