89558a41
Renato De Donato
datatype, provide...
|
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
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<dom-module id="select-fields-controllet">
<style is="custom-style">
#select_fields_controllet_container {
height: 100%;
width: 100%;
}
#select_fields_controllet_container * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
}
#select_fields_controllet_container #header {
background: #B6B6B6;
height: 24px;
padding: 12px;
text-align: center;
font-weight: 700;
cursor: pointer;
}
|
256ece27
Renato De Donato
new controllet
|
31
32
33
34
|
#select_fields_controllet_container #header:hover {
color: #2196F3;
}
|
89558a41
Renato De Donato
datatype, provide...
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#select_fields_controllet_container #menu_container {
position: relative;
height: calc(100% - 48px);
width: 100%;
}
paper-menu {
padding: 0px;
}
paper-item {
cursor: pointer;
color: #000000;
margin: 4px;
|
256ece27
Renato De Donato
new controllet
|
49
50
51
52
53
54
55
56
|
padding: 0px 12px;
}
paper-item span {
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
|
89558a41
Renato De Donato
datatype, provide...
|
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
|
}
paper-item.iron-selected {
background: #2196F3;
color: #FFFFFF;
}
paper-item:focus:before {
opacity: 0 !important;
background: white;
}
paper-item:focus:after {
opacity: 0 !important;
background: white;
}
paper-item:hover:not(.iron-selected) {
background-color: rgba(0, 0, 0, 0.12);
}
</style>
<template>
<paper-material id="select_fields_controllet_container" elevation="5">
<div id="header" on-click="_invertSelection"><span id="fields"></span></div>
<div id="menu_container">
<paper-menu id="menu" multi>
<template is="dom-repeat" items="{{fields}}">
|
256ece27
Renato De Donato
new controllet
|
88
|
<paper-item title="{{item}}"><span>{{item}}</span></paper-item>
|
89558a41
Renato De Donato
datatype, provide...
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
</template>
</paper-menu>
</div>
</paper-material>
</template>
<script>
Polymer({
is : 'select-fields-controllet',
properties : {
fields : {
type : Array,
value : []
|
256ece27
Renato De Donato
new controllet
|
107
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
108
|
|
89558a41
Renato De Donato
datatype, provide...
|
109
110
111
112
113
114
115
116
117
118
119
120
|
},
listeners: {
'iron-activate': '_fireSelectedFields'
},
ready : function() {
$(this.$.menu_container).perfectScrollbar();
},
attached : function() {
this._translate();
|
89558a41
Renato De Donato
datatype, provide...
|
121
122
123
|
},
setFields : function(fields) {
|
256ece27
Renato De Donato
new controllet
|
124
125
126
127
|
var index = fields.indexOf("_id");
if(index > -1)
fields.splice(index, 1);//providers_utility _copy
this.fields = fields.sort();
|
89558a41
Renato De Donato
datatype, provide...
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
},
setSelectFields : function(selectFields) {
for(var i=0; i<selectFields.length; i++)
this.$.menu.select(selectFields[i]);
this._fireSelectedFields();
},
reset: function() {
this.$.menu.selectedValues = [];
this.setFields([]);
},
_translate : function() {
this.$.fields.innerHTML = ln["fields_" + ln["localization"]];
},
|
89558a41
Renato De Donato
datatype, provide...
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
_fireSelectedFields : function() {
this.debounce('_fireSelectedFields', function () {
this.fire('select-fields-controllet_selected-fields', {selectedFields: this.$.menu.selectedValues});
}, 300);
},
_invertSelection : function() {
// for(var i=this.fields.length-1; i>=0; i--)
for(var i=0; i<this.fields.length; i++)
this.$.menu.select(i);
$(this.$.menu_container).animate({ scrollTop: 0}, 0);
this._fireSelectedFields();
}
});
</script>
</dom-module>
|