-
Notifications
You must be signed in to change notification settings - Fork 17
/
px-context-browser-trigger.html
91 lines (75 loc) · 2.53 KB
/
px-context-browser-trigger.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!--
Copyright (c) 2018, General Electric
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../px-icon-set/px-icon-set-navigation.html"/>
<link rel="import" href="../px-icon-set/px-icon.html"/>
<link rel="import" href="css/px-context-browser-trigger-styles.html"/>
<!--
### Usage
<px-context-browser-trigger trigger={{openTrigger}}></px-context-browser-trigger>
<px-context-browser open-trigger="[[openTrigger]]" items='[{"label":"Home","id":"home"},{"label":"Alerts","id":"alerts"},{"label":"Assets","id":"assets"}]'></px-context-browser>
@element px-context-browser-trigger
@homepage index.html
@demo index.html
-->
<dom-module id="px-context-browser-trigger">
<template>
<style include="px-context-browser-trigger-styles"></style>
<px-icon icon="[[_getIcon(favorited)]]"></px-icon>
</template>
<script>
Polymer({
is: 'px-context-browser-trigger',
properties: {
/**
* Read-only reference to the trigger element. Data-bind this property
* into the px-context-browser `openTrigger` or `favoritedTrigger`
* property to open the context browser when this icon is tapped.
*/
trigger: {
type: HTMLElement,
readOnly: true,
notify: true,
value: null
},
/**
* Enable to use this trigger to open the px-context-browser favorited
* panel. If enabled, bind this element's `trigger` property to the
* context browser's `favoritedTrigger` property.
*/
favorited: {
type: Boolean,
value: false
}
},
attached() {
this._setTrigger(this);
},
detached() {
this._setTrigger(null);
},
listeners: {
'tap' : '_handleTapped'
},
_handleTapped(evt) {
evt.preventDefault();
this.fire('trigger-tapped');
},
_getIcon(favorites) {
if (favorites === true) {
return 'px-nav:favorite';
}
return 'px-nav:hierarchy'
}
})
</script>
</dom-module>