Version Description
- updated selectize library to v0.13 which fixes issues with name tags containing custom values
- fixed minor php warning
Download this release
Release Info
Developer | netweblogic |
Plugin | Meta Tag Manager |
Version | 2.1.3 |
Comparing to | |
See all releases |
Code changes from version 2.1.2 to 2.1.3
- css/meta-tag-manager.css +251 -184
- css/meta-tag-manager.css.map +1 -0
- css/meta-tag-manager.less +159 -2
- css/meta-tag-manager.min.css +1 -1
- css/selectize/plugins/drag_drop.less +14 -14
- css/selectize/plugins/dropdown_header.less +14 -14
- css/selectize/plugins/optgroup_columns.less +15 -15
- css/selectize/plugins/remove_button.less +41 -35
- css/{selectize.css → selectize/selectize.css} +32 -12
- css/selectize/selectize.css.map +1 -0
- css/selectize/selectize.less +197 -186
- js/selectize.js +788 -518
- js/selectize.min.js +1 -3
- meta-tag-manager-admin.php +20 -3
- meta-tag-manager.php +2 -2
- mtm-builder.php +1 -1
- readme.txt +5 -1
css/meta-tag-manager.css
CHANGED
@@ -1,182 +1,229 @@
|
|
1 |
/* .mtm.postbox { background-color:#dedede;} */
|
2 |
-
.mtm-menu-builder {
|
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 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
.selectize-control.plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {
|
174 |
visibility: visible !important;
|
175 |
background: #f2f2f2 !important;
|
176 |
background: rgba(0, 0, 0, 0.06) !important;
|
177 |
border: 0 none !important;
|
178 |
-
-webkit-box-shadow: inset 0 0 12px 4px #
|
179 |
-
box-shadow: inset 0 0 12px 4px #
|
180 |
}
|
181 |
.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {
|
182 |
content: '!';
|
@@ -188,7 +235,7 @@
|
|
188 |
}
|
189 |
.selectize-dropdown-header {
|
190 |
position: relative;
|
191 |
-
padding: 5px
|
192 |
border-bottom: 1px solid #d0d0d0;
|
193 |
background: #f8f8f8;
|
194 |
-webkit-border-radius: 3px 3px 0 0;
|
@@ -197,7 +244,7 @@
|
|
197 |
}
|
198 |
.selectize-dropdown-header-close {
|
199 |
position: absolute;
|
200 |
-
right:
|
201 |
top: 50%;
|
202 |
color: #303030;
|
203 |
opacity: 0.4;
|
@@ -265,6 +312,12 @@
|
|
265 |
.selectize-control.plugin-remove_button .disabled [data-value] .remove {
|
266 |
border-left-color: #ffffff;
|
267 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
.selectize-control {
|
269 |
position: relative;
|
270 |
}
|
@@ -279,13 +332,13 @@
|
|
279 |
}
|
280 |
.selectize-input,
|
281 |
.selectize-control.single .selectize-input.input-active {
|
282 |
-
background: #
|
283 |
cursor: text;
|
284 |
display: inline-block;
|
285 |
}
|
286 |
.selectize-input {
|
287 |
border: 1px solid #d0d0d0;
|
288 |
-
padding:
|
289 |
display: inline-block;
|
290 |
width: 100%;
|
291 |
overflow: hidden;
|
@@ -301,10 +354,10 @@
|
|
301 |
border-radius: 3px;
|
302 |
}
|
303 |
.selectize-control.multi .selectize-input.has-items {
|
304 |
-
padding:
|
305 |
}
|
306 |
.selectize-input.full {
|
307 |
-
background-color: #
|
308 |
}
|
309 |
.selectize-input.disabled,
|
310 |
.selectize-input.disabled * {
|
@@ -366,6 +419,9 @@
|
|
366 |
.selectize-input > input:focus {
|
367 |
outline: none !important;
|
368 |
}
|
|
|
|
|
|
|
369 |
.selectize-input::after {
|
370 |
content: ' ';
|
371 |
display: block;
|
@@ -385,7 +441,7 @@
|
|
385 |
position: absolute;
|
386 |
z-index: 10;
|
387 |
border: 1px solid #d0d0d0;
|
388 |
-
background: #
|
389 |
margin: -1px 0 0 0;
|
390 |
border-top: 0 none;
|
391 |
-webkit-box-sizing: border-box;
|
@@ -407,16 +463,25 @@
|
|
407 |
-moz-border-radius: 1px;
|
408 |
border-radius: 1px;
|
409 |
}
|
410 |
-
.selectize-dropdown
|
411 |
.selectize-dropdown .optgroup-header {
|
412 |
-
padding: 5px
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
}
|
414 |
.selectize-dropdown .optgroup:first-child .optgroup-header {
|
415 |
border-top: 0 none;
|
416 |
}
|
417 |
.selectize-dropdown .optgroup-header {
|
418 |
color: #303030;
|
419 |
-
background: #
|
420 |
cursor: default;
|
421 |
}
|
422 |
.selectize-dropdown .active {
|
@@ -433,6 +498,7 @@
|
|
433 |
overflow-y: auto;
|
434 |
overflow-x: hidden;
|
435 |
max-height: 200px;
|
|
|
436 |
}
|
437 |
.selectize-control.single .selectize-input,
|
438 |
.selectize-control.single .selectize-input input {
|
@@ -471,4 +537,5 @@
|
|
471 |
opacity: 0.5;
|
472 |
background-color: #fafafa;
|
473 |
}
|
474 |
-
|
|
1 |
/* .mtm.postbox { background-color:#dedede;} */
|
2 |
+
.mtm-menu-builder {
|
3 |
+
margin-bottom: 15px;
|
4 |
+
}
|
5 |
+
.mtm-field-template {
|
6 |
+
display: none;
|
7 |
+
visibility: hidden;
|
8 |
+
}
|
9 |
+
.mtm-field-placeholder {
|
10 |
+
width: 100%;
|
11 |
+
border: 1px dashed #aaa;
|
12 |
+
background-color: #ddd;
|
13 |
+
font-size: 18px;
|
14 |
+
padding: 30px 0px;
|
15 |
+
color: #555;
|
16 |
+
text-align: center;
|
17 |
+
margin: 10px 0px;
|
18 |
+
cursor: pointer;
|
19 |
+
}
|
20 |
+
.no-reference.no-context .mtm-field-placeholder {
|
21 |
+
padding: 20px 0px;
|
22 |
+
}
|
23 |
+
.mtm-field {
|
24 |
+
display: block;
|
25 |
+
clear: both;
|
26 |
+
width: 100%;
|
27 |
+
border: 1px solid #c3c3c3;
|
28 |
+
background-color: #fff;
|
29 |
+
margin: 10px 0px;
|
30 |
+
}
|
31 |
+
.mtm-field.closed .mtm-field-data {
|
32 |
+
display: none;
|
33 |
+
visibility: hidden;
|
34 |
+
}
|
35 |
+
.mtm-field .mtm-field-actions {
|
36 |
+
clear: both;
|
37 |
+
}
|
38 |
+
/* Field Header / Title section */
|
39 |
+
.mtm-field-header {
|
40 |
+
padding: 10px 0px;
|
41 |
+
cursor: pointer;
|
42 |
+
}
|
43 |
+
.mtm-col-sort {
|
44 |
+
display: block;
|
45 |
+
float: left;
|
46 |
+
width: 20px;
|
47 |
+
height: 20px;
|
48 |
+
padding: 10px 0px 0px 10px;
|
49 |
+
margin: 0px;
|
50 |
+
font-size: 20px;
|
51 |
+
align: center;
|
52 |
+
cursor: move;
|
53 |
+
color: #dedede;
|
54 |
+
}
|
55 |
+
.no-reference.no-context .mtm-col-sort {
|
56 |
+
padding: 0px 0px 0px 10px;
|
57 |
+
}
|
58 |
+
/* Display Title for each Card */
|
59 |
+
.mtm-field-title {
|
60 |
+
margin-left: 40px;
|
61 |
+
min-height: 50px;
|
62 |
+
}
|
63 |
+
.no-reference.no-context .mtm-field-title {
|
64 |
+
min-height: 20px;
|
65 |
+
}
|
66 |
+
.mtm-field-title .mtm-meta-reference {
|
67 |
+
font-size: 18px;
|
68 |
+
padding-bottom: 5px;
|
69 |
+
}
|
70 |
+
.mtm-field-title .mtm-meta-reference-value {
|
71 |
+
display: inline-block;
|
72 |
+
}
|
73 |
+
.mtm-field-title .mtm-meta-context {
|
74 |
+
font-size: 12px;
|
75 |
+
padding-bottom: 3px;
|
76 |
+
color: #bcbcbc;
|
77 |
+
font-weight: bold;
|
78 |
+
font-style: italic;
|
79 |
+
}
|
80 |
+
.mtm-field-title .mtm-meta-context .dashicons {
|
81 |
+
font-size: 15px;
|
82 |
+
}
|
83 |
+
.mtm-field-title code {
|
84 |
+
font-weight: bold;
|
85 |
+
}
|
86 |
+
.mtm-field-title code .mtm-meta-type-val,
|
87 |
+
.mtm-field-title code .mtm-meta-content-value {
|
88 |
+
font-style: italic;
|
89 |
+
font-weight: normal;
|
90 |
+
background-color: #fefefe;
|
91 |
+
}
|
92 |
+
.mtm-field-title code .mtm-meta-content.hidden {
|
93 |
+
display: none;
|
94 |
+
}
|
95 |
+
/* Header toggles */
|
96 |
+
.mtm-field-header-toggle:hover,
|
97 |
+
.mtm-field-section-toggle:hover {
|
98 |
+
cursor: pointer;
|
99 |
+
}
|
100 |
+
.mtm-field-header-toggle:before,
|
101 |
+
.mtm-field-section-toggle:before {
|
102 |
+
float: right;
|
103 |
+
width: 32px;
|
104 |
+
height: 32px;
|
105 |
+
content: "\f142";
|
106 |
+
display: inline-block;
|
107 |
+
font: normal 20px/1 dashicons;
|
108 |
+
speak: none;
|
109 |
+
-webkit-font-smoothing: antialiased;
|
110 |
+
-moz-osx-font-smoothing: grayscale;
|
111 |
+
text-decoration: none !important;
|
112 |
+
}
|
113 |
+
.mtm-field.closed .mtm-field-header-toggle:before {
|
114 |
+
content: "\f140";
|
115 |
+
}
|
116 |
+
/* Field form data */
|
117 |
+
.mtm-field-data {
|
118 |
+
/* display: none; */
|
119 |
+
border-top: 1px solid #e5e5e5;
|
120 |
+
padding: 10px 10px 15px;
|
121 |
+
}
|
122 |
+
.mtm-field-input {
|
123 |
+
margin: 0px 0px 15px 0px;
|
124 |
+
clear: both;
|
125 |
+
}
|
126 |
+
.mtm-field-input-label {
|
127 |
+
display: inline-block;
|
128 |
+
margin-bottom: 3px;
|
129 |
+
padding: 2px;
|
130 |
+
font-weight: bold;
|
131 |
+
display: block;
|
132 |
+
}
|
133 |
+
.mtm-field-input-label em {
|
134 |
+
font-style: normal;
|
135 |
+
background: #eaeaea;
|
136 |
+
padding: 1px 2px;
|
137 |
+
}
|
138 |
+
.mtm-field-input input,
|
139 |
+
.mtm-field-input select {
|
140 |
+
width: 100%;
|
141 |
+
padding: 4px;
|
142 |
+
font-size: 13px;
|
143 |
+
/* matches selectize */
|
144 |
+
}
|
145 |
+
.mtm-field-type-custom {
|
146 |
+
clear: both;
|
147 |
+
}
|
148 |
+
.mtm-field-type-custom > div {
|
149 |
+
clear: none;
|
150 |
+
float: left;
|
151 |
+
width: 48%;
|
152 |
+
margin: 10px 1%;
|
153 |
+
}
|
154 |
+
/* Specific type field selectors */
|
155 |
+
.mtm-field-input.mtm-field-type-type {
|
156 |
+
width: 20%;
|
157 |
+
float: left;
|
158 |
+
clear: none;
|
159 |
+
}
|
160 |
+
.mtm-field-input.mtm-field-type-value {
|
161 |
+
width: 79% !important;
|
162 |
+
margin-left: 21%;
|
163 |
+
clear: none;
|
164 |
+
}
|
165 |
+
.mtm-field-input input.mtm-field-input-tag-value {
|
166 |
+
float: left;
|
167 |
+
clear: none;
|
168 |
+
}
|
169 |
+
.mtm-field-section {
|
170 |
+
margin-top: 20px;
|
171 |
+
}
|
172 |
+
.mtm-field-section-header {
|
173 |
+
border-bottom: 1px solid #e3e3e3;
|
174 |
+
padding-bottom: 10px;
|
175 |
+
}
|
176 |
+
.mtm-field-section-title {
|
177 |
+
font-weight: bold;
|
178 |
+
font-size: 15px;
|
179 |
+
}
|
180 |
+
.mtm-field-section-data {
|
181 |
+
margin: 10px 10px 20px;
|
182 |
+
padding-bottom: 10px;
|
183 |
+
border-bottom: 1px solid #e3e3e3;
|
184 |
+
}
|
185 |
+
/*.mtm-builder .selectize-input { padding:4px; }*/
|
186 |
+
.mtm-settings .selectize-dropdown-content .optgroup .option {
|
187 |
+
padding-left: 10px;
|
188 |
+
}
|
189 |
+
.mtm-settings .selectize-dropdown-content .optgroup .optgroup-header {
|
190 |
+
font-weight: bold;
|
191 |
+
}
|
192 |
+
.mtm-settings .selectize-control.multi .selectize-input > div {
|
193 |
+
background: #5cb85c;
|
194 |
+
border-color: #4cae4c;
|
195 |
+
color: #fff;
|
196 |
+
}
|
197 |
+
.mtm-settings .selectize-control.multi .selectize-input > div .remove {
|
198 |
+
border-color: #4cae4c;
|
199 |
+
}
|
200 |
+
.mtm-builder .mtm-field button.mtm-field-remove {
|
201 |
+
background-color: #f4e3e3;
|
202 |
+
border-color: #d8c5c5;
|
203 |
+
color: #565656;
|
204 |
+
}
|
205 |
+
.mtm-builder .mtm-field a.mtm-field-remove {
|
206 |
+
cursor: pointer;
|
207 |
+
color: #d66b6b;
|
208 |
+
}
|
209 |
+
.mtm-builder button .dashicons {
|
210 |
+
padding: 3px 0px;
|
211 |
+
margin-left: -5px;
|
212 |
+
color: #888;
|
213 |
+
}
|
214 |
+
.mtm-builder button.mtm-add-field .dashicons {
|
215 |
+
padding: 4px 0px;
|
216 |
+
}
|
217 |
+
.mtm-builder .mtm-actions {
|
218 |
+
padding-top: 15px;
|
219 |
+
}
|
220 |
.selectize-control.plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {
|
221 |
visibility: visible !important;
|
222 |
background: #f2f2f2 !important;
|
223 |
background: rgba(0, 0, 0, 0.06) !important;
|
224 |
border: 0 none !important;
|
225 |
+
-webkit-box-shadow: inset 0 0 12px 4px #fff;
|
226 |
+
box-shadow: inset 0 0 12px 4px #fff;
|
227 |
}
|
228 |
.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {
|
229 |
content: '!';
|
235 |
}
|
236 |
.selectize-dropdown-header {
|
237 |
position: relative;
|
238 |
+
padding: 5px 8px;
|
239 |
border-bottom: 1px solid #d0d0d0;
|
240 |
background: #f8f8f8;
|
241 |
-webkit-border-radius: 3px 3px 0 0;
|
244 |
}
|
245 |
.selectize-dropdown-header-close {
|
246 |
position: absolute;
|
247 |
+
right: 8px;
|
248 |
top: 50%;
|
249 |
color: #303030;
|
250 |
opacity: 0.4;
|
312 |
.selectize-control.plugin-remove_button .disabled [data-value] .remove {
|
313 |
border-left-color: #ffffff;
|
314 |
}
|
315 |
+
.selectize-control.plugin-remove_button .remove-single {
|
316 |
+
position: absolute;
|
317 |
+
right: 0;
|
318 |
+
top: 0;
|
319 |
+
font-size: 23px;
|
320 |
+
}
|
321 |
.selectize-control {
|
322 |
position: relative;
|
323 |
}
|
332 |
}
|
333 |
.selectize-input,
|
334 |
.selectize-control.single .selectize-input.input-active {
|
335 |
+
background: #fff;
|
336 |
cursor: text;
|
337 |
display: inline-block;
|
338 |
}
|
339 |
.selectize-input {
|
340 |
border: 1px solid #d0d0d0;
|
341 |
+
padding: 8px 8px;
|
342 |
display: inline-block;
|
343 |
width: 100%;
|
344 |
overflow: hidden;
|
354 |
border-radius: 3px;
|
355 |
}
|
356 |
.selectize-control.multi .selectize-input.has-items {
|
357 |
+
padding: 6px 8px 3px;
|
358 |
}
|
359 |
.selectize-input.full {
|
360 |
+
background-color: #fff;
|
361 |
}
|
362 |
.selectize-input.disabled,
|
363 |
.selectize-input.disabled * {
|
419 |
.selectize-input > input:focus {
|
420 |
outline: none !important;
|
421 |
}
|
422 |
+
.selectize-input > input[placeholder] {
|
423 |
+
box-sizing: initial;
|
424 |
+
}
|
425 |
.selectize-input::after {
|
426 |
content: ' ';
|
427 |
display: block;
|
441 |
position: absolute;
|
442 |
z-index: 10;
|
443 |
border: 1px solid #d0d0d0;
|
444 |
+
background: #fff;
|
445 |
margin: -1px 0 0 0;
|
446 |
border-top: 0 none;
|
447 |
-webkit-box-sizing: border-box;
|
463 |
-moz-border-radius: 1px;
|
464 |
border-radius: 1px;
|
465 |
}
|
466 |
+
.selectize-dropdown .option,
|
467 |
.selectize-dropdown .optgroup-header {
|
468 |
+
padding: 5px 8px;
|
469 |
+
}
|
470 |
+
.selectize-dropdown .option,
|
471 |
+
.selectize-dropdown [data-disabled],
|
472 |
+
.selectize-dropdown [data-disabled] [data-selectable].option {
|
473 |
+
cursor: inherit;
|
474 |
+
opacity: 0.5;
|
475 |
+
}
|
476 |
+
.selectize-dropdown [data-selectable].option {
|
477 |
+
opacity: 1;
|
478 |
}
|
479 |
.selectize-dropdown .optgroup:first-child .optgroup-header {
|
480 |
border-top: 0 none;
|
481 |
}
|
482 |
.selectize-dropdown .optgroup-header {
|
483 |
color: #303030;
|
484 |
+
background: #fff;
|
485 |
cursor: default;
|
486 |
}
|
487 |
.selectize-dropdown .active {
|
498 |
overflow-y: auto;
|
499 |
overflow-x: hidden;
|
500 |
max-height: 200px;
|
501 |
+
-webkit-overflow-scrolling: touch;
|
502 |
}
|
503 |
.selectize-control.single .selectize-input,
|
504 |
.selectize-control.single .selectize-input input {
|
537 |
opacity: 0.5;
|
538 |
background-color: #fafafa;
|
539 |
}
|
540 |
+
/*# sourceMappingURL=selectize.css.map */
|
541 |
+
/*# sourceMappingURL=meta-tag-manager.css.map */
|
css/meta-tag-manager.css.map
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
{"version":3,"sources":["meta-tag-manager.less","selectize/selectize.css"],"names":[],"mappings":";AACA;EAAoB,mBAAA;;AAGpB;EAAsB,aAAA;EAAc,kBAAA;;AAGpC;EACE,WAAA;EACA,uBAAA;EACA,sBAAA;EACA,eAAA;EACA,iBAAA;EACA,WAAA;EACA,kBAAA;EACA,gBAAA;EACA,eAAA;;AAEF,aAAa,WAAY;EAAyB,iBAAA;;AAElD;EACE,cAAA;EACA,WAAA;EACA,WAAA;EACA,yBAAA;EACA,sBAAA;EACA,gBAAA;;AAEF,UAAU,OAAQ;EAAkB,aAAA;EAAc,kBAAA;;AAElD,UAAW;EAAqB,WAAA;;;AAGhC;EACE,iBAAA;EACA,eAAA;;AAEF;EACE,cAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,0BAAA;EACA,WAAA;EACA,eAAA;EACA,aAAA;EACA,YAAA;EACA,cAAA;;AAEF,aAAa,WAAY;EAAgB,yBAAA;;;AAGzC;EAAmB,iBAAA;EAAkB,gBAAA;;AACrC,aAAa,WAAY;EAAmB,gBAAA;;AAC5C,gBAAiB;EAAsB,eAAA;EAAiB,mBAAA;;AACxD,gBAAiB;EAA4B,qBAAA;;AAE7C,gBAAiB;EACf,eAAA;EACA,mBAAA;EACA,cAAA;EACA,iBAAA;EACA,kBAAA;;AAEF,gBAAiB,kBAAkB;EAAa,eAAA;;AAEhD,gBAAiB;EAAO,iBAAA;;AACxB,gBAAiB,KAAK;AAAoB,gBAAiB,KAAK;EAC9D,kBAAA;EACA,mBAAA;EACA,yBAAA;;AAEF,gBAAiB,KAAK,kBAAiB;EAAU,aAAA;;;AAGjD,wBAAwB;AACxB,yBAAyB;EACvB,eAAA;;AAEF,wBAAwB;AACxB,yBAAyB;EACvB,YAAA;EACA,WAAA;EACA,YAAA;EACA,SAAS,OAAT;EACA,qBAAA;EACA,6BAAA;EACA,WAAA;EACA,mCAAA;EACA,kCAAA;EACA,gCAAA;;AAEF,UAAU,OAAQ,yBAAwB;EACxC,SAAS,OAAT;;;AAIF;;EAEE,6BAAA;EACA,uBAAA;;AAEF;EAAmB,wBAAA;EAAyB,WAAA;;AAC5C;EACE,qBAAA;EACA,kBAAA;EACA,YAAA;EACA,iBAAA;EACA,cAAA;;AAEF,sBAAuB;EAAK,kBAAA;EAAmB,mBAAA;EAAoB,gBAAA;;AACnE,gBAAiB;AAAO,gBAAiB;EACvC,WAAA;EACA,YAAA;EACA,eAAA;;;AAGF;EAAyB,WAAA;;AACzB,sBAAuB;EACrB,WAAA;EACA,WAAA;EACA,UAAA;EACA,eAAA;;;AAIF,gBAAgB;EACd,UAAA;EACA,WAAA;EACA,WAAA;;AAEF,gBAAgB;EACd,qBAAA;EACA,gBAAA;EACA,WAAA;;AAEF,gBAAiB,MAAK;EAA6B,WAAA;EAAY,WAAA;;AAI/D;EAAqB,gBAAA;;AACrB;EAA4B,gCAAA;EAAiC,oBAAA;;AAC7D;EAA2B,iBAAA;EAAkB,eAAA;;AAC7C;EAA0B,sBAAA;EAAuB,oBAAA;EAAqB,gCAAA;;;AAGtE,aAAc,4BAA4B,UAAU;EAAU,kBAAA;;AAC9D,aAAc,4BAA4B,UAAU;EAAmB,iBAAA;;AACvE,aAAc,mBAAkB,MAAO,iBAAiB;EAAQ,mBAAA;EAAoB,qBAAA;EAAsB,WAAA;;AAC1G,aAAc,mBAAkB,MAAO,iBAAiB,MAAM;EAAU,qBAAA;;AAExE,YAAa,WAAW,OAAM;EAAoB,yBAAA;EAA0B,qBAAA;EAAsB,cAAA;;AAClG,YAAa,WAAW,EAAC;EAAoB,eAAA;EAAgB,cAAA;;AAC7D,YAAa,OAAO;EAAa,gBAAA;EAAkB,iBAAA;EAAmB,WAAA;;AACtE,YAAa,OAAM,cAAe;EAAa,gBAAA;;AAE/C,YAAa;EAAe,iBAAA;;AC5J5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"meta-tag-manager.css"}
|
css/meta-tag-manager.less
CHANGED
@@ -1,2 +1,159 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* .mtm.postbox { background-color:#dedede;} */
|
2 |
+
.mtm-menu-builder { margin-bottom:15px; }
|
3 |
+
.mtm-builder {}
|
4 |
+
|
5 |
+
.mtm-field-template { display:none; visibility:hidden; }
|
6 |
+
.mtm-fields {}
|
7 |
+
|
8 |
+
.mtm-field-placeholder {
|
9 |
+
width:100%;
|
10 |
+
border:1px dashed #aaa;
|
11 |
+
background-color: #ddd;
|
12 |
+
font-size:18px;
|
13 |
+
padding:30px 0px;
|
14 |
+
color:#555;
|
15 |
+
text-align:center;
|
16 |
+
margin:10px 0px;
|
17 |
+
cursor:pointer;
|
18 |
+
}
|
19 |
+
.no-reference.no-context .mtm-field-placeholder { padding:20px 0px; }
|
20 |
+
|
21 |
+
.mtm-field {
|
22 |
+
display:block;
|
23 |
+
clear:both;
|
24 |
+
width:100%;
|
25 |
+
border: 1px solid #c3c3c3;
|
26 |
+
background-color: #fff;
|
27 |
+
margin:10px 0px;
|
28 |
+
}
|
29 |
+
.mtm-field.closed .mtm-field-data { display:none; visibility:hidden; }
|
30 |
+
|
31 |
+
.mtm-field .mtm-field-actions { clear:both; }
|
32 |
+
|
33 |
+
/* Field Header / Title section */
|
34 |
+
.mtm-field-header {
|
35 |
+
padding: 10px 0px;
|
36 |
+
cursor:pointer;
|
37 |
+
}
|
38 |
+
.mtm-col-sort {
|
39 |
+
display:block;
|
40 |
+
float:left;
|
41 |
+
width:20px;
|
42 |
+
height:20px;
|
43 |
+
padding:10px 0px 0px 10px;
|
44 |
+
margin:0px;
|
45 |
+
font-size:20px;
|
46 |
+
align:center;
|
47 |
+
cursor:move;
|
48 |
+
color:#dedede
|
49 |
+
}
|
50 |
+
.no-reference.no-context .mtm-col-sort { padding:0px 0px 0px 10px;}
|
51 |
+
|
52 |
+
/* Display Title for each Card */
|
53 |
+
.mtm-field-title { margin-left:40px; min-height:50px;}
|
54 |
+
.no-reference.no-context .mtm-field-title { min-height:20px; }
|
55 |
+
.mtm-field-title .mtm-meta-reference { font-size: 18px; padding-bottom:5px; }
|
56 |
+
.mtm-field-title .mtm-meta-reference-value { display: inline-block; }
|
57 |
+
|
58 |
+
.mtm-field-title .mtm-meta-context {
|
59 |
+
font-size:12px;
|
60 |
+
padding-bottom:3px;
|
61 |
+
color:#bcbcbc;
|
62 |
+
font-weight:bold;
|
63 |
+
font-style:italic;
|
64 |
+
}
|
65 |
+
.mtm-field-title .mtm-meta-context .dashicons { font-size:15px; }
|
66 |
+
|
67 |
+
.mtm-field-title code { font-weight:bold; }
|
68 |
+
.mtm-field-title code .mtm-meta-type-val, .mtm-field-title code .mtm-meta-content-value {
|
69 |
+
font-style:italic;
|
70 |
+
font-weight:normal;
|
71 |
+
background-color:#fefefe;
|
72 |
+
}
|
73 |
+
.mtm-field-title code .mtm-meta-content.hidden { display:none; }
|
74 |
+
|
75 |
+
/* Header toggles */
|
76 |
+
.mtm-field-header-toggle:hover,
|
77 |
+
.mtm-field-section-toggle:hover {
|
78 |
+
cursor:pointer;
|
79 |
+
}
|
80 |
+
.mtm-field-header-toggle:before,
|
81 |
+
.mtm-field-section-toggle:before {
|
82 |
+
float:right;
|
83 |
+
width: 32px;
|
84 |
+
height: 32px;
|
85 |
+
content: "\f142";
|
86 |
+
display: inline-block;
|
87 |
+
font: normal 20px/1 dashicons;
|
88 |
+
speak: none;
|
89 |
+
-webkit-font-smoothing: antialiased;
|
90 |
+
-moz-osx-font-smoothing: grayscale;
|
91 |
+
text-decoration: none !important;
|
92 |
+
}
|
93 |
+
.mtm-field.closed .mtm-field-header-toggle:before {
|
94 |
+
content: "\f140";
|
95 |
+
}
|
96 |
+
|
97 |
+
/* Field form data */
|
98 |
+
.mtm-field-data {
|
99 |
+
/* display: none; */
|
100 |
+
border-top: 1px solid #e5e5e5;
|
101 |
+
padding:10px 10px 15px;
|
102 |
+
}
|
103 |
+
.mtm-field-input { margin:0px 0px 15px 0px; clear:both; }
|
104 |
+
.mtm-field-input-label {
|
105 |
+
display:inline-block;
|
106 |
+
margin-bottom:3px;
|
107 |
+
padding:2px;
|
108 |
+
font-weight:bold;
|
109 |
+
display:block;
|
110 |
+
}
|
111 |
+
.mtm-field-input-label em { font-style:normal; background:#eaeaea; padding:1px 2px; }
|
112 |
+
.mtm-field-input input, .mtm-field-input select {
|
113 |
+
width:100%;
|
114 |
+
padding:4px;
|
115 |
+
font-size:13px; /* matches selectize */
|
116 |
+
}
|
117 |
+
|
118 |
+
.mtm-field-type-custom { clear:both; }
|
119 |
+
.mtm-field-type-custom > div {
|
120 |
+
clear:none;
|
121 |
+
float:left;
|
122 |
+
width:48%;
|
123 |
+
margin:10px 1%;
|
124 |
+
}
|
125 |
+
|
126 |
+
/* Specific type field selectors */
|
127 |
+
.mtm-field-input.mtm-field-type-type {
|
128 |
+
width:20%;
|
129 |
+
float:left;
|
130 |
+
clear:none;
|
131 |
+
}
|
132 |
+
.mtm-field-input.mtm-field-type-value {
|
133 |
+
width:79% !important;
|
134 |
+
margin-left: 21%;
|
135 |
+
clear:none;
|
136 |
+
}
|
137 |
+
.mtm-field-input input.mtm-field-input-tag-value { float:left; clear:none; }
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
.mtm-field-section { margin-top:20px; }
|
142 |
+
.mtm-field-section-header { border-bottom:1px solid #e3e3e3; padding-bottom:10px; }
|
143 |
+
.mtm-field-section-title { font-weight:bold; font-size:15px; }
|
144 |
+
.mtm-field-section-data { margin:10px 10px 20px; padding-bottom:10px; border-bottom:1px solid #e3e3e3; }
|
145 |
+
|
146 |
+
/*.mtm-builder .selectize-input { padding:4px; }*/
|
147 |
+
.mtm-settings .selectize-dropdown-content .optgroup .option { padding-left:10px; }
|
148 |
+
.mtm-settings .selectize-dropdown-content .optgroup .optgroup-header { font-weight:bold; }
|
149 |
+
.mtm-settings .selectize-control.multi .selectize-input > div { background:#5cb85c; border-color:#4cae4c; color:#fff; }
|
150 |
+
.mtm-settings .selectize-control.multi .selectize-input > div .remove { border-color:#4cae4c; }
|
151 |
+
|
152 |
+
.mtm-builder .mtm-field button.mtm-field-remove { background-color:#f4e3e3; border-color:#d8c5c5; color:#565656; }
|
153 |
+
.mtm-builder .mtm-field a.mtm-field-remove { cursor:pointer; color:#d66b6b; }
|
154 |
+
.mtm-builder button .dashicons { padding: 3px 0px; margin-left: -5px; color: #888; }
|
155 |
+
.mtm-builder button.mtm-add-field .dashicons { padding: 4px 0px; }
|
156 |
+
|
157 |
+
.mtm-builder .mtm-actions { padding-top:15px; }
|
158 |
+
|
159 |
+
@import (inline) "selectize/selectize.css";
|
css/meta-tag-manager.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.mtm-menu-builder{margin-bottom:15px}.mtm-field-template{display:none;visibility:hidden}.mtm-field-placeholder{width:100%;border:1px dashed #aaa;background-color:#ddd;font-size:18px;padding:30px 0;color:#555;text-align:center;margin:10px 0;cursor:pointer}.no-reference.no-context .mtm-field-placeholder{padding:20px 0}.mtm-field{display:block;clear:both;width:100%;border:1px solid #c3c3c3;background-color:#fff;margin:10px 0}.mtm-field.closed .mtm-field-data{display:none;visibility:hidden}.mtm-field .mtm-field-actions{clear:both}.mtm-field-header{padding:10px 0;cursor:pointer}.mtm-col-sort{display:block;float:left;width:20px;height:20px;padding:10px 0 0 10px;margin:0;font-size:20px;align:center;cursor:move;color:#dedede}.no-reference.no-context .mtm-col-sort{padding:0 0 0 10px}.mtm-field-title{margin-left:40px;min-height:50px}.no-reference.no-context .mtm-field-title{min-height:20px}.mtm-field-title .mtm-meta-reference{font-size:18px;padding-bottom:5px}.mtm-field-title .mtm-meta-reference-value{display:inline-block}.mtm-field-title .mtm-meta-context{font-size:12px;padding-bottom:3px;color:#bcbcbc;font-weight:700;font-style:italic}.mtm-field-title .mtm-meta-context .dashicons{font-size:15px}.mtm-field-title code{font-weight:700}.mtm-field-title code .mtm-meta-content-value,.mtm-field-title code .mtm-meta-type-val{font-style:italic;font-weight:400;background-color:#fefefe}.mtm-field-title code .mtm-meta-content.hidden{display:none}.mtm-field-header-toggle:hover,.mtm-field-section-toggle:hover{cursor:pointer}.mtm-field-header-toggle:before,.mtm-field-section-toggle:before{float:right;width:32px;height:32px;content:"\f142";display:inline-block;font:400 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.mtm-field.closed .mtm-field-header-toggle:before{content:"\f140"}.mtm-field-data{border-top:1px solid #e5e5e5;padding:10px 10px 15px}.mtm-field-input{margin:0 0 15px;clear:both}.mtm-field-input-label{margin-bottom:3px;padding:2px;font-weight:700;display:block}.mtm-field-input-label em{font-style:normal;background:#eaeaea;padding:1px 2px}.mtm-field-input input,.mtm-field-input select{width:100%;padding:4px;font-size:13px}.mtm-field-type-custom{clear:both}.mtm-field-type-custom>div{clear:none;float:left;width:48%;margin:10px 1%}.mtm-field-input.mtm-field-type-type{width:20%;float:left;clear:none}.mtm-field-input.mtm-field-type-value{width:79%!important;margin-left:21%;clear:none}.mtm-field-input input.mtm-field-input-tag-value{float:left;clear:none}.mtm-field-section{margin-top:20px}.mtm-field-section-header{border-bottom:1px solid #e3e3e3;padding-bottom:10px}.mtm-field-section-title{font-weight:700;font-size:15px}.mtm-field-section-data{margin:10px 10px 20px;padding-bottom:10px;border-bottom:1px solid #e3e3e3}.mtm-settings .selectize-dropdown-content .optgroup .option{padding-left:10px}.mtm-settings .selectize-dropdown-content .optgroup .optgroup-header{font-weight:700}.mtm-settings .selectize-control.multi .selectize-input>div{background:#5cb85c;border-color:#4cae4c;color:#fff}.mtm-settings .selectize-control.multi .selectize-input>div .remove{border-color:#4cae4c}.mtm-builder .mtm-field button.mtm-field-remove{background-color:#f4e3e3;border-color:#d8c5c5;color:#565656}.mtm-builder .mtm-field a.mtm-field-remove{cursor:pointer;color:#d66b6b}.mtm-builder button .dashicons{padding:3px 0;margin-left:-5px;color:#888}.mtm-builder button.mtm-add-field .dashicons{padding:4px 0}.mtm-builder .mtm-actions{padding-top:15px}.selectize-control.plugin-drag_drop.multi>.selectize-input>div.ui-sortable-placeholder{visibility:visible!important;background:#f2f2f2!important;background:rgba(0,0,0,.06)!important;border:0!important;-webkit-box-shadow:inset 0 0 12px 4px #fff;box-shadow:inset 0 0 12px 4px #fff}.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after{content:'!';visibility:hidden}.selectize-control.plugin-drag_drop .ui-sortable-helper{-webkit-box-shadow:0 2px 5px rgba(0,0,0,.2);box-shadow:0 2px 5px rgba(0,0,0,.2)}.selectize-dropdown-header{position:relative;padding:5px 4px;border-bottom:1px solid #d0d0d0;background:#f8f8f8;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.selectize-dropdown-header-close{position:absolute;right:4px;top:50%;color:#303030;opacity:.4;margin-top:-12px;line-height:20px;font-size:20px!important}.selectize-dropdown-header-close:hover{color:#000}.selectize-dropdown.plugin-optgroup_columns .optgroup{border-right:1px solid #f2f2f2;border-top:0 none;float:left;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child{border-right:0 none}.selectize-dropdown.plugin-optgroup_columns .optgroup:before{display:none}.selectize-dropdown.plugin-optgroup_columns .optgroup-header{border-top:0 none}.selectize-control.plugin-remove_button [data-value]{position:relative;padding-right:24px!important}.selectize-control.plugin-remove_button [data-value] .remove{z-index:1;position:absolute;top:0;right:0;bottom:0;width:17px;text-align:center;font-weight:700;font-size:12px;color:inherit;text-decoration:none;vertical-align:middle;display:inline-block;padding:2px 0 0;border-left:1px solid #d0d0d0;-webkit-border-radius:0 2px 2px 0;-moz-border-radius:0 2px 2px 0;border-radius:0 2px 2px 0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.selectize-control.plugin-remove_button [data-value] .remove:hover{background:rgba(0,0,0,.05)}.selectize-control.plugin-remove_button [data-value].active .remove{border-left-color:#cacaca}.selectize-control.plugin-remove_button .disabled [data-value] .remove:hover{background:0 0}.selectize-control.plugin-remove_button .disabled [data-value] .remove{border-left-color:#fff}.selectize-control{position:relative}.selectize-dropdown,.selectize-input,.selectize-input input{color:#303030;font-family:inherit;font-size:13px;line-height:18px;-webkit-font-smoothing:inherit}.selectize-control.single .selectize-input.input-active,.selectize-input{background:#fff;display:inline-block}.selectize-input{border:1px solid #d0d0d0;padding:4px;display:inline-block;width:100%;overflow:hidden;position:relative;z-index:1;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.1);box-shadow:inset 0 1px 1px rgba(0,0,0,.1);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.selectize-control.multi .selectize-input.has-items{padding:2px 4px -1px}.selectize-input.full{background-color:#fff}.selectize-input.disabled,.selectize-input.disabled *{cursor:default!important}.selectize-input.focus{-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.15);box-shadow:inset 0 1px 2px rgba(0,0,0,.15)}.selectize-input.dropdown-active{-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.selectize-input>*{vertical-align:baseline;display:-moz-inline-stack;display:inline-block;zoom:1;*display:inline}.selectize-control.multi .selectize-input>div{cursor:pointer;margin:0 3px 3px 0;padding:2px 6px;background:#f2f2f2;color:#303030;border:0 solid #d0d0d0}.selectize-control.multi .selectize-input>div.active{background:#e8e8e8;color:#303030;border:0 solid #cacaca}.selectize-control.multi .selectize-input.disabled>div,.selectize-control.multi .selectize-input.disabled>div.active{color:#7d7d7d;background:#fff;border:0 solid #fff}.selectize-input>input{display:inline-block!important;padding:0!important;min-height:0!important;max-height:none!important;max-width:100%!important;margin:0 2px 0 0!important;text-indent:0!important;border:0!important;background:0 0!important;line-height:inherit!important;-webkit-user-select:auto!important;-webkit-box-shadow:none!important;box-shadow:none!important}.selectize-input>input::-ms-clear{display:none}.selectize-input>input:focus{outline:0!important}.selectize-input::after{content:' ';display:block;clear:left}.selectize-input.dropdown-active::before{content:' ';display:block;position:absolute;background:#f0f0f0;height:1px;bottom:0;left:0;right:0}.selectize-dropdown{position:absolute;z-index:10;border:1px solid #d0d0d0;background:#fff;margin:-1px 0 0;border-top:0 none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0 1px 3px rgba(0,0,0,.1);box-shadow:0 1px 3px rgba(0,0,0,.1);-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px}.selectize-dropdown [data-selectable]{cursor:pointer;overflow:hidden}.selectize-dropdown [data-selectable] .highlight{background:rgba(125,168,208,.2);-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px}.selectize-dropdown .optgroup-header,.selectize-dropdown [data-selectable]{padding:5px 4px}.selectize-dropdown .optgroup:first-child .optgroup-header{border-top:0 none}.selectize-dropdown .optgroup-header{color:#303030;background:#fff;cursor:default}.selectize-dropdown .active{background-color:#f5fafd;color:#495c68}.selectize-dropdown .active.create{color:#495c68}.selectize-dropdown .create{color:rgba(48,48,48,.5)}.selectize-dropdown-content{overflow-y:auto;overflow-x:hidden;max-height:200px}.selectize-control.single .selectize-input,.selectize-control.single .selectize-input input{cursor:pointer}.selectize-control.single .selectize-input.input-active,.selectize-control.single .selectize-input.input-active input{cursor:text}.selectize-control.single .selectize-input:after{content:' ';display:block;position:absolute;top:50%;right:15px;margin-top:-3px;width:0;height:0;border-style:solid;border-width:5px 5px 0;border-color:grey transparent transparent}.selectize-control.single .selectize-input.dropdown-active:after{margin-top:-4px;border-width:0 5px 5px;border-color:transparent transparent grey}.selectize-control.rtl.single .selectize-input:after{left:15px;right:auto}.selectize-control.rtl .selectize-input>input{margin:0 4px 0 -2px!important}.selectize-control .selectize-input.disabled{opacity:.5;background-color:#fafafa}
|
1 |
+
.mtm-menu-builder{margin-bottom:15px}.mtm-field-template{display:none;visibility:hidden}.mtm-field-placeholder{width:100%;border:1px dashed #aaa;background-color:#ddd;font-size:18px;padding:30px 0;color:#555;text-align:center;margin:10px 0;cursor:pointer}.no-reference.no-context .mtm-field-placeholder{padding:20px 0}.mtm-field{display:block;clear:both;width:100%;border:1px solid #c3c3c3;background-color:#fff;margin:10px 0}.mtm-field.closed .mtm-field-data{display:none;visibility:hidden}.mtm-field .mtm-field-actions{clear:both}.mtm-field-header{padding:10px 0;cursor:pointer}.mtm-col-sort{display:block;float:left;width:20px;height:20px;padding:10px 0 0 10px;margin:0;font-size:20px;align:center;cursor:move;color:#dedede}.no-reference.no-context .mtm-col-sort{padding:0 0 0 10px}.mtm-field-title{margin-left:40px;min-height:50px}.no-reference.no-context .mtm-field-title{min-height:20px}.mtm-field-title .mtm-meta-reference{font-size:18px;padding-bottom:5px}.mtm-field-title .mtm-meta-reference-value{display:inline-block}.mtm-field-title .mtm-meta-context{font-size:12px;padding-bottom:3px;color:#bcbcbc;font-weight:700;font-style:italic}.mtm-field-title .mtm-meta-context .dashicons{font-size:15px}.mtm-field-title code{font-weight:700}.mtm-field-title code .mtm-meta-content-value,.mtm-field-title code .mtm-meta-type-val{font-style:italic;font-weight:400;background-color:#fefefe}.mtm-field-title code .mtm-meta-content.hidden{display:none}.mtm-field-header-toggle:hover,.mtm-field-section-toggle:hover{cursor:pointer}.mtm-field-header-toggle:before,.mtm-field-section-toggle:before{float:right;width:32px;height:32px;content:"\f142";display:inline-block;font:20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.mtm-field.closed .mtm-field-header-toggle:before{content:"\f140"}.mtm-field-data{border-top:1px solid #e5e5e5;padding:10px 10px 15px}.mtm-field-input{margin:0 0 15px;clear:both}.mtm-field-input-label{margin-bottom:3px;padding:2px;font-weight:700;display:block}.mtm-field-input-label em{font-style:normal;background:#eaeaea;padding:1px 2px}.mtm-field-input input,.mtm-field-input select{width:100%;padding:4px;font-size:13px}.mtm-field-type-custom{clear:both}.mtm-field-type-custom>div{clear:none;float:left;width:48%;margin:10px 1%}.mtm-field-input.mtm-field-type-type{width:20%;float:left;clear:none}.mtm-field-input.mtm-field-type-value{width:79%!important;margin-left:21%;clear:none}.mtm-field-input input.mtm-field-input-tag-value{float:left;clear:none}.mtm-field-section{margin-top:20px}.mtm-field-section-header{border-bottom:1px solid #e3e3e3;padding-bottom:10px}.mtm-field-section-title{font-weight:700;font-size:15px}.mtm-field-section-data{margin:10px 10px 20px;padding-bottom:10px;border-bottom:1px solid #e3e3e3}.mtm-settings .selectize-dropdown-content .optgroup .option{padding-left:10px}.mtm-settings .selectize-dropdown-content .optgroup .optgroup-header{font-weight:700}.mtm-settings .selectize-control.multi .selectize-input>div{background:#5cb85c;border-color:#4cae4c;color:#fff}.mtm-settings .selectize-control.multi .selectize-input>div .remove{border-color:#4cae4c}.mtm-builder .mtm-field button.mtm-field-remove{background-color:#f4e3e3;border-color:#d8c5c5;color:#565656}.mtm-builder .mtm-field a.mtm-field-remove{cursor:pointer;color:#d66b6b}.mtm-builder button .dashicons{padding:3px 0;margin-left:-5px;color:#888}.mtm-builder button.mtm-add-field .dashicons{padding:4px 0}.mtm-builder .mtm-actions{padding-top:15px}.selectize-control.plugin-drag_drop.multi>.selectize-input>div.ui-sortable-placeholder{visibility:visible!important;background:#f2f2f2!important;background:rgba(0,0,0,.06)!important;border:0!important;-webkit-box-shadow:inset 0 0 12px 4px #fff;box-shadow:inset 0 0 12px 4px #fff}.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after{content:'!';visibility:hidden}.selectize-control.plugin-drag_drop .ui-sortable-helper{-webkit-box-shadow:0 2px 5px rgba(0,0,0,.2);box-shadow:0 2px 5px rgba(0,0,0,.2)}.selectize-dropdown-header{position:relative;padding:5px 8px;border-bottom:1px solid #d0d0d0;background:#f8f8f8;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.selectize-dropdown-header-close{position:absolute;right:8px;top:50%;color:#303030;opacity:.4;margin-top:-12px;line-height:20px;font-size:20px!important}.selectize-dropdown-header-close:hover{color:#000}.selectize-dropdown.plugin-optgroup_columns .optgroup{border-right:1px solid #f2f2f2;border-top:0 none;float:left;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child{border-right:0 none}.selectize-dropdown.plugin-optgroup_columns .optgroup:before{display:none}.selectize-dropdown.plugin-optgroup_columns .optgroup-header{border-top:0 none}.selectize-control.plugin-remove_button [data-value]{position:relative;padding-right:24px!important}.selectize-control.plugin-remove_button [data-value] .remove{z-index:1;position:absolute;top:0;right:0;bottom:0;width:17px;text-align:center;font-weight:700;font-size:12px;color:inherit;text-decoration:none;vertical-align:middle;display:inline-block;padding:2px 0 0;border-left:1px solid #d0d0d0;-webkit-border-radius:0 2px 2px 0;-moz-border-radius:0 2px 2px 0;border-radius:0 2px 2px 0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.selectize-control.plugin-remove_button [data-value] .remove:hover{background:rgba(0,0,0,.05)}.selectize-control.plugin-remove_button [data-value].active .remove{border-left-color:#cacaca}.selectize-control.plugin-remove_button .disabled [data-value] .remove:hover{background:0 0}.selectize-control.plugin-remove_button .disabled [data-value] .remove{border-left-color:#fff}.selectize-control.plugin-remove_button .remove-single{position:absolute;right:0;top:0;font-size:23px}.selectize-control{position:relative}.selectize-dropdown,.selectize-input,.selectize-input input{color:#303030;font-family:inherit;font-size:13px;line-height:18px;-webkit-font-smoothing:inherit}.selectize-input{cursor:text;border:1px solid #d0d0d0;padding:8px;width:100%;overflow:hidden;position:relative;z-index:1;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.1);box-shadow:inset 0 1px 1px rgba(0,0,0,.1);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.selectize-control.single .selectize-input.input-active,.selectize-input{background:#fff;display:inline-block}.selectize-control.multi .selectize-input.has-items{padding:6px 8px 3px}.selectize-input.full{background-color:#fff}.selectize-input.disabled,.selectize-input.disabled *{cursor:default!important}.selectize-input.focus{-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.15);box-shadow:inset 0 1px 2px rgba(0,0,0,.15)}.selectize-input.dropdown-active{-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.selectize-input>*{vertical-align:baseline;display:-moz-inline-stack;display:inline-block;zoom:1;*display:inline}.selectize-control.multi .selectize-input>div{cursor:pointer;margin:0 3px 3px 0;padding:2px 6px;background:#f2f2f2;color:#303030;border:0 solid #d0d0d0}.selectize-control.multi .selectize-input>div.active{background:#e8e8e8;color:#303030;border:0 solid #cacaca}.selectize-control.multi .selectize-input.disabled>div,.selectize-control.multi .selectize-input.disabled>div.active{color:#7d7d7d;background:#fff;border:0 solid #fff}.selectize-input>input{display:inline-block!important;padding:0!important;min-height:0!important;max-height:none!important;max-width:100%!important;margin:0 2px 0 0!important;text-indent:0!important;border:0!important;background:0 0!important;line-height:inherit!important;-webkit-user-select:auto!important;-webkit-box-shadow:none!important;box-shadow:none!important}.selectize-input>input::-ms-clear{display:none}.selectize-input>input:focus{outline:0!important}.selectize-input>input[placeholder]{box-sizing:initial}.selectize-input::after{content:' ';display:block;clear:left}.selectize-input.dropdown-active::before{content:' ';display:block;position:absolute;background:#f0f0f0;height:1px;bottom:0;left:0;right:0}.selectize-dropdown{position:absolute;z-index:10;border:1px solid #d0d0d0;background:#fff;margin:-1px 0 0;border-top:0 none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0 1px 3px rgba(0,0,0,.1);box-shadow:0 1px 3px rgba(0,0,0,.1);-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px}.selectize-dropdown [data-selectable]{cursor:pointer;overflow:hidden}.selectize-dropdown [data-selectable] .highlight{background:rgba(125,168,208,.2);-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px}.selectize-dropdown .optgroup-header,.selectize-dropdown .option{padding:5px 8px}.selectize-dropdown .option,.selectize-dropdown [data-disabled],.selectize-dropdown [data-disabled] [data-selectable].option{cursor:inherit;opacity:.5}.selectize-dropdown [data-selectable].option{opacity:1}.selectize-dropdown .optgroup:first-child .optgroup-header{border-top:0 none}.selectize-dropdown .optgroup-header{color:#303030;background:#fff;cursor:default}.selectize-dropdown .active{background-color:#f5fafd;color:#495c68}.selectize-dropdown .active.create{color:#495c68}.selectize-dropdown .create{color:rgba(48,48,48,.5)}.selectize-dropdown-content{overflow-y:auto;overflow-x:hidden;max-height:200px;-webkit-overflow-scrolling:touch}.selectize-control.single .selectize-input,.selectize-control.single .selectize-input input{cursor:pointer}.selectize-control.single .selectize-input.input-active,.selectize-control.single .selectize-input.input-active input{cursor:text}.selectize-control.single .selectize-input:after{content:' ';display:block;position:absolute;top:50%;right:15px;margin-top:-3px;width:0;height:0;border-style:solid;border-width:5px 5px 0;border-color:gray transparent transparent}.selectize-control.single .selectize-input.dropdown-active:after{margin-top:-4px;border-width:0 5px 5px;border-color:transparent transparent gray}.selectize-control.rtl.single .selectize-input:after{left:15px;right:auto}.selectize-control.rtl .selectize-input>input{margin:0 4px 0 -2px!important}.selectize-control .selectize-input.disabled{opacity:.5;background-color:#fafafa}
|
css/selectize/plugins/drag_drop.less
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
.selectize-control.plugin-drag_drop {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
}
|
1 |
.selectize-control.plugin-drag_drop {
|
2 |
+
&.multi > .selectize-input > div.ui-sortable-placeholder {
|
3 |
+
visibility: visible !important;
|
4 |
+
background: #f2f2f2 !important;
|
5 |
+
background: rgba(0,0,0,0.06) !important;
|
6 |
+
border: 0 none !important;
|
7 |
+
.selectize-box-shadow(inset 0 0 12px 4px #fff);
|
8 |
+
}
|
9 |
+
.ui-sortable-placeholder::after {
|
10 |
+
content: '!';
|
11 |
+
visibility: hidden;
|
12 |
+
}
|
13 |
+
.ui-sortable-helper {
|
14 |
+
.selectize-box-shadow(0 2px 5px rgba(0,0,0,0.2));
|
15 |
+
}
|
16 |
}
|
css/selectize/plugins/dropdown_header.less
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
.selectize-dropdown-header {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
}
|
8 |
.selectize-dropdown-header-close {
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
}
|
18 |
.selectize-dropdown-header-close:hover {
|
19 |
-
|
20 |
}
|
1 |
.selectize-dropdown-header {
|
2 |
+
position: relative;
|
3 |
+
padding: @selectize-padding-dropdown-item-y @selectize-padding-dropdown-item-x;
|
4 |
+
border-bottom: 1px solid @selectize-color-border;
|
5 |
+
background: mix(@selectize-color-dropdown, @selectize-color-border, 85%);
|
6 |
+
.selectize-border-radius(@selectize-border-radius @selectize-border-radius 0 0);
|
7 |
}
|
8 |
.selectize-dropdown-header-close {
|
9 |
+
position: absolute;
|
10 |
+
right: @selectize-padding-dropdown-item-x;
|
11 |
+
top: 50%;
|
12 |
+
color: @selectize-color-text;
|
13 |
+
opacity: 0.4;
|
14 |
+
margin-top: -12px;
|
15 |
+
line-height: 20px;
|
16 |
+
font-size: 20px !important;
|
17 |
}
|
18 |
.selectize-dropdown-header-close:hover {
|
19 |
+
color: darken(@selectize-color-text, 25%);
|
20 |
}
|
css/selectize/plugins/optgroup_columns.less
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
.selectize-dropdown.plugin-optgroup_columns {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
}
|
1 |
.selectize-dropdown.plugin-optgroup_columns {
|
2 |
+
.optgroup {
|
3 |
+
border-right: 1px solid #f2f2f2;
|
4 |
+
border-top: 0 none;
|
5 |
+
float: left;
|
6 |
+
.selectize-box-sizing(border-box);
|
7 |
+
}
|
8 |
+
.optgroup:last-child {
|
9 |
+
border-right: 0 none;
|
10 |
+
}
|
11 |
+
.optgroup:before {
|
12 |
+
display: none;
|
13 |
+
}
|
14 |
+
.optgroup-header {
|
15 |
+
border-top: 0 none;
|
16 |
+
}
|
17 |
}
|
css/selectize/plugins/remove_button.less
CHANGED
@@ -1,37 +1,43 @@
|
|
1 |
.selectize-control.plugin-remove_button {
|
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 |
}
|
1 |
.selectize-control.plugin-remove_button {
|
2 |
+
[data-value] {
|
3 |
+
position: relative;
|
4 |
+
padding-right: 24px !important;
|
5 |
+
}
|
6 |
+
[data-value] .remove {
|
7 |
+
z-index: 1; /* fixes ie bug (see #392) */
|
8 |
+
position: absolute;
|
9 |
+
top: 0;
|
10 |
+
right: 0;
|
11 |
+
bottom: 0;
|
12 |
+
width: 17px;
|
13 |
+
text-align: center;
|
14 |
+
font-weight: bold;
|
15 |
+
font-size: 12px;
|
16 |
+
color: inherit;
|
17 |
+
text-decoration: none;
|
18 |
+
vertical-align: middle;
|
19 |
+
display: inline-block;
|
20 |
+
padding: @selectize-padding-item-y 0 0 0;
|
21 |
+
border-left: 1px solid @selectize-color-item-border;
|
22 |
+
.selectize-border-radius(0 2px 2px 0);
|
23 |
+
.selectize-box-sizing(border-box);
|
24 |
+
}
|
25 |
+
[data-value] .remove:hover {
|
26 |
+
background: rgba(0,0,0,0.05);
|
27 |
+
}
|
28 |
+
[data-value].active .remove {
|
29 |
+
border-left-color: @selectize-color-item-active-border;
|
30 |
+
}
|
31 |
+
.disabled [data-value] .remove:hover {
|
32 |
+
background: none;
|
33 |
+
}
|
34 |
+
.disabled [data-value] .remove {
|
35 |
+
border-left-color: lighten(desaturate(@selectize-color-item-border, 100%), @selectize-lighten-disabled-item-border);
|
36 |
+
}
|
37 |
+
.remove-single {
|
38 |
+
position: absolute;
|
39 |
+
right: 0;
|
40 |
+
top: 0;
|
41 |
+
font-size: 23px;
|
42 |
+
}
|
43 |
}
|
css/{selectize.css → selectize/selectize.css}
RENAMED
@@ -3,8 +3,8 @@
|
|
3 |
background: #f2f2f2 !important;
|
4 |
background: rgba(0, 0, 0, 0.06) !important;
|
5 |
border: 0 none !important;
|
6 |
-
-webkit-box-shadow: inset 0 0 12px 4px #
|
7 |
-
box-shadow: inset 0 0 12px 4px #
|
8 |
}
|
9 |
.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {
|
10 |
content: '!';
|
@@ -16,7 +16,7 @@
|
|
16 |
}
|
17 |
.selectize-dropdown-header {
|
18 |
position: relative;
|
19 |
-
padding: 5px
|
20 |
border-bottom: 1px solid #d0d0d0;
|
21 |
background: #f8f8f8;
|
22 |
-webkit-border-radius: 3px 3px 0 0;
|
@@ -25,7 +25,7 @@
|
|
25 |
}
|
26 |
.selectize-dropdown-header-close {
|
27 |
position: absolute;
|
28 |
-
right:
|
29 |
top: 50%;
|
30 |
color: #303030;
|
31 |
opacity: 0.4;
|
@@ -93,6 +93,12 @@
|
|
93 |
.selectize-control.plugin-remove_button .disabled [data-value] .remove {
|
94 |
border-left-color: #ffffff;
|
95 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
.selectize-control {
|
97 |
position: relative;
|
98 |
}
|
@@ -107,13 +113,13 @@
|
|
107 |
}
|
108 |
.selectize-input,
|
109 |
.selectize-control.single .selectize-input.input-active {
|
110 |
-
background: #
|
111 |
cursor: text;
|
112 |
display: inline-block;
|
113 |
}
|
114 |
.selectize-input {
|
115 |
border: 1px solid #d0d0d0;
|
116 |
-
padding:
|
117 |
display: inline-block;
|
118 |
width: 100%;
|
119 |
overflow: hidden;
|
@@ -129,10 +135,10 @@
|
|
129 |
border-radius: 3px;
|
130 |
}
|
131 |
.selectize-control.multi .selectize-input.has-items {
|
132 |
-
padding:
|
133 |
}
|
134 |
.selectize-input.full {
|
135 |
-
background-color: #
|
136 |
}
|
137 |
.selectize-input.disabled,
|
138 |
.selectize-input.disabled * {
|
@@ -194,6 +200,9 @@
|
|
194 |
.selectize-input > input:focus {
|
195 |
outline: none !important;
|
196 |
}
|
|
|
|
|
|
|
197 |
.selectize-input::after {
|
198 |
content: ' ';
|
199 |
display: block;
|
@@ -213,7 +222,7 @@
|
|
213 |
position: absolute;
|
214 |
z-index: 10;
|
215 |
border: 1px solid #d0d0d0;
|
216 |
-
background: #
|
217 |
margin: -1px 0 0 0;
|
218 |
border-top: 0 none;
|
219 |
-webkit-box-sizing: border-box;
|
@@ -235,16 +244,25 @@
|
|
235 |
-moz-border-radius: 1px;
|
236 |
border-radius: 1px;
|
237 |
}
|
238 |
-
.selectize-dropdown
|
239 |
.selectize-dropdown .optgroup-header {
|
240 |
-
padding: 5px
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
}
|
242 |
.selectize-dropdown .optgroup:first-child .optgroup-header {
|
243 |
border-top: 0 none;
|
244 |
}
|
245 |
.selectize-dropdown .optgroup-header {
|
246 |
color: #303030;
|
247 |
-
background: #
|
248 |
cursor: default;
|
249 |
}
|
250 |
.selectize-dropdown .active {
|
@@ -261,6 +279,7 @@
|
|
261 |
overflow-y: auto;
|
262 |
overflow-x: hidden;
|
263 |
max-height: 200px;
|
|
|
264 |
}
|
265 |
.selectize-control.single .selectize-input,
|
266 |
.selectize-control.single .selectize-input input {
|
@@ -299,3 +318,4 @@
|
|
299 |
opacity: 0.5;
|
300 |
background-color: #fafafa;
|
301 |
}
|
|
3 |
background: #f2f2f2 !important;
|
4 |
background: rgba(0, 0, 0, 0.06) !important;
|
5 |
border: 0 none !important;
|
6 |
+
-webkit-box-shadow: inset 0 0 12px 4px #fff;
|
7 |
+
box-shadow: inset 0 0 12px 4px #fff;
|
8 |
}
|
9 |
.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after {
|
10 |
content: '!';
|
16 |
}
|
17 |
.selectize-dropdown-header {
|
18 |
position: relative;
|
19 |
+
padding: 5px 8px;
|
20 |
border-bottom: 1px solid #d0d0d0;
|
21 |
background: #f8f8f8;
|
22 |
-webkit-border-radius: 3px 3px 0 0;
|
25 |
}
|
26 |
.selectize-dropdown-header-close {
|
27 |
position: absolute;
|
28 |
+
right: 8px;
|
29 |
top: 50%;
|
30 |
color: #303030;
|
31 |
opacity: 0.4;
|
93 |
.selectize-control.plugin-remove_button .disabled [data-value] .remove {
|
94 |
border-left-color: #ffffff;
|
95 |
}
|
96 |
+
.selectize-control.plugin-remove_button .remove-single {
|
97 |
+
position: absolute;
|
98 |
+
right: 0;
|
99 |
+
top: 0;
|
100 |
+
font-size: 23px;
|
101 |
+
}
|
102 |
.selectize-control {
|
103 |
position: relative;
|
104 |
}
|
113 |
}
|
114 |
.selectize-input,
|
115 |
.selectize-control.single .selectize-input.input-active {
|
116 |
+
background: #fff;
|
117 |
cursor: text;
|
118 |
display: inline-block;
|
119 |
}
|
120 |
.selectize-input {
|
121 |
border: 1px solid #d0d0d0;
|
122 |
+
padding: 8px 8px;
|
123 |
display: inline-block;
|
124 |
width: 100%;
|
125 |
overflow: hidden;
|
135 |
border-radius: 3px;
|
136 |
}
|
137 |
.selectize-control.multi .selectize-input.has-items {
|
138 |
+
padding: 6px 8px 3px;
|
139 |
}
|
140 |
.selectize-input.full {
|
141 |
+
background-color: #fff;
|
142 |
}
|
143 |
.selectize-input.disabled,
|
144 |
.selectize-input.disabled * {
|
200 |
.selectize-input > input:focus {
|
201 |
outline: none !important;
|
202 |
}
|
203 |
+
.selectize-input > input[placeholder] {
|
204 |
+
box-sizing: initial;
|
205 |
+
}
|
206 |
.selectize-input::after {
|
207 |
content: ' ';
|
208 |
display: block;
|
222 |
position: absolute;
|
223 |
z-index: 10;
|
224 |
border: 1px solid #d0d0d0;
|
225 |
+
background: #fff;
|
226 |
margin: -1px 0 0 0;
|
227 |
border-top: 0 none;
|
228 |
-webkit-box-sizing: border-box;
|
244 |
-moz-border-radius: 1px;
|
245 |
border-radius: 1px;
|
246 |
}
|
247 |
+
.selectize-dropdown .option,
|
248 |
.selectize-dropdown .optgroup-header {
|
249 |
+
padding: 5px 8px;
|
250 |
+
}
|
251 |
+
.selectize-dropdown .option,
|
252 |
+
.selectize-dropdown [data-disabled],
|
253 |
+
.selectize-dropdown [data-disabled] [data-selectable].option {
|
254 |
+
cursor: inherit;
|
255 |
+
opacity: 0.5;
|
256 |
+
}
|
257 |
+
.selectize-dropdown [data-selectable].option {
|
258 |
+
opacity: 1;
|
259 |
}
|
260 |
.selectize-dropdown .optgroup:first-child .optgroup-header {
|
261 |
border-top: 0 none;
|
262 |
}
|
263 |
.selectize-dropdown .optgroup-header {
|
264 |
color: #303030;
|
265 |
+
background: #fff;
|
266 |
cursor: default;
|
267 |
}
|
268 |
.selectize-dropdown .active {
|
279 |
overflow-y: auto;
|
280 |
overflow-x: hidden;
|
281 |
max-height: 200px;
|
282 |
+
-webkit-overflow-scrolling: touch;
|
283 |
}
|
284 |
.selectize-control.single .selectize-input,
|
285 |
.selectize-control.single .selectize-input input {
|
318 |
opacity: 0.5;
|
319 |
background-color: #fafafa;
|
320 |
}
|
321 |
+
/*# sourceMappingURL=selectize.css.map */
|
css/selectize/selectize.css.map
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
{"version":3,"sources":["plugins/drag_drop.less","selectize.less","plugins/dropdown_header.less","plugins/optgroup_columns.less","plugins/remove_button.less"],"names":[],"mappings":"AACE,kBADgB,iBACf,MAAO,mBAAmB,MAAK;EAC9B,8BAAA;EACA,mBAAA;EACA,+BAAA;EACA,yBAAA;ECsEF,2CAAA;EACA,mCAAA;;AD5EF,kBAAkB,iBAQhB,yBAAwB;EACtB,SAAS,GAAT;EACA,kBAAA;;AAVJ,kBAAkB,iBAYhB;EC+DA,gDAAA;EACA,wCAAA;;AC5EF;EACE,kBAAA;EACA,gBAAA;EACA,gCAAA;EACA,mBAAA;ED4DA,kCAAA;EACA,+BAAA;EACA,0BAAA;;AC3DF;EACE,kBAAA;EACA,UAAA;EACA,QAAA;EACA,cAAA;EACA,YAAA;EACA,iBAAA;EACA,iBAAA;EACA,0BAAA;;AAEF,gCAAgC;EAC9B,cAAA;;AClBF,mBAAmB,wBACjB;EACE,+BAAA;EACA,kBAAA;EACA,WAAA;EF2EF,8BAAA;EACA,2BAAA;EACA,sBAAA;;AEjFF,mBAAmB,wBAOjB,UAAS;EACP,oBAAA;;AARJ,mBAAmB,wBAUjB,UAAS;EACP,aAAA;;AAXJ,mBAAmB,wBAajB;EACE,kBAAA;;ACdJ,kBAAkB,qBAChB;EACE,kBAAA;EACA,8BAAA;;AAHJ,kBAAkB,qBAKhB,aAAa;EACX,UAAA;;EACA,kBAAA;EACA,MAAA;EACA,QAAA;EACA,SAAA;EACA,WAAA;EACA,kBAAA;EACA,iBAAA;EACA,eAAA;EACA,cAAA;EACA,qBAAA;EACA,sBAAA;EACA,qBAAA;EACA,kBAAA;EACA,8BAAA;EH4CF,kCAAA;EACA,+BAAA;EACA,0BAAA;EAaA,8BAAA;EACA,2BAAA;EACA,sBAAA;;AGjFF,kBAAkB,qBAwBhB,aAAa,QAAO;EAClB,+BAAA;;AAzBJ,kBAAkB,qBA2BhB,aAAY,OAAQ;EAClB,0BAAA;;AA5BJ,kBAAkB,qBA8BhB,UAAU,aAAa,QAAO;EAC5B,gBAAA;;AA/BJ,kBAAkB,qBAiChB,UAAU,aAAa;EACrB,0BAAA;;AAlCJ,kBAAkB,qBAoChB;EACE,kBAAA;EACA,QAAA;EACA,MAAA;EACA,eAAA;;AHsDJ;EACE,kBAAA;;AAGF;AAAqB;AAAkB,gBAAiB;EACtD,cAAA;EACA,oBAAA;EACA,eAAA;EACA,iBAAA;EACA,+BAAA;;AAGF;AAAkB,kBAAkB,OAAQ,iBAAgB;EAC1D,gBAAA;EACA,YAAA;EACA,qBAAA;;AAGF;EACE,yBAAA;EACA,gBAAA;EACA,qBAAA;EACA,WAAA;EACA,gBAAA;EACA,kBAAA;EACA,UAAA;EAxCA,8BAAA;EACA,2BAAA;EACA,sBAAA;EANA,sDAAA;EACA,8CAAA;EAZA,0BAAA;EACA,uBAAA;EACA,kBAAA;;AA0DA,kBAAkB,MAAO,iBAAC;EAIxB,oBAAA;;AAGF,gBAAC;EACC,sBAAA;;AAEF,gBAAC;AAAW,gBAAC,SAAU;EACrB,0BAAA;;AAEF,gBAAC;EA9DD,uDAAA;EACA,+CAAA;;AAgEA,gBAAC;EA5ED,kCAAA;EACA,+BAAA;EACA,0BAAA;;AA8CF,gBAgCE;EACE,wBAAA;EACA,0BAAA;EACA,qBAAA;EACA,OAAA;EACA,gBAAA;;AAEF,kBAAkB,MAAO,iBAAE;EACzB,eAAA;EACA,mBAAA;EACA,gBAAA;EACA,mBAAA;EACA,cAAA;EACA,uBAAA;;AAEA,kBARgB,MAAO,iBAAE,MAQxB;EACC,mBAAA;EACA,cAAA;EACA,uBAAA;;AAIF,kBADgB,MAAO,iBAAC,SAAU;AAC/B,kBADa,MAAO,iBAAC,SAAU,MAC9B;EACF,cAAA;EACA,mBAAA;EACA,uBAAA;;AAzDN,gBA4DE;EAIE,qBAAA;EACA,qBAAA;EACA,wBAAA;EACA,2BAAA;EACA,0BAAA;EACA,iBAAA;EACA,yBAAA;EACA,yBAAA;EACA,2BAAA;EACA,+BAAA;EACA,oCAAA;EA/GF,wBAAA;EACA,gBAAA;;AAiGE,gBADF,QACG;EACC,aAAA;;AAcF,gBAhBF,QAgBG;EAAS,wBAAA;;AACV,gBAjBF,QAiBG;EACC,mBAAA;;AAKN,gBAAgB;EACd,SAAS,GAAT;EACA,cAAA;EACA,WAAA;;AAGF,gBAAgB,gBAAgB;EAC9B,SAAS,GAAT;EACA,cAAA;EACA,kBAAA;EACA,mBAAA;EACA,WAAA;EACA,SAAA;EACA,OAAA;EACA,QAAA;;AAGF;EACE,kBAAA;EACA,WAAA;EACA,yBAAA;EACA,gBAAA;EACA,kBAAA;EACA,kBAAA;EA3IA,8BAAA;EACA,2BAAA;EACA,sBAAA;EANA,gDAAA;EACA,wCAAA;EAZA,kCAAA;EACA,+BAAA;EACA,0BAAA;;AAkJF,mBAWE;EACE,eAAA;EACA,gBAAA;;AAbJ,mBAWE,kBAGE;EACE,oCAAA;EAnKJ,0BAAA;EACA,uBAAA;EACA,kBAAA;;AAkJF,mBAmBE;AAnBF,mBAmBW;EACP,gBAAA;;AApBJ,mBAsBE;AAtBF,mBAsBW;AAtBX,mBAsB4B,gBAAgB,kBAAiB;EACzD,eAAA;EACA,YAAA;;AAxBJ,mBA0BE,kBAAiB;EACf,UAAA;;AA3BJ,mBA6BE,UAAS,YAAa;EACpB,kBAAA;;AA9BJ,mBAgCE;EACE,cAAA;EACA,gBAAA;EACA,eAAA;;AAnCJ,mBAqCE;EACE,yBAAA;EACA,cAAA;;AACA,mBAHF,QAGG;EACC,cAAA;;AAzCN,mBA4CE;EACE,4BAAA;;AAIJ;EACE,gBAAA;EACA,kBAAA;EACA,iBAAA;EACA,iCAAA;;AAIA,kBADgB,OAAQ;AAA1B,kBAAkB,OAAQ,iBACrB;EAAQ,eAAA;;AACX,kBAFgB,OAAQ,iBAEvB;AAAe,kBAFA,OAAQ,iBAEP,aAAc;EAAQ,YAAA;;AAEvC,kBAJgB,OAAQ,iBAIvB;EACC,SAAS,GAAT;EACA,cAAA;EACA,kBAAA;EACA,QAAA;EACA,WAAA;EACA,gBAAA;EACA,QAAA;EACA,SAAA;EACA,mBAAA;EACA,2BAAA;EACA,yDAAA;;AAEF,kBAjBgB,OAAQ,iBAiBvB,gBAAgB;EACf,gBAAA;EACA,2BAAA;EACA,yDAAA;;AAKF,kBADgB,IACf,OAAQ,iBAAgB;EACvB,UAAA;EACA,WAAA;;AAHJ,kBAAkB,IAKhB,iBAAiB;EACf,oBAAA;;AAIJ,kBAAmB,iBAAgB;EACjC,YAAA;EACA,yBAAA","file":"selectize.css"}
|
css/selectize/selectize.less
CHANGED
@@ -45,8 +45,8 @@
|
|
45 |
@selectize-width-item-border: 0;
|
46 |
@selectize-max-height-dropdown: 200px;
|
47 |
|
48 |
-
@selectize-padding-x:
|
49 |
-
@selectize-padding-y:
|
50 |
@selectize-padding-item-x: 6px;
|
51 |
@selectize-padding-item-y: 2px;
|
52 |
@selectize-padding-dropdown-item-x: @selectize-padding-x;
|
@@ -62,234 +62,245 @@
|
|
62 |
@selectize-caret-margin-rtl: 0 4px 0 -2px;
|
63 |
|
64 |
.selectize-border-radius (@radii) {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
}
|
69 |
.selectize-unselectable () {
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
}
|
75 |
.selectize-box-shadow (@shadow) {
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
.selectize-box-sizing (@type: border-box) {
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
}
|
84 |
.selectize-vertical-gradient (@color-top, @color-bottom) {
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
}
|
94 |
|
95 |
.selectize-control {
|
96 |
-
|
97 |
}
|
98 |
|
99 |
.selectize-dropdown, .selectize-input, .selectize-input input {
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
}
|
106 |
|
107 |
.selectize-input, .selectize-control.single .selectize-input.input-active {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
}
|
112 |
|
113 |
.selectize-input {
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
191 |
}
|
192 |
|
193 |
.selectize-input::after {
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
}
|
198 |
|
199 |
.selectize-input.dropdown-active::before {
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
}
|
209 |
|
210 |
.selectize-dropdown {
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
}
|
251 |
|
252 |
.selectize-dropdown-content {
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
256 |
}
|
257 |
|
258 |
.selectize-control.single .selectize-input {
|
259 |
-
|
260 |
-
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
}
|
281 |
|
282 |
.selectize-control.rtl {
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
}
|
291 |
|
292 |
.selectize-control .selectize-input.disabled {
|
293 |
-
|
294 |
-
|
295 |
-
}
|
45 |
@selectize-width-item-border: 0;
|
46 |
@selectize-max-height-dropdown: 200px;
|
47 |
|
48 |
+
@selectize-padding-x: 8px;
|
49 |
+
@selectize-padding-y: 8px;
|
50 |
@selectize-padding-item-x: 6px;
|
51 |
@selectize-padding-item-y: 2px;
|
52 |
@selectize-padding-dropdown-item-x: @selectize-padding-x;
|
62 |
@selectize-caret-margin-rtl: 0 4px 0 -2px;
|
63 |
|
64 |
.selectize-border-radius (@radii) {
|
65 |
+
-webkit-border-radius: @radii;
|
66 |
+
-moz-border-radius: @radii;
|
67 |
+
border-radius: @radii;
|
68 |
}
|
69 |
.selectize-unselectable () {
|
70 |
+
-webkit-user-select: none;
|
71 |
+
-moz-user-select: none;
|
72 |
+
-ms-user-select: none;
|
73 |
+
user-select: none;
|
74 |
}
|
75 |
.selectize-box-shadow (@shadow) {
|
76 |
+
-webkit-box-shadow: @shadow;
|
77 |
+
box-shadow: @shadow;
|
78 |
}
|
79 |
.selectize-box-sizing (@type: border-box) {
|
80 |
+
-webkit-box-sizing: @type;
|
81 |
+
-moz-box-sizing: @type;
|
82 |
+
box-sizing: @type;
|
83 |
}
|
84 |
.selectize-vertical-gradient (@color-top, @color-bottom) {
|
85 |
+
background-color: mix(@color-top, @color-bottom, 60%);
|
86 |
+
background-image: -moz-linear-gradient(top, @color-top, @color-bottom); // FF 3.6+
|
87 |
+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@color-top), to(@color-bottom)); // Safari 4+, Chrome 2+
|
88 |
+
background-image: -webkit-linear-gradient(top, @color-top, @color-bottom); // Safari 5.1+, Chrome 10+
|
89 |
+
background-image: -o-linear-gradient(top, @color-top, @color-bottom); // Opera 11.10
|
90 |
+
background-image: linear-gradient(to bottom, @color-top, @color-bottom); // Standard, IE10
|
91 |
+
background-repeat: repeat-x;
|
92 |
+
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@color-top),argb(@color-bottom))); // IE9 and down
|
93 |
}
|
94 |
|
95 |
.selectize-control {
|
96 |
+
position: relative;
|
97 |
}
|
98 |
|
99 |
.selectize-dropdown, .selectize-input, .selectize-input input {
|
100 |
+
color: @selectize-color-text;
|
101 |
+
font-family: @selectize-font-family;
|
102 |
+
font-size: @selectize-font-size;
|
103 |
+
line-height: @selectize-line-height;
|
104 |
+
-webkit-font-smoothing: @selectize-font-smoothing;
|
105 |
}
|
106 |
|
107 |
.selectize-input, .selectize-control.single .selectize-input.input-active {
|
108 |
+
background: @selectize-color-input;
|
109 |
+
cursor: text;
|
110 |
+
display: inline-block;
|
111 |
}
|
112 |
|
113 |
.selectize-input {
|
114 |
+
border: @selectize-border;
|
115 |
+
padding: @selectize-padding-y @selectize-padding-x;
|
116 |
+
display: inline-block;
|
117 |
+
width: 100%;
|
118 |
+
overflow: hidden;
|
119 |
+
position: relative;
|
120 |
+
z-index: 1;
|
121 |
+
.selectize-box-sizing(border-box);
|
122 |
+
.selectize-box-shadow(@selectize-shadow-input);
|
123 |
+
.selectize-border-radius(@selectize-border-radius);
|
124 |
|
125 |
+
.selectize-control.multi &.has-items {
|
126 |
+
@padding-x: @selectize-padding-x;
|
127 |
+
@padding-top: @selectize-padding-y - @selectize-padding-item-y - @selectize-width-item-border;
|
128 |
+
@padding-bottom: @selectize-padding-y - @selectize-padding-item-y - @selectize-margin-item-y - @selectize-width-item-border;
|
129 |
+
padding: @padding-top @padding-x @padding-bottom;
|
130 |
+
}
|
131 |
|
132 |
+
&.full {
|
133 |
+
background-color: @selectize-color-input-full;
|
134 |
+
}
|
135 |
+
&.disabled, &.disabled * {
|
136 |
+
cursor: default !important;
|
137 |
+
}
|
138 |
+
&.focus {
|
139 |
+
.selectize-box-shadow(@selectize-shadow-input-focus);
|
140 |
+
}
|
141 |
+
&.dropdown-active {
|
142 |
+
.selectize-border-radius(@selectize-border-radius @selectize-border-radius 0 0);
|
143 |
+
}
|
144 |
|
145 |
+
> * {
|
146 |
+
vertical-align: baseline;
|
147 |
+
display: -moz-inline-stack;
|
148 |
+
display: inline-block;
|
149 |
+
zoom: 1;
|
150 |
+
*display: inline;
|
151 |
+
}
|
152 |
+
.selectize-control.multi & > div {
|
153 |
+
cursor: pointer;
|
154 |
+
margin: 0 @selectize-margin-item-x @selectize-margin-item-y 0;
|
155 |
+
padding: @selectize-padding-item-y @selectize-padding-item-x;
|
156 |
+
background: @selectize-color-item;
|
157 |
+
color: @selectize-color-item-text;
|
158 |
+
border: @selectize-width-item-border solid @selectize-color-item-border;
|
159 |
|
160 |
+
&.active {
|
161 |
+
background: @selectize-color-item-active;
|
162 |
+
color: @selectize-color-item-active-text;
|
163 |
+
border: @selectize-width-item-border solid @selectize-color-item-active-border;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
.selectize-control.multi &.disabled > div {
|
167 |
+
&, &.active {
|
168 |
+
color: lighten(desaturate(@selectize-color-item-text, 100%), @selectize-lighten-disabled-item-text);
|
169 |
+
background: lighten(desaturate(@selectize-color-item, 100%), @selectize-lighten-disabled-item);
|
170 |
+
border: @selectize-width-item-border solid lighten(desaturate(@selectize-color-item-border, 100%), @selectize-lighten-disabled-item-border);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
> input {
|
174 |
+
&::-ms-clear {
|
175 |
+
display: none;
|
176 |
+
}
|
177 |
+
display: inline-block !important;
|
178 |
+
padding: 0 !important;
|
179 |
+
min-height: 0 !important;
|
180 |
+
max-height: none !important;
|
181 |
+
max-width: 100% !important;
|
182 |
+
margin: @selectize-caret-margin !important;
|
183 |
+
text-indent: 0 !important;
|
184 |
+
border: 0 none !important;
|
185 |
+
background: none !important;
|
186 |
+
line-height: inherit !important;
|
187 |
+
-webkit-user-select: auto !important;
|
188 |
+
.selectize-box-shadow(none) !important;
|
189 |
+
&:focus { outline: none !important; }
|
190 |
+
&[placeholder] {
|
191 |
+
box-sizing: initial;
|
192 |
+
}
|
193 |
+
}
|
194 |
}
|
195 |
|
196 |
.selectize-input::after {
|
197 |
+
content: ' ';
|
198 |
+
display: block;
|
199 |
+
clear: left;
|
200 |
}
|
201 |
|
202 |
.selectize-input.dropdown-active::before {
|
203 |
+
content: ' ';
|
204 |
+
display: block;
|
205 |
+
position: absolute;
|
206 |
+
background: @selectize-color-dropdown-border-top;
|
207 |
+
height: 1px;
|
208 |
+
bottom: 0;
|
209 |
+
left: 0;
|
210 |
+
right: 0;
|
211 |
}
|
212 |
|
213 |
.selectize-dropdown {
|
214 |
+
position: absolute;
|
215 |
+
z-index: 10;
|
216 |
+
border: @selectize-dropdown-border;
|
217 |
+
background: @selectize-color-dropdown;
|
218 |
+
margin: -1px 0 0 0;
|
219 |
+
border-top: 0 none;
|
220 |
+
.selectize-box-sizing(border-box);
|
221 |
+
.selectize-box-shadow(0 1px 3px rgba(0,0,0,0.1));
|
222 |
+
.selectize-border-radius(0 0 @selectize-border-radius @selectize-border-radius);
|
223 |
|
224 |
+
[data-selectable] {
|
225 |
+
cursor: pointer;
|
226 |
+
overflow: hidden;
|
227 |
+
.highlight {
|
228 |
+
background: @selectize-color-highlight;
|
229 |
+
.selectize-border-radius(1px);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
.option, .optgroup-header {
|
233 |
+
padding: @selectize-padding-dropdown-item-y @selectize-padding-dropdown-item-x;
|
234 |
+
}
|
235 |
+
.option, [data-disabled], [data-disabled] [data-selectable].option {
|
236 |
+
cursor: inherit;
|
237 |
+
opacity: 0.5;
|
238 |
+
}
|
239 |
+
[data-selectable].option {
|
240 |
+
opacity: 1;
|
241 |
+
}
|
242 |
+
.optgroup:first-child .optgroup-header {
|
243 |
+
border-top: 0 none;
|
244 |
+
}
|
245 |
+
.optgroup-header {
|
246 |
+
color: @selectize-color-optgroup-text;
|
247 |
+
background: @selectize-color-optgroup;
|
248 |
+
cursor: default;
|
249 |
+
}
|
250 |
+
.active {
|
251 |
+
background-color: @selectize-color-dropdown-item-active;
|
252 |
+
color: @selectize-color-dropdown-item-active-text;
|
253 |
+
&.create {
|
254 |
+
color: @selectize-color-dropdown-item-create-active-text;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
.create {
|
258 |
+
color: @selectize-color-dropdown-item-create-text;
|
259 |
+
}
|
260 |
}
|
261 |
|
262 |
.selectize-dropdown-content {
|
263 |
+
overflow-y: auto;
|
264 |
+
overflow-x: hidden;
|
265 |
+
max-height: @selectize-max-height-dropdown;
|
266 |
+
-webkit-overflow-scrolling: touch;
|
267 |
}
|
268 |
|
269 |
.selectize-control.single .selectize-input {
|
270 |
+
&, input { cursor: pointer; }
|
271 |
+
&.input-active, &.input-active input { cursor: text; }
|
272 |
|
273 |
+
&:after {
|
274 |
+
content: ' ';
|
275 |
+
display: block;
|
276 |
+
position: absolute;
|
277 |
+
top: 50%;
|
278 |
+
right: @selectize-arrow-offset;
|
279 |
+
margin-top: round((-1 * @selectize-arrow-size / 2));
|
280 |
+
width: 0;
|
281 |
+
height: 0;
|
282 |
+
border-style: solid;
|
283 |
+
border-width: @selectize-arrow-size @selectize-arrow-size 0 @selectize-arrow-size;
|
284 |
+
border-color: @selectize-arrow-color transparent transparent transparent;
|
285 |
+
}
|
286 |
+
&.dropdown-active:after {
|
287 |
+
margin-top: @selectize-arrow-size * -0.8;
|
288 |
+
border-width: 0 @selectize-arrow-size @selectize-arrow-size @selectize-arrow-size;
|
289 |
+
border-color: transparent transparent @selectize-arrow-color transparent;
|
290 |
+
}
|
291 |
}
|
292 |
|
293 |
.selectize-control.rtl {
|
294 |
+
&.single .selectize-input:after {
|
295 |
+
left: @selectize-arrow-offset;
|
296 |
+
right: auto;
|
297 |
+
}
|
298 |
+
.selectize-input > input {
|
299 |
+
margin: @selectize-caret-margin-rtl !important;
|
300 |
+
}
|
301 |
}
|
302 |
|
303 |
.selectize-control .selectize-input.disabled {
|
304 |
+
opacity: @selectize-opacity-disabled;
|
305 |
+
background-color: @selectize-color-disabled;
|
306 |
+
}
|
js/selectize.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* sifter.js
|
3 |
-
* Copyright (c) 2013 Brian Reavis & contributors
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
6 |
* file except in compliance with the License. You may obtain a copy of the License at:
|
@@ -16,7 +16,7 @@
|
|
16 |
|
17 |
(function(root, factory) {
|
18 |
if (typeof define === 'function' && define.amd) {
|
19 |
-
define(
|
20 |
} else if (typeof exports === 'object') {
|
21 |
module.exports = factory();
|
22 |
} else {
|
@@ -45,7 +45,7 @@
|
|
45 |
* @param {string} query
|
46 |
* @returns {array}
|
47 |
*/
|
48 |
-
Sifter.prototype.tokenize = function(query) {
|
49 |
query = trim(String(query || '').toLowerCase());
|
50 |
if (!query || !query.length) return [];
|
51 |
|
@@ -62,6 +62,7 @@
|
|
62 |
}
|
63 |
}
|
64 |
}
|
|
|
65 |
tokens.push({
|
66 |
string : words[i],
|
67 |
regex : new RegExp(regex, 'i')
|
@@ -114,13 +115,14 @@
|
|
114 |
* @returns {function}
|
115 |
*/
|
116 |
Sifter.prototype.getScoreFunction = function(search, options) {
|
117 |
-
var self, fields, tokens, token_count;
|
118 |
|
119 |
self = this;
|
120 |
search = self.prepareSearch(search, options);
|
121 |
tokens = search.tokens;
|
122 |
fields = search.options.fields;
|
123 |
token_count = tokens.length;
|
|
|
124 |
|
125 |
/**
|
126 |
* Calculates how close of a match the
|
@@ -157,12 +159,12 @@
|
|
157 |
}
|
158 |
if (field_count === 1) {
|
159 |
return function(token, data) {
|
160 |
-
return scoreValue(data
|
161 |
};
|
162 |
}
|
163 |
return function(token, data) {
|
164 |
for (var i = 0, sum = 0; i < field_count; i++) {
|
165 |
-
sum += scoreValue(data
|
166 |
}
|
167 |
return sum / field_count;
|
168 |
};
|
@@ -223,7 +225,7 @@
|
|
223 |
*/
|
224 |
get_field = function(name, result) {
|
225 |
if (name === '$score') return result.score;
|
226 |
-
return self.items[result.id]
|
227 |
};
|
228 |
|
229 |
// parse options
|
@@ -317,7 +319,7 @@
|
|
317 |
return {
|
318 |
options : options,
|
319 |
query : String(query || '').toLowerCase(),
|
320 |
-
tokens : this.tokenize(query),
|
321 |
total : 0,
|
322 |
items : []
|
323 |
};
|
@@ -412,6 +414,21 @@
|
|
412 |
return a;
|
413 |
};
|
414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
var trim = function(str) {
|
416 |
return (str + '').replace(/^\s+|\s+$|/g, '');
|
417 |
};
|
@@ -420,25 +437,36 @@
|
|
420 |
return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
|
421 |
};
|
422 |
|
423 |
-
var is_array = Array.isArray || ($ && $.isArray) || function(object) {
|
424 |
return Object.prototype.toString.call(object) === '[object Array]';
|
425 |
};
|
426 |
|
427 |
var DIACRITICS = {
|
428 |
-
'a': '[
|
429 |
-
'
|
430 |
-
'
|
431 |
-
'
|
432 |
-
'
|
433 |
-
'
|
434 |
-
'
|
435 |
-
'
|
436 |
-
'
|
437 |
-
'
|
438 |
-
'
|
439 |
-
'
|
440 |
-
'
|
441 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
};
|
443 |
|
444 |
var asciifold = (function() {
|
@@ -469,8 +497,6 @@
|
|
469 |
return Sifter;
|
470 |
}));
|
471 |
|
472 |
-
|
473 |
-
|
474 |
/**
|
475 |
* microplugin.js
|
476 |
* Copyright (c) 2013 Brian Reavis & contributors
|
@@ -489,7 +515,7 @@
|
|
489 |
|
490 |
(function(root, factory) {
|
491 |
if (typeof define === 'function' && define.amd) {
|
492 |
-
define(
|
493 |
} else if (typeof exports === 'object') {
|
494 |
module.exports = factory();
|
495 |
} else {
|
@@ -608,8 +634,9 @@
|
|
608 |
}));
|
609 |
|
610 |
/**
|
611 |
-
* selectize.js (v0.
|
612 |
* Copyright (c) 2013–2015 Brian Reavis & contributors
|
|
|
613 |
*
|
614 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
615 |
* file except in compliance with the License. You may obtain a copy of the License at:
|
@@ -621,6 +648,7 @@
|
|
621 |
* governing permissions and limitations under the License.
|
622 |
*
|
623 |
* @author Brian Reavis <brian@thirdroute.com>
|
|
|
624 |
*/
|
625 |
|
626 |
/*jshint curly:false */
|
@@ -628,8 +656,8 @@
|
|
628 |
|
629 |
(function(root, factory) {
|
630 |
if (typeof define === 'function' && define.amd) {
|
631 |
-
define(
|
632 |
-
} else if (typeof exports === 'object') {
|
633 |
module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));
|
634 |
} else {
|
635 |
root.Selectize = factory(root.jQuery, root.Sifter, root.MicroPlugin);
|
@@ -640,9 +668,11 @@
|
|
640 |
var highlight = function($element, pattern) {
|
641 |
if (typeof pattern === 'string' && !pattern.length) return;
|
642 |
var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
|
643 |
-
|
644 |
var highlight = function(node) {
|
645 |
var skip = 0;
|
|
|
|
|
646 |
if (node.nodeType === 3) {
|
647 |
var pos = node.data.search(regex);
|
648 |
if (pos >= 0 && node.data.length > 0) {
|
@@ -656,19 +686,36 @@
|
|
656 |
middlebit.parentNode.replaceChild(spannode, middlebit);
|
657 |
skip = 1;
|
658 |
}
|
659 |
-
}
|
|
|
|
|
|
|
660 |
for (var i = 0; i < node.childNodes.length; ++i) {
|
661 |
i += highlight(node.childNodes[i]);
|
662 |
}
|
663 |
}
|
664 |
return skip;
|
665 |
};
|
666 |
-
|
667 |
return $element.each(function() {
|
668 |
highlight(this);
|
669 |
});
|
670 |
};
|
671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
var MicroEvent = function() {};
|
673 |
MicroEvent.prototype = {
|
674 |
on: function(event, fct){
|
@@ -680,7 +727,7 @@
|
|
680 |
var n = arguments.length;
|
681 |
if (n === 0) return delete this._events;
|
682 |
if (n === 1) return delete this._events[event];
|
683 |
-
|
684 |
this._events = this._events || {};
|
685 |
if (event in this._events === false) return;
|
686 |
this._events[event].splice(this._events[event].indexOf(fct), 1);
|
@@ -693,7 +740,7 @@
|
|
693 |
}
|
694 |
}
|
695 |
};
|
696 |
-
|
697 |
/**
|
698 |
* Mixin will delegate all MicroEvent.js function in the destination object.
|
699 |
*
|
@@ -707,9 +754,9 @@
|
|
707 |
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
|
708 |
}
|
709 |
};
|
710 |
-
|
711 |
var IS_MAC = /Mac/.test(navigator.userAgent);
|
712 |
-
|
713 |
var KEY_A = 65;
|
714 |
var KEY_COMMA = 188;
|
715 |
var KEY_RETURN = 13;
|
@@ -726,17 +773,18 @@
|
|
726 |
var KEY_CMD = IS_MAC ? 91 : 17;
|
727 |
var KEY_CTRL = IS_MAC ? 18 : 17;
|
728 |
var KEY_TAB = 9;
|
729 |
-
|
730 |
var TAG_SELECT = 1;
|
731 |
var TAG_INPUT = 2;
|
732 |
-
|
733 |
// for now, android support in general is too spotty to support validity
|
734 |
-
var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('
|
735 |
-
|
|
|
736 |
var isset = function(object) {
|
737 |
return typeof object !== 'undefined';
|
738 |
};
|
739 |
-
|
740 |
/**
|
741 |
* Converts a scalar to its best string representation
|
742 |
* for hash keys and HTML attribute values.
|
@@ -758,7 +806,7 @@
|
|
758 |
if (typeof value === 'boolean') return value ? '1' : '0';
|
759 |
return value + '';
|
760 |
};
|
761 |
-
|
762 |
/**
|
763 |
* Escapes a string for use within HTML.
|
764 |
*
|
@@ -772,7 +820,7 @@
|
|
772 |
.replace(/>/g, '>')
|
773 |
.replace(/"/g, '"');
|
774 |
};
|
775 |
-
|
776 |
/**
|
777 |
* Escapes "$" characters in replacement strings.
|
778 |
*
|
@@ -782,9 +830,9 @@
|
|
782 |
var escape_replace = function(str) {
|
783 |
return (str + '').replace(/\$/g, '$$$$');
|
784 |
};
|
785 |
-
|
786 |
var hook = {};
|
787 |
-
|
788 |
/**
|
789 |
* Wraps `method` on `self` so that `fn`
|
790 |
* is invoked before the original method.
|
@@ -800,7 +848,7 @@
|
|
800 |
return original.apply(self, arguments);
|
801 |
};
|
802 |
};
|
803 |
-
|
804 |
/**
|
805 |
* Wraps `method` on `self` so that `fn`
|
806 |
* is invoked after the original method.
|
@@ -817,7 +865,7 @@
|
|
817 |
return result;
|
818 |
};
|
819 |
};
|
820 |
-
|
821 |
/**
|
822 |
* Wraps `fn` so that it can only be invoked once.
|
823 |
*
|
@@ -832,7 +880,7 @@
|
|
832 |
fn.apply(this, arguments);
|
833 |
};
|
834 |
};
|
835 |
-
|
836 |
/**
|
837 |
* Wraps `fn` so that it can only be called once
|
838 |
* every `delay` milliseconds (invoked on the falling edge).
|
@@ -852,7 +900,7 @@
|
|
852 |
}, delay);
|
853 |
};
|
854 |
};
|
855 |
-
|
856 |
/**
|
857 |
* Debounce all fired events types listed in `types`
|
858 |
* while executing the provided `fn`.
|
@@ -865,7 +913,7 @@
|
|
865 |
var type;
|
866 |
var trigger = self.trigger;
|
867 |
var event_args = {};
|
868 |
-
|
869 |
// override trigger method
|
870 |
self.trigger = function() {
|
871 |
var type = arguments[0];
|
@@ -875,11 +923,11 @@
|
|
875 |
return trigger.apply(self, arguments);
|
876 |
}
|
877 |
};
|
878 |
-
|
879 |
// invoke provided function
|
880 |
fn.apply(self, []);
|
881 |
self.trigger = trigger;
|
882 |
-
|
883 |
// trigger queued events
|
884 |
for (type in event_args) {
|
885 |
if (event_args.hasOwnProperty(type)) {
|
@@ -887,7 +935,7 @@
|
|
887 |
}
|
888 |
}
|
889 |
};
|
890 |
-
|
891 |
/**
|
892 |
* A workaround for http://bugs.jquery.com/ticket/6696
|
893 |
*
|
@@ -906,7 +954,7 @@
|
|
906 |
return fn.apply(this, [e]);
|
907 |
});
|
908 |
};
|
909 |
-
|
910 |
/**
|
911 |
* Determines the current selection within a text input control.
|
912 |
* Returns an object containing:
|
@@ -931,7 +979,7 @@
|
|
931 |
}
|
932 |
return result;
|
933 |
};
|
934 |
-
|
935 |
/**
|
936 |
* Copies CSS properties from one element to another.
|
937 |
*
|
@@ -950,7 +998,7 @@
|
|
950 |
}
|
951 |
$to.css(styles);
|
952 |
};
|
953 |
-
|
954 |
/**
|
955 |
* Measures the width of a string within a
|
956 |
* parent element (in pixels).
|
@@ -963,30 +1011,36 @@
|
|
963 |
if (!str) {
|
964 |
return 0;
|
965 |
}
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
'letterSpacing',
|
978 |
'fontSize',
|
979 |
'fontFamily',
|
980 |
'fontWeight',
|
981 |
'textTransform'
|
982 |
]);
|
983 |
-
|
984 |
-
|
985 |
-
$test.remove();
|
986 |
-
|
987 |
-
return width;
|
988 |
};
|
989 |
-
|
990 |
/**
|
991 |
* Sets up an input to grow horizontally as the user
|
992 |
* types. If the value is changed manually, you can
|
@@ -998,26 +1052,27 @@
|
|
998 |
*/
|
999 |
var autoGrow = function($input) {
|
1000 |
var currentWidth = null;
|
1001 |
-
|
1002 |
var update = function(e, options) {
|
1003 |
var value, keyCode, printable, placeholder, width;
|
1004 |
var shift, character, selection;
|
1005 |
e = e || window.event || {};
|
1006 |
options = options || {};
|
1007 |
-
|
1008 |
if (e.metaKey || e.altKey) return;
|
1009 |
if (!options.force && $input.data('grow') === false) return;
|
1010 |
-
|
1011 |
value = $input.val();
|
1012 |
if (e.type && e.type.toLowerCase() === 'keydown') {
|
1013 |
keyCode = e.keyCode;
|
1014 |
printable = (
|
1015 |
-
(keyCode >= 97 && keyCode <= 122) || // a-z
|
1016 |
-
(keyCode >= 65 && keyCode <= 90) || // A-Z
|
1017 |
(keyCode >= 48 && keyCode <= 57) || // 0-9
|
|
|
|
|
|
|
1018 |
keyCode === 32 // space
|
1019 |
);
|
1020 |
-
|
1021 |
if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
|
1022 |
selection = getSelection($input[0]);
|
1023 |
if (selection.length) {
|
@@ -1035,12 +1090,12 @@
|
|
1035 |
value += character;
|
1036 |
}
|
1037 |
}
|
1038 |
-
|
1039 |
placeholder = $input.attr('placeholder');
|
1040 |
if (!value && placeholder) {
|
1041 |
value = placeholder;
|
1042 |
}
|
1043 |
-
|
1044 |
width = measureString(value, $input) + 4;
|
1045 |
if (width !== currentWidth) {
|
1046 |
currentWidth = width;
|
@@ -1048,21 +1103,44 @@
|
|
1048 |
$input.triggerHandler('resize');
|
1049 |
}
|
1050 |
};
|
1051 |
-
|
1052 |
$input.on('keydown keyup update blur', update);
|
1053 |
update();
|
1054 |
};
|
1055 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1056 |
var Selectize = function($input, settings) {
|
1057 |
var key, i, n, dir, input, self = this;
|
1058 |
input = $input[0];
|
1059 |
input.selectize = self;
|
1060 |
-
|
1061 |
// detect rtl environment
|
1062 |
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
|
1063 |
dir = computedStyle ? computedStyle.getPropertyValue('direction') : input.currentStyle && input.currentStyle.direction;
|
1064 |
dir = dir || $input.parents('[dir]:first').attr('dir') || '';
|
1065 |
-
|
1066 |
// setup default state
|
1067 |
$.extend(self, {
|
1068 |
order : 0,
|
@@ -1071,9 +1149,10 @@
|
|
1071 |
tabIndex : $input.attr('tabindex') || '',
|
1072 |
tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
|
1073 |
rtl : /rtl/i.test(dir),
|
1074 |
-
|
1075 |
eventNS : '.selectize' + (++Selectize.count),
|
1076 |
highlightedValue : null,
|
|
|
1077 |
isOpen : false,
|
1078 |
isDisabled : false,
|
1079 |
isRequired : $input.is('[required]'),
|
@@ -1094,10 +1173,10 @@
|
|
1094 |
caretPos : 0,
|
1095 |
loading : 0,
|
1096 |
loadedSearches : {},
|
1097 |
-
|
1098 |
$activeOption : null,
|
1099 |
$activeItems : [],
|
1100 |
-
|
1101 |
optgroups : {},
|
1102 |
options : {},
|
1103 |
userOptions : {},
|
@@ -1105,10 +1184,10 @@
|
|
1105 |
renderCache : {},
|
1106 |
onSearchChange : settings.loadThrottle === null ? self.onSearchChange : debounce(self.onSearchChange, settings.loadThrottle)
|
1107 |
});
|
1108 |
-
|
1109 |
// search system
|
1110 |
self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
|
1111 |
-
|
1112 |
// build options table
|
1113 |
if (self.settings.options) {
|
1114 |
for (i = 0, n = self.settings.options.length; i < n; i++) {
|
@@ -1116,7 +1195,7 @@
|
|
1116 |
}
|
1117 |
delete self.settings.options;
|
1118 |
}
|
1119 |
-
|
1120 |
// build optgroup table
|
1121 |
if (self.settings.optgroups) {
|
1122 |
for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
|
@@ -1124,30 +1203,41 @@
|
|
1124 |
}
|
1125 |
delete self.settings.optgroups;
|
1126 |
}
|
1127 |
-
|
1128 |
// option-dependent defaults
|
1129 |
self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
|
1130 |
if (typeof self.settings.hideSelected !== 'boolean') {
|
1131 |
self.settings.hideSelected = self.settings.mode === 'multi';
|
1132 |
}
|
1133 |
-
|
1134 |
self.initializePlugins(self.settings.plugins);
|
1135 |
self.setupCallbacks();
|
1136 |
self.setupTemplates();
|
1137 |
self.setup();
|
1138 |
};
|
1139 |
-
|
1140 |
// mixins
|
1141 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1142 |
-
|
1143 |
MicroEvent.mixin(Selectize);
|
1144 |
-
|
1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
// methods
|
1147 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1148 |
-
|
1149 |
$.extend(Selectize.prototype, {
|
1150 |
-
|
1151 |
/**
|
1152 |
* Creates all elements and sets up event bindings.
|
1153 |
*/
|
@@ -1158,7 +1248,7 @@
|
|
1158 |
var $window = $(window);
|
1159 |
var $document = $(document);
|
1160 |
var $input = self.$input;
|
1161 |
-
|
1162 |
var $wrapper;
|
1163 |
var $control;
|
1164 |
var $control_input;
|
@@ -1170,69 +1260,77 @@
|
|
1170 |
var timeout_focus;
|
1171 |
var classes;
|
1172 |
var classes_plugins;
|
1173 |
-
|
|
|
1174 |
inputMode = self.settings.mode;
|
1175 |
classes = $input.attr('class') || '';
|
1176 |
-
|
1177 |
$wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
|
1178 |
$control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
|
1179 |
-
$control_input = $('<input type="text" autocomplete="
|
1180 |
$dropdown_parent = $(settings.dropdownParent || $wrapper);
|
1181 |
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
|
1182 |
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
|
1183 |
-
|
|
|
|
|
|
|
|
|
|
|
1184 |
if(self.settings.copyClassesToDropdown) {
|
1185 |
$dropdown.addClass(classes);
|
1186 |
}
|
1187 |
-
|
1188 |
$wrapper.css({
|
1189 |
width: $input[0].style.width
|
1190 |
});
|
1191 |
-
|
1192 |
if (self.plugins.names.length) {
|
1193 |
classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
|
1194 |
$wrapper.addClass(classes_plugins);
|
1195 |
$dropdown.addClass(classes_plugins);
|
1196 |
}
|
1197 |
-
|
1198 |
if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
|
1199 |
$input.attr('multiple', 'multiple');
|
1200 |
}
|
1201 |
-
|
1202 |
if (self.settings.placeholder) {
|
1203 |
$control_input.attr('placeholder', settings.placeholder);
|
1204 |
}
|
1205 |
-
|
1206 |
// if splitOn was not passed in, construct it from the delimiter to allow pasting universally
|
1207 |
if (!self.settings.splitOn && self.settings.delimiter) {
|
1208 |
var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
1209 |
self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
|
1210 |
}
|
1211 |
-
|
1212 |
if ($input.attr('autocorrect')) {
|
1213 |
$control_input.attr('autocorrect', $input.attr('autocorrect'));
|
1214 |
}
|
1215 |
-
|
1216 |
if ($input.attr('autocapitalize')) {
|
1217 |
$control_input.attr('autocapitalize', $input.attr('autocapitalize'));
|
1218 |
}
|
1219 |
-
|
|
|
1220 |
self.$wrapper = $wrapper;
|
1221 |
self.$control = $control;
|
1222 |
self.$control_input = $control_input;
|
1223 |
self.$dropdown = $dropdown;
|
1224 |
self.$dropdown_content = $dropdown_content;
|
1225 |
-
|
|
|
1226 |
$dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
|
1227 |
$dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
|
1228 |
watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
|
1229 |
autoGrow($control_input);
|
1230 |
-
|
1231 |
$control.on({
|
1232 |
mousedown : function() { return self.onMouseDown.apply(self, arguments); },
|
1233 |
click : function() { return self.onClick.apply(self, arguments); }
|
1234 |
});
|
1235 |
-
|
1236 |
$control_input.on({
|
1237 |
mousedown : function(e) { e.stopPropagation(); },
|
1238 |
keydown : function() { return self.onKeyDown.apply(self, arguments); },
|
@@ -1243,19 +1341,19 @@
|
|
1243 |
focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
|
1244 |
paste : function() { return self.onPaste.apply(self, arguments); }
|
1245 |
});
|
1246 |
-
|
1247 |
$document.on('keydown' + eventNS, function(e) {
|
1248 |
self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
|
1249 |
self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
|
1250 |
self.isShiftDown = e.shiftKey;
|
1251 |
});
|
1252 |
-
|
1253 |
$document.on('keyup' + eventNS, function(e) {
|
1254 |
if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
|
1255 |
if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
|
1256 |
if (e.keyCode === KEY_CMD) self.isCmdDown = false;
|
1257 |
});
|
1258 |
-
|
1259 |
$document.on('mousedown' + eventNS, function(e) {
|
1260 |
if (self.isFocused) {
|
1261 |
// prevent events on the dropdown scrollbar from causing the control to blur
|
@@ -1268,7 +1366,7 @@
|
|
1268 |
}
|
1269 |
}
|
1270 |
});
|
1271 |
-
|
1272 |
$window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function() {
|
1273 |
if (self.isOpen) {
|
1274 |
self.positionDropdown.apply(self, arguments);
|
@@ -1277,21 +1375,21 @@
|
|
1277 |
$window.on('mousemove' + eventNS, function() {
|
1278 |
self.ignoreHover = false;
|
1279 |
});
|
1280 |
-
|
1281 |
// store original children and tab index so that they can be
|
1282 |
// restored when the destroy() method is called.
|
1283 |
this.revertSettings = {
|
1284 |
$children : $input.children().detach(),
|
1285 |
tabindex : $input.attr('tabindex')
|
1286 |
};
|
1287 |
-
|
1288 |
$input.attr('tabindex', -1).hide().after(self.$wrapper);
|
1289 |
-
|
1290 |
if ($.isArray(settings.items)) {
|
1291 |
self.setValue(settings.items);
|
1292 |
delete settings.items;
|
1293 |
}
|
1294 |
-
|
1295 |
// feature detect for the validation API
|
1296 |
if (SUPPORTS_VALIDITY_API) {
|
1297 |
$input.on('invalid' + eventNS, function(e) {
|
@@ -1300,30 +1398,30 @@
|
|
1300 |
self.refreshState();
|
1301 |
});
|
1302 |
}
|
1303 |
-
|
1304 |
self.updateOriginalInput();
|
1305 |
self.refreshItems();
|
1306 |
self.refreshState();
|
1307 |
self.updatePlaceholder();
|
1308 |
self.isSetup = true;
|
1309 |
-
|
1310 |
if ($input.is(':disabled')) {
|
1311 |
self.disable();
|
1312 |
}
|
1313 |
-
|
1314 |
self.on('change', this.onChange);
|
1315 |
-
|
1316 |
$input.data('selectize', self);
|
1317 |
$input.addClass('selectized');
|
1318 |
self.trigger('initialize');
|
1319 |
-
|
1320 |
// preload options
|
1321 |
if (settings.preload === true) {
|
1322 |
self.onSearchChange('');
|
1323 |
}
|
1324 |
-
|
1325 |
},
|
1326 |
-
|
1327 |
/**
|
1328 |
* Sets up default rendering functions.
|
1329 |
*/
|
@@ -1331,7 +1429,7 @@
|
|
1331 |
var self = this;
|
1332 |
var field_label = self.settings.labelField;
|
1333 |
var field_optgroup = self.settings.optgroupLabelField;
|
1334 |
-
|
1335 |
var templates = {
|
1336 |
'optgroup': function(data) {
|
1337 |
return '<div class="optgroup">' + data.html + '</div>';
|
@@ -1349,10 +1447,10 @@
|
|
1349 |
return '<div class="create">Add <strong>' + escape(data.input) + '</strong>…</div>';
|
1350 |
}
|
1351 |
};
|
1352 |
-
|
1353 |
self.settings.render = $.extend({}, templates, self.settings.render);
|
1354 |
},
|
1355 |
-
|
1356 |
/**
|
1357 |
* Maps fired events to callbacks provided
|
1358 |
* in the settings used when creating the control.
|
@@ -1375,9 +1473,11 @@
|
|
1375 |
'type' : 'onType',
|
1376 |
'load' : 'onLoad',
|
1377 |
'focus' : 'onFocus',
|
1378 |
-
'blur' : 'onBlur'
|
|
|
|
|
1379 |
};
|
1380 |
-
|
1381 |
for (key in callbacks) {
|
1382 |
if (callbacks.hasOwnProperty(key)) {
|
1383 |
fn = this.settings[callbacks[key]];
|
@@ -1385,7 +1485,7 @@
|
|
1385 |
}
|
1386 |
}
|
1387 |
},
|
1388 |
-
|
1389 |
/**
|
1390 |
* Triggered when the main control element
|
1391 |
* has a click event.
|
@@ -1395,15 +1495,17 @@
|
|
1395 |
*/
|
1396 |
onClick: function(e) {
|
1397 |
var self = this;
|
1398 |
-
|
1399 |
// necessary for mobile webkit devices (manual focus triggering
|
1400 |
// is ignored unless invoked within a click event)
|
1401 |
-
|
|
|
|
|
1402 |
self.focus();
|
1403 |
e.preventDefault();
|
1404 |
}
|
1405 |
},
|
1406 |
-
|
1407 |
/**
|
1408 |
* Triggered when the main control element
|
1409 |
* has a mouse down event.
|
@@ -1415,7 +1517,7 @@
|
|
1415 |
var self = this;
|
1416 |
var defaultPrevented = e.isDefaultPrevented();
|
1417 |
var $target = $(e.target);
|
1418 |
-
|
1419 |
if (self.isFocused) {
|
1420 |
// retain focus by preventing native handling. if the
|
1421 |
// event target is the input it should not be modified.
|
@@ -1438,7 +1540,7 @@
|
|
1438 |
}
|
1439 |
}
|
1440 |
},
|
1441 |
-
|
1442 |
/**
|
1443 |
* Triggered when the value of the control has been changed.
|
1444 |
* This should propagate the event to the original DOM
|
@@ -1447,7 +1549,7 @@
|
|
1447 |
onChange: function() {
|
1448 |
this.$input.trigger('change');
|
1449 |
},
|
1450 |
-
|
1451 |
/**
|
1452 |
* Triggered on <input> paste.
|
1453 |
*
|
@@ -1456,22 +1558,29 @@
|
|
1456 |
*/
|
1457 |
onPaste: function(e) {
|
1458 |
var self = this;
|
|
|
1459 |
if (self.isFull() || self.isInputHidden || self.isLocked) {
|
1460 |
e.preventDefault();
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1472 |
}
|
1473 |
},
|
1474 |
-
|
1475 |
/**
|
1476 |
* Triggered on <input> keypress.
|
1477 |
*
|
@@ -1487,7 +1596,7 @@
|
|
1487 |
return false;
|
1488 |
}
|
1489 |
},
|
1490 |
-
|
1491 |
/**
|
1492 |
* Triggered on <input> keydown.
|
1493 |
*
|
@@ -1497,14 +1606,14 @@
|
|
1497 |
onKeyDown: function(e) {
|
1498 |
var isInput = e.target === this.$control_input[0];
|
1499 |
var self = this;
|
1500 |
-
|
1501 |
if (self.isLocked) {
|
1502 |
if (e.keyCode !== KEY_TAB) {
|
1503 |
e.preventDefault();
|
1504 |
}
|
1505 |
return;
|
1506 |
}
|
1507 |
-
|
1508 |
switch (e.keyCode) {
|
1509 |
case KEY_A:
|
1510 |
if (self.isCmdDown) {
|
@@ -1556,7 +1665,7 @@
|
|
1556 |
case KEY_TAB:
|
1557 |
if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
|
1558 |
self.onOptionSelect({currentTarget: self.$activeOption});
|
1559 |
-
|
1560 |
// Default behaviour is to jump to the next field, we only want this
|
1561 |
// if the current field doesn't accept any more entries
|
1562 |
if (!self.isFull()) {
|
@@ -1572,13 +1681,13 @@
|
|
1572 |
self.deleteSelection(e);
|
1573 |
return;
|
1574 |
}
|
1575 |
-
|
1576 |
if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
|
1577 |
e.preventDefault();
|
1578 |
return;
|
1579 |
}
|
1580 |
},
|
1581 |
-
|
1582 |
/**
|
1583 |
* Triggered on <input> keyup.
|
1584 |
*
|
@@ -1587,7 +1696,7 @@
|
|
1587 |
*/
|
1588 |
onKeyUp: function(e) {
|
1589 |
var self = this;
|
1590 |
-
|
1591 |
if (self.isLocked) return e && e.preventDefault();
|
1592 |
var value = self.$control_input.val() || '';
|
1593 |
if (self.lastValue !== value) {
|
@@ -1597,12 +1706,12 @@
|
|
1597 |
self.trigger('type', value);
|
1598 |
}
|
1599 |
},
|
1600 |
-
|
1601 |
/**
|
1602 |
* Invokes the user-provide option provider / loader.
|
1603 |
*
|
1604 |
* Note: this function is debounced in the Selectize
|
1605 |
-
* constructor (by `settings.
|
1606 |
*
|
1607 |
* @param {string} value
|
1608 |
*/
|
@@ -1616,7 +1725,7 @@
|
|
1616 |
fn.apply(self, [value, callback]);
|
1617 |
});
|
1618 |
},
|
1619 |
-
|
1620 |
/**
|
1621 |
* Triggered on <input> focus.
|
1622 |
*
|
@@ -1626,28 +1735,28 @@
|
|
1626 |
onFocus: function(e) {
|
1627 |
var self = this;
|
1628 |
var wasFocused = self.isFocused;
|
1629 |
-
|
1630 |
if (self.isDisabled) {
|
1631 |
self.blur();
|
1632 |
e && e.preventDefault();
|
1633 |
return false;
|
1634 |
}
|
1635 |
-
|
1636 |
if (self.ignoreFocus) return;
|
1637 |
self.isFocused = true;
|
1638 |
if (self.settings.preload === 'focus') self.onSearchChange('');
|
1639 |
-
|
1640 |
if (!wasFocused) self.trigger('focus');
|
1641 |
-
|
1642 |
if (!self.$activeItems.length) {
|
1643 |
self.showInput();
|
1644 |
self.setActiveItem(null);
|
1645 |
self.refreshOptions(!!self.settings.openOnFocus);
|
1646 |
}
|
1647 |
-
|
1648 |
self.refreshState();
|
1649 |
},
|
1650 |
-
|
1651 |
/**
|
1652 |
* Triggered on <input> blur.
|
1653 |
*
|
@@ -1658,7 +1767,7 @@
|
|
1658 |
var self = this;
|
1659 |
if (!self.isFocused) return;
|
1660 |
self.isFocused = false;
|
1661 |
-
|
1662 |
if (self.ignoreFocus) {
|
1663 |
return;
|
1664 |
} else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
|
@@ -1667,7 +1776,7 @@
|
|
1667 |
self.onFocus(e);
|
1668 |
return;
|
1669 |
}
|
1670 |
-
|
1671 |
var deactivate = function() {
|
1672 |
self.close();
|
1673 |
self.setTextboxValue('');
|
@@ -1675,14 +1784,16 @@
|
|
1675 |
self.setActiveOption(null);
|
1676 |
self.setCaret(self.items.length);
|
1677 |
self.refreshState();
|
1678 |
-
|
1679 |
// IE11 bug: element still marked as active
|
1680 |
-
|
1681 |
-
|
|
|
1682 |
self.ignoreFocus = false;
|
1683 |
self.trigger('blur');
|
1684 |
};
|
1685 |
-
|
|
|
1686 |
self.ignoreFocus = true;
|
1687 |
if (self.settings.create && self.settings.createOnBlur) {
|
1688 |
self.createItem(null, false, deactivate);
|
@@ -1690,7 +1801,7 @@
|
|
1690 |
deactivate();
|
1691 |
}
|
1692 |
},
|
1693 |
-
|
1694 |
/**
|
1695 |
* Triggered when the user rolls over
|
1696 |
* an option in the autocomplete dropdown menu.
|
@@ -1702,7 +1813,7 @@
|
|
1702 |
if (this.ignoreHover) return;
|
1703 |
this.setActiveOption(e.currentTarget, false);
|
1704 |
},
|
1705 |
-
|
1706 |
/**
|
1707 |
* Triggered when the user clicks on an option
|
1708 |
* in the autocomplete dropdown menu.
|
@@ -1712,12 +1823,12 @@
|
|
1712 |
*/
|
1713 |
onOptionSelect: function(e) {
|
1714 |
var value, $target, $option, self = this;
|
1715 |
-
|
1716 |
if (e.preventDefault) {
|
1717 |
e.preventDefault();
|
1718 |
e.stopPropagation();
|
1719 |
}
|
1720 |
-
|
1721 |
$target = $(e.currentTarget);
|
1722 |
if ($target.hasClass('create')) {
|
1723 |
self.createItem(null, function() {
|
@@ -1739,7 +1850,7 @@
|
|
1739 |
}
|
1740 |
}
|
1741 |
},
|
1742 |
-
|
1743 |
/**
|
1744 |
* Triggered when the user clicks on an item
|
1745 |
* that has been selected.
|
@@ -1749,14 +1860,14 @@
|
|
1749 |
*/
|
1750 |
onItemSelect: function(e) {
|
1751 |
var self = this;
|
1752 |
-
|
1753 |
if (self.isLocked) return;
|
1754 |
if (self.settings.mode === 'multi') {
|
1755 |
e.preventDefault();
|
1756 |
self.setActiveItem(e.currentTarget, e);
|
1757 |
}
|
1758 |
},
|
1759 |
-
|
1760 |
/**
|
1761 |
* Invokes the provided method that provides
|
1762 |
* results to a callback---which are then added
|
@@ -1767,7 +1878,7 @@
|
|
1767 |
load: function(fn) {
|
1768 |
var self = this;
|
1769 |
var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
|
1770 |
-
|
1771 |
self.loading++;
|
1772 |
fn.apply(self, [function(results) {
|
1773 |
self.loading = Math.max(self.loading - 1, 0);
|
@@ -1781,7 +1892,7 @@
|
|
1781 |
self.trigger('load', results);
|
1782 |
}]);
|
1783 |
},
|
1784 |
-
|
1785 |
/**
|
1786 |
* Sets the input field of the control to the specified value.
|
1787 |
*
|
@@ -1795,7 +1906,7 @@
|
|
1795 |
this.lastValue = value;
|
1796 |
}
|
1797 |
},
|
1798 |
-
|
1799 |
/**
|
1800 |
* Returns the value of the control. If multiple items
|
1801 |
* can be selected (e.g. <select multiple>), this returns
|
@@ -1811,7 +1922,7 @@
|
|
1811 |
return this.items.join(this.settings.delimiter);
|
1812 |
}
|
1813 |
},
|
1814 |
-
|
1815 |
/**
|
1816 |
* Resets the selected items to the given value.
|
1817 |
*
|
@@ -1819,13 +1930,25 @@
|
|
1819 |
*/
|
1820 |
setValue: function(value, silent) {
|
1821 |
var events = silent ? [] : ['change'];
|
1822 |
-
|
1823 |
debounce_events(this, events, function() {
|
1824 |
this.clear(silent);
|
1825 |
this.addItems(value, silent);
|
1826 |
});
|
1827 |
},
|
1828 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1829 |
/**
|
1830 |
* Sets the selected item.
|
1831 |
*
|
@@ -1837,10 +1960,10 @@
|
|
1837 |
var eventName;
|
1838 |
var i, idx, begin, end, item, swap;
|
1839 |
var $last;
|
1840 |
-
|
1841 |
if (self.settings.mode === 'single') return;
|
1842 |
$item = $($item);
|
1843 |
-
|
1844 |
// clear the active selection
|
1845 |
if (!$item.length) {
|
1846 |
$(self.$activeItems).removeClass('active');
|
@@ -1850,10 +1973,10 @@
|
|
1850 |
}
|
1851 |
return;
|
1852 |
}
|
1853 |
-
|
1854 |
// modify selection
|
1855 |
eventName = e && e.type.toLowerCase();
|
1856 |
-
|
1857 |
if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
|
1858 |
$last = self.$control.children('.active:last');
|
1859 |
begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
|
@@ -1883,14 +2006,14 @@
|
|
1883 |
$(self.$activeItems).removeClass('active');
|
1884 |
self.$activeItems = [$item.addClass('active')[0]];
|
1885 |
}
|
1886 |
-
|
1887 |
// ensure control has focus
|
1888 |
self.hideInput();
|
1889 |
if (!this.isFocused) {
|
1890 |
self.focus();
|
1891 |
}
|
1892 |
},
|
1893 |
-
|
1894 |
/**
|
1895 |
* Sets the selected item in the dropdown menu
|
1896 |
* of available options.
|
@@ -1903,40 +2026,44 @@
|
|
1903 |
var height_menu, height_item, y;
|
1904 |
var scroll_top, scroll_bottom;
|
1905 |
var self = this;
|
1906 |
-
|
1907 |
-
if (self.$activeOption)
|
|
|
|
|
|
|
1908 |
self.$activeOption = null;
|
1909 |
-
|
1910 |
$option = $($option);
|
1911 |
if (!$option.length) return;
|
1912 |
-
|
1913 |
self.$activeOption = $option.addClass('active');
|
1914 |
-
|
|
|
1915 |
if (scroll || !isset(scroll)) {
|
1916 |
-
|
1917 |
height_menu = self.$dropdown_content.height();
|
1918 |
height_item = self.$activeOption.outerHeight(true);
|
1919 |
scroll = self.$dropdown_content.scrollTop() || 0;
|
1920 |
y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
|
1921 |
scroll_top = y;
|
1922 |
scroll_bottom = y - height_menu + height_item;
|
1923 |
-
|
1924 |
if (y + height_item > height_menu + scroll) {
|
1925 |
self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
|
1926 |
} else if (y < scroll) {
|
1927 |
self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
|
1928 |
}
|
1929 |
-
|
1930 |
}
|
1931 |
},
|
1932 |
-
|
1933 |
/**
|
1934 |
* Selects all items (CTRL + A).
|
1935 |
*/
|
1936 |
selectAll: function() {
|
1937 |
var self = this;
|
1938 |
if (self.settings.mode === 'single') return;
|
1939 |
-
|
1940 |
self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
|
1941 |
if (self.$activeItems.length) {
|
1942 |
self.hideInput();
|
@@ -1944,19 +2071,19 @@
|
|
1944 |
}
|
1945 |
self.focus();
|
1946 |
},
|
1947 |
-
|
1948 |
/**
|
1949 |
* Hides the input element out of view, while
|
1950 |
* retaining its focus.
|
1951 |
*/
|
1952 |
hideInput: function() {
|
1953 |
var self = this;
|
1954 |
-
|
1955 |
self.setTextboxValue('');
|
1956 |
self.$control_input.css({opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000});
|
1957 |
self.isInputHidden = true;
|
1958 |
},
|
1959 |
-
|
1960 |
/**
|
1961 |
* Restores input visibility.
|
1962 |
*/
|
@@ -1964,14 +2091,14 @@
|
|
1964 |
this.$control_input.css({opacity: 1, position: 'relative', left: 0});
|
1965 |
this.isInputHidden = false;
|
1966 |
},
|
1967 |
-
|
1968 |
/**
|
1969 |
* Gives the control focus.
|
1970 |
*/
|
1971 |
focus: function() {
|
1972 |
var self = this;
|
1973 |
if (self.isDisabled) return;
|
1974 |
-
|
1975 |
self.ignoreFocus = true;
|
1976 |
self.$control_input[0].focus();
|
1977 |
window.setTimeout(function() {
|
@@ -1979,7 +2106,7 @@
|
|
1979 |
self.onFocus();
|
1980 |
}, 0);
|
1981 |
},
|
1982 |
-
|
1983 |
/**
|
1984 |
* Forces the control out of focus.
|
1985 |
*
|
@@ -1989,7 +2116,7 @@
|
|
1989 |
this.$control_input[0].blur();
|
1990 |
this.onBlur(null, dest);
|
1991 |
},
|
1992 |
-
|
1993 |
/**
|
1994 |
* Returns a function that scores an object
|
1995 |
* to show how good of a match it is to the
|
@@ -2002,7 +2129,7 @@
|
|
2002 |
getScoreFunction: function(query) {
|
2003 |
return this.sifter.getScoreFunction(query, this.getSearchOptions());
|
2004 |
},
|
2005 |
-
|
2006 |
/**
|
2007 |
* Returns search options for sifter (the system
|
2008 |
* for scoring and sorting results).
|
@@ -2016,14 +2143,15 @@
|
|
2016 |
if (typeof sort === 'string') {
|
2017 |
sort = [{field: sort}];
|
2018 |
}
|
2019 |
-
|
2020 |
return {
|
2021 |
fields : settings.searchField,
|
2022 |
conjunction : settings.searchConjunction,
|
2023 |
-
sort : sort
|
|
|
2024 |
};
|
2025 |
},
|
2026 |
-
|
2027 |
/**
|
2028 |
* Searches through available options and returns
|
2029 |
* a sorted array of matches.
|
@@ -2043,7 +2171,7 @@
|
|
2043 |
var self = this;
|
2044 |
var settings = self.settings;
|
2045 |
var options = this.getSearchOptions();
|
2046 |
-
|
2047 |
// validate user-provided result scoring function
|
2048 |
if (settings.score) {
|
2049 |
calculateScore = self.settings.score.apply(this, [query]);
|
@@ -2051,7 +2179,7 @@
|
|
2051 |
throw new Error('Selectize "score" setting must be a function that returns a function');
|
2052 |
}
|
2053 |
}
|
2054 |
-
|
2055 |
// perform search
|
2056 |
if (query !== self.lastQuery) {
|
2057 |
self.lastQuery = query;
|
@@ -2060,7 +2188,7 @@
|
|
2060 |
} else {
|
2061 |
result = $.extend(true, {}, self.currentResults);
|
2062 |
}
|
2063 |
-
|
2064 |
// filter out selected items
|
2065 |
if (settings.hideSelected) {
|
2066 |
for (i = result.items.length - 1; i >= 0; i--) {
|
@@ -2069,10 +2197,10 @@
|
|
2069 |
}
|
2070 |
}
|
2071 |
}
|
2072 |
-
|
2073 |
return result;
|
2074 |
},
|
2075 |
-
|
2076 |
/**
|
2077 |
* Refreshes the list of available options shown
|
2078 |
* in the autocomplete dropdown menu.
|
@@ -2082,46 +2210,46 @@
|
|
2082 |
refreshOptions: function(triggerDropdown) {
|
2083 |
var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
|
2084 |
var $active, $active_before, $create;
|
2085 |
-
|
2086 |
if (typeof triggerDropdown === 'undefined') {
|
2087 |
triggerDropdown = true;
|
2088 |
}
|
2089 |
-
|
2090 |
var self = this;
|
2091 |
var query = $.trim(self.$control_input.val());
|
2092 |
var results = self.search(query);
|
2093 |
var $dropdown_content = self.$dropdown_content;
|
2094 |
var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
|
2095 |
-
|
2096 |
// build markup
|
2097 |
n = results.items.length;
|
2098 |
if (typeof self.settings.maxOptions === 'number') {
|
2099 |
n = Math.min(n, self.settings.maxOptions);
|
2100 |
}
|
2101 |
-
|
2102 |
// render and group available options individually
|
2103 |
groups = {};
|
2104 |
groups_order = [];
|
2105 |
-
|
2106 |
for (i = 0; i < n; i++) {
|
2107 |
option = self.options[results.items[i].id];
|
2108 |
option_html = self.render('option', option);
|
2109 |
optgroup = option[self.settings.optgroupField] || '';
|
2110 |
optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
|
2111 |
-
|
2112 |
for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
|
2113 |
optgroup = optgroups[j];
|
2114 |
if (!self.optgroups.hasOwnProperty(optgroup)) {
|
2115 |
optgroup = '';
|
2116 |
}
|
2117 |
if (!groups.hasOwnProperty(optgroup)) {
|
2118 |
-
groups[optgroup] =
|
2119 |
groups_order.push(optgroup);
|
2120 |
}
|
2121 |
-
groups[optgroup].
|
2122 |
}
|
2123 |
}
|
2124 |
-
|
2125 |
// sort optgroups
|
2126 |
if (this.settings.lockOptgroupOrder) {
|
2127 |
groups_order.sort(function(a, b) {
|
@@ -2130,47 +2258,56 @@
|
|
2130 |
return a_order - b_order;
|
2131 |
});
|
2132 |
}
|
2133 |
-
|
2134 |
// render optgroup headers & join groups
|
2135 |
-
html =
|
2136 |
for (i = 0, n = groups_order.length; i < n; i++) {
|
2137 |
optgroup = groups_order[i];
|
2138 |
-
if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].length) {
|
2139 |
// render the optgroup header and options within it,
|
2140 |
// then pass it to the wrapper template
|
2141 |
-
html_children =
|
2142 |
-
html_children
|
2143 |
-
|
2144 |
-
|
|
|
|
|
|
|
2145 |
})));
|
2146 |
} else {
|
2147 |
-
html.
|
2148 |
}
|
2149 |
}
|
2150 |
-
|
2151 |
-
$dropdown_content.html(html
|
2152 |
-
|
2153 |
// highlight matching terms inline
|
2154 |
-
if (self.settings.highlight
|
2155 |
-
|
2156 |
-
|
|
|
|
|
|
|
2157 |
}
|
2158 |
}
|
2159 |
-
|
2160 |
// add "selected" class to selected options
|
2161 |
if (!self.settings.hideSelected) {
|
|
|
|
|
|
|
2162 |
for (i = 0, n = self.items.length; i < n; i++) {
|
2163 |
self.getOption(self.items[i]).addClass('selected');
|
2164 |
}
|
2165 |
}
|
2166 |
-
|
2167 |
// add create option
|
2168 |
has_create_option = self.canCreate(query);
|
2169 |
if (has_create_option) {
|
2170 |
$dropdown_content.prepend(self.render('option_create', {input: query}));
|
2171 |
$create = $($dropdown_content[0].childNodes[0]);
|
2172 |
}
|
2173 |
-
|
2174 |
// activate
|
2175 |
self.hasOptions = results.items.length > 0 || has_create_option;
|
2176 |
if (self.hasOptions) {
|
@@ -2198,7 +2335,7 @@
|
|
2198 |
if (triggerDropdown && self.isOpen) { self.close(); }
|
2199 |
}
|
2200 |
},
|
2201 |
-
|
2202 |
/**
|
2203 |
* Adds an available option. If it already exists,
|
2204 |
* nothing will happen. Note: this does not refresh
|
@@ -2213,21 +2350,21 @@
|
|
2213 |
*/
|
2214 |
addOption: function(data) {
|
2215 |
var i, n, value, self = this;
|
2216 |
-
|
2217 |
if ($.isArray(data)) {
|
2218 |
for (i = 0, n = data.length; i < n; i++) {
|
2219 |
self.addOption(data[i]);
|
2220 |
}
|
2221 |
return;
|
2222 |
}
|
2223 |
-
|
2224 |
if (value = self.registerOption(data)) {
|
2225 |
self.userOptions[value] = true;
|
2226 |
self.lastQuery = null;
|
2227 |
self.trigger('option_add', value, data);
|
2228 |
}
|
2229 |
},
|
2230 |
-
|
2231 |
/**
|
2232 |
* Registers an option to the pool of options.
|
2233 |
*
|
@@ -2236,12 +2373,12 @@
|
|
2236 |
*/
|
2237 |
registerOption: function(data) {
|
2238 |
var key = hash_key(data[this.settings.valueField]);
|
2239 |
-
if (
|
2240 |
data.$order = data.$order || ++this.order;
|
2241 |
this.options[key] = data;
|
2242 |
return key;
|
2243 |
},
|
2244 |
-
|
2245 |
/**
|
2246 |
* Registers an option group to the pool of option groups.
|
2247 |
*
|
@@ -2251,12 +2388,12 @@
|
|
2251 |
registerOptionGroup: function(data) {
|
2252 |
var key = hash_key(data[this.settings.optgroupValueField]);
|
2253 |
if (!key) return false;
|
2254 |
-
|
2255 |
data.$order = data.$order || ++this.order;
|
2256 |
this.optgroups[key] = data;
|
2257 |
return key;
|
2258 |
},
|
2259 |
-
|
2260 |
/**
|
2261 |
* Registers a new optgroup for options
|
2262 |
* to be bucketed into.
|
@@ -2270,7 +2407,7 @@
|
|
2270 |
this.trigger('optgroup_add', id, data);
|
2271 |
}
|
2272 |
},
|
2273 |
-
|
2274 |
/**
|
2275 |
* Removes an existing option group.
|
2276 |
*
|
@@ -2283,7 +2420,7 @@
|
|
2283 |
this.trigger('optgroup_remove', id);
|
2284 |
}
|
2285 |
},
|
2286 |
-
|
2287 |
/**
|
2288 |
* Clears all existing option groups.
|
2289 |
*/
|
@@ -2292,7 +2429,7 @@
|
|
2292 |
this.renderCache = {};
|
2293 |
this.trigger('optgroup_clear');
|
2294 |
},
|
2295 |
-
|
2296 |
/**
|
2297 |
* Updates an option available for selection. If
|
2298 |
* it is visible in the selected items or options
|
@@ -2305,17 +2442,17 @@
|
|
2305 |
var self = this;
|
2306 |
var $item, $item_new;
|
2307 |
var value_new, index_item, cache_items, cache_options, order_old;
|
2308 |
-
|
2309 |
value = hash_key(value);
|
2310 |
value_new = hash_key(data[self.settings.valueField]);
|
2311 |
-
|
2312 |
// sanity checks
|
2313 |
if (value === null) return;
|
2314 |
if (!self.options.hasOwnProperty(value)) return;
|
2315 |
if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
|
2316 |
-
|
2317 |
order_old = self.options[value].$order;
|
2318 |
-
|
2319 |
// update references
|
2320 |
if (value_new !== value) {
|
2321 |
delete self.options[value];
|
@@ -2326,11 +2463,11 @@
|
|
2326 |
}
|
2327 |
data.$order = data.$order || order_old;
|
2328 |
self.options[value_new] = data;
|
2329 |
-
|
2330 |
// invalidate render cache
|
2331 |
cache_items = self.renderCache['item'];
|
2332 |
cache_options = self.renderCache['option'];
|
2333 |
-
|
2334 |
if (cache_items) {
|
2335 |
delete cache_items[value];
|
2336 |
delete cache_items[value_new];
|
@@ -2339,7 +2476,7 @@
|
|
2339 |
delete cache_options[value];
|
2340 |
delete cache_options[value_new];
|
2341 |
}
|
2342 |
-
|
2343 |
// update the item if it's selected
|
2344 |
if (self.items.indexOf(value_new) !== -1) {
|
2345 |
$item = self.getItem(value);
|
@@ -2347,16 +2484,16 @@
|
|
2347 |
if ($item.hasClass('active')) $item_new.addClass('active');
|
2348 |
$item.replaceWith($item_new);
|
2349 |
}
|
2350 |
-
|
2351 |
// invalidate last query because we might have updated the sortField
|
2352 |
self.lastQuery = null;
|
2353 |
-
|
2354 |
// update dropdown contents
|
2355 |
if (self.isOpen) {
|
2356 |
self.refreshOptions(false);
|
2357 |
}
|
2358 |
},
|
2359 |
-
|
2360 |
/**
|
2361 |
* Removes a single option.
|
2362 |
*
|
@@ -2366,34 +2503,42 @@
|
|
2366 |
removeOption: function(value, silent) {
|
2367 |
var self = this;
|
2368 |
value = hash_key(value);
|
2369 |
-
|
2370 |
var cache_items = self.renderCache['item'];
|
2371 |
var cache_options = self.renderCache['option'];
|
2372 |
if (cache_items) delete cache_items[value];
|
2373 |
if (cache_options) delete cache_options[value];
|
2374 |
-
|
2375 |
delete self.userOptions[value];
|
2376 |
delete self.options[value];
|
2377 |
self.lastQuery = null;
|
2378 |
self.trigger('option_remove', value);
|
2379 |
self.removeItem(value, silent);
|
2380 |
},
|
2381 |
-
|
2382 |
/**
|
2383 |
* Clears all options.
|
|
|
|
|
2384 |
*/
|
2385 |
-
clearOptions: function() {
|
2386 |
var self = this;
|
2387 |
-
|
2388 |
self.loadedSearches = {};
|
2389 |
self.userOptions = {};
|
2390 |
self.renderCache = {};
|
2391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2392 |
self.lastQuery = null;
|
2393 |
self.trigger('option_clear');
|
2394 |
-
self.clear();
|
2395 |
},
|
2396 |
-
|
2397 |
/**
|
2398 |
* Returns the jQuery element of the option
|
2399 |
* matching the given value.
|
@@ -2404,7 +2549,7 @@
|
|
2404 |
getOption: function(value) {
|
2405 |
return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
|
2406 |
},
|
2407 |
-
|
2408 |
/**
|
2409 |
* Returns the jQuery element of the next or
|
2410 |
* previous selectable option.
|
@@ -2416,10 +2561,10 @@
|
|
2416 |
getAdjacentOption: function($option, direction) {
|
2417 |
var $options = this.$dropdown.find('[data-selectable]');
|
2418 |
var index = $options.index($option) + direction;
|
2419 |
-
|
2420 |
return index >= 0 && index < $options.length ? $options.eq(index) : $();
|
2421 |
},
|
2422 |
-
|
2423 |
/**
|
2424 |
* Finds the first element with a "data-value" attribute
|
2425 |
* that matches the given value.
|
@@ -2430,7 +2575,7 @@
|
|
2430 |
*/
|
2431 |
getElementWithValue: function(value, $els) {
|
2432 |
value = hash_key(value);
|
2433 |
-
|
2434 |
if (typeof value !== 'undefined' && value !== null) {
|
2435 |
for (var i = 0, n = $els.length; i < n; i++) {
|
2436 |
if ($els[i].getAttribute('data-value') === value) {
|
@@ -2438,10 +2583,10 @@
|
|
2438 |
}
|
2439 |
}
|
2440 |
}
|
2441 |
-
|
2442 |
return $();
|
2443 |
},
|
2444 |
-
|
2445 |
/**
|
2446 |
* Returns the jQuery element of the item
|
2447 |
* matching the given value.
|
@@ -2452,7 +2597,7 @@
|
|
2452 |
getItem: function(value) {
|
2453 |
return this.getElementWithValue(value, this.$control.children());
|
2454 |
},
|
2455 |
-
|
2456 |
/**
|
2457 |
* "Selects" multiple items at once. Adds them to the list
|
2458 |
* at the current caret position.
|
@@ -2461,13 +2606,25 @@
|
|
2461 |
* @param {boolean} silent
|
2462 |
*/
|
2463 |
addItems: function(values, silent) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2464 |
var items = $.isArray(values) ? values : [values];
|
2465 |
for (var i = 0, n = items.length; i < n; i++) {
|
2466 |
this.isPending = (i < n - 1);
|
2467 |
this.addItem(items[i], silent);
|
2468 |
}
|
|
|
|
|
|
|
|
|
|
|
2469 |
},
|
2470 |
-
|
2471 |
/**
|
2472 |
* "Selects" an item. Adds it to the list
|
2473 |
* at the current caret position.
|
@@ -2477,23 +2634,23 @@
|
|
2477 |
*/
|
2478 |
addItem: function(value, silent) {
|
2479 |
var events = silent ? [] : ['change'];
|
2480 |
-
|
2481 |
debounce_events(this, events, function() {
|
2482 |
var $item, $option, $options;
|
2483 |
var self = this;
|
2484 |
var inputMode = self.settings.mode;
|
2485 |
var i, active, value_next, wasFull;
|
2486 |
value = hash_key(value);
|
2487 |
-
|
2488 |
if (self.items.indexOf(value) !== -1) {
|
2489 |
if (inputMode === 'single') self.close();
|
2490 |
return;
|
2491 |
}
|
2492 |
-
|
2493 |
if (!self.options.hasOwnProperty(value)) return;
|
2494 |
if (inputMode === 'single') self.clear(silent);
|
2495 |
if (inputMode === 'multi' && self.isFull()) return;
|
2496 |
-
|
2497 |
$item = $(self.render('item', self.options[value]));
|
2498 |
wasFull = self.isFull();
|
2499 |
self.items.splice(self.caretPos, 0, value);
|
@@ -2501,10 +2658,10 @@
|
|
2501 |
if (!self.isPending || (!wasFull && self.isFull())) {
|
2502 |
self.refreshState();
|
2503 |
}
|
2504 |
-
|
2505 |
if (self.isSetup) {
|
2506 |
$options = self.$dropdown_content.find('[data-selectable]');
|
2507 |
-
|
2508 |
// update menu / remove the option (if this is not one item being added as part of series)
|
2509 |
if (!self.isPending) {
|
2510 |
$option = self.getOption(value);
|
@@ -2514,21 +2671,24 @@
|
|
2514 |
self.setActiveOption(self.getOption(value_next));
|
2515 |
}
|
2516 |
}
|
2517 |
-
|
2518 |
// hide the menu if the maximum number of items have been selected or no options are left
|
2519 |
if (!$options.length || self.isFull()) {
|
2520 |
self.close();
|
2521 |
-
} else {
|
2522 |
self.positionDropdown();
|
2523 |
}
|
2524 |
-
|
2525 |
self.updatePlaceholder();
|
2526 |
self.trigger('item_add', value, $item);
|
2527 |
-
|
|
|
|
|
|
|
2528 |
}
|
2529 |
});
|
2530 |
},
|
2531 |
-
|
2532 |
/**
|
2533 |
* Removes the selected item matching
|
2534 |
* the provided value.
|
@@ -2538,28 +2698,28 @@
|
|
2538 |
removeItem: function(value, silent) {
|
2539 |
var self = this;
|
2540 |
var $item, i, idx;
|
2541 |
-
|
2542 |
-
$item = (
|
2543 |
value = hash_key($item.attr('data-value'));
|
2544 |
i = self.items.indexOf(value);
|
2545 |
-
|
2546 |
if (i !== -1) {
|
2547 |
$item.remove();
|
2548 |
if ($item.hasClass('active')) {
|
2549 |
idx = self.$activeItems.indexOf($item[0]);
|
2550 |
self.$activeItems.splice(idx, 1);
|
2551 |
}
|
2552 |
-
|
2553 |
self.items.splice(i, 1);
|
2554 |
self.lastQuery = null;
|
2555 |
if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
|
2556 |
self.removeOption(value, silent);
|
2557 |
}
|
2558 |
-
|
2559 |
if (i < self.caretPos) {
|
2560 |
self.setCaret(self.caretPos - 1);
|
2561 |
}
|
2562 |
-
|
2563 |
self.refreshState();
|
2564 |
self.updatePlaceholder();
|
2565 |
self.updateOriginalInput({silent: silent});
|
@@ -2567,7 +2727,7 @@
|
|
2567 |
self.trigger('item_remove', value, $item);
|
2568 |
}
|
2569 |
},
|
2570 |
-
|
2571 |
/**
|
2572 |
* Invokes the `create` method provided in the
|
2573 |
* selectize options that should provide the data
|
@@ -2585,35 +2745,35 @@
|
|
2585 |
var self = this;
|
2586 |
var caret = self.caretPos;
|
2587 |
input = input || $.trim(self.$control_input.val() || '');
|
2588 |
-
|
2589 |
var callback = arguments[arguments.length - 1];
|
2590 |
if (typeof callback !== 'function') callback = function() {};
|
2591 |
-
|
2592 |
if (typeof triggerDropdown !== 'boolean') {
|
2593 |
triggerDropdown = true;
|
2594 |
}
|
2595 |
-
|
2596 |
if (!self.canCreate(input)) {
|
2597 |
callback();
|
2598 |
return false;
|
2599 |
}
|
2600 |
-
|
2601 |
self.lock();
|
2602 |
-
|
2603 |
var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
|
2604 |
var data = {};
|
2605 |
data[self.settings.labelField] = input;
|
2606 |
data[self.settings.valueField] = input;
|
2607 |
return data;
|
2608 |
};
|
2609 |
-
|
2610 |
var create = once(function(data) {
|
2611 |
self.unlock();
|
2612 |
-
|
2613 |
if (!data || typeof data !== 'object') return callback();
|
2614 |
var value = hash_key(data[self.settings.valueField]);
|
2615 |
if (typeof value !== 'string') return callback();
|
2616 |
-
|
2617 |
self.setTextboxValue('');
|
2618 |
self.addOption(data);
|
2619 |
self.setCaret(caret);
|
@@ -2621,42 +2781,56 @@
|
|
2621 |
self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
|
2622 |
callback(data);
|
2623 |
});
|
2624 |
-
|
2625 |
var output = setup.apply(this, [input, create]);
|
2626 |
if (typeof output !== 'undefined') {
|
2627 |
create(output);
|
2628 |
}
|
2629 |
-
|
2630 |
return true;
|
2631 |
},
|
2632 |
-
|
2633 |
/**
|
2634 |
* Re-renders the selected item lists.
|
2635 |
*/
|
2636 |
refreshItems: function() {
|
2637 |
this.lastQuery = null;
|
2638 |
-
|
2639 |
if (this.isSetup) {
|
2640 |
this.addItem(this.items);
|
2641 |
}
|
2642 |
-
|
2643 |
this.refreshState();
|
2644 |
this.updateOriginalInput();
|
2645 |
},
|
2646 |
-
|
2647 |
/**
|
2648 |
* Updates all state-dependent attributes
|
2649 |
* and CSS classes.
|
2650 |
*/
|
2651 |
refreshState: function() {
|
2652 |
-
|
2653 |
-
|
2654 |
-
if (self.items.length) self.isInvalid = false;
|
2655 |
-
self.$control_input.prop('required', invalid);
|
2656 |
-
}
|
2657 |
-
self.refreshClasses();
|
2658 |
},
|
2659 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2660 |
/**
|
2661 |
* Updates all state-dependent CSS classes.
|
2662 |
*/
|
@@ -2664,10 +2838,10 @@
|
|
2664 |
var self = this;
|
2665 |
var isFull = self.isFull();
|
2666 |
var isLocked = self.isLocked;
|
2667 |
-
|
2668 |
self.$wrapper
|
2669 |
.toggleClass('rtl', self.rtl);
|
2670 |
-
|
2671 |
self.$control
|
2672 |
.toggleClass('focus', self.isFocused)
|
2673 |
.toggleClass('disabled', self.isDisabled)
|
@@ -2679,10 +2853,10 @@
|
|
2679 |
.toggleClass('dropdown-active', self.isOpen)
|
2680 |
.toggleClass('has-options', !$.isEmptyObject(self.options))
|
2681 |
.toggleClass('has-items', self.items.length > 0);
|
2682 |
-
|
2683 |
self.$control_input.data('grow', !isFull && !isLocked);
|
2684 |
},
|
2685 |
-
|
2686 |
/**
|
2687 |
* Determines whether or not more items can be added
|
2688 |
* to the control without exceeding the user-defined maximum.
|
@@ -2692,7 +2866,7 @@
|
|
2692 |
isFull: function() {
|
2693 |
return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
|
2694 |
},
|
2695 |
-
|
2696 |
/**
|
2697 |
* Refreshes the original <select> or <input>
|
2698 |
* element to reflect the current state.
|
@@ -2700,7 +2874,7 @@
|
|
2700 |
updateOriginalInput: function(opts) {
|
2701 |
var i, n, options, label, self = this;
|
2702 |
opts = opts || {};
|
2703 |
-
|
2704 |
if (self.tagType === TAG_SELECT) {
|
2705 |
options = [];
|
2706 |
for (i = 0, n = self.items.length; i < n; i++) {
|
@@ -2715,14 +2889,14 @@
|
|
2715 |
self.$input.val(self.getValue());
|
2716 |
self.$input.attr('value',self.$input.val());
|
2717 |
}
|
2718 |
-
|
2719 |
if (self.isSetup) {
|
2720 |
if (!opts.silent) {
|
2721 |
self.trigger('change', self.$input.val());
|
2722 |
}
|
2723 |
}
|
2724 |
},
|
2725 |
-
|
2726 |
/**
|
2727 |
* Shows/hide the input placeholder depending
|
2728 |
* on if there items in the list already.
|
@@ -2730,7 +2904,7 @@
|
|
2730 |
updatePlaceholder: function() {
|
2731 |
if (!this.settings.placeholder) return;
|
2732 |
var $input = this.$control_input;
|
2733 |
-
|
2734 |
if (this.items.length) {
|
2735 |
$input.removeAttr('placeholder');
|
2736 |
} else {
|
@@ -2738,14 +2912,14 @@
|
|
2738 |
}
|
2739 |
$input.triggerHandler('update', {force: true});
|
2740 |
},
|
2741 |
-
|
2742 |
/**
|
2743 |
* Shows the autocomplete dropdown containing
|
2744 |
* the available options.
|
2745 |
*/
|
2746 |
open: function() {
|
2747 |
var self = this;
|
2748 |
-
|
2749 |
if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
|
2750 |
self.focus();
|
2751 |
self.isOpen = true;
|
@@ -2755,26 +2929,33 @@
|
|
2755 |
self.$dropdown.css({visibility: 'visible'});
|
2756 |
self.trigger('dropdown_open', self.$dropdown);
|
2757 |
},
|
2758 |
-
|
2759 |
/**
|
2760 |
* Closes the autocomplete dropdown menu.
|
2761 |
*/
|
2762 |
close: function() {
|
2763 |
var self = this;
|
2764 |
var trigger = self.isOpen;
|
2765 |
-
|
2766 |
if (self.settings.mode === 'single' && self.items.length) {
|
2767 |
self.hideInput();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2768 |
}
|
2769 |
-
|
2770 |
self.isOpen = false;
|
2771 |
self.$dropdown.hide();
|
2772 |
self.setActiveOption(null);
|
2773 |
self.refreshState();
|
2774 |
-
|
2775 |
if (trigger) self.trigger('dropdown_close', self.$dropdown);
|
2776 |
},
|
2777 |
-
|
2778 |
/**
|
2779 |
* Calculates and applies the appropriate
|
2780 |
* position of the dropdown.
|
@@ -2783,14 +2964,14 @@
|
|
2783 |
var $control = this.$control;
|
2784 |
var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
|
2785 |
offset.top += $control.outerHeight(true);
|
2786 |
-
|
2787 |
this.$dropdown.css({
|
2788 |
-
width : $control.
|
2789 |
top : offset.top,
|
2790 |
left : offset.left
|
2791 |
});
|
2792 |
},
|
2793 |
-
|
2794 |
/**
|
2795 |
* Resets / clears all selected items
|
2796 |
* from the control.
|
@@ -2799,7 +2980,7 @@
|
|
2799 |
*/
|
2800 |
clear: function(silent) {
|
2801 |
var self = this;
|
2802 |
-
|
2803 |
if (!self.items.length) return;
|
2804 |
self.$control.children(':not(input)').remove();
|
2805 |
self.items = [];
|
@@ -2812,7 +2993,7 @@
|
|
2812 |
self.showInput();
|
2813 |
self.trigger('clear');
|
2814 |
},
|
2815 |
-
|
2816 |
/**
|
2817 |
* A helper method for inserting an element
|
2818 |
* at the current caret position.
|
@@ -2821,14 +3002,18 @@
|
|
2821 |
*/
|
2822 |
insertAtCaret: function($el) {
|
2823 |
var caret = Math.min(this.caretPos, this.items.length);
|
|
|
|
|
|
|
2824 |
if (caret === 0) {
|
2825 |
-
|
2826 |
} else {
|
2827 |
-
|
2828 |
}
|
|
|
2829 |
this.setCaret(caret + 1);
|
2830 |
},
|
2831 |
-
|
2832 |
/**
|
2833 |
* Removes the current selected item(s).
|
2834 |
*
|
@@ -2838,22 +3023,22 @@
|
|
2838 |
deleteSelection: function(e) {
|
2839 |
var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
|
2840 |
var self = this;
|
2841 |
-
|
2842 |
direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
|
2843 |
selection = getSelection(self.$control_input[0]);
|
2844 |
-
|
2845 |
if (self.$activeOption && !self.settings.hideSelected) {
|
2846 |
option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
|
2847 |
}
|
2848 |
-
|
2849 |
// determine items that will be removed
|
2850 |
values = [];
|
2851 |
-
|
2852 |
if (self.$activeItems.length) {
|
2853 |
$tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
|
2854 |
caret = self.$control.children(':not(input)').index($tail);
|
2855 |
if (direction > 0) { caret++; }
|
2856 |
-
|
2857 |
for (i = 0, n = self.$activeItems.length; i < n; i++) {
|
2858 |
values.push($(self.$activeItems[i]).attr('data-value'));
|
2859 |
}
|
@@ -2868,12 +3053,12 @@
|
|
2868 |
values.push(self.items[self.caretPos]);
|
2869 |
}
|
2870 |
}
|
2871 |
-
|
2872 |
// allow the callback to abort
|
2873 |
if (!values.length || (typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false)) {
|
2874 |
return false;
|
2875 |
}
|
2876 |
-
|
2877 |
// perform removal
|
2878 |
if (typeof caret !== 'undefined') {
|
2879 |
self.setCaret(caret);
|
@@ -2881,11 +3066,11 @@
|
|
2881 |
while (values.length) {
|
2882 |
self.removeItem(values.pop());
|
2883 |
}
|
2884 |
-
|
2885 |
self.showInput();
|
2886 |
self.positionDropdown();
|
2887 |
self.refreshOptions(true);
|
2888 |
-
|
2889 |
// select previous option
|
2890 |
if (option_select) {
|
2891 |
$option_select = self.getOption(option_select);
|
@@ -2893,10 +3078,10 @@
|
|
2893 |
self.setActiveOption($option_select);
|
2894 |
}
|
2895 |
}
|
2896 |
-
|
2897 |
return true;
|
2898 |
},
|
2899 |
-
|
2900 |
/**
|
2901 |
* Selects the previous / next item (depending
|
2902 |
* on the `direction` argument).
|
@@ -2910,19 +3095,19 @@
|
|
2910 |
advanceSelection: function(direction, e) {
|
2911 |
var tail, selection, idx, valueLength, cursorAtEdge, $tail;
|
2912 |
var self = this;
|
2913 |
-
|
2914 |
if (direction === 0) return;
|
2915 |
if (self.rtl) direction *= -1;
|
2916 |
-
|
2917 |
tail = direction > 0 ? 'last' : 'first';
|
2918 |
selection = getSelection(self.$control_input[0]);
|
2919 |
-
|
2920 |
if (self.isFocused && !self.isInputHidden) {
|
2921 |
valueLength = self.$control_input.val().length;
|
2922 |
cursorAtEdge = direction < 0
|
2923 |
? selection.start === 0 && selection.length === 0
|
2924 |
: selection.start === valueLength;
|
2925 |
-
|
2926 |
if (cursorAtEdge && !valueLength) {
|
2927 |
self.advanceCaret(direction, e);
|
2928 |
}
|
@@ -2935,7 +3120,7 @@
|
|
2935 |
}
|
2936 |
}
|
2937 |
},
|
2938 |
-
|
2939 |
/**
|
2940 |
* Moves the caret left / right.
|
2941 |
*
|
@@ -2944,9 +3129,9 @@
|
|
2944 |
*/
|
2945 |
advanceCaret: function(direction, e) {
|
2946 |
var self = this, fn, $adj;
|
2947 |
-
|
2948 |
if (direction === 0) return;
|
2949 |
-
|
2950 |
fn = direction > 0 ? 'next' : 'prev';
|
2951 |
if (self.isShiftDown) {
|
2952 |
$adj = self.$control_input[fn]();
|
@@ -2959,7 +3144,7 @@
|
|
2959 |
self.setCaret(self.caretPos + direction);
|
2960 |
}
|
2961 |
},
|
2962 |
-
|
2963 |
/**
|
2964 |
* Moves the caret to the specified index.
|
2965 |
*
|
@@ -2967,13 +3152,13 @@
|
|
2967 |
*/
|
2968 |
setCaret: function(i) {
|
2969 |
var self = this;
|
2970 |
-
|
2971 |
if (self.settings.mode === 'single') {
|
2972 |
i = self.items.length;
|
2973 |
} else {
|
2974 |
i = Math.max(0, Math.min(self.items.length, i));
|
2975 |
}
|
2976 |
-
|
2977 |
if(!self.isPending) {
|
2978 |
// the input must be moved by leaving it in place and moving the
|
2979 |
// siblings, due to the fact that focus cannot be restored once lost
|
@@ -2989,10 +3174,10 @@
|
|
2989 |
}
|
2990 |
}
|
2991 |
}
|
2992 |
-
|
2993 |
self.caretPos = i;
|
2994 |
},
|
2995 |
-
|
2996 |
/**
|
2997 |
* Disables user input on the control. Used while
|
2998 |
* items are being asynchronously created.
|
@@ -3002,7 +3187,7 @@
|
|
3002 |
this.isLocked = true;
|
3003 |
this.refreshState();
|
3004 |
},
|
3005 |
-
|
3006 |
/**
|
3007 |
* Re-enables user input on the control.
|
3008 |
*/
|
@@ -3010,7 +3195,7 @@
|
|
3010 |
this.isLocked = false;
|
3011 |
this.refreshState();
|
3012 |
},
|
3013 |
-
|
3014 |
/**
|
3015 |
* Disables user input on the control completely.
|
3016 |
* While disabled, it cannot receive focus.
|
@@ -3022,7 +3207,7 @@
|
|
3022 |
self.isDisabled = true;
|
3023 |
self.lock();
|
3024 |
},
|
3025 |
-
|
3026 |
/**
|
3027 |
* Enables the control so that it can respond
|
3028 |
* to focus and user input.
|
@@ -3034,7 +3219,7 @@
|
|
3034 |
self.isDisabled = false;
|
3035 |
self.unlock();
|
3036 |
},
|
3037 |
-
|
3038 |
/**
|
3039 |
* Completely destroys the control and
|
3040 |
* unbinds all event listeners so that it can
|
@@ -3044,12 +3229,12 @@
|
|
3044 |
var self = this;
|
3045 |
var eventNS = self.eventNS;
|
3046 |
var revertSettings = self.revertSettings;
|
3047 |
-
|
3048 |
self.trigger('destroy');
|
3049 |
self.off();
|
3050 |
self.$wrapper.remove();
|
3051 |
self.$dropdown.remove();
|
3052 |
-
|
3053 |
self.$input
|
3054 |
.html('')
|
3055 |
.append(revertSettings.$children)
|
@@ -3057,17 +3242,22 @@
|
|
3057 |
.removeClass('selectized')
|
3058 |
.attr({tabindex: revertSettings.tabindex})
|
3059 |
.show();
|
3060 |
-
|
3061 |
self.$control_input.removeData('grow');
|
3062 |
self.$input.removeData('selectize');
|
3063 |
-
|
|
|
|
|
|
|
|
|
|
|
3064 |
$(window).off(eventNS);
|
3065 |
$(document).off(eventNS);
|
3066 |
$(document.body).off(eventNS);
|
3067 |
-
|
3068 |
delete self.$input[0].selectize;
|
3069 |
},
|
3070 |
-
|
3071 |
/**
|
3072 |
* A helper method for rendering "item" and
|
3073 |
* "option" templates, given the data.
|
@@ -3082,12 +3272,12 @@
|
|
3082 |
var cache = false;
|
3083 |
var self = this;
|
3084 |
var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
|
3085 |
-
|
3086 |
if (templateName === 'option' || templateName === 'item') {
|
3087 |
value = hash_key(data[self.settings.valueField]);
|
3088 |
cache = !!value;
|
3089 |
}
|
3090 |
-
|
3091 |
// pull markup from cache if it exists
|
3092 |
if (cache) {
|
3093 |
if (!isset(self.renderCache[templateName])) {
|
@@ -3097,30 +3287,35 @@
|
|
3097 |
return self.renderCache[templateName][value];
|
3098 |
}
|
3099 |
}
|
3100 |
-
|
3101 |
// render markup
|
3102 |
-
html = self.settings.render[templateName].apply(this, [data, escape_html]);
|
3103 |
-
|
3104 |
// add mandatory attributes
|
3105 |
if (templateName === 'option' || templateName === 'option_create') {
|
3106 |
-
|
|
|
|
|
3107 |
}
|
3108 |
-
if (templateName === 'optgroup') {
|
3109 |
id = data[self.settings.optgroupValueField] || '';
|
3110 |
-
html
|
|
|
|
|
|
|
3111 |
}
|
3112 |
if (templateName === 'option' || templateName === 'item') {
|
3113 |
-
html
|
3114 |
}
|
3115 |
-
|
3116 |
// update cache
|
3117 |
if (cache) {
|
3118 |
-
self.renderCache[templateName][value] = html;
|
3119 |
}
|
3120 |
-
|
3121 |
-
return html;
|
3122 |
},
|
3123 |
-
|
3124 |
/**
|
3125 |
* Clears the render cache for a template. If
|
3126 |
* no template is given, clears all render
|
@@ -3136,7 +3331,7 @@
|
|
3136 |
delete self.renderCache[templateName];
|
3137 |
}
|
3138 |
},
|
3139 |
-
|
3140 |
/**
|
3141 |
* Determines whether or not to display the
|
3142 |
* create item prompt, given a user input.
|
@@ -3153,15 +3348,15 @@
|
|
3153 |
&& (typeof filter !== 'string' || new RegExp(filter).test(input))
|
3154 |
&& (!(filter instanceof RegExp) || filter.test(input));
|
3155 |
}
|
3156 |
-
|
3157 |
});
|
3158 |
-
|
3159 |
-
|
3160 |
Selectize.count = 0;
|
3161 |
Selectize.defaults = {
|
3162 |
options: [],
|
3163 |
optgroups: [],
|
3164 |
-
|
3165 |
plugins: [],
|
3166 |
delimiter: ',',
|
3167 |
splitOn: null, // regexp or string for splitting up values from a paste command
|
@@ -3176,37 +3371,38 @@
|
|
3176 |
maxItems: null,
|
3177 |
hideSelected: null,
|
3178 |
addPrecedence: false,
|
3179 |
-
selectOnTab:
|
3180 |
preload: false,
|
3181 |
allowEmptyOption: false,
|
3182 |
closeAfterSelect: false,
|
3183 |
-
|
3184 |
scrollDuration: 60,
|
3185 |
loadThrottle: 300,
|
3186 |
loadingClass: 'loading',
|
3187 |
-
|
3188 |
dataAttr: 'data-data',
|
3189 |
optgroupField: 'optgroup',
|
3190 |
valueField: 'value',
|
3191 |
labelField: 'text',
|
|
|
3192 |
optgroupLabelField: 'label',
|
3193 |
optgroupValueField: 'value',
|
3194 |
lockOptgroupOrder: false,
|
3195 |
-
|
3196 |
sortField: '$order',
|
3197 |
searchField: ['text'],
|
3198 |
searchConjunction: 'and',
|
3199 |
-
|
3200 |
mode: null,
|
3201 |
wrapperClass: 'selectize-control',
|
3202 |
inputClass: 'selectize-input',
|
3203 |
dropdownClass: 'selectize-dropdown',
|
3204 |
dropdownContentClass: 'selectize-dropdown-content',
|
3205 |
-
|
3206 |
dropdownParent: null,
|
3207 |
-
|
3208 |
copyClassesToDropdown: true,
|
3209 |
-
|
3210 |
/*
|
3211 |
load : null, // function(query, callback) { ... }
|
3212 |
score : null, // function(search) { ... }
|
@@ -3226,7 +3422,7 @@
|
|
3226 |
onType : null, // function(str) { ... }
|
3227 |
onDelete : null, // function(values) { ... }
|
3228 |
*/
|
3229 |
-
|
3230 |
render: {
|
3231 |
/*
|
3232 |
item: null,
|
@@ -3237,18 +3433,19 @@
|
|
3237 |
*/
|
3238 |
}
|
3239 |
};
|
3240 |
-
|
3241 |
-
|
3242 |
$.fn.selectize = function(settings_user) {
|
3243 |
var defaults = $.fn.selectize.defaults;
|
3244 |
var settings = $.extend({}, defaults, settings_user);
|
3245 |
var attr_data = settings.dataAttr;
|
3246 |
var field_label = settings.labelField;
|
3247 |
var field_value = settings.valueField;
|
|
|
3248 |
var field_optgroup = settings.optgroupField;
|
3249 |
var field_optgroup_label = settings.optgroupLabelField;
|
3250 |
var field_optgroup_value = settings.optgroupValueField;
|
3251 |
-
|
3252 |
/**
|
3253 |
* Initializes selectize from a <input type="text"> element.
|
3254 |
*
|
@@ -3257,9 +3454,9 @@
|
|
3257 |
*/
|
3258 |
var init_textbox = function($input, settings_element) {
|
3259 |
var i, n, values, option;
|
3260 |
-
|
3261 |
var data_raw = $input.attr(attr_data);
|
3262 |
-
|
3263 |
if (!data_raw) {
|
3264 |
var value = $.trim($input.val() || '');
|
3265 |
if (!settings.allowEmptyOption && !value.length) return;
|
@@ -3278,7 +3475,7 @@
|
|
3278 |
}
|
3279 |
}
|
3280 |
};
|
3281 |
-
|
3282 |
/**
|
3283 |
* Initializes selectize from a <select> element.
|
3284 |
*
|
@@ -3289,7 +3486,7 @@
|
|
3289 |
var i, n, tagName, $children, order = 0;
|
3290 |
var options = settings_element.options;
|
3291 |
var optionsMap = {};
|
3292 |
-
|
3293 |
var readData = function($el) {
|
3294 |
var data = attr_data && $el.attr(attr_data);
|
3295 |
if (typeof data === 'string' && data.length) {
|
@@ -3297,13 +3494,13 @@
|
|
3297 |
}
|
3298 |
return null;
|
3299 |
};
|
3300 |
-
|
3301 |
var addOption = function($option, group) {
|
3302 |
$option = $($option);
|
3303 |
-
|
3304 |
-
var value = hash_key($option.
|
3305 |
if (!value && !settings.allowEmptyOption) return;
|
3306 |
-
|
3307 |
// if the option already exists, it's probably been
|
3308 |
// duplicated in another optgroup. in this case, push
|
3309 |
// the current group to the "optgroup" property on the
|
@@ -3321,41 +3518,43 @@
|
|
3321 |
}
|
3322 |
return;
|
3323 |
}
|
3324 |
-
|
3325 |
var option = readData($option) || {};
|
3326 |
option[field_label] = option[field_label] || $option.text();
|
3327 |
option[field_value] = option[field_value] || value;
|
|
|
3328 |
option[field_optgroup] = option[field_optgroup] || group;
|
3329 |
-
|
3330 |
optionsMap[value] = option;
|
3331 |
options.push(option);
|
3332 |
-
|
3333 |
if ($option.is(':selected')) {
|
3334 |
settings_element.items.push(value);
|
3335 |
}
|
3336 |
};
|
3337 |
-
|
3338 |
var addGroup = function($optgroup) {
|
3339 |
var i, n, id, optgroup, $options;
|
3340 |
-
|
3341 |
$optgroup = $($optgroup);
|
3342 |
id = $optgroup.attr('label');
|
3343 |
-
|
3344 |
if (id) {
|
3345 |
optgroup = readData($optgroup) || {};
|
3346 |
optgroup[field_optgroup_label] = id;
|
3347 |
optgroup[field_optgroup_value] = id;
|
|
|
3348 |
settings_element.optgroups.push(optgroup);
|
3349 |
}
|
3350 |
-
|
3351 |
$options = $('option', $optgroup);
|
3352 |
for (i = 0, n = $options.length; i < n; i++) {
|
3353 |
addOption($options[i], id);
|
3354 |
}
|
3355 |
};
|
3356 |
-
|
3357 |
settings_element.maxItems = $input.attr('multiple') ? null : 1;
|
3358 |
-
|
3359 |
$children = $input.children();
|
3360 |
for (i = 0, n = $children.length; i < n; i++) {
|
3361 |
tagName = $children[i].tagName.toLowerCase();
|
@@ -3366,10 +3565,10 @@
|
|
3366 |
}
|
3367 |
}
|
3368 |
};
|
3369 |
-
|
3370 |
return this.each(function() {
|
3371 |
if (this.selectize) return;
|
3372 |
-
|
3373 |
var instance;
|
3374 |
var $input = $(this);
|
3375 |
var tag_name = this.tagName.toLowerCase();
|
@@ -3377,35 +3576,50 @@
|
|
3377 |
if (!placeholder && !settings.allowEmptyOption) {
|
3378 |
placeholder = $input.children('option[value=""]').text();
|
3379 |
}
|
3380 |
-
|
3381 |
var settings_element = {
|
3382 |
'placeholder' : placeholder,
|
3383 |
'options' : [],
|
3384 |
'optgroups' : [],
|
3385 |
'items' : []
|
3386 |
};
|
3387 |
-
|
3388 |
if (tag_name === 'select') {
|
3389 |
init_select($input, settings_element);
|
3390 |
} else {
|
3391 |
init_textbox($input, settings_element);
|
3392 |
}
|
3393 |
-
|
3394 |
instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
|
3395 |
});
|
3396 |
};
|
3397 |
-
|
3398 |
$.fn.selectize.defaults = Selectize.defaults;
|
3399 |
$.fn.selectize.support = {
|
3400 |
validity: SUPPORTS_VALIDITY_API
|
3401 |
};
|
3402 |
-
|
3403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3404 |
Selectize.define('drag_drop', function(options) {
|
3405 |
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
|
3406 |
if (this.settings.mode !== 'multi') return;
|
3407 |
var self = this;
|
3408 |
-
|
3409 |
self.lock = (function() {
|
3410 |
var original = self.lock;
|
3411 |
return function() {
|
@@ -3414,7 +3628,7 @@
|
|
3414 |
return original.apply(self, arguments);
|
3415 |
};
|
3416 |
})();
|
3417 |
-
|
3418 |
self.unlock = (function() {
|
3419 |
var original = self.unlock;
|
3420 |
return function() {
|
@@ -3423,12 +3637,12 @@
|
|
3423 |
return original.apply(self, arguments);
|
3424 |
};
|
3425 |
})();
|
3426 |
-
|
3427 |
self.setup = (function() {
|
3428 |
var original = self.setup;
|
3429 |
return function() {
|
3430 |
original.apply(this, arguments);
|
3431 |
-
|
3432 |
var $control = self.$control.sortable({
|
3433 |
items: '[data-value]',
|
3434 |
forcePlaceholderSize: true,
|
@@ -3450,31 +3664,31 @@
|
|
3450 |
});
|
3451 |
};
|
3452 |
})();
|
3453 |
-
|
3454 |
});
|
3455 |
-
|
3456 |
Selectize.define('dropdown_header', function(options) {
|
3457 |
var self = this;
|
3458 |
-
|
3459 |
options = $.extend({
|
3460 |
title : 'Untitled',
|
3461 |
headerClass : 'selectize-dropdown-header',
|
3462 |
titleRowClass : 'selectize-dropdown-header-title',
|
3463 |
labelClass : 'selectize-dropdown-header-label',
|
3464 |
closeClass : 'selectize-dropdown-header-close',
|
3465 |
-
|
3466 |
html: function(data) {
|
3467 |
return (
|
3468 |
'<div class="' + data.headerClass + '">' +
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
'</div>'
|
3474 |
);
|
3475 |
}
|
3476 |
}, options);
|
3477 |
-
|
3478 |
self.setup = (function() {
|
3479 |
var original = self.setup;
|
3480 |
return function() {
|
@@ -3483,40 +3697,40 @@
|
|
3483 |
self.$dropdown.prepend(self.$dropdown_header);
|
3484 |
};
|
3485 |
})();
|
3486 |
-
|
3487 |
});
|
3488 |
-
|
3489 |
Selectize.define('optgroup_columns', function(options) {
|
3490 |
var self = this;
|
3491 |
-
|
3492 |
options = $.extend({
|
3493 |
equalizeWidth : true,
|
3494 |
equalizeHeight : true
|
3495 |
}, options);
|
3496 |
-
|
3497 |
this.getAdjacentOption = function($option, direction) {
|
3498 |
var $options = $option.closest('[data-group]').find('[data-selectable]');
|
3499 |
var index = $options.index($option) + direction;
|
3500 |
-
|
3501 |
return index >= 0 && index < $options.length ? $options.eq(index) : $();
|
3502 |
};
|
3503 |
-
|
3504 |
this.onKeyDown = (function() {
|
3505 |
var original = self.onKeyDown;
|
3506 |
return function(e) {
|
3507 |
var index, $option, $options, $optgroup;
|
3508 |
-
|
3509 |
if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
|
3510 |
self.ignoreHover = true;
|
3511 |
$optgroup = this.$activeOption.closest('[data-group]');
|
3512 |
index = $optgroup.find('[data-selectable]').index(this.$activeOption);
|
3513 |
-
|
3514 |
if(e.keyCode === KEY_LEFT) {
|
3515 |
$optgroup = $optgroup.prev('[data-group]');
|
3516 |
} else {
|
3517 |
$optgroup = $optgroup.next('[data-group]');
|
3518 |
}
|
3519 |
-
|
3520 |
$options = $optgroup.find('[data-selectable]');
|
3521 |
$option = $options.eq(Math.min($options.length - 1, index));
|
3522 |
if ($option.length) {
|
@@ -3524,16 +3738,16 @@
|
|
3524 |
}
|
3525 |
return;
|
3526 |
}
|
3527 |
-
|
3528 |
return original.apply(this, arguments);
|
3529 |
};
|
3530 |
})();
|
3531 |
-
|
3532 |
var getScrollbarWidth = function() {
|
3533 |
var div;
|
3534 |
var width = getScrollbarWidth.width;
|
3535 |
var doc = document;
|
3536 |
-
|
3537 |
if (typeof width === 'undefined') {
|
3538 |
div = doc.createElement('div');
|
3539 |
div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
|
@@ -3544,14 +3758,14 @@
|
|
3544 |
}
|
3545 |
return width;
|
3546 |
};
|
3547 |
-
|
3548 |
var equalizeSizes = function() {
|
3549 |
var i, n, height_max, width, width_last, width_parent, $optgroups;
|
3550 |
-
|
3551 |
$optgroups = $('[data-group]', self.$dropdown_content);
|
3552 |
n = $optgroups.length;
|
3553 |
if (!n || !self.$dropdown_content.width()) return;
|
3554 |
-
|
3555 |
if (options.equalizeHeight) {
|
3556 |
height_max = 0;
|
3557 |
for (i = 0; i < n; i++) {
|
@@ -3559,7 +3773,7 @@
|
|
3559 |
}
|
3560 |
$optgroups.css({height: height_max});
|
3561 |
}
|
3562 |
-
|
3563 |
if (options.equalizeWidth) {
|
3564 |
width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
|
3565 |
width = Math.round(width_parent / n);
|
@@ -3570,77 +3784,133 @@
|
|
3570 |
}
|
3571 |
}
|
3572 |
};
|
3573 |
-
|
3574 |
if (options.equalizeHeight || options.equalizeWidth) {
|
3575 |
hook.after(this, 'positionDropdown', equalizeSizes);
|
3576 |
hook.after(this, 'refreshOptions', equalizeSizes);
|
3577 |
}
|
3578 |
-
|
3579 |
-
|
3580 |
});
|
3581 |
-
|
3582 |
Selectize.define('remove_button', function(options) {
|
3583 |
-
if (this.settings.mode === 'single') return;
|
3584 |
-
|
3585 |
options = $.extend({
|
3586 |
label : '×',
|
3587 |
title : 'Remove',
|
3588 |
className : 'remove',
|
3589 |
append : true
|
3590 |
}, options);
|
3591 |
-
|
3592 |
-
var
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
|
3601 |
-
|
3602 |
-
|
3603 |
-
|
3604 |
-
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
|
3609 |
-
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
|
3615 |
-
|
3616 |
-
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
if (self.isLocked) return;
|
3624 |
-
|
3625 |
-
var $item = $(e.currentTarget).parent();
|
3626 |
-
self.setActiveItem($item);
|
3627 |
-
if (self.deleteSelection()) {
|
3628 |
-
self.setCaret(self.items.length);
|
3629 |
}
|
3630 |
-
|
3631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3632 |
};
|
3633 |
-
|
3634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3635 |
});
|
3636 |
-
|
|
|
3637 |
Selectize.define('restore_on_backspace', function(options) {
|
3638 |
var self = this;
|
3639 |
-
|
3640 |
options.text = options.text || function(option) {
|
3641 |
return option[this.settings.labelField];
|
3642 |
};
|
3643 |
-
|
3644 |
this.onKeyDown = (function() {
|
3645 |
var original = self.onKeyDown;
|
3646 |
return function(e) {
|
@@ -3661,7 +3931,7 @@
|
|
3661 |
};
|
3662 |
})();
|
3663 |
});
|
3664 |
-
|
3665 |
|
3666 |
return Selectize;
|
3667 |
}));
|
1 |
/**
|
2 |
* sifter.js
|
3 |
+
* Copyright (c) 2013–2020 Brian Reavis & contributors
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
6 |
* file except in compliance with the License. You may obtain a copy of the License at:
|
16 |
|
17 |
(function(root, factory) {
|
18 |
if (typeof define === 'function' && define.amd) {
|
19 |
+
define(factory);
|
20 |
} else if (typeof exports === 'object') {
|
21 |
module.exports = factory();
|
22 |
} else {
|
45 |
* @param {string} query
|
46 |
* @returns {array}
|
47 |
*/
|
48 |
+
Sifter.prototype.tokenize = function(query, respect_word_boundaries) {
|
49 |
query = trim(String(query || '').toLowerCase());
|
50 |
if (!query || !query.length) return [];
|
51 |
|
62 |
}
|
63 |
}
|
64 |
}
|
65 |
+
if (respect_word_boundaries) regex = "\\b"+regex
|
66 |
tokens.push({
|
67 |
string : words[i],
|
68 |
regex : new RegExp(regex, 'i')
|
115 |
* @returns {function}
|
116 |
*/
|
117 |
Sifter.prototype.getScoreFunction = function(search, options) {
|
118 |
+
var self, fields, tokens, token_count, nesting;
|
119 |
|
120 |
self = this;
|
121 |
search = self.prepareSearch(search, options);
|
122 |
tokens = search.tokens;
|
123 |
fields = search.options.fields;
|
124 |
token_count = tokens.length;
|
125 |
+
nesting = search.options.nesting;
|
126 |
|
127 |
/**
|
128 |
* Calculates how close of a match the
|
159 |
}
|
160 |
if (field_count === 1) {
|
161 |
return function(token, data) {
|
162 |
+
return scoreValue(getattr(data, fields[0], nesting), token);
|
163 |
};
|
164 |
}
|
165 |
return function(token, data) {
|
166 |
for (var i = 0, sum = 0; i < field_count; i++) {
|
167 |
+
sum += scoreValue(getattr(data, fields[i], nesting), token);
|
168 |
}
|
169 |
return sum / field_count;
|
170 |
};
|
225 |
*/
|
226 |
get_field = function(name, result) {
|
227 |
if (name === '$score') return result.score;
|
228 |
+
return getattr(self.items[result.id], name, options.nesting);
|
229 |
};
|
230 |
|
231 |
// parse options
|
319 |
return {
|
320 |
options : options,
|
321 |
query : String(query || '').toLowerCase(),
|
322 |
+
tokens : this.tokenize(query, options.respect_word_boundaries),
|
323 |
total : 0,
|
324 |
items : []
|
325 |
};
|
414 |
return a;
|
415 |
};
|
416 |
|
417 |
+
/**
|
418 |
+
* A property getter resolving dot-notation
|
419 |
+
* @param {Object} obj The root object to fetch property on
|
420 |
+
* @param {String} name The optionally dotted property name to fetch
|
421 |
+
* @param {Boolean} nesting Handle nesting or not
|
422 |
+
* @return {Object} The resolved property value
|
423 |
+
*/
|
424 |
+
var getattr = function(obj, name, nesting) {
|
425 |
+
if (!obj || !name) return;
|
426 |
+
if (!nesting) return obj[name];
|
427 |
+
var names = name.split(".");
|
428 |
+
while(names.length && (obj = obj[names.shift()]));
|
429 |
+
return obj;
|
430 |
+
};
|
431 |
+
|
432 |
var trim = function(str) {
|
433 |
return (str + '').replace(/^\s+|\s+$|/g, '');
|
434 |
};
|
437 |
return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
|
438 |
};
|
439 |
|
440 |
+
var is_array = Array.isArray || (typeof $ !== 'undefined' && $.isArray) || function(object) {
|
441 |
return Object.prototype.toString.call(object) === '[object Array]';
|
442 |
};
|
443 |
|
444 |
var DIACRITICS = {
|
445 |
+
'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
|
446 |
+
'b': '[b␢βΒB฿𐌁ᛒ]',
|
447 |
+
'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
|
448 |
+
'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
|
449 |
+
'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
|
450 |
+
'f': '[fƑƒḞḟ]',
|
451 |
+
'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
|
452 |
+
'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
|
453 |
+
'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
|
454 |
+
'j': '[jȷĴĵɈɉʝɟʲ]',
|
455 |
+
'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
|
456 |
+
'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
|
457 |
+
'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
|
458 |
+
'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
|
459 |
+
'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
|
460 |
+
'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
|
461 |
+
'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
|
462 |
+
's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
|
463 |
+
't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
|
464 |
+
'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
|
465 |
+
'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
|
466 |
+
'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
|
467 |
+
'x': '[xẌẍẊẋχ]',
|
468 |
+
'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
|
469 |
+
'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
|
470 |
};
|
471 |
|
472 |
var asciifold = (function() {
|
497 |
return Sifter;
|
498 |
}));
|
499 |
|
|
|
|
|
500 |
/**
|
501 |
* microplugin.js
|
502 |
* Copyright (c) 2013 Brian Reavis & contributors
|
515 |
|
516 |
(function(root, factory) {
|
517 |
if (typeof define === 'function' && define.amd) {
|
518 |
+
define(factory);
|
519 |
} else if (typeof exports === 'object') {
|
520 |
module.exports = factory();
|
521 |
} else {
|
634 |
}));
|
635 |
|
636 |
/**
|
637 |
+
* selectize.js (v0.13.0)
|
638 |
* Copyright (c) 2013–2015 Brian Reavis & contributors
|
639 |
+
* Copyright (c) 2020 Selectize Team & contributors
|
640 |
*
|
641 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
642 |
* file except in compliance with the License. You may obtain a copy of the License at:
|
648 |
* governing permissions and limitations under the License.
|
649 |
*
|
650 |
* @author Brian Reavis <brian@thirdroute.com>
|
651 |
+
* @author Ris Adams <selectize@risadams.com>
|
652 |
*/
|
653 |
|
654 |
/*jshint curly:false */
|
656 |
|
657 |
(function(root, factory) {
|
658 |
if (typeof define === 'function' && define.amd) {
|
659 |
+
define(['jquery','sifter','microplugin'], factory);
|
660 |
+
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
661 |
module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));
|
662 |
} else {
|
663 |
root.Selectize = factory(root.jQuery, root.Sifter, root.MicroPlugin);
|
668 |
var highlight = function($element, pattern) {
|
669 |
if (typeof pattern === 'string' && !pattern.length) return;
|
670 |
var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
|
671 |
+
|
672 |
var highlight = function(node) {
|
673 |
var skip = 0;
|
674 |
+
// Wrap matching part of text node with highlighting <span>, e.g.
|
675 |
+
// Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
|
676 |
if (node.nodeType === 3) {
|
677 |
var pos = node.data.search(regex);
|
678 |
if (pos >= 0 && node.data.length > 0) {
|
686 |
middlebit.parentNode.replaceChild(spannode, middlebit);
|
687 |
skip = 1;
|
688 |
}
|
689 |
+
}
|
690 |
+
// Recurse element node, looking for child text nodes to highlight, unless element
|
691 |
+
// is childless, <script>, <style>, or already highlighted: <span class="highlight">
|
692 |
+
else if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && ( node.className !== 'highlight' || node.tagName !== 'SPAN' )) {
|
693 |
for (var i = 0; i < node.childNodes.length; ++i) {
|
694 |
i += highlight(node.childNodes[i]);
|
695 |
}
|
696 |
}
|
697 |
return skip;
|
698 |
};
|
699 |
+
|
700 |
return $element.each(function() {
|
701 |
highlight(this);
|
702 |
});
|
703 |
};
|
704 |
+
|
705 |
+
/**
|
706 |
+
* removeHighlight fn copied from highlight v5 and
|
707 |
+
* edited to remove with() and pass js strict mode
|
708 |
+
*/
|
709 |
+
$.fn.removeHighlight = function() {
|
710 |
+
return this.find("span.highlight").each(function() {
|
711 |
+
this.parentNode.firstChild.nodeName;
|
712 |
+
var parent = this.parentNode;
|
713 |
+
parent.replaceChild(this.firstChild, this);
|
714 |
+
parent.normalize();
|
715 |
+
}).end();
|
716 |
+
};
|
717 |
+
|
718 |
+
|
719 |
var MicroEvent = function() {};
|
720 |
MicroEvent.prototype = {
|
721 |
on: function(event, fct){
|
727 |
var n = arguments.length;
|
728 |
if (n === 0) return delete this._events;
|
729 |
if (n === 1) return delete this._events[event];
|
730 |
+
|
731 |
this._events = this._events || {};
|
732 |
if (event in this._events === false) return;
|
733 |
this._events[event].splice(this._events[event].indexOf(fct), 1);
|
740 |
}
|
741 |
}
|
742 |
};
|
743 |
+
|
744 |
/**
|
745 |
* Mixin will delegate all MicroEvent.js function in the destination object.
|
746 |
*
|
754 |
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
|
755 |
}
|
756 |
};
|
757 |
+
|
758 |
var IS_MAC = /Mac/.test(navigator.userAgent);
|
759 |
+
|
760 |
var KEY_A = 65;
|
761 |
var KEY_COMMA = 188;
|
762 |
var KEY_RETURN = 13;
|
773 |
var KEY_CMD = IS_MAC ? 91 : 17;
|
774 |
var KEY_CTRL = IS_MAC ? 18 : 17;
|
775 |
var KEY_TAB = 9;
|
776 |
+
|
777 |
var TAG_SELECT = 1;
|
778 |
var TAG_INPUT = 2;
|
779 |
+
|
780 |
// for now, android support in general is too spotty to support validity
|
781 |
+
var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
|
782 |
+
|
783 |
+
|
784 |
var isset = function(object) {
|
785 |
return typeof object !== 'undefined';
|
786 |
};
|
787 |
+
|
788 |
/**
|
789 |
* Converts a scalar to its best string representation
|
790 |
* for hash keys and HTML attribute values.
|
806 |
if (typeof value === 'boolean') return value ? '1' : '0';
|
807 |
return value + '';
|
808 |
};
|
809 |
+
|
810 |
/**
|
811 |
* Escapes a string for use within HTML.
|
812 |
*
|
820 |
.replace(/>/g, '>')
|
821 |
.replace(/"/g, '"');
|
822 |
};
|
823 |
+
|
824 |
/**
|
825 |
* Escapes "$" characters in replacement strings.
|
826 |
*
|
830 |
var escape_replace = function(str) {
|
831 |
return (str + '').replace(/\$/g, '$$$$');
|
832 |
};
|
833 |
+
|
834 |
var hook = {};
|
835 |
+
|
836 |
/**
|
837 |
* Wraps `method` on `self` so that `fn`
|
838 |
* is invoked before the original method.
|
848 |
return original.apply(self, arguments);
|
849 |
};
|
850 |
};
|
851 |
+
|
852 |
/**
|
853 |
* Wraps `method` on `self` so that `fn`
|
854 |
* is invoked after the original method.
|
865 |
return result;
|
866 |
};
|
867 |
};
|
868 |
+
|
869 |
/**
|
870 |
* Wraps `fn` so that it can only be invoked once.
|
871 |
*
|
880 |
fn.apply(this, arguments);
|
881 |
};
|
882 |
};
|
883 |
+
|
884 |
/**
|
885 |
* Wraps `fn` so that it can only be called once
|
886 |
* every `delay` milliseconds (invoked on the falling edge).
|
900 |
}, delay);
|
901 |
};
|
902 |
};
|
903 |
+
|
904 |
/**
|
905 |
* Debounce all fired events types listed in `types`
|
906 |
* while executing the provided `fn`.
|
913 |
var type;
|
914 |
var trigger = self.trigger;
|
915 |
var event_args = {};
|
916 |
+
|
917 |
// override trigger method
|
918 |
self.trigger = function() {
|
919 |
var type = arguments[0];
|
923 |
return trigger.apply(self, arguments);
|
924 |
}
|
925 |
};
|
926 |
+
|
927 |
// invoke provided function
|
928 |
fn.apply(self, []);
|
929 |
self.trigger = trigger;
|
930 |
+
|
931 |
// trigger queued events
|
932 |
for (type in event_args) {
|
933 |
if (event_args.hasOwnProperty(type)) {
|
935 |
}
|
936 |
}
|
937 |
};
|
938 |
+
|
939 |
/**
|
940 |
* A workaround for http://bugs.jquery.com/ticket/6696
|
941 |
*
|
954 |
return fn.apply(this, [e]);
|
955 |
});
|
956 |
};
|
957 |
+
|
958 |
/**
|
959 |
* Determines the current selection within a text input control.
|
960 |
* Returns an object containing:
|
979 |
}
|
980 |
return result;
|
981 |
};
|
982 |
+
|
983 |
/**
|
984 |
* Copies CSS properties from one element to another.
|
985 |
*
|
998 |
}
|
999 |
$to.css(styles);
|
1000 |
};
|
1001 |
+
|
1002 |
/**
|
1003 |
* Measures the width of a string within a
|
1004 |
* parent element (in pixels).
|
1011 |
if (!str) {
|
1012 |
return 0;
|
1013 |
}
|
1014 |
+
|
1015 |
+
if (!Selectize.$testInput) {
|
1016 |
+
Selectize.$testInput = $('<span />').css({
|
1017 |
+
position: 'absolute',
|
1018 |
+
width: 'auto',
|
1019 |
+
padding: 0,
|
1020 |
+
whiteSpace: 'pre'
|
1021 |
+
});
|
1022 |
+
|
1023 |
+
$('<div />').css({
|
1024 |
+
position: 'absolute',
|
1025 |
+
width: 0,
|
1026 |
+
height: 0,
|
1027 |
+
overflow: 'hidden'
|
1028 |
+
}).append(Selectize.$testInput).appendTo('body');
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
Selectize.$testInput.text(str);
|
1032 |
+
|
1033 |
+
transferStyles($parent, Selectize.$testInput, [
|
1034 |
'letterSpacing',
|
1035 |
'fontSize',
|
1036 |
'fontFamily',
|
1037 |
'fontWeight',
|
1038 |
'textTransform'
|
1039 |
]);
|
1040 |
+
|
1041 |
+
return Selectize.$testInput.width();
|
|
|
|
|
|
|
1042 |
};
|
1043 |
+
|
1044 |
/**
|
1045 |
* Sets up an input to grow horizontally as the user
|
1046 |
* types. If the value is changed manually, you can
|
1052 |
*/
|
1053 |
var autoGrow = function($input) {
|
1054 |
var currentWidth = null;
|
1055 |
+
|
1056 |
var update = function(e, options) {
|
1057 |
var value, keyCode, printable, placeholder, width;
|
1058 |
var shift, character, selection;
|
1059 |
e = e || window.event || {};
|
1060 |
options = options || {};
|
1061 |
+
|
1062 |
if (e.metaKey || e.altKey) return;
|
1063 |
if (!options.force && $input.data('grow') === false) return;
|
1064 |
+
|
1065 |
value = $input.val();
|
1066 |
if (e.type && e.type.toLowerCase() === 'keydown') {
|
1067 |
keyCode = e.keyCode;
|
1068 |
printable = (
|
|
|
|
|
1069 |
(keyCode >= 48 && keyCode <= 57) || // 0-9
|
1070 |
+
(keyCode >= 65 && keyCode <= 90) || // a-z
|
1071 |
+
(keyCode >= 96 && keyCode <= 111) || // numpad 0-9, numeric operators
|
1072 |
+
(keyCode >= 186 && keyCode <= 222) || // semicolon, equal, comma, dash, etc.
|
1073 |
keyCode === 32 // space
|
1074 |
);
|
1075 |
+
|
1076 |
if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
|
1077 |
selection = getSelection($input[0]);
|
1078 |
if (selection.length) {
|
1090 |
value += character;
|
1091 |
}
|
1092 |
}
|
1093 |
+
|
1094 |
placeholder = $input.attr('placeholder');
|
1095 |
if (!value && placeholder) {
|
1096 |
value = placeholder;
|
1097 |
}
|
1098 |
+
|
1099 |
width = measureString(value, $input) + 4;
|
1100 |
if (width !== currentWidth) {
|
1101 |
currentWidth = width;
|
1103 |
$input.triggerHandler('resize');
|
1104 |
}
|
1105 |
};
|
1106 |
+
|
1107 |
$input.on('keydown keyup update blur', update);
|
1108 |
update();
|
1109 |
};
|
1110 |
+
|
1111 |
+
var domToString = function(d) {
|
1112 |
+
var tmp = document.createElement('div');
|
1113 |
+
|
1114 |
+
tmp.appendChild(d.cloneNode(true));
|
1115 |
+
|
1116 |
+
return tmp.innerHTML;
|
1117 |
+
};
|
1118 |
+
|
1119 |
+
var logError = function(message, options){
|
1120 |
+
if(!options) options = {};
|
1121 |
+
var component = "Selectize";
|
1122 |
+
|
1123 |
+
console.error(component + ": " + message)
|
1124 |
+
|
1125 |
+
if(options.explanation){
|
1126 |
+
// console.group is undefined in <IE11
|
1127 |
+
if(console.group) console.group();
|
1128 |
+
console.error(options.explanation);
|
1129 |
+
if(console.group) console.groupEnd();
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
|
1134 |
var Selectize = function($input, settings) {
|
1135 |
var key, i, n, dir, input, self = this;
|
1136 |
input = $input[0];
|
1137 |
input.selectize = self;
|
1138 |
+
|
1139 |
// detect rtl environment
|
1140 |
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
|
1141 |
dir = computedStyle ? computedStyle.getPropertyValue('direction') : input.currentStyle && input.currentStyle.direction;
|
1142 |
dir = dir || $input.parents('[dir]:first').attr('dir') || '';
|
1143 |
+
|
1144 |
// setup default state
|
1145 |
$.extend(self, {
|
1146 |
order : 0,
|
1149 |
tabIndex : $input.attr('tabindex') || '',
|
1150 |
tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
|
1151 |
rtl : /rtl/i.test(dir),
|
1152 |
+
|
1153 |
eventNS : '.selectize' + (++Selectize.count),
|
1154 |
highlightedValue : null,
|
1155 |
+
isBlurring : false,
|
1156 |
isOpen : false,
|
1157 |
isDisabled : false,
|
1158 |
isRequired : $input.is('[required]'),
|
1173 |
caretPos : 0,
|
1174 |
loading : 0,
|
1175 |
loadedSearches : {},
|
1176 |
+
|
1177 |
$activeOption : null,
|
1178 |
$activeItems : [],
|
1179 |
+
|
1180 |
optgroups : {},
|
1181 |
options : {},
|
1182 |
userOptions : {},
|
1184 |
renderCache : {},
|
1185 |
onSearchChange : settings.loadThrottle === null ? self.onSearchChange : debounce(self.onSearchChange, settings.loadThrottle)
|
1186 |
});
|
1187 |
+
|
1188 |
// search system
|
1189 |
self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
|
1190 |
+
|
1191 |
// build options table
|
1192 |
if (self.settings.options) {
|
1193 |
for (i = 0, n = self.settings.options.length; i < n; i++) {
|
1195 |
}
|
1196 |
delete self.settings.options;
|
1197 |
}
|
1198 |
+
|
1199 |
// build optgroup table
|
1200 |
if (self.settings.optgroups) {
|
1201 |
for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
|
1203 |
}
|
1204 |
delete self.settings.optgroups;
|
1205 |
}
|
1206 |
+
|
1207 |
// option-dependent defaults
|
1208 |
self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
|
1209 |
if (typeof self.settings.hideSelected !== 'boolean') {
|
1210 |
self.settings.hideSelected = self.settings.mode === 'multi';
|
1211 |
}
|
1212 |
+
|
1213 |
self.initializePlugins(self.settings.plugins);
|
1214 |
self.setupCallbacks();
|
1215 |
self.setupTemplates();
|
1216 |
self.setup();
|
1217 |
};
|
1218 |
+
|
1219 |
// mixins
|
1220 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1221 |
+
|
1222 |
MicroEvent.mixin(Selectize);
|
1223 |
+
|
1224 |
+
if(typeof MicroPlugin !== "undefined"){
|
1225 |
+
MicroPlugin.mixin(Selectize);
|
1226 |
+
}else{
|
1227 |
+
logError("Dependency MicroPlugin is missing",
|
1228 |
+
{explanation:
|
1229 |
+
"Make sure you either: (1) are using the \"standalone\" "+
|
1230 |
+
"version of Selectize, or (2) require MicroPlugin before you "+
|
1231 |
+
"load Selectize."}
|
1232 |
+
);
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
|
1236 |
// methods
|
1237 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1238 |
+
|
1239 |
$.extend(Selectize.prototype, {
|
1240 |
+
|
1241 |
/**
|
1242 |
* Creates all elements and sets up event bindings.
|
1243 |
*/
|
1248 |
var $window = $(window);
|
1249 |
var $document = $(document);
|
1250 |
var $input = self.$input;
|
1251 |
+
|
1252 |
var $wrapper;
|
1253 |
var $control;
|
1254 |
var $control_input;
|
1260 |
var timeout_focus;
|
1261 |
var classes;
|
1262 |
var classes_plugins;
|
1263 |
+
var inputId;
|
1264 |
+
|
1265 |
inputMode = self.settings.mode;
|
1266 |
classes = $input.attr('class') || '';
|
1267 |
+
|
1268 |
$wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
|
1269 |
$control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
|
1270 |
+
$control_input = $('<input type="text" autocomplete="new-password" autofill="no" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
|
1271 |
$dropdown_parent = $(settings.dropdownParent || $wrapper);
|
1272 |
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
|
1273 |
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
|
1274 |
+
|
1275 |
+
if(inputId = $input.attr('id')) {
|
1276 |
+
$control_input.attr('id', inputId + '-selectized');
|
1277 |
+
$("label[for='"+inputId+"']").attr('for', inputId + '-selectized');
|
1278 |
+
}
|
1279 |
+
|
1280 |
if(self.settings.copyClassesToDropdown) {
|
1281 |
$dropdown.addClass(classes);
|
1282 |
}
|
1283 |
+
|
1284 |
$wrapper.css({
|
1285 |
width: $input[0].style.width
|
1286 |
});
|
1287 |
+
|
1288 |
if (self.plugins.names.length) {
|
1289 |
classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
|
1290 |
$wrapper.addClass(classes_plugins);
|
1291 |
$dropdown.addClass(classes_plugins);
|
1292 |
}
|
1293 |
+
|
1294 |
if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
|
1295 |
$input.attr('multiple', 'multiple');
|
1296 |
}
|
1297 |
+
|
1298 |
if (self.settings.placeholder) {
|
1299 |
$control_input.attr('placeholder', settings.placeholder);
|
1300 |
}
|
1301 |
+
|
1302 |
// if splitOn was not passed in, construct it from the delimiter to allow pasting universally
|
1303 |
if (!self.settings.splitOn && self.settings.delimiter) {
|
1304 |
var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
1305 |
self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
|
1306 |
}
|
1307 |
+
|
1308 |
if ($input.attr('autocorrect')) {
|
1309 |
$control_input.attr('autocorrect', $input.attr('autocorrect'));
|
1310 |
}
|
1311 |
+
|
1312 |
if ($input.attr('autocapitalize')) {
|
1313 |
$control_input.attr('autocapitalize', $input.attr('autocapitalize'));
|
1314 |
}
|
1315 |
+
$control_input[0].type = $input[0].type;
|
1316 |
+
|
1317 |
self.$wrapper = $wrapper;
|
1318 |
self.$control = $control;
|
1319 |
self.$control_input = $control_input;
|
1320 |
self.$dropdown = $dropdown;
|
1321 |
self.$dropdown_content = $dropdown_content;
|
1322 |
+
|
1323 |
+
$dropdown.on('mouseenter mousedown click', '[data-disabled]>[data-selectable]', function(e) { e.stopImmediatePropagation(); });
|
1324 |
$dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
|
1325 |
$dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
|
1326 |
watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
|
1327 |
autoGrow($control_input);
|
1328 |
+
|
1329 |
$control.on({
|
1330 |
mousedown : function() { return self.onMouseDown.apply(self, arguments); },
|
1331 |
click : function() { return self.onClick.apply(self, arguments); }
|
1332 |
});
|
1333 |
+
|
1334 |
$control_input.on({
|
1335 |
mousedown : function(e) { e.stopPropagation(); },
|
1336 |
keydown : function() { return self.onKeyDown.apply(self, arguments); },
|
1341 |
focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
|
1342 |
paste : function() { return self.onPaste.apply(self, arguments); }
|
1343 |
});
|
1344 |
+
|
1345 |
$document.on('keydown' + eventNS, function(e) {
|
1346 |
self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
|
1347 |
self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
|
1348 |
self.isShiftDown = e.shiftKey;
|
1349 |
});
|
1350 |
+
|
1351 |
$document.on('keyup' + eventNS, function(e) {
|
1352 |
if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
|
1353 |
if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
|
1354 |
if (e.keyCode === KEY_CMD) self.isCmdDown = false;
|
1355 |
});
|
1356 |
+
|
1357 |
$document.on('mousedown' + eventNS, function(e) {
|
1358 |
if (self.isFocused) {
|
1359 |
// prevent events on the dropdown scrollbar from causing the control to blur
|
1366 |
}
|
1367 |
}
|
1368 |
});
|
1369 |
+
|
1370 |
$window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function() {
|
1371 |
if (self.isOpen) {
|
1372 |
self.positionDropdown.apply(self, arguments);
|
1375 |
$window.on('mousemove' + eventNS, function() {
|
1376 |
self.ignoreHover = false;
|
1377 |
});
|
1378 |
+
|
1379 |
// store original children and tab index so that they can be
|
1380 |
// restored when the destroy() method is called.
|
1381 |
this.revertSettings = {
|
1382 |
$children : $input.children().detach(),
|
1383 |
tabindex : $input.attr('tabindex')
|
1384 |
};
|
1385 |
+
|
1386 |
$input.attr('tabindex', -1).hide().after(self.$wrapper);
|
1387 |
+
|
1388 |
if ($.isArray(settings.items)) {
|
1389 |
self.setValue(settings.items);
|
1390 |
delete settings.items;
|
1391 |
}
|
1392 |
+
|
1393 |
// feature detect for the validation API
|
1394 |
if (SUPPORTS_VALIDITY_API) {
|
1395 |
$input.on('invalid' + eventNS, function(e) {
|
1398 |
self.refreshState();
|
1399 |
});
|
1400 |
}
|
1401 |
+
|
1402 |
self.updateOriginalInput();
|
1403 |
self.refreshItems();
|
1404 |
self.refreshState();
|
1405 |
self.updatePlaceholder();
|
1406 |
self.isSetup = true;
|
1407 |
+
|
1408 |
if ($input.is(':disabled')) {
|
1409 |
self.disable();
|
1410 |
}
|
1411 |
+
|
1412 |
self.on('change', this.onChange);
|
1413 |
+
|
1414 |
$input.data('selectize', self);
|
1415 |
$input.addClass('selectized');
|
1416 |
self.trigger('initialize');
|
1417 |
+
|
1418 |
// preload options
|
1419 |
if (settings.preload === true) {
|
1420 |
self.onSearchChange('');
|
1421 |
}
|
1422 |
+
|
1423 |
},
|
1424 |
+
|
1425 |
/**
|
1426 |
* Sets up default rendering functions.
|
1427 |
*/
|
1429 |
var self = this;
|
1430 |
var field_label = self.settings.labelField;
|
1431 |
var field_optgroup = self.settings.optgroupLabelField;
|
1432 |
+
|
1433 |
var templates = {
|
1434 |
'optgroup': function(data) {
|
1435 |
return '<div class="optgroup">' + data.html + '</div>';
|
1447 |
return '<div class="create">Add <strong>' + escape(data.input) + '</strong>…</div>';
|
1448 |
}
|
1449 |
};
|
1450 |
+
|
1451 |
self.settings.render = $.extend({}, templates, self.settings.render);
|
1452 |
},
|
1453 |
+
|
1454 |
/**
|
1455 |
* Maps fired events to callbacks provided
|
1456 |
* in the settings used when creating the control.
|
1473 |
'type' : 'onType',
|
1474 |
'load' : 'onLoad',
|
1475 |
'focus' : 'onFocus',
|
1476 |
+
'blur' : 'onBlur',
|
1477 |
+
'dropdown_item_activate' : 'onDropdownItemActivate',
|
1478 |
+
'dropdown_item_deactivate' : 'onDropdownItemDeactivate'
|
1479 |
};
|
1480 |
+
|
1481 |
for (key in callbacks) {
|
1482 |
if (callbacks.hasOwnProperty(key)) {
|
1483 |
fn = this.settings[callbacks[key]];
|
1485 |
}
|
1486 |
}
|
1487 |
},
|
1488 |
+
|
1489 |
/**
|
1490 |
* Triggered when the main control element
|
1491 |
* has a click event.
|
1495 |
*/
|
1496 |
onClick: function(e) {
|
1497 |
var self = this;
|
1498 |
+
|
1499 |
// necessary for mobile webkit devices (manual focus triggering
|
1500 |
// is ignored unless invoked within a click event)
|
1501 |
+
// also necessary to reopen a dropdown that has been closed by
|
1502 |
+
// closeAfterSelect
|
1503 |
+
if (!self.isFocused || !self.isOpen) {
|
1504 |
self.focus();
|
1505 |
e.preventDefault();
|
1506 |
}
|
1507 |
},
|
1508 |
+
|
1509 |
/**
|
1510 |
* Triggered when the main control element
|
1511 |
* has a mouse down event.
|
1517 |
var self = this;
|
1518 |
var defaultPrevented = e.isDefaultPrevented();
|
1519 |
var $target = $(e.target);
|
1520 |
+
|
1521 |
if (self.isFocused) {
|
1522 |
// retain focus by preventing native handling. if the
|
1523 |
// event target is the input it should not be modified.
|
1540 |
}
|
1541 |
}
|
1542 |
},
|
1543 |
+
|
1544 |
/**
|
1545 |
* Triggered when the value of the control has been changed.
|
1546 |
* This should propagate the event to the original DOM
|
1549 |
onChange: function() {
|
1550 |
this.$input.trigger('change');
|
1551 |
},
|
1552 |
+
|
1553 |
/**
|
1554 |
* Triggered on <input> paste.
|
1555 |
*
|
1558 |
*/
|
1559 |
onPaste: function(e) {
|
1560 |
var self = this;
|
1561 |
+
|
1562 |
if (self.isFull() || self.isInputHidden || self.isLocked) {
|
1563 |
e.preventDefault();
|
1564 |
+
return;
|
1565 |
+
}
|
1566 |
+
|
1567 |
+
// If a regex or string is included, this will split the pasted
|
1568 |
+
// input and create Items for each separate value
|
1569 |
+
if (self.settings.splitOn) {
|
1570 |
+
|
1571 |
+
// Wait for pasted text to be recognized in value
|
1572 |
+
setTimeout(function() {
|
1573 |
+
var pastedText = self.$control_input.val();
|
1574 |
+
if(!pastedText.match(self.settings.splitOn)){ return }
|
1575 |
+
|
1576 |
+
var splitInput = $.trim(pastedText).split(self.settings.splitOn);
|
1577 |
+
for (var i = 0, n = splitInput.length; i < n; i++) {
|
1578 |
+
self.createItem(splitInput[i]);
|
1579 |
+
}
|
1580 |
+
}, 0);
|
1581 |
}
|
1582 |
},
|
1583 |
+
|
1584 |
/**
|
1585 |
* Triggered on <input> keypress.
|
1586 |
*
|
1596 |
return false;
|
1597 |
}
|
1598 |
},
|
1599 |
+
|
1600 |
/**
|
1601 |
* Triggered on <input> keydown.
|
1602 |
*
|
1606 |
onKeyDown: function(e) {
|
1607 |
var isInput = e.target === this.$control_input[0];
|
1608 |
var self = this;
|
1609 |
+
|
1610 |
if (self.isLocked) {
|
1611 |
if (e.keyCode !== KEY_TAB) {
|
1612 |
e.preventDefault();
|
1613 |
}
|
1614 |
return;
|
1615 |
}
|
1616 |
+
|
1617 |
switch (e.keyCode) {
|
1618 |
case KEY_A:
|
1619 |
if (self.isCmdDown) {
|
1665 |
case KEY_TAB:
|
1666 |
if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
|
1667 |
self.onOptionSelect({currentTarget: self.$activeOption});
|
1668 |
+
|
1669 |
// Default behaviour is to jump to the next field, we only want this
|
1670 |
// if the current field doesn't accept any more entries
|
1671 |
if (!self.isFull()) {
|
1681 |
self.deleteSelection(e);
|
1682 |
return;
|
1683 |
}
|
1684 |
+
|
1685 |
if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
|
1686 |
e.preventDefault();
|
1687 |
return;
|
1688 |
}
|
1689 |
},
|
1690 |
+
|
1691 |
/**
|
1692 |
* Triggered on <input> keyup.
|
1693 |
*
|
1696 |
*/
|
1697 |
onKeyUp: function(e) {
|
1698 |
var self = this;
|
1699 |
+
|
1700 |
if (self.isLocked) return e && e.preventDefault();
|
1701 |
var value = self.$control_input.val() || '';
|
1702 |
if (self.lastValue !== value) {
|
1706 |
self.trigger('type', value);
|
1707 |
}
|
1708 |
},
|
1709 |
+
|
1710 |
/**
|
1711 |
* Invokes the user-provide option provider / loader.
|
1712 |
*
|
1713 |
* Note: this function is debounced in the Selectize
|
1714 |
+
* constructor (by `settings.loadThrottle` milliseconds)
|
1715 |
*
|
1716 |
* @param {string} value
|
1717 |
*/
|
1725 |
fn.apply(self, [value, callback]);
|
1726 |
});
|
1727 |
},
|
1728 |
+
|
1729 |
/**
|
1730 |
* Triggered on <input> focus.
|
1731 |
*
|
1735 |
onFocus: function(e) {
|
1736 |
var self = this;
|
1737 |
var wasFocused = self.isFocused;
|
1738 |
+
|
1739 |
if (self.isDisabled) {
|
1740 |
self.blur();
|
1741 |
e && e.preventDefault();
|
1742 |
return false;
|
1743 |
}
|
1744 |
+
|
1745 |
if (self.ignoreFocus) return;
|
1746 |
self.isFocused = true;
|
1747 |
if (self.settings.preload === 'focus') self.onSearchChange('');
|
1748 |
+
|
1749 |
if (!wasFocused) self.trigger('focus');
|
1750 |
+
|
1751 |
if (!self.$activeItems.length) {
|
1752 |
self.showInput();
|
1753 |
self.setActiveItem(null);
|
1754 |
self.refreshOptions(!!self.settings.openOnFocus);
|
1755 |
}
|
1756 |
+
|
1757 |
self.refreshState();
|
1758 |
},
|
1759 |
+
|
1760 |
/**
|
1761 |
* Triggered on <input> blur.
|
1762 |
*
|
1767 |
var self = this;
|
1768 |
if (!self.isFocused) return;
|
1769 |
self.isFocused = false;
|
1770 |
+
|
1771 |
if (self.ignoreFocus) {
|
1772 |
return;
|
1773 |
} else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
|
1776 |
self.onFocus(e);
|
1777 |
return;
|
1778 |
}
|
1779 |
+
|
1780 |
var deactivate = function() {
|
1781 |
self.close();
|
1782 |
self.setTextboxValue('');
|
1784 |
self.setActiveOption(null);
|
1785 |
self.setCaret(self.items.length);
|
1786 |
self.refreshState();
|
1787 |
+
|
1788 |
// IE11 bug: element still marked as active
|
1789 |
+
dest && dest.focus && dest.focus();
|
1790 |
+
|
1791 |
+
self.isBlurring = false;
|
1792 |
self.ignoreFocus = false;
|
1793 |
self.trigger('blur');
|
1794 |
};
|
1795 |
+
|
1796 |
+
self.isBlurring = true;
|
1797 |
self.ignoreFocus = true;
|
1798 |
if (self.settings.create && self.settings.createOnBlur) {
|
1799 |
self.createItem(null, false, deactivate);
|
1801 |
deactivate();
|
1802 |
}
|
1803 |
},
|
1804 |
+
|
1805 |
/**
|
1806 |
* Triggered when the user rolls over
|
1807 |
* an option in the autocomplete dropdown menu.
|
1813 |
if (this.ignoreHover) return;
|
1814 |
this.setActiveOption(e.currentTarget, false);
|
1815 |
},
|
1816 |
+
|
1817 |
/**
|
1818 |
* Triggered when the user clicks on an option
|
1819 |
* in the autocomplete dropdown menu.
|
1823 |
*/
|
1824 |
onOptionSelect: function(e) {
|
1825 |
var value, $target, $option, self = this;
|
1826 |
+
|
1827 |
if (e.preventDefault) {
|
1828 |
e.preventDefault();
|
1829 |
e.stopPropagation();
|
1830 |
}
|
1831 |
+
|
1832 |
$target = $(e.currentTarget);
|
1833 |
if ($target.hasClass('create')) {
|
1834 |
self.createItem(null, function() {
|
1850 |
}
|
1851 |
}
|
1852 |
},
|
1853 |
+
|
1854 |
/**
|
1855 |
* Triggered when the user clicks on an item
|
1856 |
* that has been selected.
|
1860 |
*/
|
1861 |
onItemSelect: function(e) {
|
1862 |
var self = this;
|
1863 |
+
|
1864 |
if (self.isLocked) return;
|
1865 |
if (self.settings.mode === 'multi') {
|
1866 |
e.preventDefault();
|
1867 |
self.setActiveItem(e.currentTarget, e);
|
1868 |
}
|
1869 |
},
|
1870 |
+
|
1871 |
/**
|
1872 |
* Invokes the provided method that provides
|
1873 |
* results to a callback---which are then added
|
1878 |
load: function(fn) {
|
1879 |
var self = this;
|
1880 |
var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
|
1881 |
+
|
1882 |
self.loading++;
|
1883 |
fn.apply(self, [function(results) {
|
1884 |
self.loading = Math.max(self.loading - 1, 0);
|
1892 |
self.trigger('load', results);
|
1893 |
}]);
|
1894 |
},
|
1895 |
+
|
1896 |
/**
|
1897 |
* Sets the input field of the control to the specified value.
|
1898 |
*
|
1906 |
this.lastValue = value;
|
1907 |
}
|
1908 |
},
|
1909 |
+
|
1910 |
/**
|
1911 |
* Returns the value of the control. If multiple items
|
1912 |
* can be selected (e.g. <select multiple>), this returns
|
1922 |
return this.items.join(this.settings.delimiter);
|
1923 |
}
|
1924 |
},
|
1925 |
+
|
1926 |
/**
|
1927 |
* Resets the selected items to the given value.
|
1928 |
*
|
1930 |
*/
|
1931 |
setValue: function(value, silent) {
|
1932 |
var events = silent ? [] : ['change'];
|
1933 |
+
|
1934 |
debounce_events(this, events, function() {
|
1935 |
this.clear(silent);
|
1936 |
this.addItems(value, silent);
|
1937 |
});
|
1938 |
},
|
1939 |
+
|
1940 |
+
/**
|
1941 |
+
* Resets the number of max items to the given value
|
1942 |
+
*
|
1943 |
+
* @param {number} value
|
1944 |
+
*/
|
1945 |
+
setMaxItems: function(value){
|
1946 |
+
if(value === 0) value = null; //reset to unlimited items.
|
1947 |
+
this.settings.maxItems = value;
|
1948 |
+
this.settings.mode = this.settings.mode || (this.settings.maxItems === 1 ? 'single' : 'multi');
|
1949 |
+
this.refreshState();
|
1950 |
+
},
|
1951 |
+
|
1952 |
/**
|
1953 |
* Sets the selected item.
|
1954 |
*
|
1960 |
var eventName;
|
1961 |
var i, idx, begin, end, item, swap;
|
1962 |
var $last;
|
1963 |
+
|
1964 |
if (self.settings.mode === 'single') return;
|
1965 |
$item = $($item);
|
1966 |
+
|
1967 |
// clear the active selection
|
1968 |
if (!$item.length) {
|
1969 |
$(self.$activeItems).removeClass('active');
|
1973 |
}
|
1974 |
return;
|
1975 |
}
|
1976 |
+
|
1977 |
// modify selection
|
1978 |
eventName = e && e.type.toLowerCase();
|
1979 |
+
|
1980 |
if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
|
1981 |
$last = self.$control.children('.active:last');
|
1982 |
begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
|
2006 |
$(self.$activeItems).removeClass('active');
|
2007 |
self.$activeItems = [$item.addClass('active')[0]];
|
2008 |
}
|
2009 |
+
|
2010 |
// ensure control has focus
|
2011 |
self.hideInput();
|
2012 |
if (!this.isFocused) {
|
2013 |
self.focus();
|
2014 |
}
|
2015 |
},
|
2016 |
+
|
2017 |
/**
|
2018 |
* Sets the selected item in the dropdown menu
|
2019 |
* of available options.
|
2026 |
var height_menu, height_item, y;
|
2027 |
var scroll_top, scroll_bottom;
|
2028 |
var self = this;
|
2029 |
+
|
2030 |
+
if (self.$activeOption) {
|
2031 |
+
self.$activeOption.removeClass('active');
|
2032 |
+
self.trigger('dropdown_item_deactivate', self.$activeOption.attr('data-value'));
|
2033 |
+
}
|
2034 |
self.$activeOption = null;
|
2035 |
+
|
2036 |
$option = $($option);
|
2037 |
if (!$option.length) return;
|
2038 |
+
|
2039 |
self.$activeOption = $option.addClass('active');
|
2040 |
+
if (self.isOpen) self.trigger('dropdown_item_activate', self.$activeOption.attr('data-value'));
|
2041 |
+
|
2042 |
if (scroll || !isset(scroll)) {
|
2043 |
+
|
2044 |
height_menu = self.$dropdown_content.height();
|
2045 |
height_item = self.$activeOption.outerHeight(true);
|
2046 |
scroll = self.$dropdown_content.scrollTop() || 0;
|
2047 |
y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
|
2048 |
scroll_top = y;
|
2049 |
scroll_bottom = y - height_menu + height_item;
|
2050 |
+
|
2051 |
if (y + height_item > height_menu + scroll) {
|
2052 |
self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
|
2053 |
} else if (y < scroll) {
|
2054 |
self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
|
2055 |
}
|
2056 |
+
|
2057 |
}
|
2058 |
},
|
2059 |
+
|
2060 |
/**
|
2061 |
* Selects all items (CTRL + A).
|
2062 |
*/
|
2063 |
selectAll: function() {
|
2064 |
var self = this;
|
2065 |
if (self.settings.mode === 'single') return;
|
2066 |
+
|
2067 |
self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
|
2068 |
if (self.$activeItems.length) {
|
2069 |
self.hideInput();
|
2071 |
}
|
2072 |
self.focus();
|
2073 |
},
|
2074 |
+
|
2075 |
/**
|
2076 |
* Hides the input element out of view, while
|
2077 |
* retaining its focus.
|
2078 |
*/
|
2079 |
hideInput: function() {
|
2080 |
var self = this;
|
2081 |
+
|
2082 |
self.setTextboxValue('');
|
2083 |
self.$control_input.css({opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000});
|
2084 |
self.isInputHidden = true;
|
2085 |
},
|
2086 |
+
|
2087 |
/**
|
2088 |
* Restores input visibility.
|
2089 |
*/
|
2091 |
this.$control_input.css({opacity: 1, position: 'relative', left: 0});
|
2092 |
this.isInputHidden = false;
|
2093 |
},
|
2094 |
+
|
2095 |
/**
|
2096 |
* Gives the control focus.
|
2097 |
*/
|
2098 |
focus: function() {
|
2099 |
var self = this;
|
2100 |
if (self.isDisabled) return;
|
2101 |
+
|
2102 |
self.ignoreFocus = true;
|
2103 |
self.$control_input[0].focus();
|
2104 |
window.setTimeout(function() {
|
2106 |
self.onFocus();
|
2107 |
}, 0);
|
2108 |
},
|
2109 |
+
|
2110 |
/**
|
2111 |
* Forces the control out of focus.
|
2112 |
*
|
2116 |
this.$control_input[0].blur();
|
2117 |
this.onBlur(null, dest);
|
2118 |
},
|
2119 |
+
|
2120 |
/**
|
2121 |
* Returns a function that scores an object
|
2122 |
* to show how good of a match it is to the
|
2129 |
getScoreFunction: function(query) {
|
2130 |
return this.sifter.getScoreFunction(query, this.getSearchOptions());
|
2131 |
},
|
2132 |
+
|
2133 |
/**
|
2134 |
* Returns search options for sifter (the system
|
2135 |
* for scoring and sorting results).
|
2143 |
if (typeof sort === 'string') {
|
2144 |
sort = [{field: sort}];
|
2145 |
}
|
2146 |
+
|
2147 |
return {
|
2148 |
fields : settings.searchField,
|
2149 |
conjunction : settings.searchConjunction,
|
2150 |
+
sort : sort,
|
2151 |
+
nesting : settings.nesting
|
2152 |
};
|
2153 |
},
|
2154 |
+
|
2155 |
/**
|
2156 |
* Searches through available options and returns
|
2157 |
* a sorted array of matches.
|
2171 |
var self = this;
|
2172 |
var settings = self.settings;
|
2173 |
var options = this.getSearchOptions();
|
2174 |
+
|
2175 |
// validate user-provided result scoring function
|
2176 |
if (settings.score) {
|
2177 |
calculateScore = self.settings.score.apply(this, [query]);
|
2179 |
throw new Error('Selectize "score" setting must be a function that returns a function');
|
2180 |
}
|
2181 |
}
|
2182 |
+
|
2183 |
// perform search
|
2184 |
if (query !== self.lastQuery) {
|
2185 |
self.lastQuery = query;
|
2188 |
} else {
|
2189 |
result = $.extend(true, {}, self.currentResults);
|
2190 |
}
|
2191 |
+
|
2192 |
// filter out selected items
|
2193 |
if (settings.hideSelected) {
|
2194 |
for (i = result.items.length - 1; i >= 0; i--) {
|
2197 |
}
|
2198 |
}
|
2199 |
}
|
2200 |
+
|
2201 |
return result;
|
2202 |
},
|
2203 |
+
|
2204 |
/**
|
2205 |
* Refreshes the list of available options shown
|
2206 |
* in the autocomplete dropdown menu.
|
2210 |
refreshOptions: function(triggerDropdown) {
|
2211 |
var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
|
2212 |
var $active, $active_before, $create;
|
2213 |
+
|
2214 |
if (typeof triggerDropdown === 'undefined') {
|
2215 |
triggerDropdown = true;
|
2216 |
}
|
2217 |
+
|
2218 |
var self = this;
|
2219 |
var query = $.trim(self.$control_input.val());
|
2220 |
var results = self.search(query);
|
2221 |
var $dropdown_content = self.$dropdown_content;
|
2222 |
var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
|
2223 |
+
|
2224 |
// build markup
|
2225 |
n = results.items.length;
|
2226 |
if (typeof self.settings.maxOptions === 'number') {
|
2227 |
n = Math.min(n, self.settings.maxOptions);
|
2228 |
}
|
2229 |
+
|
2230 |
// render and group available options individually
|
2231 |
groups = {};
|
2232 |
groups_order = [];
|
2233 |
+
|
2234 |
for (i = 0; i < n; i++) {
|
2235 |
option = self.options[results.items[i].id];
|
2236 |
option_html = self.render('option', option);
|
2237 |
optgroup = option[self.settings.optgroupField] || '';
|
2238 |
optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
|
2239 |
+
|
2240 |
for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
|
2241 |
optgroup = optgroups[j];
|
2242 |
if (!self.optgroups.hasOwnProperty(optgroup)) {
|
2243 |
optgroup = '';
|
2244 |
}
|
2245 |
if (!groups.hasOwnProperty(optgroup)) {
|
2246 |
+
groups[optgroup] = document.createDocumentFragment();
|
2247 |
groups_order.push(optgroup);
|
2248 |
}
|
2249 |
+
groups[optgroup].appendChild(option_html);
|
2250 |
}
|
2251 |
}
|
2252 |
+
|
2253 |
// sort optgroups
|
2254 |
if (this.settings.lockOptgroupOrder) {
|
2255 |
groups_order.sort(function(a, b) {
|
2258 |
return a_order - b_order;
|
2259 |
});
|
2260 |
}
|
2261 |
+
|
2262 |
// render optgroup headers & join groups
|
2263 |
+
html = document.createDocumentFragment();
|
2264 |
for (i = 0, n = groups_order.length; i < n; i++) {
|
2265 |
optgroup = groups_order[i];
|
2266 |
+
if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
|
2267 |
// render the optgroup header and options within it,
|
2268 |
// then pass it to the wrapper template
|
2269 |
+
html_children = document.createDocumentFragment();
|
2270 |
+
html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
|
2271 |
+
html_children.appendChild(groups[optgroup]);
|
2272 |
+
|
2273 |
+
html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
|
2274 |
+
html: domToString(html_children),
|
2275 |
+
dom: html_children
|
2276 |
})));
|
2277 |
} else {
|
2278 |
+
html.appendChild(groups[optgroup]);
|
2279 |
}
|
2280 |
}
|
2281 |
+
|
2282 |
+
$dropdown_content.html(html);
|
2283 |
+
|
2284 |
// highlight matching terms inline
|
2285 |
+
if (self.settings.highlight) {
|
2286 |
+
$dropdown_content.removeHighlight();
|
2287 |
+
if (results.query.length && results.tokens.length) {
|
2288 |
+
for (i = 0, n = results.tokens.length; i < n; i++) {
|
2289 |
+
highlight($dropdown_content, results.tokens[i].regex);
|
2290 |
+
}
|
2291 |
}
|
2292 |
}
|
2293 |
+
|
2294 |
// add "selected" class to selected options
|
2295 |
if (!self.settings.hideSelected) {
|
2296 |
+
// clear selection on all previously selected elements first
|
2297 |
+
self.$dropdown.find('.selected').removeClass('selected');
|
2298 |
+
|
2299 |
for (i = 0, n = self.items.length; i < n; i++) {
|
2300 |
self.getOption(self.items[i]).addClass('selected');
|
2301 |
}
|
2302 |
}
|
2303 |
+
|
2304 |
// add create option
|
2305 |
has_create_option = self.canCreate(query);
|
2306 |
if (has_create_option) {
|
2307 |
$dropdown_content.prepend(self.render('option_create', {input: query}));
|
2308 |
$create = $($dropdown_content[0].childNodes[0]);
|
2309 |
}
|
2310 |
+
|
2311 |
// activate
|
2312 |
self.hasOptions = results.items.length > 0 || has_create_option;
|
2313 |
if (self.hasOptions) {
|
2335 |
if (triggerDropdown && self.isOpen) { self.close(); }
|
2336 |
}
|
2337 |
},
|
2338 |
+
|
2339 |
/**
|
2340 |
* Adds an available option. If it already exists,
|
2341 |
* nothing will happen. Note: this does not refresh
|
2350 |
*/
|
2351 |
addOption: function(data) {
|
2352 |
var i, n, value, self = this;
|
2353 |
+
|
2354 |
if ($.isArray(data)) {
|
2355 |
for (i = 0, n = data.length; i < n; i++) {
|
2356 |
self.addOption(data[i]);
|
2357 |
}
|
2358 |
return;
|
2359 |
}
|
2360 |
+
|
2361 |
if (value = self.registerOption(data)) {
|
2362 |
self.userOptions[value] = true;
|
2363 |
self.lastQuery = null;
|
2364 |
self.trigger('option_add', value, data);
|
2365 |
}
|
2366 |
},
|
2367 |
+
|
2368 |
/**
|
2369 |
* Registers an option to the pool of options.
|
2370 |
*
|
2373 |
*/
|
2374 |
registerOption: function(data) {
|
2375 |
var key = hash_key(data[this.settings.valueField]);
|
2376 |
+
if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
|
2377 |
data.$order = data.$order || ++this.order;
|
2378 |
this.options[key] = data;
|
2379 |
return key;
|
2380 |
},
|
2381 |
+
|
2382 |
/**
|
2383 |
* Registers an option group to the pool of option groups.
|
2384 |
*
|
2388 |
registerOptionGroup: function(data) {
|
2389 |
var key = hash_key(data[this.settings.optgroupValueField]);
|
2390 |
if (!key) return false;
|
2391 |
+
|
2392 |
data.$order = data.$order || ++this.order;
|
2393 |
this.optgroups[key] = data;
|
2394 |
return key;
|
2395 |
},
|
2396 |
+
|
2397 |
/**
|
2398 |
* Registers a new optgroup for options
|
2399 |
* to be bucketed into.
|
2407 |
this.trigger('optgroup_add', id, data);
|
2408 |
}
|
2409 |
},
|
2410 |
+
|
2411 |
/**
|
2412 |
* Removes an existing option group.
|
2413 |
*
|
2420 |
this.trigger('optgroup_remove', id);
|
2421 |
}
|
2422 |
},
|
2423 |
+
|
2424 |
/**
|
2425 |
* Clears all existing option groups.
|
2426 |
*/
|
2429 |
this.renderCache = {};
|
2430 |
this.trigger('optgroup_clear');
|
2431 |
},
|
2432 |
+
|
2433 |
/**
|
2434 |
* Updates an option available for selection. If
|
2435 |
* it is visible in the selected items or options
|
2442 |
var self = this;
|
2443 |
var $item, $item_new;
|
2444 |
var value_new, index_item, cache_items, cache_options, order_old;
|
2445 |
+
|
2446 |
value = hash_key(value);
|
2447 |
value_new = hash_key(data[self.settings.valueField]);
|
2448 |
+
|
2449 |
// sanity checks
|
2450 |
if (value === null) return;
|
2451 |
if (!self.options.hasOwnProperty(value)) return;
|
2452 |
if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
|
2453 |
+
|
2454 |
order_old = self.options[value].$order;
|
2455 |
+
|
2456 |
// update references
|
2457 |
if (value_new !== value) {
|
2458 |
delete self.options[value];
|
2463 |
}
|
2464 |
data.$order = data.$order || order_old;
|
2465 |
self.options[value_new] = data;
|
2466 |
+
|
2467 |
// invalidate render cache
|
2468 |
cache_items = self.renderCache['item'];
|
2469 |
cache_options = self.renderCache['option'];
|
2470 |
+
|
2471 |
if (cache_items) {
|
2472 |
delete cache_items[value];
|
2473 |
delete cache_items[value_new];
|
2476 |
delete cache_options[value];
|
2477 |
delete cache_options[value_new];
|
2478 |
}
|
2479 |
+
|
2480 |
// update the item if it's selected
|
2481 |
if (self.items.indexOf(value_new) !== -1) {
|
2482 |
$item = self.getItem(value);
|
2484 |
if ($item.hasClass('active')) $item_new.addClass('active');
|
2485 |
$item.replaceWith($item_new);
|
2486 |
}
|
2487 |
+
|
2488 |
// invalidate last query because we might have updated the sortField
|
2489 |
self.lastQuery = null;
|
2490 |
+
|
2491 |
// update dropdown contents
|
2492 |
if (self.isOpen) {
|
2493 |
self.refreshOptions(false);
|
2494 |
}
|
2495 |
},
|
2496 |
+
|
2497 |
/**
|
2498 |
* Removes a single option.
|
2499 |
*
|
2503 |
removeOption: function(value, silent) {
|
2504 |
var self = this;
|
2505 |
value = hash_key(value);
|
2506 |
+
|
2507 |
var cache_items = self.renderCache['item'];
|
2508 |
var cache_options = self.renderCache['option'];
|
2509 |
if (cache_items) delete cache_items[value];
|
2510 |
if (cache_options) delete cache_options[value];
|
2511 |
+
|
2512 |
delete self.userOptions[value];
|
2513 |
delete self.options[value];
|
2514 |
self.lastQuery = null;
|
2515 |
self.trigger('option_remove', value);
|
2516 |
self.removeItem(value, silent);
|
2517 |
},
|
2518 |
+
|
2519 |
/**
|
2520 |
* Clears all options.
|
2521 |
+
*
|
2522 |
+
* @param {boolean} silent
|
2523 |
*/
|
2524 |
+
clearOptions: function(silent) {
|
2525 |
var self = this;
|
2526 |
+
|
2527 |
self.loadedSearches = {};
|
2528 |
self.userOptions = {};
|
2529 |
self.renderCache = {};
|
2530 |
+
var options = self.options;
|
2531 |
+
$.each(self.options, function(key, value) {
|
2532 |
+
if(self.items.indexOf(key) == -1) {
|
2533 |
+
delete options[key];
|
2534 |
+
}
|
2535 |
+
});
|
2536 |
+
self.options = self.sifter.items = options;
|
2537 |
self.lastQuery = null;
|
2538 |
self.trigger('option_clear');
|
2539 |
+
self.clear(silent);
|
2540 |
},
|
2541 |
+
|
2542 |
/**
|
2543 |
* Returns the jQuery element of the option
|
2544 |
* matching the given value.
|
2549 |
getOption: function(value) {
|
2550 |
return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
|
2551 |
},
|
2552 |
+
|
2553 |
/**
|
2554 |
* Returns the jQuery element of the next or
|
2555 |
* previous selectable option.
|
2561 |
getAdjacentOption: function($option, direction) {
|
2562 |
var $options = this.$dropdown.find('[data-selectable]');
|
2563 |
var index = $options.index($option) + direction;
|
2564 |
+
|
2565 |
return index >= 0 && index < $options.length ? $options.eq(index) : $();
|
2566 |
},
|
2567 |
+
|
2568 |
/**
|
2569 |
* Finds the first element with a "data-value" attribute
|
2570 |
* that matches the given value.
|
2575 |
*/
|
2576 |
getElementWithValue: function(value, $els) {
|
2577 |
value = hash_key(value);
|
2578 |
+
|
2579 |
if (typeof value !== 'undefined' && value !== null) {
|
2580 |
for (var i = 0, n = $els.length; i < n; i++) {
|
2581 |
if ($els[i].getAttribute('data-value') === value) {
|
2583 |
}
|
2584 |
}
|
2585 |
}
|
2586 |
+
|
2587 |
return $();
|
2588 |
},
|
2589 |
+
|
2590 |
/**
|
2591 |
* Returns the jQuery element of the item
|
2592 |
* matching the given value.
|
2597 |
getItem: function(value) {
|
2598 |
return this.getElementWithValue(value, this.$control.children());
|
2599 |
},
|
2600 |
+
|
2601 |
/**
|
2602 |
* "Selects" multiple items at once. Adds them to the list
|
2603 |
* at the current caret position.
|
2606 |
* @param {boolean} silent
|
2607 |
*/
|
2608 |
addItems: function(values, silent) {
|
2609 |
+
this.buffer = document.createDocumentFragment();
|
2610 |
+
|
2611 |
+
var childNodes = this.$control[0].childNodes;
|
2612 |
+
for (var i = 0; i < childNodes.length; i++) {
|
2613 |
+
this.buffer.appendChild(childNodes[i]);
|
2614 |
+
}
|
2615 |
+
|
2616 |
var items = $.isArray(values) ? values : [values];
|
2617 |
for (var i = 0, n = items.length; i < n; i++) {
|
2618 |
this.isPending = (i < n - 1);
|
2619 |
this.addItem(items[i], silent);
|
2620 |
}
|
2621 |
+
|
2622 |
+
var control = this.$control[0];
|
2623 |
+
control.insertBefore(this.buffer, control.firstChild);
|
2624 |
+
|
2625 |
+
this.buffer = null;
|
2626 |
},
|
2627 |
+
|
2628 |
/**
|
2629 |
* "Selects" an item. Adds it to the list
|
2630 |
* at the current caret position.
|
2634 |
*/
|
2635 |
addItem: function(value, silent) {
|
2636 |
var events = silent ? [] : ['change'];
|
2637 |
+
|
2638 |
debounce_events(this, events, function() {
|
2639 |
var $item, $option, $options;
|
2640 |
var self = this;
|
2641 |
var inputMode = self.settings.mode;
|
2642 |
var i, active, value_next, wasFull;
|
2643 |
value = hash_key(value);
|
2644 |
+
|
2645 |
if (self.items.indexOf(value) !== -1) {
|
2646 |
if (inputMode === 'single') self.close();
|
2647 |
return;
|
2648 |
}
|
2649 |
+
|
2650 |
if (!self.options.hasOwnProperty(value)) return;
|
2651 |
if (inputMode === 'single') self.clear(silent);
|
2652 |
if (inputMode === 'multi' && self.isFull()) return;
|
2653 |
+
|
2654 |
$item = $(self.render('item', self.options[value]));
|
2655 |
wasFull = self.isFull();
|
2656 |
self.items.splice(self.caretPos, 0, value);
|
2658 |
if (!self.isPending || (!wasFull && self.isFull())) {
|
2659 |
self.refreshState();
|
2660 |
}
|
2661 |
+
|
2662 |
if (self.isSetup) {
|
2663 |
$options = self.$dropdown_content.find('[data-selectable]');
|
2664 |
+
|
2665 |
// update menu / remove the option (if this is not one item being added as part of series)
|
2666 |
if (!self.isPending) {
|
2667 |
$option = self.getOption(value);
|
2671 |
self.setActiveOption(self.getOption(value_next));
|
2672 |
}
|
2673 |
}
|
2674 |
+
|
2675 |
// hide the menu if the maximum number of items have been selected or no options are left
|
2676 |
if (!$options.length || self.isFull()) {
|
2677 |
self.close();
|
2678 |
+
} else if (!self.isPending) {
|
2679 |
self.positionDropdown();
|
2680 |
}
|
2681 |
+
|
2682 |
self.updatePlaceholder();
|
2683 |
self.trigger('item_add', value, $item);
|
2684 |
+
|
2685 |
+
if (!self.isPending) {
|
2686 |
+
self.updateOriginalInput({silent: silent});
|
2687 |
+
}
|
2688 |
}
|
2689 |
});
|
2690 |
},
|
2691 |
+
|
2692 |
/**
|
2693 |
* Removes the selected item matching
|
2694 |
* the provided value.
|
2698 |
removeItem: function(value, silent) {
|
2699 |
var self = this;
|
2700 |
var $item, i, idx;
|
2701 |
+
|
2702 |
+
$item = (value instanceof $) ? value : self.getItem(value);
|
2703 |
value = hash_key($item.attr('data-value'));
|
2704 |
i = self.items.indexOf(value);
|
2705 |
+
|
2706 |
if (i !== -1) {
|
2707 |
$item.remove();
|
2708 |
if ($item.hasClass('active')) {
|
2709 |
idx = self.$activeItems.indexOf($item[0]);
|
2710 |
self.$activeItems.splice(idx, 1);
|
2711 |
}
|
2712 |
+
|
2713 |
self.items.splice(i, 1);
|
2714 |
self.lastQuery = null;
|
2715 |
if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
|
2716 |
self.removeOption(value, silent);
|
2717 |
}
|
2718 |
+
|
2719 |
if (i < self.caretPos) {
|
2720 |
self.setCaret(self.caretPos - 1);
|
2721 |
}
|
2722 |
+
|
2723 |
self.refreshState();
|
2724 |
self.updatePlaceholder();
|
2725 |
self.updateOriginalInput({silent: silent});
|
2727 |
self.trigger('item_remove', value, $item);
|
2728 |
}
|
2729 |
},
|
2730 |
+
|
2731 |
/**
|
2732 |
* Invokes the `create` method provided in the
|
2733 |
* selectize options that should provide the data
|
2745 |
var self = this;
|
2746 |
var caret = self.caretPos;
|
2747 |
input = input || $.trim(self.$control_input.val() || '');
|
2748 |
+
|
2749 |
var callback = arguments[arguments.length - 1];
|
2750 |
if (typeof callback !== 'function') callback = function() {};
|
2751 |
+
|
2752 |
if (typeof triggerDropdown !== 'boolean') {
|
2753 |
triggerDropdown = true;
|
2754 |
}
|
2755 |
+
|
2756 |
if (!self.canCreate(input)) {
|
2757 |
callback();
|
2758 |
return false;
|
2759 |
}
|
2760 |
+
|
2761 |
self.lock();
|
2762 |
+
|
2763 |
var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
|
2764 |
var data = {};
|
2765 |
data[self.settings.labelField] = input;
|
2766 |
data[self.settings.valueField] = input;
|
2767 |
return data;
|
2768 |
};
|
2769 |
+
|
2770 |
var create = once(function(data) {
|
2771 |
self.unlock();
|
2772 |
+
|
2773 |
if (!data || typeof data !== 'object') return callback();
|
2774 |
var value = hash_key(data[self.settings.valueField]);
|
2775 |
if (typeof value !== 'string') return callback();
|
2776 |
+
|
2777 |
self.setTextboxValue('');
|
2778 |
self.addOption(data);
|
2779 |
self.setCaret(caret);
|
2781 |
self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
|
2782 |
callback(data);
|
2783 |
});
|
2784 |
+
|
2785 |
var output = setup.apply(this, [input, create]);
|
2786 |
if (typeof output !== 'undefined') {
|
2787 |
create(output);
|
2788 |
}
|
2789 |
+
|
2790 |
return true;
|
2791 |
},
|
2792 |
+
|
2793 |
/**
|
2794 |
* Re-renders the selected item lists.
|
2795 |
*/
|
2796 |
refreshItems: function() {
|
2797 |
this.lastQuery = null;
|
2798 |
+
|
2799 |
if (this.isSetup) {
|
2800 |
this.addItem(this.items);
|
2801 |
}
|
2802 |
+
|
2803 |
this.refreshState();
|
2804 |
this.updateOriginalInput();
|
2805 |
},
|
2806 |
+
|
2807 |
/**
|
2808 |
* Updates all state-dependent attributes
|
2809 |
* and CSS classes.
|
2810 |
*/
|
2811 |
refreshState: function() {
|
2812 |
+
this.refreshValidityState();
|
2813 |
+
this.refreshClasses();
|
|
|
|
|
|
|
|
|
2814 |
},
|
2815 |
+
|
2816 |
+
/**
|
2817 |
+
* Update the `required` attribute of both input and control input.
|
2818 |
+
*
|
2819 |
+
* The `required` property needs to be activated on the control input
|
2820 |
+
* for the error to be displayed at the right place. `required` also
|
2821 |
+
* needs to be temporarily deactivated on the input since the input is
|
2822 |
+
* hidden and can't show errors.
|
2823 |
+
*/
|
2824 |
+
refreshValidityState: function() {
|
2825 |
+
if (!this.isRequired) return false;
|
2826 |
+
|
2827 |
+
var invalid = !this.items.length;
|
2828 |
+
|
2829 |
+
this.isInvalid = invalid;
|
2830 |
+
this.$control_input.prop('required', invalid);
|
2831 |
+
this.$input.prop('required', !invalid);
|
2832 |
+
},
|
2833 |
+
|
2834 |
/**
|
2835 |
* Updates all state-dependent CSS classes.
|
2836 |
*/
|
2838 |
var self = this;
|
2839 |
var isFull = self.isFull();
|
2840 |
var isLocked = self.isLocked;
|
2841 |
+
|
2842 |
self.$wrapper
|
2843 |
.toggleClass('rtl', self.rtl);
|
2844 |
+
|
2845 |
self.$control
|
2846 |
.toggleClass('focus', self.isFocused)
|
2847 |
.toggleClass('disabled', self.isDisabled)
|
2853 |
.toggleClass('dropdown-active', self.isOpen)
|
2854 |
.toggleClass('has-options', !$.isEmptyObject(self.options))
|
2855 |
.toggleClass('has-items', self.items.length > 0);
|
2856 |
+
|
2857 |
self.$control_input.data('grow', !isFull && !isLocked);
|
2858 |
},
|
2859 |
+
|
2860 |
/**
|
2861 |
* Determines whether or not more items can be added
|
2862 |
* to the control without exceeding the user-defined maximum.
|
2866 |
isFull: function() {
|
2867 |
return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
|
2868 |
},
|
2869 |
+
|
2870 |
/**
|
2871 |
* Refreshes the original <select> or <input>
|
2872 |
* element to reflect the current state.
|
2874 |
updateOriginalInput: function(opts) {
|
2875 |
var i, n, options, label, self = this;
|
2876 |
opts = opts || {};
|
2877 |
+
|
2878 |
if (self.tagType === TAG_SELECT) {
|
2879 |
options = [];
|
2880 |
for (i = 0, n = self.items.length; i < n; i++) {
|
2889 |
self.$input.val(self.getValue());
|
2890 |
self.$input.attr('value',self.$input.val());
|
2891 |
}
|
2892 |
+
|
2893 |
if (self.isSetup) {
|
2894 |
if (!opts.silent) {
|
2895 |
self.trigger('change', self.$input.val());
|
2896 |
}
|
2897 |
}
|
2898 |
},
|
2899 |
+
|
2900 |
/**
|
2901 |
* Shows/hide the input placeholder depending
|
2902 |
* on if there items in the list already.
|
2904 |
updatePlaceholder: function() {
|
2905 |
if (!this.settings.placeholder) return;
|
2906 |
var $input = this.$control_input;
|
2907 |
+
|
2908 |
if (this.items.length) {
|
2909 |
$input.removeAttr('placeholder');
|
2910 |
} else {
|
2912 |
}
|
2913 |
$input.triggerHandler('update', {force: true});
|
2914 |
},
|
2915 |
+
|
2916 |
/**
|
2917 |
* Shows the autocomplete dropdown containing
|
2918 |
* the available options.
|
2919 |
*/
|
2920 |
open: function() {
|
2921 |
var self = this;
|
2922 |
+
|
2923 |
if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
|
2924 |
self.focus();
|
2925 |
self.isOpen = true;
|
2929 |
self.$dropdown.css({visibility: 'visible'});
|
2930 |
self.trigger('dropdown_open', self.$dropdown);
|
2931 |
},
|
2932 |
+
|
2933 |
/**
|
2934 |
* Closes the autocomplete dropdown menu.
|
2935 |
*/
|
2936 |
close: function() {
|
2937 |
var self = this;
|
2938 |
var trigger = self.isOpen;
|
2939 |
+
|
2940 |
if (self.settings.mode === 'single' && self.items.length) {
|
2941 |
self.hideInput();
|
2942 |
+
|
2943 |
+
// Do not trigger blur while inside a blur event,
|
2944 |
+
// this fixes some weird tabbing behavior in FF and IE.
|
2945 |
+
// See #1164
|
2946 |
+
if (!self.isBlurring) {
|
2947 |
+
self.$control_input.blur(); // close keyboard on iOS
|
2948 |
+
}
|
2949 |
}
|
2950 |
+
|
2951 |
self.isOpen = false;
|
2952 |
self.$dropdown.hide();
|
2953 |
self.setActiveOption(null);
|
2954 |
self.refreshState();
|
2955 |
+
|
2956 |
if (trigger) self.trigger('dropdown_close', self.$dropdown);
|
2957 |
},
|
2958 |
+
|
2959 |
/**
|
2960 |
* Calculates and applies the appropriate
|
2961 |
* position of the dropdown.
|
2964 |
var $control = this.$control;
|
2965 |
var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
|
2966 |
offset.top += $control.outerHeight(true);
|
2967 |
+
|
2968 |
this.$dropdown.css({
|
2969 |
+
width : $control[0].getBoundingClientRect().width,
|
2970 |
top : offset.top,
|
2971 |
left : offset.left
|
2972 |
});
|
2973 |
},
|
2974 |
+
|
2975 |
/**
|
2976 |
* Resets / clears all selected items
|
2977 |
* from the control.
|
2980 |
*/
|
2981 |
clear: function(silent) {
|
2982 |
var self = this;
|
2983 |
+
|
2984 |
if (!self.items.length) return;
|
2985 |
self.$control.children(':not(input)').remove();
|
2986 |
self.items = [];
|
2993 |
self.showInput();
|
2994 |
self.trigger('clear');
|
2995 |
},
|
2996 |
+
|
2997 |
/**
|
2998 |
* A helper method for inserting an element
|
2999 |
* at the current caret position.
|
3002 |
*/
|
3003 |
insertAtCaret: function($el) {
|
3004 |
var caret = Math.min(this.caretPos, this.items.length);
|
3005 |
+
var el = $el[0];
|
3006 |
+
var target = this.buffer || this.$control[0];
|
3007 |
+
|
3008 |
if (caret === 0) {
|
3009 |
+
target.insertBefore(el, target.firstChild);
|
3010 |
} else {
|
3011 |
+
target.insertBefore(el, target.childNodes[caret]);
|
3012 |
}
|
3013 |
+
|
3014 |
this.setCaret(caret + 1);
|
3015 |
},
|
3016 |
+
|
3017 |
/**
|
3018 |
* Removes the current selected item(s).
|
3019 |
*
|
3023 |
deleteSelection: function(e) {
|
3024 |
var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
|
3025 |
var self = this;
|
3026 |
+
|
3027 |
direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
|
3028 |
selection = getSelection(self.$control_input[0]);
|
3029 |
+
|
3030 |
if (self.$activeOption && !self.settings.hideSelected) {
|
3031 |
option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
|
3032 |
}
|
3033 |
+
|
3034 |
// determine items that will be removed
|
3035 |
values = [];
|
3036 |
+
|
3037 |
if (self.$activeItems.length) {
|
3038 |
$tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
|
3039 |
caret = self.$control.children(':not(input)').index($tail);
|
3040 |
if (direction > 0) { caret++; }
|
3041 |
+
|
3042 |
for (i = 0, n = self.$activeItems.length; i < n; i++) {
|
3043 |
values.push($(self.$activeItems[i]).attr('data-value'));
|
3044 |
}
|
3053 |
values.push(self.items[self.caretPos]);
|
3054 |
}
|
3055 |
}
|
3056 |
+
|
3057 |
// allow the callback to abort
|
3058 |
if (!values.length || (typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false)) {
|
3059 |
return false;
|
3060 |
}
|
3061 |
+
|
3062 |
// perform removal
|
3063 |
if (typeof caret !== 'undefined') {
|
3064 |
self.setCaret(caret);
|
3066 |
while (values.length) {
|
3067 |
self.removeItem(values.pop());
|
3068 |
}
|
3069 |
+
|
3070 |
self.showInput();
|
3071 |
self.positionDropdown();
|
3072 |
self.refreshOptions(true);
|
3073 |
+
|
3074 |
// select previous option
|
3075 |
if (option_select) {
|
3076 |
$option_select = self.getOption(option_select);
|
3078 |
self.setActiveOption($option_select);
|
3079 |
}
|
3080 |
}
|
3081 |
+
|
3082 |
return true;
|
3083 |
},
|
3084 |
+
|
3085 |
/**
|
3086 |
* Selects the previous / next item (depending
|
3087 |
* on the `direction` argument).
|
3095 |
advanceSelection: function(direction, e) {
|
3096 |
var tail, selection, idx, valueLength, cursorAtEdge, $tail;
|
3097 |
var self = this;
|
3098 |
+
|
3099 |
if (direction === 0) return;
|
3100 |
if (self.rtl) direction *= -1;
|
3101 |
+
|
3102 |
tail = direction > 0 ? 'last' : 'first';
|
3103 |
selection = getSelection(self.$control_input[0]);
|
3104 |
+
|
3105 |
if (self.isFocused && !self.isInputHidden) {
|
3106 |
valueLength = self.$control_input.val().length;
|
3107 |
cursorAtEdge = direction < 0
|
3108 |
? selection.start === 0 && selection.length === 0
|
3109 |
: selection.start === valueLength;
|
3110 |
+
|
3111 |
if (cursorAtEdge && !valueLength) {
|
3112 |
self.advanceCaret(direction, e);
|
3113 |
}
|
3120 |
}
|
3121 |
}
|
3122 |
},
|
3123 |
+
|
3124 |
/**
|
3125 |
* Moves the caret left / right.
|
3126 |
*
|
3129 |
*/
|
3130 |
advanceCaret: function(direction, e) {
|
3131 |
var self = this, fn, $adj;
|
3132 |
+
|
3133 |
if (direction === 0) return;
|
3134 |
+
|
3135 |
fn = direction > 0 ? 'next' : 'prev';
|
3136 |
if (self.isShiftDown) {
|
3137 |
$adj = self.$control_input[fn]();
|
3144 |
self.setCaret(self.caretPos + direction);
|
3145 |
}
|
3146 |
},
|
3147 |
+
|
3148 |
/**
|
3149 |
* Moves the caret to the specified index.
|
3150 |
*
|
3152 |
*/
|
3153 |
setCaret: function(i) {
|
3154 |
var self = this;
|
3155 |
+
|
3156 |
if (self.settings.mode === 'single') {
|
3157 |
i = self.items.length;
|
3158 |
} else {
|
3159 |
i = Math.max(0, Math.min(self.items.length, i));
|
3160 |
}
|
3161 |
+
|
3162 |
if(!self.isPending) {
|
3163 |
// the input must be moved by leaving it in place and moving the
|
3164 |
// siblings, due to the fact that focus cannot be restored once lost
|
3174 |
}
|
3175 |
}
|
3176 |
}
|
3177 |
+
|
3178 |
self.caretPos = i;
|
3179 |
},
|
3180 |
+
|
3181 |
/**
|
3182 |
* Disables user input on the control. Used while
|
3183 |
* items are being asynchronously created.
|
3187 |
this.isLocked = true;
|
3188 |
this.refreshState();
|
3189 |
},
|
3190 |
+
|
3191 |
/**
|
3192 |
* Re-enables user input on the control.
|
3193 |
*/
|
3195 |
this.isLocked = false;
|
3196 |
this.refreshState();
|
3197 |
},
|
3198 |
+
|
3199 |
/**
|
3200 |
* Disables user input on the control completely.
|
3201 |
* While disabled, it cannot receive focus.
|
3207 |
self.isDisabled = true;
|
3208 |
self.lock();
|
3209 |
},
|
3210 |
+
|
3211 |
/**
|
3212 |
* Enables the control so that it can respond
|
3213 |
* to focus and user input.
|
3219 |
self.isDisabled = false;
|
3220 |
self.unlock();
|
3221 |
},
|
3222 |
+
|
3223 |
/**
|
3224 |
* Completely destroys the control and
|
3225 |
* unbinds all event listeners so that it can
|
3229 |
var self = this;
|
3230 |
var eventNS = self.eventNS;
|
3231 |
var revertSettings = self.revertSettings;
|
3232 |
+
|
3233 |
self.trigger('destroy');
|
3234 |
self.off();
|
3235 |
self.$wrapper.remove();
|
3236 |
self.$dropdown.remove();
|
3237 |
+
|
3238 |
self.$input
|
3239 |
.html('')
|
3240 |
.append(revertSettings.$children)
|
3242 |
.removeClass('selectized')
|
3243 |
.attr({tabindex: revertSettings.tabindex})
|
3244 |
.show();
|
3245 |
+
|
3246 |
self.$control_input.removeData('grow');
|
3247 |
self.$input.removeData('selectize');
|
3248 |
+
|
3249 |
+
if (--Selectize.count == 0 && Selectize.$testInput) {
|
3250 |
+
Selectize.$testInput.remove();
|
3251 |
+
Selectize.$testInput = undefined;
|
3252 |
+
}
|
3253 |
+
|
3254 |
$(window).off(eventNS);
|
3255 |
$(document).off(eventNS);
|
3256 |
$(document.body).off(eventNS);
|
3257 |
+
|
3258 |
delete self.$input[0].selectize;
|
3259 |
},
|
3260 |
+
|
3261 |
/**
|
3262 |
* A helper method for rendering "item" and
|
3263 |
* "option" templates, given the data.
|
3272 |
var cache = false;
|
3273 |
var self = this;
|
3274 |
var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
|
3275 |
+
|
3276 |
if (templateName === 'option' || templateName === 'item') {
|
3277 |
value = hash_key(data[self.settings.valueField]);
|
3278 |
cache = !!value;
|
3279 |
}
|
3280 |
+
|
3281 |
// pull markup from cache if it exists
|
3282 |
if (cache) {
|
3283 |
if (!isset(self.renderCache[templateName])) {
|
3287 |
return self.renderCache[templateName][value];
|
3288 |
}
|
3289 |
}
|
3290 |
+
|
3291 |
// render markup
|
3292 |
+
html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
|
3293 |
+
|
3294 |
// add mandatory attributes
|
3295 |
if (templateName === 'option' || templateName === 'option_create') {
|
3296 |
+
if (!data[self.settings.disabledField]) {
|
3297 |
+
html.attr('data-selectable', '');
|
3298 |
+
}
|
3299 |
}
|
3300 |
+
else if (templateName === 'optgroup') {
|
3301 |
id = data[self.settings.optgroupValueField] || '';
|
3302 |
+
html.attr('data-group', id);
|
3303 |
+
if(data[self.settings.disabledField]) {
|
3304 |
+
html.attr('data-disabled', '');
|
3305 |
+
}
|
3306 |
}
|
3307 |
if (templateName === 'option' || templateName === 'item') {
|
3308 |
+
html.attr('data-value', value || '');
|
3309 |
}
|
3310 |
+
|
3311 |
// update cache
|
3312 |
if (cache) {
|
3313 |
+
self.renderCache[templateName][value] = html[0];
|
3314 |
}
|
3315 |
+
|
3316 |
+
return html[0];
|
3317 |
},
|
3318 |
+
|
3319 |
/**
|
3320 |
* Clears the render cache for a template. If
|
3321 |
* no template is given, clears all render
|
3331 |
delete self.renderCache[templateName];
|
3332 |
}
|
3333 |
},
|
3334 |
+
|
3335 |
/**
|
3336 |
* Determines whether or not to display the
|
3337 |
* create item prompt, given a user input.
|
3348 |
&& (typeof filter !== 'string' || new RegExp(filter).test(input))
|
3349 |
&& (!(filter instanceof RegExp) || filter.test(input));
|
3350 |
}
|
3351 |
+
|
3352 |
});
|
3353 |
+
|
3354 |
+
|
3355 |
Selectize.count = 0;
|
3356 |
Selectize.defaults = {
|
3357 |
options: [],
|
3358 |
optgroups: [],
|
3359 |
+
|
3360 |
plugins: [],
|
3361 |
delimiter: ',',
|
3362 |
splitOn: null, // regexp or string for splitting up values from a paste command
|
3371 |
maxItems: null,
|
3372 |
hideSelected: null,
|
3373 |
addPrecedence: false,
|
3374 |
+
selectOnTab: true,
|
3375 |
preload: false,
|
3376 |
allowEmptyOption: false,
|
3377 |
closeAfterSelect: false,
|
3378 |
+
|
3379 |
scrollDuration: 60,
|
3380 |
loadThrottle: 300,
|
3381 |
loadingClass: 'loading',
|
3382 |
+
|
3383 |
dataAttr: 'data-data',
|
3384 |
optgroupField: 'optgroup',
|
3385 |
valueField: 'value',
|
3386 |
labelField: 'text',
|
3387 |
+
disabledField: 'disabled',
|
3388 |
optgroupLabelField: 'label',
|
3389 |
optgroupValueField: 'value',
|
3390 |
lockOptgroupOrder: false,
|
3391 |
+
|
3392 |
sortField: '$order',
|
3393 |
searchField: ['text'],
|
3394 |
searchConjunction: 'and',
|
3395 |
+
|
3396 |
mode: null,
|
3397 |
wrapperClass: 'selectize-control',
|
3398 |
inputClass: 'selectize-input',
|
3399 |
dropdownClass: 'selectize-dropdown',
|
3400 |
dropdownContentClass: 'selectize-dropdown-content',
|
3401 |
+
|
3402 |
dropdownParent: null,
|
3403 |
+
|
3404 |
copyClassesToDropdown: true,
|
3405 |
+
|
3406 |
/*
|
3407 |
load : null, // function(query, callback) { ... }
|
3408 |
score : null, // function(search) { ... }
|
3422 |
onType : null, // function(str) { ... }
|
3423 |
onDelete : null, // function(values) { ... }
|
3424 |
*/
|
3425 |
+
|
3426 |
render: {
|
3427 |
/*
|
3428 |
item: null,
|
3433 |
*/
|
3434 |
}
|
3435 |
};
|
3436 |
+
|
3437 |
+
|
3438 |
$.fn.selectize = function(settings_user) {
|
3439 |
var defaults = $.fn.selectize.defaults;
|
3440 |
var settings = $.extend({}, defaults, settings_user);
|
3441 |
var attr_data = settings.dataAttr;
|
3442 |
var field_label = settings.labelField;
|
3443 |
var field_value = settings.valueField;
|
3444 |
+
var field_disabled = settings.disabledField;
|
3445 |
var field_optgroup = settings.optgroupField;
|
3446 |
var field_optgroup_label = settings.optgroupLabelField;
|
3447 |
var field_optgroup_value = settings.optgroupValueField;
|
3448 |
+
|
3449 |
/**
|
3450 |
* Initializes selectize from a <input type="text"> element.
|
3451 |
*
|
3454 |
*/
|
3455 |
var init_textbox = function($input, settings_element) {
|
3456 |
var i, n, values, option;
|
3457 |
+
|
3458 |
var data_raw = $input.attr(attr_data);
|
3459 |
+
|
3460 |
if (!data_raw) {
|
3461 |
var value = $.trim($input.val() || '');
|
3462 |
if (!settings.allowEmptyOption && !value.length) return;
|
3475 |
}
|
3476 |
}
|
3477 |
};
|
3478 |
+
|
3479 |
/**
|
3480 |
* Initializes selectize from a <select> element.
|
3481 |
*
|
3486 |
var i, n, tagName, $children, order = 0;
|
3487 |
var options = settings_element.options;
|
3488 |
var optionsMap = {};
|
3489 |
+
|
3490 |
var readData = function($el) {
|
3491 |
var data = attr_data && $el.attr(attr_data);
|
3492 |
if (typeof data === 'string' && data.length) {
|
3494 |
}
|
3495 |
return null;
|
3496 |
};
|
3497 |
+
|
3498 |
var addOption = function($option, group) {
|
3499 |
$option = $($option);
|
3500 |
+
|
3501 |
+
var value = hash_key($option.val());
|
3502 |
if (!value && !settings.allowEmptyOption) return;
|
3503 |
+
|
3504 |
// if the option already exists, it's probably been
|
3505 |
// duplicated in another optgroup. in this case, push
|
3506 |
// the current group to the "optgroup" property on the
|
3518 |
}
|
3519 |
return;
|
3520 |
}
|
3521 |
+
|
3522 |
var option = readData($option) || {};
|
3523 |
option[field_label] = option[field_label] || $option.text();
|
3524 |
option[field_value] = option[field_value] || value;
|
3525 |
+
option[field_disabled] = option[field_disabled] || $option.prop('disabled');
|
3526 |
option[field_optgroup] = option[field_optgroup] || group;
|
3527 |
+
|
3528 |
optionsMap[value] = option;
|
3529 |
options.push(option);
|
3530 |
+
|
3531 |
if ($option.is(':selected')) {
|
3532 |
settings_element.items.push(value);
|
3533 |
}
|
3534 |
};
|
3535 |
+
|
3536 |
var addGroup = function($optgroup) {
|
3537 |
var i, n, id, optgroup, $options;
|
3538 |
+
|
3539 |
$optgroup = $($optgroup);
|
3540 |
id = $optgroup.attr('label');
|
3541 |
+
|
3542 |
if (id) {
|
3543 |
optgroup = readData($optgroup) || {};
|
3544 |
optgroup[field_optgroup_label] = id;
|
3545 |
optgroup[field_optgroup_value] = id;
|
3546 |
+
optgroup[field_disabled] = $optgroup.prop('disabled');
|
3547 |
settings_element.optgroups.push(optgroup);
|
3548 |
}
|
3549 |
+
|
3550 |
$options = $('option', $optgroup);
|
3551 |
for (i = 0, n = $options.length; i < n; i++) {
|
3552 |
addOption($options[i], id);
|
3553 |
}
|
3554 |
};
|
3555 |
+
|
3556 |
settings_element.maxItems = $input.attr('multiple') ? null : 1;
|
3557 |
+
|
3558 |
$children = $input.children();
|
3559 |
for (i = 0, n = $children.length; i < n; i++) {
|
3560 |
tagName = $children[i].tagName.toLowerCase();
|
3565 |
}
|
3566 |
}
|
3567 |
};
|
3568 |
+
|
3569 |
return this.each(function() {
|
3570 |
if (this.selectize) return;
|
3571 |
+
|
3572 |
var instance;
|
3573 |
var $input = $(this);
|
3574 |
var tag_name = this.tagName.toLowerCase();
|
3576 |
if (!placeholder && !settings.allowEmptyOption) {
|
3577 |
placeholder = $input.children('option[value=""]').text();
|
3578 |
}
|
3579 |
+
|
3580 |
var settings_element = {
|
3581 |
'placeholder' : placeholder,
|
3582 |
'options' : [],
|
3583 |
'optgroups' : [],
|
3584 |
'items' : []
|
3585 |
};
|
3586 |
+
|
3587 |
if (tag_name === 'select') {
|
3588 |
init_select($input, settings_element);
|
3589 |
} else {
|
3590 |
init_textbox($input, settings_element);
|
3591 |
}
|
3592 |
+
|
3593 |
instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
|
3594 |
});
|
3595 |
};
|
3596 |
+
|
3597 |
$.fn.selectize.defaults = Selectize.defaults;
|
3598 |
$.fn.selectize.support = {
|
3599 |
validity: SUPPORTS_VALIDITY_API
|
3600 |
};
|
3601 |
+
|
3602 |
+
|
3603 |
+
Selectize.define("autofill_disable", function (options) {
|
3604 |
+
var self = this;
|
3605 |
+
|
3606 |
+
self.setup = (function () {
|
3607 |
+
var original = self.setup;
|
3608 |
+
return function () {
|
3609 |
+
original.apply(self, arguments);
|
3610 |
+
|
3611 |
+
// https://stackoverflow.com/questions/30053167/autocomplete-off-vs-false
|
3612 |
+
self.$control_input.attr({ autocomplete: "new-password", autofill: "no" });
|
3613 |
+
};
|
3614 |
+
})();
|
3615 |
+
});
|
3616 |
+
|
3617 |
+
|
3618 |
Selectize.define('drag_drop', function(options) {
|
3619 |
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
|
3620 |
if (this.settings.mode !== 'multi') return;
|
3621 |
var self = this;
|
3622 |
+
|
3623 |
self.lock = (function() {
|
3624 |
var original = self.lock;
|
3625 |
return function() {
|
3628 |
return original.apply(self, arguments);
|
3629 |
};
|
3630 |
})();
|
3631 |
+
|
3632 |
self.unlock = (function() {
|
3633 |
var original = self.unlock;
|
3634 |
return function() {
|
3637 |
return original.apply(self, arguments);
|
3638 |
};
|
3639 |
})();
|
3640 |
+
|
3641 |
self.setup = (function() {
|
3642 |
var original = self.setup;
|
3643 |
return function() {
|
3644 |
original.apply(this, arguments);
|
3645 |
+
|
3646 |
var $control = self.$control.sortable({
|
3647 |
items: '[data-value]',
|
3648 |
forcePlaceholderSize: true,
|
3664 |
});
|
3665 |
};
|
3666 |
})();
|
3667 |
+
|
3668 |
});
|
3669 |
+
|
3670 |
Selectize.define('dropdown_header', function(options) {
|
3671 |
var self = this;
|
3672 |
+
|
3673 |
options = $.extend({
|
3674 |
title : 'Untitled',
|
3675 |
headerClass : 'selectize-dropdown-header',
|
3676 |
titleRowClass : 'selectize-dropdown-header-title',
|
3677 |
labelClass : 'selectize-dropdown-header-label',
|
3678 |
closeClass : 'selectize-dropdown-header-close',
|
3679 |
+
|
3680 |
html: function(data) {
|
3681 |
return (
|
3682 |
'<div class="' + data.headerClass + '">' +
|
3683 |
+
'<div class="' + data.titleRowClass + '">' +
|
3684 |
+
'<span class="' + data.labelClass + '">' + data.title + '</span>' +
|
3685 |
+
'<a href="javascript:void(0)" class="' + data.closeClass + '">×</a>' +
|
3686 |
+
'</div>' +
|
3687 |
'</div>'
|
3688 |
);
|
3689 |
}
|
3690 |
}, options);
|
3691 |
+
|
3692 |
self.setup = (function() {
|
3693 |
var original = self.setup;
|
3694 |
return function() {
|
3697 |
self.$dropdown.prepend(self.$dropdown_header);
|
3698 |
};
|
3699 |
})();
|
3700 |
+
|
3701 |
});
|
3702 |
+
|
3703 |
Selectize.define('optgroup_columns', function(options) {
|
3704 |
var self = this;
|
3705 |
+
|
3706 |
options = $.extend({
|
3707 |
equalizeWidth : true,
|
3708 |
equalizeHeight : true
|
3709 |
}, options);
|
3710 |
+
|
3711 |
this.getAdjacentOption = function($option, direction) {
|
3712 |
var $options = $option.closest('[data-group]').find('[data-selectable]');
|
3713 |
var index = $options.index($option) + direction;
|
3714 |
+
|
3715 |
return index >= 0 && index < $options.length ? $options.eq(index) : $();
|
3716 |
};
|
3717 |
+
|
3718 |
this.onKeyDown = (function() {
|
3719 |
var original = self.onKeyDown;
|
3720 |
return function(e) {
|
3721 |
var index, $option, $options, $optgroup;
|
3722 |
+
|
3723 |
if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
|
3724 |
self.ignoreHover = true;
|
3725 |
$optgroup = this.$activeOption.closest('[data-group]');
|
3726 |
index = $optgroup.find('[data-selectable]').index(this.$activeOption);
|
3727 |
+
|
3728 |
if(e.keyCode === KEY_LEFT) {
|
3729 |
$optgroup = $optgroup.prev('[data-group]');
|
3730 |
} else {
|
3731 |
$optgroup = $optgroup.next('[data-group]');
|
3732 |
}
|
3733 |
+
|
3734 |
$options = $optgroup.find('[data-selectable]');
|
3735 |
$option = $options.eq(Math.min($options.length - 1, index));
|
3736 |
if ($option.length) {
|
3738 |
}
|
3739 |
return;
|
3740 |
}
|
3741 |
+
|
3742 |
return original.apply(this, arguments);
|
3743 |
};
|
3744 |
})();
|
3745 |
+
|
3746 |
var getScrollbarWidth = function() {
|
3747 |
var div;
|
3748 |
var width = getScrollbarWidth.width;
|
3749 |
var doc = document;
|
3750 |
+
|
3751 |
if (typeof width === 'undefined') {
|
3752 |
div = doc.createElement('div');
|
3753 |
div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
|
3758 |
}
|
3759 |
return width;
|
3760 |
};
|
3761 |
+
|
3762 |
var equalizeSizes = function() {
|
3763 |
var i, n, height_max, width, width_last, width_parent, $optgroups;
|
3764 |
+
|
3765 |
$optgroups = $('[data-group]', self.$dropdown_content);
|
3766 |
n = $optgroups.length;
|
3767 |
if (!n || !self.$dropdown_content.width()) return;
|
3768 |
+
|
3769 |
if (options.equalizeHeight) {
|
3770 |
height_max = 0;
|
3771 |
for (i = 0; i < n; i++) {
|
3773 |
}
|
3774 |
$optgroups.css({height: height_max});
|
3775 |
}
|
3776 |
+
|
3777 |
if (options.equalizeWidth) {
|
3778 |
width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
|
3779 |
width = Math.round(width_parent / n);
|
3784 |
}
|
3785 |
}
|
3786 |
};
|
3787 |
+
|
3788 |
if (options.equalizeHeight || options.equalizeWidth) {
|
3789 |
hook.after(this, 'positionDropdown', equalizeSizes);
|
3790 |
hook.after(this, 'refreshOptions', equalizeSizes);
|
3791 |
}
|
3792 |
+
|
3793 |
+
|
3794 |
});
|
3795 |
+
|
3796 |
Selectize.define('remove_button', function(options) {
|
|
|
|
|
3797 |
options = $.extend({
|
3798 |
label : '×',
|
3799 |
title : 'Remove',
|
3800 |
className : 'remove',
|
3801 |
append : true
|
3802 |
}, options);
|
3803 |
+
|
3804 |
+
var singleClose = function(thisRef, options) {
|
3805 |
+
|
3806 |
+
options.className = 'remove-single';
|
3807 |
+
|
3808 |
+
var self = thisRef;
|
3809 |
+
var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
|
3810 |
+
|
3811 |
+
/**
|
3812 |
+
* Appends an element as a child (with raw HTML).
|
3813 |
+
*
|
3814 |
+
* @param {string} html_container
|
3815 |
+
* @param {string} html_element
|
3816 |
+
* @return {string}
|
3817 |
+
*/
|
3818 |
+
var append = function(html_container, html_element) {
|
3819 |
+
return $('<span>').append(html_container)
|
3820 |
+
.append(html_element);
|
3821 |
+
};
|
3822 |
+
|
3823 |
+
thisRef.setup = (function() {
|
3824 |
+
var original = self.setup;
|
3825 |
+
return function() {
|
3826 |
+
// override the item rendering method to add the button to each
|
3827 |
+
if (options.append) {
|
3828 |
+
var id = $(self.$input.context).attr('id');
|
3829 |
+
var selectizer = $('#'+id);
|
3830 |
+
|
3831 |
+
var render_item = self.settings.render.item;
|
3832 |
+
self.settings.render.item = function(data) {
|
3833 |
+
return append(render_item.apply(thisRef, arguments), html);
|
3834 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
3835 |
}
|
3836 |
+
|
3837 |
+
original.apply(thisRef, arguments);
|
3838 |
+
|
3839 |
+
// add event listener
|
3840 |
+
thisRef.$control.on('click', '.' + options.className, function(e) {
|
3841 |
+
e.preventDefault();
|
3842 |
+
if (self.isLocked) return;
|
3843 |
+
|
3844 |
+
self.clear();
|
3845 |
+
});
|
3846 |
+
|
3847 |
+
};
|
3848 |
+
})();
|
3849 |
+
};
|
3850 |
+
|
3851 |
+
var multiClose = function(thisRef, options) {
|
3852 |
+
|
3853 |
+
var self = thisRef;
|
3854 |
+
var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
|
3855 |
+
|
3856 |
+
/**
|
3857 |
+
* Appends an element as a child (with raw HTML).
|
3858 |
+
*
|
3859 |
+
* @param {string} html_container
|
3860 |
+
* @param {string} html_element
|
3861 |
+
* @return {string}
|
3862 |
+
*/
|
3863 |
+
var append = function(html_container, html_element) {
|
3864 |
+
var pos = html_container.search(/(<\/[^>]+>\s*)$/);
|
3865 |
+
return html_container.substring(0, pos) + html_element + html_container.substring(pos);
|
3866 |
};
|
3867 |
+
|
3868 |
+
thisRef.setup = (function() {
|
3869 |
+
var original = self.setup;
|
3870 |
+
return function() {
|
3871 |
+
// override the item rendering method to add the button to each
|
3872 |
+
if (options.append) {
|
3873 |
+
var render_item = self.settings.render.item;
|
3874 |
+
self.settings.render.item = function(data) {
|
3875 |
+
return append(render_item.apply(thisRef, arguments), html);
|
3876 |
+
};
|
3877 |
+
}
|
3878 |
+
|
3879 |
+
original.apply(thisRef, arguments);
|
3880 |
+
|
3881 |
+
// add event listener
|
3882 |
+
thisRef.$control.on('click', '.' + options.className, function(e) {
|
3883 |
+
e.preventDefault();
|
3884 |
+
if (self.isLocked) return;
|
3885 |
+
|
3886 |
+
var $item = $(e.currentTarget).parent();
|
3887 |
+
self.setActiveItem($item);
|
3888 |
+
if (self.deleteSelection()) {
|
3889 |
+
self.setCaret(self.items.length);
|
3890 |
+
}
|
3891 |
+
return false;
|
3892 |
+
});
|
3893 |
+
|
3894 |
+
};
|
3895 |
+
})();
|
3896 |
+
};
|
3897 |
+
|
3898 |
+
if (this.settings.mode === 'single') {
|
3899 |
+
singleClose(this, options);
|
3900 |
+
return;
|
3901 |
+
} else {
|
3902 |
+
multiClose(this, options);
|
3903 |
+
}
|
3904 |
});
|
3905 |
+
|
3906 |
+
|
3907 |
Selectize.define('restore_on_backspace', function(options) {
|
3908 |
var self = this;
|
3909 |
+
|
3910 |
options.text = options.text || function(option) {
|
3911 |
return option[this.settings.labelField];
|
3912 |
};
|
3913 |
+
|
3914 |
this.onKeyDown = (function() {
|
3915 |
var original = self.onKeyDown;
|
3916 |
return function(e) {
|
3931 |
};
|
3932 |
})();
|
3933 |
});
|
3934 |
+
|
3935 |
|
3936 |
return Selectize;
|
3937 |
}));
|
js/selectize.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
/*! selectize.js - v0.12.1 | https://github.com/brianreavis/selectize.js | Apache License (v2) */
|
2 |
-
!function(a,b){"function"==typeof define&&define.amd?define("sifter",b):"object"==typeof exports?module.exports=b():a.Sifter=b()}(this,function(){var a=function(a,b){this.items=a,this.settings=b||{diacritics:!0}};a.prototype.tokenize=function(a){if(a=d(String(a||"").toLowerCase()),!a||!a.length)return[];var b,c,f,h,i=[],j=a.split(/ +/);for(b=0,c=j.length;c>b;b++){if(f=e(j[b]),this.settings.diacritics)for(h in g)g.hasOwnProperty(h)&&(f=f.replace(new RegExp(h,"g"),g[h]));i.push({string:j[b],regex:new RegExp(f,"i")})}return i},a.prototype.iterator=function(a,b){var c;c=f(a)?Array.prototype.forEach||function(a){for(var b=0,c=this.length;c>b;b++)a(this[b],b,this)}:function(a){for(var b in this)this.hasOwnProperty(b)&&a(this[b],b,this)},c.apply(a,[b])},a.prototype.getScoreFunction=function(a,b){var c,d,e,f;c=this,a=c.prepareSearch(a,b),e=a.tokens,d=a.options.fields,f=e.length;var g=function(a,b){var c,d;return a?(a=String(a||""),d=a.search(b.regex),-1===d?0:(c=b.string.length/a.length,0===d&&(c+=.5),c)):0},h=function(){var a=d.length;return a?1===a?function(a,b){return g(b[d[0]],a)}:function(b,c){for(var e=0,f=0;a>e;e++)f+=g(c[d[e]],b);return f/a}:function(){return 0}}();return f?1===f?function(a){return h(e[0],a)}:"and"===a.options.conjunction?function(a){for(var b,c=0,d=0;f>c;c++){if(b=h(e[c],a),0>=b)return 0;d+=b}return d/f}:function(a){for(var b=0,c=0;f>b;b++)c+=h(e[b],a);return c/f}:function(){return 0}},a.prototype.getSortFunction=function(a,c){var d,e,f,g,h,i,j,k,l,m,n;if(f=this,a=f.prepareSearch(a,c),n=!a.query&&c.sort_empty||c.sort,l=function(a,b){return"$score"===a?b.score:f.items[b.id][a]},h=[],n)for(d=0,e=n.length;e>d;d++)(a.query||"$score"!==n[d].field)&&h.push(n[d]);if(a.query){for(m=!0,d=0,e=h.length;e>d;d++)if("$score"===h[d].field){m=!1;break}m&&h.unshift({field:"$score",direction:"desc"})}else for(d=0,e=h.length;e>d;d++)if("$score"===h[d].field){h.splice(d,1);break}for(k=[],d=0,e=h.length;e>d;d++)k.push("desc"===h[d].direction?-1:1);return i=h.length,i?1===i?(g=h[0].field,j=k[0],function(a,c){return j*b(l(g,a),l(g,c))}):function(a,c){var d,e,f;for(d=0;i>d;d++)if(f=h[d].field,e=k[d]*b(l(f,a),l(f,c)))return e;return 0}:null},a.prototype.prepareSearch=function(a,b){if("object"==typeof a)return a;b=c({},b);var d=b.fields,e=b.sort,g=b.sort_empty;return d&&!f(d)&&(b.fields=[d]),e&&!f(e)&&(b.sort=[e]),g&&!f(g)&&(b.sort_empty=[g]),{options:b,query:String(a||"").toLowerCase(),tokens:this.tokenize(a),total:0,items:[]}},a.prototype.search=function(a,b){var c,d,e,f,g=this;return d=this.prepareSearch(a,b),b=d.options,a=d.query,f=b.score||g.getScoreFunction(d),a.length?g.iterator(g.items,function(a,e){c=f(a),(b.filter===!1||c>0)&&d.items.push({score:c,id:e})}):g.iterator(g.items,function(a,b){d.items.push({score:1,id:b})}),e=g.getSortFunction(d,b),e&&d.items.sort(e),d.total=d.items.length,"number"==typeof b.limit&&(d.items=d.items.slice(0,b.limit)),d};var b=function(a,b){return"number"==typeof a&&"number"==typeof b?a>b?1:b>a?-1:0:(a=h(String(a||"")),b=h(String(b||"")),a>b?1:b>a?-1:0)},c=function(a){var b,c,d,e;for(b=1,c=arguments.length;c>b;b++)if(e=arguments[b])for(d in e)e.hasOwnProperty(d)&&(a[d]=e[d]);return a},d=function(a){return(a+"").replace(/^\s+|\s+$|/g,"")},e=function(a){return(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},f=Array.isArray||$&&$.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},g={a:"[aÀÁÂÃÄÅàáâãäåĀāąĄ]",c:"[cÇçćĆčČ]",d:"[dđĐďĎ]",e:"[eÈÉÊËèéêëěĚĒēęĘ]",i:"[iÌÍÎÏìíîïĪī]",l:"[lłŁ]",n:"[nÑñňŇńŃ]",o:"[oÒÓÔÕÕÖØòóôõöøŌō]",r:"[rřŘ]",s:"[sŠšśŚ]",t:"[tťŤ]",u:"[uÙÚÛÜùúûüůŮŪū]",y:"[yŸÿýÝ]",z:"[zŽžżŻźŹ]"},h=function(){var a,b,c,d,e="",f={};for(c in g)if(g.hasOwnProperty(c))for(d=g[c].substring(2,g[c].length-1),e+=d,a=0,b=d.length;b>a;a++)f[d.charAt(a)]=c;var h=new RegExp("["+e+"]","g");return function(a){return a.replace(h,function(a){return f[a]}).toLowerCase()}}();return a}),function(a,b){"function"==typeof define&&define.amd?define("microplugin",b):"object"==typeof exports?module.exports=b():a.MicroPlugin=b()}(this,function(){var a={};a.mixin=function(a){a.plugins={},a.prototype.initializePlugins=function(a){var c,d,e,f=this,g=[];if(f.plugins={names:[],settings:{},requested:{},loaded:{}},b.isArray(a))for(c=0,d=a.length;d>c;c++)"string"==typeof a[c]?g.push(a[c]):(f.plugins.settings[a[c].name]=a[c].options,g.push(a[c].name));else if(a)for(e in a)a.hasOwnProperty(e)&&(f.plugins.settings[e]=a[e],g.push(e));for(;g.length;)f.require(g.shift())},a.prototype.loadPlugin=function(b){var c=this,d=c.plugins,e=a.plugins[b];if(!a.plugins.hasOwnProperty(b))throw new Error('Unable to find "'+b+'" plugin');d.requested[b]=!0,d.loaded[b]=e.fn.apply(c,[c.plugins.settings[b]||{}]),d.names.push(b)},a.prototype.require=function(a){var b=this,c=b.plugins;if(!b.plugins.loaded.hasOwnProperty(a)){if(c.requested[a])throw new Error('Plugin has circular dependency ("'+a+'")');b.loadPlugin(a)}return c.loaded[a]},a.define=function(b,c){a.plugins[b]={name:b,fn:c}}};var b={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}};return a}),function(a,b){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],b):"object"==typeof exports?module.exports=b(require("jquery"),require("sifter"),require("microplugin")):a.Selectize=b(a.jQuery,a.Sifter,a.MicroPlugin)}(this,function(a,b,c){"use strict";var d=function(a,b){if("string"!=typeof b||b.length){var c="string"==typeof b?new RegExp(b,"i"):b,d=function(a){var b=0;if(3===a.nodeType){var e=a.data.search(c);if(e>=0&&a.data.length>0){var f=a.data.match(c),g=document.createElement("span");g.className="highlight";var h=a.splitText(e),i=(h.splitText(f[0].length),h.cloneNode(!0));g.appendChild(i),h.parentNode.replaceChild(g,h),b=1}}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName))for(var j=0;j<a.childNodes.length;++j)j+=d(a.childNodes[j]);return b};return a.each(function(){d(this)})}},e=function(){};e.prototype={on:function(a,b){this._events=this._events||{},this._events[a]=this._events[a]||[],this._events[a].push(b)},off:function(a,b){var c=arguments.length;return 0===c?delete this._events:1===c?delete this._events[a]:(this._events=this._events||{},void(a in this._events!=!1&&this._events[a].splice(this._events[a].indexOf(b),1)))},trigger:function(a){if(this._events=this._events||{},a in this._events!=!1)for(var b=0;b<this._events[a].length;b++)this._events[a][b].apply(this,Array.prototype.slice.call(arguments,1))}},e.mixin=function(a){for(var b=["on","off","trigger"],c=0;c<b.length;c++)a.prototype[b[c]]=e.prototype[b[c]]};var f=/Mac/.test(navigator.userAgent),g=65,h=13,i=27,j=37,k=38,l=80,m=39,n=40,o=78,p=8,q=46,r=16,s=f?91:17,t=f?18:17,u=9,v=1,w=2,x=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("form").validity,y=function(a){return"undefined"!=typeof a},z=function(a){return"undefined"==typeof a||null===a?null:"boolean"==typeof a?a?"1":"0":a+""},A=function(a){return(a+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},B=function(a){return(a+"").replace(/\$/g,"$$$$")},C={};C.before=function(a,b,c){var d=a[b];a[b]=function(){return c.apply(a,arguments),d.apply(a,arguments)}},C.after=function(a,b,c){var d=a[b];a[b]=function(){var b=d.apply(a,arguments);return c.apply(a,arguments),b}};var D=function(a){var b=!1;return function(){b||(b=!0,a.apply(this,arguments))}},E=function(a,b){var c;return function(){var d=this,e=arguments;window.clearTimeout(c),c=window.setTimeout(function(){a.apply(d,e)},b)}},F=function(a,b,c){var d,e=a.trigger,f={};a.trigger=function(){var c=arguments[0];return-1===b.indexOf(c)?e.apply(a,arguments):void(f[c]=arguments)},c.apply(a,[]),a.trigger=e;for(d in f)f.hasOwnProperty(d)&&e.apply(a,f[d])},G=function(a,b,c,d){a.on(b,c,function(b){for(var c=b.target;c&&c.parentNode!==a[0];)c=c.parentNode;return b.currentTarget=c,d.apply(this,[b])})},H=function(a){var b={};if("selectionStart"in a)b.start=a.selectionStart,b.length=a.selectionEnd-b.start;else if(document.selection){a.focus();var c=document.selection.createRange(),d=document.selection.createRange().text.length;c.moveStart("character",-a.value.length),b.start=c.text.length-d,b.length=d}return b},I=function(a,b,c){var d,e,f={};if(c)for(d=0,e=c.length;e>d;d++)f[c[d]]=a.css(c[d]);else f=a.css();b.css(f)},J=function(b,c){if(!b)return 0;var d=a("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(b).appendTo("body");I(c,d,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var e=d.width();return d.remove(),e},K=function(a){var b=null,c=function(c,d){var e,f,g,h,i,j,k,l;c=c||window.event||{},d=d||{},c.metaKey||c.altKey||(d.force||a.data("grow")!==!1)&&(e=a.val(),c.type&&"keydown"===c.type.toLowerCase()&&(f=c.keyCode,g=f>=97&&122>=f||f>=65&&90>=f||f>=48&&57>=f||32===f,f===q||f===p?(l=H(a[0]),l.length?e=e.substring(0,l.start)+e.substring(l.start+l.length):f===p&&l.start?e=e.substring(0,l.start-1)+e.substring(l.start+1):f===q&&"undefined"!=typeof l.start&&(e=e.substring(0,l.start)+e.substring(l.start+1))):g&&(j=c.shiftKey,k=String.fromCharCode(c.keyCode),k=j?k.toUpperCase():k.toLowerCase(),e+=k)),h=a.attr("placeholder"),!e&&h&&(e=h),i=J(e,a)+4,i!==b&&(b=i,a.width(i),a.triggerHandler("resize")))};a.on("keydown keyup update blur",c),c()},L=function(c,d){var e,f,g,h,i=this;h=c[0],h.selectize=i;var j=window.getComputedStyle&&window.getComputedStyle(h,null);if(g=j?j.getPropertyValue("direction"):h.currentStyle&&h.currentStyle.direction,g=g||c.parents("[dir]:first").attr("dir")||"",a.extend(i,{order:0,settings:d,$input:c,tabIndex:c.attr("tabindex")||"",tagType:"select"===h.tagName.toLowerCase()?v:w,rtl:/rtl/i.test(g),eventNS:".selectize"+ ++L.count,highlightedValue:null,isOpen:!1,isDisabled:!1,isRequired:c.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===d.loadThrottle?i.onSearchChange:E(i.onSearchChange,d.loadThrottle)}),i.sifter=new b(this.options,{diacritics:d.diacritics}),i.settings.options){for(e=0,f=i.settings.options.length;f>e;e++)i.registerOption(i.settings.options[e]);delete i.settings.options}if(i.settings.optgroups){for(e=0,f=i.settings.optgroups.length;f>e;e++)i.registerOptionGroup(i.settings.optgroups[e]);delete i.settings.optgroups}i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup()};return e.mixin(L),c.mixin(L),a.extend(L.prototype,{setup:function(){var b,c,d,e,g,h,i,j,k,l=this,m=l.settings,n=l.eventNS,o=a(window),p=a(document),q=l.$input;if(i=l.settings.mode,j=q.attr("class")||"",b=a("<div>").addClass(m.wrapperClass).addClass(j).addClass(i),c=a("<div>").addClass(m.inputClass).addClass("items").appendTo(b),d=a('<input type="text" autocomplete="off" />').appendTo(c).attr("tabindex",q.is(":disabled")?"-1":l.tabIndex),h=a(m.dropdownParent||b),e=a("<div>").addClass(m.dropdownClass).addClass(i).hide().appendTo(h),g=a("<div>").addClass(m.dropdownContentClass).appendTo(e),l.settings.copyClassesToDropdown&&e.addClass(j),b.css({width:q[0].style.width}),l.plugins.names.length&&(k="plugin-"+l.plugins.names.join(" plugin-"),b.addClass(k),e.addClass(k)),(null===m.maxItems||m.maxItems>1)&&l.tagType===v&&q.attr("multiple","multiple"),l.settings.placeholder&&d.attr("placeholder",m.placeholder),!l.settings.splitOn&&l.settings.delimiter){var u=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");l.settings.splitOn=new RegExp("\\s*"+u+"+\\s*")}q.attr("autocorrect")&&d.attr("autocorrect",q.attr("autocorrect")),q.attr("autocapitalize")&&d.attr("autocapitalize",q.attr("autocapitalize")),l.$wrapper=b,l.$control=c,l.$control_input=d,l.$dropdown=e,l.$dropdown_content=g,e.on("mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),e.on("mousedown click","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),G(c,"mousedown","*:not(input)",function(){return l.onItemSelect.apply(l,arguments)}),K(d),c.on({mousedown:function(){return l.onMouseDown.apply(l,arguments)},click:function(){return l.onClick.apply(l,arguments)}}),d.on({mousedown:function(a){a.stopPropagation()},keydown:function(){return l.onKeyDown.apply(l,arguments)},keyup:function(){return l.onKeyUp.apply(l,arguments)},keypress:function(){return l.onKeyPress.apply(l,arguments)},resize:function(){l.positionDropdown.apply(l,[])},blur:function(){return l.onBlur.apply(l,arguments)},focus:function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)},paste:function(){return l.onPaste.apply(l,arguments)}}),p.on("keydown"+n,function(a){l.isCmdDown=a[f?"metaKey":"ctrlKey"],l.isCtrlDown=a[f?"altKey":"ctrlKey"],l.isShiftDown=a.shiftKey}),p.on("keyup"+n,function(a){a.keyCode===t&&(l.isCtrlDown=!1),a.keyCode===r&&(l.isShiftDown=!1),a.keyCode===s&&(l.isCmdDown=!1)}),p.on("mousedown"+n,function(a){if(l.isFocused){if(a.target===l.$dropdown[0]||a.target.parentNode===l.$dropdown[0])return!1;l.$control.has(a.target).length||a.target===l.$control[0]||l.blur(a.target)}}),o.on(["scroll"+n,"resize"+n].join(" "),function(){l.isOpen&&l.positionDropdown.apply(l,arguments)}),o.on("mousemove"+n,function(){l.ignoreHover=!1}),this.revertSettings={$children:q.children().detach(),tabindex:q.attr("tabindex")},q.attr("tabindex",-1).hide().after(l.$wrapper),a.isArray(m.items)&&(l.setValue(m.items),delete m.items),x&&q.on("invalid"+n,function(a){a.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.updatePlaceholder(),l.isSetup=!0,q.is(":disabled")&&l.disable(),l.on("change",this.onChange),q.data("selectize",l),q.addClass("selectized"),l.trigger("initialize"),m.preload===!0&&l.onSearchChange("")},setupTemplates:function(){var b=this,c=b.settings.labelField,d=b.settings.optgroupLabelField,e={optgroup:function(a){return'<div class="optgroup">'+a.html+"</div>"},optgroup_header:function(a,b){return'<div class="optgroup-header">'+b(a[d])+"</div>"},option:function(a,b){return'<div class="option">'+b(a[c])+"</div>"},item:function(a,b){return'<div class="item">'+b(a[c])+"</div>"},option_create:function(a,b){return'<div class="create">Add <strong>'+b(a.input)+"</strong>…</div>"}};b.settings.render=a.extend({},e,b.settings.render)},setupCallbacks:function(){var a,b,c={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(a in c)c.hasOwnProperty(a)&&(b=this.settings[c[a]],b&&this.on(a,b))},onClick:function(a){var b=this;b.isFocused||(b.focus(),a.preventDefault())},onMouseDown:function(b){{var c=this,d=b.isDefaultPrevented();a(b.target)}if(c.isFocused){if(b.target!==c.$control_input[0])return"single"===c.settings.mode?c.isOpen?c.close():c.open():d||c.setActiveItem(null),!1}else d||window.setTimeout(function(){c.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(b){var c=this;c.isFull()||c.isInputHidden||c.isLocked?b.preventDefault():c.settings.splitOn&&setTimeout(function(){for(var b=a.trim(c.$control_input.val()||"").split(c.settings.splitOn),d=0,e=b.length;e>d;d++)c.createItem(b[d])},0)},onKeyPress:function(a){if(this.isLocked)return a&&a.preventDefault();var b=String.fromCharCode(a.keyCode||a.which);return this.settings.create&&"multi"===this.settings.mode&&b===this.settings.delimiter?(this.createItem(),a.preventDefault(),!1):void 0},onKeyDown:function(a){var b=(a.target===this.$control_input[0],this);if(b.isLocked)return void(a.keyCode!==u&&a.preventDefault());switch(a.keyCode){case g:if(b.isCmdDown)return void b.selectAll();break;case i:return void(b.isOpen&&(a.preventDefault(),a.stopPropagation(),b.close()));case o:if(!a.ctrlKey||a.altKey)break;case n:if(!b.isOpen&&b.hasOptions)b.open();else if(b.$activeOption){b.ignoreHover=!0;var c=b.getAdjacentOption(b.$activeOption,1);c.length&&b.setActiveOption(c,!0,!0)}return void a.preventDefault();case l:if(!a.ctrlKey||a.altKey)break;case k:if(b.$activeOption){b.ignoreHover=!0;var d=b.getAdjacentOption(b.$activeOption,-1);d.length&&b.setActiveOption(d,!0,!0)}return void a.preventDefault();case h:return void(b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),a.preventDefault()));case j:return void b.advanceSelection(-1,a);case m:return void b.advanceSelection(1,a);case u:return b.settings.selectOnTab&&b.isOpen&&b.$activeOption&&(b.onOptionSelect({currentTarget:b.$activeOption}),b.isFull()||a.preventDefault()),void(b.settings.create&&b.createItem()&&a.preventDefault());case p:case q:return void b.deleteSelection(a)}return!b.isFull()&&!b.isInputHidden||(f?a.metaKey:a.ctrlKey)?void 0:void a.preventDefault()},onKeyUp:function(a){var b=this;if(b.isLocked)return a&&a.preventDefault();var c=b.$control_input.val()||"";b.lastValue!==c&&(b.lastValue=c,b.onSearchChange(c),b.refreshOptions(),b.trigger("type",c))},onSearchChange:function(a){var b=this,c=b.settings.load;c&&(b.loadedSearches.hasOwnProperty(a)||(b.loadedSearches[a]=!0,b.load(function(d){c.apply(b,[a,d])})))},onFocus:function(a){var b=this,c=b.isFocused;return b.isDisabled?(b.blur(),a&&a.preventDefault(),!1):void(b.ignoreFocus||(b.isFocused=!0,"focus"===b.settings.preload&&b.onSearchChange(""),c||b.trigger("focus"),b.$activeItems.length||(b.showInput(),b.setActiveItem(null),b.refreshOptions(!!b.settings.openOnFocus)),b.refreshState()))},onBlur:function(a,b){var c=this;if(c.isFocused&&(c.isFocused=!1,!c.ignoreFocus)){if(!c.ignoreBlur&&document.activeElement===c.$dropdown_content[0])return c.ignoreBlur=!0,void c.onFocus(a);var d=function(){c.close(),c.setTextboxValue(""),c.setActiveItem(null),c.setActiveOption(null),c.setCaret(c.items.length),c.refreshState(),(b||document.body).focus(),c.ignoreFocus=!1,c.trigger("blur")};c.ignoreFocus=!0,c.settings.create&&c.settings.createOnBlur?c.createItem(null,!1,d):d()}},onOptionHover:function(a){this.ignoreHover||this.setActiveOption(a.currentTarget,!1)},onOptionSelect:function(b){var c,d,e=this;b.preventDefault&&(b.preventDefault(),b.stopPropagation()),d=a(b.currentTarget),d.hasClass("create")?e.createItem(null,function(){e.settings.closeAfterSelect&&e.close()}):(c=d.attr("data-value"),"undefined"!=typeof c&&(e.lastQuery=null,e.setTextboxValue(""),e.addItem(c),e.settings.closeAfterSelect?e.close():!e.settings.hideSelected&&b.type&&/mouse/.test(b.type)&&e.setActiveOption(e.getOption(c))))},onItemSelect:function(a){var b=this;b.isLocked||"multi"===b.settings.mode&&(a.preventDefault(),b.setActiveItem(a.currentTarget,a))},load:function(a){var b=this,c=b.$wrapper.addClass(b.settings.loadingClass);b.loading++,a.apply(b,[function(a){b.loading=Math.max(b.loading-1,0),a&&a.length&&(b.addOption(a),b.refreshOptions(b.isFocused&&!b.isInputHidden)),b.loading||c.removeClass(b.settings.loadingClass),b.trigger("load",a)}])},setTextboxValue:function(a){var b=this.$control_input,c=b.val()!==a;c&&(b.val(a).triggerHandler("update"),this.lastValue=a)},getValue:function(){return this.tagType===v&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(a,b){var c=b?[]:["change"];F(this,c,function(){this.clear(b),this.addItems(a,b)})},setActiveItem:function(b,c){var d,e,f,g,h,i,j,k,l=this;if("single"!==l.settings.mode){if(b=a(b),!b.length)return a(l.$activeItems).removeClass("active"),l.$activeItems=[],void(l.isFocused&&l.showInput());if(d=c&&c.type.toLowerCase(),"mousedown"===d&&l.isShiftDown&&l.$activeItems.length){for(k=l.$control.children(".active:last"),g=Array.prototype.indexOf.apply(l.$control[0].childNodes,[k[0]]),h=Array.prototype.indexOf.apply(l.$control[0].childNodes,[b[0]]),g>h&&(j=g,g=h,h=j),e=g;h>=e;e++)i=l.$control[0].childNodes[e],-1===l.$activeItems.indexOf(i)&&(a(i).addClass("active"),l.$activeItems.push(i));c.preventDefault()}else"mousedown"===d&&l.isCtrlDown||"keydown"===d&&this.isShiftDown?b.hasClass("active")?(f=l.$activeItems.indexOf(b[0]),l.$activeItems.splice(f,1),b.removeClass("active")):l.$activeItems.push(b.addClass("active")[0]):(a(l.$activeItems).removeClass("active"),l.$activeItems=[b.addClass("active")[0]]);l.hideInput(),this.isFocused||l.focus()}},setActiveOption:function(b,c,d){var e,f,g,h,i,j=this;j.$activeOption&&j.$activeOption.removeClass("active"),j.$activeOption=null,b=a(b),b.length&&(j.$activeOption=b.addClass("active"),(c||!y(c))&&(e=j.$dropdown_content.height(),f=j.$activeOption.outerHeight(!0),c=j.$dropdown_content.scrollTop()||0,g=j.$activeOption.offset().top-j.$dropdown_content.offset().top+c,h=g,i=g-e+f,g+f>e+c?j.$dropdown_content.stop().animate({scrollTop:i},d?j.settings.scrollDuration:0):c>g&&j.$dropdown_content.stop().animate({scrollTop:h},d?j.settings.scrollDuration:0)))},selectAll:function(){var a=this;"single"!==a.settings.mode&&(a.$activeItems=Array.prototype.slice.apply(a.$control.children(":not(input)").addClass("active")),a.$activeItems.length&&(a.hideInput(),a.close()),a.focus())},hideInput:function(){var a=this;a.setTextboxValue(""),a.$control_input.css({opacity:0,position:"absolute",left:a.rtl?1e4:-1e4}),a.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0}),this.isInputHidden=!1},focus:function(){var a=this;a.isDisabled||(a.ignoreFocus=!0,a.$control_input[0].focus(),window.setTimeout(function(){a.ignoreFocus=!1,a.onFocus()},0))},blur:function(a){this.$control_input[0].blur(),this.onBlur(null,a)},getScoreFunction:function(a){return this.sifter.getScoreFunction(a,this.getSearchOptions())},getSearchOptions:function(){var a=this.settings,b=a.sortField;return"string"==typeof b&&(b=[{field:b}]),{fields:a.searchField,conjunction:a.searchConjunction,sort:b}},search:function(b){var c,d,e,f=this,g=f.settings,h=this.getSearchOptions();if(g.score&&(e=f.settings.score.apply(this,[b]),"function"!=typeof e))throw new Error('Selectize "score" setting must be a function that returns a function');if(b!==f.lastQuery?(f.lastQuery=b,d=f.sifter.search(b,a.extend(h,{score:e})),f.currentResults=d):d=a.extend(!0,{},f.currentResults),g.hideSelected)for(c=d.items.length-1;c>=0;c--)-1!==f.items.indexOf(z(d.items[c].id))&&d.items.splice(c,1);return d},refreshOptions:function(b){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;"undefined"==typeof b&&(b=!0);var t=this,u=a.trim(t.$control_input.val()),v=t.search(u),w=t.$dropdown_content,x=t.$activeOption&&z(t.$activeOption.attr("data-value"));for(g=v.items.length,"number"==typeof t.settings.maxOptions&&(g=Math.min(g,t.settings.maxOptions)),h={},i=[],c=0;g>c;c++)for(j=t.options[v.items[c].id],k=t.render("option",j),l=j[t.settings.optgroupField]||"",m=a.isArray(l)?l:[l],e=0,f=m&&m.length;f>e;e++)l=m[e],t.optgroups.hasOwnProperty(l)||(l=""),h.hasOwnProperty(l)||(h[l]=[],i.push(l)),h[l].push(k);for(this.settings.lockOptgroupOrder&&i.sort(function(a,b){var c=t.optgroups[a].$order||0,d=t.optgroups[b].$order||0;return c-d}),n=[],c=0,g=i.length;g>c;c++)l=i[c],t.optgroups.hasOwnProperty(l)&&h[l].length?(o=t.render("optgroup_header",t.optgroups[l])||"",o+=h[l].join(""),n.push(t.render("optgroup",a.extend({},t.optgroups[l],{html:o})))):n.push(h[l].join(""));if(w.html(n.join("")),t.settings.highlight&&v.query.length&&v.tokens.length)for(c=0,g=v.tokens.length;g>c;c++)d(w,v.tokens[c].regex);if(!t.settings.hideSelected)for(c=0,g=t.items.length;g>c;c++)t.getOption(t.items[c]).addClass("selected");p=t.canCreate(u),p&&(w.prepend(t.render("option_create",{input:u})),s=a(w[0].childNodes[0])),t.hasOptions=v.items.length>0||p,t.hasOptions?(v.items.length>0?(r=x&&t.getOption(x),r&&r.length?q=r:"single"===t.settings.mode&&t.items.length&&(q=t.getOption(t.items[0])),q&&q.length||(q=s&&!t.settings.addPrecedence?t.getAdjacentOption(s,1):w.find("[data-selectable]:first"))):q=s,t.setActiveOption(q),b&&!t.isOpen&&t.open()):(t.setActiveOption(null),b&&t.isOpen&&t.close())},addOption:function(b){var c,d,e,f=this;if(a.isArray(b))for(c=0,d=b.length;d>c;c++)f.addOption(b[c]);else(e=f.registerOption(b))&&(f.userOptions[e]=!0,f.lastQuery=null,f.trigger("option_add",e,b))},registerOption:function(a){var b=z(a[this.settings.valueField]);return!b||this.options.hasOwnProperty(b)?!1:(a.$order=a.$order||++this.order,this.options[b]=a,b)},registerOptionGroup:function(a){var b=z(a[this.settings.optgroupValueField]);return b?(a.$order=a.$order||++this.order,this.optgroups[b]=a,b):!1},addOptionGroup:function(a,b){b[this.settings.optgroupValueField]=a,(a=this.registerOptionGroup(b))&&this.trigger("optgroup_add",a,b)},removeOptionGroup:function(a){this.optgroups.hasOwnProperty(a)&&(delete this.optgroups[a],this.renderCache={},this.trigger("optgroup_remove",a))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(b,c){var d,e,f,g,h,i,j,k=this;if(b=z(b),f=z(c[k.settings.valueField]),null!==b&&k.options.hasOwnProperty(b)){if("string"!=typeof f)throw new Error("Value must be set in option data");j=k.options[b].$order,f!==b&&(delete k.options[b],g=k.items.indexOf(b),-1!==g&&k.items.splice(g,1,f)),c.$order=c.$order||j,k.options[f]=c,h=k.renderCache.item,i=k.renderCache.option,h&&(delete h[b],delete h[f]),i&&(delete i[b],delete i[f]),-1!==k.items.indexOf(f)&&(d=k.getItem(b),e=a(k.render("item",c)),d.hasClass("active")&&e.addClass("active"),d.replaceWith(e)),k.lastQuery=null,k.isOpen&&k.refreshOptions(!1)}},removeOption:function(a,b){var c=this;a=z(a);var d=c.renderCache.item,e=c.renderCache.option;d&&delete d[a],e&&delete e[a],delete c.userOptions[a],delete c.options[a],c.lastQuery=null,c.trigger("option_remove",a),c.removeItem(a,b)},clearOptions:function(){var a=this;a.loadedSearches={},a.userOptions={},a.renderCache={},a.options=a.sifter.items={},a.lastQuery=null,a.trigger("option_clear"),a.clear()},getOption:function(a){return this.getElementWithValue(a,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(b,c){var d=this.$dropdown.find("[data-selectable]"),e=d.index(b)+c;return e>=0&&e<d.length?d.eq(e):a()},getElementWithValue:function(b,c){if(b=z(b),"undefined"!=typeof b&&null!==b)for(var d=0,e=c.length;e>d;d++)if(c[d].getAttribute("data-value")===b)return a(c[d]);return a()},getItem:function(a){return this.getElementWithValue(a,this.$control.children())},addItems:function(b,c){for(var d=a.isArray(b)?b:[b],e=0,f=d.length;f>e;e++)this.isPending=f-1>e,this.addItem(d[e],c)},addItem:function(b,c){var d=c?[]:["change"];F(this,d,function(){var d,e,f,g,h,i=this,j=i.settings.mode;return b=z(b),-1!==i.items.indexOf(b)?void("single"===j&&i.close()):void(i.options.hasOwnProperty(b)&&("single"===j&&i.clear(c),"multi"===j&&i.isFull()||(d=a(i.render("item",i.options[b])),h=i.isFull(),i.items.splice(i.caretPos,0,b),i.insertAtCaret(d),(!i.isPending||!h&&i.isFull())&&i.refreshState(),i.isSetup&&(f=i.$dropdown_content.find("[data-selectable]"),i.isPending||(e=i.getOption(b),g=i.getAdjacentOption(e,1).attr("data-value"),i.refreshOptions(i.isFocused&&"single"!==j),g&&i.setActiveOption(i.getOption(g))),!f.length||i.isFull()?i.close():i.positionDropdown(),i.updatePlaceholder(),i.trigger("item_add",b,d),i.updateOriginalInput({silent:c})))))})},removeItem:function(a,b){var c,d,e,f=this;c="object"==typeof a?a:f.getItem(a),a=z(c.attr("data-value")),d=f.items.indexOf(a),-1!==d&&(c.remove(),c.hasClass("active")&&(e=f.$activeItems.indexOf(c[0]),f.$activeItems.splice(e,1)),f.items.splice(d,1),f.lastQuery=null,!f.settings.persist&&f.userOptions.hasOwnProperty(a)&&f.removeOption(a,b),d<f.caretPos&&f.setCaret(f.caretPos-1),f.refreshState(),f.updatePlaceholder(),f.updateOriginalInput({silent:b}),f.positionDropdown(),f.trigger("item_remove",a,c))},createItem:function(b,c){var d=this,e=d.caretPos;b=b||a.trim(d.$control_input.val()||"");var f=arguments[arguments.length-1];if("function"!=typeof f&&(f=function(){}),"boolean"!=typeof c&&(c=!0),!d.canCreate(b))return f(),!1;d.lock();var g="function"==typeof d.settings.create?this.settings.create:function(a){var b={};return b[d.settings.labelField]=a,b[d.settings.valueField]=a,b},h=D(function(a){if(d.unlock(),!a||"object"!=typeof a)return f();var b=z(a[d.settings.valueField]);return"string"!=typeof b?f():(d.setTextboxValue(""),d.addOption(a),d.setCaret(e),d.addItem(b),d.refreshOptions(c&&"single"!==d.settings.mode),void f(a))}),i=g.apply(this,[b,h]);return"undefined"!=typeof i&&h(i),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){var a,b=this;b.isRequired&&(b.items.length&&(b.isInvalid=!1),b.$control_input.prop("required",a)),b.refreshClasses()},refreshClasses:function(){var b=this,c=b.isFull(),d=b.isLocked;b.$wrapper.toggleClass("rtl",b.rtl),b.$control.toggleClass("focus",b.isFocused).toggleClass("disabled",b.isDisabled).toggleClass("required",b.isRequired).toggleClass("invalid",b.isInvalid).toggleClass("locked",d).toggleClass("full",c).toggleClass("not-full",!c).toggleClass("input-active",b.isFocused&&!b.isInputHidden).toggleClass("dropdown-active",b.isOpen).toggleClass("has-options",!a.isEmptyObject(b.options)).toggleClass("has-items",b.items.length>0),b.$control_input.data("grow",!c&&!d)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(a){var b,c,d,e,f=this;if(a=a||{},f.tagType===v){for(d=[],b=0,c=f.items.length;c>b;b++)e=f.options[f.items[b]][f.settings.labelField]||"",d.push('<option value="'+A(f.items[b])+'" selected="selected">'+A(e)+"</option>");d.length||this.$input.attr("multiple")||d.push('<option value="" selected="selected"></option>'),f.$input.html(d.join(""))}else f.$input.val(f.getValue()),f.$input.attr("value",f.$input.val());f.isSetup&&(a.silent||f.trigger("change",f.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var a=this.$control_input;this.items.length?a.removeAttr("placeholder"):a.attr("placeholder",this.settings.placeholder),a.triggerHandler("update",{force:!0})}},open:function(){var a=this;a.isLocked||a.isOpen||"multi"===a.settings.mode&&a.isFull()||(a.focus(),a.isOpen=!0,a.refreshState(),a.$dropdown.css({visibility:"hidden",display:"block"}),a.positionDropdown(),a.$dropdown.css({visibility:"visible"}),a.trigger("dropdown_open",a.$dropdown))},close:function(){var a=this,b=a.isOpen;"single"===a.settings.mode&&a.items.length&&a.hideInput(),a.isOpen=!1,a.$dropdown.hide(),a.setActiveOption(null),a.refreshState(),b&&a.trigger("dropdown_close",a.$dropdown)},positionDropdown:function(){var a=this.$control,b="body"===this.settings.dropdownParent?a.offset():a.position();b.top+=a.outerHeight(!0),this.$dropdown.css({width:a.outerWidth(),top:b.top,left:b.left})},clear:function(a){var b=this;b.items.length&&(b.$control.children(":not(input)").remove(),b.items=[],b.lastQuery=null,b.setCaret(0),b.setActiveItem(null),b.updatePlaceholder(),b.updateOriginalInput({silent:a}),b.refreshState(),b.showInput(),b.trigger("clear"))},insertAtCaret:function(b){var c=Math.min(this.caretPos,this.items.length);0===c?this.$control.prepend(b):a(this.$control[0].childNodes[c]).before(b),this.setCaret(c+1)},deleteSelection:function(b){var c,d,e,f,g,h,i,j,k,l=this;if(e=b&&b.keyCode===p?-1:1,f=H(l.$control_input[0]),l.$activeOption&&!l.settings.hideSelected&&(i=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),g=[],l.$activeItems.length){for(k=l.$control.children(".active:"+(e>0?"last":"first")),h=l.$control.children(":not(input)").index(k),e>0&&h++,c=0,d=l.$activeItems.length;d>c;c++)g.push(a(l.$activeItems[c]).attr("data-value"));
|
3 |
-
b&&(b.preventDefault(),b.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(0>e&&0===f.start&&0===f.length?g.push(l.items[l.caretPos-1]):e>0&&f.start===l.$control_input.val().length&&g.push(l.items[l.caretPos]));if(!g.length||"function"==typeof l.settings.onDelete&&l.settings.onDelete.apply(l,[g])===!1)return!1;for("undefined"!=typeof h&&l.setCaret(h);g.length;)l.removeItem(g.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),i&&(j=l.getOption(i),j.length&&l.setActiveOption(j)),!0},advanceSelection:function(a,b){var c,d,e,f,g,h,i=this;0!==a&&(i.rtl&&(a*=-1),c=a>0?"last":"first",d=H(i.$control_input[0]),i.isFocused&&!i.isInputHidden?(f=i.$control_input.val().length,g=0>a?0===d.start&&0===d.length:d.start===f,g&&!f&&i.advanceCaret(a,b)):(h=i.$control.children(".active:"+c),h.length&&(e=i.$control.children(":not(input)").index(h),i.setActiveItem(null),i.setCaret(a>0?e+1:e))))},advanceCaret:function(a,b){var c,d,e=this;0!==a&&(c=a>0?"next":"prev",e.isShiftDown?(d=e.$control_input[c](),d.length&&(e.hideInput(),e.setActiveItem(d),b&&b.preventDefault())):e.setCaret(e.caretPos+a))},setCaret:function(b){var c=this;if(b="single"===c.settings.mode?c.items.length:Math.max(0,Math.min(c.items.length,b)),!c.isPending){var d,e,f,g;for(f=c.$control.children(":not(input)"),d=0,e=f.length;e>d;d++)g=a(f[d]).detach(),b>d?c.$control_input.before(g):c.$control.append(g)}c.caretPos=b},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){var a=this;a.$input.prop("disabled",!0),a.$control_input.prop("disabled",!0).prop("tabindex",-1),a.isDisabled=!0,a.lock()},enable:function(){var a=this;a.$input.prop("disabled",!1),a.$control_input.prop("disabled",!1).prop("tabindex",a.tabIndex),a.isDisabled=!1,a.unlock()},destroy:function(){var b=this,c=b.eventNS,d=b.revertSettings;b.trigger("destroy"),b.off(),b.$wrapper.remove(),b.$dropdown.remove(),b.$input.html("").append(d.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:d.tabindex}).show(),b.$control_input.removeData("grow"),b.$input.removeData("selectize"),a(window).off(c),a(document).off(c),a(document.body).off(c),delete b.$input[0].selectize},render:function(a,b){var c,d,e="",f=!1,g=this,h=/^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;return("option"===a||"item"===a)&&(c=z(b[g.settings.valueField]),f=!!c),f&&(y(g.renderCache[a])||(g.renderCache[a]={}),g.renderCache[a].hasOwnProperty(c))?g.renderCache[a][c]:(e=g.settings.render[a].apply(this,[b,A]),("option"===a||"option_create"===a)&&(e=e.replace(h,"<$1 data-selectable")),"optgroup"===a&&(d=b[g.settings.optgroupValueField]||"",e=e.replace(h,'<$1 data-group="'+B(A(d))+'"')),("option"===a||"item"===a)&&(e=e.replace(h,'<$1 data-value="'+B(A(c||""))+'"')),f&&(g.renderCache[a][c]=e),e)},clearCache:function(a){var b=this;"undefined"==typeof a?b.renderCache={}:delete b.renderCache[a]},canCreate:function(a){var b=this;if(!b.settings.create)return!1;var c=b.settings.createFilter;return!(!a.length||"function"==typeof c&&!c.apply(b,[a])||"string"==typeof c&&!new RegExp(c).test(a)||c instanceof RegExp&&!c.test(a))}}),L.count=0,L.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},a.fn.selectize=function(b){var c=a.fn.selectize.defaults,d=a.extend({},c,b),e=d.dataAttr,f=d.labelField,g=d.valueField,h=d.optgroupField,i=d.optgroupLabelField,j=d.optgroupValueField,k=function(b,c){var h,i,j,k,l=b.attr(e);if(l)for(c.options=JSON.parse(l),h=0,i=c.options.length;i>h;h++)c.items.push(c.options[h][g]);else{var m=a.trim(b.val()||"");if(!d.allowEmptyOption&&!m.length)return;for(j=m.split(d.delimiter),h=0,i=j.length;i>h;h++)k={},k[f]=j[h],k[g]=j[h],c.options.push(k);c.items=j}},l=function(b,c){var k,l,m,n,o=c.options,p={},q=function(a){var b=e&&a.attr(e);return"string"==typeof b&&b.length?JSON.parse(b):null},r=function(b,e){b=a(b);var i=z(b.attr("value"));if(i||d.allowEmptyOption)if(p.hasOwnProperty(i)){if(e){var j=p[i][h];j?a.isArray(j)?j.push(e):p[i][h]=[j,e]:p[i][h]=e}}else{var k=q(b)||{};k[f]=k[f]||b.text(),k[g]=k[g]||i,k[h]=k[h]||e,p[i]=k,o.push(k),b.is(":selected")&&c.items.push(i)}},s=function(b){var d,e,f,g,h;for(b=a(b),f=b.attr("label"),f&&(g=q(b)||{},g[i]=f,g[j]=f,c.optgroups.push(g)),h=a("option",b),d=0,e=h.length;e>d;d++)r(h[d],f)};for(c.maxItems=b.attr("multiple")?null:1,n=b.children(),k=0,l=n.length;l>k;k++)m=n[k].tagName.toLowerCase(),"optgroup"===m?s(n[k]):"option"===m&&r(n[k])};return this.each(function(){if(!this.selectize){var e,f=a(this),g=this.tagName.toLowerCase(),h=f.attr("placeholder")||f.attr("data-placeholder");h||d.allowEmptyOption||(h=f.children('option[value=""]').text());var i={placeholder:h,options:[],optgroups:[],items:[]};"select"===g?l(f,i):k(f,i),e=new L(f,a.extend(!0,{},c,i,b))}})},a.fn.selectize.defaults=L.defaults,a.fn.selectize.support={validity:x},L.define("drag_drop",function(){if(!a.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var b=this;b.lock=function(){var a=b.lock;return function(){var c=b.$control.data("sortable");return c&&c.disable(),a.apply(b,arguments)}}(),b.unlock=function(){var a=b.unlock;return function(){var c=b.$control.data("sortable");return c&&c.enable(),a.apply(b,arguments)}}(),b.setup=function(){var c=b.setup;return function(){c.apply(this,arguments);var d=b.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:b.isLocked,start:function(a,b){b.placeholder.css("width",b.helper.css("width")),d.css({overflow:"visible"})},stop:function(){d.css({overflow:"hidden"});var c=b.$activeItems?b.$activeItems.slice():null,e=[];d.children("[data-value]").each(function(){e.push(a(this).attr("data-value"))}),b.setValue(e),b.setActiveItem(c)}})}}()}}),L.define("dropdown_header",function(b){var c=this;b=a.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(a){return'<div class="'+a.headerClass+'"><div class="'+a.titleRowClass+'"><span class="'+a.labelClass+'">'+a.title+'</span><a href="javascript:void(0)" class="'+a.closeClass+'">×</a></div></div>'}},b),c.setup=function(){var d=c.setup;return function(){d.apply(c,arguments),c.$dropdown_header=a(b.html(b)),c.$dropdown.prepend(c.$dropdown_header)}}()}),L.define("optgroup_columns",function(b){var c=this;b=a.extend({equalizeWidth:!0,equalizeHeight:!0},b),this.getAdjacentOption=function(b,c){var d=b.closest("[data-group]").find("[data-selectable]"),e=d.index(b)+c;return e>=0&&e<d.length?d.eq(e):a()},this.onKeyDown=function(){var a=c.onKeyDown;return function(b){var d,e,f,g;return!this.isOpen||b.keyCode!==j&&b.keyCode!==m?a.apply(this,arguments):(c.ignoreHover=!0,g=this.$activeOption.closest("[data-group]"),d=g.find("[data-selectable]").index(this.$activeOption),g=b.keyCode===j?g.prev("[data-group]"):g.next("[data-group]"),f=g.find("[data-selectable]"),e=f.eq(Math.min(f.length-1,d)),void(e.length&&this.setActiveOption(e)))}}();var d=function(){var a,b=d.width,c=document;return"undefined"==typeof b&&(a=c.createElement("div"),a.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',a=a.firstChild,c.body.appendChild(a),b=d.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},e=function(){var e,f,g,h,i,j,k;if(k=a("[data-group]",c.$dropdown_content),f=k.length,f&&c.$dropdown_content.width()){if(b.equalizeHeight){for(g=0,e=0;f>e;e++)g=Math.max(g,k.eq(e).height());k.css({height:g})}b.equalizeWidth&&(j=c.$dropdown_content.innerWidth()-d(),h=Math.round(j/f),k.css({width:h}),f>1&&(i=j-h*(f-1),k.eq(f-1).css({width:i})))}};(b.equalizeHeight||b.equalizeWidth)&&(C.after(this,"positionDropdown",e),C.after(this,"refreshOptions",e))}),L.define("remove_button",function(b){if("single"!==this.settings.mode){b=a.extend({label:"×",title:"Remove",className:"remove",append:!0},b);var c=this,d='<a href="javascript:void(0)" class="'+b.className+'" tabindex="-1" title="'+A(b.title)+'">'+b.label+"</a>",e=function(a,b){var c=a.search(/(<\/[^>]+>\s*)$/);return a.substring(0,c)+b+a.substring(c)};this.setup=function(){var f=c.setup;return function(){if(b.append){var g=c.settings.render.item;c.settings.render.item=function(){return e(g.apply(this,arguments),d)}}f.apply(this,arguments),this.$control.on("click","."+b.className,function(b){if(b.preventDefault(),!c.isLocked){var d=a(b.currentTarget).parent();c.setActiveItem(d),c.deleteSelection()&&c.setCaret(c.items.length)}})}}()}}),L.define("restore_on_backspace",function(a){var b=this;a.text=a.text||function(a){return a[this.settings.labelField]},this.onKeyDown=function(){var c=b.onKeyDown;return function(b){var d,e;return b.keyCode===p&&""===this.$control_input.val()&&!this.$activeItems.length&&(d=this.caretPos-1,d>=0&&d<this.items.length)?(e=this.options[this.items[d]],this.deleteSelection(b)&&(this.setTextboxValue(a.text.apply(this,[e])),this.refreshOptions(!0)),void b.preventDefault()):c.apply(this,arguments)}}()}),L});
|
1 |
+
(function(root,factory){if(typeof define==="function"&&define.amd){define(factory)}else if(typeof exports==="object"){module.exports=factory()}else{root.Sifter=factory()}})(this,function(){var Sifter=function(items,settings){this.items=items;this.settings=settings||{diacritics:true}};Sifter.prototype.tokenize=function(query,respect_word_boundaries){query=trim(String(query||"").toLowerCase());if(!query||!query.length)return[];var i,n,regex,letter;var tokens=[];var words=query.split(/ +/);for(i=0,n=words.length;i<n;i++){regex=escape_regex(words[i]);if(this.settings.diacritics){for(letter in DIACRITICS){if(DIACRITICS.hasOwnProperty(letter)){regex=regex.replace(new RegExp(letter,"g"),DIACRITICS[letter])}}}if(respect_word_boundaries)regex="\\b"+regex;tokens.push({string:words[i],regex:new RegExp(regex,"i")})}return tokens};Sifter.prototype.iterator=function(object,callback){var iterator;if(is_array(object)){iterator=Array.prototype.forEach||function(callback){for(var i=0,n=this.length;i<n;i++){callback(this[i],i,this)}}}else{iterator=function(callback){for(var key in this){if(this.hasOwnProperty(key)){callback(this[key],key,this)}}}}iterator.apply(object,[callback])};Sifter.prototype.getScoreFunction=function(search,options){var self,fields,tokens,token_count,nesting;self=this;search=self.prepareSearch(search,options);tokens=search.tokens;fields=search.options.fields;token_count=tokens.length;nesting=search.options.nesting;var scoreValue=function(value,token){var score,pos;if(!value)return 0;value=String(value||"");pos=value.search(token.regex);if(pos===-1)return 0;score=token.string.length/value.length;if(pos===0)score+=.5;return score};var scoreObject=function(){var field_count=fields.length;if(!field_count){return function(){return 0}}if(field_count===1){return function(token,data){return scoreValue(getattr(data,fields[0],nesting),token)}}return function(token,data){for(var i=0,sum=0;i<field_count;i++){sum+=scoreValue(getattr(data,fields[i],nesting),token)}return sum/field_count}}();if(!token_count){return function(){return 0}}if(token_count===1){return function(data){return scoreObject(tokens[0],data)}}if(search.options.conjunction==="and"){return function(data){var score;for(var i=0,sum=0;i<token_count;i++){score=scoreObject(tokens[i],data);if(score<=0)return 0;sum+=score}return sum/token_count}}else{return function(data){for(var i=0,sum=0;i<token_count;i++){sum+=scoreObject(tokens[i],data)}return sum/token_count}}};Sifter.prototype.getSortFunction=function(search,options){var i,n,self,field,fields,fields_count,multiplier,multipliers,get_field,implicit_score,sort;self=this;search=self.prepareSearch(search,options);sort=!search.query&&options.sort_empty||options.sort;get_field=function(name,result){if(name==="$score")return result.score;return getattr(self.items[result.id],name,options.nesting)};fields=[];if(sort){for(i=0,n=sort.length;i<n;i++){if(search.query||sort[i].field!=="$score"){fields.push(sort[i])}}}if(search.query){implicit_score=true;for(i=0,n=fields.length;i<n;i++){if(fields[i].field==="$score"){implicit_score=false;break}}if(implicit_score){fields.unshift({field:"$score",direction:"desc"})}}else{for(i=0,n=fields.length;i<n;i++){if(fields[i].field==="$score"){fields.splice(i,1);break}}}multipliers=[];for(i=0,n=fields.length;i<n;i++){multipliers.push(fields[i].direction==="desc"?-1:1)}fields_count=fields.length;if(!fields_count){return null}else if(fields_count===1){field=fields[0].field;multiplier=multipliers[0];return function(a,b){return multiplier*cmp(get_field(field,a),get_field(field,b))}}else{return function(a,b){var i,result,a_value,b_value,field;for(i=0;i<fields_count;i++){field=fields[i].field;result=multipliers[i]*cmp(get_field(field,a),get_field(field,b));if(result)return result}return 0}}};Sifter.prototype.prepareSearch=function(query,options){if(typeof query==="object")return query;options=extend({},options);var option_fields=options.fields;var option_sort=options.sort;var option_sort_empty=options.sort_empty;if(option_fields&&!is_array(option_fields))options.fields=[option_fields];if(option_sort&&!is_array(option_sort))options.sort=[option_sort];if(option_sort_empty&&!is_array(option_sort_empty))options.sort_empty=[option_sort_empty];return{options:options,query:String(query||"").toLowerCase(),tokens:this.tokenize(query,options.respect_word_boundaries),total:0,items:[]}};Sifter.prototype.search=function(query,options){var self=this,value,score,search,calculateScore;var fn_sort;var fn_score;search=this.prepareSearch(query,options);options=search.options;query=search.query;fn_score=options.score||self.getScoreFunction(search);if(query.length){self.iterator(self.items,function(item,id){score=fn_score(item);if(options.filter===false||score>0){search.items.push({score:score,id:id})}})}else{self.iterator(self.items,function(item,id){search.items.push({score:1,id:id})})}fn_sort=self.getSortFunction(search,options);if(fn_sort)search.items.sort(fn_sort);search.total=search.items.length;if(typeof options.limit==="number"){search.items=search.items.slice(0,options.limit)}return search};var cmp=function(a,b){if(typeof a==="number"&&typeof b==="number"){return a>b?1:a<b?-1:0}a=asciifold(String(a||""));b=asciifold(String(b||""));if(a>b)return 1;if(b>a)return-1;return 0};var extend=function(a,b){var i,n,k,object;for(i=1,n=arguments.length;i<n;i++){object=arguments[i];if(!object)continue;for(k in object){if(object.hasOwnProperty(k)){a[k]=object[k]}}}return a};var getattr=function(obj,name,nesting){if(!obj||!name)return;if(!nesting)return obj[name];var names=name.split(".");while(names.length&&(obj=obj[names.shift()]));return obj};var trim=function(str){return(str+"").replace(/^\s+|\s+$|/g,"")};var escape_regex=function(str){return(str+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")};var is_array=Array.isArray||typeof $!=="undefined"&&$.isArray||function(object){return Object.prototype.toString.call(object)==="[object Array]"};var DIACRITICS={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"};var asciifold=function(){var i,n,k,chunk;var foreignletters="";var lookup={};for(k in DIACRITICS){if(DIACRITICS.hasOwnProperty(k)){chunk=DIACRITICS[k].substring(2,DIACRITICS[k].length-1);foreignletters+=chunk;for(i=0,n=chunk.length;i<n;i++){lookup[chunk.charAt(i)]=k}}}var regexp=new RegExp("["+foreignletters+"]","g");return function(str){return str.replace(regexp,function(foreignletter){return lookup[foreignletter]}).toLowerCase()}}();return Sifter});(function(root,factory){if(typeof define==="function"&&define.amd){define(factory)}else if(typeof exports==="object"){module.exports=factory()}else{root.MicroPlugin=factory()}})(this,function(){var MicroPlugin={};MicroPlugin.mixin=function(Interface){Interface.plugins={};Interface.prototype.initializePlugins=function(plugins){var i,n,key;var self=this;var queue=[];self.plugins={names:[],settings:{},requested:{},loaded:{}};if(utils.isArray(plugins)){for(i=0,n=plugins.length;i<n;i++){if(typeof plugins[i]==="string"){queue.push(plugins[i])}else{self.plugins.settings[plugins[i].name]=plugins[i].options;queue.push(plugins[i].name)}}}else if(plugins){for(key in plugins){if(plugins.hasOwnProperty(key)){self.plugins.settings[key]=plugins[key];queue.push(key)}}}while(queue.length){self.require(queue.shift())}};Interface.prototype.loadPlugin=function(name){var self=this;var plugins=self.plugins;var plugin=Interface.plugins[name];if(!Interface.plugins.hasOwnProperty(name)){throw new Error('Unable to find "'+name+'" plugin')}plugins.requested[name]=true;plugins.loaded[name]=plugin.fn.apply(self,[self.plugins.settings[name]||{}]);plugins.names.push(name)};Interface.prototype.require=function(name){var self=this;var plugins=self.plugins;if(!self.plugins.loaded.hasOwnProperty(name)){if(plugins.requested[name]){throw new Error('Plugin has circular dependency ("'+name+'")')}self.loadPlugin(name)}return plugins.loaded[name]};Interface.define=function(name,fn){Interface.plugins[name]={name:name,fn:fn}}};var utils={isArray:Array.isArray||function(vArg){return Object.prototype.toString.call(vArg)==="[object Array]"}};return MicroPlugin});(function(root,factory){if(typeof define==="function"&&define.amd){define(["jquery","sifter","microplugin"],factory)}else if(typeof module==="object"&&typeof module.exports==="object"){module.exports=factory(require("jquery"),require("sifter"),require("microplugin"))}else{root.Selectize=factory(root.jQuery,root.Sifter,root.MicroPlugin)}})(this,function($,Sifter,MicroPlugin){"use strict";var highlight=function($element,pattern){if(typeof pattern==="string"&&!pattern.length)return;var regex=typeof pattern==="string"?new RegExp(pattern,"i"):pattern;var highlight=function(node){var skip=0;if(node.nodeType===3){var pos=node.data.search(regex);if(pos>=0&&node.data.length>0){var match=node.data.match(regex);var spannode=document.createElement("span");spannode.className="highlight";var middlebit=node.splitText(pos);var endbit=middlebit.splitText(match[0].length);var middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);skip=1}}else if(node.nodeType===1&&node.childNodes&&!/(script|style)/i.test(node.tagName)&&(node.className!=="highlight"||node.tagName!=="SPAN")){for(var i=0;i<node.childNodes.length;++i){i+=highlight(node.childNodes[i])}}return skip};return $element.each(function(){highlight(this)})};$.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var parent=this.parentNode;parent.replaceChild(this.firstChild,this);parent.normalize()}).end()};var MicroEvent=function(){};MicroEvent.prototype={on:function(event,fct){this._events=this._events||{};this._events[event]=this._events[event]||[];this._events[event].push(fct)},off:function(event,fct){var n=arguments.length;if(n===0)return delete this._events;if(n===1)return delete this._events[event];this._events=this._events||{};if(event in this._events===false)return;this._events[event].splice(this._events[event].indexOf(fct),1)},trigger:function(event){this._events=this._events||{};if(event in this._events===false)return;for(var i=0;i<this._events[event].length;i++){this._events[event][i].apply(this,Array.prototype.slice.call(arguments,1))}}};MicroEvent.mixin=function(destObject){var props=["on","off","trigger"];for(var i=0;i<props.length;i++){destObject.prototype[props[i]]=MicroEvent.prototype[props[i]]}};var IS_MAC=/Mac/.test(navigator.userAgent);var KEY_A=65;var KEY_COMMA=188;var KEY_RETURN=13;var KEY_ESC=27;var KEY_LEFT=37;var KEY_UP=38;var KEY_P=80;var KEY_RIGHT=39;var KEY_DOWN=40;var KEY_N=78;var KEY_BACKSPACE=8;var KEY_DELETE=46;var KEY_SHIFT=16;var KEY_CMD=IS_MAC?91:17;var KEY_CTRL=IS_MAC?18:17;var KEY_TAB=9;var TAG_SELECT=1;var TAG_INPUT=2;var SUPPORTS_VALIDITY_API=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity;var isset=function(object){return typeof object!=="undefined"};var hash_key=function(value){if(typeof value==="undefined"||value===null)return null;if(typeof value==="boolean")return value?"1":"0";return value+""};var escape_html=function(str){return(str+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")};var escape_replace=function(str){return(str+"").replace(/\$/g,"$$$$")};var hook={};hook.before=function(self,method,fn){var original=self[method];self[method]=function(){fn.apply(self,arguments);return original.apply(self,arguments)}};hook.after=function(self,method,fn){var original=self[method];self[method]=function(){var result=original.apply(self,arguments);fn.apply(self,arguments);return result}};var once=function(fn){var called=false;return function(){if(called)return;called=true;fn.apply(this,arguments)}};var debounce=function(fn,delay){var timeout;return function(){var self=this;var args=arguments;window.clearTimeout(timeout);timeout=window.setTimeout(function(){fn.apply(self,args)},delay)}};var debounce_events=function(self,types,fn){var type;var trigger=self.trigger;var event_args={};self.trigger=function(){var type=arguments[0];if(types.indexOf(type)!==-1){event_args[type]=arguments}else{return trigger.apply(self,arguments)}};fn.apply(self,[]);self.trigger=trigger;for(type in event_args){if(event_args.hasOwnProperty(type)){trigger.apply(self,event_args[type])}}};var watchChildEvent=function($parent,event,selector,fn){$parent.on(event,selector,function(e){var child=e.target;while(child&&child.parentNode!==$parent[0]){child=child.parentNode}e.currentTarget=child;return fn.apply(this,[e])})};var getSelection=function(input){var result={};if("selectionStart"in input){result.start=input.selectionStart;result.length=input.selectionEnd-result.start}else if(document.selection){input.focus();var sel=document.selection.createRange();var selLen=document.selection.createRange().text.length;sel.moveStart("character",-input.value.length);result.start=sel.text.length-selLen;result.length=selLen}return result};var transferStyles=function($from,$to,properties){var i,n,styles={};if(properties){for(i=0,n=properties.length;i<n;i++){styles[properties[i]]=$from.css(properties[i])}}else{styles=$from.css()}$to.css(styles)};var measureString=function(str,$parent){if(!str){return 0}if(!Selectize.$testInput){Selectize.$testInput=$("<span />").css({position:"absolute",width:"auto",padding:0,whiteSpace:"pre"});$("<div />").css({position:"absolute",width:0,height:0,overflow:"hidden"}).append(Selectize.$testInput).appendTo("body")}Selectize.$testInput.text(str);transferStyles($parent,Selectize.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);return Selectize.$testInput.width()};var autoGrow=function($input){var currentWidth=null;var update=function(e,options){var value,keyCode,printable,placeholder,width;var shift,character,selection;e=e||window.event||{};options=options||{};if(e.metaKey||e.altKey)return;if(!options.force&&$input.data("grow")===false)return;value=$input.val();if(e.type&&e.type.toLowerCase()==="keydown"){keyCode=e.keyCode;printable=keyCode>=48&&keyCode<=57||keyCode>=65&&keyCode<=90||keyCode>=96&&keyCode<=111||keyCode>=186&&keyCode<=222||keyCode===32;if(keyCode===KEY_DELETE||keyCode===KEY_BACKSPACE){selection=getSelection($input[0]);if(selection.length){value=value.substring(0,selection.start)+value.substring(selection.start+selection.length)}else if(keyCode===KEY_BACKSPACE&&selection.start){value=value.substring(0,selection.start-1)+value.substring(selection.start+1)}else if(keyCode===KEY_DELETE&&typeof selection.start!=="undefined"){value=value.substring(0,selection.start)+value.substring(selection.start+1)}}else if(printable){shift=e.shiftKey;character=String.fromCharCode(e.keyCode);if(shift)character=character.toUpperCase();else character=character.toLowerCase();value+=character}}placeholder=$input.attr("placeholder");if(!value&&placeholder){value=placeholder}width=measureString(value,$input)+4;if(width!==currentWidth){currentWidth=width;$input.width(width);$input.triggerHandler("resize")}};$input.on("keydown keyup update blur",update);update()};var domToString=function(d){var tmp=document.createElement("div");tmp.appendChild(d.cloneNode(true));return tmp.innerHTML};var logError=function(message,options){if(!options)options={};var component="Selectize";console.error(component+": "+message);if(options.explanation){if(console.group)console.group();console.error(options.explanation);if(console.group)console.groupEnd()}};var Selectize=function($input,settings){var key,i,n,dir,input,self=this;input=$input[0];input.selectize=self;var computedStyle=window.getComputedStyle&&window.getComputedStyle(input,null);dir=computedStyle?computedStyle.getPropertyValue("direction"):input.currentStyle&&input.currentStyle.direction;dir=dir||$input.parents("[dir]:first").attr("dir")||"";$.extend(self,{order:0,settings:settings,$input:$input,tabIndex:$input.attr("tabindex")||"",tagType:input.tagName.toLowerCase()==="select"?TAG_SELECT:TAG_INPUT,rtl:/rtl/i.test(dir),eventNS:".selectize"+ ++Selectize.count,highlightedValue:null,isBlurring:false,isOpen:false,isDisabled:false,isRequired:$input.is("[required]"),isInvalid:false,isLocked:false,isFocused:false,isInputHidden:false,isSetup:false,isShiftDown:false,isCmdDown:false,isCtrlDown:false,ignoreFocus:false,ignoreBlur:false,ignoreHover:false,hasOptions:false,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:settings.loadThrottle===null?self.onSearchChange:debounce(self.onSearchChange,settings.loadThrottle)});self.sifter=new Sifter(this.options,{diacritics:settings.diacritics});if(self.settings.options){for(i=0,n=self.settings.options.length;i<n;i++){self.registerOption(self.settings.options[i])}delete self.settings.options}if(self.settings.optgroups){for(i=0,n=self.settings.optgroups.length;i<n;i++){self.registerOptionGroup(self.settings.optgroups[i])}delete self.settings.optgroups}self.settings.mode=self.settings.mode||(self.settings.maxItems===1?"single":"multi");if(typeof self.settings.hideSelected!=="boolean"){self.settings.hideSelected=self.settings.mode==="multi"}self.initializePlugins(self.settings.plugins);self.setupCallbacks();self.setupTemplates();self.setup()};MicroEvent.mixin(Selectize);if(typeof MicroPlugin!=="undefined"){MicroPlugin.mixin(Selectize)}else{logError("Dependency MicroPlugin is missing",{explanation:'Make sure you either: (1) are using the "standalone" '+"version of Selectize, or (2) require MicroPlugin before you "+"load Selectize."})}$.extend(Selectize.prototype,{setup:function(){var self=this;var settings=self.settings;var eventNS=self.eventNS;var $window=$(window);var $document=$(document);var $input=self.$input;var $wrapper;var $control;var $control_input;var $dropdown;var $dropdown_content;var $dropdown_parent;var inputMode;var timeout_blur;var timeout_focus;var classes;var classes_plugins;var inputId;inputMode=self.settings.mode;classes=$input.attr("class")||"";$wrapper=$("<div>").addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);$control=$("<div>").addClass(settings.inputClass).addClass("items").appendTo($wrapper);$control_input=$('<input type="text" autocomplete="new-password" autofill="no" />').appendTo($control).attr("tabindex",$input.is(":disabled")?"-1":self.tabIndex);$dropdown_parent=$(settings.dropdownParent||$wrapper);$dropdown=$("<div>").addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);$dropdown_content=$("<div>").addClass(settings.dropdownContentClass).appendTo($dropdown);if(inputId=$input.attr("id")){$control_input.attr("id",inputId+"-selectized");$("label[for='"+inputId+"']").attr("for",inputId+"-selectized")}if(self.settings.copyClassesToDropdown){$dropdown.addClass(classes)}$wrapper.css({width:$input[0].style.width});if(self.plugins.names.length){classes_plugins="plugin-"+self.plugins.names.join(" plugin-");$wrapper.addClass(classes_plugins);$dropdown.addClass(classes_plugins)}if((settings.maxItems===null||settings.maxItems>1)&&self.tagType===TAG_SELECT){$input.attr("multiple","multiple")}if(self.settings.placeholder){$control_input.attr("placeholder",settings.placeholder)}if(!self.settings.splitOn&&self.settings.delimiter){var delimiterEscaped=self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");self.settings.splitOn=new RegExp("\\s*"+delimiterEscaped+"+\\s*")}if($input.attr("autocorrect")){$control_input.attr("autocorrect",$input.attr("autocorrect"))}if($input.attr("autocapitalize")){$control_input.attr("autocapitalize",$input.attr("autocapitalize"))}$control_input[0].type=$input[0].type;self.$wrapper=$wrapper;self.$control=$control;self.$control_input=$control_input;self.$dropdown=$dropdown;self.$dropdown_content=$dropdown_content;$dropdown.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(e){e.stopImmediatePropagation()});$dropdown.on("mouseenter","[data-selectable]",function(){return self.onOptionHover.apply(self,arguments)});$dropdown.on("mousedown click","[data-selectable]",function(){return self.onOptionSelect.apply(self,arguments)});watchChildEvent($control,"mousedown","*:not(input)",function(){return self.onItemSelect.apply(self,arguments)});autoGrow($control_input);$control.on({mousedown:function(){return self.onMouseDown.apply(self,arguments)},click:function(){return self.onClick.apply(self,arguments)}});$control_input.on({mousedown:function(e){e.stopPropagation()},keydown:function(){return self.onKeyDown.apply(self,arguments)},keyup:function(){return self.onKeyUp.apply(self,arguments)},keypress:function(){return self.onKeyPress.apply(self,arguments)},resize:function(){self.positionDropdown.apply(self,[])},blur:function(){return self.onBlur.apply(self,arguments)},focus:function(){self.ignoreBlur=false;return self.onFocus.apply(self,arguments)},paste:function(){return self.onPaste.apply(self,arguments)}});$document.on("keydown"+eventNS,function(e){self.isCmdDown=e[IS_MAC?"metaKey":"ctrlKey"];self.isCtrlDown=e[IS_MAC?"altKey":"ctrlKey"];self.isShiftDown=e.shiftKey});$document.on("keyup"+eventNS,function(e){if(e.keyCode===KEY_CTRL)self.isCtrlDown=false;if(e.keyCode===KEY_SHIFT)self.isShiftDown=false;if(e.keyCode===KEY_CMD)self.isCmdDown=false});$document.on("mousedown"+eventNS,function(e){if(self.isFocused){if(e.target===self.$dropdown[0]||e.target.parentNode===self.$dropdown[0]){return false}if(!self.$control.has(e.target).length&&e.target!==self.$control[0]){self.blur(e.target)}}});$window.on(["scroll"+eventNS,"resize"+eventNS].join(" "),function(){if(self.isOpen){self.positionDropdown.apply(self,arguments)}});$window.on("mousemove"+eventNS,function(){self.ignoreHover=false});this.revertSettings={$children:$input.children().detach(),tabindex:$input.attr("tabindex")};$input.attr("tabindex",-1).hide().after(self.$wrapper);if($.isArray(settings.items)){self.setValue(settings.items);delete settings.items}if(SUPPORTS_VALIDITY_API){$input.on("invalid"+eventNS,function(e){e.preventDefault();self.isInvalid=true;self.refreshState()})}self.updateOriginalInput();self.refreshItems();self.refreshState();self.updatePlaceholder();self.isSetup=true;if($input.is(":disabled")){self.disable()}self.on("change",this.onChange);$input.data("selectize",self);$input.addClass("selectized");self.trigger("initialize");if(settings.preload===true){self.onSearchChange("")}},setupTemplates:function(){var self=this;var field_label=self.settings.labelField;var field_optgroup=self.settings.optgroupLabelField;var templates={optgroup:function(data){return'<div class="optgroup">'+data.html+"</div>"},optgroup_header:function(data,escape){return'<div class="optgroup-header">'+escape(data[field_optgroup])+"</div>"},option:function(data,escape){return'<div class="option">'+escape(data[field_label])+"</div>"},item:function(data,escape){return'<div class="item">'+escape(data[field_label])+"</div>"},option_create:function(data,escape){return'<div class="create">Add <strong>'+escape(data.input)+"</strong>…</div>"}};self.settings.render=$.extend({},templates,self.settings.render)},setupCallbacks:function(){var key,fn,callbacks={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur",dropdown_item_activate:"onDropdownItemActivate",dropdown_item_deactivate:"onDropdownItemDeactivate"};for(key in callbacks){if(callbacks.hasOwnProperty(key)){fn=this.settings[callbacks[key]];if(fn)this.on(key,fn)}}},onClick:function(e){var self=this;if(!self.isFocused||!self.isOpen){self.focus();e.preventDefault()}},onMouseDown:function(e){var self=this;var defaultPrevented=e.isDefaultPrevented();var $target=$(e.target);if(self.isFocused){if(e.target!==self.$control_input[0]){if(self.settings.mode==="single"){self.isOpen?self.close():self.open()}else if(!defaultPrevented){self.setActiveItem(null)}return false}}else{if(!defaultPrevented){window.setTimeout(function(){self.focus()},0)}}},onChange:function(){this.$input.trigger("change")},onPaste:function(e){var self=this;if(self.isFull()||self.isInputHidden||self.isLocked){e.preventDefault();return}if(self.settings.splitOn){setTimeout(function(){var pastedText=self.$control_input.val();if(!pastedText.match(self.settings.splitOn)){return}var splitInput=$.trim(pastedText).split(self.settings.splitOn);for(var i=0,n=splitInput.length;i<n;i++){self.createItem(splitInput[i])}},0)}},onKeyPress:function(e){if(this.isLocked)return e&&e.preventDefault();var character=String.fromCharCode(e.keyCode||e.which);if(this.settings.create&&this.settings.mode==="multi"&&character===this.settings.delimiter){this.createItem();e.preventDefault();return false}},onKeyDown:function(e){var isInput=e.target===this.$control_input[0];var self=this;if(self.isLocked){if(e.keyCode!==KEY_TAB){e.preventDefault()}return}switch(e.keyCode){case KEY_A:if(self.isCmdDown){self.selectAll();return}break;case KEY_ESC:if(self.isOpen){e.preventDefault();e.stopPropagation();self.close()}return;case KEY_N:if(!e.ctrlKey||e.altKey)break;case KEY_DOWN:if(!self.isOpen&&self.hasOptions){self.open()}else if(self.$activeOption){self.ignoreHover=true;var $next=self.getAdjacentOption(self.$activeOption,1);if($next.length)self.setActiveOption($next,true,true)}e.preventDefault();return;case KEY_P:if(!e.ctrlKey||e.altKey)break;case KEY_UP:if(self.$activeOption){self.ignoreHover=true;var $prev=self.getAdjacentOption(self.$activeOption,-1);if($prev.length)self.setActiveOption($prev,true,true)}e.preventDefault();return;case KEY_RETURN:if(self.isOpen&&self.$activeOption){self.onOptionSelect({currentTarget:self.$activeOption});e.preventDefault()}return;case KEY_LEFT:self.advanceSelection(-1,e);return;case KEY_RIGHT:self.advanceSelection(1,e);return;case KEY_TAB:if(self.settings.selectOnTab&&self.isOpen&&self.$activeOption){self.onOptionSelect({currentTarget:self.$activeOption});if(!self.isFull()){e.preventDefault()}}if(self.settings.create&&self.createItem()){e.preventDefault()}return;case KEY_BACKSPACE:case KEY_DELETE:self.deleteSelection(e);return}if((self.isFull()||self.isInputHidden)&&!(IS_MAC?e.metaKey:e.ctrlKey)){e.preventDefault();return}},onKeyUp:function(e){var self=this;if(self.isLocked)return e&&e.preventDefault();var value=self.$control_input.val()||"";if(self.lastValue!==value){self.lastValue=value;self.onSearchChange(value);self.refreshOptions();self.trigger("type",value)}},onSearchChange:function(value){var self=this;var fn=self.settings.load;if(!fn)return;if(self.loadedSearches.hasOwnProperty(value))return;self.loadedSearches[value]=true;self.load(function(callback){fn.apply(self,[value,callback])})},onFocus:function(e){var self=this;var wasFocused=self.isFocused;if(self.isDisabled){self.blur();e&&e.preventDefault();return false}if(self.ignoreFocus)return;self.isFocused=true;if(self.settings.preload==="focus")self.onSearchChange("");if(!wasFocused)self.trigger("focus");if(!self.$activeItems.length){self.showInput();self.setActiveItem(null);self.refreshOptions(!!self.settings.openOnFocus)}self.refreshState()},onBlur:function(e,dest){var self=this;if(!self.isFocused)return;self.isFocused=false;if(self.ignoreFocus){return}else if(!self.ignoreBlur&&document.activeElement===self.$dropdown_content[0]){self.ignoreBlur=true;self.onFocus(e);return}var deactivate=function(){self.close();self.setTextboxValue("");self.setActiveItem(null);self.setActiveOption(null);self.setCaret(self.items.length);self.refreshState();dest&&dest.focus&&dest.focus();self.isBlurring=false;self.ignoreFocus=false;self.trigger("blur")};self.isBlurring=true;self.ignoreFocus=true;if(self.settings.create&&self.settings.createOnBlur){self.createItem(null,false,deactivate)}else{deactivate()}},onOptionHover:function(e){if(this.ignoreHover)return;this.setActiveOption(e.currentTarget,false)},onOptionSelect:function(e){var value,$target,$option,self=this;if(e.preventDefault){e.preventDefault();e.stopPropagation()}$target=$(e.currentTarget);if($target.hasClass("create")){self.createItem(null,function(){if(self.settings.closeAfterSelect){self.close()}})}else{value=$target.attr("data-value");if(typeof value!=="undefined"){self.lastQuery=null;self.setTextboxValue("");self.addItem(value);if(self.settings.closeAfterSelect){self.close()}else if(!self.settings.hideSelected&&e.type&&/mouse/.test(e.type)){self.setActiveOption(self.getOption(value))}}}},onItemSelect:function(e){var self=this;if(self.isLocked)return;if(self.settings.mode==="multi"){e.preventDefault();self.setActiveItem(e.currentTarget,e)}},load:function(fn){var self=this;var $wrapper=self.$wrapper.addClass(self.settings.loadingClass);self.loading++;fn.apply(self,[function(results){self.loading=Math.max(self.loading-1,0);if(results&&results.length){self.addOption(results);self.refreshOptions(self.isFocused&&!self.isInputHidden)}if(!self.loading){$wrapper.removeClass(self.settings.loadingClass)}self.trigger("load",results)}])},setTextboxValue:function(value){var $input=this.$control_input;var changed=$input.val()!==value;if(changed){$input.val(value).triggerHandler("update");this.lastValue=value}},getValue:function(){if(this.tagType===TAG_SELECT&&this.$input.attr("multiple")){return this.items}else{return this.items.join(this.settings.delimiter)}},setValue:function(value,silent){var events=silent?[]:["change"];debounce_events(this,events,function(){this.clear(silent);this.addItems(value,silent)})},setMaxItems:function(value){if(value===0)value=null;this.settings.maxItems=value;this.settings.mode=this.settings.mode||(this.settings.maxItems===1?"single":"multi");this.refreshState()},setActiveItem:function($item,e){var self=this;var eventName;var i,idx,begin,end,item,swap;var $last;if(self.settings.mode==="single")return;$item=$($item);if(!$item.length){$(self.$activeItems).removeClass("active");self.$activeItems=[];if(self.isFocused){self.showInput()}return}eventName=e&&e.type.toLowerCase();if(eventName==="mousedown"&&self.isShiftDown&&self.$activeItems.length){$last=self.$control.children(".active:last");begin=Array.prototype.indexOf.apply(self.$control[0].childNodes,[$last[0]]);end=Array.prototype.indexOf.apply(self.$control[0].childNodes,[$item[0]]);if(begin>end){swap=begin;begin=end;end=swap}for(i=begin;i<=end;i++){item=self.$control[0].childNodes[i];if(self.$activeItems.indexOf(item)===-1){$(item).addClass("active");self.$activeItems.push(item)}}e.preventDefault()}else if(eventName==="mousedown"&&self.isCtrlDown||eventName==="keydown"&&this.isShiftDown){if($item.hasClass("active")){idx=self.$activeItems.indexOf($item[0]);self.$activeItems.splice(idx,1);$item.removeClass("active")}else{self.$activeItems.push($item.addClass("active")[0])}}else{$(self.$activeItems).removeClass("active");self.$activeItems=[$item.addClass("active")[0]]}self.hideInput();if(!this.isFocused){self.focus()}},setActiveOption:function($option,scroll,animate){var height_menu,height_item,y;var scroll_top,scroll_bottom;var self=this;if(self.$activeOption){self.$activeOption.removeClass("active");self.trigger("dropdown_item_deactivate",self.$activeOption.attr("data-value"))}self.$activeOption=null;$option=$($option);if(!$option.length)return;self.$activeOption=$option.addClass("active");if(self.isOpen)self.trigger("dropdown_item_activate",self.$activeOption.attr("data-value"));if(scroll||!isset(scroll)){height_menu=self.$dropdown_content.height();height_item=self.$activeOption.outerHeight(true);scroll=self.$dropdown_content.scrollTop()||0;y=self.$activeOption.offset().top-self.$dropdown_content.offset().top+scroll;scroll_top=y;scroll_bottom=y-height_menu+height_item;if(y+height_item>height_menu+scroll){self.$dropdown_content.stop().animate({scrollTop:scroll_bottom},animate?self.settings.scrollDuration:0)}else if(y<scroll){self.$dropdown_content.stop().animate({scrollTop:scroll_top},animate?self.settings.scrollDuration:0)}}},selectAll:function(){var self=this;if(self.settings.mode==="single")return;self.$activeItems=Array.prototype.slice.apply(self.$control.children(":not(input)").addClass("active"));if(self.$activeItems.length){self.hideInput();self.close()}self.focus()},hideInput:function(){var self=this;self.setTextboxValue("");self.$control_input.css({opacity:0,position:"absolute",left:self.rtl?1e4:-1e4});self.isInputHidden=true},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0});this.isInputHidden=false},focus:function(){var self=this;if(self.isDisabled)return;self.ignoreFocus=true;self.$control_input[0].focus();window.setTimeout(function(){self.ignoreFocus=false;self.onFocus()},0)},blur:function(dest){this.$control_input[0].blur();this.onBlur(null,dest)},getScoreFunction:function(query){return this.sifter.getScoreFunction(query,this.getSearchOptions())},getSearchOptions:function(){var settings=this.settings;var sort=settings.sortField;if(typeof sort==="string"){sort=[{field:sort}]}return{fields:settings.searchField,conjunction:settings.searchConjunction,sort:sort,nesting:settings.nesting}},search:function(query){var i,value,score,result,calculateScore;var self=this;var settings=self.settings;var options=this.getSearchOptions();if(settings.score){calculateScore=self.settings.score.apply(this,[query]);if(typeof calculateScore!=="function"){throw new Error('Selectize "score" setting must be a function that returns a function')}}if(query!==self.lastQuery){self.lastQuery=query;result=self.sifter.search(query,$.extend(options,{score:calculateScore}));self.currentResults=result}else{result=$.extend(true,{},self.currentResults)}if(settings.hideSelected){for(i=result.items.length-1;i>=0;i--){if(self.items.indexOf(hash_key(result.items[i].id))!==-1){result.items.splice(i,1)}}}return result},refreshOptions:function(triggerDropdown){var i,j,k,n,groups,groups_order,option,option_html,optgroup,optgroups,html,html_children,has_create_option;var $active,$active_before,$create;if(typeof triggerDropdown==="undefined"){triggerDropdown=true}var self=this;var query=$.trim(self.$control_input.val());var results=self.search(query);var $dropdown_content=self.$dropdown_content;var active_before=self.$activeOption&&hash_key(self.$activeOption.attr("data-value"));n=results.items.length;if(typeof self.settings.maxOptions==="number"){n=Math.min(n,self.settings.maxOptions)}groups={};groups_order=[];for(i=0;i<n;i++){option=self.options[results.items[i].id];option_html=self.render("option",option);optgroup=option[self.settings.optgroupField]||"";optgroups=$.isArray(optgroup)?optgroup:[optgroup];for(j=0,k=optgroups&&optgroups.length;j<k;j++){optgroup=optgroups[j];if(!self.optgroups.hasOwnProperty(optgroup)){optgroup=""}if(!groups.hasOwnProperty(optgroup)){groups[optgroup]=document.createDocumentFragment();groups_order.push(optgroup)}groups[optgroup].appendChild(option_html)}}if(this.settings.lockOptgroupOrder){groups_order.sort(function(a,b){var a_order=self.optgroups[a].$order||0;var b_order=self.optgroups[b].$order||0;return a_order-b_order})}html=document.createDocumentFragment();for(i=0,n=groups_order.length;i<n;i++){optgroup=groups_order[i];if(self.optgroups.hasOwnProperty(optgroup)&&groups[optgroup].childNodes.length){html_children=document.createDocumentFragment();html_children.appendChild(self.render("optgroup_header",self.optgroups[optgroup]));html_children.appendChild(groups[optgroup]);html.appendChild(self.render("optgroup",$.extend({},self.optgroups[optgroup],{html:domToString(html_children),dom:html_children})))}else{html.appendChild(groups[optgroup])}}$dropdown_content.html(html);if(self.settings.highlight){$dropdown_content.removeHighlight();if(results.query.length&&results.tokens.length){for(i=0,n=results.tokens.length;i<n;i++){highlight($dropdown_content,results.tokens[i].regex)}}}if(!self.settings.hideSelected){self.$dropdown.find(".selected").removeClass("selected");for(i=0,n=self.items.length;i<n;i++){self.getOption(self.items[i]).addClass("selected")}}has_create_option=self.canCreate(query);if(has_create_option){$dropdown_content.prepend(self.render("option_create",{input:query}));$create=$($dropdown_content[0].childNodes[0])}self.hasOptions=results.items.length>0||has_create_option;if(self.hasOptions){if(results.items.length>0){$active_before=active_before&&self.getOption(active_before);if($active_before&&$active_before.length){$active=$active_before}else if(self.settings.mode==="single"&&self.items.length){$active=self.getOption(self.items[0])}if(!$active||!$active.length){if($create&&!self.settings.addPrecedence){$active=self.getAdjacentOption($create,1)}else{$active=$dropdown_content.find("[data-selectable]:first")}}}else{$active=$create}self.setActiveOption($active);if(triggerDropdown&&!self.isOpen){self.open()}}else{self.setActiveOption(null);if(triggerDropdown&&self.isOpen){self.close()}}},addOption:function(data){var i,n,value,self=this;if($.isArray(data)){for(i=0,n=data.length;i<n;i++){self.addOption(data[i])}return}if(value=self.registerOption(data)){self.userOptions[value]=true;self.lastQuery=null;self.trigger("option_add",value,data)}},registerOption:function(data){var key=hash_key(data[this.settings.valueField]);if(typeof key==="undefined"||key===null||this.options.hasOwnProperty(key))return false;data.$order=data.$order||++this.order;this.options[key]=data;return key},registerOptionGroup:function(data){var key=hash_key(data[this.settings.optgroupValueField]);if(!key)return false;data.$order=data.$order||++this.order;this.optgroups[key]=data;return key},addOptionGroup:function(id,data){data[this.settings.optgroupValueField]=id;if(id=this.registerOptionGroup(data)){this.trigger("optgroup_add",id,data)}},removeOptionGroup:function(id){if(this.optgroups.hasOwnProperty(id)){delete this.optgroups[id];this.renderCache={};this.trigger("optgroup_remove",id)}},clearOptionGroups:function(){this.optgroups={};this.renderCache={};this.trigger("optgroup_clear")},updateOption:function(value,data){var self=this;var $item,$item_new;var value_new,index_item,cache_items,cache_options,order_old;value=hash_key(value);value_new=hash_key(data[self.settings.valueField]);if(value===null)return;if(!self.options.hasOwnProperty(value))return;if(typeof value_new!=="string")throw new Error("Value must be set in option data");order_old=self.options[value].$order;if(value_new!==value){delete self.options[value];index_item=self.items.indexOf(value);if(index_item!==-1){self.items.splice(index_item,1,value_new)}}data.$order=data.$order||order_old;self.options[value_new]=data;cache_items=self.renderCache["item"];cache_options=self.renderCache["option"];if(cache_items){delete cache_items[value];delete cache_items[value_new]}if(cache_options){delete cache_options[value];delete cache_options[value_new]}if(self.items.indexOf(value_new)!==-1){$item=self.getItem(value);$item_new=$(self.render("item",data));if($item.hasClass("active"))$item_new.addClass("active");$item.replaceWith($item_new)}self.lastQuery=null;if(self.isOpen){self.refreshOptions(false)}},removeOption:function(value,silent){var self=this;value=hash_key(value);var cache_items=self.renderCache["item"];var cache_options=self.renderCache["option"];if(cache_items)delete cache_items[value];if(cache_options)delete cache_options[value];delete self.userOptions[value];delete self.options[value];self.lastQuery=null;self.trigger("option_remove",value);self.removeItem(value,silent)},clearOptions:function(silent){var self=this;self.loadedSearches={};self.userOptions={};self.renderCache={};var options=self.options;$.each(self.options,function(key,value){if(self.items.indexOf(key)==-1){delete options[key]}});self.options=self.sifter.items=options;self.lastQuery=null;self.trigger("option_clear");self.clear(silent)},getOption:function(value){return this.getElementWithValue(value,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function($option,direction){var $options=this.$dropdown.find("[data-selectable]");var index=$options.index($option)+direction;return index>=0&&index<$options.length?$options.eq(index):$()},getElementWithValue:function(value,$els){value=hash_key(value);if(typeof value!=="undefined"&&value!==null){for(var i=0,n=$els.length;i<n;i++){if($els[i].getAttribute("data-value")===value){return $($els[i])}}}return $()},getItem:function(value){return this.getElementWithValue(value,this.$control.children())},addItems:function(values,silent){this.buffer=document.createDocumentFragment();var childNodes=this.$control[0].childNodes;for(var i=0;i<childNodes.length;i++){this.buffer.appendChild(childNodes[i])}var items=$.isArray(values)?values:[values];for(var i=0,n=items.length;i<n;i++){this.isPending=i<n-1;this.addItem(items[i],silent)}var control=this.$control[0];control.insertBefore(this.buffer,control.firstChild);this.buffer=null},addItem:function(value,silent){var events=silent?[]:["change"];debounce_events(this,events,function(){var $item,$option,$options;var self=this;var inputMode=self.settings.mode;var i,active,value_next,wasFull;value=hash_key(value);if(self.items.indexOf(value)!==-1){if(inputMode==="single")self.close();return}if(!self.options.hasOwnProperty(value))return;if(inputMode==="single")self.clear(silent);if(inputMode==="multi"&&self.isFull())return;$item=$(self.render("item",self.options[value]));wasFull=self.isFull();self.items.splice(self.caretPos,0,value);self.insertAtCaret($item);if(!self.isPending||!wasFull&&self.isFull()){self.refreshState()}if(self.isSetup){$options=self.$dropdown_content.find("[data-selectable]");if(!self.isPending){$option=self.getOption(value);value_next=self.getAdjacentOption($option,1).attr("data-value");self.refreshOptions(self.isFocused&&inputMode!=="single");if(value_next){self.setActiveOption(self.getOption(value_next))}}if(!$options.length||self.isFull()){self.close()}else if(!self.isPending){self.positionDropdown()}self.updatePlaceholder();self.trigger("item_add",value,$item);if(!self.isPending){self.updateOriginalInput({silent:silent})}}})},removeItem:function(value,silent){var self=this;var $item,i,idx;$item=value instanceof $?value:self.getItem(value);value=hash_key($item.attr("data-value"));i=self.items.indexOf(value);if(i!==-1){$item.remove();if($item.hasClass("active")){idx=self.$activeItems.indexOf($item[0]);self.$activeItems.splice(idx,1)}self.items.splice(i,1);self.lastQuery=null;if(!self.settings.persist&&self.userOptions.hasOwnProperty(value)){self.removeOption(value,silent)}if(i<self.caretPos){self.setCaret(self.caretPos-1)}self.refreshState();self.updatePlaceholder();self.updateOriginalInput({silent:silent});self.positionDropdown();self.trigger("item_remove",value,$item)}},createItem:function(input,triggerDropdown){var self=this;var caret=self.caretPos;input=input||$.trim(self.$control_input.val()||"");var callback=arguments[arguments.length-1];if(typeof callback!=="function")callback=function(){};if(typeof triggerDropdown!=="boolean"){triggerDropdown=true}if(!self.canCreate(input)){callback();return false}self.lock();var setup=typeof self.settings.create==="function"?this.settings.create:function(input){var data={};data[self.settings.labelField]=input;data[self.settings.valueField]=input;return data};var create=once(function(data){self.unlock();if(!data||typeof data!=="object")return callback();var value=hash_key(data[self.settings.valueField]);if(typeof value!=="string")return callback();self.setTextboxValue("");self.addOption(data);self.setCaret(caret);self.addItem(value);self.refreshOptions(triggerDropdown&&self.settings.mode!=="single");callback(data)});var output=setup.apply(this,[input,create]);if(typeof output!=="undefined"){create(output)}return true},refreshItems:function(){this.lastQuery=null;if(this.isSetup){this.addItem(this.items)}this.refreshState();this.updateOriginalInput()},refreshState:function(){this.refreshValidityState();this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired)return false;var invalid=!this.items.length;this.isInvalid=invalid;this.$control_input.prop("required",invalid);this.$input.prop("required",!invalid)},refreshClasses:function(){var self=this;var isFull=self.isFull();var isLocked=self.isLocked;self.$wrapper.toggleClass("rtl",self.rtl);self.$control.toggleClass("focus",self.isFocused).toggleClass("disabled",self.isDisabled).toggleClass("required",self.isRequired).toggleClass("invalid",self.isInvalid).toggleClass("locked",isLocked).toggleClass("full",isFull).toggleClass("not-full",!isFull).toggleClass("input-active",self.isFocused&&!self.isInputHidden).toggleClass("dropdown-active",self.isOpen).toggleClass("has-options",!$.isEmptyObject(self.options)).toggleClass("has-items",self.items.length>0);self.$control_input.data("grow",!isFull&&!isLocked)},isFull:function(){return this.settings.maxItems!==null&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(opts){var i,n,options,label,self=this;opts=opts||{};if(self.tagType===TAG_SELECT){options=[];for(i=0,n=self.items.length;i<n;i++){label=self.options[self.items[i]][self.settings.labelField]||"";options.push('<option value="'+escape_html(self.items[i])+'" selected="selected">'+escape_html(label)+"</option>")}if(!options.length&&!this.$input.attr("multiple")){options.push('<option value="" selected="selected"></option>')}self.$input.html(options.join(""))}else{self.$input.val(self.getValue());self.$input.attr("value",self.$input.val())}if(self.isSetup){if(!opts.silent){self.trigger("change",self.$input.val())}}},updatePlaceholder:function(){if(!this.settings.placeholder)return;var $input=this.$control_input;if(this.items.length){$input.removeAttr("placeholder")}else{$input.attr("placeholder",this.settings.placeholder)}$input.triggerHandler("update",{force:true})},open:function(){var self=this;if(self.isLocked||self.isOpen||self.settings.mode==="multi"&&self.isFull())return;self.focus();self.isOpen=true;self.refreshState();self.$dropdown.css({visibility:"hidden",display:"block"});self.positionDropdown();self.$dropdown.css({visibility:"visible"});self.trigger("dropdown_open",self.$dropdown)},close:function(){var self=this;var trigger=self.isOpen;if(self.settings.mode==="single"&&self.items.length){self.hideInput();if(!self.isBlurring){self.$control_input.blur()}}self.isOpen=false;self.$dropdown.hide();self.setActiveOption(null);self.refreshState();if(trigger)self.trigger("dropdown_close",self.$dropdown)},positionDropdown:function(){var $control=this.$control;var offset=this.settings.dropdownParent==="body"?$control.offset():$control.position();offset.top+=$control.outerHeight(true);this.$dropdown.css({width:$control[0].getBoundingClientRect().width,top:offset.top,left:offset.left})},clear:function(silent){var self=this;if(!self.items.length)return;self.$control.children(":not(input)").remove();self.items=[];self.lastQuery=null;self.setCaret(0);self.setActiveItem(null);self.updatePlaceholder();self.updateOriginalInput({silent:silent});self.refreshState();self.showInput();self.trigger("clear")},insertAtCaret:function($el){var caret=Math.min(this.caretPos,this.items.length);var el=$el[0];var target=this.buffer||this.$control[0];if(caret===0){target.insertBefore(el,target.firstChild)}else{target.insertBefore(el,target.childNodes[caret])}this.setCaret(caret+1)},deleteSelection:function(e){var i,n,direction,selection,values,caret,option_select,$option_select,$tail;var self=this;direction=e&&e.keyCode===KEY_BACKSPACE?-1:1;selection=getSelection(self.$control_input[0]);if(self.$activeOption&&!self.settings.hideSelected){option_select=self.getAdjacentOption(self.$activeOption,-1).attr("data-value")}values=[];if(self.$activeItems.length){$tail=self.$control.children(".active:"+(direction>0?"last":"first"));caret=self.$control.children(":not(input)").index($tail);if(direction>0){caret++}for(i=0,n=self.$activeItems.length;i<n;i++){values.push($(self.$activeItems[i]).attr("data-value"))}if(e){e.preventDefault();e.stopPropagation()}}else if((self.isFocused||self.settings.mode==="single")&&self.items.length){if(direction<0&&selection.start===0&&selection.length===0){values.push(self.items[self.caretPos-1])}else if(direction>0&&selection.start===self.$control_input.val().length){values.push(self.items[self.caretPos])}}if(!values.length||typeof self.settings.onDelete==="function"&&self.settings.onDelete.apply(self,[values])===false){return false}if(typeof caret!=="undefined"){self.setCaret(caret)}while(values.length){self.removeItem(values.pop())}self.showInput();self.positionDropdown();self.refreshOptions(true);if(option_select){$option_select=self.getOption(option_select);if($option_select.length){self.setActiveOption($option_select)}}return true},advanceSelection:function(direction,e){var tail,selection,idx,valueLength,cursorAtEdge,$tail;var self=this;if(direction===0)return;if(self.rtl)direction*=-1;tail=direction>0?"last":"first";selection=getSelection(self.$control_input[0]);if(self.isFocused&&!self.isInputHidden){valueLength=self.$control_input.val().length;cursorAtEdge=direction<0?selection.start===0&&selection.length===0:selection.start===valueLength;if(cursorAtEdge&&!valueLength){self.advanceCaret(direction,e)}}else{$tail=self.$control.children(".active:"+tail);if($tail.length){idx=self.$control.children(":not(input)").index($tail);self.setActiveItem(null);self.setCaret(direction>0?idx+1:idx)}}},advanceCaret:function(direction,e){var self=this,fn,$adj;if(direction===0)return;fn=direction>0?"next":"prev";if(self.isShiftDown){$adj=self.$control_input[fn]();if($adj.length){self.hideInput();self.setActiveItem($adj);e&&e.preventDefault()}}else{self.setCaret(self.caretPos+direction)}},setCaret:function(i){var self=this;if(self.settings.mode==="single"){i=self.items.length}else{i=Math.max(0,Math.min(self.items.length,i))}if(!self.isPending){var j,n,fn,$children,$child;$children=self.$control.children(":not(input)");for(j=0,n=$children.length;j<n;j++){$child=$($children[j]).detach();if(j<i){self.$control_input.before($child)}else{self.$control.append($child)}}}self.caretPos=i},lock:function(){this.close();this.isLocked=true;this.refreshState()},unlock:function(){this.isLocked=false;this.refreshState()},disable:function(){var self=this;self.$input.prop("disabled",true);self.$control_input.prop("disabled",true).prop("tabindex",-1);self.isDisabled=true;self.lock()},enable:function(){var self=this;self.$input.prop("disabled",false);self.$control_input.prop("disabled",false).prop("tabindex",self.tabIndex);self.isDisabled=false;self.unlock()},destroy:function(){var self=this;var eventNS=self.eventNS;var revertSettings=self.revertSettings;self.trigger("destroy");self.off();self.$wrapper.remove();self.$dropdown.remove();self.$input.html("").append(revertSettings.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:revertSettings.tabindex}).show();self.$control_input.removeData("grow");self.$input.removeData("selectize");if(--Selectize.count==0&&Selectize.$testInput){Selectize.$testInput.remove();Selectize.$testInput=undefined}$(window).off(eventNS);$(document).off(eventNS);$(document.body).off(eventNS);delete self.$input[0].selectize},render:function(templateName,data){var value,id,label;var html="";var cache=false;var self=this;var regex_tag=/^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;if(templateName==="option"||templateName==="item"){value=hash_key(data[self.settings.valueField]);cache=!!value}if(cache){if(!isset(self.renderCache[templateName])){self.renderCache[templateName]={}}if(self.renderCache[templateName].hasOwnProperty(value)){return self.renderCache[templateName][value]}}html=$(self.settings.render[templateName].apply(this,[data,escape_html]));if(templateName==="option"||templateName==="option_create"){if(!data[self.settings.disabledField]){html.attr("data-selectable","")}}else if(templateName==="optgroup"){id=data[self.settings.optgroupValueField]||"";html.attr("data-group",id);if(data[self.settings.disabledField]){html.attr("data-disabled","")}}if(templateName==="option"||templateName==="item"){html.attr("data-value",value||"")}if(cache){self.renderCache[templateName][value]=html[0]}return html[0]},clearCache:function(templateName){var self=this;if(typeof templateName==="undefined"){self.renderCache={}}else{delete self.renderCache[templateName]}},canCreate:function(input){var self=this;if(!self.settings.create)return false;var filter=self.settings.createFilter;return input.length&&(typeof filter!=="function"||filter.apply(self,[input]))&&(typeof filter!=="string"||new RegExp(filter).test(input))&&(!(filter instanceof RegExp)||filter.test(input))}});Selectize.count=0;Selectize.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:true,diacritics:true,create:false,createOnBlur:false,createFilter:null,highlight:true,openOnFocus:true,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:false,selectOnTab:true,preload:false,allowEmptyOption:false,closeAfterSelect:false,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:false,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:true,render:{}};$.fn.selectize=function(settings_user){var defaults=$.fn.selectize.defaults;var settings=$.extend({},defaults,settings_user);var attr_data=settings.dataAttr;var field_label=settings.labelField;var field_value=settings.valueField;var field_disabled=settings.disabledField;var field_optgroup=settings.optgroupField;var field_optgroup_label=settings.optgroupLabelField;var field_optgroup_value=settings.optgroupValueField;var init_textbox=function($input,settings_element){var i,n,values,option;var data_raw=$input.attr(attr_data);if(!data_raw){var value=$.trim($input.val()||"");if(!settings.allowEmptyOption&&!value.length)return;values=value.split(settings.delimiter);for(i=0,n=values.length;i<n;i++){option={};option[field_label]=values[i];option[field_value]=values[i];settings_element.options.push(option)}settings_element.items=values}else{settings_element.options=JSON.parse(data_raw);for(i=0,n=settings_element.options.length;i<n;i++){settings_element.items.push(settings_element.options[i][field_value])}}};var init_select=function($input,settings_element){var i,n,tagName,$children,order=0;var options=settings_element.options;var optionsMap={};var readData=function($el){var data=attr_data&&$el.attr(attr_data);if(typeof data==="string"&&data.length){return JSON.parse(data)}return null};var addOption=function($option,group){$option=$($option);var value=hash_key($option.val());if(!value&&!settings.allowEmptyOption)return;if(optionsMap.hasOwnProperty(value)){if(group){var arr=optionsMap[value][field_optgroup];if(!arr){optionsMap[value][field_optgroup]=group}else if(!$.isArray(arr)){optionsMap[value][field_optgroup]=[arr,group]}else{arr.push(group)}}return}var option=readData($option)||{};option[field_label]=option[field_label]||$option.text();option[field_value]=option[field_value]||value;option[field_disabled]=option[field_disabled]||$option.prop("disabled");option[field_optgroup]=option[field_optgroup]||group;optionsMap[value]=option;options.push(option);if($option.is(":selected")){settings_element.items.push(value)}};var addGroup=function($optgroup){var i,n,id,optgroup,$options;$optgroup=$($optgroup);id=$optgroup.attr("label");if(id){optgroup=readData($optgroup)||{};optgroup[field_optgroup_label]=id;optgroup[field_optgroup_value]=id;optgroup[field_disabled]=$optgroup.prop("disabled");settings_element.optgroups.push(optgroup)}$options=$("option",$optgroup);for(i=0,n=$options.length;i<n;i++){addOption($options[i],id)}};settings_element.maxItems=$input.attr("multiple")?null:1;$children=$input.children();for(i=0,n=$children.length;i<n;i++){tagName=$children[i].tagName.toLowerCase();if(tagName==="optgroup"){addGroup($children[i])}else if(tagName==="option"){addOption($children[i])}}};return this.each(function(){if(this.selectize)return;var instance;var $input=$(this);var tag_name=this.tagName.toLowerCase();var placeholder=$input.attr("placeholder")||$input.attr("data-placeholder");if(!placeholder&&!settings.allowEmptyOption){placeholder=$input.children('option[value=""]').text()}var settings_element={placeholder:placeholder,options:[],optgroups:[],items:[]};if(tag_name==="select"){init_select($input,settings_element)}else{init_textbox($input,settings_element)}instance=new Selectize($input,$.extend(true,{},defaults,settings_element,settings_user))})};$.fn.selectize.defaults=Selectize.defaults;$.fn.selectize.support={validity:SUPPORTS_VALIDITY_API};Selectize.define("autofill_disable",function(options){var self=this;self.setup=function(){var original=self.setup;return function(){original.apply(self,arguments);self.$control_input.attr({autocomplete:"new-password",autofill:"no"})}}()});Selectize.define("drag_drop",function(options){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if(this.settings.mode!=="multi")return;var self=this;self.lock=function(){var original=self.lock;return function(){var sortable=self.$control.data("sortable");if(sortable)sortable.disable();return original.apply(self,arguments)}}();self.unlock=function(){var original=self.unlock;return function(){var sortable=self.$control.data("sortable");if(sortable)sortable.enable();return original.apply(self,arguments)}}();self.setup=function(){var original=self.setup;return function(){original.apply(this,arguments);var $control=self.$control.sortable({items:"[data-value]",forcePlaceholderSize:true,disabled:self.isLocked,start:function(e,ui){ui.placeholder.css("width",ui.helper.css("width"));$control.css({overflow:"visible"})},stop:function(){$control.css({overflow:"hidden"});var active=self.$activeItems?self.$activeItems.slice():null;var values=[];$control.children("[data-value]").each(function(){values.push($(this).attr("data-value"))});self.setValue(values);self.setActiveItem(active)}})}}()});Selectize.define("dropdown_header",function(options){var self=this;options=$.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(data){return'<div class="'+data.headerClass+'">'+'<div class="'+data.titleRowClass+'">'+'<span class="'+data.labelClass+'">'+data.title+"</span>"+'<a href="javascript:void(0)" class="'+data.closeClass+'">×</a>'+"</div>"+"</div>"}},options);self.setup=function(){var original=self.setup;return function(){original.apply(self,arguments);self.$dropdown_header=$(options.html(options));self.$dropdown.prepend(self.$dropdown_header)}}()});Selectize.define("optgroup_columns",function(options){var self=this;options=$.extend({equalizeWidth:true,equalizeHeight:true},options);this.getAdjacentOption=function($option,direction){var $options=$option.closest("[data-group]").find("[data-selectable]");var index=$options.index($option)+direction;return index>=0&&index<$options.length?$options.eq(index):$()};this.onKeyDown=function(){var original=self.onKeyDown;return function(e){var index,$option,$options,$optgroup;if(this.isOpen&&(e.keyCode===KEY_LEFT||e.keyCode===KEY_RIGHT)){self.ignoreHover=true;$optgroup=this.$activeOption.closest("[data-group]");index=$optgroup.find("[data-selectable]").index(this.$activeOption);if(e.keyCode===KEY_LEFT){$optgroup=$optgroup.prev("[data-group]")}else{$optgroup=$optgroup.next("[data-group]")}$options=$optgroup.find("[data-selectable]");$option=$options.eq(Math.min($options.length-1,index));if($option.length){this.setActiveOption($option)}return}return original.apply(this,arguments)}}();var getScrollbarWidth=function(){var div;var width=getScrollbarWidth.width;var doc=document;if(typeof width==="undefined"){div=doc.createElement("div");div.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';div=div.firstChild;doc.body.appendChild(div);width=getScrollbarWidth.width=div.offsetWidth-div.clientWidth;doc.body.removeChild(div)}return width};var equalizeSizes=function(){var i,n,height_max,width,width_last,width_parent,$optgroups;$optgroups=$("[data-group]",self.$dropdown_content);n=$optgroups.length;if(!n||!self.$dropdown_content.width())return;if(options.equalizeHeight){height_max=0;for(i=0;i<n;i++){height_max=Math.max(height_max,$optgroups.eq(i).height())}$optgroups.css({height:height_max})}if(options.equalizeWidth){width_parent=self.$dropdown_content.innerWidth()-getScrollbarWidth();width=Math.round(width_parent/n);$optgroups.css({width:width});if(n>1){width_last=width_parent-width*(n-1);$optgroups.eq(n-1).css({width:width_last})}}};if(options.equalizeHeight||options.equalizeWidth){hook.after(this,"positionDropdown",equalizeSizes);hook.after(this,"refreshOptions",equalizeSizes)}});Selectize.define("remove_button",function(options){options=$.extend({label:"×",title:"Remove",className:"remove",append:true},options);var singleClose=function(thisRef,options){options.className="remove-single";var self=thisRef;var html='<a href="javascript:void(0)" class="'+options.className+'" tabindex="-1" title="'+escape_html(options.title)+'">'+options.label+"</a>";var append=function(html_container,html_element){return $("<span>").append(html_container).append(html_element)};thisRef.setup=function(){var original=self.setup;return function(){if(options.append){var id=$(self.$input.context).attr("id");var selectizer=$("#"+id);var render_item=self.settings.render.item;self.settings.render.item=function(data){return append(render_item.apply(thisRef,arguments),html)}}original.apply(thisRef,arguments);thisRef.$control.on("click","."+options.className,function(e){e.preventDefault();if(self.isLocked)return;self.clear()})}}()};var multiClose=function(thisRef,options){var self=thisRef;var html='<a href="javascript:void(0)" class="'+options.className+'" tabindex="-1" title="'+escape_html(options.title)+'">'+options.label+"</a>";var append=function(html_container,html_element){var pos=html_container.search(/(<\/[^>]+>\s*)$/);return html_container.substring(0,pos)+html_element+html_container.substring(pos)};thisRef.setup=function(){var original=self.setup;return function(){if(options.append){var render_item=self.settings.render.item;self.settings.render.item=function(data){return append(render_item.apply(thisRef,arguments),html)}}original.apply(thisRef,arguments);thisRef.$control.on("click","."+options.className,function(e){e.preventDefault();if(self.isLocked)return;var $item=$(e.currentTarget).parent();self.setActiveItem($item);if(self.deleteSelection()){self.setCaret(self.items.length)}return false})}}()};if(this.settings.mode==="single"){singleClose(this,options);return}else{multiClose(this,options)}});Selectize.define("restore_on_backspace",function(options){var self=this;options.text=options.text||function(option){return option[this.settings.labelField]};this.onKeyDown=function(){var original=self.onKeyDown;return function(e){var index,option;if(e.keyCode===KEY_BACKSPACE&&this.$control_input.val()===""&&!this.$activeItems.length){index=this.caretPos-1;if(index>=0&&index<this.items.length){option=this.options[this.items[index]];if(this.deleteSelection(e)){this.setTextboxValue(options.text.apply(this,[option]));this.refreshOptions(true)}e.preventDefault();return}}return original.apply(this,arguments)}}()});return Selectize});
|
|
|
|
meta-tag-manager-admin.php
CHANGED
@@ -32,6 +32,9 @@ class Meta_Tag_Manager_Admin {
|
|
32 |
add_action('add_meta_boxes', 'Meta_Tag_Manager_Admin::meta_boxes');
|
33 |
//Save/Edit actions
|
34 |
add_filter('wp_insert_post_data', 'Meta_Tag_Manager_Admin::wp_insert_post_data', 100, 2); //validate post meta before saving is done
|
|
|
|
|
|
|
35 |
}
|
36 |
}
|
37 |
|
@@ -58,7 +61,7 @@ class Meta_Tag_Manager_Admin {
|
|
58 |
if( defined('WP_DEBUG') && WP_DEBUG ){
|
59 |
wp_enqueue_script('mtm-selectize', plugins_url('js/selectize.js',__FILE__), $jquery_deps, MTM_VERSION);
|
60 |
wp_enqueue_script('meta-tag-manager', plugins_url('js/meta-tag-manager.js',__FILE__), $jquery_deps, MTM_VERSION);
|
61 |
-
wp_enqueue_style('mtm-selectize', plugins_url('css/selectize.css',__FILE__), array(), MTM_VERSION);
|
62 |
wp_enqueue_style('meta-tag-manager', plugins_url('css/meta-tag-manager.css',__FILE__), array(), MTM_VERSION);
|
63 |
}else{
|
64 |
wp_enqueue_script('mtm-selectize', plugins_url('js/selectize.min.js',__FILE__), $jquery_deps, MTM_VERSION);
|
@@ -82,7 +85,7 @@ class Meta_Tag_Manager_Admin {
|
|
82 |
echo MTM_Builder::output(Meta_Tag_Manager::get_post_data($post->ID), array('context'=>false));
|
83 |
}
|
84 |
|
85 |
-
public static function wp_insert_post_data($data, $postarr){
|
86 |
$post_type = $data['post_type'];
|
87 |
$post_ID = !empty($postarr['ID']) ? $postarr['ID'] : false;
|
88 |
$mtm_custom = get_option('mtm_custom');
|
@@ -90,10 +93,24 @@ class Meta_Tag_Manager_Admin {
|
|
90 |
if( $post_ID && !empty($mtm_custom['post-types']) && in_array($post_type, $mtm_custom['post-types']) ){
|
91 |
include_once('mtm-builder.php');
|
92 |
$mtm_data = MTM_Builder::get_post(array('context'=>false));
|
93 |
-
if( !empty($mtm_data) )
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
return $data;
|
96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
/** the plugin options page */
|
99 |
public static function options() {
|
32 |
add_action('add_meta_boxes', 'Meta_Tag_Manager_Admin::meta_boxes');
|
33 |
//Save/Edit actions
|
34 |
add_filter('wp_insert_post_data', 'Meta_Tag_Manager_Admin::wp_insert_post_data', 100, 2); //validate post meta before saving is done
|
35 |
+
//special for attachments (if supported)
|
36 |
+
add_action('attachment_updated', 'Meta_Tag_Manager_Admin::wp_insert_attachment_data');
|
37 |
+
add_action('add_attachment', 'Meta_Tag_Manager_Admin::wp_insert_attachment_data');
|
38 |
}
|
39 |
}
|
40 |
|
61 |
if( defined('WP_DEBUG') && WP_DEBUG ){
|
62 |
wp_enqueue_script('mtm-selectize', plugins_url('js/selectize.js',__FILE__), $jquery_deps, MTM_VERSION);
|
63 |
wp_enqueue_script('meta-tag-manager', plugins_url('js/meta-tag-manager.js',__FILE__), $jquery_deps, MTM_VERSION);
|
64 |
+
wp_enqueue_style('mtm-selectize', plugins_url('css/selectize/selectize.css',__FILE__), array(), MTM_VERSION);
|
65 |
wp_enqueue_style('meta-tag-manager', plugins_url('css/meta-tag-manager.css',__FILE__), array(), MTM_VERSION);
|
66 |
}else{
|
67 |
wp_enqueue_script('mtm-selectize', plugins_url('js/selectize.min.js',__FILE__), $jquery_deps, MTM_VERSION);
|
85 |
echo MTM_Builder::output(Meta_Tag_Manager::get_post_data($post->ID), array('context'=>false));
|
86 |
}
|
87 |
|
88 |
+
public static function wp_insert_post_data( $data, $postarr ){
|
89 |
$post_type = $data['post_type'];
|
90 |
$post_ID = !empty($postarr['ID']) ? $postarr['ID'] : false;
|
91 |
$mtm_custom = get_option('mtm_custom');
|
93 |
if( $post_ID && !empty($mtm_custom['post-types']) && in_array($post_type, $mtm_custom['post-types']) ){
|
94 |
include_once('mtm-builder.php');
|
95 |
$mtm_data = MTM_Builder::get_post(array('context'=>false));
|
96 |
+
if( !empty($mtm_data) ){
|
97 |
+
update_post_meta($post_ID, 'mtm_data', $mtm_data);
|
98 |
+
}else{
|
99 |
+
//check if we already had tags for this post, if so, delete them since it must have been deleted
|
100 |
+
$previous_tags = Meta_Tag_Manager::get_post_data($post_ID);
|
101 |
+
if( !empty($previous_tags) ) delete_post_meta($post_ID, 'mtm_data');
|
102 |
+
}
|
103 |
}
|
104 |
return $data;
|
105 |
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Wrapper function for wp_insert_post_data processing of attachments, since they have specific actions and no filter.
|
109 |
+
* @param int $post_ID
|
110 |
+
*/
|
111 |
+
public static function wp_insert_attachment_data( $post_ID ){
|
112 |
+
self::wp_insert_post_data(array('post_type' => 'attachment'), array('ID'=>$post_ID));
|
113 |
+
}
|
114 |
|
115 |
/** the plugin options page */
|
116 |
public static function options() {
|
meta-tag-manager.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Meta Tag Manager
|
|
4 |
Plugin URI: https://wordpress.org/plugins/meta-tag-manager/
|
5 |
Description: A simple plugin to manage meta tags that appear on aread of your site or individual posts. This can be used for verifiying google, yahoo, and more.
|
6 |
Author: Marcus Sykes
|
7 |
-
Version: 2.1.
|
8 |
Author URI: http://msyk.es/?utm_source=meta-tag-manager&utm_medium=plugin-header&utm_campaign=plugins
|
9 |
Text Domain: meta-tag-manager
|
10 |
*/
|
@@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
26 |
*/
|
27 |
if( !defined('ABSPATH') ) exit;
|
28 |
|
29 |
-
define('MTM_VERSION', '2.1.
|
30 |
|
31 |
class Meta_Tag_Manager {
|
32 |
/** loads the plugin */
|
4 |
Plugin URI: https://wordpress.org/plugins/meta-tag-manager/
|
5 |
Description: A simple plugin to manage meta tags that appear on aread of your site or individual posts. This can be used for verifiying google, yahoo, and more.
|
6 |
Author: Marcus Sykes
|
7 |
+
Version: 2.1.3
|
8 |
Author URI: http://msyk.es/?utm_source=meta-tag-manager&utm_medium=plugin-header&utm_campaign=plugins
|
9 |
Text Domain: meta-tag-manager
|
10 |
*/
|
26 |
*/
|
27 |
if( !defined('ABSPATH') ) exit;
|
28 |
|
29 |
+
define('MTM_VERSION', '2.1.3');
|
30 |
|
31 |
class Meta_Tag_Manager {
|
32 |
/** loads the plugin */
|
mtm-builder.php
CHANGED
@@ -135,7 +135,7 @@ class MTM_Builder {
|
|
135 |
<?php echo self::output_select_options($type_values, $tag->value); ?>
|
136 |
</select>
|
137 |
<?php else: ?>
|
138 |
-
<input name="mtm-fields[<?php echo esc_attr($i); ?>][value]" type="text" class="mtm-field-input-<?php echo esc_attr($type); ?> mtm-field-input-tag-value" value="<?php echo esc_attr($tag->value); ?>" />
|
139 |
<?php endif; ?>
|
140 |
</label>
|
141 |
</div>
|
135 |
<?php echo self::output_select_options($type_values, $tag->value); ?>
|
136 |
</select>
|
137 |
<?php else: ?>
|
138 |
+
<input name="mtm-fields[<?php echo esc_attr($i); ?>][value]" type="text" class="mtm-field-input-<?php echo esc_attr($tag->type); ?> mtm-field-input-tag-value" value="<?php echo esc_attr($tag->value); ?>" />
|
139 |
<?php endif; ?>
|
140 |
</label>
|
141 |
</div>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: google, SEO, yahoo, tags, webmaster tools, meta, meta tags, ogp, open grap
|
|
4 |
Text Domain: meta-tag-manager
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 5.6
|
7 |
-
Stable tag: 2.1.
|
8 |
|
9 |
Easily add and manage custom meta tags to various parts of your site or on individual posts, such as Yahoo and Google verification tags.
|
10 |
|
@@ -69,6 +69,10 @@ Please visit our <a href="https://wordpress.org/support/plugin/meta-tag-manager"
|
|
69 |
3. If enabled you can add meta tags to a specific post in it's own meta box
|
70 |
|
71 |
== Changelog ==
|
|
|
|
|
|
|
|
|
72 |
= 2.1.2 =
|
73 |
* fixed WordPress 5.5 conflict (props to @seserss)
|
74 |
|
4 |
Text Domain: meta-tag-manager
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 5.6
|
7 |
+
Stable tag: 2.1.3
|
8 |
|
9 |
Easily add and manage custom meta tags to various parts of your site or on individual posts, such as Yahoo and Google verification tags.
|
10 |
|
69 |
3. If enabled you can add meta tags to a specific post in it's own meta box
|
70 |
|
71 |
== Changelog ==
|
72 |
+
= 2.1.3 =
|
73 |
+
* updated selectize library to v0.13 which fixes issues with name tags containing custom values
|
74 |
+
* fixed minor php warning
|
75 |
+
|
76 |
= 2.1.2 =
|
77 |
* fixed WordPress 5.5 conflict (props to @seserss)
|
78 |
|