polymer-paper-rails 0.1.0
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 +69 -0
- data/Rakefile +1 -0
- data/app/assets/components/core/animation/web-animations.html.erb +1 -0
- data/app/assets/components/core/animation/web-animations.js +5666 -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/iconset/core-iconset.html.erb +236 -0
- data/app/assets/components/core/input/core-input.css +35 -0
- data/app/assets/components/core/input/core-input.html.erb +385 -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/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/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/range/core-range.html +106 -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/style/core-style.html +386 -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/paper-button/paper-button.css +115 -0
- data/app/assets/components/paper-button/paper-button.html.erb +210 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.css +262 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.html.erb +104 -0
- data/app/assets/components/paper-dialog/paper-dialog-transition.css +59 -0
- data/app/assets/components/paper-dialog/paper-dialog-transition.html.erb +27 -0
- data/app/assets/components/paper-dialog/paper-dialog.css +0 -0
- data/app/assets/components/paper-dialog/paper-dialog.html.erb +176 -0
- data/app/assets/components/paper-fab/paper-fab.css +27 -0
- data/app/assets/components/paper-fab/paper-fab.html.erb +55 -0
- data/app/assets/components/paper-focusable/paper-focusable.html +144 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.css +17 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.html.erb +87 -0
- data/app/assets/components/paper-input/error-100.png +0 -0
- data/app/assets/components/paper-input/error-200.png +0 -0
- data/app/assets/components/paper-input/paper-input.html.erb +398 -0
- data/app/assets/components/paper-input/paper-input.scss +203 -0
- data/app/assets/components/paper-item/paper-item.css +30 -0
- data/app/assets/components/paper-item/paper-item.html.erb +103 -0
- data/app/assets/components/paper-menu-button/paper-menu-button-overlay.html.erb +86 -0
- data/app/assets/components/paper-menu-button/paper-menu-button-transition.css +19 -0
- data/app/assets/components/paper-menu-button/paper-menu-button-transition.html.erb +118 -0
- data/app/assets/components/paper-menu-button/paper-menu-button.css +86 -0
- data/app/assets/components/paper-menu-button/paper-menu-button.html.erb +128 -0
- data/app/assets/components/paper-progress/paper-progress.css +35 -0
- data/app/assets/components/paper-progress/paper-progress.html.erb +98 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.css +98 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.html.erb +148 -0
- data/app/assets/components/paper-radio-group/paper-radio-group.html.erb +68 -0
- data/app/assets/components/paper-ripple/paper-ripple.html +426 -0
- data/app/assets/components/paper-shadow/paper-shadow.css +81 -0
- data/app/assets/components/paper-shadow/paper-shadow.html.erb +212 -0
- data/app/assets/components/paper-slider/paper-slider.css +193 -0
- data/app/assets/components/paper-slider/paper-slider.html.erb +310 -0
- data/app/assets/components/paper-tabs/paper-tab.css +49 -0
- data/app/assets/components/paper-tabs/paper-tab.html.erb +66 -0
- data/app/assets/components/paper-tabs/paper-tabs.css +57 -0
- data/app/assets/components/paper-tabs/paper-tabs.html.erb +127 -0
- data/app/assets/components/paper-toast/paper-toast.css +0 -0
- data/app/assets/components/paper-toast/paper-toast.html.erb +258 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +61 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html.erb +125 -0
- data/lib/polymer-paper-rails/engine.rb +4 -0
- data/lib/polymer-paper-rails/version.rb +3 -0
- data/lib/polymer-paper-rails.rb +2 -0
- metadata +158 -0
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
html /deep/ core-menu {
|
|
11
|
+
display: block;
|
|
12
|
+
margin: 12px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
polyfill-next-selector { content: 'core-menu > core-item'; }
|
|
16
|
+
html /deep/ core-menu::shadow ::content > core-item {
|
|
17
|
+
cursor: default;
|
|
18
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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-menu` is a selector which styles to looks like a menu.
|
|
12
|
+
|
|
13
|
+
<core-menu selected="0">
|
|
14
|
+
<core-item icon="settings" label="Settings"></core-item>
|
|
15
|
+
<core-item icon="dialog" label="Dialog"></core-item>
|
|
16
|
+
<core-item icon="search" label="Search"></core-item>
|
|
17
|
+
</core-menu>
|
|
18
|
+
|
|
19
|
+
When an item is selected the `core-selected` class is added to it. The user can
|
|
20
|
+
use the class to add more stylings to the selected item.
|
|
21
|
+
|
|
22
|
+
core-item.core-selected {
|
|
23
|
+
color: red;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
The `selectedItem` property references the selected item.
|
|
27
|
+
|
|
28
|
+
<core-menu selected="0" selectedItem="{{item}}">
|
|
29
|
+
<core-item icon="settings" label="Settings"></core-item>
|
|
30
|
+
<core-item icon="dialog" label="Dialog"></core-item>
|
|
31
|
+
<core-item icon="search" label="Search"></core-item>
|
|
32
|
+
</core-menu>
|
|
33
|
+
|
|
34
|
+
<div>selected label: {{item.label}}</div>
|
|
35
|
+
|
|
36
|
+
The `core-select` event signals selection change.
|
|
37
|
+
|
|
38
|
+
<core-menu selected="0" on-core-select="{{selectAction}}">
|
|
39
|
+
<core-item icon="settings" label="Settings"></core-item>
|
|
40
|
+
<core-item icon="dialog" label="Dialog"></core-item>
|
|
41
|
+
<core-item icon="search" label="Search"></core-item>
|
|
42
|
+
</core-menu>
|
|
43
|
+
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
selectAction: function(e, detail) {
|
|
47
|
+
if (detail.isSelected) {
|
|
48
|
+
var selectedItem = detail.item;
|
|
49
|
+
...
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@group Polymer Core Elements
|
|
54
|
+
@element core-menu
|
|
55
|
+
@extends core-selector
|
|
56
|
+
-->
|
|
57
|
+
|
|
58
|
+
<%= html_import_tag "core/selector/core-selector" %>
|
|
59
|
+
|
|
60
|
+
<%= stylesheet_link_tag "core/list/core-list", "shim-shadowdom" => true %>
|
|
61
|
+
|
|
62
|
+
<polymer-element name="core-menu" extends="core-selector" noscript></polymer-element>
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
4
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
|
5
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
|
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
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
height: auto;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host(.core-selected, [active]) {
|
|
16
|
+
font-weight: initial;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
core-item {
|
|
20
|
+
cursor: default;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
::content > core-item {
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#submenu {
|
|
28
|
+
margin: 0 0 0 44px;
|
|
29
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
|
4
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
|
5
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
|
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
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<!--
|
|
11
|
+
Use to create nested menus inside of `core-menu` elements.
|
|
12
|
+
|
|
13
|
+
<core-menu selected="0">
|
|
14
|
+
|
|
15
|
+
<core-submenu icon="settings" label="Topics">
|
|
16
|
+
<core-item label="Topic 1"></core-item>
|
|
17
|
+
<core-item label="Topic 2"></core-item>
|
|
18
|
+
</core-submenu>
|
|
19
|
+
|
|
20
|
+
<core-submenu icon="settings" label="Favorites">
|
|
21
|
+
<core-item label="Favorite 1"></core-item>
|
|
22
|
+
<core-item label="Favorite 2"></core-item>
|
|
23
|
+
<core-item label="Favorite 3"></core-item>
|
|
24
|
+
</core-submenu>
|
|
25
|
+
|
|
26
|
+
</core-menu>
|
|
27
|
+
|
|
28
|
+
There is a margin set on the submenu to indent the items.
|
|
29
|
+
You can override the margin by doing:
|
|
30
|
+
|
|
31
|
+
core-submenu::shadow #submenu {
|
|
32
|
+
margin-left: 20px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@group Polymer Core Elements
|
|
36
|
+
@element core-submenu
|
|
37
|
+
@extends core-item
|
|
38
|
+
-->
|
|
39
|
+
|
|
40
|
+
<%= html_import_tag "core-item/core-item" %>
|
|
41
|
+
<%= html_import_tag "core-menu/core-menu" %>
|
|
42
|
+
<%= html_import_tag "core-collapse/core-collapse" %>
|
|
43
|
+
|
|
44
|
+
<polymer-element name="core-submenu" attributes="selected selectedItem label icon src valueattr">
|
|
45
|
+
<template>
|
|
46
|
+
|
|
47
|
+
<%= stylesheet_link_tag "core-menu/core-submenu"%>
|
|
48
|
+
|
|
49
|
+
<core-item src="{{src}}" label="{{label}}" icon="{{icon}}" class="{{ {'core-selected' : active} | tokenList}}" on-tap="{{activate}}">
|
|
50
|
+
<content select=".item-content"></content>
|
|
51
|
+
</core-item>
|
|
52
|
+
|
|
53
|
+
<core-menu id="submenu" selected="{{selected}}" selectedItem="{{selectedItem}}" valueattr="{{valueattr}}">
|
|
54
|
+
<content></content>
|
|
55
|
+
</core-menu>
|
|
56
|
+
|
|
57
|
+
<core-collapse target="{{$.submenu}}" opened="{{opened}}"></core-collapse>
|
|
58
|
+
|
|
59
|
+
</template>
|
|
60
|
+
<script>
|
|
61
|
+
|
|
62
|
+
Polymer('core-submenu', {
|
|
63
|
+
|
|
64
|
+
publish: {
|
|
65
|
+
active: {value: false, reflect: true}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
opened: false,
|
|
69
|
+
|
|
70
|
+
get items() {
|
|
71
|
+
return this.$.submenu.items;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
hasItems: function() {
|
|
75
|
+
return !!this.items.length;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
unselectAllItems: function() {
|
|
79
|
+
this.$.submenu.selected = null;
|
|
80
|
+
this.$.submenu.clearSelection();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
activeChanged: function() {
|
|
84
|
+
if (this.hasItems()) {
|
|
85
|
+
this.opened = this.active;
|
|
86
|
+
}
|
|
87
|
+
if (!this.active) {
|
|
88
|
+
this.unselectAllItems();
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
toggle: function() {
|
|
93
|
+
this.opened = !this.opened;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
activate: function() {
|
|
97
|
+
if (this.hasItems() && this.active) {
|
|
98
|
+
this.toggle();
|
|
99
|
+
this.unselectAllItems();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
</script>
|
|
106
|
+
</polymer-element>
|
|
@@ -0,0 +1,143 @@
|
|
|
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-meta` provides a method of constructing a self-organizing database.
|
|
12
|
+
It is useful to collate element meta-data for things like catalogs and for
|
|
13
|
+
designer.
|
|
14
|
+
|
|
15
|
+
Example, an element folder has a `metadata.html` file in it, that contains a
|
|
16
|
+
`core-meta`, something like this:
|
|
17
|
+
|
|
18
|
+
<core-meta id="my-element" label="My Element">
|
|
19
|
+
<property name="color" value="blue"></property>
|
|
20
|
+
</core-meta>
|
|
21
|
+
|
|
22
|
+
An application can import as many of these files as it wants, and then use
|
|
23
|
+
`core-meta` again to access the collected data.
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
var meta = document.createElement('core-meta');
|
|
27
|
+
console.log(meta.list); // dump a list of all meta-data elements that have been created
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
Use `byId(id)` to retrive a specific core-meta.
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
var meta = document.createElement('core-meta');
|
|
34
|
+
console.log(meta.byId('my-element'));
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
By default all meta-data are stored in a single databse. If your meta-data
|
|
38
|
+
have different types and want them to be stored separately, use `type` to
|
|
39
|
+
differentiate them.
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
|
|
43
|
+
<core-meta id="x-foo" type="xElt"></core-meta>
|
|
44
|
+
<core-meta id="x-bar" type="xElt"></core-meta>
|
|
45
|
+
<core-meta id="y-bar" type="yElt"></core-meta>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
var meta = document.createElement('core-meta');
|
|
49
|
+
meta.type = 'xElt';
|
|
50
|
+
console.log(meta.list);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
@group Polymer Core Elements
|
|
54
|
+
@element core-meta
|
|
55
|
+
@homepage github.io
|
|
56
|
+
-->
|
|
57
|
+
|
|
58
|
+
<polymer-element name="core-meta" attributes="list label type" hidden>
|
|
59
|
+
<script>
|
|
60
|
+
|
|
61
|
+
(function() {
|
|
62
|
+
|
|
63
|
+
var SKIP_ID = 'meta';
|
|
64
|
+
var metaData = {}, metaArray = {};
|
|
65
|
+
|
|
66
|
+
Polymer('core-meta', {
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The type of meta-data. All meta-data with the same type with be
|
|
70
|
+
* stored together.
|
|
71
|
+
*
|
|
72
|
+
* @attribute type
|
|
73
|
+
* @type string
|
|
74
|
+
* @default 'default'
|
|
75
|
+
*/
|
|
76
|
+
type: 'default',
|
|
77
|
+
|
|
78
|
+
alwaysPrepare: true,
|
|
79
|
+
|
|
80
|
+
ready: function() {
|
|
81
|
+
this.register(this.id);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
get metaArray() {
|
|
85
|
+
var t = this.type;
|
|
86
|
+
if (!metaArray[t]) {
|
|
87
|
+
metaArray[t] = [];
|
|
88
|
+
}
|
|
89
|
+
return metaArray[t];
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
get metaData() {
|
|
93
|
+
var t = this.type;
|
|
94
|
+
if (!metaData[t]) {
|
|
95
|
+
metaData[t] = {};
|
|
96
|
+
}
|
|
97
|
+
return metaData[t];
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
register: function(id, old) {
|
|
101
|
+
if (id && id !== SKIP_ID) {
|
|
102
|
+
this.unregister(this, old);
|
|
103
|
+
this.metaData[id] = this;
|
|
104
|
+
this.metaArray.push(this);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
unregister: function(meta, id) {
|
|
109
|
+
delete this.metaData[id || meta.id];
|
|
110
|
+
var i = this.metaArray.indexOf(meta);
|
|
111
|
+
if (i >= 0) {
|
|
112
|
+
this.metaArray.splice(i, 1);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns a list of all meta-data elements with the same type.
|
|
118
|
+
*
|
|
119
|
+
* @attribute list
|
|
120
|
+
* @type array
|
|
121
|
+
* @default []
|
|
122
|
+
*/
|
|
123
|
+
get list() {
|
|
124
|
+
return this.metaArray;
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Retrieves meta-data by ID.
|
|
129
|
+
*
|
|
130
|
+
* @method byId
|
|
131
|
+
* @param {String} id The ID of the meta-data to be returned.
|
|
132
|
+
* @returns Returns meta-data.
|
|
133
|
+
*/
|
|
134
|
+
byId: function(id) {
|
|
135
|
+
return this.metaData[id];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
})();
|
|
141
|
+
|
|
142
|
+
</script>
|
|
143
|
+
</polymer-element>
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
<polymer-element name="core-key-helper">
|
|
11
|
+
<script>
|
|
12
|
+
Polymer('core-key-helper', {
|
|
13
|
+
ENTER_KEY: 13,
|
|
14
|
+
ESCAPE_KEY: 27
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
</polymer-element>
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
<polymer-element name="core-overlay-layer">
|
|
11
|
+
<template>
|
|
12
|
+
<style>
|
|
13
|
+
:host {
|
|
14
|
+
position: fixed;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
z-index: 1000;
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host(.core-opened) {
|
|
22
|
+
display: block;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
<content></content>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
(function() {
|
|
29
|
+
|
|
30
|
+
Polymer('core-overlay-layer', {
|
|
31
|
+
publish: {
|
|
32
|
+
opened: false
|
|
33
|
+
},
|
|
34
|
+
openedChanged: function() {
|
|
35
|
+
this.classList.toggle('core-opened', this.opened);
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Adds an element to the overlay layer
|
|
39
|
+
*/
|
|
40
|
+
addElement: function(element) {
|
|
41
|
+
if (!this.parentNode) {
|
|
42
|
+
document.querySelector('body').appendChild(this);
|
|
43
|
+
}
|
|
44
|
+
if (element.parentNode !== this) {
|
|
45
|
+
element.__contents = [];
|
|
46
|
+
var ip$ = element.querySelectorAll('content');
|
|
47
|
+
for (var i=0, l=ip$.length, n; (i<l) && (n = ip$[i]); i++) {
|
|
48
|
+
this.moveInsertedElements(n);
|
|
49
|
+
this.cacheDomLocation(n);
|
|
50
|
+
n.parentNode.removeChild(n);
|
|
51
|
+
element.__contents.push(n);
|
|
52
|
+
}
|
|
53
|
+
this.cacheDomLocation(element);
|
|
54
|
+
this.updateEventController(element);
|
|
55
|
+
var h = this.makeHost();
|
|
56
|
+
h.shadowRoot.appendChild(element);
|
|
57
|
+
element.__host = h;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
makeHost: function() {
|
|
61
|
+
var h = document.createElement('overlay-host');
|
|
62
|
+
h.createShadowRoot();
|
|
63
|
+
this.appendChild(h);
|
|
64
|
+
return h;
|
|
65
|
+
},
|
|
66
|
+
moveInsertedElements: function(insertionPoint) {
|
|
67
|
+
var n$ = insertionPoint.getDistributedNodes();
|
|
68
|
+
var parent = insertionPoint.parentNode;
|
|
69
|
+
insertionPoint.__contents = [];
|
|
70
|
+
for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
|
|
71
|
+
this.cacheDomLocation(n);
|
|
72
|
+
this.updateEventController(n);
|
|
73
|
+
insertionPoint.__contents.push(n);
|
|
74
|
+
parent.appendChild(n);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
updateEventController: function(element) {
|
|
78
|
+
element.eventController = this.element.findController(element);
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Removes an element from the overlay layer
|
|
82
|
+
*/
|
|
83
|
+
removeElement: function(element) {
|
|
84
|
+
element.eventController = null;
|
|
85
|
+
this.replaceElement(element);
|
|
86
|
+
var h = element.__host;
|
|
87
|
+
if (h) {
|
|
88
|
+
h.parentNode.removeChild(h);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
replaceElement: function(element) {
|
|
92
|
+
if (element.__contents) {
|
|
93
|
+
for (var i=0, c$=element.__contents, c; (c=c$[i]); i++) {
|
|
94
|
+
this.replaceElement(c);
|
|
95
|
+
}
|
|
96
|
+
element.__contents = null;
|
|
97
|
+
}
|
|
98
|
+
if (element.__parentNode) {
|
|
99
|
+
var n = element.__nextElementSibling && element.__nextElementSibling
|
|
100
|
+
=== element.__parentNode ? element.__nextElementSibling : null;
|
|
101
|
+
element.__parentNode.insertBefore(element, n);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
cacheDomLocation: function(element) {
|
|
105
|
+
element.__nextElementSibling = element.nextElementSibling;
|
|
106
|
+
element.__parentNode = element.parentNode;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
})();
|
|
111
|
+
</script>
|
|
112
|
+
</polymer-element>
|