-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcasper-simple-select.js
More file actions
123 lines (104 loc) · 3.58 KB
/
casper-simple-select.js
File metadata and controls
123 lines (104 loc) · 3.58 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
- Copyright (c) 2018 Cloudware S.A. All rights reserved.
-
- This file is part of casper-context-menu.
-
- casper-context-menu is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- casper-context-menu is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with casper-context-menu. If not, see <http://www.gnu.org/licenses/>.
-
*/
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
class CasperSimpleSelect extends PolymerElement {
static get template() {
return html`
<style>
iron-icon {
/* background-color: green; */
}
iron-icon {
--iron-icon-width: 14px;
--iron-icon-height: 12px;
--iron-icon-fill-color: var(--primary-color);
}
#inner_box > a {
font-weight: bold;
cursor: pointer;
color: var(--primary-color);
}
#inner_box:hover > a:hover{
color: var(--dark-primary-color);
}
#inner_box:hover a,
#inner_box:hover iron-icon {
text-decoration: none;
cursor: pointer;
}
#inner_box:hover iron-icon {
--iron-icon-fill-color: var(--dark-primary-color);
}
#slot_text {
line-height: 30px;
display: inline-block;
padding-right: 0px;
}
casper-menu-list a[data-label]::after {
content: attr(data-label);
text-transform: uppercase;
margin-left: 5px;
font-size: 9px;
background-color: var(--primary-color);
color: white;
padding: 3px 3px;
display: inline;
border-radius: 2px;
}
casper-menu-list a:hover[data-label]::after{
color: var(--primary-color);
background: white;
}
</style>
<span id="inner_box">
<a id="slot_text" href="[[href]]" data-level="[[level]]"><slot></slot></a>
<iron-icon icon="toc-icons:expand-more">icon</iron-icon>
<casper-context-menu id="select_options" no-overlap="" vertical-align="auto" horizontal-align="auto">
<template is="dom-repeat" items="[[items]]" index-as="index">
<casper-menu-list on-click="customclick">
<a data-level="3" href="[[item.link]]" data-wizard$="[[item.data_wizard]]" data-wizard-options$="[[item.data_wizard_options]]" data-label$="[[item.label]]" data-remote$="[[item.remote]]">[[item.title]]</a>
</casper-menu-list>
</template>
</casper-context-menu>
</span>
`;
}
static get is () {
return 'casper-simple-select';
}
static get properties () {
return {
}
}
customclick(e){
var level = Number(e.target.getAttribute("data-level"));
var text = e.target.text;
this.innerText = text;
this.$.select_options.close();
this.app.$.main_menu.label_3_link = e.target.href;
}
ready () {
super.ready();
this.$.slot_text.addEventListener('click', e => this.$.select_options.open());
this.$.inner_box.addEventListener('mouseover', e => this.$.select_options.open());
this.$.inner_box.addEventListener('mouseout', e => this.$.select_options.close());
}
}
window.customElements.define(CasperSimpleSelect.is, CasperSimpleSelect);