Popup Maker – Popup Forms, Optins & More - Version 1.8.5

Version Description

Download this release

Release Info

Developer danieliser
Plugin Icon 128x128 Popup Maker – Popup Forms, Optins & More
Version 1.8.5
Comparing to
See all releases

Code changes from version 1.8.4 to 1.8.5

CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  = v1.8.4 - 03/21/2019 =
2
  * Improvement: Added content caching in the head to prevent second call to do_shortcode in the footer.
3
  * Improvement: Added runtime model caching to reduce memory usage.
1
+ = v1.8.5 - 04/17/2019 =
2
+ * Tweak: Removed unused settings.
3
+ * Fix: Typo in method name that would generate errors in some extension migration routines.
4
+ * Fix: Issue when using class="" in our Popup Trigger shortcode would not get converted to classes on the element.
5
+ * Fix: Bug in JS due to missing default value.
6
+ * Fix: Bug older extensions caused by deprecated filter not getting loaded properly.
7
+
8
  = v1.8.4 - 03/21/2019 =
9
  * Improvement: Added content caching in the head to prevent second call to do_shortcode in the footer.
10
  * Improvement: Added runtime model caching to reduce memory usage.
assets/js/admin-batch.js CHANGED
@@ -1,349 +1,349 @@
1
- /*******************************************************************************
2
- * Copyright (c) 2018, WP Popup Maker
3
- ******************************************************************************/
4
-
5
- "use strict";
6
- (function ($) {
7
-
8
- /**
9
- * Batch Processor.
10
- *
11
- * @since 1.7.0
12
- */
13
- var batch = {
14
- form: {
15
- beforeSubmit: function ($form) {
16
- var $submit = $form.find('.pum-field-submit input[type="submit"]'),
17
- $messages = $form.find('.pum-upgrade-messages'),
18
- $progress = $form.find('.pum-batch-progress'),
19
- // Handle the Are You Sure (AYS) if present on the form element.
20
- ays = $form.data('ays');
21
-
22
- if (!$submit.hasClass('button-disabled')) {
23
-
24
- if (ays !== undefined && !confirm(ays)) {
25
- return false;
26
- }
27
-
28
- $progress.removeClass('pum-batch-progress--active');
29
- $progress.find('progress').prop('value', null);
30
-
31
- // Clear messages.
32
- $messages.html('');
33
-
34
- // Disable the button.
35
- $submit.addClass('button-disabled');
36
-
37
- // Add the spinner.
38
- $('<span class="spinner is-active"></span>').insertAfter($submit);
39
-
40
- return true;
41
- }
42
-
43
- return false;
44
- }
45
- },
46
- complete: function ($form) {
47
- var $alert = $form.parents('.pum-alert');
48
-
49
- $form.find('.pum-field-submit, progress').hide();
50
- $('p.pum-upgrade-notice').hide();
51
- $alert.removeClass('pum-alert__warning').addClass('pum-alert__success');
52
- $alert.prepend('<h2>' + pum_batch_vars.complete + '</h2>');
53
- },
54
- action: 'pum_process_batch_request',
55
- /**
56
- * Processes a single batch of data.
57
- *
58
- * @param {integer|number|string} step Step in the process.
59
- * @param {object} data Form data.
60
- */
61
- process_step: function (step, data) {
62
- var self = this;
63
-
64
- $.ajax({
65
- type: 'POST',
66
- url: ajaxurl,
67
- data: {
68
- batch_id: data.batch_id,
69
- action: self.action,
70
- nonce: data.nonce,
71
- form: data.form,
72
- step: parseInt(step),
73
- data: data
74
- },
75
- dataType: "json",
76
- success: function (response) {
77
-
78
- if (response.data.done || response.data.error) {
79
-
80
- var batchSelector = response.data.mapping ? '.pum-batch-import-form' : '.pum-batch-form',
81
- // We need to get the actual in progress form, not all forms on the page
82
- $batchForm = $(batchSelector),
83
- spinner = $batchForm.find('.spinner'),
84
- notice_wrap = $batchForm.find('.notice-wrap');
85
-
86
- $batchForm.find('.button-disabled').removeClass('button-disabled');
87
-
88
- if (response.data.error) {
89
-
90
- spinner.remove();
91
- notice_wrap.html('<div class="updated error"><p>' + response.data.error + '</p></div>');
92
-
93
- } else if (response.data.done) {
94
-
95
- spinner.remove();
96
- notice_wrap.html('<div id="pum-batch-success" class="updated notice"><p class="pum-batch-success">' + response.data.message + '</p></div>');
97
-
98
- if (response.data.url) {
99
- window.location = response.data.url;
100
- }
101
-
102
- } else {
103
-
104
- notice_wrap.remove();
105
-
106
- }
107
- } else {
108
- $('.pum-batch-progress div').animate({
109
- width: response.data.percentage + '%'
110
- }, 50);
111
-
112
- self.process_step(response.data.step, data);
113
- }
114
- }
115
- }).fail(function (response) {
116
- if (window.console && window.console.log) {
117
- console.log(response);
118
- }
119
- });
120
- }
121
- },
122
- batch_upgrades = $.extend(true, {}, batch, {
123
- action: 'pum_process_upgrade_request',
124
- /**
125
- * Processes a que of batch upgrades.
126
- *
127
- * @param {integer|number|string} step Step in the process.
128
- * @param {object} data Form data.
129
- */
130
- process_step: function (step, data) {
131
- var self = this;
132
-
133
- $.ajax({
134
- type: 'POST',
135
- url: ajaxurl,
136
- data: {
137
- upgrade_id: data.upgrade_id,
138
- action: self.action,
139
- nonce: data.nonce,
140
- form: data.form,
141
- step: parseInt(step),
142
- data: data
143
- },
144
- dataType: "json",
145
- success: function (response) {
146
- var $form = $('.pum-upgrade-form'), // We need to get the actual in progress form, not all forms on the page
147
- $spinner = $form.find('.spinner'),
148
- $submit = $form.find('.button-disabled'),
149
- $messages = $form.find('.pum-upgrade-messages');
150
-
151
- if (response.data.done || response.data.error) {
152
-
153
-
154
- // Reset submit button.
155
- $submit.removeClass('button-disabled');
156
-
157
- if (response.data.error) {
158
- $spinner.remove();
159
- $messages.prepend('<div class="notice notice-error notice-alt"><p>' + response.data.error + '</p></div>');
160
- } else if (response.data.done) {
161
-
162
- $messages.prepend('<div class="notice notice-success"><p><strong>' + response.data.message + '</strong></p></div>');
163
-
164
- if (response.data.next) {
165
- $form
166
- .data('upgrade_id', response.data.next)
167
- .data('step', 1)
168
- .data('ays', false);
169
-
170
- self.process_step(1, {
171
- upgrade_id: response.data.next,
172
- nonce: data.nonce,
173
- form: data.form
174
- });
175
- } else {
176
- $submit.parent().hide();
177
- $spinner.remove();
178
-
179
- batch.complete($form);
180
- }
181
-
182
- if (response.data.url) {
183
- window.location = response.data.url;
184
- }
185
-
186
- } else {
187
- if (response.data.message !== '') {
188
- $messages.prepend('<div class="notice"><p class="">' + response.data.message + '</p></div>');
189
- }
190
- }
191
- } else {
192
-
193
- if (response.data.message !== '') {
194
- $messages.prepend('<div class="notice"><p class="">' + response.data.message + '</p></div>');
195
- }
196
-
197
- $('.pum-batch-progress').addClass('pum-batch-progress--active');
198
-
199
- $('.pum-batch-progress progress.pum-task-progress').addClass('active').val(response.data.percentage);
200
-
201
- self.process_step(response.data.step, data);
202
- }
203
- }
204
- }).fail(function (response) {
205
- if (window.console && window.console.log) {
206
- console.log(response);
207
- }
208
- });
209
- }
210
-
211
- });
212
-
213
- // Import this module.
214
- window.PUM_Admin = window.PUM_Admin || {};
215
- window.PUM_Admin.batch = batch;
216
- window.PUM_Admin.batch_upgrades = batch_upgrades;
217
-
218
- /**
219
- * Handles form submission preceding batch processing.
220
- */
221
- $(document)
222
- .on('submit', '.pum-batch-form[data-batch_id]', function (event) {
223
- var $this = $(this),
224
- submitButton = $this.find('input[type="submit"]'),
225
- // Handle the Are You Sure (AYS) if present on the form element.
226
- ays = $this.data('ays'),
227
- data = {
228
- batch_id: $this.data('batch_id'),
229
- nonce: $this.data('nonce'),
230
- form: $this.serializeAssoc(),
231
- test: $this.pumSerializeObject()
232
- };
233
-
234
- event.preventDefault();
235
-
236
- if (!submitButton.hasClass('button-disabled')) {
237
-
238
- if (ays !== undefined && !confirm(ays)) {
239
- return;
240
- }
241
-
242
- // Remove existing notice & progress bars.
243
- $this.find('.notice-wrap').remove();
244
-
245
- // Add the progress bar.
246
- $this.append($('<div class="notice-wrap"><div class="pum-batch-progress"><div></div>'));
247
-
248
- // Disable the button.
249
- submitButton.addClass('button-disabled');
250
-
251
- // Add the spinner.
252
- submitButton.parent().append('<span class="spinner is-active"></span>');
253
-
254
- // Start the process.
255
- batch.process_step(1, data);
256
- }
257
- })
258
- .on('submit', '.pum-batch-form.pum-upgrade-form[data-upgrade_id]', function (event) {
259
- var $form = $(this),
260
- data = {
261
- upgrade_id: $form.data('upgrade_id'),
262
- nonce: $form.data('nonce'),
263
- form: $form.serializeAssoc(),
264
- test: $form.pumSerializeObject()
265
- };
266
-
267
- event.preventDefault();
268
-
269
- // Process presubmit actions like showing progress data and validating info.
270
- if (batch_upgrades.form.beforeSubmit($form)) {
271
- // Start the process.
272
- batch_upgrades.process_step($form.data('step') || 1, data);
273
- }
274
-
275
- })
276
- .ready(function () {
277
- });
278
-
279
- }(jQuery));
280
-
281
- jQuery(document).ready(function ($) {
282
-
283
- $.extend({
284
- arrayMerge: function () {
285
- var a = {};
286
- var n = 0;
287
- var argv = $.arrayMerge.arguments;
288
- for (var i = 0; i < argv.length; i++) {
289
- if (Array.isArray(argv[i])) {
290
- for (var j = 0; j < argv[i].length; j++) {
291
- a[n++] = argv[i][j];
292
- }
293
- a = $.makeArray(a);
294
- } else {
295
- for (var k in argv[i]) {
296
- if (argv[i].hasOwnProperty(k)) {
297
- if (isNaN(k)) {
298
- var v = argv[i][k];
299
- if (typeof v === 'object' && a[k]) {
300
- v = $.arrayMerge(a[k], v);
301
- }
302
- a[k] = v;
303
- } else {
304
- a[n++] = argv[i][k];
305
- }
306
- }
307
- }
308
- }
309
- }
310
- return a;
311
- },
312
- count: function (arr) {
313
- return Array.isArray(arr) ? arr.length : typeof arr === 'object' ? Object.keys(arr).length : false;
314
- }
315
- });
316
-
317
- $.fn.extend({
318
- serializeAssoc: function () {
319
- var o = {
320
- aa: {},
321
- add: function (name, value) {
322
- var tmp = name.match(/^(.*)\[([^\]]*)]$/),
323
- v = {};
324
-
325
- if (tmp) {
326
- if (tmp[2])
327
- v[tmp[2]] = value;
328
- else
329
- v[$.count(v)] = value;
330
- this.add(tmp[1], v);
331
- } else if (typeof value === 'object') {
332
- if (typeof this.aa[name] !== 'object') {
333
- this.aa[name] = {};
334
- }
335
- this.aa[name] = $.arrayMerge(this.aa[name], value);
336
- } else {
337
- this.aa[name] = value;
338
- }
339
- }
340
- };
341
- var a = $(this).serializeArray();
342
- for (var i = 0; i < a.length; i++) {
343
- o.add(a[i].name, a[i].value);
344
- }
345
- return o.aa;
346
- }
347
- });
348
-
349
- });
1
+ /*******************************************************************************
2
+ * Copyright (c) 2018, WP Popup Maker
3
+ ******************************************************************************/
4
+
5
+ "use strict";
6
+ (function ($) {
7
+
8
+ /**
9
+ * Batch Processor.
10
+ *
11
+ * @since 1.7.0
12
+ */
13
+ var batch = {
14
+ form: {
15
+ beforeSubmit: function ($form) {
16
+ var $submit = $form.find('.pum-field-submit input[type="submit"]'),
17
+ $messages = $form.find('.pum-upgrade-messages'),
18
+ $progress = $form.find('.pum-batch-progress'),
19
+ // Handle the Are You Sure (AYS) if present on the form element.
20
+ ays = $form.data('ays');
21
+
22
+ if (!$submit.hasClass('button-disabled')) {
23
+
24
+ if (ays !== undefined && !confirm(ays)) {
25
+ return false;
26
+ }
27
+
28
+ $progress.removeClass('pum-batch-progress--active');
29
+ $progress.find('progress').prop('value', null);
30
+
31
+ // Clear messages.
32
+ $messages.html('');
33
+
34
+ // Disable the button.
35
+ $submit.addClass('button-disabled');
36
+
37
+ // Add the spinner.
38
+ $('<span class="spinner is-active"></span>').insertAfter($submit);
39
+
40
+ return true;
41
+ }
42
+
43
+ return false;
44
+ }
45
+ },
46
+ complete: function ($form) {
47
+ var $alert = $form.parents('.pum-alert');
48
+
49
+ $form.find('.pum-field-submit, progress').hide();
50
+ $('p.pum-upgrade-notice').hide();
51
+ $alert.removeClass('pum-alert__warning').addClass('pum-alert__success');
52
+ $alert.prepend('<h2>' + pum_batch_vars.complete + '</h2>');
53
+ },
54
+ action: 'pum_process_batch_request',
55
+ /**
56
+ * Processes a single batch of data.
57
+ *
58
+ * @param {integer|number|string} step Step in the process.
59
+ * @param {object} data Form data.
60
+ */
61
+ process_step: function (step, data) {
62
+ var self = this;
63
+
64
+ $.ajax({
65
+ type: 'POST',
66
+ url: ajaxurl,
67
+ data: {
68
+ batch_id: data.batch_id,
69
+ action: self.action,
70
+ nonce: data.nonce,
71
+ form: data.form,
72
+ step: parseInt(step),
73
+ data: data
74
+ },
75
+ dataType: "json",
76
+ success: function (response) {
77
+
78
+ if (response.data.done || response.data.error) {
79
+
80
+ var batchSelector = response.data.mapping ? '.pum-batch-import-form' : '.pum-batch-form',
81
+ // We need to get the actual in progress form, not all forms on the page
82
+ $batchForm = $(batchSelector),
83
+ spinner = $batchForm.find('.spinner'),
84
+ notice_wrap = $batchForm.find('.notice-wrap');
85
+
86
+ $batchForm.find('.button-disabled').removeClass('button-disabled');
87
+
88
+ if (response.data.error) {
89
+
90
+ spinner.remove();
91
+ notice_wrap.html('<div class="updated error"><p>' + response.data.error + '</p></div>');
92
+
93
+ } else if (response.data.done) {
94
+
95
+ spinner.remove();
96
+ notice_wrap.html('<div id="pum-batch-success" class="updated notice"><p class="pum-batch-success">' + response.data.message + '</p></div>');
97
+
98
+ if (response.data.url) {
99
+ window.location = response.data.url;
100
+ }
101
+
102
+ } else {
103
+
104
+ notice_wrap.remove();
105
+
106
+ }
107
+ } else {
108
+ $('.pum-batch-progress div').animate({
109
+ width: response.data.percentage + '%'
110
+ }, 50);
111
+
112
+ self.process_step(response.data.step, data);
113
+ }
114
+ }
115
+ }).fail(function (response) {
116
+ if (window.console && window.console.log) {
117
+ console.log(response);
118
+ }
119
+ });
120
+ }
121
+ },
122
+ batch_upgrades = $.extend(true, {}, batch, {
123
+ action: 'pum_process_upgrade_request',
124
+ /**
125
+ * Processes a que of batch upgrades.
126
+ *
127
+ * @param {integer|number|string} step Step in the process.
128
+ * @param {object} data Form data.
129
+ */
130
+ process_step: function (step, data) {
131
+ var self = this;
132
+
133
+ $.ajax({
134
+ type: 'POST',
135
+ url: ajaxurl,
136
+ data: {
137
+ upgrade_id: data.upgrade_id,
138
+ action: self.action,
139
+ nonce: data.nonce,
140
+ form: data.form,
141
+ step: parseInt(step),
142
+ data: data
143
+ },
144
+ dataType: "json",
145
+ success: function (response) {
146
+ var $form = $('.pum-upgrade-form'), // We need to get the actual in progress form, not all forms on the page
147
+ $spinner = $form.find('.spinner'),
148
+ $submit = $form.find('.button-disabled'),
149
+ $messages = $form.find('.pum-upgrade-messages');
150
+
151
+ if (response.data.done || response.data.error) {
152
+
153
+
154
+ // Reset submit button.
155
+ $submit.removeClass('button-disabled');
156
+
157
+ if (response.data.error) {
158
+ $spinner.remove();
159
+ $messages.prepend('<div class="notice notice-error notice-alt"><p>' + response.data.error + '</p></div>');
160
+ } else if (response.data.done) {
161
+
162
+ $messages.prepend('<div class="notice notice-success"><p><strong>' + response.data.message + '</strong></p></div>');
163
+
164
+ if (response.data.next) {
165
+ $form
166
+ .data('upgrade_id', response.data.next)
167
+ .data('step', 1)
168
+ .data('ays', false);
169
+
170
+ self.process_step(1, {
171
+ upgrade_id: response.data.next,
172
+ nonce: data.nonce,
173
+ form: data.form
174
+ });
175
+ } else {
176
+ $submit.parent().hide();
177
+ $spinner.remove();
178
+
179
+ batch.complete($form);
180
+ }
181
+
182
+ if (response.data.url) {
183
+ window.location = response.data.url;
184
+ }
185
+
186
+ } else {
187
+ if (response.data.message !== '') {
188
+ $messages.prepend('<div class="notice"><p class="">' + response.data.message + '</p></div>');
189
+ }
190
+ }
191
+ } else {
192
+
193
+ if (response.data.message !== '') {
194
+ $messages.prepend('<div class="notice"><p class="">' + response.data.message + '</p></div>');
195
+ }
196
+
197
+ $('.pum-batch-progress').addClass('pum-batch-progress--active');
198
+
199
+ $('.pum-batch-progress progress.pum-task-progress').addClass('active').val(response.data.percentage);
200
+
201
+ self.process_step(response.data.step, data);
202
+ }
203
+ }
204
+ }).fail(function (response) {
205
+ if (window.console && window.console.log) {
206
+ console.log(response);
207
+ }
208
+ });
209
+ }
210
+
211
+ });
212
+
213
+ // Import this module.
214
+ window.PUM_Admin = window.PUM_Admin || {};
215
+ window.PUM_Admin.batch = batch;
216
+ window.PUM_Admin.batch_upgrades = batch_upgrades;
217
+
218
+ /**
219
+ * Handles form submission preceding batch processing.
220
+ */
221
+ $(document)
222
+ .on('submit', '.pum-batch-form[data-batch_id]', function (event) {
223
+ var $this = $(this),
224
+ submitButton = $this.find('input[type="submit"]'),
225
+ // Handle the Are You Sure (AYS) if present on the form element.
226
+ ays = $this.data('ays'),
227
+ data = {
228
+ batch_id: $this.data('batch_id'),
229
+ nonce: $this.data('nonce'),
230
+ form: $this.serializeAssoc(),
231
+ test: $this.pumSerializeObject()
232
+ };
233
+
234
+ event.preventDefault();
235
+
236
+ if (!submitButton.hasClass('button-disabled')) {
237
+
238
+ if (ays !== undefined && !confirm(ays)) {
239
+ return;
240
+ }
241
+
242
+ // Remove existing notice & progress bars.
243
+ $this.find('.notice-wrap').remove();
244
+
245
+ // Add the progress bar.
246
+ $this.append($('<div class="notice-wrap"><div class="pum-batch-progress"><div></div>'));
247
+
248
+ // Disable the button.
249
+ submitButton.addClass('button-disabled');
250
+
251
+ // Add the spinner.
252
+ submitButton.parent().append('<span class="spinner is-active"></span>');
253
+
254
+ // Start the process.
255
+ batch.process_step(1, data);
256
+ }
257
+ })
258
+ .on('submit', '.pum-batch-form.pum-upgrade-form[data-upgrade_id]', function (event) {
259
+ var $form = $(this),
260
+ data = {
261
+ upgrade_id: $form.data('upgrade_id'),
262
+ nonce: $form.data('nonce'),
263
+ form: $form.serializeAssoc(),
264
+ test: $form.pumSerializeObject()
265
+ };
266
+
267
+ event.preventDefault();
268
+
269
+ // Process presubmit actions like showing progress data and validating info.
270
+ if (batch_upgrades.form.beforeSubmit($form)) {
271
+ // Start the process.
272
+ batch_upgrades.process_step($form.data('step') || 1, data);
273
+ }
274
+
275
+ })
276
+ .ready(function () {
277
+ });
278
+
279
+ }(jQuery));
280
+
281
+ jQuery(document).ready(function ($) {
282
+
283
+ $.extend({
284
+ arrayMerge: function () {
285
+ var a = {};
286
+ var n = 0;
287
+ var argv = $.arrayMerge.arguments;
288
+ for (var i = 0; i < argv.length; i++) {
289
+ if (Array.isArray(argv[i])) {
290
+ for (var j = 0; j < argv[i].length; j++) {
291
+ a[n++] = argv[i][j];
292
+ }
293
+ a = $.makeArray(a);
294
+ } else {
295
+ for (var k in argv[i]) {
296
+ if (argv[i].hasOwnProperty(k)) {
297
+ if (isNaN(k)) {
298
+ var v = argv[i][k];
299
+ if (typeof v === 'object' && a[k]) {
300
+ v = $.arrayMerge(a[k], v);
301
+ }
302
+ a[k] = v;
303
+ } else {
304
+ a[n++] = argv[i][k];
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
310
+ return a;
311
+ },
312
+ count: function (arr) {
313
+ return Array.isArray(arr) ? arr.length : typeof arr === 'object' ? Object.keys(arr).length : false;
314
+ }
315
+ });
316
+
317
+ $.fn.extend({
318
+ serializeAssoc: function () {
319
+ var o = {
320
+ aa: {},
321
+ add: function (name, value) {
322
+ var tmp = name.match(/^(.*)\[([^\]]*)]$/),
323
+ v = {};
324
+
325
+ if (tmp) {
326
+ if (tmp[2])
327
+ v[tmp[2]] = value;
328
+ else
329
+ v[$.count(v)] = value;
330
+ this.add(tmp[1], v);
331
+ } else if (typeof value === 'object') {
332
+ if (typeof this.aa[name] !== 'object') {
333
+ this.aa[name] = {};
334
+ }
335
+ this.aa[name] = $.arrayMerge(this.aa[name], value);
336
+ } else {
337
+ this.aa[name] = value;
338
+ }
339
+ }
340
+ };
341
+ var a = $(this).serializeArray();
342
+ for (var i = 0; i < a.length; i++) {
343
+ o.add(a[i].name, a[i].value);
344
+ }
345
+ return o.aa;
346
+ }
347
+ });
348
+
349
+ });
assets/js/admin-batch.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";!function(o){var i={form:{beforeSubmit:function(a){var e=a.find('.pum-field-submit input[type="submit"]'),t=a.find(".pum-upgrade-messages"),s=a.find(".pum-batch-progress"),r=a.data("ays");return!e.hasClass("button-disabled")&&(!(void 0!==r&&!confirm(r))&&(s.removeClass("pum-batch-progress--active"),s.find("progress").prop("value",null),t.html(""),e.addClass("button-disabled"),o('<span class="spinner is-active"></span>').insertAfter(e),!0))}},complete:function(a){var e=a.parents(".pum-alert");a.find(".pum-field-submit, progress").hide(),o("p.pum-upgrade-notice").hide(),e.removeClass("pum-alert__warning").addClass("pum-alert__success"),e.prepend("<h2>"+pum_batch_vars.complete+"</h2>")},action:"pum_process_batch_request",process_step:function(a,n){var d=this;o.ajax({type:"POST",url:ajaxurl,data:{batch_id:n.batch_id,action:d.action,nonce:n.nonce,form:n.form,step:parseInt(a),data:n},dataType:"json",success:function(a){if(a.data.done||a.data.error){var e=a.data.mapping?".pum-batch-import-form":".pum-batch-form",t=o(e),s=t.find(".spinner"),r=t.find(".notice-wrap");t.find(".button-disabled").removeClass("button-disabled"),a.data.error?(s.remove(),r.html('<div class="updated error"><p>'+a.data.error+"</p></div>")):a.data.done?(s.remove(),r.html('<div id="pum-batch-success" class="updated notice"><p class="pum-batch-success">'+a.data.message+"</p></div>"),a.data.url&&(window.location=a.data.url)):r.remove()}else o(".pum-batch-progress div").animate({width:a.data.percentage+"%"},50),d.process_step(a.data.step,n)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}},s=o.extend(!0,{},i,{action:"pum_process_upgrade_request",process_step:function(a,n){var d=this;o.ajax({type:"POST",url:ajaxurl,data:{upgrade_id:n.upgrade_id,action:d.action,nonce:n.nonce,form:n.form,step:parseInt(a),data:n},dataType:"json",success:function(a){var e=o(".pum-upgrade-form"),t=e.find(".spinner"),s=e.find(".button-disabled"),r=e.find(".pum-upgrade-messages");a.data.done||a.data.error?(s.removeClass("button-disabled"),a.data.error?(t.remove(),r.prepend('<div class="notice notice-error notice-alt"><p>'+a.data.error+"</p></div>")):a.data.done?(r.prepend('<div class="notice notice-success"><p><strong>'+a.data.message+"</strong></p></div>"),a.data.next?(e.data("upgrade_id",a.data.next).data("step",1).data("ays",!1),d.process_step(1,{upgrade_id:a.data.next,nonce:n.nonce,form:n.form})):(s.parent().hide(),t.remove(),i.complete(e)),a.data.url&&(window.location=a.data.url)):""!==a.data.message&&r.prepend('<div class="notice"><p class="">'+a.data.message+"</p></div>")):(""!==a.data.message&&r.prepend('<div class="notice"><p class="">'+a.data.message+"</p></div>"),o(".pum-batch-progress").addClass("pum-batch-progress--active"),o(".pum-batch-progress progress.pum-task-progress").addClass("active").val(a.data.percentage),d.process_step(a.data.step,n))}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}});window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.batch=i,window.PUM_Admin.batch_upgrades=s,o(document).on("submit",".pum-batch-form[data-batch_id]",function(a){var e=o(this),t=e.find('input[type="submit"]'),s=e.data("ays"),r={batch_id:e.data("batch_id"),nonce:e.data("nonce"),form:e.serializeAssoc(),test:e.pumSerializeObject()};if(a.preventDefault(),!t.hasClass("button-disabled")){if(void 0!==s&&!confirm(s))return;e.find(".notice-wrap").remove(),e.append(o('<div class="notice-wrap"><div class="pum-batch-progress"><div></div>')),t.addClass("button-disabled"),t.parent().append('<span class="spinner is-active"></span>'),i.process_step(1,r)}}).on("submit",".pum-batch-form.pum-upgrade-form[data-upgrade_id]",function(a){var e=o(this),t={upgrade_id:e.data("upgrade_id"),nonce:e.data("nonce"),form:e.serializeAssoc(),test:e.pumSerializeObject()};a.preventDefault(),s.form.beforeSubmit(e)&&s.process_step(e.data("step")||1,t)}).ready(function(){})}(jQuery),jQuery(document).ready(function(o){o.extend({arrayMerge:function(){for(var a={},e=0,t=o.arrayMerge.arguments,s=0;s<t.length;s++)if(Array.isArray(t[s])){for(var r=0;r<t[s].length;r++)a[e++]=t[s][r];a=o.makeArray(a)}else for(var n in t[s])if(t[s].hasOwnProperty(n))if(isNaN(n)){var d=t[s][n];"object"==typeof d&&a[n]&&(d=o.arrayMerge(a[n],d)),a[n]=d}else a[e++]=t[s][n];return a},count:function(a){return Array.isArray(a)?a.length:"object"==typeof a&&Object.keys(a).length}}),o.fn.extend({serializeAssoc:function(){for(var a={aa:{},add:function(a,e){var t=a.match(/^(.*)\[([^\]]*)]$/),s={};t?(t[2]?s[t[2]]=e:s[o.count(s)]=e,this.add(t[1],s)):this.aa[a]="object"==typeof e?("object"!=typeof this.aa[a]&&(this.aa[a]={}),o.arrayMerge(this.aa[a],e)):e}},e=o(this).serializeArray(),t=0;t<e.length;t++)a.add(e[t].name,e[t].value);return a.aa}})});
1
+ "use strict";!function(o){var i={form:{beforeSubmit:function(a){var e=a.find('.pum-field-submit input[type="submit"]'),t=a.find(".pum-upgrade-messages"),s=a.find(".pum-batch-progress"),r=a.data("ays");return!e.hasClass("button-disabled")&&(!(void 0!==r&&!confirm(r))&&(s.removeClass("pum-batch-progress--active"),s.find("progress").prop("value",null),t.html(""),e.addClass("button-disabled"),o('<span class="spinner is-active"></span>').insertAfter(e),!0))}},complete:function(a){var e=a.parents(".pum-alert");a.find(".pum-field-submit, progress").hide(),o("p.pum-upgrade-notice").hide(),e.removeClass("pum-alert__warning").addClass("pum-alert__success"),e.prepend("<h2>"+pum_batch_vars.complete+"</h2>")},action:"pum_process_batch_request",process_step:function(a,n){var d=this;o.ajax({type:"POST",url:ajaxurl,data:{batch_id:n.batch_id,action:d.action,nonce:n.nonce,form:n.form,step:parseInt(a),data:n},dataType:"json",success:function(a){if(a.data.done||a.data.error){var e=a.data.mapping?".pum-batch-import-form":".pum-batch-form",t=o(e),s=t.find(".spinner"),r=t.find(".notice-wrap");t.find(".button-disabled").removeClass("button-disabled"),a.data.error?(s.remove(),r.html('<div class="updated error"><p>'+a.data.error+"</p></div>")):a.data.done?(s.remove(),r.html('<div id="pum-batch-success" class="updated notice"><p class="pum-batch-success">'+a.data.message+"</p></div>"),a.data.url&&(window.location=a.data.url)):r.remove()}else o(".pum-batch-progress div").animate({width:a.data.percentage+"%"},50),d.process_step(a.data.step,n)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}},s=o.extend(!0,{},i,{action:"pum_process_upgrade_request",process_step:function(a,n){var d=this;o.ajax({type:"POST",url:ajaxurl,data:{upgrade_id:n.upgrade_id,action:d.action,nonce:n.nonce,form:n.form,step:parseInt(a),data:n},dataType:"json",success:function(a){var e=o(".pum-upgrade-form"),t=e.find(".spinner"),s=e.find(".button-disabled"),r=e.find(".pum-upgrade-messages");a.data.done||a.data.error?(s.removeClass("button-disabled"),a.data.error?(t.remove(),r.prepend('<div class="notice notice-error notice-alt"><p>'+a.data.error+"</p></div>")):a.data.done?(r.prepend('<div class="notice notice-success"><p><strong>'+a.data.message+"</strong></p></div>"),a.data.next?(e.data("upgrade_id",a.data.next).data("step",1).data("ays",!1),d.process_step(1,{upgrade_id:a.data.next,nonce:n.nonce,form:n.form})):(s.parent().hide(),t.remove(),i.complete(e)),a.data.url&&(window.location=a.data.url)):""!==a.data.message&&r.prepend('<div class="notice"><p class="">'+a.data.message+"</p></div>")):(""!==a.data.message&&r.prepend('<div class="notice"><p class="">'+a.data.message+"</p></div>"),o(".pum-batch-progress").addClass("pum-batch-progress--active"),o(".pum-batch-progress progress.pum-task-progress").addClass("active").val(a.data.percentage),d.process_step(a.data.step,n))}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}});window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.batch=i,window.PUM_Admin.batch_upgrades=s,o(document).on("submit",".pum-batch-form[data-batch_id]",function(a){var e=o(this),t=e.find('input[type="submit"]'),s=e.data("ays"),r={batch_id:e.data("batch_id"),nonce:e.data("nonce"),form:e.serializeAssoc(),test:e.pumSerializeObject()};if(a.preventDefault(),!t.hasClass("button-disabled")){if(void 0!==s&&!confirm(s))return;e.find(".notice-wrap").remove(),e.append(o('<div class="notice-wrap"><div class="pum-batch-progress"><div></div>')),t.addClass("button-disabled"),t.parent().append('<span class="spinner is-active"></span>'),i.process_step(1,r)}}).on("submit",".pum-batch-form.pum-upgrade-form[data-upgrade_id]",function(a){var e=o(this),t={upgrade_id:e.data("upgrade_id"),nonce:e.data("nonce"),form:e.serializeAssoc(),test:e.pumSerializeObject()};a.preventDefault(),s.form.beforeSubmit(e)&&s.process_step(e.data("step")||1,t)}).ready(function(){})}(jQuery),jQuery(document).ready(function(o){o.extend({arrayMerge:function(){for(var a={},e=0,t=o.arrayMerge.arguments,s=0;s<t.length;s++)if(Array.isArray(t[s])){for(var r=0;r<t[s].length;r++)a[e++]=t[s][r];a=o.makeArray(a)}else for(var n in t[s])if(t[s].hasOwnProperty(n))if(isNaN(n)){var d=t[s][n];"object"==typeof d&&a[n]&&(d=o.arrayMerge(a[n],d)),a[n]=d}else a[e++]=t[s][n];return a},count:function(a){return Array.isArray(a)?a.length:"object"==typeof a&&Object.keys(a).length}}),o.fn.extend({serializeAssoc:function(){for(var a={aa:{},add:function(a,e){var t=a.match(/^(.*)\[([^\]]*)]$/),s={};t?(t[2]?s[t[2]]=e:s[o.count(s)]=e,this.add(t[1],s)):"object"==typeof e?("object"!=typeof this.aa[a]&&(this.aa[a]={}),this.aa[a]=o.arrayMerge(this.aa[a],e)):this.aa[a]=e}},e=o(this).serializeArray(),t=0;t<e.length;t++)a.add(e[t].name,e[t].value);return a.aa}})});
assets/js/admin-deprecated.js CHANGED
@@ -1,28 +1,28 @@
1
- /*******************************************************************************
2
- * Copyright (c) 2017, WP Popup Maker
3
- ******************************************************************************/
4
- (function ($) {
5
- window.PUMModals = window.PUM_Admin.modals;
6
- window.PUMColorPickers = window.PUM_Admin.colorpicker;
7
- window.PUM_Templates = window.PUM_Admin.templates;
8
- window.PUMUtils = window.PUM_Admin.utils;
9
-
10
- /** Specific fixes for extensions that may break or need updating. */
11
- window.PUMTriggers = window.PUM_Admin.triggers || {};
12
- window.PUMCookies = window.PUM_Admin.cookies || {};
13
-
14
- /* Fix for pum-schedules js error. Remove once updated. */
15
- window.PUMTriggers.new_schedule = -1;
16
-
17
- /**
18
- * This needs to be preserved for backward compatibility.
19
- *
20
- * @deprecated 1.8.0
21
- * @remove 1.9.0
22
- */
23
- window.PopMakeAdmin = {
24
- update_theme: function () {
25
- return PUM_Admin.themeEditor.refresh_preview();
26
- }
27
- };
28
- }(jQuery));
1
+ /*******************************************************************************
2
+ * Copyright (c) 2017, WP Popup Maker
3
+ ******************************************************************************/
4
+ (function ($) {
5
+ window.PUMModals = window.PUM_Admin.modals;
6
+ window.PUMColorPickers = window.PUM_Admin.colorpicker;
7
+ window.PUM_Templates = window.PUM_Admin.templates;
8
+ window.PUMUtils = window.PUM_Admin.utils;
9
+
10
+ /** Specific fixes for extensions that may break or need updating. */
11
+ window.PUMTriggers = window.PUM_Admin.triggers || {};
12
+ window.PUMCookies = window.PUM_Admin.cookies || {};
13
+
14
+ /* Fix for pum-schedules js error. Remove once updated. */
15
+ window.PUMTriggers.new_schedule = -1;
16
+
17
+ /**
18
+ * This needs to be preserved for backward compatibility.
19
+ *
20
+ * @deprecated 1.8.0
21
+ * @remove 1.9.0
22
+ */
23
+ window.PopMakeAdmin = {
24
+ update_theme: function () {
25
+ return PUM_Admin.themeEditor.refresh_preview();
26
+ }
27
+ };
28
+ }(jQuery));
assets/js/admin-general.js CHANGED
@@ -1,8727 +1,8728 @@
1
- /* jshint ignore:start */
2
- /*!
3
- * Select2 4.0.2
4
- * https://select2.github.io
5
- *
6
- * Released under the MIT license
7
- * https://github.com/select2/select2/blob/master/LICENSE.md
8
- */
9
- (function (factory) {
10
- if (typeof define === 'function' && define.amd !== undefined && define.amd) {
11
- // AMD. Register as an anonymous module.
12
- define(['jquery'], factory);
13
- } else if (typeof exports === 'object') {
14
- // Node/CommonJS
15
- factory(require('jquery'));
16
- } else {
17
- // Browser globals
18
- factory(jQuery);
19
- }
20
- }(function (jQuery) {
21
- // This is needed so we can catch the AMD loader configuration and use it
22
- // The inner file should be wrapped (by `banner.start.js`) in a function that
23
- // returns the AMD loader references.
24
- var S2 =
25
- (function () {
26
- // Restore the Select2 AMD loader so it can be used
27
- // Needed mostly in the language files, where the loader is not inserted
28
- if (jQuery && jQuery.fn && jQuery.fn.pumselect2 && jQuery.fn.pumselect2.amd) {
29
- var S2 = jQuery.fn.pumselect2.amd;
30
- }
31
- var S2;(function () { if (!S2 || !S2.requirejs) {
32
- if (!S2) { S2 = {}; } else { require = S2; }
33
- /**
34
- * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
35
- * Available via the MIT or new BSD license.
36
- * see: http://github.com/jrburke/almond for details
37
- */
38
- //Going sloppy to avoid 'use strict' string cost, but strict practices should
39
- //be followed.
40
- /*jslint sloppy: true */
41
- /*global setTimeout: false */
42
-
43
- var requirejs, require, define;
44
- (function (undef) {
45
- var main, req, makeMap, handlers,
46
- defined = {},
47
- waiting = {},
48
- config = {},
49
- defining = {},
50
- hasOwn = Object.prototype.hasOwnProperty,
51
- aps = [].slice,
52
- jsSuffixRegExp = /\.js$/;
53
-
54
- function hasProp(obj, prop) {
55
- return hasOwn.call(obj, prop);
56
- }
57
-
58
- /**
59
- * Given a relative module name, like ./something, normalize it to
60
- * a real name that can be mapped to a path.
61
- * @param {String} name the relative name
62
- * @param {String} baseName a real name that the name arg is relative
63
- * to.
64
- * @returns {String} normalized name
65
- */
66
- function normalize(name, baseName) {
67
- var nameParts, nameSegment, mapValue, foundMap, lastIndex,
68
- foundI, foundStarMap, starI, i, j, part,
69
- baseParts = baseName && baseName.split("/"),
70
- map = config.map,
71
- starMap = (map && map['*']) || {};
72
-
73
- //Adjust any relative paths.
74
- if (name && name.charAt(0) === ".") {
75
- //If have a base name, try to normalize against it,
76
- //otherwise, assume it is a top-level require that will
77
- //be relative to baseUrl in the end.
78
- if (baseName) {
79
- name = name.split('/');
80
- lastIndex = name.length - 1;
81
-
82
- // Node .js allowance:
83
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
84
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
85
- }
86
-
87
- //Lop off the last part of baseParts, so that . matches the
88
- //"directory" and not name of the baseName's module. For instance,
89
- //baseName of "one/two/three", maps to "one/two/three.js", but we
90
- //want the directory, "one/two" for this normalization.
91
- name = baseParts.slice(0, baseParts.length - 1).concat(name);
92
-
93
- //start trimDots
94
- for (i = 0; i < name.length; i += 1) {
95
- part = name[i];
96
- if (part === ".") {
97
- name.splice(i, 1);
98
- i -= 1;
99
- } else if (part === "..") {
100
- if (i === 1 && (name[2] === '..' || name[0] === '..')) {
101
- //End of the line. Keep at least one non-dot
102
- //path segment at the front so it can be mapped
103
- //correctly to disk. Otherwise, there is likely
104
- //no path mapping for a path starting with '..'.
105
- //This can still fail, but catches the most reasonable
106
- //uses of ..
107
- break;
108
- } else if (i > 0) {
109
- name.splice(i - 1, 2);
110
- i -= 2;
111
- }
112
- }
113
- }
114
- //end trimDots
115
-
116
- name = name.join("/");
117
- } else if (name.indexOf('./') === 0) {
118
- // No baseName, so this is ID is resolved relative
119
- // to baseUrl, pull off the leading dot.
120
- name = name.substring(2);
121
- }
122
- }
123
-
124
- //Apply map config if available.
125
- if ((baseParts || starMap) && map) {
126
- nameParts = name.split('/');
127
-
128
- for (i = nameParts.length; i > 0; i -= 1) {
129
- nameSegment = nameParts.slice(0, i).join("/");
130
-
131
- if (baseParts) {
132
- //Find the longest baseName segment match in the config.
133
- //So, do joins on the biggest to smallest lengths of baseParts.
134
- for (j = baseParts.length; j > 0; j -= 1) {
135
- mapValue = map[baseParts.slice(0, j).join('/')];
136
-
137
- //baseName segment has config, find if it has one for
138
- //this name.
139
- if (mapValue) {
140
- mapValue = mapValue[nameSegment];
141
- if (mapValue) {
142
- //Match, update name to the new value.
143
- foundMap = mapValue;
144
- foundI = i;
145
- break;
146
- }
147
- }
148
- }
149
- }
150
-
151
- if (foundMap) {
152
- break;
153
- }
154
-
155
- //Check for a star map match, but just hold on to it,
156
- //if there is a shorter segment match later in a matching
157
- //config, then favor over this star map.
158
- if (!foundStarMap && starMap && starMap[nameSegment]) {
159
- foundStarMap = starMap[nameSegment];
160
- starI = i;
161
- }
162
- }
163
-
164
- if (!foundMap && foundStarMap) {
165
- foundMap = foundStarMap;
166
- foundI = starI;
167
- }
168
-
169
- if (foundMap) {
170
- nameParts.splice(0, foundI, foundMap);
171
- name = nameParts.join('/');
172
- }
173
- }
174
-
175
- return name;
176
- }
177
-
178
- function makeRequire(relName, forceSync) {
179
- return function () {
180
- //A version of a require function that passes a moduleName
181
- //value for items that may need to
182
- //look up paths relative to the moduleName
183
- var args = aps.call(arguments, 0);
184
-
185
- //If first arg is not require('string'), and there is only
186
- //one arg, it is the array form without a callback. Insert
187
- //a null so that the following concat is correct.
188
- if (typeof args[0] !== 'string' && args.length === 1) {
189
- args.push(null);
190
- }
191
- return req.apply(undef, args.concat([relName, forceSync]));
192
- };
193
- }
194
-
195
- function makeNormalize(relName) {
196
- return function (name) {
197
- return normalize(name, relName);
198
- };
199
- }
200
-
201
- function makeLoad(depName) {
202
- return function (value) {
203
- defined[depName] = value;
204
- };
205
- }
206
-
207
- function callDep(name) {
208
- if (hasProp(waiting, name)) {
209
- var args = waiting[name];
210
- delete waiting[name];
211
- defining[name] = true;
212
- main.apply(undef, args);
213
- }
214
-
215
- if (!hasProp(defined, name) && !hasProp(defining, name)) {
216
- throw new Error('No ' + name);
217
- }
218
- return defined[name];
219
- }
220
-
221
- //Turns a plugin!resource to [plugin, resource]
222
- //with the plugin being undefined if the name
223
- //did not have a plugin prefix.
224
- function splitPrefix(name) {
225
- var prefix,
226
- index = name ? name.indexOf('!') : -1;
227
- if (index > -1) {
228
- prefix = name.substring(0, index);
229
- name = name.substring(index + 1, name.length);
230
- }
231
- return [prefix, name];
232
- }
233
-
234
- /**
235
- * Makes a name map, normalizing the name, and using a plugin
236
- * for normalization if necessary. Grabs a ref to plugin
237
- * too, as an optimization.
238
- */
239
- makeMap = function (name, relName) {
240
- var plugin,
241
- parts = splitPrefix(name),
242
- prefix = parts[0];
243
-
244
- name = parts[1];
245
-
246
- if (prefix) {
247
- prefix = normalize(prefix, relName);
248
- plugin = callDep(prefix);
249
- }
250
-
251
- //Normalize according
252
- if (prefix) {
253
- if (plugin && plugin.normalize) {
254
- name = plugin.normalize(name, makeNormalize(relName));
255
- } else {
256
- name = normalize(name, relName);
257
- }
258
- } else {
259
- name = normalize(name, relName);
260
- parts = splitPrefix(name);
261
- prefix = parts[0];
262
- name = parts[1];
263
- if (prefix) {
264
- plugin = callDep(prefix);
265
- }
266
- }
267
-
268
- //Using ridiculous property names for space reasons
269
- return {
270
- f: prefix ? prefix + '!' + name : name, //fullName
271
- n: name,
272
- pr: prefix,
273
- p: plugin
274
- };
275
- };
276
-
277
- function makeConfig(name) {
278
- return function () {
279
- return (config && config.config && config.config[name]) || {};
280
- };
281
- }
282
-
283
- handlers = {
284
- require: function (name) {
285
- return makeRequire(name);
286
- },
287
- exports: function (name) {
288
- var e = defined[name];
289
- if (typeof e !== 'undefined') {
290
- return e;
291
- } else {
292
- return (defined[name] = {});
293
- }
294
- },
295
- module: function (name) {
296
- return {
297
- id: name,
298
- uri: '',
299
- exports: defined[name],
300
- config: makeConfig(name)
301
- };
302
- }
303
- };
304
-
305
- main = function (name, deps, callback, relName) {
306
- var cjsModule, depName, ret, map, i,
307
- args = [],
308
- callbackType = typeof callback,
309
- usingExports;
310
-
311
- //Use name if no relName
312
- relName = relName || name;
313
-
314
- //Call the callback to define the module, if necessary.
315
- if (callbackType === 'undefined' || callbackType === 'function') {
316
- //Pull out the defined dependencies and pass the ordered
317
- //values to the callback.
318
- //Default to [require, exports, module] if no deps
319
- deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
320
- for (i = 0; i < deps.length; i += 1) {
321
- map = makeMap(deps[i], relName);
322
- depName = map.f;
323
-
324
- //Fast path CommonJS standard dependencies.
325
- if (depName === "require") {
326
- args[i] = handlers.require(name);
327
- } else if (depName === "exports") {
328
- //CommonJS module spec 1.1
329
- args[i] = handlers.exports(name);
330
- usingExports = true;
331
- } else if (depName === "module") {
332
- //CommonJS module spec 1.1
333
- cjsModule = args[i] = handlers.module(name);
334
- } else if (hasProp(defined, depName) ||
335
- hasProp(waiting, depName) ||
336
- hasProp(defining, depName)) {
337
- args[i] = callDep(depName);
338
- } else if (map.p) {
339
- map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
340
- args[i] = defined[depName];
341
- } else {
342
- throw new Error(name + ' missing ' + depName);
343
- }
344
- }
345
-
346
- ret = callback ? callback.apply(defined[name], args) : undefined;
347
-
348
- if (name) {
349
- //If setting exports via "module" is in play,
350
- //favor that over return value and exports. After that,
351
- //favor a non-undefined return value over exports use.
352
- if (cjsModule && cjsModule.exports !== undef &&
353
- cjsModule.exports !== defined[name]) {
354
- defined[name] = cjsModule.exports;
355
- } else if (ret !== undef || !usingExports) {
356
- //Use the return value from the function.
357
- defined[name] = ret;
358
- }
359
- }
360
- } else if (name) {
361
- //May just be an object definition for the module. Only
362
- //worry about defining if have a module name.
363
- defined[name] = callback;
364
- }
365
- };
366
-
367
- requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
368
- if (typeof deps === "string") {
369
- if (handlers[deps]) {
370
- //callback in this case is really relName
371
- return handlers[deps](callback);
372
- }
373
- //Just return the module wanted. In this scenario, the
374
- //deps arg is the module name, and second arg (if passed)
375
- //is just the relName.
376
- //Normalize module name, if it contains . or ..
377
- return callDep(makeMap(deps, callback).f);
378
- } else if (!deps.splice) {
379
- //deps is a config object, not an array.
380
- config = deps;
381
- if (config.deps) {
382
- req(config.deps, config.callback);
383
- }
384
- if (!callback) {
385
- return;
386
- }
387
-
388
- if (callback.splice) {
389
- //callback is an array, which means it is a dependency list.
390
- //Adjust args if there are dependencies
391
- deps = callback;
392
- callback = relName;
393
- relName = null;
394
- } else {
395
- deps = undef;
396
- }
397
- }
398
-
399
- //Support require(['a'])
400
- callback = callback || function () {};
401
-
402
- //If relName is a function, it is an errback handler,
403
- //so remove it.
404
- if (typeof relName === 'function') {
405
- relName = forceSync;
406
- forceSync = alt;
407
- }
408
-
409
- //Simulate async callback;
410
- if (forceSync) {
411
- main(undef, deps, callback, relName);
412
- } else {
413
- //Using a non-zero value because of concern for what old browsers
414
- //do, and latest browsers "upgrade" to 4 if lower value is used:
415
- //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
416
- //If want a value immediately, use require('id') instead -- something
417
- //that works in almond on the global level, but not guaranteed and
418
- //unlikely to work in other AMD implementations.
419
- setTimeout(function () {
420
- main(undef, deps, callback, relName);
421
- }, 4);
422
- }
423
-
424
- return req;
425
- };
426
-
427
- /**
428
- * Just drops the config on the floor, but returns req in case
429
- * the config return value is used.
430
- */
431
- req.config = function (cfg) {
432
- return req(cfg);
433
- };
434
-
435
- /**
436
- * Expose module registry for debugging and tooling
437
- */
438
- requirejs._defined = defined;
439
-
440
- define = function (name, deps, callback) {
441
- if (typeof name !== 'string') {
442
- throw new Error('See almond README: incorrect module build, no module name');
443
- }
444
-
445
- //This module may not have dependencies
446
- if (!deps.splice) {
447
- //deps is not an array, so probably means
448
- //an object literal or factory function for
449
- //the value. Adjust args.
450
- callback = deps;
451
- deps = [];
452
- }
453
-
454
- if (!hasProp(defined, name) && !hasProp(waiting, name)) {
455
- waiting[name] = [name, deps, callback];
456
- }
457
- };
458
-
459
- define.amd = {
460
- jQuery: true
461
- };
462
- }());
463
-
464
- S2.requirejs = requirejs;S2.require = require;S2.define = define;
465
- }
466
- }());
467
- S2.define("almond", function(){});
468
-
469
- /* global jQuery:false, $:false */
470
- S2.define('jquery',[],function () {
471
- var _$ = jQuery || $;
472
-
473
- if (_$ == null && console && console.error) {
474
- console.error(
475
- 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
476
- 'found. Make sure that you are including jQuery before Select2 on your ' +
477
- 'web page.'
478
- );
479
- }
480
-
481
- return _$;
482
- });
483
-
484
- S2.define('pumselect2/utils',[
485
- 'jquery'
486
- ], function ($) {
487
- var Utils = {};
488
-
489
- Utils.Extend = function (ChildClass, SuperClass) {
490
- var __hasProp = {}.hasOwnProperty;
491
-
492
- function BaseConstructor () {
493
- this.constructor = ChildClass;
494
- }
495
-
496
- for (var key in SuperClass) {
497
- if (__hasProp.call(SuperClass, key)) {
498
- ChildClass[key] = SuperClass[key];
499
- }
500
- }
501
-
502
- BaseConstructor.prototype = SuperClass.prototype;
503
- ChildClass.prototype = new BaseConstructor();
504
- ChildClass.__super__ = SuperClass.prototype;
505
-
506
- return ChildClass;
507
- };
508
-
509
- function getMethods (theClass) {
510
- var proto = theClass.prototype;
511
-
512
- var methods = [];
513
-
514
- for (var methodName in proto) {
515
- var m = proto[methodName];
516
-
517
- if (typeof m !== 'function') {
518
- continue;
519
- }
520
-
521
- if (methodName === 'constructor') {
522
- continue;
523
- }
524
-
525
- methods.push(methodName);
526
- }
527
-
528
- return methods;
529
- }
530
-
531
- Utils.Decorate = function (SuperClass, DecoratorClass) {
532
- var decoratedMethods = getMethods(DecoratorClass);
533
- var superMethods = getMethods(SuperClass);
534
-
535
- function DecoratedClass () {
536
- var unshift = Array.prototype.unshift;
537
-
538
- var argCount = DecoratorClass.prototype.constructor.length;
539
-
540
- var calledConstructor = SuperClass.prototype.constructor;
541
-
542
- if (argCount > 0) {
543
- unshift.call(arguments, SuperClass.prototype.constructor);
544
-
545
- calledConstructor = DecoratorClass.prototype.constructor;
546
- }
547
-
548
- calledConstructor.apply(this, arguments);
549
- }
550
-
551
- DecoratorClass.displayName = SuperClass.displayName;
552
-
553
- function ctr () {
554
- this.constructor = DecoratedClass;
555
- }
556
-
557
- DecoratedClass.prototype = new ctr();
558
-
559
- for (var m = 0; m < superMethods.length; m++) {
560
- var superMethod = superMethods[m];
561
-
562
- DecoratedClass.prototype[superMethod] =
563
- SuperClass.prototype[superMethod];
564
- }
565
-
566
- var calledMethod = function (methodName) {
567
- // Stub out the original method if it's not decorating an actual method
568
- var originalMethod = function () {};
569
-
570
- if (methodName in DecoratedClass.prototype) {
571
- originalMethod = DecoratedClass.prototype[methodName];
572
- }
573
-
574
- var decoratedMethod = DecoratorClass.prototype[methodName];
575
-
576
- return function () {
577
- var unshift = Array.prototype.unshift;
578
-
579
- unshift.call(arguments, originalMethod);
580
-
581
- return decoratedMethod.apply(this, arguments);
582
- };
583
- };
584
-
585
- for (var d = 0; d < decoratedMethods.length; d++) {
586
- var decoratedMethod = decoratedMethods[d];
587
-
588
- DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
589
- }
590
-
591
- return DecoratedClass;
592
- };
593
-
594
- var Observable = function () {
595
- this.listeners = {};
596
- };
597
-
598
- Observable.prototype.on = function (event, callback) {
599
- this.listeners = this.listeners || {};
600
-
601
- if (event in this.listeners) {
602
- this.listeners[event].push(callback);
603
- } else {
604
- this.listeners[event] = [callback];
605
- }
606
- };
607
-
608
- Observable.prototype.trigger = function (event) {
609
- var slice = Array.prototype.slice;
610
-
611
- this.listeners = this.listeners || {};
612
-
613
- if (event in this.listeners) {
614
- this.invoke(this.listeners[event], slice.call(arguments, 1));
615
- }
616
-
617
- if ('*' in this.listeners) {
618
- this.invoke(this.listeners['*'], arguments);
619
- }
620
- };
621
-
622
- Observable.prototype.invoke = function (listeners, params) {
623
- for (var i = 0, len = listeners.length; i < len; i++) {
624
- listeners[i].apply(this, params);
625
- }
626
- };
627
-
628
- Utils.Observable = Observable;
629
-
630
- Utils.generateChars = function (length) {
631
- var chars = '';
632
-
633
- for (var i = 0; i < length; i++) {
634
- var randomChar = Math.floor(Math.random() * 36);
635
- chars += randomChar.toString(36);
636
- }
637
-
638
- return chars;
639
- };
640
-
641
- Utils.bind = function (func, context) {
642
- return function () {
643
- func.apply(context, arguments);
644
- };
645
- };
646
-
647
- Utils._convertData = function (data) {
648
- for (var originalKey in data) {
649
- var keys = originalKey.split('-');
650
-
651
- var dataLevel = data;
652
-
653
- if (keys.length === 1) {
654
- continue;
655
- }
656
-
657
- for (var k = 0; k < keys.length; k++) {
658
- var key = keys[k];
659
-
660
- // Lowercase the first letter
661
- // By default, dash-separated becomes camelCase
662
- key = key.substring(0, 1).toLowerCase() + key.substring(1);
663
-
664
- if (!(key in dataLevel)) {
665
- dataLevel[key] = {};
666
- }
667
-
668
- if (k == keys.length - 1) {
669
- dataLevel[key] = data[originalKey];
670
- }
671
-
672
- dataLevel = dataLevel[key];
673
- }
674
-
675
- delete data[originalKey];
676
- }
677
-
678
- return data;
679
- };
680
-
681
- Utils.hasScroll = function (index, el) {
682
- // Adapted from the function created by @ShadowScripter
683
- // and adapted by @BillBarry on the Stack Exchange Code Review website.
684
- // The original code can be found at
685
- // http://codereview.stackexchange.com/q/13338
686
- // and was designed to be used with the Sizzle selector engine.
687
-
688
- var $el = $(el);
689
- var overflowX = el.style.overflowX;
690
- var overflowY = el.style.overflowY;
691
-
692
- //Check both x and y declarations
693
- if (overflowX === overflowY &&
694
- (overflowY === 'hidden' || overflowY === 'visible')) {
695
- return false;
696
- }
697
-
698
- if (overflowX === 'scroll' || overflowY === 'scroll') {
699
- return true;
700
- }
701
-
702
- return ($el.innerHeight() < el.scrollHeight ||
703
- $el.innerWidth() < el.scrollWidth);
704
- };
705
-
706
- Utils.escapeMarkup = function (markup) {
707
- var replaceMap = {
708
- '\\': '&#92;',
709
- '&': '&amp;',
710
- '<': '&lt;',
711
- '>': '&gt;',
712
- '"': '&quot;',
713
- '\'': '&#39;',
714
- '/': '&#47;'
715
- };
716
-
717
- // Do not try to escape the markup if it's not a string
718
- if (typeof markup !== 'string') {
719
- return markup;
720
- }
721
-
722
- return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
723
- return replaceMap[match];
724
- });
725
- };
726
-
727
- // Append an array of jQuery nodes to a given element.
728
- Utils.appendMany = function ($element, $nodes) {
729
- // jQuery 1.7.x does not support $.fn.append() with an array
730
- // Fall back to a jQuery object collection using $.fn.add()
731
- if ($.fn.jquery.substr(0, 3) === '1.7') {
732
- var $jqNodes = $();
733
-
734
- $.map($nodes, function (node) {
735
- $jqNodes = $jqNodes.add(node);
736
- });
737
-
738
- $nodes = $jqNodes;
739
- }
740
-
741
- $element.append($nodes);
742
- };
743
-
744
- return Utils;
745
- });
746
-
747
- S2.define('pumselect2/results',[
748
- 'jquery',
749
- './utils'
750
- ], function ($, Utils) {
751
- function Results ($element, options, dataAdapter) {
752
- this.$element = $element;
753
- this.data = dataAdapter;
754
- this.options = options;
755
-
756
- Results.__super__.constructor.call(this);
757
- }
758
-
759
- Utils.Extend(Results, Utils.Observable);
760
-
761
- Results.prototype.render = function () {
762
- var $results = $(
763
- '<ul class="pumselect2-results__options" role="tree"></ul>'
764
- );
765
-
766
- if (this.options.get('multiple')) {
767
- $results.attr('aria-multiselectable', 'true');
768
- }
769
-
770
- this.$results = $results;
771
-
772
- return $results;
773
- };
774
-
775
- Results.prototype.clear = function () {
776
- this.$results.empty();
777
- };
778
-
779
- Results.prototype.displayMessage = function (params) {
780
- var escapeMarkup = this.options.get('escapeMarkup');
781
-
782
- this.clear();
783
- this.hideLoading();
784
-
785
- var $message = $(
786
- '<li role="treeitem" aria-live="assertive"' +
787
- ' class="pumselect2-results__option"></li>'
788
- );
789
-
790
- var message = this.options.get('translations').get(params.message);
791
-
792
- $message.append(
793
- escapeMarkup(
794
- message(params.args)
795
- )
796
- );
797
-
798
- $message[0].className += ' pumselect2-results__message';
799
-
800
- this.$results.append($message);
801
- };
802
-
803
- Results.prototype.hideMessages = function () {
804
- this.$results.find('.pumselect2-results__message').remove();
805
- };
806
-
807
- Results.prototype.append = function (data) {
808
- this.hideLoading();
809
-
810
- var $options = [];
811
-
812
- if (data.results == null || data.results.length === 0) {
813
- if (this.$results.children().length === 0) {
814
- this.trigger('results:message', {
815
- message: 'noResults'
816
- });
817
- }
818
-
819
- return;
820
- }
821
-
822
- data.results = this.sort(data.results);
823
-
824
- for (var d = 0; d < data.results.length; d++) {
825
- var item = data.results[d];
826
-
827
- var $option = this.option(item);
828
-
829
- $options.push($option);
830
- }
831
-
832
- this.$results.append($options);
833
- };
834
-
835
- Results.prototype.position = function ($results, $dropdown) {
836
- var $resultsContainer = $dropdown.find('.pumselect2-results');
837
- $resultsContainer.append($results);
838
- };
839
-
840
- Results.prototype.sort = function (data) {
841
- var sorter = this.options.get('sorter');
842
-
843
- return sorter(data);
844
- };
845
-
846
- Results.prototype.setClasses = function () {
847
- var self = this;
848
-
849
- this.data.current(function (selected) {
850
- var selectedIds = $.map(selected, function (s) {
851
- return s.id.toString();
852
- });
853
-
854
- var $options = self.$results
855
- .find('.pumselect2-results__option[aria-selected]');
856
-
857
- $options.each(function () {
858
- var $option = $(this);
859
-
860
- var item = $.data(this, 'data');
861
-
862
- // id needs to be converted to a string when comparing
863
- var id = '' + item.id;
864
-
865
- if ((item.element != null && item.element.selected) ||
866
- (item.element == null && $.inArray(id, selectedIds) > -1)) {
867
- $option.attr('aria-selected', 'true');
868
- } else {
869
- $option.attr('aria-selected', 'false');
870
- }
871
- });
872
-
873
- var $selected = $options.filter('[aria-selected=true]');
874
-
875
- // Check if there are any selected options
876
- if ($selected.length > 0) {
877
- // If there are selected options, highlight the first
878
- $selected.first().trigger('mouseenter');
879
- } else {
880
- // If there are no selected options, highlight the first option
881
- // in the dropdown
882
- $options.first().trigger('mouseenter');
883
- }
884
- });
885
- };
886
-
887
- Results.prototype.showLoading = function (params) {
888
- this.hideLoading();
889
-
890
- var loadingMore = this.options.get('translations').get('searching');
891
-
892
- var loading = {
893
- disabled: true,
894
- loading: true,
895
- text: loadingMore(params)
896
- };
897
- var $loading = this.option(loading);
898
- $loading.className += ' loading-results';
899
-
900
- this.$results.prepend($loading);
901
- };
902
-
903
- Results.prototype.hideLoading = function () {
904
- this.$results.find('.loading-results').remove();
905
- };
906
-
907
- Results.prototype.option = function (data) {
908
- var option = document.createElement('li');
909
- option.className = 'pumselect2-results__option';
910
-
911
- var attrs = {
912
- 'role': 'treeitem',
913
- 'aria-selected': 'false'
914
- };
915
-
916
- if (data.disabled) {
917
- delete attrs['aria-selected'];
918
- attrs['aria-disabled'] = 'true';
919
- }
920
-
921
- if (data.id == null) {
922
- delete attrs['aria-selected'];
923
- }
924
-
925
- if (data._resultId != null) {
926
- option.id = data._resultId;
927
- }
928
-
929
- if (data.title) {
930
- option.title = data.title;
931
- }
932
-
933
- if (data.children) {
934
- attrs.role = 'group';
935
- attrs['aria-label'] = data.text;
936
- delete attrs['aria-selected'];
937
- }
938
-
939
- for (var attr in attrs) {
940
- var val = attrs[attr];
941
-
942
- option.setAttribute(attr, val);
943
- }
944
-
945
- if (data.children) {
946
- var $option = $(option);
947
-
948
- var label = document.createElement('strong');
949
- label.className = 'pumselect2-results__group';
950
-
951
- var $label = $(label);
952
- this.template(data, label);
953
-
954
- var $children = [];
955
-
956
- for (var c = 0; c < data.children.length; c++) {
957
- var child = data.children[c];
958
-
959
- var $child = this.option(child);
960
-
961
- $children.push($child);
962
- }
963
-
964
- var $childrenContainer = $('<ul></ul>', {
965
- 'class': 'pumselect2-results__options pumselect2-results__options--nested'
966
- });
967
-
968
- $childrenContainer.append($children);
969
-
970
- $option.append(label);
971
- $option.append($childrenContainer);
972
- } else {
973
- this.template(data, option);
974
- }
975
-
976
- $.data(option, 'data', data);
977
-
978
- return option;
979
- };
980
-
981
- Results.prototype.bind = function (container, $container) {
982
- var self = this;
983
-
984
- var id = container.id + '-results';
985
-
986
- this.$results.attr('id', id);
987
-
988
- container.on('results:all', function (params) {
989
- self.clear();
990
- self.append(params.data);
991
-
992
- if (container.isOpen()) {
993
- self.setClasses();
994
- }
995
- });
996
-
997
- container.on('results:append', function (params) {
998
- self.append(params.data);
999
-
1000
- if (container.isOpen()) {
1001
- self.setClasses();
1002
- }
1003
- });
1004
-
1005
- container.on('query', function (params) {
1006
- self.hideMessages();
1007
- self.showLoading(params);
1008
- });
1009
-
1010
- container.on('select', function () {
1011
- if (!container.isOpen()) {
1012
- return;
1013
- }
1014
-
1015
- self.setClasses();
1016
- });
1017
-
1018
- container.on('unselect', function () {
1019
- if (!container.isOpen()) {
1020
- return;
1021
- }
1022
-
1023
- self.setClasses();
1024
- });
1025
-
1026
- container.on('open', function () {
1027
- // When the dropdown is open, aria-expended="true"
1028
- self.$results.attr('aria-expanded', 'true');
1029
- self.$results.attr('aria-hidden', 'false');
1030
-
1031
- self.setClasses();
1032
- self.ensureHighlightVisible();
1033
- });
1034
-
1035
- container.on('close', function () {
1036
- // When the dropdown is closed, aria-expended="false"
1037
- self.$results.attr('aria-expanded', 'false');
1038
- self.$results.attr('aria-hidden', 'true');
1039
- self.$results.removeAttr('aria-activedescendant');
1040
- });
1041
-
1042
- container.on('results:toggle', function () {
1043
- var $highlighted = self.getHighlightedResults();
1044
-
1045
- if ($highlighted.length === 0) {
1046
- return;
1047
- }
1048
-
1049
- $highlighted.trigger('mouseup');
1050
- });
1051
-
1052
- container.on('results:select', function () {
1053
- var $highlighted = self.getHighlightedResults();
1054
-
1055
- if ($highlighted.length === 0) {
1056
- return;
1057
- }
1058
-
1059
- var data = $highlighted.data('data');
1060
-
1061
- if ($highlighted.attr('aria-selected') == 'true') {
1062
- self.trigger('close', {});
1063
- } else {
1064
- self.trigger('select', {
1065
- data: data
1066
- });
1067
- }
1068
- });
1069
-
1070
- container.on('results:previous', function () {
1071
- var $highlighted = self.getHighlightedResults();
1072
-
1073
- var $options = self.$results.find('[aria-selected]');
1074
-
1075
- var currentIndex = $options.index($highlighted);
1076
-
1077
- // If we are already at te top, don't move further
1078
- if (currentIndex === 0) {
1079
- return;
1080
- }
1081
-
1082
- var nextIndex = currentIndex - 1;
1083
-
1084
- // If none are highlighted, highlight the first
1085
- if ($highlighted.length === 0) {
1086
- nextIndex = 0;
1087
- }
1088
-
1089
- var $next = $options.eq(nextIndex);
1090
-
1091
- $next.trigger('mouseenter');
1092
-
1093
- var currentOffset = self.$results.offset().top;
1094
- var nextTop = $next.offset().top;
1095
- var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
1096
-
1097
- if (nextIndex === 0) {
1098
- self.$results.scrollTop(0);
1099
- } else if (nextTop - currentOffset < 0) {
1100
- self.$results.scrollTop(nextOffset);
1101
- }
1102
- });
1103
-
1104
- container.on('results:next', function () {
1105
- var $highlighted = self.getHighlightedResults();
1106
-
1107
- var $options = self.$results.find('[aria-selected]');
1108
-
1109
- var currentIndex = $options.index($highlighted);
1110
-
1111
- var nextIndex = currentIndex + 1;
1112
-
1113
- // If we are at the last option, stay there
1114
- if (nextIndex >= $options.length) {
1115
- return;
1116
- }
1117
-
1118
- var $next = $options.eq(nextIndex);
1119
-
1120
- $next.trigger('mouseenter');
1121
-
1122
- var currentOffset = self.$results.offset().top +
1123
- self.$results.outerHeight(false);
1124
- var nextBottom = $next.offset().top + $next.outerHeight(false);
1125
- var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
1126
-
1127
- if (nextIndex === 0) {
1128
- self.$results.scrollTop(0);
1129
- } else if (nextBottom > currentOffset) {
1130
- self.$results.scrollTop(nextOffset);
1131
- }
1132
- });
1133
-
1134
- container.on('results:focus', function (params) {
1135
- params.element.addClass('pumselect2-results__option--highlighted');
1136
- });
1137
-
1138
- container.on('results:message', function (params) {
1139
- self.displayMessage(params);
1140
- });
1141
-
1142
- if ($.fn.mousewheel) {
1143
- this.$results.on('mousewheel', function (e) {
1144
- var top = self.$results.scrollTop();
1145
-
1146
- var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
1147
-
1148
- var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
1149
- var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
1150
-
1151
- if (isAtTop) {
1152
- self.$results.scrollTop(0);
1153
-
1154
- e.preventDefault();
1155
- e.stopPropagation();
1156
- } else if (isAtBottom) {
1157
- self.$results.scrollTop(
1158
- self.$results.get(0).scrollHeight - self.$results.height()
1159
- );
1160
-
1161
- e.preventDefault();
1162
- e.stopPropagation();
1163
- }
1164
- });
1165
- }
1166
-
1167
- this.$results.on('mouseup', '.pumselect2-results__option[aria-selected]',
1168
- function (evt) {
1169
- var $this = $(this);
1170
-
1171
- var data = $this.data('data');
1172
-
1173
- if ($this.attr('aria-selected') === 'true') {
1174
- if (self.options.get('multiple')) {
1175
- self.trigger('unselect', {
1176
- originalEvent: evt,
1177
- data: data
1178
- });
1179
- } else {
1180
- self.trigger('close', {});
1181
- }
1182
-
1183
- return;
1184
- }
1185
-
1186
- self.trigger('select', {
1187
- originalEvent: evt,
1188
- data: data
1189
- });
1190
- });
1191
-
1192
- this.$results.on('mouseenter', '.pumselect2-results__option[aria-selected]',
1193
- function (evt) {
1194
- var data = $(this).data('data');
1195
-
1196
- self.getHighlightedResults()
1197
- .removeClass('pumselect2-results__option--highlighted');
1198
-
1199
- self.trigger('results:focus', {
1200
- data: data,
1201
- element: $(this)
1202
- });
1203
- });
1204
- };
1205
-
1206
- Results.prototype.getHighlightedResults = function () {
1207
- var $highlighted = this.$results
1208
- .find('.pumselect2-results__option--highlighted');
1209
-
1210
- return $highlighted;
1211
- };
1212
-
1213
- Results.prototype.destroy = function () {
1214
- this.$results.remove();
1215
- };
1216
-
1217
- Results.prototype.ensureHighlightVisible = function () {
1218
- var $highlighted = this.getHighlightedResults();
1219
-
1220
- if ($highlighted.length === 0) {
1221
- return;
1222
- }
1223
-
1224
- var $options = this.$results.find('[aria-selected]');
1225
-
1226
- var currentIndex = $options.index($highlighted);
1227
-
1228
- var currentOffset = this.$results.offset().top;
1229
- var nextTop = $highlighted.offset().top;
1230
- var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
1231
-
1232
- var offsetDelta = nextTop - currentOffset;
1233
- nextOffset -= $highlighted.outerHeight(false) * 2;
1234
-
1235
- if (currentIndex <= 2) {
1236
- this.$results.scrollTop(0);
1237
- } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
1238
- this.$results.scrollTop(nextOffset);
1239
- }
1240
- };
1241
-
1242
- Results.prototype.template = function (result, container) {
1243
- var template = this.options.get('templateResult');
1244
- var escapeMarkup = this.options.get('escapeMarkup');
1245
-
1246
- var content = template(result, container);
1247
-
1248
- if (content == null) {
1249
- container.style.display = 'none';
1250
- } else if (typeof content === 'string') {
1251
- container.innerHTML = escapeMarkup(content);
1252
- } else {
1253
- $(container).append(content);
1254
- }
1255
- };
1256
-
1257
- return Results;
1258
- });
1259
-
1260
- S2.define('pumselect2/keys',[
1261
-
1262
- ], function () {
1263
- var KEYS = {
1264
- BACKSPACE: 8,
1265
- TAB: 9,
1266
- ENTER: 13,
1267
- SHIFT: 16,
1268
- CTRL: 17,
1269
- ALT: 18,
1270
- ESC: 27,
1271
- SPACE: 32,
1272
- PAGE_UP: 33,
1273
- PAGE_DOWN: 34,
1274
- END: 35,
1275
- HOME: 36,
1276
- LEFT: 37,
1277
- UP: 38,
1278
- RIGHT: 39,
1279
- DOWN: 40,
1280
- DELETE: 46
1281
- };
1282
-
1283
- return KEYS;
1284
- });
1285
-
1286
- S2.define('pumselect2/selection/base',[
1287
- 'jquery',
1288
- '../utils',
1289
- '../keys'
1290
- ], function ($, Utils, KEYS) {
1291
- function BaseSelection ($element, options) {
1292
- this.$element = $element;
1293
- this.options = options;
1294
-
1295
- BaseSelection.__super__.constructor.call(this);
1296
- }
1297
-
1298
- Utils.Extend(BaseSelection, Utils.Observable);
1299
-
1300
- BaseSelection.prototype.render = function () {
1301
- var $selection = $(
1302
- '<span class="pumselect2-selection" role="combobox" ' +
1303
- ' aria-haspopup="true" aria-expanded="false">' +
1304
- '</span>'
1305
- );
1306
-
1307
- this._tabindex = 0;
1308
-
1309
- if (this.$element.data('old-tabindex') != null) {
1310
- this._tabindex = this.$element.data('old-tabindex');
1311
- } else if (this.$element.attr('tabindex') != null) {
1312
- this._tabindex = this.$element.attr('tabindex');
1313
- }
1314
-
1315
- $selection.attr('title', this.$element.attr('title'));
1316
- $selection.attr('tabindex', this._tabindex);
1317
-
1318
- this.$selection = $selection;
1319
-
1320
- return $selection;
1321
- };
1322
-
1323
- BaseSelection.prototype.bind = function (container, $container) {
1324
- var self = this;
1325
-
1326
- var id = container.id + '-container';
1327
- var resultsId = container.id + '-results';
1328
-
1329
- this.container = container;
1330
-
1331
- this.$selection.on('focus', function (evt) {
1332
- self.trigger('focus', evt);
1333
- });
1334
-
1335
- this.$selection.on('blur', function (evt) {
1336
- self._handleBlur(evt);
1337
- });
1338
-
1339
- this.$selection.on('keydown', function (evt) {
1340
- self.trigger('keypress', evt);
1341
-
1342
- if (evt.which === KEYS.SPACE) {
1343
- evt.preventDefault();
1344
- }
1345
- });
1346
-
1347
- container.on('results:focus', function (params) {
1348
- self.$selection.attr('aria-activedescendant', params.data._resultId);
1349
- });
1350
-
1351
- container.on('selection:update', function (params) {
1352
- self.update(params.data);
1353
- });
1354
-
1355
- container.on('open', function () {
1356
- // When the dropdown is open, aria-expanded="true"
1357
- self.$selection.attr('aria-expanded', 'true');
1358
- self.$selection.attr('aria-owns', resultsId);
1359
-
1360
- self._attachCloseHandler(container);
1361
- });
1362
-
1363
- container.on('close', function () {
1364
- // When the dropdown is closed, aria-expanded="false"
1365
- self.$selection.attr('aria-expanded', 'false');
1366
- self.$selection.removeAttr('aria-activedescendant');
1367
- self.$selection.removeAttr('aria-owns');
1368
-
1369
- self.$selection.focus();
1370
-
1371
- self._detachCloseHandler(container);
1372
- });
1373
-
1374
- container.on('enable', function () {
1375
- self.$selection.attr('tabindex', self._tabindex);
1376
- });
1377
-
1378
- container.on('disable', function () {
1379
- self.$selection.attr('tabindex', '-1');
1380
- });
1381
- };
1382
-
1383
- BaseSelection.prototype._handleBlur = function (evt) {
1384
- var self = this;
1385
-
1386
- // This needs to be delayed as the active element is the body when the tab
1387
- // key is pressed, possibly along with others.
1388
- window.setTimeout(function () {
1389
- // Don't trigger `blur` if the focus is still in the selection
1390
- if (
1391
- (document.activeElement == self.$selection[0]) ||
1392
- ($.contains(self.$selection[0], document.activeElement))
1393
- ) {
1394
- return;
1395
- }
1396
-
1397
- self.trigger('blur', evt);
1398
- }, 1);
1399
- };
1400
-
1401
- BaseSelection.prototype._attachCloseHandler = function (container) {
1402
- var self = this;
1403
-
1404
- $(document.body).on('mousedown.pumselect2.' + container.id, function (e) {
1405
- var $target = $(e.target);
1406
-
1407
- var $select = $target.closest('.pumselect2');
1408
-
1409
- var $all = $('.pumselect2.pumselect2-container--open');
1410
-
1411
- $all.each(function () {
1412
- var $this = $(this);
1413
-
1414
- if (this == $select[0]) {
1415
- return;
1416
- }
1417
-
1418
- var $element = $this.data('element');
1419
-
1420
- $element.pumselect2('close');
1421
- });
1422
- });
1423
- };
1424
-
1425
- BaseSelection.prototype._detachCloseHandler = function (container) {
1426
- $(document.body).off('mousedown.pumselect2.' + container.id);
1427
- };
1428
-
1429
- BaseSelection.prototype.position = function ($selection, $container) {
1430
- var $selectionContainer = $container.find('.selection');
1431
- $selectionContainer.append($selection);
1432
- };
1433
-
1434
- BaseSelection.prototype.destroy = function () {
1435
- this._detachCloseHandler(this.container);
1436
- };
1437
-
1438
- BaseSelection.prototype.update = function (data) {
1439
- throw new Error('The `update` method must be defined in child classes.');
1440
- };
1441
-
1442
- return BaseSelection;
1443
- });
1444
-
1445
- S2.define('pumselect2/selection/single',[
1446
- 'jquery',
1447
- './base',
1448
- '../utils',
1449
- '../keys'
1450
- ], function ($, BaseSelection, Utils, KEYS) {
1451
- function SingleSelection () {
1452
- SingleSelection.__super__.constructor.apply(this, arguments);
1453
- }
1454
-
1455
- Utils.Extend(SingleSelection, BaseSelection);
1456
-
1457
- SingleSelection.prototype.render = function () {
1458
- var $selection = SingleSelection.__super__.render.call(this);
1459
-
1460
- $selection.addClass('pumselect2-selection--single');
1461
-
1462
- $selection.html(
1463
- '<span class="pumselect2-selection__rendered"></span>' +
1464
- '<span class="pumselect2-selection__arrow" role="presentation">' +
1465
- '<b role="presentation"></b>' +
1466
- '</span>'
1467
- );
1468
-
1469
- return $selection;
1470
- };
1471
-
1472
- SingleSelection.prototype.bind = function (container, $container) {
1473
- var self = this;
1474
-
1475
- SingleSelection.__super__.bind.apply(this, arguments);
1476
-
1477
- var id = container.id + '-container';
1478
-
1479
- this.$selection.find('.pumselect2-selection__rendered').attr('id', id);
1480
- this.$selection.attr('aria-labelledby', id);
1481
-
1482
- this.$selection.on('mousedown', function (evt) {
1483
- // Only respond to left clicks
1484
- if (evt.which !== 1) {
1485
- return;
1486
- }
1487
-
1488
- self.trigger('toggle', {
1489
- originalEvent: evt
1490
- });
1491
- });
1492
-
1493
- this.$selection.on('focus', function (evt) {
1494
- // User focuses on the container
1495
- });
1496
-
1497
- this.$selection.on('blur', function (evt) {
1498
- // User exits the container
1499
- });
1500
-
1501
- container.on('selection:update', function (params) {
1502
- self.update(params.data);
1503
- });
1504
- };
1505
-
1506
- SingleSelection.prototype.clear = function () {
1507
- this.$selection.find('.pumselect2-selection__rendered').empty();
1508
- };
1509
-
1510
- SingleSelection.prototype.display = function (data, container) {
1511
- var template = this.options.get('templateSelection');
1512
- var escapeMarkup = this.options.get('escapeMarkup');
1513
-
1514
- return escapeMarkup(template(data, container));
1515
- };
1516
-
1517
- SingleSelection.prototype.selectionContainer = function () {
1518
- return $('<span></span>');
1519
- };
1520
-
1521
- SingleSelection.prototype.update = function (data) {
1522
- if (data.length === 0) {
1523
- this.clear();
1524
- return;
1525
- }
1526
-
1527
- var selection = data[0];
1528
-
1529
- var $rendered = this.$selection.find('.pumselect2-selection__rendered');
1530
- var formatted = this.display(selection, $rendered);
1531
-
1532
- $rendered.empty().append(formatted);
1533
- $rendered.prop('title', selection.title || selection.text);
1534
- };
1535
-
1536
- return SingleSelection;
1537
- });
1538
-
1539
- S2.define('pumselect2/selection/multiple',[
1540
- 'jquery',
1541
- './base',
1542
- '../utils'
1543
- ], function ($, BaseSelection, Utils) {
1544
- function MultipleSelection ($element, options) {
1545
- MultipleSelection.__super__.constructor.apply(this, arguments);
1546
- }
1547
-
1548
- Utils.Extend(MultipleSelection, BaseSelection);
1549
-
1550
- MultipleSelection.prototype.render = function () {
1551
- var $selection = MultipleSelection.__super__.render.call(this);
1552
-
1553
- $selection.addClass('pumselect2-selection--multiple');
1554
-
1555
- $selection.html(
1556
- '<ul class="pumselect2-selection__rendered"></ul>'
1557
- );
1558
-
1559
- return $selection;
1560
- };
1561
-
1562
- MultipleSelection.prototype.bind = function (container, $container) {
1563
- var self = this;
1564
-
1565
- MultipleSelection.__super__.bind.apply(this, arguments);
1566
-
1567
- this.$selection.on('click', function (evt) {
1568
- self.trigger('toggle', {
1569
- originalEvent: evt
1570
- });
1571
- });
1572
-
1573
- this.$selection.on(
1574
- 'click',
1575
- '.pumselect2-selection__choice__remove',
1576
- function (evt) {
1577
- // Ignore the event if it is disabled
1578
- if (self.options.get('disabled')) {
1579
- return;
1580
- }
1581
-
1582
- var $remove = $(this);
1583
- var $selection = $remove.parent();
1584
-
1585
- var data = $selection.data('data');
1586
-
1587
- self.trigger('unselect', {
1588
- originalEvent: evt,
1589
- data: data
1590
- });
1591
- }
1592
- );
1593
- };
1594
-
1595
- MultipleSelection.prototype.clear = function () {
1596
- this.$selection.find('.pumselect2-selection__rendered').empty();
1597
- };
1598
-
1599
- MultipleSelection.prototype.display = function (data, container) {
1600
- var template = this.options.get('templateSelection');
1601
- var escapeMarkup = this.options.get('escapeMarkup');
1602
-
1603
- return escapeMarkup(template(data, container));
1604
- };
1605
-
1606
- MultipleSelection.prototype.selectionContainer = function () {
1607
- var $container = $(
1608
- '<li class="pumselect2-selection__choice">' +
1609
- '<span class="pumselect2-selection__choice__remove" role="presentation">' +
1610
- '&times;' +
1611
- '</span>' +
1612
- '</li>'
1613
- );
1614
-
1615
- return $container;
1616
- };
1617
-
1618
- MultipleSelection.prototype.update = function (data) {
1619
- this.clear();
1620
-
1621
- if (data.length === 0) {
1622
- return;
1623
- }
1624
-
1625
- var $selections = [];
1626
-
1627
- for (var d = 0; d < data.length; d++) {
1628
- var selection = data[d];
1629
-
1630
- var $selection = this.selectionContainer();
1631
- var formatted = this.display(selection, $selection);
1632
-
1633
- $selection.append(formatted);
1634
- $selection.prop('title', selection.title || selection.text);
1635
-
1636
- $selection.data('data', selection);
1637
-
1638
- $selections.push($selection);
1639
- }
1640
-
1641
- var $rendered = this.$selection.find('.pumselect2-selection__rendered');
1642
-
1643
- Utils.appendMany($rendered, $selections);
1644
- };
1645
-
1646
- return MultipleSelection;
1647
- });
1648
-
1649
- S2.define('pumselect2/selection/placeholder',[
1650
- '../utils'
1651
- ], function (Utils) {
1652
- function Placeholder (decorated, $element, options) {
1653
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
1654
-
1655
- decorated.call(this, $element, options);
1656
- }
1657
-
1658
- Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
1659
- if (typeof placeholder === 'string') {
1660
- placeholder = {
1661
- id: '',
1662
- text: placeholder
1663
- };
1664
- }
1665
-
1666
- return placeholder;
1667
- };
1668
-
1669
- Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
1670
- var $placeholder = this.selectionContainer();
1671
-
1672
- $placeholder.html(this.display(placeholder));
1673
- $placeholder.addClass('pumselect2-selection__placeholder')
1674
- .removeClass('pumselect2-selection__choice');
1675
-
1676
- return $placeholder;
1677
- };
1678
-
1679
- Placeholder.prototype.update = function (decorated, data) {
1680
- var singlePlaceholder = (
1681
- data.length == 1 && data[0].id != this.placeholder.id
1682
- );
1683
- var multipleSelections = data.length > 1;
1684
-
1685
- if (multipleSelections || singlePlaceholder) {
1686
- return decorated.call(this, data);
1687
- }
1688
-
1689
- this.clear();
1690
-
1691
- var $placeholder = this.createPlaceholder(this.placeholder);
1692
-
1693
- this.$selection.find('.pumselect2-selection__rendered').append($placeholder);
1694
- };
1695
-
1696
- return Placeholder;
1697
- });
1698
-
1699
- S2.define('pumselect2/selection/allowClear',[
1700
- 'jquery',
1701
- '../keys'
1702
- ], function ($, KEYS) {
1703
- function AllowClear () { }
1704
-
1705
- AllowClear.prototype.bind = function (decorated, container, $container) {
1706
- var self = this;
1707
-
1708
- decorated.call(this, container, $container);
1709
-
1710
- if (this.placeholder == null) {
1711
- if (this.options.get('debug') && window.console && console.error) {
1712
- console.error(
1713
- 'Select2: The `allowClear` option should be used in combination ' +
1714
- 'with the `placeholder` option.'
1715
- );
1716
- }
1717
- }
1718
-
1719
- this.$selection.on('mousedown', '.pumselect2-selection__clear',
1720
- function (evt) {
1721
- self._handleClear(evt);
1722
- });
1723
-
1724
- container.on('keypress', function (evt) {
1725
- self._handleKeyboardClear(evt, container);
1726
- });
1727
- };
1728
-
1729
- AllowClear.prototype._handleClear = function (_, evt) {
1730
- // Ignore the event if it is disabled
1731
- if (this.options.get('disabled')) {
1732
- return;
1733
- }
1734
-
1735
- var $clear = this.$selection.find('.pumselect2-selection__clear');
1736
-
1737
- // Ignore the event if nothing has been selected
1738
- if ($clear.length === 0) {
1739
- return;
1740
- }
1741
-
1742
- evt.stopPropagation();
1743
-
1744
- var data = $clear.data('data');
1745
-
1746
- for (var d = 0; d < data.length; d++) {
1747
- var unselectData = {
1748
- data: data[d]
1749
- };
1750
-
1751
- // Trigger the `unselect` event, so people can prevent it from being
1752
- // cleared.
1753
- this.trigger('unselect', unselectData);
1754
-
1755
- // If the event was prevented, don't clear it out.
1756
- if (unselectData.prevented) {
1757
- return;
1758
- }
1759
- }
1760
-
1761
- this.$element.val(this.placeholder.id).trigger('change');
1762
-
1763
- this.trigger('toggle', {});
1764
- };
1765
-
1766
- AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
1767
- if (container.isOpen()) {
1768
- return;
1769
- }
1770
-
1771
- if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
1772
- this._handleClear(evt);
1773
- }
1774
- };
1775
-
1776
- AllowClear.prototype.update = function (decorated, data) {
1777
- decorated.call(this, data);
1778
-
1779
- if (this.$selection.find('.pumselect2-selection__placeholder').length > 0 ||
1780
- data.length === 0) {
1781
- return;
1782
- }
1783
-
1784
- var $remove = $(
1785
- '<span class="pumselect2-selection__clear">' +
1786
- '&times;' +
1787
- '</span>'
1788
- );
1789
- $remove.data('data', data);
1790
-
1791
- this.$selection.find('.pumselect2-selection__rendered').prepend($remove);
1792
- };
1793
-
1794
- return AllowClear;
1795
- });
1796
-
1797
- S2.define('pumselect2/selection/search',[
1798
- 'jquery',
1799
- '../utils',
1800
- '../keys'
1801
- ], function ($, Utils, KEYS) {
1802
- function Search (decorated, $element, options) {
1803
- decorated.call(this, $element, options);
1804
- }
1805
-
1806
- Search.prototype.render = function (decorated) {
1807
- var $search = $(
1808
- '<li class="pumselect2-search pumselect2-search--inline">' +
1809
- '<input class="pumselect2-search__field" type="search" tabindex="-1"' +
1810
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
1811
- ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
1812
- '</li>'
1813
- );
1814
-
1815
- this.$searchContainer = $search;
1816
- this.$search = $search.find('input');
1817
-
1818
- var $rendered = decorated.call(this);
1819
-
1820
- this._transferTabIndex();
1821
-
1822
- return $rendered;
1823
- };
1824
-
1825
- Search.prototype.bind = function (decorated, container, $container) {
1826
- var self = this;
1827
-
1828
- decorated.call(this, container, $container);
1829
-
1830
- container.on('open', function () {
1831
- self.$search.trigger('focus');
1832
- });
1833
-
1834
- container.on('close', function () {
1835
- self.$search.val('');
1836
- self.$search.removeAttr('aria-activedescendant');
1837
- self.$search.trigger('focus');
1838
- });
1839
-
1840
- container.on('enable', function () {
1841
- self.$search.prop('disabled', false);
1842
-
1843
- self._transferTabIndex();
1844
- });
1845
-
1846
- container.on('disable', function () {
1847
- self.$search.prop('disabled', true);
1848
- });
1849
-
1850
- container.on('focus', function (evt) {
1851
- self.$search.trigger('focus');
1852
- });
1853
-
1854
- container.on('results:focus', function (params) {
1855
- self.$search.attr('aria-activedescendant', params.id);
1856
- });
1857
-
1858
- this.$selection.on('focusin', '.pumselect2-search--inline', function (evt) {
1859
- self.trigger('focus', evt);
1860
- });
1861
-
1862
- this.$selection.on('focusout', '.pumselect2-search--inline', function (evt) {
1863
- self._handleBlur(evt);
1864
- });
1865
-
1866
- this.$selection.on('keydown', '.pumselect2-search--inline', function (evt) {
1867
- evt.stopPropagation();
1868
-
1869
- self.trigger('keypress', evt);
1870
-
1871
- self._keyUpPrevented = evt.isDefaultPrevented();
1872
-
1873
- var key = evt.which;
1874
-
1875
- if (key === KEYS.BACKSPACE && self.$search.val() === '') {
1876
- var $previousChoice = self.$searchContainer
1877
- .prev('.pumselect2-selection__choice');
1878
-
1879
- if ($previousChoice.length > 0) {
1880
- var item = $previousChoice.data('data');
1881
-
1882
- self.searchRemoveChoice(item);
1883
-
1884
- evt.preventDefault();
1885
- }
1886
- }
1887
- });
1888
-
1889
- // Try to detect the IE version should the `documentMode` property that
1890
- // is stored on the document. This is only implemented in IE and is
1891
- // slightly cleaner than doing a user agent check.
1892
- // This property is not available in Edge, but Edge also doesn't have
1893
- // this bug.
1894
- var msie = document.documentMode;
1895
- var disableInputEvents = msie && msie <= 11;
1896
-
1897
- // Workaround for browsers which do not support the `input` event
1898
- // This will prevent double-triggering of events for browsers which support
1899
- // both the `keyup` and `input` events.
1900
- this.$selection.on(
1901
- 'input.searchcheck',
1902
- '.pumselect2-search--inline',
1903
- function (evt) {
1904
- // IE will trigger the `input` event when a placeholder is used on a
1905
- // search box. To get around this issue, we are forced to ignore all
1906
- // `input` events in IE and keep using `keyup`.
1907
- if (disableInputEvents) {
1908
- self.$selection.off('input.search input.searchcheck');
1909
- return;
1910
- }
1911
-
1912
- // Unbind the duplicated `keyup` event
1913
- self.$selection.off('keyup.search');
1914
- }
1915
- );
1916
-
1917
- this.$selection.on(
1918
- 'keyup.search input.search',
1919
- '.pumselect2-search--inline',
1920
- function (evt) {
1921
- // IE will trigger the `input` event when a placeholder is used on a
1922
- // search box. To get around this issue, we are forced to ignore all
1923
- // `input` events in IE and keep using `keyup`.
1924
- if (disableInputEvents && evt.type === 'input') {
1925
- self.$selection.off('input.search input.searchcheck');
1926
- return;
1927
- }
1928
-
1929
- var key = evt.which;
1930
-
1931
- // We can freely ignore events from modifier keys
1932
- if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
1933
- return;
1934
- }
1935
-
1936
- // Tabbing will be handled during the `keydown` phase
1937
- if (key == KEYS.TAB) {
1938
- return;
1939
- }
1940
-
1941
- self.handleSearch(evt);
1942
- }
1943
- );
1944
- };
1945
-
1946
- /**
1947
- * This method will transfer the tabindex attribute from the rendered
1948
- * selection to the search box. This allows for the search box to be used as
1949
- * the primary focus instead of the selection container.
1950
- *
1951
- * @private
1952
- */
1953
- Search.prototype._transferTabIndex = function (decorated) {
1954
- this.$search.attr('tabindex', this.$selection.attr('tabindex'));
1955
- this.$selection.attr('tabindex', '-1');
1956
- };
1957
-
1958
- Search.prototype.createPlaceholder = function (decorated, placeholder) {
1959
- this.$search.attr('placeholder', placeholder.text);
1960
- };
1961
-
1962
- Search.prototype.update = function (decorated, data) {
1963
- var searchHadFocus = this.$search[0] == document.activeElement;
1964
-
1965
- this.$search.attr('placeholder', '');
1966
-
1967
- decorated.call(this, data);
1968
-
1969
- this.$selection.find('.pumselect2-selection__rendered')
1970
- .append(this.$searchContainer);
1971
-
1972
- this.resizeSearch();
1973
- if (searchHadFocus) {
1974
- this.$search.focus();
1975
- }
1976
- };
1977
-
1978
- Search.prototype.handleSearch = function () {
1979
- this.resizeSearch();
1980
-
1981
- if (!this._keyUpPrevented) {
1982
- var input = this.$search.val();
1983
-
1984
- this.trigger('query', {
1985
- term: input
1986
- });
1987
- }
1988
-
1989
- this._keyUpPrevented = false;
1990
- };
1991
-
1992
- Search.prototype.searchRemoveChoice = function (decorated, item) {
1993
- this.trigger('unselect', {
1994
- data: item
1995
- });
1996
-
1997
- this.$search.val(item.text);
1998
- this.handleSearch();
1999
- };
2000
-
2001
- Search.prototype.resizeSearch = function () {
2002
- this.$search.css('width', '25px');
2003
-
2004
- var width = '';
2005
-
2006
- if (this.$search.attr('placeholder') !== '') {
2007
- width = this.$selection.find('.pumselect2-selection__rendered').innerWidth();
2008
- } else {
2009
- var minimumWidth = this.$search.val().length + 1;
2010
-
2011
- width = (minimumWidth * 0.75) + 'em';
2012
- }
2013
-
2014
- this.$search.css('width', width);
2015
- };
2016
-
2017
- return Search;
2018
- });
2019
-
2020
- S2.define('pumselect2/selection/eventRelay',[
2021
- 'jquery'
2022
- ], function ($) {
2023
- function EventRelay () { }
2024
-
2025
- EventRelay.prototype.bind = function (decorated, container, $container) {
2026
- var self = this;
2027
- var relayEvents = [
2028
- 'open', 'opening',
2029
- 'close', 'closing',
2030
- 'select', 'selecting',
2031
- 'unselect', 'unselecting'
2032
- ];
2033
-
2034
- var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
2035
-
2036
- decorated.call(this, container, $container);
2037
-
2038
- container.on('*', function (name, params) {
2039
- // Ignore events that should not be relayed
2040
- if ($.inArray(name, relayEvents) === -1) {
2041
- return;
2042
- }
2043
-
2044
- // The parameters should always be an object
2045
- params = params || {};
2046
-
2047
- // Generate the jQuery event for the Select2 event
2048
- var evt = $.Event('pumselect2:' + name, {
2049
- params: params
2050
- });
2051
-
2052
- self.$element.trigger(evt);
2053
-
2054
- // Only handle preventable events if it was one
2055
- if ($.inArray(name, preventableEvents) === -1) {
2056
- return;
2057
- }
2058
-
2059
- params.prevented = evt.isDefaultPrevented();
2060
- });
2061
- };
2062
-
2063
- return EventRelay;
2064
- });
2065
-
2066
- S2.define('pumselect2/translation',[
2067
- 'jquery',
2068
- 'require'
2069
- ], function ($, require) {
2070
- function Translation (dict) {
2071
- this.dict = dict || {};
2072
- }
2073
-
2074
- Translation.prototype.all = function () {
2075
- return this.dict;
2076
- };
2077
-
2078
- Translation.prototype.get = function (key) {
2079
- return this.dict[key];
2080
- };
2081
-
2082
- Translation.prototype.extend = function (translation) {
2083
- this.dict = $.extend({}, translation.all(), this.dict);
2084
- };
2085
-
2086
- // Static functions
2087
-
2088
- Translation._cache = {};
2089
-
2090
- Translation.loadPath = function (path) {
2091
- if (!(path in Translation._cache)) {
2092
- var translations = require(path);
2093
-
2094
- Translation._cache[path] = translations;
2095
- }
2096
-
2097
- return new Translation(Translation._cache[path]);
2098
- };
2099
-
2100
- return Translation;
2101
- });
2102
-
2103
- S2.define('pumselect2/diacritics',[
2104
-
2105
- ], function () {
2106
- var diacritics = {
2107
- '\u24B6': 'A',
2108
- '\uFF21': 'A',
2109
- '\u00C0': 'A',
2110
- '\u00C1': 'A',
2111
- '\u00C2': 'A',
2112
- '\u1EA6': 'A',
2113
- '\u1EA4': 'A',
2114
- '\u1EAA': 'A',
2115
- '\u1EA8': 'A',
2116
- '\u00C3': 'A',
2117
- '\u0100': 'A',
2118
- '\u0102': 'A',
2119
- '\u1EB0': 'A',
2120
- '\u1EAE': 'A',
2121
- '\u1EB4': 'A',
2122
- '\u1EB2': 'A',
2123
- '\u0226': 'A',
2124
- '\u01E0': 'A',
2125
- '\u00C4': 'A',
2126
- '\u01DE': 'A',
2127
- '\u1EA2': 'A',
2128
- '\u00C5': 'A',
2129
- '\u01FA': 'A',
2130
- '\u01CD': 'A',
2131
- '\u0200': 'A',
2132
- '\u0202': 'A',
2133
- '\u1EA0': 'A',
2134
- '\u1EAC': 'A',
2135
- '\u1EB6': 'A',
2136
- '\u1E00': 'A',
2137
- '\u0104': 'A',
2138
- '\u023A': 'A',
2139
- '\u2C6F': 'A',
2140
- '\uA732': 'AA',
2141
- '\u00C6': 'AE',
2142
- '\u01FC': 'AE',
2143
- '\u01E2': 'AE',
2144
- '\uA734': 'AO',
2145
- '\uA736': 'AU',
2146
- '\uA738': 'AV',
2147
- '\uA73A': 'AV',
2148
- '\uA73C': 'AY',
2149
- '\u24B7': 'B',
2150
- '\uFF22': 'B',
2151
- '\u1E02': 'B',
2152
- '\u1E04': 'B',
2153
- '\u1E06': 'B',
2154
- '\u0243': 'B',
2155
- '\u0182': 'B',
2156
- '\u0181': 'B',
2157
- '\u24B8': 'C',
2158
- '\uFF23': 'C',
2159
- '\u0106': 'C',
2160
- '\u0108': 'C',
2161
- '\u010A': 'C',
2162
- '\u010C': 'C',
2163
- '\u00C7': 'C',
2164
- '\u1E08': 'C',
2165
- '\u0187': 'C',
2166
- '\u023B': 'C',
2167
- '\uA73E': 'C',
2168
- '\u24B9': 'D',
2169
- '\uFF24': 'D',
2170
- '\u1E0A': 'D',
2171
- '\u010E': 'D',
2172
- '\u1E0C': 'D',
2173
- '\u1E10': 'D',
2174
- '\u1E12': 'D',
2175
- '\u1E0E': 'D',
2176
- '\u0110': 'D',
2177
- '\u018B': 'D',
2178
- '\u018A': 'D',
2179
- '\u0189': 'D',
2180
- '\uA779': 'D',
2181
- '\u01F1': 'DZ',
2182
- '\u01C4': 'DZ',
2183
- '\u01F2': 'Dz',
2184
- '\u01C5': 'Dz',
2185
- '\u24BA': 'E',
2186
- '\uFF25': 'E',
2187
- '\u00C8': 'E',
2188
- '\u00C9': 'E',
2189
- '\u00CA': 'E',
2190
- '\u1EC0': 'E',
2191
- '\u1EBE': 'E',
2192
- '\u1EC4': 'E',
2193
- '\u1EC2': 'E',
2194
- '\u1EBC': 'E',
2195
- '\u0112': 'E',
2196
- '\u1E14': 'E',
2197
- '\u1E16': 'E',
2198
- '\u0114': 'E',
2199
- '\u0116': 'E',
2200
- '\u00CB': 'E',
2201
- '\u1EBA': 'E',
2202
- '\u011A': 'E',
2203
- '\u0204': 'E',
2204
- '\u0206': 'E',
2205
- '\u1EB8': 'E',
2206
- '\u1EC6': 'E',
2207
- '\u0228': 'E',
2208
- '\u1E1C': 'E',
2209
- '\u0118': 'E',
2210
- '\u1E18': 'E',
2211
- '\u1E1A': 'E',
2212
- '\u0190': 'E',
2213
- '\u018E': 'E',
2214
- '\u24BB': 'F',
2215
- '\uFF26': 'F',
2216
- '\u1E1E': 'F',
2217
- '\u0191': 'F',
2218
- '\uA77B': 'F',
2219
- '\u24BC': 'G',
2220
- '\uFF27': 'G',
2221
- '\u01F4': 'G',
2222
- '\u011C': 'G',
2223
- '\u1E20': 'G',
2224
- '\u011E': 'G',
2225
- '\u0120': 'G',
2226
- '\u01E6': 'G',
2227
- '\u0122': 'G',
2228
- '\u01E4': 'G',
2229
- '\u0193': 'G',
2230
- '\uA7A0': 'G',
2231
- '\uA77D': 'G',
2232
- '\uA77E': 'G',
2233
- '\u24BD': 'H',
2234
- '\uFF28': 'H',
2235
- '\u0124': 'H',
2236
- '\u1E22': 'H',
2237
- '\u1E26': 'H',
2238
- '\u021E': 'H',
2239
- '\u1E24': 'H',
2240
- '\u1E28': 'H',
2241
- '\u1E2A': 'H',
2242
- '\u0126': 'H',
2243
- '\u2C67': 'H',
2244
- '\u2C75': 'H',
2245
- '\uA78D': 'H',
2246
- '\u24BE': 'I',
2247
- '\uFF29': 'I',
2248
- '\u00CC': 'I',
2249
- '\u00CD': 'I',
2250
- '\u00CE': 'I',
2251
- '\u0128': 'I',
2252
- '\u012A': 'I',
2253
- '\u012C': 'I',
2254
- '\u0130': 'I',
2255
- '\u00CF': 'I',
2256
- '\u1E2E': 'I',
2257
- '\u1EC8': 'I',
2258
- '\u01CF': 'I',
2259
- '\u0208': 'I',
2260
- '\u020A': 'I',
2261
- '\u1ECA': 'I',
2262
- '\u012E': 'I',
2263
- '\u1E2C': 'I',
2264
- '\u0197': 'I',
2265
- '\u24BF': 'J',
2266
- '\uFF2A': 'J',
2267
- '\u0134': 'J',
2268
- '\u0248': 'J',
2269
- '\u24C0': 'K',
2270
- '\uFF2B': 'K',
2271
- '\u1E30': 'K',
2272
- '\u01E8': 'K',
2273
- '\u1E32': 'K',
2274
- '\u0136': 'K',
2275
- '\u1E34': 'K',
2276
- '\u0198': 'K',
2277
- '\u2C69': 'K',
2278
- '\uA740': 'K',
2279
- '\uA742': 'K',
2280
- '\uA744': 'K',
2281
- '\uA7A2': 'K',
2282
- '\u24C1': 'L',
2283
- '\uFF2C': 'L',
2284
- '\u013F': 'L',
2285
- '\u0139': 'L',
2286
- '\u013D': 'L',
2287
- '\u1E36': 'L',
2288
- '\u1E38': 'L',
2289
- '\u013B': 'L',
2290
- '\u1E3C': 'L',
2291
- '\u1E3A': 'L',
2292
- '\u0141': 'L',
2293
- '\u023D': 'L',
2294
- '\u2C62': 'L',
2295
- '\u2C60': 'L',
2296
- '\uA748': 'L',
2297
- '\uA746': 'L',
2298
- '\uA780': 'L',
2299
- '\u01C7': 'LJ',
2300
- '\u01C8': 'Lj',
2301
- '\u24C2': 'M',
2302
- '\uFF2D': 'M',
2303
- '\u1E3E': 'M',
2304
- '\u1E40': 'M',
2305
- '\u1E42': 'M',
2306
- '\u2C6E': 'M',
2307
- '\u019C': 'M',
2308
- '\u24C3': 'N',
2309
- '\uFF2E': 'N',
2310
- '\u01F8': 'N',
2311
- '\u0143': 'N',
2312
- '\u00D1': 'N',
2313
- '\u1E44': 'N',
2314
- '\u0147': 'N',
2315
- '\u1E46': 'N',
2316
- '\u0145': 'N',
2317
- '\u1E4A': 'N',
2318
- '\u1E48': 'N',
2319
- '\u0220': 'N',
2320
- '\u019D': 'N',
2321
- '\uA790': 'N',
2322
- '\uA7A4': 'N',
2323
- '\u01CA': 'NJ',
2324
- '\u01CB': 'Nj',
2325
- '\u24C4': 'O',
2326
- '\uFF2F': 'O',
2327
- '\u00D2': 'O',
2328
- '\u00D3': 'O',
2329
- '\u00D4': 'O',
2330
- '\u1ED2': 'O',
2331
- '\u1ED0': 'O',
2332
- '\u1ED6': 'O',
2333
- '\u1ED4': 'O',
2334
- '\u00D5': 'O',
2335
- '\u1E4C': 'O',
2336
- '\u022C': 'O',
2337
- '\u1E4E': 'O',
2338
- '\u014C': 'O',
2339
- '\u1E50': 'O',
2340
- '\u1E52': 'O',
2341
- '\u014E': 'O',
2342
- '\u022E': 'O',
2343
- '\u0230': 'O',
2344
- '\u00D6': 'O',
2345
- '\u022A': 'O',
2346
- '\u1ECE': 'O',
2347
- '\u0150': 'O',
2348
- '\u01D1': 'O',
2349
- '\u020C': 'O',
2350
- '\u020E': 'O',
2351
- '\u01A0': 'O',
2352
- '\u1EDC': 'O',
2353
- '\u1EDA': 'O',
2354
- '\u1EE0': 'O',
2355
- '\u1EDE': 'O',
2356
- '\u1EE2': 'O',
2357
- '\u1ECC': 'O',
2358
- '\u1ED8': 'O',
2359
- '\u01EA': 'O',
2360
- '\u01EC': 'O',
2361
- '\u00D8': 'O',
2362
- '\u01FE': 'O',
2363
- '\u0186': 'O',
2364
- '\u019F': 'O',
2365
- '\uA74A': 'O',
2366
- '\uA74C': 'O',
2367
- '\u01A2': 'OI',
2368
- '\uA74E': 'OO',
2369
- '\u0222': 'OU',
2370
- '\u24C5': 'P',
2371
- '\uFF30': 'P',
2372
- '\u1E54': 'P',
2373
- '\u1E56': 'P',
2374
- '\u01A4': 'P',
2375
- '\u2C63': 'P',
2376
- '\uA750': 'P',
2377
- '\uA752': 'P',
2378
- '\uA754': 'P',
2379
- '\u24C6': 'Q',
2380
- '\uFF31': 'Q',
2381
- '\uA756': 'Q',
2382
- '\uA758': 'Q',
2383
- '\u024A': 'Q',
2384
- '\u24C7': 'R',
2385
- '\uFF32': 'R',
2386
- '\u0154': 'R',
2387
- '\u1E58': 'R',
2388
- '\u0158': 'R',
2389
- '\u0210': 'R',
2390
- '\u0212': 'R',
2391
- '\u1E5A': 'R',
2392
- '\u1E5C': 'R',
2393
- '\u0156': 'R',
2394
- '\u1E5E': 'R',
2395
- '\u024C': 'R',
2396
- '\u2C64': 'R',
2397
- '\uA75A': 'R',
2398
- '\uA7A6': 'R',
2399
- '\uA782': 'R',
2400
- '\u24C8': 'S',
2401
- '\uFF33': 'S',
2402
- '\u1E9E': 'S',
2403
- '\u015A': 'S',
2404
- '\u1E64': 'S',
2405
- '\u015C': 'S',
2406
- '\u1E60': 'S',
2407
- '\u0160': 'S',
2408
- '\u1E66': 'S',
2409
- '\u1E62': 'S',
2410
- '\u1E68': 'S',
2411
- '\u0218': 'S',
2412
- '\u015E': 'S',
2413
- '\u2C7E': 'S',
2414
- '\uA7A8': 'S',
2415
- '\uA784': 'S',
2416
- '\u24C9': 'T',
2417
- '\uFF34': 'T',
2418
- '\u1E6A': 'T',
2419
- '\u0164': 'T',
2420
- '\u1E6C': 'T',
2421
- '\u021A': 'T',
2422
- '\u0162': 'T',
2423
- '\u1E70': 'T',
2424
- '\u1E6E': 'T',
2425
- '\u0166': 'T',
2426
- '\u01AC': 'T',
2427
- '\u01AE': 'T',
2428
- '\u023E': 'T',
2429
- '\uA786': 'T',
2430
- '\uA728': 'TZ',
2431
- '\u24CA': 'U',
2432
- '\uFF35': 'U',
2433
- '\u00D9': 'U',
2434
- '\u00DA': 'U',
2435
- '\u00DB': 'U',
2436
- '\u0168': 'U',
2437
- '\u1E78': 'U',
2438
- '\u016A': 'U',
2439
- '\u1E7A': 'U',
2440
- '\u016C': 'U',
2441
- '\u00DC': 'U',
2442
- '\u01DB': 'U',
2443
- '\u01D7': 'U',
2444
- '\u01D5': 'U',
2445
- '\u01D9': 'U',
2446
- '\u1EE6': 'U',
2447
- '\u016E': 'U',
2448
- '\u0170': 'U',
2449
- '\u01D3': 'U',
2450
- '\u0214': 'U',
2451
- '\u0216': 'U',
2452
- '\u01AF': 'U',
2453
- '\u1EEA': 'U',
2454
- '\u1EE8': 'U',
2455
- '\u1EEE': 'U',
2456
- '\u1EEC': 'U',
2457
- '\u1EF0': 'U',
2458
- '\u1EE4': 'U',
2459
- '\u1E72': 'U',
2460
- '\u0172': 'U',
2461
- '\u1E76': 'U',
2462
- '\u1E74': 'U',
2463
- '\u0244': 'U',
2464
- '\u24CB': 'V',
2465
- '\uFF36': 'V',
2466
- '\u1E7C': 'V',
2467
- '\u1E7E': 'V',
2468
- '\u01B2': 'V',
2469
- '\uA75E': 'V',
2470
- '\u0245': 'V',
2471
- '\uA760': 'VY',
2472
- '\u24CC': 'W',
2473
- '\uFF37': 'W',
2474
- '\u1E80': 'W',
2475
- '\u1E82': 'W',
2476
- '\u0174': 'W',
2477
- '\u1E86': 'W',
2478
- '\u1E84': 'W',
2479
- '\u1E88': 'W',
2480
- '\u2C72': 'W',
2481
- '\u24CD': 'X',
2482
- '\uFF38': 'X',
2483
- '\u1E8A': 'X',
2484
- '\u1E8C': 'X',
2485
- '\u24CE': 'Y',
2486
- '\uFF39': 'Y',
2487
- '\u1EF2': 'Y',
2488
- '\u00DD': 'Y',
2489
- '\u0176': 'Y',
2490
- '\u1EF8': 'Y',
2491
- '\u0232': 'Y',
2492
- '\u1E8E': 'Y',
2493
- '\u0178': 'Y',
2494
- '\u1EF6': 'Y',
2495
- '\u1EF4': 'Y',
2496
- '\u01B3': 'Y',
2497
- '\u024E': 'Y',
2498
- '\u1EFE': 'Y',
2499
- '\u24CF': 'Z',
2500
- '\uFF3A': 'Z',
2501
- '\u0179': 'Z',
2502
- '\u1E90': 'Z',
2503
- '\u017B': 'Z',
2504
- '\u017D': 'Z',
2505
- '\u1E92': 'Z',
2506
- '\u1E94': 'Z',
2507
- '\u01B5': 'Z',
2508
- '\u0224': 'Z',
2509
- '\u2C7F': 'Z',
2510
- '\u2C6B': 'Z',
2511
- '\uA762': 'Z',
2512
- '\u24D0': 'a',
2513
- '\uFF41': 'a',
2514
- '\u1E9A': 'a',
2515
- '\u00E0': 'a',
2516
- '\u00E1': 'a',
2517
- '\u00E2': 'a',
2518
- '\u1EA7': 'a',
2519
- '\u1EA5': 'a',
2520
- '\u1EAB': 'a',
2521
- '\u1EA9': 'a',
2522
- '\u00E3': 'a',
2523
- '\u0101': 'a',
2524
- '\u0103': 'a',
2525
- '\u1EB1': 'a',
2526
- '\u1EAF': 'a',
2527
- '\u1EB5': 'a',
2528
- '\u1EB3': 'a',
2529
- '\u0227': 'a',
2530
- '\u01E1': 'a',
2531
- '\u00E4': 'a',
2532
- '\u01DF': 'a',
2533
- '\u1EA3': 'a',
2534
- '\u00E5': 'a',
2535
- '\u01FB': 'a',
2536
- '\u01CE': 'a',
2537
- '\u0201': 'a',
2538
- '\u0203': 'a',
2539
- '\u1EA1': 'a',
2540
- '\u1EAD': 'a',
2541
- '\u1EB7': 'a',
2542
- '\u1E01': 'a',
2543
- '\u0105': 'a',
2544
- '\u2C65': 'a',
2545
- '\u0250': 'a',
2546
- '\uA733': 'aa',
2547
- '\u00E6': 'ae',
2548
- '\u01FD': 'ae',
2549
- '\u01E3': 'ae',
2550
- '\uA735': 'ao',
2551
- '\uA737': 'au',
2552
- '\uA739': 'av',
2553
- '\uA73B': 'av',
2554
- '\uA73D': 'ay',
2555
- '\u24D1': 'b',
2556
- '\uFF42': 'b',
2557
- '\u1E03': 'b',
2558
- '\u1E05': 'b',
2559
- '\u1E07': 'b',
2560
- '\u0180': 'b',
2561
- '\u0183': 'b',
2562
- '\u0253': 'b',
2563
- '\u24D2': 'c',
2564
- '\uFF43': 'c',
2565
- '\u0107': 'c',
2566
- '\u0109': 'c',
2567
- '\u010B': 'c',
2568
- '\u010D': 'c',
2569
- '\u00E7': 'c',
2570
- '\u1E09': 'c',
2571
- '\u0188': 'c',
2572
- '\u023C': 'c',
2573
- '\uA73F': 'c',
2574
- '\u2184': 'c',
2575
- '\u24D3': 'd',
2576
- '\uFF44': 'd',
2577
- '\u1E0B': 'd',
2578
- '\u010F': 'd',
2579
- '\u1E0D': 'd',
2580
- '\u1E11': 'd',
2581
- '\u1E13': 'd',
2582
- '\u1E0F': 'd',
2583
- '\u0111': 'd',
2584
- '\u018C': 'd',
2585
- '\u0256': 'd',
2586
- '\u0257': 'd',
2587
- '\uA77A': 'd',
2588
- '\u01F3': 'dz',
2589
- '\u01C6': 'dz',
2590
- '\u24D4': 'e',
2591
- '\uFF45': 'e',
2592
- '\u00E8': 'e',
2593
- '\u00E9': 'e',
2594
- '\u00EA': 'e',
2595
- '\u1EC1': 'e',
2596
- '\u1EBF': 'e',
2597
- '\u1EC5': 'e',
2598
- '\u1EC3': 'e',
2599
- '\u1EBD': 'e',
2600
- '\u0113': 'e',
2601
- '\u1E15': 'e',
2602
- '\u1E17': 'e',
2603
- '\u0115': 'e',
2604
- '\u0117': 'e',
2605
- '\u00EB': 'e',
2606
- '\u1EBB': 'e',
2607
- '\u011B': 'e',
2608
- '\u0205': 'e',
2609
- '\u0207': 'e',
2610
- '\u1EB9': 'e',
2611
- '\u1EC7': 'e',
2612
- '\u0229': 'e',
2613
- '\u1E1D': 'e',
2614
- '\u0119': 'e',
2615
- '\u1E19': 'e',
2616
- '\u1E1B': 'e',
2617
- '\u0247': 'e',
2618
- '\u025B': 'e',
2619
- '\u01DD': 'e',
2620
- '\u24D5': 'f',
2621
- '\uFF46': 'f',
2622
- '\u1E1F': 'f',
2623
- '\u0192': 'f',
2624
- '\uA77C': 'f',
2625
- '\u24D6': 'g',
2626
- '\uFF47': 'g',
2627
- '\u01F5': 'g',
2628
- '\u011D': 'g',
2629
- '\u1E21': 'g',
2630
- '\u011F': 'g',
2631
- '\u0121': 'g',
2632
- '\u01E7': 'g',
2633
- '\u0123': 'g',
2634
- '\u01E5': 'g',
2635
- '\u0260': 'g',
2636
- '\uA7A1': 'g',
2637
- '\u1D79': 'g',
2638
- '\uA77F': 'g',
2639
- '\u24D7': 'h',
2640
- '\uFF48': 'h',
2641
- '\u0125': 'h',
2642
- '\u1E23': 'h',
2643
- '\u1E27': 'h',
2644
- '\u021F': 'h',
2645
- '\u1E25': 'h',
2646
- '\u1E29': 'h',
2647
- '\u1E2B': 'h',
2648
- '\u1E96': 'h',
2649
- '\u0127': 'h',
2650
- '\u2C68': 'h',
2651
- '\u2C76': 'h',
2652
- '\u0265': 'h',
2653
- '\u0195': 'hv',
2654
- '\u24D8': 'i',
2655
- '\uFF49': 'i',
2656
- '\u00EC': 'i',
2657
- '\u00ED': 'i',
2658
- '\u00EE': 'i',
2659
- '\u0129': 'i',
2660
- '\u012B': 'i',
2661
- '\u012D': 'i',
2662
- '\u00EF': 'i',
2663
- '\u1E2F': 'i',
2664
- '\u1EC9': 'i',
2665
- '\u01D0': 'i',
2666
- '\u0209': 'i',
2667
- '\u020B': 'i',
2668
- '\u1ECB': 'i',
2669
- '\u012F': 'i',
2670
- '\u1E2D': 'i',
2671
- '\u0268': 'i',
2672
- '\u0131': 'i',
2673
- '\u24D9': 'j',
2674
- '\uFF4A': 'j',
2675
- '\u0135': 'j',
2676
- '\u01F0': 'j',
2677
- '\u0249': 'j',
2678
- '\u24DA': 'k',
2679
- '\uFF4B': 'k',
2680
- '\u1E31': 'k',
2681
- '\u01E9': 'k',
2682
- '\u1E33': 'k',
2683
- '\u0137': 'k',
2684
- '\u1E35': 'k',
2685
- '\u0199': 'k',
2686
- '\u2C6A': 'k',
2687
- '\uA741': 'k',
2688
- '\uA743': 'k',
2689
- '\uA745': 'k',
2690
- '\uA7A3': 'k',
2691
- '\u24DB': 'l',
2692
- '\uFF4C': 'l',
2693
- '\u0140': 'l',
2694
- '\u013A': 'l',
2695
- '\u013E': 'l',
2696
- '\u1E37': 'l',
2697
- '\u1E39': 'l',
2698
- '\u013C': 'l',
2699
- '\u1E3D': 'l',
2700
- '\u1E3B': 'l',
2701
- '\u017F': 'l',
2702
- '\u0142': 'l',
2703
- '\u019A': 'l',
2704
- '\u026B': 'l',
2705
- '\u2C61': 'l',
2706
- '\uA749': 'l',
2707
- '\uA781': 'l',
2708
- '\uA747': 'l',
2709
- '\u01C9': 'lj',
2710
- '\u24DC': 'm',
2711
- '\uFF4D': 'm',
2712
- '\u1E3F': 'm',
2713
- '\u1E41': 'm',
2714
- '\u1E43': 'm',
2715
- '\u0271': 'm',
2716
- '\u026F': 'm',
2717
- '\u24DD': 'n',
2718
- '\uFF4E': 'n',
2719
- '\u01F9': 'n',
2720
- '\u0144': 'n',
2721
- '\u00F1': 'n',
2722
- '\u1E45': 'n',
2723
- '\u0148': 'n',
2724
- '\u1E47': 'n',
2725
- '\u0146': 'n',
2726
- '\u1E4B': 'n',
2727
- '\u1E49': 'n',
2728
- '\u019E': 'n',
2729
- '\u0272': 'n',
2730
- '\u0149': 'n',
2731
- '\uA791': 'n',
2732
- '\uA7A5': 'n',
2733
- '\u01CC': 'nj',
2734
- '\u24DE': 'o',
2735
- '\uFF4F': 'o',
2736
- '\u00F2': 'o',
2737
- '\u00F3': 'o',
2738
- '\u00F4': 'o',
2739
- '\u1ED3': 'o',
2740
- '\u1ED1': 'o',
2741
- '\u1ED7': 'o',
2742
- '\u1ED5': 'o',
2743
- '\u00F5': 'o',
2744
- '\u1E4D': 'o',
2745
- '\u022D': 'o',
2746
- '\u1E4F': 'o',
2747
- '\u014D': 'o',
2748
- '\u1E51': 'o',
2749
- '\u1E53': 'o',
2750
- '\u014F': 'o',
2751
- '\u022F': 'o',
2752
- '\u0231': 'o',
2753
- '\u00F6': 'o',
2754
- '\u022B': 'o',
2755
- '\u1ECF': 'o',
2756
- '\u0151': 'o',
2757
- '\u01D2': 'o',
2758
- '\u020D': 'o',
2759
- '\u020F': 'o',
2760
- '\u01A1': 'o',
2761
- '\u1EDD': 'o',
2762
- '\u1EDB': 'o',
2763
- '\u1EE1': 'o',
2764
- '\u1EDF': 'o',
2765
- '\u1EE3': 'o',
2766
- '\u1ECD': 'o',
2767
- '\u1ED9': 'o',
2768
- '\u01EB': 'o',
2769
- '\u01ED': 'o',
2770
- '\u00F8': 'o',
2771
- '\u01FF': 'o',
2772
- '\u0254': 'o',
2773
- '\uA74B': 'o',
2774
- '\uA74D': 'o',
2775
- '\u0275': 'o',
2776
- '\u01A3': 'oi',
2777
- '\u0223': 'ou',
2778
- '\uA74F': 'oo',
2779
- '\u24DF': 'p',
2780
- '\uFF50': 'p',
2781
- '\u1E55': 'p',
2782
- '\u1E57': 'p',
2783
- '\u01A5': 'p',
2784
- '\u1D7D': 'p',
2785
- '\uA751': 'p',
2786
- '\uA753': 'p',
2787
- '\uA755': 'p',
2788
- '\u24E0': 'q',
2789
- '\uFF51': 'q',
2790
- '\u024B': 'q',
2791
- '\uA757': 'q',
2792
- '\uA759': 'q',
2793
- '\u24E1': 'r',
2794
- '\uFF52': 'r',
2795
- '\u0155': 'r',
2796
- '\u1E59': 'r',
2797
- '\u0159': 'r',
2798
- '\u0211': 'r',
2799
- '\u0213': 'r',
2800
- '\u1E5B': 'r',
2801
- '\u1E5D': 'r',
2802
- '\u0157': 'r',
2803
- '\u1E5F': 'r',
2804
- '\u024D': 'r',
2805
- '\u027D': 'r',
2806
- '\uA75B': 'r',
2807
- '\uA7A7': 'r',
2808
- '\uA783': 'r',
2809
- '\u24E2': 's',
2810
- '\uFF53': 's',
2811
- '\u00DF': 's',
2812
- '\u015B': 's',
2813
- '\u1E65': 's',
2814
- '\u015D': 's',
2815
- '\u1E61': 's',
2816
- '\u0161': 's',
2817
- '\u1E67': 's',
2818
- '\u1E63': 's',
2819
- '\u1E69': 's',
2820
- '\u0219': 's',
2821
- '\u015F': 's',
2822
- '\u023F': 's',
2823
- '\uA7A9': 's',
2824
- '\uA785': 's',
2825
- '\u1E9B': 's',
2826
- '\u24E3': 't',
2827
- '\uFF54': 't',
2828
- '\u1E6B': 't',
2829
- '\u1E97': 't',
2830
- '\u0165': 't',
2831
- '\u1E6D': 't',
2832
- '\u021B': 't',
2833
- '\u0163': 't',
2834
- '\u1E71': 't',
2835
- '\u1E6F': 't',
2836
- '\u0167': 't',
2837
- '\u01AD': 't',
2838
- '\u0288': 't',
2839
- '\u2C66': 't',
2840
- '\uA787': 't',
2841
- '\uA729': 'tz',
2842
- '\u24E4': 'u',
2843
- '\uFF55': 'u',
2844
- '\u00F9': 'u',
2845
- '\u00FA': 'u',
2846
- '\u00FB': 'u',
2847
- '\u0169': 'u',
2848
- '\u1E79': 'u',
2849
- '\u016B': 'u',
2850
- '\u1E7B': 'u',
2851
- '\u016D': 'u',
2852
- '\u00FC': 'u',
2853
- '\u01DC': 'u',
2854
- '\u01D8': 'u',
2855
- '\u01D6': 'u',
2856
- '\u01DA': 'u',
2857
- '\u1EE7': 'u',
2858
- '\u016F': 'u',
2859
- '\u0171': 'u',
2860
- '\u01D4': 'u',
2861
- '\u0215': 'u',
2862
- '\u0217': 'u',
2863
- '\u01B0': 'u',
2864
- '\u1EEB': 'u',
2865
- '\u1EE9': 'u',
2866
- '\u1EEF': 'u',
2867
- '\u1EED': 'u',
2868
- '\u1EF1': 'u',
2869
- '\u1EE5': 'u',
2870
- '\u1E73': 'u',
2871
- '\u0173': 'u',
2872
- '\u1E77': 'u',
2873
- '\u1E75': 'u',
2874
- '\u0289': 'u',
2875
- '\u24E5': 'v',
2876
- '\uFF56': 'v',
2877
- '\u1E7D': 'v',
2878
- '\u1E7F': 'v',
2879
- '\u028B': 'v',
2880
- '\uA75F': 'v',
2881
- '\u028C': 'v',
2882
- '\uA761': 'vy',
2883
- '\u24E6': 'w',
2884
- '\uFF57': 'w',
2885
- '\u1E81': 'w',
2886
- '\u1E83': 'w',
2887
- '\u0175': 'w',
2888
- '\u1E87': 'w',
2889
- '\u1E85': 'w',
2890
- '\u1E98': 'w',
2891
- '\u1E89': 'w',
2892
- '\u2C73': 'w',
2893
- '\u24E7': 'x',
2894
- '\uFF58': 'x',
2895
- '\u1E8B': 'x',
2896
- '\u1E8D': 'x',
2897
- '\u24E8': 'y',
2898
- '\uFF59': 'y',
2899
- '\u1EF3': 'y',
2900
- '\u00FD': 'y',
2901
- '\u0177': 'y',
2902
- '\u1EF9': 'y',
2903
- '\u0233': 'y',
2904
- '\u1E8F': 'y',
2905
- '\u00FF': 'y',
2906
- '\u1EF7': 'y',
2907
- '\u1E99': 'y',
2908
- '\u1EF5': 'y',
2909
- '\u01B4': 'y',
2910
- '\u024F': 'y',
2911
- '\u1EFF': 'y',
2912
- '\u24E9': 'z',
2913
- '\uFF5A': 'z',
2914
- '\u017A': 'z',
2915
- '\u1E91': 'z',
2916
- '\u017C': 'z',
2917
- '\u017E': 'z',
2918
- '\u1E93': 'z',
2919
- '\u1E95': 'z',
2920
- '\u01B6': 'z',
2921
- '\u0225': 'z',
2922
- '\u0240': 'z',
2923
- '\u2C6C': 'z',
2924
- '\uA763': 'z',
2925
- '\u0386': '\u0391',
2926
- '\u0388': '\u0395',
2927
- '\u0389': '\u0397',
2928
- '\u038A': '\u0399',
2929
- '\u03AA': '\u0399',
2930
- '\u038C': '\u039F',
2931
- '\u038E': '\u03A5',
2932
- '\u03AB': '\u03A5',
2933
- '\u038F': '\u03A9',
2934
- '\u03AC': '\u03B1',
2935
- '\u03AD': '\u03B5',
2936
- '\u03AE': '\u03B7',
2937
- '\u03AF': '\u03B9',
2938
- '\u03CA': '\u03B9',
2939
- '\u0390': '\u03B9',
2940
- '\u03CC': '\u03BF',
2941
- '\u03CD': '\u03C5',
2942
- '\u03CB': '\u03C5',
2943
- '\u03B0': '\u03C5',
2944
- '\u03C9': '\u03C9',
2945
- '\u03C2': '\u03C3'
2946
- };
2947
-
2948
- return diacritics;
2949
- });
2950
-
2951
- S2.define('pumselect2/data/base',[
2952
- '../utils'
2953
- ], function (Utils) {
2954
- function BaseAdapter ($element, options) {
2955
- BaseAdapter.__super__.constructor.call(this);
2956
- }
2957
-
2958
- Utils.Extend(BaseAdapter, Utils.Observable);
2959
-
2960
- BaseAdapter.prototype.current = function (callback) {
2961
- throw new Error('The `current` method must be defined in child classes.');
2962
- };
2963
-
2964
- BaseAdapter.prototype.query = function (params, callback) {
2965
- throw new Error('The `query` method must be defined in child classes.');
2966
- };
2967
-
2968
- BaseAdapter.prototype.bind = function (container, $container) {
2969
- // Can be implemented in subclasses
2970
- };
2971
-
2972
- BaseAdapter.prototype.destroy = function () {
2973
- // Can be implemented in subclasses
2974
- };
2975
-
2976
- BaseAdapter.prototype.generateResultId = function (container, data) {
2977
- var id = container.id + '-result-';
2978
-
2979
- id += Utils.generateChars(4);
2980
-
2981
- if (data.id != null) {
2982
- id += '-' + data.id.toString();
2983
- } else {
2984
- id += '-' + Utils.generateChars(4);
2985
- }
2986
- return id;
2987
- };
2988
-
2989
- return BaseAdapter;
2990
- });
2991
-
2992
- S2.define('pumselect2/data/select',[
2993
- './base',
2994
- '../utils',
2995
- 'jquery'
2996
- ], function (BaseAdapter, Utils, $) {
2997
- function SelectAdapter ($element, options) {
2998
- this.$element = $element;
2999
- this.options = options;
3000
-
3001
- SelectAdapter.__super__.constructor.call(this);
3002
- }
3003
-
3004
- Utils.Extend(SelectAdapter, BaseAdapter);
3005
-
3006
- SelectAdapter.prototype.current = function (callback) {
3007
- var data = [];
3008
- var self = this;
3009
-
3010
- this.$element.find(':selected').each(function () {
3011
- var $option = $(this);
3012
-
3013
- var option = self.item($option);
3014
-
3015
- data.push(option);
3016
- });
3017
-
3018
- callback(data);
3019
- };
3020
-
3021
- SelectAdapter.prototype.select = function (data) {
3022
- var self = this;
3023
-
3024
- data.selected = true;
3025
-
3026
- // If data.element is a DOM node, use it instead
3027
- if ($(data.element).is('option')) {
3028
- data.element.selected = true;
3029
-
3030
- this.$element.trigger('change');
3031
-
3032
- return;
3033
- }
3034
-
3035
- if (this.$element.prop('multiple')) {
3036
- this.current(function (currentData) {
3037
- var val = [];
3038
-
3039
- data = [data];
3040
- data.push.apply(data, currentData);
3041
-
3042
- for (var d = 0; d < data.length; d++) {
3043
- var id = data[d].id;
3044
-
3045
- if ($.inArray(id, val) === -1) {
3046
- val.push(id);
3047
- }
3048
- }
3049
-
3050
- self.$element.val(val);
3051
- self.$element.trigger('change');
3052
- });
3053
- } else {
3054
- var val = data.id;
3055
-
3056
- this.$element.val(val);
3057
- this.$element.trigger('change');
3058
- }
3059
- };
3060
-
3061
- SelectAdapter.prototype.unselect = function (data) {
3062
- var self = this;
3063
-
3064
- if (!this.$element.prop('multiple')) {
3065
- return;
3066
- }
3067
-
3068
- data.selected = false;
3069
-
3070
- if ($(data.element).is('option')) {
3071
- data.element.selected = false;
3072
-
3073
- this.$element.trigger('change');
3074
-
3075
- return;
3076
- }
3077
-
3078
- this.current(function (currentData) {
3079
- var val = [];
3080
-
3081
- for (var d = 0; d < currentData.length; d++) {
3082
- var id = currentData[d].id;
3083
-
3084
- if (id !== data.id && $.inArray(id, val) === -1) {
3085
- val.push(id);
3086
- }
3087
- }
3088
-
3089
- self.$element.val(val);
3090
-
3091
- self.$element.trigger('change');
3092
- });
3093
- };
3094
-
3095
- SelectAdapter.prototype.bind = function (container, $container) {
3096
- var self = this;
3097
-
3098
- this.container = container;
3099
-
3100
- container.on('select', function (params) {
3101
- self.select(params.data);
3102
- });
3103
-
3104
- container.on('unselect', function (params) {
3105
- self.unselect(params.data);
3106
- });
3107
- };
3108
-
3109
- SelectAdapter.prototype.destroy = function () {
3110
- // Remove anything added to child elements
3111
- this.$element.find('*').each(function () {
3112
- // Remove any custom data set by Select2
3113
- $.removeData(this, 'data');
3114
- });
3115
- };
3116
-
3117
- SelectAdapter.prototype.query = function (params, callback) {
3118
- var data = [];
3119
- var self = this;
3120
-
3121
- var $options = this.$element.children();
3122
-
3123
- $options.each(function () {
3124
- var $option = $(this);
3125
-
3126
- if (!$option.is('option') && !$option.is('optgroup')) {
3127
- return;
3128
- }
3129
-
3130
- var option = self.item($option);
3131
-
3132
- var matches = self.matches(params, option);
3133
-
3134
- if (matches !== null) {
3135
- data.push(matches);
3136
- }
3137
- });
3138
-
3139
- callback({
3140
- results: data
3141
- });
3142
- };
3143
-
3144
- SelectAdapter.prototype.addOptions = function ($options) {
3145
- Utils.appendMany(this.$element, $options);
3146
- };
3147
-
3148
- SelectAdapter.prototype.option = function (data) {
3149
- var option;
3150
-
3151
- if (data.children) {
3152
- option = document.createElement('optgroup');
3153
- option.label = data.text;
3154
- } else {
3155
- option = document.createElement('option');
3156
-
3157
- if (option.textContent !== undefined) {
3158
- option.textContent = data.text;
3159
- } else {
3160
- option.innerText = data.text;
3161
- }
3162
- }
3163
-
3164
- if (data.id) {
3165
- option.value = data.id;
3166
- }
3167
-
3168
- if (data.disabled) {
3169
- option.disabled = true;
3170
- }
3171
-
3172
- if (data.selected) {
3173
- option.selected = true;
3174
- }
3175
-
3176
- if (data.title) {
3177
- option.title = data.title;
3178
- }
3179
-
3180
- var $option = $(option);
3181
-
3182
- var normalizedData = this._normalizeItem(data);
3183
- normalizedData.element = option;
3184
-
3185
- // Override the option's data with the combined data
3186
- $.data(option, 'data', normalizedData);
3187
-
3188
- return $option;
3189
- };
3190
-
3191
- SelectAdapter.prototype.item = function ($option) {
3192
- var data = {};
3193
-
3194
- data = $.data($option[0], 'data');
3195
-
3196
- if (data != null) {
3197
- return data;
3198
- }
3199
-
3200
- if ($option.is('option')) {
3201
- data = {
3202
- id: $option.val(),
3203
- text: $option.text(),
3204
- disabled: $option.prop('disabled'),
3205
- selected: $option.prop('selected'),
3206
- title: $option.prop('title')
3207
- };
3208
- } else if ($option.is('optgroup')) {
3209
- data = {
3210
- text: $option.prop('label'),
3211
- children: [],
3212
- title: $option.prop('title')
3213
- };
3214
-
3215
- var $children = $option.children('option');
3216
- var children = [];
3217
-
3218
- for (var c = 0; c < $children.length; c++) {
3219
- var $child = $($children[c]);
3220
-
3221
- var child = this.item($child);
3222
-
3223
- children.push(child);
3224
- }
3225
-
3226
- data.children = children;
3227
- }
3228
-
3229
- data = this._normalizeItem(data);
3230
- data.element = $option[0];
3231
-
3232
- $.data($option[0], 'data', data);
3233
-
3234
- return data;
3235
- };
3236
-
3237
- SelectAdapter.prototype._normalizeItem = function (item) {
3238
- if (!$.isPlainObject(item)) {
3239
- item = {
3240
- id: item,
3241
- text: item
3242
- };
3243
- }
3244
-
3245
- item = $.extend({}, {
3246
- text: ''
3247
- }, item);
3248
-
3249
- var defaults = {
3250
- selected: false,
3251
- disabled: false
3252
- };
3253
-
3254
- if (item.id != null) {
3255
- item.id = item.id.toString();
3256
- }
3257
-
3258
- if (item.text != null) {
3259
- item.text = item.text.toString();
3260
- }
3261
-
3262
- if (item._resultId == null && item.id && this.container != null) {
3263
- item._resultId = this.generateResultId(this.container, item);
3264
- }
3265
-
3266
- return $.extend({}, defaults, item);
3267
- };
3268
-
3269
- SelectAdapter.prototype.matches = function (params, data) {
3270
- var matcher = this.options.get('matcher');
3271
-
3272
- return matcher(params, data);
3273
- };
3274
-
3275
- return SelectAdapter;
3276
- });
3277
-
3278
- S2.define('pumselect2/data/array',[
3279
- './select',
3280
- '../utils',
3281
- 'jquery'
3282
- ], function (SelectAdapter, Utils, $) {
3283
- function ArrayAdapter ($element, options) {
3284
- var data = options.get('data') || [];
3285
-
3286
- ArrayAdapter.__super__.constructor.call(this, $element, options);
3287
-
3288
- this.addOptions(this.convertToOptions(data));
3289
- }
3290
-
3291
- Utils.Extend(ArrayAdapter, SelectAdapter);
3292
-
3293
- ArrayAdapter.prototype.select = function (data) {
3294
- var $option = this.$element.find('option').filter(function (i, elm) {
3295
- return elm.value == data.id.toString();
3296
- });
3297
-
3298
- if ($option.length === 0) {
3299
- $option = this.option(data);
3300
-
3301
- this.addOptions($option);
3302
- }
3303
-
3304
- ArrayAdapter.__super__.select.call(this, data);
3305
- };
3306
-
3307
- ArrayAdapter.prototype.convertToOptions = function (data) {
3308
- var self = this;
3309
-
3310
- var $existing = this.$element.find('option');
3311
- var existingIds = $existing.map(function () {
3312
- return self.item($(this)).id;
3313
- }).get();
3314
-
3315
- var $options = [];
3316
-
3317
- // Filter out all items except for the one passed in the argument
3318
- function onlyItem (item) {
3319
- return function () {
3320
- return $(this).val() == item.id;
3321
- };
3322
- }
3323
-
3324
- for (var d = 0; d < data.length; d++) {
3325
- var item = this._normalizeItem(data[d]);
3326
-
3327
- // Skip items which were pre-loaded, only merge the data
3328
- if ($.inArray(item.id, existingIds) >= 0) {
3329
- var $existingOption = $existing.filter(onlyItem(item));
3330
-
3331
- var existingData = this.item($existingOption);
3332
- var newData = $.extend(true, {}, item, existingData);
3333
-
3334
- var $newOption = this.option(newData);
3335
-
3336
- $existingOption.replaceWith($newOption);
3337
-
3338
- continue;
3339
- }
3340
-
3341
- var $option = this.option(item);
3342
-
3343
- if (item.children) {
3344
- var $children = this.convertToOptions(item.children);
3345
-
3346
- Utils.appendMany($option, $children);
3347
- }
3348
-
3349
- $options.push($option);
3350
- }
3351
-
3352
- return $options;
3353
- };
3354
-
3355
- return ArrayAdapter;
3356
- });
3357
-
3358
- S2.define('pumselect2/data/ajax',[
3359
- './array',
3360
- '../utils',
3361
- 'jquery'
3362
- ], function (ArrayAdapter, Utils, $) {
3363
- function AjaxAdapter ($element, options) {
3364
- this.ajaxOptions = this._applyDefaults(options.get('ajax'));
3365
-
3366
- if (this.ajaxOptions.processResults != null) {
3367
- this.processResults = this.ajaxOptions.processResults;
3368
- }
3369
-
3370
- AjaxAdapter.__super__.constructor.call(this, $element, options);
3371
- }
3372
-
3373
- Utils.Extend(AjaxAdapter, ArrayAdapter);
3374
-
3375
- AjaxAdapter.prototype._applyDefaults = function (options) {
3376
- var defaults = {
3377
- data: function (params) {
3378
- return $.extend({}, params, {
3379
- q: params.term
3380
- });
3381
- },
3382
- transport: function (params, success, failure) {
3383
- var $request = $.ajax(params);
3384
-
3385
- $request.then(success);
3386
- $request.fail(failure);
3387
-
3388
- return $request;
3389
- }
3390
- };
3391
-
3392
- return $.extend({}, defaults, options, true);
3393
- };
3394
-
3395
- AjaxAdapter.prototype.processResults = function (results) {
3396
- return results;
3397
- };
3398
-
3399
- AjaxAdapter.prototype.query = function (params, callback) {
3400
- var matches = [];
3401
- var self = this;
3402
-
3403
- if (this._request != null) {
3404
- // JSONP requests cannot always be aborted
3405
- if ($.isFunction(this._request.abort)) {
3406
- this._request.abort();
3407
- }
3408
-
3409
- this._request = null;
3410
- }
3411
-
3412
- var options = $.extend({
3413
- type: 'GET'
3414
- }, this.ajaxOptions);
3415
-
3416
- if (typeof options.url === 'function') {
3417
- options.url = options.url.call(this.$element, params);
3418
- }
3419
-
3420
- if (typeof options.data === 'function') {
3421
- options.data = options.data.call(this.$element, params);
3422
- }
3423
-
3424
- function request () {
3425
- var $request = options.transport(options, function (data) {
3426
- var results = self.processResults(data, params);
3427
-
3428
- if (self.options.get('debug') && window.console && console.error) {
3429
- // Check to make sure that the response included a `results` key.
3430
- if (!results || !results.results || !$.isArray(results.results)) {
3431
- console.error(
3432
- 'Select2: The AJAX results did not return an array in the ' +
3433
- '`results` key of the response.'
3434
- );
3435
- }
3436
- }
3437
-
3438
- callback(results);
3439
- }, function () {
3440
- self.trigger('results:message', {
3441
- message: 'errorLoading'
3442
- });
3443
- });
3444
-
3445
- self._request = $request;
3446
- }
3447
-
3448
- if (this.ajaxOptions.delay && params.term !== '') {
3449
- if (this._queryTimeout) {
3450
- window.clearTimeout(this._queryTimeout);
3451
- }
3452
-
3453
- this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
3454
- } else {
3455
- request();
3456
- }
3457
- };
3458
-
3459
- return AjaxAdapter;
3460
- });
3461
-
3462
- S2.define('pumselect2/data/tags',[
3463
- 'jquery'
3464
- ], function ($) {
3465
- function Tags (decorated, $element, options) {
3466
- var tags = options.get('tags');
3467
-
3468
- var createTag = options.get('createTag');
3469
-
3470
- if (createTag !== undefined) {
3471
- this.createTag = createTag;
3472
- }
3473
-
3474
- var insertTag = options.get('insertTag');
3475
-
3476
- if (insertTag !== undefined) {
3477
- this.insertTag = insertTag;
3478
- }
3479
-
3480
- decorated.call(this, $element, options);
3481
-
3482
- if ($.isArray(tags)) {
3483
- for (var t = 0; t < tags.length; t++) {
3484
- var tag = tags[t];
3485
- var item = this._normalizeItem(tag);
3486
-
3487
- var $option = this.option(item);
3488
-
3489
- this.$element.append($option);
3490
- }
3491
- }
3492
- }
3493
-
3494
- Tags.prototype.query = function (decorated, params, callback) {
3495
- var self = this;
3496
-
3497
- this._removeOldTags();
3498
-
3499
- if (params.term == null || params.page != null) {
3500
- decorated.call(this, params, callback);
3501
- return;
3502
- }
3503
-
3504
- function wrapper (obj, child) {
3505
- var data = obj.results;
3506
-
3507
- for (var i = 0; i < data.length; i++) {
3508
- var option = data[i];
3509
-
3510
- var checkChildren = (
3511
- option.children != null &&
3512
- !wrapper({
3513
- results: option.children
3514
- }, true)
3515
- );
3516
-
3517
- var checkText = option.text === params.term;
3518
-
3519
- if (checkText || checkChildren) {
3520
- if (child) {
3521
- return false;
3522
- }
3523
-
3524
- obj.data = data;
3525
- callback(obj);
3526
-
3527
- return;
3528
- }
3529
- }
3530
-
3531
- if (child) {
3532
- return true;
3533
- }
3534
-
3535
- var tag = self.createTag(params);
3536
-
3537
- if (tag != null) {
3538
- var $option = self.option(tag);
3539
- $option.attr('data-pumselect2-tag', true);
3540
-
3541
- self.addOptions([$option]);
3542
-
3543
- self.insertTag(data, tag);
3544
- }
3545
-
3546
- obj.results = data;
3547
-
3548
- callback(obj);
3549
- }
3550
-
3551
- decorated.call(this, params, wrapper);
3552
- };
3553
-
3554
- Tags.prototype.createTag = function (decorated, params) {
3555
- var term = $.trim(params.term);
3556
-
3557
- if (term === '') {
3558
- return null;
3559
- }
3560
-
3561
- return {
3562
- id: term,
3563
- text: term
3564
- };
3565
- };
3566
-
3567
- Tags.prototype.insertTag = function (_, data, tag) {
3568
- data.unshift(tag);
3569
- };
3570
-
3571
- Tags.prototype._removeOldTags = function (_) {
3572
- var tag = this._lastTag;
3573
-
3574
- var $options = this.$element.find('option[data-pumselect2-tag]');
3575
-
3576
- $options.each(function () {
3577
- if (this.selected) {
3578
- return;
3579
- }
3580
-
3581
- $(this).remove();
3582
- });
3583
- };
3584
-
3585
- return Tags;
3586
- });
3587
-
3588
- S2.define('pumselect2/data/tokenizer',[
3589
- 'jquery'
3590
- ], function ($) {
3591
- function Tokenizer (decorated, $element, options) {
3592
- var tokenizer = options.get('tokenizer');
3593
-
3594
- if (tokenizer !== undefined) {
3595
- this.tokenizer = tokenizer;
3596
- }
3597
-
3598
- decorated.call(this, $element, options);
3599
- }
3600
-
3601
- Tokenizer.prototype.bind = function (decorated, container, $container) {
3602
- decorated.call(this, container, $container);
3603
-
3604
- this.$search = container.dropdown.$search || container.selection.$search ||
3605
- $container.find('.pumselect2-search__field');
3606
- };
3607
-
3608
- Tokenizer.prototype.query = function (decorated, params, callback) {
3609
- var self = this;
3610
-
3611
- function select (data) {
3612
- self.trigger('select', {
3613
- data: data
3614
- });
3615
- }
3616
-
3617
- params.term = params.term || '';
3618
-
3619
- var tokenData = this.tokenizer(params, this.options, select);
3620
-
3621
- if (tokenData.term !== params.term) {
3622
- // Replace the search term if we have the search box
3623
- if (this.$search.length) {
3624
- this.$search.val(tokenData.term);
3625
- this.$search.focus();
3626
- }
3627
-
3628
- params.term = tokenData.term;
3629
- }
3630
-
3631
- decorated.call(this, params, callback);
3632
- };
3633
-
3634
- Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
3635
- var separators = options.get('tokenSeparators') || [];
3636
- var term = params.term;
3637
- var i = 0;
3638
-
3639
- var createTag = this.createTag || function (params) {
3640
- return {
3641
- id: params.term,
3642
- text: params.term
3643
- };
3644
- };
3645
-
3646
- while (i < term.length) {
3647
- var termChar = term[i];
3648
-
3649
- if ($.inArray(termChar, separators) === -1) {
3650
- i++;
3651
-
3652
- continue;
3653
- }
3654
-
3655
- var part = term.substr(0, i);
3656
- var partParams = $.extend({}, params, {
3657
- term: part
3658
- });
3659
-
3660
- var data = createTag(partParams);
3661
-
3662
- if (data == null) {
3663
- i++;
3664
- continue;
3665
- }
3666
-
3667
- callback(data);
3668
-
3669
- // Reset the term to not include the tokenized portion
3670
- term = term.substr(i + 1) || '';
3671
- i = 0;
3672
- }
3673
-
3674
- return {
3675
- term: term
3676
- };
3677
- };
3678
-
3679
- return Tokenizer;
3680
- });
3681
-
3682
- S2.define('pumselect2/data/minimumInputLength',[
3683
-
3684
- ], function () {
3685
- function MinimumInputLength (decorated, $e, options) {
3686
- this.minimumInputLength = options.get('minimumInputLength');
3687
-
3688
- decorated.call(this, $e, options);
3689
- }
3690
-
3691
- MinimumInputLength.prototype.query = function (decorated, params, callback) {
3692
- params.term = params.term || '';
3693
-
3694
- if (params.term.length < this.minimumInputLength) {
3695
- this.trigger('results:message', {
3696
- message: 'inputTooShort',
3697
- args: {
3698
- minimum: this.minimumInputLength,
3699
- input: params.term,
3700
- params: params
3701
- }
3702
- });
3703
-
3704
- return;
3705
- }
3706
-
3707
- decorated.call(this, params, callback);
3708
- };
3709
-
3710
- return MinimumInputLength;
3711
- });
3712
-
3713
- S2.define('pumselect2/data/maximumInputLength',[
3714
-
3715
- ], function () {
3716
- function MaximumInputLength (decorated, $e, options) {
3717
- this.maximumInputLength = options.get('maximumInputLength');
3718
-
3719
- decorated.call(this, $e, options);
3720
- }
3721
-
3722
- MaximumInputLength.prototype.query = function (decorated, params, callback) {
3723
- params.term = params.term || '';
3724
-
3725
- if (this.maximumInputLength > 0 &&
3726
- params.term.length > this.maximumInputLength) {
3727
- this.trigger('results:message', {
3728
- message: 'inputTooLong',
3729
- args: {
3730
- maximum: this.maximumInputLength,
3731
- input: params.term,
3732
- params: params
3733
- }
3734
- });
3735
-
3736
- return;
3737
- }
3738
-
3739
- decorated.call(this, params, callback);
3740
- };
3741
-
3742
- return MaximumInputLength;
3743
- });
3744
-
3745
- S2.define('pumselect2/data/maximumSelectionLength',[
3746
-
3747
- ], function (){
3748
- function MaximumSelectionLength (decorated, $e, options) {
3749
- this.maximumSelectionLength = options.get('maximumSelectionLength');
3750
-
3751
- decorated.call(this, $e, options);
3752
- }
3753
-
3754
- MaximumSelectionLength.prototype.query =
3755
- function (decorated, params, callback) {
3756
- var self = this;
3757
-
3758
- this.current(function (currentData) {
3759
- var count = currentData != null ? currentData.length : 0;
3760
- if (self.maximumSelectionLength > 0 &&
3761
- count >= self.maximumSelectionLength) {
3762
- self.trigger('results:message', {
3763
- message: 'maximumSelected',
3764
- args: {
3765
- maximum: self.maximumSelectionLength
3766
- }
3767
- });
3768
- return;
3769
- }
3770
- decorated.call(self, params, callback);
3771
- });
3772
- };
3773
-
3774
- return MaximumSelectionLength;
3775
- });
3776
-
3777
- S2.define('pumselect2/dropdown',[
3778
- 'jquery',
3779
- './utils'
3780
- ], function ($, Utils) {
3781
- function Dropdown ($element, options) {
3782
- this.$element = $element;
3783
- this.options = options;
3784
-
3785
- Dropdown.__super__.constructor.call(this);
3786
- }
3787
-
3788
- Utils.Extend(Dropdown, Utils.Observable);
3789
-
3790
- Dropdown.prototype.render = function () {
3791
- var $dropdown = $(
3792
- '<span class="pumselect2-dropdown">' +
3793
- '<span class="pumselect2-results"></span>' +
3794
- '</span>'
3795
- );
3796
-
3797
- $dropdown.attr('dir', this.options.get('dir'));
3798
-
3799
- this.$dropdown = $dropdown;
3800
-
3801
- return $dropdown;
3802
- };
3803
-
3804
- Dropdown.prototype.bind = function () {
3805
- // Should be implemented in subclasses
3806
- };
3807
-
3808
- Dropdown.prototype.position = function ($dropdown, $container) {
3809
- // Should be implmented in subclasses
3810
- };
3811
-
3812
- Dropdown.prototype.destroy = function () {
3813
- // Remove the dropdown from the DOM
3814
- this.$dropdown.remove();
3815
- };
3816
-
3817
- return Dropdown;
3818
- });
3819
-
3820
- S2.define('pumselect2/dropdown/search',[
3821
- 'jquery',
3822
- '../utils'
3823
- ], function ($, Utils) {
3824
- function Search () { }
3825
-
3826
- Search.prototype.render = function (decorated) {
3827
- var $rendered = decorated.call(this);
3828
-
3829
- var $search = $(
3830
- '<span class="pumselect2-search pumselect2-search--dropdown">' +
3831
- '<input class="pumselect2-search__field" type="search" tabindex="-1"' +
3832
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
3833
- ' spellcheck="false" role="textbox" />' +
3834
- '</span>'
3835
- );
3836
-
3837
- this.$searchContainer = $search;
3838
- this.$search = $search.find('input');
3839
-
3840
- $rendered.prepend($search);
3841
-
3842
- return $rendered;
3843
- };
3844
-
3845
- Search.prototype.bind = function (decorated, container, $container) {
3846
- var self = this;
3847
-
3848
- decorated.call(this, container, $container);
3849
-
3850
- this.$search.on('keydown', function (evt) {
3851
- self.trigger('keypress', evt);
3852
-
3853
- self._keyUpPrevented = evt.isDefaultPrevented();
3854
- });
3855
-
3856
- // Workaround for browsers which do not support the `input` event
3857
- // This will prevent double-triggering of events for browsers which support
3858
- // both the `keyup` and `input` events.
3859
- this.$search.on('input', function (evt) {
3860
- // Unbind the duplicated `keyup` event
3861
- $(this).off('keyup');
3862
- });
3863
-
3864
- this.$search.on('keyup input', function (evt) {
3865
- self.handleSearch(evt);
3866
- });
3867
-
3868
- container.on('open', function () {
3869
- self.$search.attr('tabindex', 0);
3870
-
3871
- self.$search.focus();
3872
-
3873
- window.setTimeout(function () {
3874
- self.$search.focus();
3875
- }, 0);
3876
- });
3877
-
3878
- container.on('close', function () {
3879
- self.$search.attr('tabindex', -1);
3880
-
3881
- self.$search.val('');
3882
- });
3883
-
3884
- container.on('results:all', function (params) {
3885
- if (params.query.term == null || params.query.term === '') {
3886
- var showSearch = self.showSearch(params);
3887
-
3888
- if (showSearch) {
3889
- self.$searchContainer.removeClass('pumselect2-search--hide');
3890
- } else {
3891
- self.$searchContainer.addClass('pumselect2-search--hide');
3892
- }
3893
- }
3894
- });
3895
- };
3896
-
3897
- Search.prototype.handleSearch = function (evt) {
3898
- if (!this._keyUpPrevented) {
3899
- var input = this.$search.val();
3900
-
3901
- this.trigger('query', {
3902
- term: input
3903
- });
3904
- }
3905
-
3906
- this._keyUpPrevented = false;
3907
- };
3908
-
3909
- Search.prototype.showSearch = function (_, params) {
3910
- return true;
3911
- };
3912
-
3913
- return Search;
3914
- });
3915
-
3916
- S2.define('pumselect2/dropdown/hidePlaceholder',[
3917
-
3918
- ], function () {
3919
- function HidePlaceholder (decorated, $element, options, dataAdapter) {
3920
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
3921
-
3922
- decorated.call(this, $element, options, dataAdapter);
3923
- }
3924
-
3925
- HidePlaceholder.prototype.append = function (decorated, data) {
3926
- data.results = this.removePlaceholder(data.results);
3927
-
3928
- decorated.call(this, data);
3929
- };
3930
-
3931
- HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
3932
- if (typeof placeholder === 'string') {
3933
- placeholder = {
3934
- id: '',
3935
- text: placeholder
3936
- };
3937
- }
3938
-
3939
- return placeholder;
3940
- };
3941
-
3942
- HidePlaceholder.prototype.removePlaceholder = function (_, data) {
3943
- var modifiedData = data.slice(0);
3944
-
3945
- for (var d = data.length - 1; d >= 0; d--) {
3946
- var item = data[d];
3947
-
3948
- if (this.placeholder.id === item.id) {
3949
- modifiedData.splice(d, 1);
3950
- }
3951
- }
3952
-
3953
- return modifiedData;
3954
- };
3955
-
3956
- return HidePlaceholder;
3957
- });
3958
-
3959
- S2.define('pumselect2/dropdown/infiniteScroll',[
3960
- 'jquery'
3961
- ], function ($) {
3962
- function InfiniteScroll (decorated, $element, options, dataAdapter) {
3963
- this.lastParams = {};
3964
-
3965
- decorated.call(this, $element, options, dataAdapter);
3966
-
3967
- this.$loadingMore = this.createLoadingMore();
3968
- this.loading = false;
3969
- }
3970
-
3971
- InfiniteScroll.prototype.append = function (decorated, data) {
3972
- this.$loadingMore.remove();
3973
- this.loading = false;
3974
-
3975
- decorated.call(this, data);
3976
-
3977
- if (this.showLoadingMore(data)) {
3978
- this.$results.append(this.$loadingMore);
3979
- }
3980
- };
3981
-
3982
- InfiniteScroll.prototype.bind = function (decorated, container, $container) {
3983
- var self = this;
3984
-
3985
- decorated.call(this, container, $container);
3986
-
3987
- container.on('query', function (params) {
3988
- self.lastParams = params;
3989
- self.loading = true;
3990
- });
3991
-
3992
- container.on('query:append', function (params) {
3993
- self.lastParams = params;
3994
- self.loading = true;
3995
- });
3996
-
3997
- this.$results.on('scroll', function () {
3998
- var isLoadMoreVisible = $.contains(
3999
- document.documentElement,
4000
- self.$loadingMore[0]
4001
- );
4002
-
4003
- if (self.loading || !isLoadMoreVisible) {
4004
- return;
4005
- }
4006
-
4007
- var currentOffset = self.$results.offset().top +
4008
- self.$results.outerHeight(false);
4009
- var loadingMoreOffset = self.$loadingMore.offset().top +
4010
- self.$loadingMore.outerHeight(false);
4011
-
4012
- if (currentOffset + 50 >= loadingMoreOffset) {
4013
- self.loadMore();
4014
- }
4015
- });
4016
- };
4017
-
4018
- InfiniteScroll.prototype.loadMore = function () {
4019
- this.loading = true;
4020
-
4021
- var params = $.extend({}, {page: 1}, this.lastParams);
4022
-
4023
- params.page++;
4024
-
4025
- this.trigger('query:append', params);
4026
- };
4027
-
4028
- InfiniteScroll.prototype.showLoadingMore = function (_, data) {
4029
- return data.pagination && data.pagination.more;
4030
- };
4031
-
4032
- InfiniteScroll.prototype.createLoadingMore = function () {
4033
- var $option = $(
4034
- '<li ' +
4035
- 'class="pumselect2-results__option pumselect2-results__option--load-more"' +
4036
- 'role="treeitem" aria-disabled="true"></li>'
4037
- );
4038
-
4039
- var message = this.options.get('translations').get('loadingMore');
4040
-
4041
- $option.html(message(this.lastParams));
4042
-
4043
- return $option;
4044
- };
4045
-
4046
- return InfiniteScroll;
4047
- });
4048
-
4049
- S2.define('pumselect2/dropdown/attachBody',[
4050
- 'jquery',
4051
- '../utils'
4052
- ], function ($, Utils) {
4053
- function AttachBody (decorated, $element, options) {
4054
- this.$dropdownParent = options.get('dropdownParent') || $(document.body);
4055
-
4056
- decorated.call(this, $element, options);
4057
- }
4058
-
4059
- AttachBody.prototype.bind = function (decorated, container, $container) {
4060
- var self = this;
4061
-
4062
- var setupResultsEvents = false;
4063
-
4064
- decorated.call(this, container, $container);
4065
-
4066
- container.on('open', function () {
4067
- self._showDropdown();
4068
- self._attachPositioningHandler(container);
4069
-
4070
- if (!setupResultsEvents) {
4071
- setupResultsEvents = true;
4072
-
4073
- container.on('results:all', function () {
4074
- self._positionDropdown();
4075
- self._resizeDropdown();
4076
- });
4077
-
4078
- container.on('results:append', function () {
4079
- self._positionDropdown();
4080
- self._resizeDropdown();
4081
- });
4082
- }
4083
- });
4084
-
4085
- container.on('close', function () {
4086
- self._hideDropdown();
4087
- self._detachPositioningHandler(container);
4088
- });
4089
-
4090
- this.$dropdownContainer.on('mousedown', function (evt) {
4091
- evt.stopPropagation();
4092
- });
4093
- };
4094
-
4095
- AttachBody.prototype.destroy = function (decorated) {
4096
- decorated.call(this);
4097
-
4098
- this.$dropdownContainer.remove();
4099
- };
4100
-
4101
- AttachBody.prototype.position = function (decorated, $dropdown, $container) {
4102
- // Clone all of the container classes
4103
- $dropdown.attr('class', $container.attr('class'));
4104
-
4105
- $dropdown.removeClass('pumselect2');
4106
- $dropdown.addClass('pumselect2-container--open');
4107
-
4108
- $dropdown.css({
4109
- position: 'absolute',
4110
- top: -999999
4111
- });
4112
-
4113
- this.$container = $container;
4114
- };
4115
-
4116
- AttachBody.prototype.render = function (decorated) {
4117
- var $container = $('<span></span>');
4118
-
4119
- var $dropdown = decorated.call(this);
4120
- $container.append($dropdown);
4121
-
4122
- this.$dropdownContainer = $container;
4123
-
4124
- return $container;
4125
- };
4126
-
4127
- AttachBody.prototype._hideDropdown = function (decorated) {
4128
- this.$dropdownContainer.detach();
4129
- };
4130
-
4131
- AttachBody.prototype._attachPositioningHandler =
4132
- function (decorated, container) {
4133
- var self = this;
4134
-
4135
- var scrollEvent = 'scroll.pumselect2.' + container.id;
4136
- var resizeEvent = 'resize.pumselect2.' + container.id;
4137
- var orientationEvent = 'orientationchange.pumselect2.' + container.id;
4138
-
4139
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
4140
- $watchers.each(function () {
4141
- $(this).data('pumselect2-scroll-position', {
4142
- x: $(this).scrollLeft(),
4143
- y: $(this).scrollTop()
4144
- });
4145
- });
4146
-
4147
- $watchers.on(scrollEvent, function (ev) {
4148
- var position = $(this).data('pumselect2-scroll-position');
4149
- $(this).scrollTop(position.y);
4150
- });
4151
-
4152
- $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
4153
- function (e) {
4154
- self._positionDropdown();
4155
- self._resizeDropdown();
4156
- });
4157
- };
4158
-
4159
- AttachBody.prototype._detachPositioningHandler =
4160
- function (decorated, container) {
4161
- var scrollEvent = 'scroll.pumselect2.' + container.id;
4162
- var resizeEvent = 'resize.pumselect2.' + container.id;
4163
- var orientationEvent = 'orientationchange.pumselect2.' + container.id;
4164
-
4165
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
4166
- $watchers.off(scrollEvent);
4167
-
4168
- $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
4169
- };
4170
-
4171
- AttachBody.prototype._positionDropdown = function () {
4172
- var $window = $(window);
4173
-
4174
- var isCurrentlyAbove = this.$dropdown.hasClass('pumselect2-dropdown--above');
4175
- var isCurrentlyBelow = this.$dropdown.hasClass('pumselect2-dropdown--below');
4176
-
4177
- var newDirection = null;
4178
-
4179
- var offset = this.$container.offset();
4180
-
4181
- offset.bottom = offset.top + this.$container.outerHeight(false);
4182
-
4183
- var container = {
4184
- height: this.$container.outerHeight(false)
4185
- };
4186
-
4187
- container.top = offset.top;
4188
- container.bottom = offset.top + container.height;
4189
-
4190
- var dropdown = {
4191
- height: this.$dropdown.outerHeight(false)
4192
- };
4193
-
4194
- var viewport = {
4195
- top: $window.scrollTop(),
4196
- bottom: $window.scrollTop() + $window.height()
4197
- };
4198
-
4199
- var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
4200
- var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
4201
-
4202
- var css = {
4203
- left: offset.left,
4204
- top: container.bottom
4205
- };
4206
-
4207
- // Determine what the parent element is to use for calciulating the offset
4208
- var $offsetParent = this.$dropdownParent;
4209
-
4210
- // For statically positoned elements, we need to get the element
4211
- // that is determining the offset
4212
- if ($offsetParent.css('position') === 'static') {
4213
- $offsetParent = $offsetParent.offsetParent();
4214
- }
4215
-
4216
- var parentOffset = $offsetParent.offset();
4217
-
4218
- css.top -= parentOffset.top;
4219
- css.left -= parentOffset.left;
4220
-
4221
- if (!isCurrentlyAbove && !isCurrentlyBelow) {
4222
- newDirection = 'below';
4223
- }
4224
-
4225
- if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
4226
- newDirection = 'above';
4227
- } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
4228
- newDirection = 'below';
4229
- }
4230
-
4231
- if (newDirection == 'above' ||
4232
- (isCurrentlyAbove && newDirection !== 'below')) {
4233
- css.top = container.top - dropdown.height;
4234
- }
4235
-
4236
- if (newDirection != null) {
4237
- this.$dropdown
4238
- .removeClass('pumselect2-dropdown--below pumselect2-dropdown--above')
4239
- .addClass('pumselect2-dropdown--' + newDirection);
4240
- this.$container
4241
- .removeClass('pumselect2-container--below pumselect2-container--above')
4242
- .addClass('pumselect2-container--' + newDirection);
4243
- }
4244
-
4245
- this.$dropdownContainer.css(css);
4246
- };
4247
-
4248
- AttachBody.prototype._resizeDropdown = function () {
4249
- var css = {
4250
- width: this.$container.outerWidth(false) + 'px'
4251
- };
4252
-
4253
- if (this.options.get('dropdownAutoWidth')) {
4254
- css.minWidth = css.width;
4255
- css.width = 'auto';
4256
- }
4257
-
4258
- this.$dropdown.css(css);
4259
- };
4260
-
4261
- AttachBody.prototype._showDropdown = function (decorated) {
4262
- this.$dropdownContainer.appendTo(this.$dropdownParent);
4263
-
4264
- this._positionDropdown();
4265
- this._resizeDropdown();
4266
- };
4267
-
4268
- return AttachBody;
4269
- });
4270
-
4271
- S2.define('pumselect2/dropdown/minimumResultsForSearch',[
4272
-
4273
- ], function () {
4274
- function countResults (data) {
4275
- var count = 0;
4276
-
4277
- for (var d = 0; d < data.length; d++) {
4278
- var item = data[d];
4279
-
4280
- if (item.children) {
4281
- count += countResults(item.children);
4282
- } else {
4283
- count++;
4284
- }
4285
- }
4286
-
4287
- return count;
4288
- }
4289
-
4290
- function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
4291
- this.minimumResultsForSearch = options.get('minimumResultsForSearch');
4292
-
4293
- if (this.minimumResultsForSearch < 0) {
4294
- this.minimumResultsForSearch = Infinity;
4295
- }
4296
-
4297
- decorated.call(this, $element, options, dataAdapter);
4298
- }
4299
-
4300
- MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
4301
- if (countResults(params.data.results) < this.minimumResultsForSearch) {
4302
- return false;
4303
- }
4304
-
4305
- return decorated.call(this, params);
4306
- };
4307
-
4308
- return MinimumResultsForSearch;
4309
- });
4310
-
4311
- S2.define('pumselect2/dropdown/selectOnClose',[
4312
-
4313
- ], function () {
4314
- function SelectOnClose () { }
4315
-
4316
- SelectOnClose.prototype.bind = function (decorated, container, $container) {
4317
- var self = this;
4318
-
4319
- decorated.call(this, container, $container);
4320
-
4321
- container.on('close', function () {
4322
- self._handleSelectOnClose();
4323
- });
4324
- };
4325
-
4326
- SelectOnClose.prototype._handleSelectOnClose = function () {
4327
- var $highlightedResults = this.getHighlightedResults();
4328
-
4329
- // Only select highlighted results
4330
- if ($highlightedResults.length < 1) {
4331
- return;
4332
- }
4333
-
4334
- var data = $highlightedResults.data('data');
4335
-
4336
- // Don't re-select already selected resulte
4337
- if (
4338
- (data.element != null && data.element.selected) ||
4339
- (data.element == null && data.selected)
4340
- ) {
4341
- return;
4342
- }
4343
-
4344
- this.trigger('select', {
4345
- data: data
4346
- });
4347
- };
4348
-
4349
- return SelectOnClose;
4350
- });
4351
-
4352
- S2.define('pumselect2/dropdown/closeOnSelect',[
4353
-
4354
- ], function () {
4355
- function CloseOnSelect () { }
4356
-
4357
- CloseOnSelect.prototype.bind = function (decorated, container, $container) {
4358
- var self = this;
4359
-
4360
- decorated.call(this, container, $container);
4361
-
4362
- container.on('select', function (evt) {
4363
- self._selectTriggered(evt);
4364
- });
4365
-
4366
- container.on('unselect', function (evt) {
4367
- self._selectTriggered(evt);
4368
- });
4369
- };
4370
-
4371
- CloseOnSelect.prototype._selectTriggered = function (_, evt) {
4372
- var originalEvent = evt.originalEvent;
4373
-
4374
- // Don't close if the control key is being held
4375
- if (originalEvent && originalEvent.ctrlKey) {
4376
- return;
4377
- }
4378
-
4379
- this.trigger('close', {});
4380
- };
4381
-
4382
- return CloseOnSelect;
4383
- });
4384
-
4385
- S2.define('pumselect2/i18n/en',[],function () {
4386
- // English
4387
- return {
4388
- errorLoading: function () {
4389
- return 'The results could not be loaded.';
4390
- },
4391
- inputTooLong: function (args) {
4392
- var overChars = args.input.length - args.maximum;
4393
-
4394
- var message = 'Please delete ' + overChars + ' character';
4395
-
4396
- if (overChars != 1) {
4397
- message += 's';
4398
- }
4399
-
4400
- return message;
4401
- },
4402
- inputTooShort: function (args) {
4403
- var remainingChars = args.minimum - args.input.length;
4404
-
4405
- var message = 'Please enter ' + remainingChars + ' or more characters';
4406
-
4407
- return message;
4408
- },
4409
- loadingMore: function () {
4410
- return 'Loading more results…';
4411
- },
4412
- maximumSelected: function (args) {
4413
- var message = 'You can only select ' + args.maximum + ' item';
4414
-
4415
- if (args.maximum != 1) {
4416
- message += 's';
4417
- }
4418
-
4419
- return message;
4420
- },
4421
- noResults: function () {
4422
- return 'No results found';
4423
- },
4424
- searching: function () {
4425
- return 'Searching…';
4426
- }
4427
- };
4428
- });
4429
-
4430
- S2.define('pumselect2/defaults',[
4431
- 'jquery',
4432
- 'require',
4433
-
4434
- './results',
4435
-
4436
- './selection/single',
4437
- './selection/multiple',
4438
- './selection/placeholder',
4439
- './selection/allowClear',
4440
- './selection/search',
4441
- './selection/eventRelay',
4442
-
4443
- './utils',
4444
- './translation',
4445
- './diacritics',
4446
-
4447
- './data/select',
4448
- './data/array',
4449
- './data/ajax',
4450
- './data/tags',
4451
- './data/tokenizer',
4452
- './data/minimumInputLength',
4453
- './data/maximumInputLength',
4454
- './data/maximumSelectionLength',
4455
-
4456
- './dropdown',
4457
- './dropdown/search',
4458
- './dropdown/hidePlaceholder',
4459
- './dropdown/infiniteScroll',
4460
- './dropdown/attachBody',
4461
- './dropdown/minimumResultsForSearch',
4462
- './dropdown/selectOnClose',
4463
- './dropdown/closeOnSelect',
4464
-
4465
- './i18n/en'
4466
- ], function ($, require,
4467
-
4468
- ResultsList,
4469
-
4470
- SingleSelection, MultipleSelection, Placeholder, AllowClear,
4471
- SelectionSearch, EventRelay,
4472
-
4473
- Utils, Translation, DIACRITICS,
4474
-
4475
- SelectData, ArrayData, AjaxData, Tags, Tokenizer,
4476
- MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
4477
-
4478
- Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
4479
- AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
4480
-
4481
- EnglishTranslation) {
4482
- function Defaults () {
4483
- this.reset();
4484
- }
4485
-
4486
- Defaults.prototype.apply = function (options) {
4487
- options = $.extend(true, {}, this.defaults, options);
4488
-
4489
- if (options.dataAdapter == null) {
4490
- if (options.ajax != null) {
4491
- options.dataAdapter = AjaxData;
4492
- } else if (options.data != null) {
4493
- options.dataAdapter = ArrayData;
4494
- } else {
4495
- options.dataAdapter = SelectData;
4496
- }
4497
-
4498
- if (options.minimumInputLength > 0) {
4499
- options.dataAdapter = Utils.Decorate(
4500
- options.dataAdapter,
4501
- MinimumInputLength
4502
- );
4503
- }
4504
-
4505
- if (options.maximumInputLength > 0) {
4506
- options.dataAdapter = Utils.Decorate(
4507
- options.dataAdapter,
4508
- MaximumInputLength
4509
- );
4510
- }
4511
-
4512
- if (options.maximumSelectionLength > 0) {
4513
- options.dataAdapter = Utils.Decorate(
4514
- options.dataAdapter,
4515
- MaximumSelectionLength
4516
- );
4517
- }
4518
-
4519
- if (options.tags) {
4520
- options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
4521
- }
4522
-
4523
- if (options.tokenSeparators != null || options.tokenizer != null) {
4524
- options.dataAdapter = Utils.Decorate(
4525
- options.dataAdapter,
4526
- Tokenizer
4527
- );
4528
- }
4529
-
4530
- if (options.query != null) {
4531
- var Query = require(options.amdBase + 'compat/query');
4532
-
4533
- options.dataAdapter = Utils.Decorate(
4534
- options.dataAdapter,
4535
- Query
4536
- );
4537
- }
4538
-
4539
- if (options.initSelection != null) {
4540
- var InitSelection = require(options.amdBase + 'compat/initSelection');
4541
-
4542
- options.dataAdapter = Utils.Decorate(
4543
- options.dataAdapter,
4544
- InitSelection
4545
- );
4546
- }
4547
- }
4548
-
4549
- if (options.resultsAdapter == null) {
4550
- options.resultsAdapter = ResultsList;
4551
-
4552
- if (options.ajax != null) {
4553
- options.resultsAdapter = Utils.Decorate(
4554
- options.resultsAdapter,
4555
- InfiniteScroll
4556
- );
4557
- }
4558
-
4559
- if (options.placeholder != null) {
4560
- options.resultsAdapter = Utils.Decorate(
4561
- options.resultsAdapter,
4562
- HidePlaceholder
4563
- );
4564
- }
4565
-
4566
- if (options.selectOnClose) {
4567
- options.resultsAdapter = Utils.Decorate(
4568
- options.resultsAdapter,
4569
- SelectOnClose
4570
- );
4571
- }
4572
- }
4573
-
4574
- if (options.dropdownAdapter == null) {
4575
- if (options.multiple) {
4576
- options.dropdownAdapter = Dropdown;
4577
- } else {
4578
- var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
4579
-
4580
- options.dropdownAdapter = SearchableDropdown;
4581
- }
4582
-
4583
- if (options.minimumResultsForSearch !== 0) {
4584
- options.dropdownAdapter = Utils.Decorate(
4585
- options.dropdownAdapter,
4586
- MinimumResultsForSearch
4587
- );
4588
- }
4589
-
4590
- if (options.closeOnSelect) {
4591
- options.dropdownAdapter = Utils.Decorate(
4592
- options.dropdownAdapter,
4593
- CloseOnSelect
4594
- );
4595
- }
4596
-
4597
- if (
4598
- options.dropdownCssClass != null ||
4599
- options.dropdownCss != null ||
4600
- options.adaptDropdownCssClass != null
4601
- ) {
4602
- var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
4603
-
4604
- options.dropdownAdapter = Utils.Decorate(
4605
- options.dropdownAdapter,
4606
- DropdownCSS
4607
- );
4608
- }
4609
-
4610
- options.dropdownAdapter = Utils.Decorate(
4611
- options.dropdownAdapter,
4612
- AttachBody
4613
- );
4614
- }
4615
-
4616
- if (options.selectionAdapter == null) {
4617
- if (options.multiple) {
4618
- options.selectionAdapter = MultipleSelection;
4619
- } else {
4620
- options.selectionAdapter = SingleSelection;
4621
- }
4622
-
4623
- // Add the placeholder mixin if a placeholder was specified
4624
- if (options.placeholder != null) {
4625
- options.selectionAdapter = Utils.Decorate(
4626
- options.selectionAdapter,
4627
- Placeholder
4628
- );
4629
- }
4630
-
4631
- if (options.allowClear) {
4632
- options.selectionAdapter = Utils.Decorate(
4633
- options.selectionAdapter,
4634
- AllowClear
4635
- );
4636
- }
4637
-
4638
- if (options.multiple) {
4639
- options.selectionAdapter = Utils.Decorate(
4640
- options.selectionAdapter,
4641
- SelectionSearch
4642
- );
4643
- }
4644
-
4645
- if (
4646
- options.containerCssClass != null ||
4647
- options.containerCss != null ||
4648
- options.adaptContainerCssClass != null
4649
- ) {
4650
- var ContainerCSS = require(options.amdBase + 'compat/containerCss');
4651
-
4652
- options.selectionAdapter = Utils.Decorate(
4653
- options.selectionAdapter,
4654
- ContainerCSS
4655
- );
4656
- }
4657
-
4658
- options.selectionAdapter = Utils.Decorate(
4659
- options.selectionAdapter,
4660
- EventRelay
4661
- );
4662
- }
4663
-
4664
- if (typeof options.language === 'string') {
4665
- // Check if the language is specified with a region
4666
- if (options.language.indexOf('-') > 0) {
4667
- // Extract the region information if it is included
4668
- var languageParts = options.language.split('-');
4669
- var baseLanguage = languageParts[0];
4670
-
4671
- options.language = [options.language, baseLanguage];
4672
- } else {
4673
- options.language = [options.language];
4674
- }
4675
- }
4676
-
4677
- if ($.isArray(options.language)) {
4678
- var languages = new Translation();
4679
- options.language.push('en');
4680
-
4681
- var languageNames = options.language;
4682
-
4683
- for (var l = 0; l < languageNames.length; l++) {
4684
- var name = languageNames[l];
4685
- var language = {};
4686
-
4687
- try {
4688
- // Try to load it with the original name
4689
- language = Translation.loadPath(name);
4690
- } catch (e) {
4691
- try {
4692
- // If we couldn't load it, check if it wasn't the full path
4693
- name = this.defaults.amdLanguageBase + name;
4694
- language = Translation.loadPath(name);
4695
- } catch (ex) {
4696
- // The translation could not be loaded at all. Sometimes this is
4697
- // because of a configuration problem, other times this can be
4698
- // because of how Select2 helps load all possible translation files.
4699
- if (options.debug && window.console && console.warn) {
4700
- console.warn(
4701
- 'Select2: The language file for "' + name + '" could not be ' +
4702
- 'automatically loaded. A fallback will be used instead.'
4703
- );
4704
- }
4705
-
4706
- continue;
4707
- }
4708
- }
4709
-
4710
- languages.extend(language);
4711
- }
4712
-
4713
- options.translations = languages;
4714
- } else {
4715
- var baseTranslation = Translation.loadPath(
4716
- this.defaults.amdLanguageBase + 'en'
4717
- );
4718
- var customTranslation = new Translation(options.language);
4719
-
4720
- customTranslation.extend(baseTranslation);
4721
-
4722
- options.translations = customTranslation;
4723
- }
4724
-
4725
- return options;
4726
- };
4727
-
4728
- Defaults.prototype.reset = function () {
4729
- function stripDiacritics (text) {
4730
- // Used 'uni range + named function' from http://jsperf.com/diacritics/18
4731
- function match(a) {
4732
- return DIACRITICS[a] || a;
4733
- }
4734
-
4735
- return text.replace(/[^\u0000-\u007E]/g, match);
4736
- }
4737
-
4738
- function matcher (params, data) {
4739
- // Always return the object if there is nothing to compare
4740
- if ($.trim(params.term) === '') {
4741
- return data;
4742
- }
4743
-
4744
- // Do a recursive check for options with children
4745
- if (data.children && data.children.length > 0) {
4746
- // Clone the data object if there are children
4747
- // This is required as we modify the object to remove any non-matches
4748
- var match = $.extend(true, {}, data);
4749
-
4750
- // Check each child of the option
4751
- for (var c = data.children.length - 1; c >= 0; c--) {
4752
- var child = data.children[c];
4753
-
4754
- var matches = matcher(params, child);
4755
-
4756
- // If there wasn't a match, remove the object in the array
4757
- if (matches == null) {
4758
- match.children.splice(c, 1);
4759
- }
4760
- }
4761
-
4762
- // If any children matched, return the new object
4763
- if (match.children.length > 0) {
4764
- return match;
4765
- }
4766
-
4767
- // If there were no matching children, check just the plain object
4768
- return matcher(params, match);
4769
- }
4770
-
4771
- var original = stripDiacritics(data.text).toUpperCase();
4772
- var term = stripDiacritics(params.term).toUpperCase();
4773
-
4774
- // Check if the text contains the term
4775
- if (original.indexOf(term) > -1) {
4776
- return data;
4777
- }
4778
-
4779
- // If it doesn't contain the term, don't return anything
4780
- return null;
4781
- }
4782
-
4783
- this.defaults = {
4784
- amdBase: './',
4785
- amdLanguageBase: './i18n/',
4786
- closeOnSelect: true,
4787
- debug: false,
4788
- dropdownAutoWidth: false,
4789
- escapeMarkup: Utils.escapeMarkup,
4790
- language: EnglishTranslation,
4791
- matcher: matcher,
4792
- minimumInputLength: 0,
4793
- maximumInputLength: 0,
4794
- maximumSelectionLength: 0,
4795
- minimumResultsForSearch: 0,
4796
- selectOnClose: false,
4797
- sorter: function (data) {
4798
- return data;
4799
- },
4800
- templateResult: function (result) {
4801
- return result.text;
4802
- },
4803
- templateSelection: function (selection) {
4804
- return selection.text;
4805
- },
4806
- theme: 'default',
4807
- width: 'resolve'
4808
- };
4809
- };
4810
-
4811
- Defaults.prototype.set = function (key, value) {
4812
- var camelKey = $.camelCase(key);
4813
-
4814
- var data = {};
4815
- data[camelKey] = value;
4816
-
4817
- var convertedData = Utils._convertData(data);
4818
-
4819
- $.extend(this.defaults, convertedData);
4820
- };
4821
-
4822
- var defaults = new Defaults();
4823
-
4824
- return defaults;
4825
- });
4826
-
4827
- S2.define('pumselect2/options',[
4828
- 'require',
4829
- 'jquery',
4830
- './defaults',
4831
- './utils'
4832
- ], function (require, $, Defaults, Utils) {
4833
- function Options (options, $element) {
4834
- this.options = options;
4835
-
4836
- if ($element != null) {
4837
- this.fromElement($element);
4838
- }
4839
-
4840
- this.options = Defaults.apply(this.options);
4841
-
4842
- if ($element && $element.is('input')) {
4843
- var InputCompat = require(this.get('amdBase') + 'compat/inputData');
4844
-
4845
- this.options.dataAdapter = Utils.Decorate(
4846
- this.options.dataAdapter,
4847
- InputCompat
4848
- );
4849
- }
4850
- }
4851
-
4852
- Options.prototype.fromElement = function ($e) {
4853
- var excludedData = ['pumselect2'];
4854
-
4855
- if (this.options.multiple == null) {
4856
- this.options.multiple = $e.prop('multiple');
4857
- }
4858
-
4859
- if (this.options.disabled == null) {
4860
- this.options.disabled = $e.prop('disabled');
4861
- }
4862
-
4863
- if (this.options.language == null) {
4864
- if ($e.prop('lang')) {
4865
- this.options.language = $e.prop('lang').toLowerCase();
4866
- } else if ($e.closest('[lang]').prop('lang')) {
4867
- this.options.language = $e.closest('[lang]').prop('lang');
4868
- }
4869
- }
4870
-
4871
- if (this.options.dir == null) {
4872
- if ($e.prop('dir')) {
4873
- this.options.dir = $e.prop('dir');
4874
- } else if ($e.closest('[dir]').prop('dir')) {
4875
- this.options.dir = $e.closest('[dir]').prop('dir');
4876
- } else {
4877
- this.options.dir = 'ltr';
4878
- }
4879
- }
4880
-
4881
- $e.prop('disabled', this.options.disabled);
4882
- $e.prop('multiple', this.options.multiple);
4883
-
4884
- if ($e.data('pumselect2Tags')) {
4885
- if (this.options.debug && window.console && console.warn) {
4886
- console.warn(
4887
- 'Select2: The `data-pumselect2-tags` attribute has been changed to ' +
4888
- 'use the `data-data` and `data-tags="true"` attributes and will be ' +
4889
- 'removed in future versions of Select2.'
4890
- );
4891
- }
4892
-
4893
- $e.data('data', $e.data('pumselect2Tags'));
4894
- $e.data('tags', true);
4895
- }
4896
-
4897
- if ($e.data('ajaxUrl')) {
4898
- if (this.options.debug && window.console && console.warn) {
4899
- console.warn(
4900
- 'Select2: The `data-ajax-url` attribute has been changed to ' +
4901
- '`data-ajax--url` and support for the old attribute will be removed' +
4902
- ' in future versions of Select2.'
4903
- );
4904
- }
4905
-
4906
- $e.attr('ajax--url', $e.data('ajaxUrl'));
4907
- $e.data('ajax--url', $e.data('ajaxUrl'));
4908
- }
4909
-
4910
- var dataset = {};
4911
-
4912
- // Prefer the element's `dataset` attribute if it exists
4913
- // jQuery 1.x does not correctly handle data attributes with multiple dashes
4914
- if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
4915
- dataset = $.extend(true, {}, $e[0].dataset, $e.data());
4916
- } else {
4917
- dataset = $e.data();
4918
- }
4919
-
4920
- var data = $.extend(true, {}, dataset);
4921
-
4922
- data = Utils._convertData(data);
4923
-
4924
- for (var key in data) {
4925
- if ($.inArray(key, excludedData) > -1) {
4926
- continue;
4927
- }
4928
-
4929
- if ($.isPlainObject(this.options[key])) {
4930
- $.extend(this.options[key], data[key]);
4931
- } else {
4932
- this.options[key] = data[key];
4933
- }
4934
- }
4935
-
4936
- return this;
4937
- };
4938
-
4939
- Options.prototype.get = function (key) {
4940
- return this.options[key];
4941
- };
4942
-
4943
- Options.prototype.set = function (key, val) {
4944
- this.options[key] = val;
4945
- };
4946
-
4947
- return Options;
4948
- });
4949
-
4950
- S2.define('pumselect2/core',[
4951
- 'jquery',
4952
- './options',
4953
- './utils',
4954
- './keys'
4955
- ], function ($, Options, Utils, KEYS) {
4956
- var Select2 = function ($element, options) {
4957
- if ($element.data('pumselect2') != null) {
4958
- $element.data('pumselect2').destroy();
4959
- }
4960
-
4961
- this.$element = $element;
4962
-
4963
- this.id = this._generateId($element);
4964
-
4965
- options = options || {};
4966
-
4967
- this.options = new Options(options, $element);
4968
-
4969
- Select2.__super__.constructor.call(this);
4970
-
4971
- // Set up the tabindex
4972
-
4973
- var tabindex = $element.attr('tabindex') || 0;
4974
- $element.data('old-tabindex', tabindex);
4975
- $element.attr('tabindex', '-1');
4976
-
4977
- // Set up containers and adapters
4978
-
4979
- var DataAdapter = this.options.get('dataAdapter');
4980
- this.dataAdapter = new DataAdapter($element, this.options);
4981
-
4982
- var $container = this.render();
4983
-
4984
- this._placeContainer($container);
4985
-
4986
- var SelectionAdapter = this.options.get('selectionAdapter');
4987
- this.selection = new SelectionAdapter($element, this.options);
4988
- this.$selection = this.selection.render();
4989
-
4990
- this.selection.position(this.$selection, $container);
4991
-
4992
- var DropdownAdapter = this.options.get('dropdownAdapter');
4993
- this.dropdown = new DropdownAdapter($element, this.options);
4994
- this.$dropdown = this.dropdown.render();
4995
-
4996
- this.dropdown.position(this.$dropdown, $container);
4997
-
4998
- var ResultsAdapter = this.options.get('resultsAdapter');
4999
- this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
5000
- this.$results = this.results.render();
5001
-
5002
- this.results.position(this.$results, this.$dropdown);
5003
-
5004
- // Bind events
5005
-
5006
- var self = this;
5007
-
5008
- // Bind the container to all of the adapters
5009
- this._bindAdapters();
5010
-
5011
- // Register any DOM event handlers
5012
- this._registerDomEvents();
5013
-
5014
- // Register any internal event handlers
5015
- this._registerDataEvents();
5016
- this._registerSelectionEvents();
5017
- this._registerDropdownEvents();
5018
- this._registerResultsEvents();
5019
- this._registerEvents();
5020
-
5021
- // Set the initial state
5022
- this.dataAdapter.current(function (initialData) {
5023
- self.trigger('selection:update', {
5024
- data: initialData
5025
- });
5026
- });
5027
-
5028
- // Hide the original select
5029
- $element.addClass('pumselect2-hidden-accessible');
5030
- $element.attr('aria-hidden', 'true');
5031
-
5032
- // Synchronize any monitored attributes
5033
- this._syncAttributes();
5034
-
5035
- $element.data('pumselect2', this);
5036
- };
5037
-
5038
- Utils.Extend(Select2, Utils.Observable);
5039
-
5040
- Select2.prototype._generateId = function ($element) {
5041
- var id = '';
5042
-
5043
- if ($element.attr('id') != null) {
5044
- id = $element.attr('id');
5045
- } else if ($element.attr('name') != null) {
5046
- id = $element.attr('name') + '-' + Utils.generateChars(2);
5047
- } else {
5048
- id = Utils.generateChars(4);
5049
- }
5050
-
5051
- id = id.replace(/(:|\.|\[|\]|,)/g, '');
5052
- id = 'pumselect2-' + id;
5053
-
5054
- return id;
5055
- };
5056
-
5057
- Select2.prototype._placeContainer = function ($container) {
5058
- $container.insertAfter(this.$element);
5059
-
5060
- var width = this._resolveWidth(this.$element, this.options.get('width'));
5061
-
5062
- if (width != null) {
5063
- $container.css('width', width);
5064
- }
5065
- };
5066
-
5067
- Select2.prototype._resolveWidth = function ($element, method) {
5068
- var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
5069
-
5070
- if (method == 'resolve') {
5071
- var styleWidth = this._resolveWidth($element, 'style');
5072
-
5073
- if (styleWidth != null) {
5074
- return styleWidth;
5075
- }
5076
-
5077
- return this._resolveWidth($element, 'element');
5078
- }
5079
-
5080
- if (method == 'element') {
5081
- var elementWidth = $element.outerWidth(false);
5082
-
5083
- if (elementWidth <= 0) {
5084
- return 'auto';
5085
- }
5086
-
5087
- return elementWidth + 'px';
5088
- }
5089
-
5090
- if (method == 'style') {
5091
- var style = $element.attr('style');
5092
-
5093
- if (typeof(style) !== 'string') {
5094
- return null;
5095
- }
5096
-
5097
- var attrs = style.split(';');
5098
-
5099
- for (var i = 0, l = attrs.length; i < l; i = i + 1) {
5100
- var attr = attrs[i].replace(/\s/g, '');
5101
- var matches = attr.match(WIDTH);
5102
-
5103
- if (matches !== null && matches.length >= 1) {
5104
- return matches[1];
5105
- }
5106
- }
5107
-
5108
- return null;
5109
- }
5110
-
5111
- return method;
5112
- };
5113
-
5114
- Select2.prototype._bindAdapters = function () {
5115
- this.dataAdapter.bind(this, this.$container);
5116
- this.selection.bind(this, this.$container);
5117
-
5118
- this.dropdown.bind(this, this.$container);
5119
- this.results.bind(this, this.$container);
5120
- };
5121
-
5122
- Select2.prototype._registerDomEvents = function () {
5123
- var self = this;
5124
-
5125
- this.$element.on('change.pumselect2', function () {
5126
- self.dataAdapter.current(function (data) {
5127
- self.trigger('selection:update', {
5128
- data: data
5129
- });
5130
- });
5131
- });
5132
-
5133
- this._sync = Utils.bind(this._syncAttributes, this);
5134
-
5135
- if (this.$element[0].attachEvent) {
5136
- this.$element[0].attachEvent('onpropertychange', this._sync);
5137
- }
5138
-
5139
- var observer = window.MutationObserver ||
5140
- window.WebKitMutationObserver ||
5141
- window.MozMutationObserver
5142
- ;
5143
-
5144
- if (observer != null) {
5145
- this._observer = new observer(function (mutations) {
5146
- $.each(mutations, self._sync);
5147
- });
5148
- this._observer.observe(this.$element[0], {
5149
- attributes: true,
5150
- subtree: false
5151
- });
5152
- } else if (this.$element[0].addEventListener) {
5153
- this.$element[0].addEventListener('DOMAttrModified', self._sync, false);
5154
- }
5155
- };
5156
-
5157
- Select2.prototype._registerDataEvents = function () {
5158
- var self = this;
5159
-
5160
- this.dataAdapter.on('*', function (name, params) {
5161
- self.trigger(name, params);
5162
- });
5163
- };
5164
-
5165
- Select2.prototype._registerSelectionEvents = function () {
5166
- var self = this;
5167
- var nonRelayEvents = ['toggle', 'focus'];
5168
-
5169
- this.selection.on('toggle', function () {
5170
- self.toggleDropdown();
5171
- });
5172
-
5173
- this.selection.on('focus', function (params) {
5174
- self.focus(params);
5175
- });
5176
-
5177
- this.selection.on('*', function (name, params) {
5178
- if ($.inArray(name, nonRelayEvents) !== -1) {
5179
- return;
5180
- }
5181
-
5182
- self.trigger(name, params);
5183
- });
5184
- };
5185
-
5186
- Select2.prototype._registerDropdownEvents = function () {
5187
- var self = this;
5188
-
5189
- this.dropdown.on('*', function (name, params) {
5190
- self.trigger(name, params);
5191
- });
5192
- };
5193
-
5194
- Select2.prototype._registerResultsEvents = function () {
5195
- var self = this;
5196
-
5197
- this.results.on('*', function (name, params) {
5198
- self.trigger(name, params);
5199
- });
5200
- };
5201
-
5202
- Select2.prototype._registerEvents = function () {
5203
- var self = this;
5204
-
5205
- this.on('open', function () {
5206
- self.$container.addClass('pumselect2-container--open');
5207
- });
5208
-
5209
- this.on('close', function () {
5210
- self.$container.removeClass('pumselect2-container--open');
5211
- });
5212
-
5213
- this.on('enable', function () {
5214
- self.$container.removeClass('pumselect2-container--disabled');
5215
- });
5216
-
5217
- this.on('disable', function () {
5218
- self.$container.addClass('pumselect2-container--disabled');
5219
- });
5220
-
5221
- this.on('blur', function () {
5222
- self.$container.removeClass('pumselect2-container--focus');
5223
- });
5224
-
5225
- this.on('query', function (params) {
5226
- if (!self.isOpen()) {
5227
- self.trigger('open', {});
5228
- }
5229
-
5230
- this.dataAdapter.query(params, function (data) {
5231
- self.trigger('results:all', {
5232
- data: data,
5233
- query: params
5234
- });
5235
- });
5236
- });
5237
-
5238
- this.on('query:append', function (params) {
5239
- this.dataAdapter.query(params, function (data) {
5240
- self.trigger('results:append', {
5241
- data: data,
5242
- query: params
5243
- });
5244
- });
5245
- });
5246
-
5247
- this.on('keypress', function (evt) {
5248
- var key = evt.which;
5249
-
5250
- if (self.isOpen()) {
5251
- if (key === KEYS.ESC || key === KEYS.TAB ||
5252
- (key === KEYS.UP && evt.altKey)) {
5253
- self.close();
5254
-
5255
- evt.preventDefault();
5256
- } else if (key === KEYS.ENTER) {
5257
- self.trigger('results:select', {});
5258
-
5259
- evt.preventDefault();
5260
- } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
5261
- self.trigger('results:toggle', {});
5262
-
5263
- evt.preventDefault();
5264
- } else if (key === KEYS.UP) {
5265
- self.trigger('results:previous', {});
5266
-
5267
- evt.preventDefault();
5268
- } else if (key === KEYS.DOWN) {
5269
- self.trigger('results:next', {});
5270
-
5271
- evt.preventDefault();
5272
- }
5273
- } else {
5274
- if (key === KEYS.ENTER || key === KEYS.SPACE ||
5275
- (key === KEYS.DOWN && evt.altKey)) {
5276
- self.open();
5277
-
5278
- evt.preventDefault();
5279
- }
5280
- }
5281
- });
5282
- };
5283
-
5284
- Select2.prototype._syncAttributes = function () {
5285
- this.options.set('disabled', this.$element.prop('disabled'));
5286
-
5287
- if (this.options.get('disabled')) {
5288
- if (this.isOpen()) {
5289
- this.close();
5290
- }
5291
-
5292
- this.trigger('disable', {});
5293
- } else {
5294
- this.trigger('enable', {});
5295
- }
5296
- };
5297
-
5298
- /**
5299
- * Override the trigger method to automatically trigger pre-events when
5300
- * there are events that can be prevented.
5301
- */
5302
- Select2.prototype.trigger = function (name, args) {
5303
- var actualTrigger = Select2.__super__.trigger;
5304
- var preTriggerMap = {
5305
- 'open': 'opening',
5306
- 'close': 'closing',
5307
- 'select': 'selecting',
5308
- 'unselect': 'unselecting'
5309
- };
5310
-
5311
- if (args === undefined) {
5312
- args = {};
5313
- }
5314
-
5315
- if (name in preTriggerMap) {
5316
- var preTriggerName = preTriggerMap[name];
5317
- var preTriggerArgs = {
5318
- prevented: false,
5319
- name: name,
5320
- args: args
5321
- };
5322
-
5323
- actualTrigger.call(this, preTriggerName, preTriggerArgs);
5324
-
5325
- if (preTriggerArgs.prevented) {
5326
- args.prevented = true;
5327
-
5328
- return;
5329
- }
5330
- }
5331
-
5332
- actualTrigger.call(this, name, args);
5333
- };
5334
-
5335
- Select2.prototype.toggleDropdown = function () {
5336
- if (this.options.get('disabled')) {
5337
- return;
5338
- }
5339
-
5340
- if (this.isOpen()) {
5341
- this.close();
5342
- } else {
5343
- this.open();
5344
- }
5345
- };
5346
-
5347
- Select2.prototype.open = function () {
5348
- if (this.isOpen()) {
5349
- return;
5350
- }
5351
-
5352
- this.trigger('query', {});
5353
- };
5354
-
5355
- Select2.prototype.close = function () {
5356
- if (!this.isOpen()) {
5357
- return;
5358
- }
5359
-
5360
- this.trigger('close', {});
5361
- };
5362
-
5363
- Select2.prototype.isOpen = function () {
5364
- return this.$container.hasClass('pumselect2-container--open');
5365
- };
5366
-
5367
- Select2.prototype.hasFocus = function () {
5368
- return this.$container.hasClass('pumselect2-container--focus');
5369
- };
5370
-
5371
- Select2.prototype.focus = function (data) {
5372
- // No need to re-trigger focus events if we are already focused
5373
- if (this.hasFocus()) {
5374
- return;
5375
- }
5376
-
5377
- this.$container.addClass('pumselect2-container--focus');
5378
- this.trigger('focus', {});
5379
- };
5380
-
5381
- Select2.prototype.enable = function (args) {
5382
- if (this.options.get('debug') && window.console && console.warn) {
5383
- console.warn(
5384
- 'Select2: The `pumselect2("enable")` method has been deprecated and will' +
5385
- ' be removed in later Select2 versions. Use $element.prop("disabled")' +
5386
- ' instead.'
5387
- );
5388
- }
5389
-
5390
- if (args == null || args.length === 0) {
5391
- args = [true];
5392
- }
5393
-
5394
- var disabled = !args[0];
5395
-
5396
- this.$element.prop('disabled', disabled);
5397
- };
5398
-
5399
- Select2.prototype.data = function () {
5400
- if (this.options.get('debug') &&
5401
- arguments.length > 0 && window.console && console.warn) {
5402
- console.warn(
5403
- 'Select2: Data can no longer be set using `pumselect2("data")`. You ' +
5404
- 'should consider setting the value instead using `$element.val()`.'
5405
- );
5406
- }
5407
-
5408
- var data = [];
5409
-
5410
- this.dataAdapter.current(function (currentData) {
5411
- data = currentData;
5412
- });
5413
-
5414
- return data;
5415
- };
5416
-
5417
- Select2.prototype.val = function (args) {
5418
- if (this.options.get('debug') && window.console && console.warn) {
5419
- console.warn(
5420
- 'Select2: The `pumselect2("val")` method has been deprecated and will be' +
5421
- ' removed in later Select2 versions. Use $element.val() instead.'
5422
- );
5423
- }
5424
-
5425
- if (args == null || args.length === 0) {
5426
- return this.$element.val();
5427
- }
5428
-
5429
- var newVal = args[0];
5430
-
5431
- if ($.isArray(newVal)) {
5432
- newVal = $.map(newVal, function (obj) {
5433
- return obj.toString();
5434
- });
5435
- }
5436
-
5437
- this.$element.val(newVal).trigger('change');
5438
- };
5439
-
5440
- Select2.prototype.destroy = function () {
5441
- this.$container.remove();
5442
-
5443
- if (this.$element[0].detachEvent) {
5444
- this.$element[0].detachEvent('onpropertychange', this._sync);
5445
- }
5446
-
5447
- if (this._observer != null) {
5448
- this._observer.disconnect();
5449
- this._observer = null;
5450
- } else if (this.$element[0].removeEventListener) {
5451
- this.$element[0]
5452
- .removeEventListener('DOMAttrModified', this._sync, false);
5453
- }
5454
-
5455
- this._sync = null;
5456
-
5457
- this.$element.off('.pumselect2');
5458
- this.$element.attr('tabindex', this.$element.data('old-tabindex'));
5459
-
5460
- this.$element.removeClass('pumselect2-hidden-accessible');
5461
- this.$element.attr('aria-hidden', 'false');
5462
- this.$element.removeData('pumselect2');
5463
-
5464
- this.dataAdapter.destroy();
5465
- this.selection.destroy();
5466
- this.dropdown.destroy();
5467
- this.results.destroy();
5468
-
5469
- this.dataAdapter = null;
5470
- this.selection = null;
5471
- this.dropdown = null;
5472
- this.results = null;
5473
- };
5474
-
5475
- Select2.prototype.render = function () {
5476
- var $container = $(
5477
- '<span class="pumselect2 pumselect2-container">' +
5478
- '<span class="selection"></span>' +
5479
- '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
5480
- '</span>'
5481
- );
5482
-
5483
- $container.attr('dir', this.options.get('dir'));
5484
-
5485
- this.$container = $container;
5486
-
5487
- this.$container.addClass('pumselect2-container--' + this.options.get('theme'));
5488
-
5489
- $container.data('element', this.$element);
5490
-
5491
- return $container;
5492
- };
5493
-
5494
- return Select2;
5495
- });
5496
-
5497
- S2.define('pumselect2/compat/utils',[
5498
- 'jquery'
5499
- ], function ($) {
5500
- function syncCssClasses ($dest, $src, adapter) {
5501
- var classes, replacements = [], adapted;
5502
-
5503
- classes = $.trim($dest.attr('class'));
5504
-
5505
- if (classes) {
5506
- classes = '' + classes; // for IE which returns object
5507
-
5508
- $(classes.split(/\s+/)).each(function () {
5509
- // Save all Select2 classes
5510
- if (this.indexOf('pumselect2-') === 0) {
5511
- replacements.push(this);
5512
- }
5513
- });
5514
- }
5515
-
5516
- classes = $.trim($src.attr('class'));
5517
-
5518
- if (classes) {
5519
- classes = '' + classes; // for IE which returns object
5520
-
5521
- $(classes.split(/\s+/)).each(function () {
5522
- // Only adapt non-Select2 classes
5523
- if (this.indexOf('pumselect2-') !== 0) {
5524
- adapted = adapter(this);
5525
-
5526
- if (adapted != null) {
5527
- replacements.push(adapted);
5528
- }
5529
- }
5530
- });
5531
- }
5532
-
5533
- $dest.attr('class', replacements.join(' '));
5534
- }
5535
-
5536
- return {
5537
- syncCssClasses: syncCssClasses
5538
- };
5539
- });
5540
-
5541
- S2.define('pumselect2/compat/containerCss',[
5542
- 'jquery',
5543
- './utils'
5544
- ], function ($, CompatUtils) {
5545
- // No-op CSS adapter that discards all classes by default
5546
- function _containerAdapter (clazz) {
5547
- return null;
5548
- }
5549
-
5550
- function ContainerCSS () { }
5551
-
5552
- ContainerCSS.prototype.render = function (decorated) {
5553
- var $container = decorated.call(this);
5554
-
5555
- var containerCssClass = this.options.get('containerCssClass') || '';
5556
-
5557
- if ($.isFunction(containerCssClass)) {
5558
- containerCssClass = containerCssClass(this.$element);
5559
- }
5560
-
5561
- var containerCssAdapter = this.options.get('adaptContainerCssClass');
5562
- containerCssAdapter = containerCssAdapter || _containerAdapter;
5563
-
5564
- if (containerCssClass.indexOf(':all:') !== -1) {
5565
- containerCssClass = containerCssClass.replace(':all:', '');
5566
-
5567
- var _cssAdapter = containerCssAdapter;
5568
-
5569
- containerCssAdapter = function (clazz) {
5570
- var adapted = _cssAdapter(clazz);
5571
-
5572
- if (adapted != null) {
5573
- // Append the old one along with the adapted one
5574
- return adapted + ' ' + clazz;
5575
- }
5576
-
5577
- return clazz;
5578
- };
5579
- }
5580
-
5581
- var containerCss = this.options.get('containerCss') || {};
5582
-
5583
- if ($.isFunction(containerCss)) {
5584
- containerCss = containerCss(this.$element);
5585
- }
5586
-
5587
- CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);
5588
-
5589
- $container.css(containerCss);
5590
- $container.addClass(containerCssClass);
5591
-
5592
- return $container;
5593
- };
5594
-
5595
- return ContainerCSS;
5596
- });
5597
-
5598
- S2.define('pumselect2/compat/dropdownCss',[
5599
- 'jquery',
5600
- './utils'
5601
- ], function ($, CompatUtils) {
5602
- // No-op CSS adapter that discards all classes by default
5603
- function _dropdownAdapter (clazz) {
5604
- return null;
5605
- }
5606
-
5607
- function DropdownCSS () { }
5608
-
5609
- DropdownCSS.prototype.render = function (decorated) {
5610
- var $dropdown = decorated.call(this);
5611
-
5612
- var dropdownCssClass = this.options.get('dropdownCssClass') || '';
5613
-
5614
- if ($.isFunction(dropdownCssClass)) {
5615
- dropdownCssClass = dropdownCssClass(this.$element);
5616
- }
5617
-
5618
- var dropdownCssAdapter = this.options.get('adaptDropdownCssClass');
5619
- dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter;
5620
-
5621
- if (dropdownCssClass.indexOf(':all:') !== -1) {
5622
- dropdownCssClass = dropdownCssClass.replace(':all:', '');
5623
-
5624
- var _cssAdapter = dropdownCssAdapter;
5625
-
5626
- dropdownCssAdapter = function (clazz) {
5627
- var adapted = _cssAdapter(clazz);
5628
-
5629
- if (adapted != null) {
5630
- // Append the old one along with the adapted one
5631
- return adapted + ' ' + clazz;
5632
- }
5633
-
5634
- return clazz;
5635
- };
5636
- }
5637
-
5638
- var dropdownCss = this.options.get('dropdownCss') || {};
5639
-
5640
- if ($.isFunction(dropdownCss)) {
5641
- dropdownCss = dropdownCss(this.$element);
5642
- }
5643
-
5644
- CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);
5645
-
5646
- $dropdown.css(dropdownCss);
5647
- $dropdown.addClass(dropdownCssClass);
5648
-
5649
- return $dropdown;
5650
- };
5651
-
5652
- return DropdownCSS;
5653
- });
5654
-
5655
- S2.define('pumselect2/compat/initSelection',[
5656
- 'jquery'
5657
- ], function ($) {
5658
- function InitSelection (decorated, $element, options) {
5659
- if (options.get('debug') && window.console && console.warn) {
5660
- console.warn(
5661
- 'Select2: The `initSelection` option has been deprecated in favor' +
5662
- ' of a custom data adapter that overrides the `current` method. ' +
5663
- 'This method is now called multiple times instead of a single ' +
5664
- 'time when the instance is initialized. Support will be removed ' +
5665
- 'for the `initSelection` option in future versions of Select2'
5666
- );
5667
- }
5668
-
5669
- this.initSelection = options.get('initSelection');
5670
- this._isInitialized = false;
5671
-
5672
- decorated.call(this, $element, options);
5673
- }
5674
-
5675
- InitSelection.prototype.current = function (decorated, callback) {
5676
- var self = this;
5677
-
5678
- if (this._isInitialized) {
5679
- decorated.call(this, callback);
5680
-
5681
- return;
5682
- }
5683
-
5684
- this.initSelection.call(null, this.$element, function (data) {
5685
- self._isInitialized = true;
5686
-
5687
- if (!$.isArray(data)) {
5688
- data = [data];
5689
- }
5690
-
5691
- callback(data);
5692
- });
5693
- };
5694
-
5695
- return InitSelection;
5696
- });
5697
-
5698
- S2.define('pumselect2/compat/inputData',[
5699
- 'jquery'
5700
- ], function ($) {
5701
- function InputData (decorated, $element, options) {
5702
- this._currentData = [];
5703
- this._valueSeparator = options.get('valueSeparator') || ',';
5704
-
5705
- if ($element.prop('type') === 'hidden') {
5706
- if (options.get('debug') && console && console.warn) {
5707
- console.warn(
5708
- 'Select2: Using a hidden input with Select2 is no longer ' +
5709
- 'supported and may stop working in the future. It is recommended ' +
5710
- 'to use a `<select>` element instead.'
5711
- );
5712
- }
5713
- }
5714
-
5715
- decorated.call(this, $element, options);
5716
- }
5717
-
5718
- InputData.prototype.current = function (_, callback) {
5719
- function getSelected (data, selectedIds) {
5720
- var selected = [];
5721
-
5722
- if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
5723
- data.selected = true;
5724
- selected.push(data);
5725
- } else {
5726
- data.selected = false;
5727
- }
5728
-
5729
- if (data.children) {
5730
- selected.push.apply(selected, getSelected(data.children, selectedIds));
5731
- }
5732
-
5733
- return selected;
5734
- }
5735
-
5736
- var selected = [];
5737
-
5738
- for (var d = 0; d < this._currentData.length; d++) {
5739
- var data = this._currentData[d];
5740
-
5741
- selected.push.apply(
5742
- selected,
5743
- getSelected(
5744
- data,
5745
- this.$element.val().split(
5746
- this._valueSeparator
5747
- )
5748
- )
5749
- );
5750
- }
5751
-
5752
- callback(selected);
5753
- };
5754
-
5755
- InputData.prototype.select = function (_, data) {
5756
- if (!this.options.get('multiple')) {
5757
- this.current(function (allData) {
5758
- $.map(allData, function (data) {
5759
- data.selected = false;
5760
- });
5761
- });
5762
-
5763
- this.$element.val(data.id);
5764
- this.$element.trigger('change');
5765
- } else {
5766
- var value = this.$element.val();
5767
- value += this._valueSeparator + data.id;
5768
-
5769
- this.$element.val(value);
5770
- this.$element.trigger('change');
5771
- }
5772
- };
5773
-
5774
- InputData.prototype.unselect = function (_, data) {
5775
- var self = this;
5776
-
5777
- data.selected = false;
5778
-
5779
- this.current(function (allData) {
5780
- var values = [];
5781
-
5782
- for (var d = 0; d < allData.length; d++) {
5783
- var item = allData[d];
5784
-
5785
- if (data.id == item.id) {
5786
- continue;
5787
- }
5788
-
5789
- values.push(item.id);
5790
- }
5791
-
5792
- self.$element.val(values.join(self._valueSeparator));
5793
- self.$element.trigger('change');
5794
- });
5795
- };
5796
-
5797
- InputData.prototype.query = function (_, params, callback) {
5798
- var results = [];
5799
-
5800
- for (var d = 0; d < this._currentData.length; d++) {
5801
- var data = this._currentData[d];
5802
-
5803
- var matches = this.matches(params, data);
5804
-
5805
- if (matches !== null) {
5806
- results.push(matches);
5807
- }
5808
- }
5809
-
5810
- callback({
5811
- results: results
5812
- });
5813
- };
5814
-
5815
- InputData.prototype.addOptions = function (_, $options) {
5816
- var options = $.map($options, function ($option) {
5817
- return $.data($option[0], 'data');
5818
- });
5819
-
5820
- this._currentData.push.apply(this._currentData, options);
5821
- };
5822
-
5823
- return InputData;
5824
- });
5825
-
5826
- S2.define('pumselect2/compat/matcher',[
5827
- 'jquery'
5828
- ], function ($) {
5829
- function oldMatcher (matcher) {
5830
- function wrappedMatcher (params, data) {
5831
- var match = $.extend(true, {}, data);
5832
-
5833
- if (params.term == null || $.trim(params.term) === '') {
5834
- return match;
5835
- }
5836
-
5837
- if (data.children) {
5838
- for (var c = data.children.length - 1; c >= 0; c--) {
5839
- var child = data.children[c];
5840
-
5841
- // Check if the child object matches
5842
- // The old matcher returned a boolean true or false
5843
- var doesMatch = matcher(params.term, child.text, child);
5844
-
5845
- // If the child didn't match, pop it off
5846
- if (!doesMatch) {
5847
- match.children.splice(c, 1);
5848
- }
5849
- }
5850
-
5851
- if (match.children.length > 0) {
5852
- return match;
5853
- }
5854
- }
5855
-
5856
- if (matcher(params.term, data.text, data)) {
5857
- return match;
5858
- }
5859
-
5860
- return null;
5861
- }
5862
-
5863
- return wrappedMatcher;
5864
- }
5865
-
5866
- return oldMatcher;
5867
- });
5868
-
5869
- S2.define('pumselect2/compat/query',[
5870
-
5871
- ], function () {
5872
- function Query (decorated, $element, options) {
5873
- if (options.get('debug') && window.console && console.warn) {
5874
- console.warn(
5875
- 'Select2: The `query` option has been deprecated in favor of a ' +
5876
- 'custom data adapter that overrides the `query` method. Support ' +
5877
- 'will be removed for the `query` option in future versions of ' +
5878
- 'Select2.'
5879
- );
5880
- }
5881
-
5882
- decorated.call(this, $element, options);
5883
- }
5884
-
5885
- Query.prototype.query = function (_, params, callback) {
5886
- params.callback = callback;
5887
-
5888
- var query = this.options.get('query');
5889
-
5890
- query.call(null, params);
5891
- };
5892
-
5893
- return Query;
5894
- });
5895
-
5896
- S2.define('pumselect2/dropdown/attachContainer',[
5897
-
5898
- ], function () {
5899
- function AttachContainer (decorated, $element, options) {
5900
- decorated.call(this, $element, options);
5901
- }
5902
-
5903
- AttachContainer.prototype.position =
5904
- function (decorated, $dropdown, $container) {
5905
- var $dropdownContainer = $container.find('.dropdown-wrapper');
5906
- $dropdownContainer.append($dropdown);
5907
-
5908
- $dropdown.addClass('pumselect2-dropdown--below');
5909
- $container.addClass('pumselect2-container--below');
5910
- };
5911
-
5912
- return AttachContainer;
5913
- });
5914
-
5915
- S2.define('pumselect2/dropdown/stopPropagation',[
5916
-
5917
- ], function () {
5918
- function StopPropagation () { }
5919
-
5920
- StopPropagation.prototype.bind = function (decorated, container, $container) {
5921
- decorated.call(this, container, $container);
5922
-
5923
- var stoppedEvents = [
5924
- 'blur',
5925
- 'change',
5926
- 'click',
5927
- 'dblclick',
5928
- 'focus',
5929
- 'focusin',
5930
- 'focusout',
5931
- 'input',
5932
- 'keydown',
5933
- 'keyup',
5934
- 'keypress',
5935
- 'mousedown',
5936
- 'mouseenter',
5937
- 'mouseleave',
5938
- 'mousemove',
5939
- 'mouseover',
5940
- 'mouseup',
5941
- 'search',
5942
- 'touchend',
5943
- 'touchstart'
5944
- ];
5945
-
5946
- this.$dropdown.on(stoppedEvents.join(' '), function (evt) {
5947
- evt.stopPropagation();
5948
- });
5949
- };
5950
-
5951
- return StopPropagation;
5952
- });
5953
-
5954
- S2.define('pumselect2/selection/stopPropagation',[
5955
-
5956
- ], function () {
5957
- function StopPropagation () { }
5958
-
5959
- StopPropagation.prototype.bind = function (decorated, container, $container) {
5960
- decorated.call(this, container, $container);
5961
-
5962
- var stoppedEvents = [
5963
- 'blur',
5964
- 'change',
5965
- 'click',
5966
- 'dblclick',
5967
- 'focus',
5968
- 'focusin',
5969
- 'focusout',
5970
- 'input',
5971
- 'keydown',
5972
- 'keyup',
5973
- 'keypress',
5974
- 'mousedown',
5975
- 'mouseenter',
5976
- 'mouseleave',
5977
- 'mousemove',
5978
- 'mouseover',
5979
- 'mouseup',
5980
- 'search',
5981
- 'touchend',
5982
- 'touchstart'
5983
- ];
5984
-
5985
- this.$selection.on(stoppedEvents.join(' '), function (evt) {
5986
- evt.stopPropagation();
5987
- });
5988
- };
5989
-
5990
- return StopPropagation;
5991
- });
5992
-
5993
- /*!
5994
- * jQuery Mousewheel 3.1.13
5995
- *
5996
- * Copyright jQuery Foundation and other contributors
5997
- * Released under the MIT license
5998
- * http://jquery.org/license
5999
- */
6000
-
6001
- (function (factory) {
6002
- if ( typeof S2.define === 'function' && S2.define.amd ) {
6003
- // AMD. Register as an anonymous module.
6004
- S2.define('jquery-mousewheel',['jquery'], factory);
6005
- } else if (typeof exports === 'object') {
6006
- // Node/CommonJS style for Browserify
6007
- module.exports = factory;
6008
- } else {
6009
- // Browser globals
6010
- factory(jQuery);
6011
- }
6012
- }(function ($) {
6013
-
6014
- var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
6015
- toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
6016
- ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
6017
- slice = Array.prototype.slice,
6018
- nullLowestDeltaTimeout, lowestDelta;
6019
-
6020
- if ( $.event.fixHooks ) {
6021
- for ( var i = toFix.length; i; ) {
6022
- $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
6023
- }
6024
- }
6025
-
6026
- var special = $.event.special.mousewheel = {
6027
- version: '3.1.12',
6028
-
6029
- setup: function() {
6030
- if ( this.addEventListener ) {
6031
- for ( var i = toBind.length; i; ) {
6032
- this.addEventListener( toBind[--i], handler, false );
6033
- }
6034
- } else {
6035
- this.onmousewheel = handler;
6036
- }
6037
- // Store the line height and page height for this particular element
6038
- $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
6039
- $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
6040
- },
6041
-
6042
- teardown: function() {
6043
- if ( this.removeEventListener ) {
6044
- for ( var i = toBind.length; i; ) {
6045
- this.removeEventListener( toBind[--i], handler, false );
6046
- }
6047
- } else {
6048
- this.onmousewheel = null;
6049
- }
6050
- // Clean up the data we added to the element
6051
- $.removeData(this, 'mousewheel-line-height');
6052
- $.removeData(this, 'mousewheel-page-height');
6053
- },
6054
-
6055
- getLineHeight: function(elem) {
6056
- var $elem = $(elem),
6057
- $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
6058
- if (!$parent.length) {
6059
- $parent = $('body');
6060
- }
6061
- return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
6062
- },
6063
-
6064
- getPageHeight: function(elem) {
6065
- return $(elem).height();
6066
- },
6067
-
6068
- settings: {
6069
- adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
6070
- normalizeOffset: true // calls getBoundingClientRect for each event
6071
- }
6072
- };
6073
-
6074
- $.fn.extend({
6075
- mousewheel: function(fn) {
6076
- return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
6077
- },
6078
-
6079
- unmousewheel: function(fn) {
6080
- return this.unbind('mousewheel', fn);
6081
- }
6082
- });
6083
-
6084
-
6085
- function handler(event) {
6086
- var orgEvent = event || window.event,
6087
- args = slice.call(arguments, 1),
6088
- delta = 0,
6089
- deltaX = 0,
6090
- deltaY = 0,
6091
- absDelta = 0,
6092
- offsetX = 0,
6093
- offsetY = 0;
6094
- event = $.event.fix(orgEvent);
6095
- event.type = 'mousewheel';
6096
-
6097
- // Old school scrollwheel delta
6098
- if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
6099
- if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
6100
- if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
6101
- if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
6102
-
6103
- // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
6104
- if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
6105
- deltaX = deltaY * -1;
6106
- deltaY = 0;
6107
- }
6108
-
6109
- // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
6110
- delta = deltaY === 0 ? deltaX : deltaY;
6111
-
6112
- // New school wheel delta (wheel event)
6113
- if ( 'deltaY' in orgEvent ) {
6114
- deltaY = orgEvent.deltaY * -1;
6115
- delta = deltaY;
6116
- }
6117
- if ( 'deltaX' in orgEvent ) {
6118
- deltaX = orgEvent.deltaX;
6119
- if ( deltaY === 0 ) { delta = deltaX * -1; }
6120
- }
6121
-
6122
- // No change actually happened, no reason to go any further
6123
- if ( deltaY === 0 && deltaX === 0 ) { return; }
6124
-
6125
- // Need to convert lines and pages to pixels if we aren't already in pixels
6126
- // There are three delta modes:
6127
- // * deltaMode 0 is by pixels, nothing to do
6128
- // * deltaMode 1 is by lines
6129
- // * deltaMode 2 is by pages
6130
- if ( orgEvent.deltaMode === 1 ) {
6131
- var lineHeight = $.data(this, 'mousewheel-line-height');
6132
- delta *= lineHeight;
6133
- deltaY *= lineHeight;
6134
- deltaX *= lineHeight;
6135
- } else if ( orgEvent.deltaMode === 2 ) {
6136
- var pageHeight = $.data(this, 'mousewheel-page-height');
6137
- delta *= pageHeight;
6138
- deltaY *= pageHeight;
6139
- deltaX *= pageHeight;
6140
- }
6141
-
6142
- // Store lowest absolute delta to normalize the delta values
6143
- absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
6144
-
6145
- if ( !lowestDelta || absDelta < lowestDelta ) {
6146
- lowestDelta = absDelta;
6147
-
6148
- // Adjust older deltas if necessary
6149
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
6150
- lowestDelta /= 40;
6151
- }
6152
- }
6153
-
6154
- // Adjust older deltas if necessary
6155
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
6156
- // Divide all the things by 40!
6157
- delta /= 40;
6158
- deltaX /= 40;
6159
- deltaY /= 40;
6160
- }
6161
-
6162
- // Get a whole, normalized value for the deltas
6163
- delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
6164
- deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
6165
- deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
6166
-
6167
- // Normalise offsetX and offsetY properties
6168
- if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
6169
- var boundingRect = this.getBoundingClientRect();
6170
- offsetX = event.clientX - boundingRect.left;
6171
- offsetY = event.clientY - boundingRect.top;
6172
- }
6173
-
6174
- // Add information to the event object
6175
- event.deltaX = deltaX;
6176
- event.deltaY = deltaY;
6177
- event.deltaFactor = lowestDelta;
6178
- event.offsetX = offsetX;
6179
- event.offsetY = offsetY;
6180
- // Go ahead and set deltaMode to 0 since we converted to pixels
6181
- // Although this is a little odd since we overwrite the deltaX/Y
6182
- // properties with normalized deltas.
6183
- event.deltaMode = 0;
6184
-
6185
- // Add event and delta to the front of the arguments
6186
- args.unshift(event, delta, deltaX, deltaY);
6187
-
6188
- // Clearout lowestDelta after sometime to better
6189
- // handle multiple device types that give different
6190
- // a different lowestDelta
6191
- // Ex: trackpad = 3 and mouse wheel = 120
6192
- if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
6193
- nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
6194
-
6195
- return ($.event.dispatch || $.event.handle).apply(this, args);
6196
- }
6197
-
6198
- function nullLowestDelta() {
6199
- lowestDelta = null;
6200
- }
6201
-
6202
- function shouldAdjustOldDeltas(orgEvent, absDelta) {
6203
- // If this is an older event and the delta is divisable by 120,
6204
- // then we are assuming that the browser is treating this as an
6205
- // older mouse wheel event and that we should divide the deltas
6206
- // by 40 to try and get a more usable deltaFactor.
6207
- // Side note, this actually impacts the reported scroll distance
6208
- // in older browsers and can cause scrolling to be slower than native.
6209
- // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
6210
- return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
6211
- }
6212
-
6213
- }));
6214
-
6215
- S2.define('jquery.pumselect2',[
6216
- 'jquery',
6217
- 'jquery-mousewheel',
6218
-
6219
- './pumselect2/core',
6220
- './pumselect2/defaults'
6221
- ], function ($, _, Select2, Defaults) {
6222
- if ($.fn.pumselect2 == null) {
6223
- // All methods that should return the element
6224
- var thisMethods = ['open', 'close', 'destroy'];
6225
-
6226
- $.fn.pumselect2 = function (options) {
6227
- options = options || {};
6228
-
6229
- if (typeof options === 'object') {
6230
- this.each(function () {
6231
- var instanceOptions = $.extend(true, {}, options);
6232
-
6233
- var instance = new Select2($(this), instanceOptions);
6234
- });
6235
-
6236
- return this;
6237
- } else if (typeof options === 'string') {
6238
- var ret;
6239
-
6240
- this.each(function () {
6241
- var instance = $(this).data('pumselect2');
6242
-
6243
- if (instance == null && window.console && console.error) {
6244
- console.error(
6245
- 'The pumselect2(\'' + options + '\') method was called on an ' +
6246
- 'element that is not using Select2.'
6247
- );
6248
- }
6249
-
6250
- var args = Array.prototype.slice.call(arguments, 1);
6251
-
6252
- ret = instance[options].apply(instance, args);
6253
- });
6254
-
6255
- // Check if we should be returning `this`
6256
- if ($.inArray(options, thisMethods) > -1) {
6257
- return this;
6258
- }
6259
-
6260
- return ret;
6261
- } else {
6262
- throw new Error('Invalid arguments for Select2: ' + options);
6263
- }
6264
- };
6265
- }
6266
-
6267
- if ($.fn.pumselect2.defaults == null) {
6268
- $.fn.pumselect2.defaults = Defaults;
6269
- }
6270
-
6271
- return Select2;
6272
- });
6273
-
6274
- // Return the AMD loader configuration so it can be used outside of this file
6275
- return {
6276
- define: S2.define,
6277
- require: S2.require
6278
- };
6279
- }());
6280
-
6281
- // Autoload the jQuery bindings
6282
- // We know that all of the modules exist above this, so we're safe
6283
- var pumselect2 = S2.require('jquery.pumselect2');
6284
-
6285
- // Hold the AMD module references on the jQuery function that was just loaded
6286
- // This allows Select2 to use the internal loader outside of this file, such
6287
- // as in the language files.
6288
- jQuery.fn.pumselect2.amd = S2;
6289
-
6290
- // Return the Select2 instance for anyone who is importing it.
6291
- return pumselect2;
6292
  }));
6293
- /*******************************************************************************
6294
- * Copyright (c) 2017, WP Popup Maker
6295
- ******************************************************************************/
6296
- (function ($) {
6297
- "use strict";
6298
-
6299
- function dismissAlert($alert) {
6300
- var dismissible = $alert.data('dismissible'),
6301
- expires = dismissible === '1' || dismissible === 1 || dismissible === true ? null: dismissible;
6302
-
6303
- $.ajax({
6304
- method: "POST",
6305
- dataType: "json",
6306
- url: ajaxurl,
6307
- data: {
6308
- action: 'pum_alerts_action',
6309
- nonce: window.pum_alerts_nonce,
6310
- code: $alert.data('code'),
6311
- expires: expires
6312
- }
6313
- });
6314
- }
6315
-
6316
- function dismissReviewRequest(reason) {
6317
- $.ajax({
6318
- method: "POST",
6319
- dataType: "json",
6320
- url: ajaxurl,
6321
- data: {
6322
- action: 'pum_review_action',
6323
- nonce: window.pum_review_nonce,
6324
- group: window.pum_review_trigger.group,
6325
- code: window.pum_review_trigger.code,
6326
- pri: window.pum_review_trigger.pri,
6327
- reason: reason
6328
- }
6329
- });
6330
-
6331
- if (typeof window.pum_review_api_url !== 'undefined') {
6332
- $.ajax({
6333
- method: "POST",
6334
- dataType: "json",
6335
- url: window.pum_review_api_url,
6336
- data: {
6337
- trigger_group: window.pum_review_trigger.group,
6338
- trigger_code: window.pum_review_trigger.code,
6339
- reason: reason,
6340
- uuid: window.pum_review_uuid || null
6341
- }
6342
- });
6343
- }
6344
- }
6345
-
6346
- var $alerts = $('.pum-alerts'),
6347
- $notice_counts = $('.pum-alert-count'),
6348
- count = parseInt($notice_counts.eq(0).text());
6349
-
6350
- function checkRemoveAlerts() {
6351
- if ($alerts.find('.pum-alert-holder').length === 0) {
6352
- $alerts.slideUp(100, function () {
6353
- $alerts.remove();
6354
- });
6355
-
6356
- $('#menu-posts-popup .wp-menu-name .update-plugins').fadeOut();
6357
- }
6358
-
6359
- }
6360
-
6361
- function removeAlert($alert) {
6362
- count--;
6363
-
6364
- $notice_counts.text(count);
6365
-
6366
- $alert.fadeTo(100, 0, function () {
6367
- $alert.slideUp(100, function () {
6368
- $alert.remove();
6369
-
6370
- checkRemoveAlerts();
6371
- });
6372
- });
6373
- }
6374
-
6375
- $(document)
6376
- .on('pumDismissAlert', checkRemoveAlerts)
6377
- .on('click', '.pum-alert-holder .pum-dismiss', function () {
6378
- var $this = $(this),
6379
- $alert = $this.parents('.pum-alert-holder'),
6380
- reason = $this.data('reason') || 'maybe_later';
6381
-
6382
- if ( 'review_request' !== $alert.data('code')) {
6383
- dismissAlert($alert);
6384
- } else {
6385
- dismissReviewRequest(reason);
6386
- }
6387
-
6388
- removeAlert($alert);
6389
-
6390
- });
6391
  }(jQuery));
6392
- /*******************************************************************************
6393
- * Copyright (c) 2017, WP Popup Maker
6394
- ******************************************************************************/
6395
- (function ($) {
6396
- "use strict";
6397
-
6398
- var colorpicker = {
6399
- init: function () {
6400
- $('.pum-color-picker').filter(':not(.pum-color-picker-initialized)')
6401
- .addClass('pum-color-picker-initialized')
6402
- .wpColorPicker({
6403
- change: function (event, ui) {
6404
- $(event.target).trigger('colorchange', ui);
6405
- },
6406
- clear: function (event) {
6407
- $(event.target).prev().trigger('colorchange').wpColorPicker('close');
6408
- },
6409
- hide: true
6410
- });
6411
- }
6412
- };
6413
-
6414
- // Import this module.
6415
- window.PUM_Admin = window.PUM_Admin || {};
6416
- window.PUM_Admin.colorpicker = colorpicker;
6417
-
6418
- $(document)
6419
- .on('click', '.iris-palette', function () {
6420
- $(this).parents('.wp-picker-active').find('input.pum-color-picker').trigger('change');
6421
- })
6422
- .on('colorchange', function (event, ui) {
6423
- var $input = $(event.target),
6424
- color = '';
6425
-
6426
- if (ui !== undefined && ui.color !== undefined) {
6427
- color = ui.color.toString();
6428
- }
6429
-
6430
- $input.val(color).trigger('change');
6431
-
6432
- if ($('form#post input#post_type').val() === 'popup_theme') {
6433
- PUM_Admin.utils.debounce(PUM_Admin.themeEditor.refresh_preview, 100);
6434
- }
6435
- })
6436
- .on('pum_init', colorpicker.init);
6437
  }(jQuery));
6438
- /*******************************************************************************
6439
- * Copyright (c) 2017, WP Popup Maker
6440
- ******************************************************************************/
6441
-
6442
- (function ($) {
6443
- "use strict";
6444
-
6445
- var forms = {
6446
- init: function () {
6447
- forms.checkDependencies();
6448
- },
6449
- /**
6450
- * dependencies should look like this:
6451
- *
6452
- * {
6453
- * field_name_1: value, // Select, radio etc.
6454
- * field_name_2: true // Checkbox
6455
- * }
6456
- *
6457
- * Support for Multiple possible values of one field
6458
- *
6459
- * {
6460
- * field_name_1: [ value_1, value_2 ]
6461
- * }
6462
- *
6463
- */
6464
- checkDependencies: function ($dependent_fields) {
6465
- var _fields = $($dependent_fields);
6466
-
6467
- // If no fields passed, only do those not already initialized.
6468
- $dependent_fields = _fields.length ? _fields : $("[data-pum-dependencies]:not([data-pum-processed-dependencies])");
6469
-
6470
- $dependent_fields.each(function () {
6471
- var $dependent = $(this),
6472
- dependentID = $dependent.data('id'),
6473
- // The dependency object for this field.
6474
- dependencies = $dependent.data("pum-processed-dependencies") || {},
6475
- // Total number of fields this :input is dependent on.
6476
- requiredCount = Object.keys(dependencies).length,
6477
- // Current count of fields this :input matched properly.
6478
- count = 0,
6479
- // An array of fields this :input is dependent on.
6480
- dependentFields = $dependent.data("pum-dependent-fields"),
6481
- // Early declarations.
6482
- key;
6483
-
6484
- // Clean up & pre-process dependencies so we don't need to rebuild each time.
6485
- if (!$dependent.data("pum-processed-dependencies")) {
6486
- dependencies = $dependent.data("pum-dependencies");
6487
- if (typeof dependencies === 'string') {
6488
- dependencies = JSON.parse(dependencies);
6489
- }
6490
-
6491
- // Convert each key to an array of acceptable values.
6492
- for (key in dependencies) {
6493
- if (dependencies.hasOwnProperty(key)) {
6494
- if (typeof dependencies[key] === "string") {
6495
- // Leave boolean values alone as they are for checkboxes or checking if an input has any value.
6496
-
6497
- if (dependencies[key].indexOf(',') !== -1) {
6498
- dependencies[key] = dependencies[key].split(',');
6499
- } else {
6500
- dependencies[key] = [dependencies[key]];
6501
- }
6502
- } else if (typeof dependencies[key] === "number") {
6503
- dependencies[key] = [dependencies[key]];
6504
- }
6505
- }
6506
- }
6507
-
6508
- // Update cache & counts.
6509
- requiredCount = Object.keys(dependencies).length;
6510
- $dependent.data("pum-processed-dependencies", dependencies).attr("data-pum-processed-dependencies", dependencies);
6511
- }
6512
-
6513
- if (!dependentFields) {
6514
- dependentFields = $.map(dependencies, function (value, index) {
6515
- var $wrapper = $('.pum-field[data-id="' + index + '"]');
6516
-
6517
- return $wrapper.length ? $wrapper.eq(0) : null;
6518
- });
6519
-
6520
- $dependent.data("pum-dependent-fields", dependentFields);
6521
- }
6522
-
6523
- $(dependentFields).each(function () {
6524
- var $wrapper = $(this),
6525
- $field = $wrapper.find(':input:first'),
6526
- id = $wrapper.data("id"),
6527
- value = $field.val(),
6528
- required = dependencies[id],
6529
- matched,
6530
- // Used for limiting the fields that get updated when this field is changed.
6531
- all_this_fields_dependents = $wrapper.data('pum-field-dependents') || [];
6532
-
6533
- if (all_this_fields_dependents.indexOf(dependentID) === -1) {
6534
- all_this_fields_dependents.push(dependentID);
6535
- $wrapper.data('pum-field-dependents', all_this_fields_dependents);
6536
- }
6537
-
6538
- // If no required values found bail early.
6539
- if (typeof required === 'undefined' || required === null) {
6540
- $dependent.removeClass('pum-dependencies-met').hide(0).trigger('pumFormDependencyUnmet');
6541
- // Effectively breaks the .each for this $dependent and hides it.
6542
- return false;
6543
- }
6544
-
6545
- if ($wrapper.hasClass('pum-field-radio')) {
6546
- value = $wrapper.find(':input:checked').val();
6547
- }
6548
-
6549
- if ($wrapper.hasClass('pum-field-multicheck')) {
6550
- value = [];
6551
- $wrapper.find(':checkbox:checked').each(function (i) {
6552
- value[i] = $(this).val();
6553
-
6554
- if (typeof value[i] === 'string' && !isNaN(parseInt(value[i]))) {
6555
- value[i] = parseInt(value[i]);
6556
- }
6557
-
6558
- });
6559
- }
6560
-
6561
- // Check if the value matches required values.
6562
- if ($wrapper.hasClass('pum-field-select') || $wrapper.hasClass('pum-field-radio')) {
6563
- matched = required && required.indexOf(value) !== -1;
6564
- } else if ($wrapper.hasClass('pum-field-checkbox')) {
6565
- matched = required === $field.is(':checked');
6566
- } else if ($wrapper.hasClass('pum-field-multicheck')) {
6567
- if (Array.isArray(required)) {
6568
- matched = false;
6569
- for (var i = 0; i < required.length; i++) {
6570
- if (value.indexOf(required[i]) !== -1) {
6571
- matched = true;
6572
- }
6573
- }
6574
- } else {
6575
- matched = value.indexOf(required) !== -1;
6576
- }
6577
- } else {
6578
- matched = Array.isArray(required) ? required.indexOf(value) !== -1 : required == value;
6579
- }
6580
-
6581
- if (matched) {
6582
- count++;
6583
- } else {
6584
- $dependent.removeClass('pum-dependencies-met').hide(0).trigger('pumFormDependencyUnmet');
6585
- // Effectively breaks the .each for this $dependent and hides it.
6586
- return false;
6587
- }
6588
-
6589
- if (count === requiredCount) {
6590
- $dependent.addClass('pum-dependencies-met').show(0).trigger('pumFormDependencyMet');
6591
- }
6592
- });
6593
- });
6594
- },
6595
- form_check: function () {
6596
- $(document).trigger('pum_form_check');
6597
- },
6598
- is_field: function (data) {
6599
- if (typeof data !== 'object') {
6600
- return false;
6601
- }
6602
-
6603
- var field_tests = [
6604
- data.type === undefined && (data.label !== undefined || data.desc !== undefined),
6605
- data.type !== undefined && typeof data.type === 'string'
6606
- ];
6607
-
6608
- return field_tests.indexOf(true) >= 0;
6609
- },
6610
- flattenFields: function (data) {
6611
- var form_fields = {},
6612
- tabs = data.tabs || {},
6613
- sections = data.sections || {},
6614
- fields = data.fields || {};
6615
-
6616
- if (Object.keys(tabs).length && Object.keys(sections).length) {
6617
- // Loop Tabs
6618
- _.each(fields, function (subTabs, tabID) {
6619
-
6620
- // If not a valid tab or no subsections skip it.
6621
- if (typeof subTabs !== 'object' || !Object.keys(subTabs).length) {
6622
- return;
6623
- }
6624
-
6625
- // Loop Tab Sections
6626
- _.each(subTabs, function (subTabFields, subTabID) {
6627
-
6628
- // If not a valid subtab or no fields skip it.
6629
- if (typeof subTabFields !== 'object' || !Object.keys(subTabFields).length) {
6630
- return;
6631
- }
6632
-
6633
- // Move single fields into the main subtab.
6634
- if (forms.is_field(subTabFields)) {
6635
- var newSubTabFields = {};
6636
- newSubTabFields[subTabID] = subTabFields;
6637
- subTabID = 'main';
6638
- subTabFields = newSubTabFields;
6639
- }
6640
-
6641
- // Loop Tab Section Fields
6642
- _.each(subTabFields, function (field) {
6643
- // Store the field by id for easy lookup later.
6644
- form_fields[field.id] = field;
6645
- });
6646
- });
6647
- });
6648
- }
6649
- else if (Object.keys(tabs).length) {
6650
- // Loop Tabs
6651
- _.each(fields, function (tabFields, tabID) {
6652
-
6653
- // If not a valid tab or no subsections skip it.
6654
- if (typeof tabFields !== 'object' || !Object.keys(tabFields).length) {
6655
- return;
6656
- }
6657
-
6658
- // Loop Tab Fields
6659
- _.each(tabFields, function (field) {
6660
- // Store the field by id for easy lookup later.
6661
- form_fields[field.id] = field;
6662
- });
6663
- });
6664
- }
6665
- else if (Object.keys(sections).length) {
6666
-
6667
- // Loop Sections
6668
- _.each(fields, function (sectionFields, sectionID) {
6669
- // Loop Tab Section Fields
6670
- _.each(sectionFields, function (field) {
6671
- // Store the field by id for easy lookup later.
6672
- form_fields[field.id] = field;
6673
- });
6674
- });
6675
- }
6676
- else {
6677
- fields = forms.parseFields(fields, values);
6678
-
6679
- // Replace the array with rendered fields.
6680
- _.each(fields, function (field) {
6681
- // Store the field by id for easy lookup later.
6682
- form_fields[field.id] = field;
6683
- });
6684
- }
6685
-
6686
- return form_fields;
6687
- },
6688
- parseFields: function (fields, values) {
6689
-
6690
- values = values || {};
6691
-
6692
- _.each(fields, function (field, fieldID) {
6693
-
6694
- fields[fieldID] = PUM_Admin.models.field(field);
6695
-
6696
- if (typeof fields[fieldID].meta !== 'object') {
6697
- fields[fieldID].meta = {};
6698
- }
6699
-
6700
- if (undefined !== values[fieldID]) {
6701
- fields[fieldID].value = values[fieldID];
6702
- }
6703
-
6704
- if (fields[fieldID].id === '') {
6705
- fields[fieldID].id = fieldID;
6706
- }
6707
- });
6708
-
6709
- return fields;
6710
- },
6711
- renderTab: function () {
6712
-
6713
- },
6714
- renderSection: function () {
6715
-
6716
- },
6717
- render: function (args, values, $container) {
6718
- var form,
6719
- sections = {},
6720
- section = [],
6721
- form_fields = {},
6722
- data = $.extend(true, {
6723
- id: "",
6724
- tabs: {},
6725
- sections: {},
6726
- fields: {},
6727
- maintabs: {},
6728
- subtabs: {}
6729
- }, args),
6730
- maintabs = $.extend({
6731
- id: data.id,
6732
- classes: [],
6733
- tabs: {},
6734
- vertical: true,
6735
- form: true,
6736
- meta: {
6737
- 'data-min-height': 250
6738
- }
6739
- }, data.maintabs),
6740
- subtabs = $.extend({
6741
- classes: ['link-tabs', 'sub-tabs'],
6742
- tabs: {}
6743
- }, data.subtabs),
6744
- container_classes = ['pum-dynamic-form'];
6745
-
6746
- values = values || {};
6747
-
6748
- if (Object.keys(data.tabs).length && Object.keys(data.sections).length) {
6749
- container_classes.push('tabbed-content');
6750
-
6751
- // Loop Tabs
6752
- _.each(data.fields, function (subTabs, tabID) {
6753
-
6754
- // If not a valid tab or no subsections skip it.
6755
- if (typeof subTabs !== 'object' || !Object.keys(subTabs).length) {
6756
- return;
6757
- }
6758
-
6759
- // Define this tab.
6760
- if (undefined === maintabs.tabs[tabID]) {
6761
- maintabs.tabs[tabID] = {
6762
- label: data.tabs[tabID],
6763
- content: ''
6764
- };
6765
- }
6766
-
6767
- // Define the sub tabs model.
6768
- subtabs = $.extend(subtabs, {
6769
- id: data.id + '-' + tabID + '-subtabs',
6770
- tabs: {}
6771
- });
6772
-
6773
- // Loop Tab Sections
6774
- _.each(subTabs, function (subTabFields, subTabID) {
6775
-
6776
- // If not a valid subtab or no fields skip it.
6777
- if (typeof subTabFields !== 'object' || !Object.keys(subTabFields).length) {
6778
- return;
6779
- }
6780
-
6781
- // Move single fields into the main subtab.
6782
- if (forms.is_field(subTabFields)) {
6783
- var newSubTabFields = {};
6784
- newSubTabFields[subTabID] = subTabFields;
6785
- subTabID = 'main';
6786
- subTabFields = newSubTabFields;
6787
- }
6788
-
6789
- // Define this subtab model.
6790
- if (undefined === subtabs.tabs[subTabID]) {
6791
- subtabs.tabs[subTabID] = {
6792
- label: data.sections[tabID][subTabID],
6793
- content: ''
6794
- };
6795
- }
6796
-
6797
- subTabFields = forms.parseFields(subTabFields, values);
6798
-
6799
- // Loop Tab Section Fields
6800
- _.each(subTabFields, function (field) {
6801
- // Store the field by id for easy lookup later.
6802
- form_fields[field.id] = field;
6803
-
6804
- // Push rendered fields into the subtab content.
6805
- subtabs.tabs[subTabID].content += PUM_Admin.templates.field(field);
6806
- });
6807
-
6808
- // Remove any empty tabs.
6809
- if ("" === subtabs.tabs[subTabID].content) {
6810
- delete subtabs.tabs[subTabID];
6811
- }
6812
- });
6813
-
6814
- // If there are subtabs, then render them into the main tabs content, otherwise remove this main tab.
6815
- if (Object.keys(subtabs.tabs).length) {
6816
- maintabs.tabs[tabID].content = PUM_Admin.templates.tabs(subtabs);
6817
- } else {
6818
- delete maintabs.tabs[tabID];
6819
- }
6820
- });
6821
-
6822
- if (Object.keys(maintabs.tabs).length) {
6823
- form = PUM_Admin.templates.tabs(maintabs);
6824
- }
6825
- }
6826
- else if (Object.keys(data.tabs).length) {
6827
- container_classes.push('tabbed-content');
6828
-
6829
- // Loop Tabs
6830
- _.each(data.fields, function (tabFields, tabID) {
6831
-
6832
- // If not a valid tab or no subsections skip it.
6833
- if (typeof tabFields !== 'object' || !Object.keys(tabFields).length) {
6834
- return;
6835
- }
6836
-
6837
- // Define this tab.
6838
- if (undefined === maintabs.tabs[tabID]) {
6839
- maintabs.tabs[tabID] = {
6840
- label: data.tabs[tabID],
6841
- content: ''
6842
- };
6843
- }
6844
-
6845
- section = [];
6846
-
6847
- tabFields = forms.parseFields(tabFields, values);
6848
-
6849
- // Loop Tab Fields
6850
- _.each(tabFields, function (field) {
6851
- // Store the field by id for easy lookup later.
6852
- form_fields[field.id] = field;
6853
-
6854
- // Push rendered fields into the subtab content.
6855
- section.push(PUM_Admin.templates.field(field));
6856
- });
6857
-
6858
- // Push rendered tab into the tab.
6859
- if (section.length) {
6860
- // Push rendered sub tabs into the main tabs if not empty.
6861
- maintabs.tabs[tabID].content = PUM_Admin.templates.section({
6862
- fields: section
6863
- });
6864
- } else {
6865
- delete (maintabs.tabs[tabID]);
6866
- }
6867
- });
6868
-
6869
- if (Object.keys(maintabs.tabs).length) {
6870
- form = PUM_Admin.templates.tabs(maintabs);
6871
- }
6872
- }
6873
- else if (Object.keys(data.sections).length) {
6874
-
6875
- // Loop Sections
6876
- _.each(data.fields, function (sectionFields, sectionID) {
6877
- section = [];
6878
-
6879
- section.push(PUM_Admin.templates.field({
6880
- type: 'heading',
6881
- desc: data.sections[sectionID] || ''
6882
- }));
6883
-
6884
- sectionFields = forms.parseFields(sectionFields, values);
6885
-
6886
- // Loop Tab Section Fields
6887
- _.each(sectionFields, function (field) {
6888
- // Store the field by id for easy lookup later.
6889
- form_fields[field.id] = field;
6890
-
6891
- // Push rendered fields into the section.
6892
- section.push(PUM_Admin.templates.field(field));
6893
- });
6894
-
6895
- // Push rendered sections into the form.
6896
- form += PUM_Admin.templates.section({
6897
- fields: section
6898
- });
6899
- });
6900
- }
6901
- else {
6902
- data.fields = forms.parseFields(data.fields, values);
6903
-
6904
- // Replace the array with rendered fields.
6905
- _.each(data.fields, function (field) {
6906
- // Store the field by id for easy lookup later.
6907
- form_fields[field.id] = field;
6908
-
6909
- // Push rendered fields into the section.
6910
- section.push(PUM_Admin.templates.field(field));
6911
- });
6912
-
6913
- // Render the section.
6914
- form = PUM_Admin.templates.section({
6915
- fields: section
6916
- });
6917
- }
6918
-
6919
- if ($container !== undefined && $container.length) {
6920
- $container
6921
- .addClass(container_classes.join(' '))
6922
- .data('form_fields', form_fields)
6923
- .html(form)
6924
- .trigger('pum_init');
6925
- }
6926
-
6927
- return form;
6928
-
6929
- },
6930
- parseValues: function (values, fields) {
6931
- fields = fields || false
6932
-
6933
- if (!fields) {
6934
- return values;
6935
- }
6936
-
6937
- debugger;
6938
-
6939
- for (var key in fields) {
6940
- if (!fields.hasOwnProperty(key)) {
6941
- continue;
6942
- }
6943
-
6944
- // Measure field value corrections.
6945
- if (values.hasOwnProperty(key + "_unit")) {
6946
- values[key] += values[key + "_unit"];
6947
- delete values[key + "_unit"];
6948
- }
6949
-
6950
- // If the value key is empty and a checkbox set it to false. Then return.
6951
- if (typeof values[key] === 'undefined') {
6952
- if (fields[key].type === 'checkbox') {
6953
- values[key] = false;
6954
- }
6955
- continue;
6956
- }
6957
-
6958
- if (fields[key].allow_html && !PUM_Admin.utils.htmlencoder.hasEncoded(values[key])) {
6959
- values[key] = PUM_Admin.utils.htmlencoder.htmlEncode(values[key]);
6960
- }
6961
- }
6962
-
6963
- return values;
6964
- }
6965
- };
6966
-
6967
- // Import this module.
6968
- window.PUM_Admin = window.PUM_Admin || {};
6969
- window.PUM_Admin.forms = forms;
6970
-
6971
- $(document)
6972
- .on('pum_init pum_form_check', function () {
6973
- PUM_Admin.forms.init();
6974
- })
6975
- .on('pumFieldChanged', '.pum-field', function () {
6976
- var $wrapper = $(this),
6977
- dependent_field_ids = $wrapper.data('pum-field-dependents') || [],
6978
- $fields_with_dependencies = $(),
6979
- i;
6980
-
6981
- if (!dependent_field_ids || dependent_field_ids.length <= 0) {
6982
- return;
6983
- }
6984
-
6985
- for (i = 0; i < dependent_field_ids.length; i++) {
6986
- $fields_with_dependencies = $fields_with_dependencies.add('.pum-field[data-id="' + dependent_field_ids[i] + '"]');
6987
- }
6988
-
6989
- PUM_Admin.forms.checkDependencies($fields_with_dependencies);
6990
- })
6991
- .on('pumFieldChanged', '.pum-field-dynamic-desc', function () {
6992
- var $this = $(this),
6993
- $input = $this.find(':input'),
6994
- $container = $this.parents('.pum-dynamic-form:first'),
6995
- val = $input.val(),
6996
- form_fields = $container.data('form_fields') || {},
6997
- field = form_fields[$this.data('id')] || {},
6998
- $desc = $this.find('.pum-desc'),
6999
- desc = $this.data('pum-dynamic-desc');
7000
-
7001
- switch (field.type) {
7002
- case 'radio':
7003
- val = $this.find(':input:checked').val();
7004
- break;
7005
- }
7006
-
7007
- field.value = val;
7008
-
7009
- if (desc && desc.length) {
7010
- $desc.html(PUM_Admin.templates.renderInline(desc, field));
7011
- }
7012
- })
7013
- .on('change', '.pum-field-select select', function () {
7014
- $(this).parents('.pum-field').trigger('pumFieldChanged');
7015
- })
7016
- .on('click', '.pum-field-checkbox input', function () {
7017
- $(this).parents('.pum-field').trigger('pumFieldChanged');
7018
- })
7019
- .on('click', '.pum-field-multicheck input', function () {
7020
- $(this).parents('.pum-field').trigger('pumFieldChanged');
7021
- })
7022
- .on('click', '.pum-field-radio input', function (event) {
7023
- var $this = $(this),
7024
- $selected = $this.parents('li'),
7025
- $wrapper = $this.parents('.pum-field');
7026
-
7027
- $wrapper.trigger('pumFieldChanged');
7028
-
7029
- $wrapper.find('li.pum-selected').removeClass('pum-selected');
7030
-
7031
- $selected.addClass('pum-selected');
7032
- });
7033
-
7034
  }(jQuery));
7035
- function pumSelected(val1, val2, print) {
7036
- "use strict";
7037
-
7038
- var selected = false;
7039
- if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
7040
- selected = true;
7041
- } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
7042
- selected = true;
7043
- } else if (val1 === val2) {
7044
- selected = true;
7045
- }
7046
-
7047
- if (print !== undefined && print) {
7048
- return selected ? ' selected="selected"' : '';
7049
- }
7050
- return selected;
7051
- }
7052
-
7053
- function pumChecked(val1, val2, print) {
7054
- "use strict";
7055
-
7056
- var checked = false;
7057
- if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
7058
- checked = true;
7059
- } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
7060
- checked = true;
7061
- } else if (val1 === val2) {
7062
- checked = true;
7063
- }
7064
-
7065
- if (print !== undefined && print) {
7066
- return checked ? ' checked="checked"' : '';
7067
- }
7068
- return checked;
7069
- }
7070
-
7071
- /*******************************************************************************
7072
- * Copyright (c) 2017, WP Popup Maker
7073
- ******************************************************************************/
7074
- (function ($) {
7075
- "use strict";
7076
-
7077
- var $html = $('html'),
7078
- $document = $(document),
7079
- $top_level_elements,
7080
- focusableElementsString = "a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",
7081
- previouslyFocused,
7082
- modals = {
7083
- _current: null,
7084
- // Accessibility: Checks focus events to ensure they stay inside the modal.
7085
- forceFocus: function (event) {
7086
- if (PUM_Admin.modals._current && !PUM_Admin.modals._current.contains(event.target)) {
7087
- event.stopPropagation();
7088
- PUM_Admin.modals._current.focus();
7089
- }
7090
- },
7091
- trapEscapeKey: function (e) {
7092
- if (e.keyCode === 27) {
7093
- PUM_Admin.modals.closeAll();
7094
- e.preventDefault();
7095
- }
7096
- },
7097
- trapTabKey: function (e) {
7098
- // if tab or shift-tab pressed
7099
- if (e.keyCode === 9) {
7100
- // get list of focusable items
7101
- var focusableItems = PUM_Admin.modals._current.find('*').filter(focusableElementsString).filter(':visible'),
7102
- // get currently focused item
7103
- focusedItem = $(':focus'),
7104
- // get the number of focusable items
7105
- numberOfFocusableItems = focusableItems.length,
7106
- // get the index of the currently focused item
7107
- focusedItemIndex = focusableItems.index(focusedItem);
7108
-
7109
- if (e.shiftKey) {
7110
- //back tab
7111
- // if focused on first item and user preses back-tab, go to the last focusable item
7112
- if (focusedItemIndex === 0) {
7113
- focusableItems.get(numberOfFocusableItems - 1).focus();
7114
- e.preventDefault();
7115
- }
7116
- } else {
7117
- //forward tab
7118
- // if focused on the last item and user preses tab, go to the first focusable item
7119
- if (focusedItemIndex === numberOfFocusableItems - 1) {
7120
- focusableItems.get(0).focus();
7121
- e.preventDefault();
7122
- }
7123
- }
7124
- }
7125
- },
7126
- setFocusToFirstItem: function () {
7127
- // set focus to first focusable item
7128
- PUM_Admin.modals._current.find('.pum-modal-content *').filter(focusableElementsString).filter(':visible').first().focus();
7129
- },
7130
- closeAll: function (callback) {
7131
- $('.pum-modal-background')
7132
- .off('keydown.pum_modal')
7133
- .hide(0, function () {
7134
- $('html').css({overflow: 'visible', width: 'auto'});
7135
-
7136
- if ($top_level_elements) {
7137
- $top_level_elements.attr('aria-hidden', 'false');
7138
- $top_level_elements = null;
7139
- }
7140
-
7141
- // Accessibility: Focus back on the previously focused element.
7142
- if (previouslyFocused.length) {
7143
- previouslyFocused.focus();
7144
- }
7145
-
7146
- // Accessibility: Clears the PUM_Admin.modals._current var.
7147
- PUM_Admin.modals._current = null;
7148
-
7149
- // Accessibility: Removes the force focus check.
7150
- $document.off('focus.pum_modal');
7151
- if (undefined !== callback) {
7152
- callback();
7153
- }
7154
- })
7155
- .attr('aria-hidden', 'true');
7156
-
7157
- },
7158
- show: function (modal, callback) {
7159
- $('.pum-modal-background')
7160
- .off('keydown.pum_modal')
7161
- .hide(0)
7162
- .attr('aria-hidden', 'true');
7163
-
7164
- $html
7165
- .data('origwidth', $html.innerWidth())
7166
- .css({overflow: 'hidden', 'width': $html.innerWidth()});
7167
-
7168
- // Accessibility: Sets the previous focus element.
7169
-
7170
- var $focused = $(':focus');
7171
- if (!$focused.parents('.pum-modal-wrap').length) {
7172
- previouslyFocused = $focused;
7173
- }
7174
-
7175
- // Accessibility: Sets the current modal for focus checks.
7176
- PUM_Admin.modals._current = $(modal);
7177
-
7178
- // Accessibility: Close on esc press.
7179
- PUM_Admin.modals._current
7180
- .on('keydown.pum_modal', function (e) {
7181
- PUM_Admin.modals.trapEscapeKey(e);
7182
- PUM_Admin.modals.trapTabKey(e);
7183
- })
7184
- .show(0, function () {
7185
- $top_level_elements = $('body > *').filter(':visible').not(PUM_Admin.modals._current);
7186
- $top_level_elements.attr('aria-hidden', 'true');
7187
-
7188
- PUM_Admin.modals._current
7189
- .trigger('pum_init')
7190
- // Accessibility: Add focus check that prevents tabbing outside of modal.
7191
- .on('focus.pum_modal', PUM_Admin.modals.forceFocus);
7192
-
7193
- // Accessibility: Focus on the modal.
7194
- PUM_Admin.modals.setFocusToFirstItem();
7195
-
7196
- if (undefined !== callback) {
7197
- callback();
7198
- }
7199
- })
7200
- .attr('aria-hidden', 'false');
7201
-
7202
- },
7203
- remove: function (modal) {
7204
- $(modal).remove();
7205
- },
7206
- replace: function (modal, replacement) {
7207
- PUM_Admin.modals.remove($.trim(modal));
7208
- $('body').append($.trim(replacement));
7209
- },
7210
- reload: function (modal, replacement, callback) {
7211
- PUM_Admin.modals.replace(modal, replacement);
7212
- PUM_Admin.modals.show(modal, callback);
7213
- $(modal).trigger('pum_init');
7214
- }
7215
- };
7216
-
7217
- // Import this module.
7218
- window.PUM_Admin = window.PUM_Admin || {};
7219
- window.PUM_Admin.modals = modals;
7220
-
7221
- $(document).on('click', '.pum-modal-background, .pum-modal-wrap .cancel, .pum-modal-wrap .pum-modal-close', function (e) {
7222
- var $target = $(e.target);
7223
- if (/*$target.hasClass('pum-modal-background') || */$target.hasClass('cancel') || $target.hasClass('pum-modal-close') || $target.hasClass('submitdelete')) {
7224
- PUM_Admin.modals.closeAll();
7225
- e.preventDefault();
7226
- e.stopPropagation();
7227
- }
7228
- });
7229
-
7230
  }(jQuery));
7231
- /*******************************************************************************
7232
- * Copyright (c) 2017, WP Popup Maker
7233
- ******************************************************************************/
7234
- (function ($) {
7235
- "use strict";
7236
-
7237
- var models = {
7238
- field: function (args) {
7239
- return $.extend(true, {}, {
7240
- type: 'text',
7241
- id: '',
7242
- id_prefix: '',
7243
- name: '',
7244
- label: null,
7245
- placeholder: '',
7246
- desc: null,
7247
- dynamic_desc: null,
7248
- size: 'regular',
7249
- classes: [],
7250
- dependencies: "",
7251
- value: null,
7252
- select2: false,
7253
- allow_html: false,
7254
- multiple: false,
7255
- as_array: false,
7256
- options: [],
7257
- object_type: null,
7258
- object_key: null,
7259
- std: null,
7260
- min: 0,
7261
- max: 50,
7262
- step: 1,
7263
- unit: 'px',
7264
- units: {},
7265
- required: false,
7266
- desc_position: 'bottom',
7267
- meta: {}
7268
- }, args);
7269
- }
7270
- };
7271
-
7272
- // Import this module.
7273
- window.PUM_Admin = window.PUM_Admin || {};
7274
- window.PUM_Admin.models = models;
 
7275
  }(jQuery));
7276
- /*******************************************************************************
7277
- * Copyright (c) 2017, WP Popup Maker
7278
- ******************************************************************************/
7279
- (function ($) {
7280
- 'use strict';
7281
- var rangesliders = {
7282
- cloneables: {
7283
- slider: $('<input type="range" class="pum-range-slider" />'),
7284
- plus: $('<button type="button" class="pum-range-plus">+</button>'),
7285
- minus: $('<button type="button" class="pum-range-minus">-</button>')
7286
- },
7287
- init: function () {
7288
- $('.pum-field-rangeslider:not(.pum-rangeslider-initialized)').each(function () {
7289
- var $this = $(this).addClass('pum-rangeslider-initialized'),
7290
- $input = $this.find('input.pum-range-manual'),
7291
- $slider = rangesliders.cloneables.slider.clone(),
7292
- $plus = rangesliders.cloneables.plus.clone(),
7293
- $minus = rangesliders.cloneables.minus.clone(),
7294
- settings = {
7295
- force: $input.data('force-minmax'),
7296
- min: parseInt($input.attr('min'), 10) || 0,
7297
- max: parseInt($input.attr('max'), 10) || 100,
7298
- step: parseInt($input.attr('step'), 10) || 1,
7299
- value: parseInt($input.attr('value'), 10) || 0
7300
- };
7301
-
7302
- if (settings.force && settings.value > settings.max) {
7303
- settings.value = settings.max;
7304
- $input.val(settings.value);
7305
- }
7306
-
7307
- $slider.prop({
7308
- min: settings.min || 0,
7309
- max: (settings.force || (settings.max && settings.max > settings.value)) ? settings.max : settings.value *
7310
- 1.5,
7311
- step: settings.step || settings.value * 1.5 / 100,
7312
- value: settings.value
7313
- }).on('change input', function () {
7314
- $input.trigger('input');
7315
- });
7316
-
7317
- $input.next().after($minus, $plus);
7318
- $input.before($slider);
7319
-
7320
- });
7321
- }
7322
- };
7323
-
7324
- // Import this module.
7325
- window.PUM_Admin = window.PUM_Admin || {};
7326
- window.PUM_Admin.rangesliders = rangesliders;
7327
-
7328
- $(document)
7329
- .on('pum_init', PUM_Admin.rangesliders.init)
7330
- /**
7331
- * Updates the input field when the slider is used.
7332
- */
7333
- .on('input', '.pum-field-rangeslider.pum-rangeslider-initialized .pum-range-slider', function () {
7334
- var $slider = $(this);
7335
- $slider.siblings('.pum-range-manual').val($slider.val());
7336
- })
7337
- /**
7338
- * Update sliders value, min, & max when manual entry is detected.
7339
- */
7340
- .on('change', '.pum-range-manual', function () {
7341
- var $input = $(this),
7342
- max = parseInt($input.prop('max'), 0),
7343
- min = parseInt($input.prop('min'), 0),
7344
- step = parseInt($input.prop('step'), 0),
7345
- force = $input.data('force-minmax'),
7346
- value = parseInt($input.val(), 0),
7347
- $slider = $input.prev();
7348
-
7349
- if (isNaN(value)) {
7350
- value = $slider.val();
7351
- }
7352
-
7353
- if (force && value > max) {
7354
- value = max;
7355
- } else if (force && value < min) {
7356
- value = min;
7357
- }
7358
-
7359
- $input.val(value).trigger('input');
7360
-
7361
- $slider.prop({
7362
- 'max': force || (max && max > value) ? max : value * 1.5,
7363
- 'step': step || value * 1.5 / 100,
7364
- 'value': value
7365
- });
7366
- })
7367
- .on('click', '.pum-range-plus', function (event) {
7368
- var $input = $(this).siblings('.pum-range-manual'),
7369
- max = parseInt($input.prop('max'), 0),
7370
- step = parseInt($input.prop('step'), 0),
7371
- force = $input.data('force-minmax'),
7372
- value = parseInt($input.val(), 0),
7373
- $slider = $input.prev();
7374
-
7375
- event.preventDefault();
7376
-
7377
- value += step;
7378
-
7379
- if (isNaN(value)) {
7380
- value = $slider.val();
7381
- }
7382
-
7383
- if (force && value > max) {
7384
- value = max;
7385
- }
7386
-
7387
- $input.val(value).trigger('input');
7388
- $slider.val(value);
7389
- })
7390
- .on('click', '.pum-range-minus', function (event) {
7391
- var $input = $(this).siblings('.pum-range-manual'),
7392
- min = parseInt($input.prop('min'), 0),
7393
- step = parseInt($input.prop('step'), 0),
7394
- force = $input.data('force-minmax'),
7395
- value = parseInt($input.val(), 0),
7396
- $slider = $input.prev();
7397
-
7398
- event.preventDefault();
7399
-
7400
- value -= step;
7401
-
7402
- if (isNaN(value)) {
7403
- value = $slider.val();
7404
- }
7405
-
7406
- if (force && value < min) {
7407
- value = min;
7408
- }
7409
-
7410
- $input.val(value).trigger('input');
7411
- $slider.val(value);
7412
- });
7413
-
7414
  }(jQuery));
7415
- /*******************************************************************************
7416
- * Copyright (c) 2017, WP Popup Maker
7417
- ******************************************************************************/
7418
- (function ($) {
7419
- "use strict";
7420
-
7421
- // Here because some plugins load additional copies, big no-no. This is the best we can do.
7422
- $.fn.pumselect2 = $.fn.pumselect2 || $.fn.select2;
7423
-
7424
- var select2 = {
7425
- init: function () {
7426
- $('.pum-field-select2 select').filter(':not(.pumselect2-initialized)').each(function () {
7427
- var $this = $(this),
7428
- current = $this.data('current') || $this.val(),
7429
- object_type = $this.data('objecttype'),
7430
- object_key = $this.data('objectkey'),
7431
- object_excludes = $this.data('objectexcludes') || null,
7432
- options = {
7433
- width: '100%',
7434
- multiple: false,
7435
- dropdownParent: $this.parent()
7436
- };
7437
-
7438
- if ($this.attr('multiple')) {
7439
- options.multiple = true;
7440
- }
7441
-
7442
- if (object_type && object_key) {
7443
- options = $.extend(options, {
7444
- ajax: {
7445
- url: ajaxurl,
7446
- dataType: 'json',
7447
- delay: 250,
7448
- data: function (params) {
7449
- return {
7450
- s: params.term, // search term
7451
- paged: params.page,
7452
- action: "pum_object_search",
7453
- object_type: object_type,
7454
- object_key: object_key,
7455
- exclude: object_excludes
7456
- };
7457
- },
7458
- processResults: function (data, params) {
7459
- // parse the results into the format expected by Select2
7460
- // since we are using custom formatting functions we do not need to
7461
- // alter the remote JSON data, except to indicate that infinite
7462
- // scrolling can be used
7463
- params.page = params.page || 1;
7464
-
7465
- return {
7466
- results: data.items,
7467
- pagination: {
7468
- more: (params.page * 10) < data.total_count
7469
- }
7470
- };
7471
- },
7472
- cache: true
7473
- },
7474
- cache: true,
7475
- escapeMarkup: function (markup) {
7476
- return markup;
7477
- }, // let our custom formatter work
7478
- maximumInputLength: 20,
7479
- closeOnSelect: !options.multiple,
7480
- templateResult: PUM_Admin.select2.formatObject,
7481
- templateSelection: PUM_Admin.select2.formatObjectSelection
7482
- });
7483
- }
7484
-
7485
- $this
7486
- .addClass('pumselect2-initialized')
7487
- .pumselect2(options);
7488
-
7489
- if (current !== null && current !== undefined) {
7490
-
7491
- if (options.multiple && 'object' !== typeof current && current !== "") {
7492
- current = [current];
7493
- } else if (!options.multiple && current === '') {
7494
- current = null;
7495
- }
7496
- } else {
7497
- current = null;
7498
- }
7499
-
7500
- if (object_type && object_key && current !== null && (typeof current === 'number' || current.length)) {
7501
- $.ajax({
7502
- url: ajaxurl,
7503
- data: {
7504
- action: "pum_object_search",
7505
- object_type: object_type,
7506
- object_key: object_key,
7507
- exclude: object_excludes,
7508
- include: current && current.length ? (typeof current === 'string' || typeof current === 'number') ? [current] : current : null
7509
- },
7510
- dataType: "json",
7511
- success: function (data) {
7512
- $.each(data.items, function (key, item) {
7513
- // Add any option that doesn't already exist
7514
- if (!$this.find('option[value="' + item.id + '"]').length) {
7515
- $this.prepend('<option value="' + item.id + '">' + item.text + '</option>');
7516
- }
7517
- });
7518
- // Update the options
7519
- $this.val(current).trigger('change');
7520
- }
7521
- });
7522
- } else if (current && ((options.multiple && current.length) || (!options.multiple && current !== ""))) {
7523
- $this.val(current).trigger('change');
7524
- } else if (current === null) {
7525
- $this.val(current).trigger('change');
7526
- }
7527
- });
7528
- },
7529
- formatObject: function (object) {
7530
- return object.text;
7531
- },
7532
- formatObjectSelection: function (object) {
7533
- return object.text || object.text;
7534
- }
7535
- };
7536
-
7537
- // Import this module.
7538
- window.PUM_Admin = window.PUM_Admin || {};
7539
- window.PUM_Admin.select2 = select2;
7540
-
7541
- $(document)
7542
- .on('pum_init', function () {
7543
- PUM_Admin.select2.init();
7544
- });
7545
  }(jQuery));
7546
- /*
7547
- * $$ Selector Cache
7548
- * Cache your selectors, without messy code.
7549
- * @author Stephen Kamenar
7550
- */
7551
- (function ($, undefined) {
7552
- // '#a': $('#a')
7553
- if (typeof window.$$ === 'function') {
7554
- return;
7555
- }
7556
-
7557
- var cache = {},
7558
- cacheByContext = {}, // '#context': (a cache object for the element)
7559
- tmp, tmp2; // Here for performance/minification
7560
-
7561
- window.$$ = function (selector, context) {
7562
- if (context) {
7563
- if (tmp = context.selector) {
7564
- context = tmp;
7565
- }
7566
-
7567
- // tmp2 is contextCache
7568
- tmp2 = cacheByContext[context];
7569
-
7570
- if (tmp2 === undefined) {
7571
- tmp2 = cacheByContext[context] = {};
7572
- }
7573
-
7574
- tmp = tmp2[selector];
7575
-
7576
- if (tmp !== undefined) {
7577
- return tmp;
7578
- }
7579
-
7580
- return tmp2[selector] = $(selector, $$(context));
7581
- }
7582
-
7583
- tmp = cache[selector];
7584
-
7585
- if (tmp !== undefined) {
7586
- return tmp;
7587
- }
7588
-
7589
- return cache[selector] = $(selector);
7590
- };
7591
-
7592
- window.$$clear = function (selector, context) {
7593
- if (context) {
7594
- if (tmp = context.selector) {
7595
- context = tmp;
7596
- }
7597
-
7598
- if (selector && (tmp = cacheByContext[context])) {
7599
- tmp[selector] = undefined;
7600
- }
7601
-
7602
- cacheByContext[context] = undefined;
7603
- } else {
7604
- if (selector) {
7605
- cache[selector] = undefined;
7606
- cacheByContext[selector] = undefined;
7607
- } else {
7608
- cache = {};
7609
- cacheByContext = {};
7610
- }
7611
- }
7612
- };
7613
-
7614
- window.$$fresh = function (selector, context) {
7615
- $$clear(selector, context);
7616
- return $$(selector, context);
7617
- };
7618
-
7619
  }(jQuery));
7620
- /**
7621
- * jQuery serializeObject
7622
- * @copyright 2014, macek <paulmacek@gmail.com>
7623
- * @link https://github.com/macek/jquery-serialize-object
7624
- * @license BSD
7625
- * @version 2.5.0
7626
- */
7627
- (function (root, factory) {
7628
-
7629
- // AMD
7630
- if (typeof define === "function" && define.amd) {
7631
- define(["exports", "jquery"], function (exports, $) {
7632
- return factory(exports, $);
7633
- });
7634
- }
7635
-
7636
- // CommonJS
7637
- else if (typeof exports !== "undefined") {
7638
- var $ = require("jquery");
7639
- factory(exports, $);
7640
- }
7641
-
7642
- // Browser
7643
- else {
7644
- factory(root, (root.jQuery || root.Zepto || root.ender || root.$));
7645
- }
7646
-
7647
- }(this, function (exports, $) {
7648
-
7649
- var patterns = {
7650
- validate: /^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,
7651
- key: /[a-z0-9_]+|(?=\[\])/gi,
7652
- push: /^$/,
7653
- fixed: /^\d+$/,
7654
- named: /^[a-z0-9_]+$/i
7655
- };
7656
-
7657
- function FormSerializer(helper, $form) {
7658
-
7659
- // private variables
7660
- var data = {},
7661
- pushes = {};
7662
-
7663
- // private API
7664
- function build(base, key, value) {
7665
- base[key] = value;
7666
- return base;
7667
- }
7668
-
7669
- function makeObject(root, value) {
7670
-
7671
- var keys = root.match(patterns.key), k;
7672
-
7673
- try {
7674
- value = JSON.parse(value);
7675
- } catch (Error) {
7676
- }
7677
-
7678
- // nest, nest, ..., nest
7679
- while ((k = keys.pop()) !== undefined) {
7680
- // foo[]
7681
- if (patterns.push.test(k)) {
7682
- var idx = incrementPush(root.replace(/\[\]$/, ''));
7683
- value = build([], idx, value);
7684
- }
7685
-
7686
- // foo[n]
7687
- else if (patterns.fixed.test(k)) {
7688
- value = build([], k, value);
7689
- }
7690
-
7691
- // foo; foo[bar]
7692
- else if (patterns.named.test(k)) {
7693
- value = build({}, k, value);
7694
- }
7695
- }
7696
-
7697
- return value;
7698
- }
7699
-
7700
- function incrementPush(key) {
7701
- if (pushes[key] === undefined) {
7702
- pushes[key] = 0;
7703
- }
7704
- return pushes[key]++;
7705
- }
7706
-
7707
- function encode(pair) {
7708
- switch ($('[name="' + pair.name + '"]', $form).attr("type")) {
7709
- case "checkbox":
7710
- return pair.value === "1" ? true : pair.value;
7711
- default:
7712
- return pair.value;
7713
- }
7714
- }
7715
-
7716
- function addPair(pair) {
7717
- if (!patterns.validate.test(pair.name)) return this;
7718
- var obj = makeObject(pair.name, encode(pair));
7719
-
7720
- data = helper.extend(true, data, obj);
7721
- return this;
7722
- }
7723
-
7724
- function addPairs(pairs) {
7725
- if (!helper.isArray(pairs)) {
7726
- throw new Error("formSerializer.addPairs expects an Array");
7727
- }
7728
- for (var i = 0, len = pairs.length; i < len; i++) {
7729
- this.addPair(pairs[i]);
7730
- }
7731
- return this;
7732
- }
7733
-
7734
- function serialize() {
7735
- return data;
7736
- }
7737
-
7738
- function serializeJSON() {
7739
- return JSON.stringify(serialize());
7740
- }
7741
-
7742
- // public API
7743
- this.addPair = addPair;
7744
- this.addPairs = addPairs;
7745
- this.serialize = serialize;
7746
- this.serializeJSON = serializeJSON;
7747
- }
7748
-
7749
- FormSerializer.patterns = patterns;
7750
-
7751
- FormSerializer.serializeObject = function serializeObject() {
7752
- var serialized;
7753
-
7754
- if (this.is('form')) {
7755
- serialized = this.serializeArray();
7756
- } else {
7757
- serialized = this.find(':input').serializeArray();
7758
- }
7759
-
7760
- return new FormSerializer($, this)
7761
- .addPairs(serialized)
7762
- .serialize();
7763
- };
7764
-
7765
- FormSerializer.serializeJSON = function serializeJSON() {
7766
- var serialized;
7767
-
7768
- if (this.is('form')) {
7769
- serialized = this.serializeArray();
7770
- } else {
7771
- serialized = this.find(':input').serializeArray();
7772
- }
7773
-
7774
- return new FormSerializer($, this)
7775
- .addPairs(serialized)
7776
- .serializeJSON();
7777
- };
7778
-
7779
- if (typeof $.fn !== "undefined") {
7780
- $.fn.pumSerializeObject = FormSerializer.serializeObject;
7781
- $.fn.pumSerializeJSON = FormSerializer.serializeJSON;
7782
- }
7783
-
7784
- exports.FormSerializer = FormSerializer;
7785
-
7786
- return FormSerializer;
7787
  }));
7788
- /*******************************************************************************
7789
- * Copyright (c) 2017, WP Popup Maker
7790
- ******************************************************************************/
7791
- (function ($) {
7792
- "use strict";
7793
- var tabs = {
7794
- init: function () {
7795
- $('.pum-tabs-container').filter(':not(.pum-tabs-initialized)').each(function () {
7796
- var $this = $(this).addClass('pum-tabs-initialized'),
7797
- $tabList = $this.find('> ul.tabs'),
7798
- $firstTab = $tabList.find('> li:first'),
7799
- forceMinHeight = $this.data('min-height');
7800
-
7801
- if ($this.hasClass('vertical-tabs')) {
7802
- var minHeight = forceMinHeight && forceMinHeight > 0 ? forceMinHeight : $tabList.eq(0).outerHeight(true);
7803
-
7804
- $this.css({
7805
- minHeight: minHeight + 'px'
7806
- });
7807
-
7808
- if ($this.parent().innerHeight < minHeight) {
7809
- $this.parent().css({
7810
- minHeight: minHeight + 'px'
7811
- });
7812
- }
7813
- }
7814
-
7815
- // Trigger first tab.
7816
- $firstTab.trigger('click');
7817
- });
7818
- }
7819
- };
7820
-
7821
- // Import this module.
7822
- window.PUM_Admin = window.PUM_Admin || {};
7823
- window.PUM_Admin.tabs = tabs;
7824
-
7825
- $(document)
7826
- .on('pum_init', PUM_Admin.tabs.init)
7827
- .on('click', '.pum-tabs-initialized li.tab', function (e) {
7828
- var $this = $(this),
7829
- $container = $this.parents('.pum-tabs-container:first'),
7830
- $tabs = $container.find('> ul.tabs > li.tab'),
7831
- $tab_contents = $container.find('> div.tab-content'),
7832
- link = $this.find('a').attr('href');
7833
-
7834
- $tabs.removeClass('active');
7835
- $tab_contents.removeClass('active');
7836
-
7837
- $this.addClass('active');
7838
- $container.find('> div.tab-content' + link).addClass('active');
7839
-
7840
- e.preventDefault();
7841
- });
7842
  }(jQuery));
7843
- /*******************************************************************************
7844
- * Copyright (c) 2017, WP Popup Maker
7845
- ******************************************************************************/
7846
- (function ($) {
7847
- "use strict";
7848
- var I10n = pum_admin_vars.I10n,
7849
- templates = {
7850
- render: function (template, data) {
7851
- var _template = wp.template(template);
7852
-
7853
- data = data || {};
7854
-
7855
- if (data.classes !== undefined && Array.isArray(data.classes)) {
7856
- data.classes = data.classes.join(' ');
7857
- }
7858
-
7859
- // Prepare the meta data for templates.
7860
- data = PUM_Admin.templates.prepareMeta(data);
7861
-
7862
- return _template(data);
7863
- },
7864
- renderInline: function (content, data) {
7865
- var options = {
7866
- evaluate: /<#([\s\S]+?)#>/g,
7867
- interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
7868
- escape: /\{\{([^\}]+?)\}\}(?!\})/g,
7869
- variable: 'data'
7870
- },
7871
- template = _.template(content, null, options);
7872
-
7873
- return template(data);
7874
- },
7875
- shortcode: function (args) {
7876
- var data = $.extend(true, {}, {
7877
- tag: '',
7878
- meta: {},
7879
- has_content: false,
7880
- content: ''
7881
- }, args),
7882
- template = data.has_content ? 'pum-shortcode-w-content' : 'pum-shortcode';
7883
-
7884
- return PUM_Admin.templates.render(template, data);
7885
- },
7886
- modal: function (args) {
7887
- var data = $.extend(true, {}, {
7888
- id: '',
7889
- title: '',
7890
- description: '',
7891
- classes: '',
7892
- save_button: I10n.save,
7893
- cancel_button: I10n.cancel,
7894
- content: ''
7895
- }, args);
7896
-
7897
- return PUM_Admin.templates.render('pum-modal', data);
7898
- },
7899
- tabs: function (data) {
7900
- data = $.extend(true, {}, {
7901
- id: '',
7902
- vertical: false,
7903
- form: false,
7904
- classes: [],
7905
- tabs: {},
7906
- meta: {}
7907
- }, data);
7908
-
7909
- if (typeof data.classes === 'string') {
7910
- data.classes = [data.classes];
7911
- }
7912
-
7913
- if (data.form) {
7914
- data.classes.push('pum-tabbed-form');
7915
- }
7916
-
7917
- data.meta['data-tab-count'] = Object.keys(data.tabs).length;
7918
-
7919
- data.classes.push(data.vertical ? 'vertical-tabs' : 'horizontal-tabs');
7920
-
7921
- data.classes = data.classes.join(' ');
7922
-
7923
- return PUM_Admin.templates.render('pum-tabs', data);
7924
- },
7925
- section: function (args) {
7926
- var data = $.extend(true, {}, {
7927
- classes: [],
7928
- fields: []
7929
- }, args);
7930
-
7931
-
7932
- return PUM_Admin.templates.render('pum-field-section', data);
7933
- },
7934
- fieldArgs: function (args) {
7935
- var options = [],
7936
- data = $.extend(true, {}, PUM_Admin.models.field(args));
7937
-
7938
- if (args.std !== undefined && args.type !== 'checkbox' && (data.value === null || data.value === false)) {
7939
- data.value = args.std;
7940
- }
7941
-
7942
- if ('string' === typeof data.classes) {
7943
- data.classes = data.classes.split(' ');
7944
- }
7945
-
7946
- if (args.class !== undefined) {
7947
- data.classes.push(args.class);
7948
- }
7949
-
7950
- if (args.dependencies !== undefined && typeof args.dependencies === 'object') {
7951
- data.dependencies = JSON.stringify(args.dependencies);
7952
- }
7953
-
7954
- if (data.required) {
7955
- data.meta.required = true;
7956
- data.classes.push('pum-required');
7957
- }
7958
-
7959
- if (typeof data.dynamic_desc === 'string' && data.dynamic_desc.length) {
7960
- data.classes.push('pum-field-dynamic-desc');
7961
- data.desc = PUM_Admin.templates.renderInline(data.dynamic_desc, data);
7962
- }
7963
-
7964
- if (data.allow_html) {
7965
- data.classes.push('pum-field-' + data.type + '--html');
7966
- if ( typeof data.value === 'string' && data.value !== '' && PUM_Admin.utils.htmlencoder.hasEncoded(data.value)) {
7967
- data.value = PUM_Admin.utils.htmlencoder.htmlDecode(data.value);
7968
- }
7969
- }
7970
-
7971
- switch (args.type) {
7972
- case 'select':
7973
- case 'objectselect':
7974
- case 'postselect':
7975
- case 'taxonomyselect':
7976
- if (data.options !== undefined) {
7977
- _.each(data.options, function (label, value) {
7978
- var selected = false,
7979
- optgroup,
7980
- optgroup_options;
7981
-
7982
- // Check if the label is an object. If so this is a optgroup and the label is sub options array.
7983
- // NOTE: The value in the case its an optgroup is the optgroup label.
7984
- if (typeof label !== 'object') {
7985
-
7986
- if (data.value !== null) {
7987
- if (data.multiple && ((typeof data.value === 'string' && data.value == value) || (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined))) {
7988
- selected = 'selected';
7989
- } else if (!data.multiple && data.value == value) {
7990
- selected = 'selected';
7991
- }
7992
- }
7993
-
7994
- options.push(
7995
- PUM_Admin.templates.prepareMeta({
7996
- label: label,
7997
- value: value,
7998
- meta: {
7999
- selected: selected
8000
- }
8001
- })
8002
- );
8003
-
8004
- } else {
8005
- // Process Option Groups
8006
-
8007
- // Swap label & value due to group labels being used as keys.
8008
- optgroup = value;
8009
- optgroup_options = [];
8010
-
8011
- _.each(label, function (label, value) {
8012
- var selected = false;
8013
-
8014
- if (data.value !== null) {
8015
- if (data.multiple && ((typeof data.value === 'string' && data.value == value) || (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined))) {
8016
- selected = 'selected';
8017
- } else if (!data.multiple && data.value == value) {
8018
- selected = 'selected';
8019
- }
8020
- }
8021
- optgroup_options.push(
8022
- PUM_Admin.templates.prepareMeta({
8023
- label: label,
8024
- value: value,
8025
- meta: {
8026
- selected: selected
8027
- }
8028
- })
8029
- );
8030
-
8031
- });
8032
-
8033
- options.push({
8034
- label: optgroup,
8035
- options: optgroup_options
8036
- });
8037
-
8038
- }
8039
-
8040
- });
8041
-
8042
- data.options = options;
8043
-
8044
- }
8045
-
8046
- if (data.multiple) {
8047
-
8048
- data.meta.multiple = true;
8049
-
8050
- if (data.as_array) {
8051
- data.name += '[]';
8052
- }
8053
-
8054
- if (!data.value || !data.value.length) {
8055
- data.value = [];
8056
- }
8057
-
8058
- if (typeof data.value === 'string') {
8059
- data.value = [data.value];
8060
- }
8061
-
8062
- }
8063
-
8064
- if (args.type !== 'select') {
8065
- data.select2 = true;
8066
- data.classes.push('pum-field-objectselect');
8067
- data.classes.push(args.type === 'postselect' ? 'pum-field-postselect' : 'pum-field-taxonomyselect');
8068
- data.meta['data-objecttype'] = args.type === 'postselect' ? 'post_type' : 'taxonomy';
8069
- data.meta['data-objectkey'] = args.type === 'postselect' ? args.post_type : args.taxonomy;
8070
- data.meta['data-current'] = typeof data.value === 'object' || Array.isArray(data.value) ? JSON.stringify(data.value) : data.value;
8071
- }
8072
-
8073
- if (data.select2) {
8074
- data.classes.push('pum-field-select2');
8075
-
8076
- if (data.placeholder) {
8077
- data.meta['data-placeholder'] = data.placeholder;
8078
- }
8079
- }
8080
-
8081
- break;
8082
- case 'radio':
8083
- if (data.options !== undefined) {
8084
- _.each(data.options, function (label, value) {
8085
-
8086
- options.push(
8087
- PUM_Admin.templates.prepareMeta({
8088
- label: label,
8089
- value: value,
8090
- meta: {
8091
- checked: data.value === value
8092
- }
8093
- })
8094
- );
8095
-
8096
- });
8097
-
8098
- data.options = options;
8099
- }
8100
- break;
8101
- case 'multicheck':
8102
- if (data.options !== undefined) {
8103
-
8104
- if (data.value === false || data.value === null) {
8105
- data.value = [];
8106
- }
8107
-
8108
- debugger;
8109
-
8110
- if (typeof data.value === 'string' && data.value.indexOf(',')) {
8111
- data.value = data.value.split(',');
8112
- }
8113
-
8114
- if (data.as_array) {
8115
- data.name += '[]';
8116
- }
8117
-
8118
- _.each(data.options, function (label, value) {
8119
-
8120
- options.push(
8121
- PUM_Admin.templates.prepareMeta({
8122
- label: label,
8123
- value: value,
8124
- meta: {
8125
- checked: (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined)
8126
- }
8127
- })
8128
- );
8129
-
8130
- });
8131
-
8132
- data.options = options;
8133
- }
8134
- break;
8135
- case 'checkbox':
8136
- switch (typeof data.value) {
8137
- case 'object':
8138
- if (Array.isArray(data.value) && data.value.length === 1 && data.value[0].toString() === '1') {
8139
- data.value = true;
8140
- data.meta.checked = true;
8141
- } else {
8142
-
8143
- }
8144
- break;
8145
- case 'boolean':
8146
- if (data.value) {
8147
- data.meta.checked = true;
8148
- }
8149
- break;
8150
- case 'string':
8151
- if (data.value === 'true' || data.value === 'yes' || data.value === '1') {
8152
- data.meta.checked = true;
8153
- }
8154
- break;
8155
- case 'number':
8156
- if (parseInt(data.value, 10) === 1 || parseInt(data.value, 10) > 0) {
8157
- data.meta.checked = true;
8158
- }
8159
- }
8160
- break;
8161
- case 'rangeslider':
8162
- // data.meta.readonly = true;
8163
- data.meta.step = data.step;
8164
- data.meta.min = data.min;
8165
- data.meta.max = data.max;
8166
- data.meta['data-force-minmax'] = data.force_minmax.toString();
8167
- break;
8168
- case 'textarea':
8169
- data.meta.cols = data.cols;
8170
- data.meta.rows = data.rows;
8171
- break;
8172
- case 'measure':
8173
- if (typeof data.value === 'string' && data.value !== '') {
8174
- data.number = parseInt(data.value);
8175
- data.unitValue = data.value.replace(data.number, "");
8176
- data.value = data.number;
8177
- } else {
8178
- data.unitValue = null;
8179
- }
8180
-
8181
- if (data.units !== undefined) {
8182
- _.each(data.units, function (label, value) {
8183
- var selected = false;
8184
-
8185
- if (data.unitValue == value) {
8186
- selected = 'selected';
8187
- }
8188
-
8189
- options.push(
8190
- PUM_Admin.templates.prepareMeta({
8191
- label: label,
8192
- value: value,
8193
- meta: {
8194
- selected: selected
8195
- }
8196
- })
8197
- );
8198
-
8199
- });
8200
-
8201
- data.units = options;
8202
- }
8203
- break;
8204
- case 'color':
8205
- if ( typeof data.value === 'string' && data.value !== '') {
8206
- data.meta['data-default-color'] = data.value;
8207
- }
8208
- break;
8209
- case 'license_key':
8210
-
8211
- data.value = $.extend({
8212
- key: '',
8213
- license: {},
8214
- messages: [],
8215
- status: 'empty',
8216
- expires: false,
8217
- classes: false
8218
- }, data.value);
8219
-
8220
- data.classes.push('pum-license-' + data.value.status + '-notice');
8221
-
8222
- if (data.value.classes) {
8223
- data.classes.push(data.value.classes);
8224
- }
8225
- break;
8226
- }
8227
-
8228
- return data;
8229
- },
8230
- field: function (args) {
8231
- var fieldTemplate,
8232
- data = PUM_Admin.templates.fieldArgs(args);
8233
-
8234
- fieldTemplate = 'pum-field-' + data.type;
8235
-
8236
- if (data.type === 'objectselfect' || data.type === 'postselect' || data.type === 'taxonomyselect') {
8237
- fieldTemplate = 'pum-field-select';
8238
- }
8239
-
8240
- if (!$('#tmpl-' + fieldTemplate).length) {
8241
- console.warn('No field template found for type:' + data.type + ' fieldID: ' + data.id);
8242
- return '';
8243
- }
8244
-
8245
- data.field = PUM_Admin.templates.render(fieldTemplate, data);
8246
-
8247
- return PUM_Admin.templates.render('pum-field-wrapper', data);
8248
- },
8249
- prepareMeta: function (data) {
8250
- // Convert meta JSON to attribute string.
8251
- var _meta = [],
8252
- key;
8253
-
8254
- for (key in data.meta) {
8255
- if (data.meta.hasOwnProperty(key)) {
8256
- // Boolean attributes can only require attribute key, not value.
8257
- if ('boolean' === typeof data.meta[key]) {
8258
- // Only set truthy boolean attributes.
8259
- if (data.meta[key]) {
8260
- _meta.push(_.escape(key));
8261
- }
8262
- } else {
8263
- _meta.push(_.escape(key) + '="' + _.escape(data.meta[key]) + '"');
8264
- }
8265
- }
8266
- }
8267
-
8268
- data.meta = _meta.join(' ');
8269
- return data;
8270
- }
8271
- };
8272
-
8273
- // Import this module.
8274
- window.PUM_Admin = window.PUM_Admin || {};
8275
- window.PUM_Admin.templates = templates;
8276
  }(window.jQuery));
8277
- /*******************************************************************************
8278
- * Copyright (c) 2017, WP Popup Maker
8279
- ******************************************************************************/
8280
- (function ($) {
8281
- "use strict";
8282
-
8283
- String.prototype.capitalize = function () {
8284
- return this.charAt(0).toUpperCase() + this.slice(1);
8285
- };
8286
-
8287
- var root = this,
8288
- inputTypes = 'color,date,datetime,datetime-local,email,hidden,month,number,password,range,search,tel,text,time,url,week'.split(','),
8289
- inputNodes = 'select,textarea'.split(','),
8290
- rName = /\[([^\]]*)\]/g;
8291
-
8292
- // ugly hack for IE7-8
8293
- function isInArray(array, needle) {
8294
- return $.inArray(needle, array) !== -1;
8295
- }
8296
-
8297
- function storeValue(container, parsedName, value) {
8298
-
8299
- var part = parsedName[0];
8300
-
8301
- if (parsedName.length > 1) {
8302
- if (!container[part]) {
8303
- // If the next part is eq to '' it means we are processing complex name (i.e. `some[]`)
8304
- // for this case we need to use Array instead of an Object for the index increment purpose
8305
- container[part] = parsedName[1] ? {} : [];
8306
- }
8307
- storeValue(container[part], parsedName.slice(1), value);
8308
- } else {
8309
-
8310
- // Increment Array index for `some[]` case
8311
- if (!part) {
8312
- part = container.length;
8313
- }
8314
-
8315
- container[part] = value;
8316
- }
8317
- }
8318
-
8319
- /**
8320
- * A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding
8321
- * Author: R Reid
8322
- * source: http://www.strictly-software.com/htmlencode
8323
- * Licences: GPL, The MIT License (MIT)
8324
- * Copyright: (c) 2011 Robert Reid - Strictly-Software.com
8325
- *
8326
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8327
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8328
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8329
- *
8330
- * Revision:
8331
- * 2011-07-14, Jacques-Yves Bleau:
8332
- * - fixed conversion error with capitalized accentuated characters
8333
- * + converted arr1 and arr2 to object property to remove redundancy
8334
- *
8335
- * Revision:
8336
- * 2011-11-10, Ce-Yi Hio:
8337
- * - fixed conversion error with a number of capitalized entity characters
8338
- *
8339
- * Revision:
8340
- * 2011-11-10, Rob Reid:
8341
- * - changed array format
8342
- *
8343
- * Revision:
8344
- * 2012-09-23, Alex Oss:
8345
- * - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid
8346
- */
8347
-
8348
- var Encoder = {
8349
-
8350
- // When encoding do we convert characters into html or numerical entities
8351
- EncodeType : "entity", // entity OR numerical
8352
-
8353
- isEmpty : function(val){
8354
- if(val){
8355
- return ((val===null) || val.length==0 || /^\s+$/.test(val));
8356
- }else{
8357
- return true;
8358
- }
8359
- },
8360
-
8361
- // arrays for conversion from HTML Entities to Numerical values
8362
- arr1: ['&nbsp;','&iexcl;','&cent;','&pound;','&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','&shy;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&sup1;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;','&quot;','&amp;','&lt;','&gt;','&OElig;','&oelig;','&Scaron;','&scaron;','&Yuml;','&circ;','&tilde;','&ensp;','&emsp;','&thinsp;','&zwnj;','&zwj;','&lrm;','&rlm;','&ndash;','&mdash;','&lsquo;','&rsquo;','&sbquo;','&ldquo;','&rdquo;','&bdquo;','&dagger;','&Dagger;','&permil;','&lsaquo;','&rsaquo;','&euro;','&fnof;','&Alpha;','&Beta;','&Gamma;','&Delta;','&Epsilon;','&Zeta;','&Eta;','&Theta;','&Iota;','&Kappa;','&Lambda;','&Mu;','&Nu;','&Xi;','&Omicron;','&Pi;','&Rho;','&Sigma;','&Tau;','&Upsilon;','&Phi;','&Chi;','&Psi;','&Omega;','&alpha;','&beta;','&gamma;','&delta;','&epsilon;','&zeta;','&eta;','&theta;','&iota;','&kappa;','&lambda;','&mu;','&nu;','&xi;','&omicron;','&pi;','&rho;','&sigmaf;','&sigma;','&tau;','&upsilon;','&phi;','&chi;','&psi;','&omega;','&thetasym;','&upsih;','&piv;','&bull;','&hellip;','&prime;','&Prime;','&oline;','&frasl;','&weierp;','&image;','&real;','&trade;','&alefsym;','&larr;','&uarr;','&rarr;','&darr;','&harr;','&crarr;','&lArr;','&uArr;','&rArr;','&dArr;','&hArr;','&forall;','&part;','&exist;','&empty;','&nabla;','&isin;','&notin;','&ni;','&prod;','&sum;','&minus;','&lowast;','&radic;','&prop;','&infin;','&ang;','&and;','&or;','&cap;','&cup;','&int;','&there4;','&sim;','&cong;','&asymp;','&ne;','&equiv;','&le;','&ge;','&sub;','&sup;','&nsub;','&sube;','&supe;','&oplus;','&otimes;','&perp;','&sdot;','&lceil;','&rceil;','&lfloor;','&rfloor;','&lang;','&rang;','&loz;','&spades;','&clubs;','&hearts;','&diams;'],
8363
- arr2: ['&#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;','&#194;','&#195;','&#196;','&#197;','&#198;','&#199;','&#200;','&#201;','&#202;','&#203;','&#204;','&#205;','&#206;','&#207;','&#208;','&#209;','&#210;','&#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;','&#253;','&#254;','&#255;','&#34;','&#38;','&#60;','&#62;','&#338;','&#339;','&#352;','&#353;','&#376;','&#710;','&#732;','&#8194;','&#8195;','&#8201;','&#8204;','&#8205;','&#8206;','&#8207;','&#8211;','&#8212;','&#8216;','&#8217;','&#8218;','&#8220;','&#8221;','&#8222;','&#8224;','&#8225;','&#8240;','&#8249;','&#8250;','&#8364;','&#402;','&#913;','&#914;','&#915;','&#916;','&#917;','&#918;','&#919;','&#920;','&#921;','&#922;','&#923;','&#924;','&#925;','&#926;','&#927;','&#928;','&#929;','&#931;','&#932;','&#933;','&#934;','&#935;','&#936;','&#937;','&#945;','&#946;','&#947;','&#948;','&#949;','&#950;','&#951;','&#952;','&#953;','&#954;','&#955;','&#956;','&#957;','&#958;','&#959;','&#960;','&#961;','&#962;','&#963;','&#964;','&#965;','&#966;','&#967;','&#968;','&#969;','&#977;','&#978;','&#982;','&#8226;','&#8230;','&#8242;','&#8243;','&#8254;','&#8260;','&#8472;','&#8465;','&#8476;','&#8482;','&#8501;','&#8592;','&#8593;','&#8594;','&#8595;','&#8596;','&#8629;','&#8656;','&#8657;','&#8658;','&#8659;','&#8660;','&#8704;','&#8706;','&#8707;','&#8709;','&#8711;','&#8712;','&#8713;','&#8715;','&#8719;','&#8721;','&#8722;','&#8727;','&#8730;','&#8733;','&#8734;','&#8736;','&#8743;','&#8744;','&#8745;','&#8746;','&#8747;','&#8756;','&#8764;','&#8773;','&#8776;','&#8800;','&#8801;','&#8804;','&#8805;','&#8834;','&#8835;','&#8836;','&#8838;','&#8839;','&#8853;','&#8855;','&#8869;','&#8901;','&#8968;','&#8969;','&#8970;','&#8971;','&#9001;','&#9002;','&#9674;','&#9824;','&#9827;','&#9829;','&#9830;'],
8364
-
8365
- // Convert HTML entities into numerical entities
8366
- HTML2Numerical : function(s){
8367
- return this.swapArrayVals(s,this.arr1,this.arr2);
8368
- },
8369
-
8370
- // Convert Numerical entities into HTML entities
8371
- NumericalToHTML : function(s){
8372
- return this.swapArrayVals(s,this.arr2,this.arr1);
8373
- },
8374
-
8375
-
8376
- // Numerically encodes all unicode characters
8377
- numEncode : function(s){
8378
- if(this.isEmpty(s)) return "";
8379
-
8380
- var a = [],
8381
- l = s.length;
8382
-
8383
- for (var i=0;i<l;i++){
8384
- var c = s.charAt(i);
8385
- if (c < " " || c > "~"){
8386
- a.push("&#");
8387
- a.push(c.charCodeAt()); //numeric value of code point
8388
- a.push(";");
8389
- }else{
8390
- a.push(c);
8391
- }
8392
- }
8393
-
8394
- return a.join("");
8395
- },
8396
-
8397
- // HTML Decode numerical and HTML entities back to original values
8398
- htmlDecode : function(s){
8399
-
8400
- var c,m,d = s;
8401
-
8402
- if(this.isEmpty(d)) return "";
8403
-
8404
- // convert HTML entites back to numerical entites first
8405
- d = this.HTML2Numerical(d);
8406
-
8407
- // look for numerical entities &#34;
8408
- var arr=d.match(/&#[0-9]{1,5};/g);
8409
-
8410
- // if no matches found in string then skip
8411
- if(arr!=null){
8412
- for(var x=0;x<arr.length;x++){
8413
- m = arr[x];
8414
- c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
8415
- // if its a valid number we can decode
8416
- if(c >= -32768 && c <= 65535){
8417
- // decode every single match within string
8418
- d = d.replace(m, String.fromCharCode(c));
8419
- }else{
8420
- d = d.replace(m, ""); //invalid so replace with nada
8421
- }
8422
- }
8423
- }
8424
-
8425
- return d;
8426
- },
8427
-
8428
- // encode an input string into either numerical or HTML entities
8429
- htmlEncode : function(s,dbl){
8430
-
8431
- if(this.isEmpty(s)) return "";
8432
-
8433
- // do we allow double encoding? E.g will &amp; be turned into &amp;amp;
8434
- dbl = dbl || false; //default to prevent double encoding
8435
-
8436
- // if allowing double encoding we do ampersands first
8437
- if(dbl){
8438
- if(this.EncodeType=="numerical"){
8439
- s = s.replace(/&/g, "&#38;");
8440
- }else{
8441
- s = s.replace(/&/g, "&amp;");
8442
- }
8443
- }
8444
-
8445
- // convert the xss chars to numerical entities ' " < >
8446
- s = this.XSSEncode(s,false);
8447
-
8448
- if(this.EncodeType=="numerical" || !dbl){
8449
- // Now call function that will convert any HTML entities to numerical codes
8450
- s = this.HTML2Numerical(s);
8451
- }
8452
-
8453
- // Now encode all chars above 127 e.g unicode
8454
- s = this.numEncode(s);
8455
-
8456
- // now we know anything that needs to be encoded has been converted to numerical entities we
8457
- // can encode any ampersands & that are not part of encoded entities
8458
- // to handle the fact that I need to do a negative check and handle multiple ampersands &&&
8459
- // I am going to use a placeholder
8460
-
8461
- // if we don't want double encoded entities we ignore the & in existing entities
8462
- if(!dbl){
8463
- s = s.replace(/&#/g,"##AMPHASH##");
8464
-
8465
- if(this.EncodeType=="numerical"){
8466
- s = s.replace(/&/g, "&#38;");
8467
- }else{
8468
- s = s.replace(/&/g, "&amp;");
8469
- }
8470
-
8471
- s = s.replace(/##AMPHASH##/g,"&#");
8472
- }
8473
-
8474
- // replace any malformed entities
8475
- s = s.replace(/&#\d*([^\d;]|$)/g, "$1");
8476
-
8477
- if(!dbl){
8478
- // safety check to correct any double encoded &amp;
8479
- s = this.correctEncoding(s);
8480
- }
8481
-
8482
- // now do we need to convert our numerical encoded string into entities
8483
- if(this.EncodeType=="entity"){
8484
- s = this.NumericalToHTML(s);
8485
- }
8486
-
8487
- return s;
8488
- },
8489
-
8490
- // Encodes the basic 4 characters used to malform HTML in XSS hacks
8491
- XSSEncode : function(s,en){
8492
- if(!this.isEmpty(s)){
8493
- en = en || true;
8494
- // do we convert to numerical or html entity?
8495
- if(en){
8496
- s = s.replace(/\'/g,"&#39;"); //no HTML equivalent as &apos is not cross browser supported
8497
- s = s.replace(/\"/g,"&quot;");
8498
- s = s.replace(/</g,"&lt;");
8499
- s = s.replace(/>/g,"&gt;");
8500
- }else{
8501
- s = s.replace(/\'/g,"&#39;"); //no HTML equivalent as &apos is not cross browser supported
8502
- s = s.replace(/\"/g,"&#34;");
8503
- s = s.replace(/</g,"&#60;");
8504
- s = s.replace(/>/g,"&#62;");
8505
- }
8506
- return s;
8507
- }else{
8508
- return "";
8509
- }
8510
- },
8511
-
8512
- // returns true if a string contains html or numerical encoded entities
8513
- hasEncoded : function(s){
8514
- if(/&#[0-9]{1,5};/g.test(s)){
8515
- return true;
8516
- }else if(/&[A-Z]{2,6};/gi.test(s)){
8517
- return true;
8518
- }else{
8519
- return false;
8520
- }
8521
- },
8522
-
8523
- // will remove any unicode characters
8524
- stripUnicode : function(s){
8525
- return s.replace(/[^\x20-\x7E]/g,"");
8526
-
8527
- },
8528
-
8529
- // corrects any double encoded &amp; entities e.g &amp;amp;
8530
- correctEncoding : function(s){
8531
- return s.replace(/(&amp;)(amp;)+/,"$1");
8532
- },
8533
-
8534
-
8535
- // Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals
8536
- swapArrayVals : function(s,arr1,arr2){
8537
- if(this.isEmpty(s)) return "";
8538
- var re;
8539
- if(arr1 && arr2){
8540
- //ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length)
8541
- // array lengths must match
8542
- if(arr1.length == arr2.length){
8543
- for(var x=0,i=arr1.length;x<i;x++){
8544
- re = new RegExp(arr1[x], 'g');
8545
- s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2
8546
- }
8547
- }
8548
- }
8549
- return s;
8550
- },
8551
-
8552
- inArray : function( item, arr ) {
8553
- for ( var i = 0, x = arr.length; i < x; i++ ){
8554
- if ( arr[i] === item ){
8555
- return i;
8556
- }
8557
- }
8558
- return -1;
8559
- }
8560
-
8561
- };
8562
-
8563
- Encoder.EncodeType = "entity";
8564
-
8565
- var utils = {
8566
- htmlencoder: Encoder,
8567
- convert_meta_to_object: function (data) {
8568
- var converted_data = {},
8569
- element,
8570
- property,
8571
- key;
8572
-
8573
- for (key in data) {
8574
- if (data.hasOwnProperty(key)) {
8575
- element = key.split(/_(.+)?/)[0];
8576
- property = key.split(/_(.+)?/)[1];
8577
- if (converted_data[element] === undefined) {
8578
- converted_data[element] = {};
8579
- }
8580
- converted_data[element][property] = data[key];
8581
- }
8582
- }
8583
- return converted_data;
8584
- },
8585
- object_to_array: function (object) {
8586
- var array = [],
8587
- i;
8588
-
8589
- // Convert facets to array (JSON.stringify breaks arrays).
8590
- if (typeof object === 'object') {
8591
- for (i in object) {
8592
- array.push(object[i]);
8593
- }
8594
- object = array;
8595
- }
8596
-
8597
- return object;
8598
- },
8599
- checked: function (val1, val2, print) {
8600
- var checked = false;
8601
- if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
8602
- checked = true;
8603
- } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
8604
- checked = true;
8605
- } else if (val1 === val2) {
8606
- checked = true;
8607
- } else if (val1 == val2) {
8608
- checked = true;
8609
- }
8610
-
8611
- if (print !== undefined && print) {
8612
- return checked ? ' checked="checked"' : '';
8613
- }
8614
- return checked;
8615
- },
8616
- selected: function (val1, val2, print) {
8617
- var selected = false;
8618
- if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
8619
- selected = true;
8620
- } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
8621
- selected = true;
8622
- } else if (val1 === val2) {
8623
- selected = true;
8624
- }
8625
-
8626
- if (print !== undefined && print) {
8627
- return selected ? ' selected="selected"' : '';
8628
- }
8629
- return selected;
8630
- },
8631
- convert_hex: function (hex, opacity) {
8632
- if (undefined === hex) {
8633
- return '';
8634
- }
8635
- if (undefined === opacity) {
8636
- opacity = 100;
8637
- }
8638
-
8639
- hex = hex.replace('#', '');
8640
- var r = parseInt(hex.substring(0, 2), 16),
8641
- g = parseInt(hex.substring(2, 4), 16),
8642
- b = parseInt(hex.substring(4, 6), 16),
8643
- result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')';
8644
- return result;
8645
- },
8646
- debounce: function (callback, threshold) {
8647
- var timeout;
8648
- return function () {
8649
- var context = this, params = arguments;
8650
- window.clearTimeout(timeout);
8651
- timeout = window.setTimeout(function () {
8652
- callback.apply(context, params);
8653
- }, threshold);
8654
- };
8655
- },
8656
- throttle: function (callback, threshold) {
8657
- var suppress = false,
8658
- clear = function () {
8659
- suppress = false;
8660
- };
8661
- return function () {
8662
- if (!suppress) {
8663
- callback();
8664
- window.setTimeout(clear, threshold);
8665
- suppress = true;
8666
- }
8667
- };
8668
- },
8669
- serializeForm: function (options) {
8670
- $.extend({}, options);
8671
-
8672
- var values = {},
8673
- settings = $.extend(true, {
8674
- include: [],
8675
- exclude: [],
8676
- includeByClass: ''
8677
- }, options);
8678
-
8679
- this.find(':input').each(function () {
8680
-
8681
- var parsedName;
8682
-
8683
- // Apply simple checks and filters
8684
- if (!this.name || this.disabled ||
8685
- isInArray(settings.exclude, this.name) ||
8686
- (settings.include.length && !isInArray(settings.include, this.name)) ||
8687
- this.className.indexOf(settings.includeByClass) === -1) {
8688
- return;
8689
- }
8690
-
8691
- // Parse complex names
8692
- // JS RegExp doesn't support "positive look behind" :( that's why so weird parsing is used
8693
- parsedName = this.name.replace(rName, '[$1').split('[');
8694
- if (!parsedName[0]) {
8695
- return;
8696
- }
8697
-
8698
- if (this.checked ||
8699
- isInArray(inputTypes, this.type) ||
8700
- isInArray(inputNodes, this.nodeName.toLowerCase())) {
8701
-
8702
- // Simulate control with a complex name (i.e. `some[]`)
8703
- // as it handled in the same way as Checkboxes should
8704
- if (this.type === 'checkbox') {
8705
- parsedName.push('');
8706
- }
8707
-
8708
- // jQuery.val() is used to simplify of getting values
8709
- // from the custom controls (which follow jQuery .val() API) and Multiple Select
8710
- storeValue(values, parsedName, $(this).val());
8711
- }
8712
- });
8713
-
8714
- return values;
8715
- }
8716
-
8717
- };
8718
-
8719
- // Import this module.
8720
- window.PUM_Admin = window.PUM_Admin || {};
8721
- window.PUM_Admin.utils = utils;
8722
-
8723
- // @deprecated 1.7.0 Here for backward compatibility.
8724
- window.PUMUtils = utils;
8725
-
8726
- $.fn.pumSerializeForm = utils.serializeForm;
8727
  }(jQuery));
1
+ /* jshint ignore:start */
2
+ /*!
3
+ * Select2 4.0.2
4
+ * https://select2.github.io
5
+ *
6
+ * Released under the MIT license
7
+ * https://github.com/select2/select2/blob/master/LICENSE.md
8
+ */
9
+ (function (factory) {
10
+ if (typeof define === 'function' && define.amd !== undefined && define.amd) {
11
+ // AMD. Register as an anonymous module.
12
+ define(['jquery'], factory);
13
+ } else if (typeof exports === 'object') {
14
+ // Node/CommonJS
15
+ factory(require('jquery'));
16
+ } else {
17
+ // Browser globals
18
+ factory(jQuery);
19
+ }
20
+ }(function (jQuery) {
21
+ // This is needed so we can catch the AMD loader configuration and use it
22
+ // The inner file should be wrapped (by `banner.start.js`) in a function that
23
+ // returns the AMD loader references.
24
+ var S2 =
25
+ (function () {
26
+ // Restore the Select2 AMD loader so it can be used
27
+ // Needed mostly in the language files, where the loader is not inserted
28
+ if (jQuery && jQuery.fn && jQuery.fn.pumselect2 && jQuery.fn.pumselect2.amd) {
29
+ var S2 = jQuery.fn.pumselect2.amd;
30
+ }
31
+ var S2;(function () { if (!S2 || !S2.requirejs) {
32
+ if (!S2) { S2 = {}; } else { require = S2; }
33
+ /**
34
+ * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
35
+ * Available via the MIT or new BSD license.
36
+ * see: http://github.com/jrburke/almond for details
37
+ */
38
+ //Going sloppy to avoid 'use strict' string cost, but strict practices should
39
+ //be followed.
40
+ /*jslint sloppy: true */
41
+ /*global setTimeout: false */
42
+
43
+ var requirejs, require, define;
44
+ (function (undef) {
45
+ var main, req, makeMap, handlers,
46
+ defined = {},
47
+ waiting = {},
48
+ config = {},
49
+ defining = {},
50
+ hasOwn = Object.prototype.hasOwnProperty,
51
+ aps = [].slice,
52
+ jsSuffixRegExp = /\.js$/;
53
+
54
+ function hasProp(obj, prop) {
55
+ return hasOwn.call(obj, prop);
56
+ }
57
+
58
+ /**
59
+ * Given a relative module name, like ./something, normalize it to
60
+ * a real name that can be mapped to a path.
61
+ * @param {String} name the relative name
62
+ * @param {String} baseName a real name that the name arg is relative
63
+ * to.
64
+ * @returns {String} normalized name
65
+ */
66
+ function normalize(name, baseName) {
67
+ var nameParts, nameSegment, mapValue, foundMap, lastIndex,
68
+ foundI, foundStarMap, starI, i, j, part,
69
+ baseParts = baseName && baseName.split("/"),
70
+ map = config.map,
71
+ starMap = (map && map['*']) || {};
72
+
73
+ //Adjust any relative paths.
74
+ if (name && name.charAt(0) === ".") {
75
+ //If have a base name, try to normalize against it,
76
+ //otherwise, assume it is a top-level require that will
77
+ //be relative to baseUrl in the end.
78
+ if (baseName) {
79
+ name = name.split('/');
80
+ lastIndex = name.length - 1;
81
+
82
+ // Node .js allowance:
83
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
84
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
85
+ }
86
+
87
+ //Lop off the last part of baseParts, so that . matches the
88
+ //"directory" and not name of the baseName's module. For instance,
89
+ //baseName of "one/two/three", maps to "one/two/three.js", but we
90
+ //want the directory, "one/two" for this normalization.
91
+ name = baseParts.slice(0, baseParts.length - 1).concat(name);
92
+
93
+ //start trimDots
94
+ for (i = 0; i < name.length; i += 1) {
95
+ part = name[i];
96
+ if (part === ".") {
97
+ name.splice(i, 1);
98
+ i -= 1;
99
+ } else if (part === "..") {
100
+ if (i === 1 && (name[2] === '..' || name[0] === '..')) {
101
+ //End of the line. Keep at least one non-dot
102
+ //path segment at the front so it can be mapped
103
+ //correctly to disk. Otherwise, there is likely
104
+ //no path mapping for a path starting with '..'.
105
+ //This can still fail, but catches the most reasonable
106
+ //uses of ..
107
+ break;
108
+ } else if (i > 0) {
109
+ name.splice(i - 1, 2);
110
+ i -= 2;
111
+ }
112
+ }
113
+ }
114
+ //end trimDots
115
+
116
+ name = name.join("/");
117
+ } else if (name.indexOf('./') === 0) {
118
+ // No baseName, so this is ID is resolved relative
119
+ // to baseUrl, pull off the leading dot.
120
+ name = name.substring(2);
121
+ }
122
+ }
123
+
124
+ //Apply map config if available.
125
+ if ((baseParts || starMap) && map) {
126
+ nameParts = name.split('/');
127
+
128
+ for (i = nameParts.length; i > 0; i -= 1) {
129
+ nameSegment = nameParts.slice(0, i).join("/");
130
+
131
+ if (baseParts) {
132
+ //Find the longest baseName segment match in the config.
133
+ //So, do joins on the biggest to smallest lengths of baseParts.
134
+ for (j = baseParts.length; j > 0; j -= 1) {
135
+ mapValue = map[baseParts.slice(0, j).join('/')];
136
+
137
+ //baseName segment has config, find if it has one for
138
+ //this name.
139
+ if (mapValue) {
140
+ mapValue = mapValue[nameSegment];
141
+ if (mapValue) {
142
+ //Match, update name to the new value.
143
+ foundMap = mapValue;
144
+ foundI = i;
145
+ break;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ if (foundMap) {
152
+ break;
153
+ }
154
+
155
+ //Check for a star map match, but just hold on to it,
156
+ //if there is a shorter segment match later in a matching
157
+ //config, then favor over this star map.
158
+ if (!foundStarMap && starMap && starMap[nameSegment]) {
159
+ foundStarMap = starMap[nameSegment];
160
+ starI = i;
161
+ }
162
+ }
163
+
164
+ if (!foundMap && foundStarMap) {
165
+ foundMap = foundStarMap;
166
+ foundI = starI;
167
+ }
168
+
169
+ if (foundMap) {
170
+ nameParts.splice(0, foundI, foundMap);
171
+ name = nameParts.join('/');
172
+ }
173
+ }
174
+
175
+ return name;
176
+ }
177
+
178
+ function makeRequire(relName, forceSync) {
179
+ return function () {
180
+ //A version of a require function that passes a moduleName
181
+ //value for items that may need to
182
+ //look up paths relative to the moduleName
183
+ var args = aps.call(arguments, 0);
184
+
185
+ //If first arg is not require('string'), and there is only
186
+ //one arg, it is the array form without a callback. Insert
187
+ //a null so that the following concat is correct.
188
+ if (typeof args[0] !== 'string' && args.length === 1) {
189
+ args.push(null);
190
+ }
191
+ return req.apply(undef, args.concat([relName, forceSync]));
192
+ };
193
+ }
194
+
195
+ function makeNormalize(relName) {
196
+ return function (name) {
197
+ return normalize(name, relName);
198
+ };
199
+ }
200
+
201
+ function makeLoad(depName) {
202
+ return function (value) {
203
+ defined[depName] = value;
204
+ };
205
+ }
206
+
207
+ function callDep(name) {
208
+ if (hasProp(waiting, name)) {
209
+ var args = waiting[name];
210
+ delete waiting[name];
211
+ defining[name] = true;
212
+ main.apply(undef, args);
213
+ }
214
+
215
+ if (!hasProp(defined, name) && !hasProp(defining, name)) {
216
+ throw new Error('No ' + name);
217
+ }
218
+ return defined[name];
219
+ }
220
+
221
+ //Turns a plugin!resource to [plugin, resource]
222
+ //with the plugin being undefined if the name
223
+ //did not have a plugin prefix.
224
+ function splitPrefix(name) {
225
+ var prefix,
226
+ index = name ? name.indexOf('!') : -1;
227
+ if (index > -1) {
228
+ prefix = name.substring(0, index);
229
+ name = name.substring(index + 1, name.length);
230
+ }
231
+ return [prefix, name];
232
+ }
233
+
234
+ /**
235
+ * Makes a name map, normalizing the name, and using a plugin
236
+ * for normalization if necessary. Grabs a ref to plugin
237
+ * too, as an optimization.
238
+ */
239
+ makeMap = function (name, relName) {
240
+ var plugin,
241
+ parts = splitPrefix(name),
242
+ prefix = parts[0];
243
+
244
+ name = parts[1];
245
+
246
+ if (prefix) {
247
+ prefix = normalize(prefix, relName);
248
+ plugin = callDep(prefix);
249
+ }
250
+
251
+ //Normalize according
252
+ if (prefix) {
253
+ if (plugin && plugin.normalize) {
254
+ name = plugin.normalize(name, makeNormalize(relName));
255
+ } else {
256
+ name = normalize(name, relName);
257
+ }
258
+ } else {
259
+ name = normalize(name, relName);
260
+ parts = splitPrefix(name);
261
+ prefix = parts[0];
262
+ name = parts[1];
263
+ if (prefix) {
264
+ plugin = callDep(prefix);
265
+ }
266
+ }
267
+
268
+ //Using ridiculous property names for space reasons
269
+ return {
270
+ f: prefix ? prefix + '!' + name : name, //fullName
271
+ n: name,
272
+ pr: prefix,
273
+ p: plugin
274
+ };
275
+ };
276
+
277
+ function makeConfig(name) {
278
+ return function () {
279
+ return (config && config.config && config.config[name]) || {};
280
+ };
281
+ }
282
+
283
+ handlers = {
284
+ require: function (name) {
285
+ return makeRequire(name);
286
+ },
287
+ exports: function (name) {
288
+ var e = defined[name];
289
+ if (typeof e !== 'undefined') {
290
+ return e;
291
+ } else {
292
+ return (defined[name] = {});
293
+ }
294
+ },
295
+ module: function (name) {
296
+ return {
297
+ id: name,
298
+ uri: '',
299
+ exports: defined[name],
300
+ config: makeConfig(name)
301
+ };
302
+ }
303
+ };
304
+
305
+ main = function (name, deps, callback, relName) {
306
+ var cjsModule, depName, ret, map, i,
307
+ args = [],
308
+ callbackType = typeof callback,
309
+ usingExports;
310
+
311
+ //Use name if no relName
312
+ relName = relName || name;
313
+
314
+ //Call the callback to define the module, if necessary.
315
+ if (callbackType === 'undefined' || callbackType === 'function') {
316
+ //Pull out the defined dependencies and pass the ordered
317
+ //values to the callback.
318
+ //Default to [require, exports, module] if no deps
319
+ deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
320
+ for (i = 0; i < deps.length; i += 1) {
321
+ map = makeMap(deps[i], relName);
322
+ depName = map.f;
323
+
324
+ //Fast path CommonJS standard dependencies.
325
+ if (depName === "require") {
326
+ args[i] = handlers.require(name);
327
+ } else if (depName === "exports") {
328
+ //CommonJS module spec 1.1
329
+ args[i] = handlers.exports(name);
330
+ usingExports = true;
331
+ } else if (depName === "module") {
332
+ //CommonJS module spec 1.1
333
+ cjsModule = args[i] = handlers.module(name);
334
+ } else if (hasProp(defined, depName) ||
335
+ hasProp(waiting, depName) ||
336
+ hasProp(defining, depName)) {
337
+ args[i] = callDep(depName);
338
+ } else if (map.p) {
339
+ map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
340
+ args[i] = defined[depName];
341
+ } else {
342
+ throw new Error(name + ' missing ' + depName);
343
+ }
344
+ }
345
+
346
+ ret = callback ? callback.apply(defined[name], args) : undefined;
347
+
348
+ if (name) {
349
+ //If setting exports via "module" is in play,
350
+ //favor that over return value and exports. After that,
351
+ //favor a non-undefined return value over exports use.
352
+ if (cjsModule && cjsModule.exports !== undef &&
353
+ cjsModule.exports !== defined[name]) {
354
+ defined[name] = cjsModule.exports;
355
+ } else if (ret !== undef || !usingExports) {
356
+ //Use the return value from the function.
357
+ defined[name] = ret;
358
+ }
359
+ }
360
+ } else if (name) {
361
+ //May just be an object definition for the module. Only
362
+ //worry about defining if have a module name.
363
+ defined[name] = callback;
364
+ }
365
+ };
366
+
367
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
368
+ if (typeof deps === "string") {
369
+ if (handlers[deps]) {
370
+ //callback in this case is really relName
371
+ return handlers[deps](callback);
372
+ }
373
+ //Just return the module wanted. In this scenario, the
374
+ //deps arg is the module name, and second arg (if passed)
375
+ //is just the relName.
376
+ //Normalize module name, if it contains . or ..
377
+ return callDep(makeMap(deps, callback).f);
378
+ } else if (!deps.splice) {
379
+ //deps is a config object, not an array.
380
+ config = deps;
381
+ if (config.deps) {
382
+ req(config.deps, config.callback);
383
+ }
384
+ if (!callback) {
385
+ return;
386
+ }
387
+
388
+ if (callback.splice) {
389
+ //callback is an array, which means it is a dependency list.
390
+ //Adjust args if there are dependencies
391
+ deps = callback;
392
+ callback = relName;
393
+ relName = null;
394
+ } else {
395
+ deps = undef;
396
+ }
397
+ }
398
+
399
+ //Support require(['a'])
400
+ callback = callback || function () {};
401
+
402
+ //If relName is a function, it is an errback handler,
403
+ //so remove it.
404
+ if (typeof relName === 'function') {
405
+ relName = forceSync;
406
+ forceSync = alt;
407
+ }
408
+
409
+ //Simulate async callback;
410
+ if (forceSync) {
411
+ main(undef, deps, callback, relName);
412
+ } else {
413
+ //Using a non-zero value because of concern for what old browsers
414
+ //do, and latest browsers "upgrade" to 4 if lower value is used:
415
+ //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
416
+ //If want a value immediately, use require('id') instead -- something
417
+ //that works in almond on the global level, but not guaranteed and
418
+ //unlikely to work in other AMD implementations.
419
+ setTimeout(function () {
420
+ main(undef, deps, callback, relName);
421
+ }, 4);
422
+ }
423
+
424
+ return req;
425
+ };
426
+
427
+ /**
428
+ * Just drops the config on the floor, but returns req in case
429
+ * the config return value is used.
430
+ */
431
+ req.config = function (cfg) {
432
+ return req(cfg);
433
+ };
434
+
435
+ /**
436
+ * Expose module registry for debugging and tooling
437
+ */
438
+ requirejs._defined = defined;
439
+
440
+ define = function (name, deps, callback) {
441
+ if (typeof name !== 'string') {
442
+ throw new Error('See almond README: incorrect module build, no module name');
443
+ }
444
+
445
+ //This module may not have dependencies
446
+ if (!deps.splice) {
447
+ //deps is not an array, so probably means
448
+ //an object literal or factory function for
449
+ //the value. Adjust args.
450
+ callback = deps;
451
+ deps = [];
452
+ }
453
+
454
+ if (!hasProp(defined, name) && !hasProp(waiting, name)) {
455
+ waiting[name] = [name, deps, callback];
456
+ }
457
+ };
458
+
459
+ define.amd = {
460
+ jQuery: true
461
+ };
462
+ }());
463
+
464
+ S2.requirejs = requirejs;S2.require = require;S2.define = define;
465
+ }
466
+ }());
467
+ S2.define("almond", function(){});
468
+
469
+ /* global jQuery:false, $:false */
470
+ S2.define('jquery',[],function () {
471
+ var _$ = jQuery || $;
472
+
473
+ if (_$ == null && console && console.error) {
474
+ console.error(
475
+ 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
476
+ 'found. Make sure that you are including jQuery before Select2 on your ' +
477
+ 'web page.'
478
+ );
479
+ }
480
+
481
+ return _$;
482
+ });
483
+
484
+ S2.define('pumselect2/utils',[
485
+ 'jquery'
486
+ ], function ($) {
487
+ var Utils = {};
488
+
489
+ Utils.Extend = function (ChildClass, SuperClass) {
490
+ var __hasProp = {}.hasOwnProperty;
491
+
492
+ function BaseConstructor () {
493
+ this.constructor = ChildClass;
494
+ }
495
+
496
+ for (var key in SuperClass) {
497
+ if (__hasProp.call(SuperClass, key)) {
498
+ ChildClass[key] = SuperClass[key];
499
+ }
500
+ }
501
+
502
+ BaseConstructor.prototype = SuperClass.prototype;
503
+ ChildClass.prototype = new BaseConstructor();
504
+ ChildClass.__super__ = SuperClass.prototype;
505
+
506
+ return ChildClass;
507
+ };
508
+
509
+ function getMethods (theClass) {
510
+ var proto = theClass.prototype;
511
+
512
+ var methods = [];
513
+
514
+ for (var methodName in proto) {
515
+ var m = proto[methodName];
516
+
517
+ if (typeof m !== 'function') {
518
+ continue;
519
+ }
520
+
521
+ if (methodName === 'constructor') {
522
+ continue;
523
+ }
524
+
525
+ methods.push(methodName);
526
+ }
527
+
528
+ return methods;
529
+ }
530
+
531
+ Utils.Decorate = function (SuperClass, DecoratorClass) {
532
+ var decoratedMethods = getMethods(DecoratorClass);
533
+ var superMethods = getMethods(SuperClass);
534
+
535
+ function DecoratedClass () {
536
+ var unshift = Array.prototype.unshift;
537
+
538
+ var argCount = DecoratorClass.prototype.constructor.length;
539
+
540
+ var calledConstructor = SuperClass.prototype.constructor;
541
+
542
+ if (argCount > 0) {
543
+ unshift.call(arguments, SuperClass.prototype.constructor);
544
+
545
+ calledConstructor = DecoratorClass.prototype.constructor;
546
+ }
547
+
548
+ calledConstructor.apply(this, arguments);
549
+ }
550
+
551
+ DecoratorClass.displayName = SuperClass.displayName;
552
+
553
+ function ctr () {
554
+ this.constructor = DecoratedClass;
555
+ }
556
+
557
+ DecoratedClass.prototype = new ctr();
558
+
559
+ for (var m = 0; m < superMethods.length; m++) {
560
+ var superMethod = superMethods[m];
561
+
562
+ DecoratedClass.prototype[superMethod] =
563
+ SuperClass.prototype[superMethod];
564
+ }
565
+
566
+ var calledMethod = function (methodName) {
567
+ // Stub out the original method if it's not decorating an actual method
568
+ var originalMethod = function () {};
569
+
570
+ if (methodName in DecoratedClass.prototype) {
571
+ originalMethod = DecoratedClass.prototype[methodName];
572
+ }
573
+
574
+ var decoratedMethod = DecoratorClass.prototype[methodName];
575
+
576
+ return function () {
577
+ var unshift = Array.prototype.unshift;
578
+
579
+ unshift.call(arguments, originalMethod);
580
+
581
+ return decoratedMethod.apply(this, arguments);
582
+ };
583
+ };
584
+
585
+ for (var d = 0; d < decoratedMethods.length; d++) {
586
+ var decoratedMethod = decoratedMethods[d];
587
+
588
+ DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
589
+ }
590
+
591
+ return DecoratedClass;
592
+ };
593
+
594
+ var Observable = function () {
595
+ this.listeners = {};
596
+ };
597
+
598
+ Observable.prototype.on = function (event, callback) {
599
+ this.listeners = this.listeners || {};
600
+
601
+ if (event in this.listeners) {
602
+ this.listeners[event].push(callback);
603
+ } else {
604
+ this.listeners[event] = [callback];
605
+ }
606
+ };
607
+
608
+ Observable.prototype.trigger = function (event) {
609
+ var slice = Array.prototype.slice;
610
+
611
+ this.listeners = this.listeners || {};
612
+
613
+ if (event in this.listeners) {
614
+ this.invoke(this.listeners[event], slice.call(arguments, 1));
615
+ }
616
+
617
+ if ('*' in this.listeners) {
618
+ this.invoke(this.listeners['*'], arguments);
619
+ }
620
+ };
621
+
622
+ Observable.prototype.invoke = function (listeners, params) {
623
+ for (var i = 0, len = listeners.length; i < len; i++) {
624
+ listeners[i].apply(this, params);
625
+ }
626
+ };
627
+
628
+ Utils.Observable = Observable;
629
+
630
+ Utils.generateChars = function (length) {
631
+ var chars = '';
632
+
633
+ for (var i = 0; i < length; i++) {
634
+ var randomChar = Math.floor(Math.random() * 36);
635
+ chars += randomChar.toString(36);
636
+ }
637
+
638
+ return chars;
639
+ };
640
+
641
+ Utils.bind = function (func, context) {
642
+ return function () {
643
+ func.apply(context, arguments);
644
+ };
645
+ };
646
+
647
+ Utils._convertData = function (data) {
648
+ for (var originalKey in data) {
649
+ var keys = originalKey.split('-');
650
+
651
+ var dataLevel = data;
652
+
653
+ if (keys.length === 1) {
654
+ continue;
655
+ }
656
+
657
+ for (var k = 0; k < keys.length; k++) {
658
+ var key = keys[k];
659
+
660
+ // Lowercase the first letter
661
+ // By default, dash-separated becomes camelCase
662
+ key = key.substring(0, 1).toLowerCase() + key.substring(1);
663
+
664
+ if (!(key in dataLevel)) {
665
+ dataLevel[key] = {};
666
+ }
667
+
668
+ if (k == keys.length - 1) {
669
+ dataLevel[key] = data[originalKey];
670
+ }
671
+
672
+ dataLevel = dataLevel[key];
673
+ }
674
+
675
+ delete data[originalKey];
676
+ }
677
+
678
+ return data;
679
+ };
680
+
681
+ Utils.hasScroll = function (index, el) {
682
+ // Adapted from the function created by @ShadowScripter
683
+ // and adapted by @BillBarry on the Stack Exchange Code Review website.
684
+ // The original code can be found at
685
+ // http://codereview.stackexchange.com/q/13338
686
+ // and was designed to be used with the Sizzle selector engine.
687
+
688
+ var $el = $(el);
689
+ var overflowX = el.style.overflowX;
690
+ var overflowY = el.style.overflowY;
691
+
692
+ //Check both x and y declarations
693
+ if (overflowX === overflowY &&
694
+ (overflowY === 'hidden' || overflowY === 'visible')) {
695
+ return false;
696
+ }
697
+
698
+ if (overflowX === 'scroll' || overflowY === 'scroll') {
699
+ return true;
700
+ }
701
+
702
+ return ($el.innerHeight() < el.scrollHeight ||
703
+ $el.innerWidth() < el.scrollWidth);
704
+ };
705
+
706
+ Utils.escapeMarkup = function (markup) {
707
+ var replaceMap = {
708
+ '\\': '&#92;',
709
+ '&': '&amp;',
710
+ '<': '&lt;',
711
+ '>': '&gt;',
712
+ '"': '&quot;',
713
+ '\'': '&#39;',
714
+ '/': '&#47;'
715
+ };
716
+
717
+ // Do not try to escape the markup if it's not a string
718
+ if (typeof markup !== 'string') {
719
+ return markup;
720
+ }
721
+
722
+ return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
723
+ return replaceMap[match];
724
+ });
725
+ };
726
+
727
+ // Append an array of jQuery nodes to a given element.
728
+ Utils.appendMany = function ($element, $nodes) {
729
+ // jQuery 1.7.x does not support $.fn.append() with an array
730
+ // Fall back to a jQuery object collection using $.fn.add()
731
+ if ($.fn.jquery.substr(0, 3) === '1.7') {
732
+ var $jqNodes = $();
733
+
734
+ $.map($nodes, function (node) {
735
+ $jqNodes = $jqNodes.add(node);
736
+ });
737
+
738
+ $nodes = $jqNodes;
739
+ }
740
+
741
+ $element.append($nodes);
742
+ };
743
+
744
+ return Utils;
745
+ });
746
+
747
+ S2.define('pumselect2/results',[
748
+ 'jquery',
749
+ './utils'
750
+ ], function ($, Utils) {
751
+ function Results ($element, options, dataAdapter) {
752
+ this.$element = $element;
753
+ this.data = dataAdapter;
754
+ this.options = options;
755
+
756
+ Results.__super__.constructor.call(this);
757
+ }
758
+
759
+ Utils.Extend(Results, Utils.Observable);
760
+
761
+ Results.prototype.render = function () {
762
+ var $results = $(
763
+ '<ul class="pumselect2-results__options" role="tree"></ul>'
764
+ );
765
+
766
+ if (this.options.get('multiple')) {
767
+ $results.attr('aria-multiselectable', 'true');
768
+ }
769
+
770
+ this.$results = $results;
771
+
772
+ return $results;
773
+ };
774
+
775
+ Results.prototype.clear = function () {
776
+ this.$results.empty();
777
+ };
778
+
779
+ Results.prototype.displayMessage = function (params) {
780
+ var escapeMarkup = this.options.get('escapeMarkup');
781
+
782
+ this.clear();
783
+ this.hideLoading();
784
+
785
+ var $message = $(
786
+ '<li role="treeitem" aria-live="assertive"' +
787
+ ' class="pumselect2-results__option"></li>'
788
+ );
789
+
790
+ var message = this.options.get('translations').get(params.message);
791
+
792
+ $message.append(
793
+ escapeMarkup(
794
+ message(params.args)
795
+ )
796
+ );
797
+
798
+ $message[0].className += ' pumselect2-results__message';
799
+
800
+ this.$results.append($message);
801
+ };
802
+
803
+ Results.prototype.hideMessages = function () {
804
+ this.$results.find('.pumselect2-results__message').remove();
805
+ };
806
+
807
+ Results.prototype.append = function (data) {
808
+ this.hideLoading();
809
+
810
+ var $options = [];
811
+
812
+ if (data.results == null || data.results.length === 0) {
813
+ if (this.$results.children().length === 0) {
814
+ this.trigger('results:message', {
815
+ message: 'noResults'
816
+ });
817
+ }
818
+
819
+ return;
820
+ }
821
+
822
+ data.results = this.sort(data.results);
823
+
824
+ for (var d = 0; d < data.results.length; d++) {
825
+ var item = data.results[d];
826
+
827
+ var $option = this.option(item);
828
+
829
+ $options.push($option);
830
+ }
831
+
832
+ this.$results.append($options);
833
+ };
834
+
835
+ Results.prototype.position = function ($results, $dropdown) {
836
+ var $resultsContainer = $dropdown.find('.pumselect2-results');
837
+ $resultsContainer.append($results);
838
+ };
839
+
840
+ Results.prototype.sort = function (data) {
841
+ var sorter = this.options.get('sorter');
842
+
843
+ return sorter(data);
844
+ };
845
+
846
+ Results.prototype.setClasses = function () {
847
+ var self = this;
848
+
849
+ this.data.current(function (selected) {
850
+ var selectedIds = $.map(selected, function (s) {
851
+ return s.id.toString();
852
+ });
853
+
854
+ var $options = self.$results
855
+ .find('.pumselect2-results__option[aria-selected]');
856
+
857
+ $options.each(function () {
858
+ var $option = $(this);
859
+
860
+ var item = $.data(this, 'data');
861
+
862
+ // id needs to be converted to a string when comparing
863
+ var id = '' + item.id;
864
+
865
+ if ((item.element != null && item.element.selected) ||
866
+ (item.element == null && $.inArray(id, selectedIds) > -1)) {
867
+ $option.attr('aria-selected', 'true');
868
+ } else {
869
+ $option.attr('aria-selected', 'false');
870
+ }
871
+ });
872
+
873
+ var $selected = $options.filter('[aria-selected=true]');
874
+
875
+ // Check if there are any selected options
876
+ if ($selected.length > 0) {
877
+ // If there are selected options, highlight the first
878
+ $selected.first().trigger('mouseenter');
879
+ } else {
880
+ // If there are no selected options, highlight the first option
881
+ // in the dropdown
882
+ $options.first().trigger('mouseenter');
883
+ }
884
+ });
885
+ };
886
+
887
+ Results.prototype.showLoading = function (params) {
888
+ this.hideLoading();
889
+
890
+ var loadingMore = this.options.get('translations').get('searching');
891
+
892
+ var loading = {
893
+ disabled: true,
894
+ loading: true,
895
+ text: loadingMore(params)
896
+ };
897
+ var $loading = this.option(loading);
898
+ $loading.className += ' loading-results';
899
+
900
+ this.$results.prepend($loading);
901
+ };
902
+
903
+ Results.prototype.hideLoading = function () {
904
+ this.$results.find('.loading-results').remove();
905
+ };
906
+
907
+ Results.prototype.option = function (data) {
908
+ var option = document.createElement('li');
909
+ option.className = 'pumselect2-results__option';
910
+
911
+ var attrs = {
912
+ 'role': 'treeitem',
913
+ 'aria-selected': 'false'
914
+ };
915
+
916
+ if (data.disabled) {
917
+ delete attrs['aria-selected'];
918
+ attrs['aria-disabled'] = 'true';
919
+ }
920
+
921
+ if (data.id == null) {
922
+ delete attrs['aria-selected'];
923
+ }
924
+
925
+ if (data._resultId != null) {
926
+ option.id = data._resultId;
927
+ }
928
+
929
+ if (data.title) {
930
+ option.title = data.title;
931
+ }
932
+
933
+ if (data.children) {
934
+ attrs.role = 'group';
935
+ attrs['aria-label'] = data.text;
936
+ delete attrs['aria-selected'];
937
+ }
938
+
939
+ for (var attr in attrs) {
940
+ var val = attrs[attr];
941
+
942
+ option.setAttribute(attr, val);
943
+ }
944
+
945
+ if (data.children) {
946
+ var $option = $(option);
947
+
948
+ var label = document.createElement('strong');
949
+ label.className = 'pumselect2-results__group';
950
+
951
+ var $label = $(label);
952
+ this.template(data, label);
953
+
954
+ var $children = [];
955
+
956
+ for (var c = 0; c < data.children.length; c++) {
957
+ var child = data.children[c];
958
+
959
+ var $child = this.option(child);
960
+
961
+ $children.push($child);
962
+ }
963
+
964
+ var $childrenContainer = $('<ul></ul>', {
965
+ 'class': 'pumselect2-results__options pumselect2-results__options--nested'
966
+ });
967
+
968
+ $childrenContainer.append($children);
969
+
970
+ $option.append(label);
971
+ $option.append($childrenContainer);
972
+ } else {
973
+ this.template(data, option);
974
+ }
975
+
976
+ $.data(option, 'data', data);
977
+
978
+ return option;
979
+ };
980
+
981
+ Results.prototype.bind = function (container, $container) {
982
+ var self = this;
983
+
984
+ var id = container.id + '-results';
985
+
986
+ this.$results.attr('id', id);
987
+
988
+ container.on('results:all', function (params) {
989
+ self.clear();
990
+ self.append(params.data);
991
+
992
+ if (container.isOpen()) {
993
+ self.setClasses();
994
+ }
995
+ });
996
+
997
+ container.on('results:append', function (params) {
998
+ self.append(params.data);
999
+
1000
+ if (container.isOpen()) {
1001
+ self.setClasses();
1002
+ }
1003
+ });
1004
+
1005
+ container.on('query', function (params) {
1006
+ self.hideMessages();
1007
+ self.showLoading(params);
1008
+ });
1009
+
1010
+ container.on('select', function () {
1011
+ if (!container.isOpen()) {
1012
+ return;
1013
+ }
1014
+
1015
+ self.setClasses();
1016
+ });
1017
+
1018
+ container.on('unselect', function () {
1019
+ if (!container.isOpen()) {
1020
+ return;
1021
+ }
1022
+
1023
+ self.setClasses();
1024
+ });
1025
+
1026
+ container.on('open', function () {
1027
+ // When the dropdown is open, aria-expended="true"
1028
+ self.$results.attr('aria-expanded', 'true');
1029
+ self.$results.attr('aria-hidden', 'false');
1030
+
1031
+ self.setClasses();
1032
+ self.ensureHighlightVisible();
1033
+ });
1034
+
1035
+ container.on('close', function () {
1036
+ // When the dropdown is closed, aria-expended="false"
1037
+ self.$results.attr('aria-expanded', 'false');
1038
+ self.$results.attr('aria-hidden', 'true');
1039
+ self.$results.removeAttr('aria-activedescendant');
1040
+ });
1041
+
1042
+ container.on('results:toggle', function () {
1043
+ var $highlighted = self.getHighlightedResults();
1044
+
1045
+ if ($highlighted.length === 0) {
1046
+ return;
1047
+ }
1048
+
1049
+ $highlighted.trigger('mouseup');
1050
+ });
1051
+
1052
+ container.on('results:select', function () {
1053
+ var $highlighted = self.getHighlightedResults();
1054
+
1055
+ if ($highlighted.length === 0) {
1056
+ return;
1057
+ }
1058
+
1059
+ var data = $highlighted.data('data');
1060
+
1061
+ if ($highlighted.attr('aria-selected') == 'true') {
1062
+ self.trigger('close', {});
1063
+ } else {
1064
+ self.trigger('select', {
1065
+ data: data
1066
+ });
1067
+ }
1068
+ });
1069
+
1070
+ container.on('results:previous', function () {
1071
+ var $highlighted = self.getHighlightedResults();
1072
+
1073
+ var $options = self.$results.find('[aria-selected]');
1074
+
1075
+ var currentIndex = $options.index($highlighted);
1076
+
1077
+ // If we are already at te top, don't move further
1078
+ if (currentIndex === 0) {
1079
+ return;
1080
+ }
1081
+
1082
+ var nextIndex = currentIndex - 1;
1083
+
1084
+ // If none are highlighted, highlight the first
1085
+ if ($highlighted.length === 0) {
1086
+ nextIndex = 0;
1087
+ }
1088
+
1089
+ var $next = $options.eq(nextIndex);
1090
+
1091
+ $next.trigger('mouseenter');
1092
+
1093
+ var currentOffset = self.$results.offset().top;
1094
+ var nextTop = $next.offset().top;
1095
+ var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
1096
+
1097
+ if (nextIndex === 0) {
1098
+ self.$results.scrollTop(0);
1099
+ } else if (nextTop - currentOffset < 0) {
1100
+ self.$results.scrollTop(nextOffset);
1101
+ }
1102
+ });
1103
+
1104
+ container.on('results:next', function () {
1105
+ var $highlighted = self.getHighlightedResults();
1106
+
1107
+ var $options = self.$results.find('[aria-selected]');
1108
+
1109
+ var currentIndex = $options.index($highlighted);
1110
+
1111
+ var nextIndex = currentIndex + 1;
1112
+
1113
+ // If we are at the last option, stay there
1114
+ if (nextIndex >= $options.length) {
1115
+ return;
1116
+ }
1117
+
1118
+ var $next = $options.eq(nextIndex);
1119
+
1120
+ $next.trigger('mouseenter');
1121
+
1122
+ var currentOffset = self.$results.offset().top +
1123
+ self.$results.outerHeight(false);
1124
+ var nextBottom = $next.offset().top + $next.outerHeight(false);
1125
+ var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
1126
+
1127
+ if (nextIndex === 0) {
1128
+ self.$results.scrollTop(0);
1129
+ } else if (nextBottom > currentOffset) {
1130
+ self.$results.scrollTop(nextOffset);
1131
+ }
1132
+ });
1133
+
1134
+ container.on('results:focus', function (params) {
1135
+ params.element.addClass('pumselect2-results__option--highlighted');
1136
+ });
1137
+
1138
+ container.on('results:message', function (params) {
1139
+ self.displayMessage(params);
1140
+ });
1141
+
1142
+ if ($.fn.mousewheel) {
1143
+ this.$results.on('mousewheel', function (e) {
1144
+ var top = self.$results.scrollTop();
1145
+
1146
+ var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
1147
+
1148
+ var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
1149
+ var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
1150
+
1151
+ if (isAtTop) {
1152
+ self.$results.scrollTop(0);
1153
+
1154
+ e.preventDefault();
1155
+ e.stopPropagation();
1156
+ } else if (isAtBottom) {
1157
+ self.$results.scrollTop(
1158
+ self.$results.get(0).scrollHeight - self.$results.height()
1159
+ );
1160
+
1161
+ e.preventDefault();
1162
+ e.stopPropagation();
1163
+ }
1164
+ });
1165
+ }
1166
+
1167
+ this.$results.on('mouseup', '.pumselect2-results__option[aria-selected]',
1168
+ function (evt) {
1169
+ var $this = $(this);
1170
+
1171
+ var data = $this.data('data');
1172
+
1173
+ if ($this.attr('aria-selected') === 'true') {
1174
+ if (self.options.get('multiple')) {
1175
+ self.trigger('unselect', {
1176
+ originalEvent: evt,
1177
+ data: data
1178
+ });
1179
+ } else {
1180
+ self.trigger('close', {});
1181
+ }
1182
+
1183
+ return;
1184
+ }
1185
+
1186
+ self.trigger('select', {
1187
+ originalEvent: evt,
1188
+ data: data
1189
+ });
1190
+ });
1191
+
1192
+ this.$results.on('mouseenter', '.pumselect2-results__option[aria-selected]',
1193
+ function (evt) {
1194
+ var data = $(this).data('data');
1195
+
1196
+ self.getHighlightedResults()
1197
+ .removeClass('pumselect2-results__option--highlighted');
1198
+
1199
+ self.trigger('results:focus', {
1200
+ data: data,
1201
+ element: $(this)
1202
+ });
1203
+ });
1204
+ };
1205
+
1206
+ Results.prototype.getHighlightedResults = function () {
1207
+ var $highlighted = this.$results
1208
+ .find('.pumselect2-results__option--highlighted');
1209
+
1210
+ return $highlighted;
1211
+ };
1212
+
1213
+ Results.prototype.destroy = function () {
1214
+ this.$results.remove();
1215
+ };
1216
+
1217
+ Results.prototype.ensureHighlightVisible = function () {
1218
+ var $highlighted = this.getHighlightedResults();
1219
+
1220
+ if ($highlighted.length === 0) {
1221
+ return;
1222
+ }
1223
+
1224
+ var $options = this.$results.find('[aria-selected]');
1225
+
1226
+ var currentIndex = $options.index($highlighted);
1227
+
1228
+ var currentOffset = this.$results.offset().top;
1229
+ var nextTop = $highlighted.offset().top;
1230
+ var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
1231
+
1232
+ var offsetDelta = nextTop - currentOffset;
1233
+ nextOffset -= $highlighted.outerHeight(false) * 2;
1234
+
1235
+ if (currentIndex <= 2) {
1236
+ this.$results.scrollTop(0);
1237
+ } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
1238
+ this.$results.scrollTop(nextOffset);
1239
+ }
1240
+ };
1241
+
1242
+ Results.prototype.template = function (result, container) {
1243
+ var template = this.options.get('templateResult');
1244
+ var escapeMarkup = this.options.get('escapeMarkup');
1245
+
1246
+ var content = template(result, container);
1247
+
1248
+ if (content == null) {
1249
+ container.style.display = 'none';
1250
+ } else if (typeof content === 'string') {
1251
+ container.innerHTML = escapeMarkup(content);
1252
+ } else {
1253
+ $(container).append(content);
1254
+ }
1255
+ };
1256
+
1257
+ return Results;
1258
+ });
1259
+
1260
+ S2.define('pumselect2/keys',[
1261
+
1262
+ ], function () {
1263
+ var KEYS = {
1264
+ BACKSPACE: 8,
1265
+ TAB: 9,
1266
+ ENTER: 13,
1267
+ SHIFT: 16,
1268
+ CTRL: 17,
1269
+ ALT: 18,
1270
+ ESC: 27,
1271
+ SPACE: 32,
1272
+ PAGE_UP: 33,
1273
+ PAGE_DOWN: 34,
1274
+ END: 35,
1275
+ HOME: 36,
1276
+ LEFT: 37,
1277
+ UP: 38,
1278
+ RIGHT: 39,
1279
+ DOWN: 40,
1280
+ DELETE: 46
1281
+ };
1282
+
1283
+ return KEYS;
1284
+ });
1285
+
1286
+ S2.define('pumselect2/selection/base',[
1287
+ 'jquery',
1288
+ '../utils',
1289
+ '../keys'
1290
+ ], function ($, Utils, KEYS) {
1291
+ function BaseSelection ($element, options) {
1292
+ this.$element = $element;
1293
+ this.options = options;
1294
+
1295
+ BaseSelection.__super__.constructor.call(this);
1296
+ }
1297
+
1298
+ Utils.Extend(BaseSelection, Utils.Observable);
1299
+
1300
+ BaseSelection.prototype.render = function () {
1301
+ var $selection = $(
1302
+ '<span class="pumselect2-selection" role="combobox" ' +
1303
+ ' aria-haspopup="true" aria-expanded="false">' +
1304
+ '</span>'
1305
+ );
1306
+
1307
+ this._tabindex = 0;
1308
+
1309
+ if (this.$element.data('old-tabindex') != null) {
1310
+ this._tabindex = this.$element.data('old-tabindex');
1311
+ } else if (this.$element.attr('tabindex') != null) {
1312
+ this._tabindex = this.$element.attr('tabindex');
1313
+ }
1314
+
1315
+ $selection.attr('title', this.$element.attr('title'));
1316
+ $selection.attr('tabindex', this._tabindex);
1317
+
1318
+ this.$selection = $selection;
1319
+
1320
+ return $selection;
1321
+ };
1322
+
1323
+ BaseSelection.prototype.bind = function (container, $container) {
1324
+ var self = this;
1325
+
1326
+ var id = container.id + '-container';
1327
+ var resultsId = container.id + '-results';
1328
+
1329
+ this.container = container;
1330
+
1331
+ this.$selection.on('focus', function (evt) {
1332
+ self.trigger('focus', evt);
1333
+ });
1334
+
1335
+ this.$selection.on('blur', function (evt) {
1336
+ self._handleBlur(evt);
1337
+ });
1338
+
1339
+ this.$selection.on('keydown', function (evt) {
1340
+ self.trigger('keypress', evt);
1341
+
1342
+ if (evt.which === KEYS.SPACE) {
1343
+ evt.preventDefault();
1344
+ }
1345
+ });
1346
+
1347
+ container.on('results:focus', function (params) {
1348
+ self.$selection.attr('aria-activedescendant', params.data._resultId);
1349
+ });
1350
+
1351
+ container.on('selection:update', function (params) {
1352
+ self.update(params.data);
1353
+ });
1354
+
1355
+ container.on('open', function () {
1356
+ // When the dropdown is open, aria-expanded="true"
1357
+ self.$selection.attr('aria-expanded', 'true');
1358
+ self.$selection.attr('aria-owns', resultsId);
1359
+
1360
+ self._attachCloseHandler(container);
1361
+ });
1362
+
1363
+ container.on('close', function () {
1364
+ // When the dropdown is closed, aria-expanded="false"
1365
+ self.$selection.attr('aria-expanded', 'false');
1366
+ self.$selection.removeAttr('aria-activedescendant');
1367
+ self.$selection.removeAttr('aria-owns');
1368
+
1369
+ self.$selection.focus();
1370
+
1371
+ self._detachCloseHandler(container);
1372
+ });
1373
+
1374
+ container.on('enable', function () {
1375
+ self.$selection.attr('tabindex', self._tabindex);
1376
+ });
1377
+
1378
+ container.on('disable', function () {
1379
+ self.$selection.attr('tabindex', '-1');
1380
+ });
1381
+ };
1382
+
1383
+ BaseSelection.prototype._handleBlur = function (evt) {
1384
+ var self = this;
1385
+
1386
+ // This needs to be delayed as the active element is the body when the tab
1387
+ // key is pressed, possibly along with others.
1388
+ window.setTimeout(function () {
1389
+ // Don't trigger `blur` if the focus is still in the selection
1390
+ if (
1391
+ (document.activeElement == self.$selection[0]) ||
1392
+ ($.contains(self.$selection[0], document.activeElement))
1393
+ ) {
1394
+ return;
1395
+ }
1396
+
1397
+ self.trigger('blur', evt);
1398
+ }, 1);
1399
+ };
1400
+
1401
+ BaseSelection.prototype._attachCloseHandler = function (container) {
1402
+ var self = this;
1403
+
1404
+ $(document.body).on('mousedown.pumselect2.' + container.id, function (e) {
1405
+ var $target = $(e.target);
1406
+
1407
+ var $select = $target.closest('.pumselect2');
1408
+
1409
+ var $all = $('.pumselect2.pumselect2-container--open');
1410
+
1411
+ $all.each(function () {
1412
+ var $this = $(this);
1413
+
1414
+ if (this == $select[0]) {
1415
+ return;
1416
+ }
1417
+
1418
+ var $element = $this.data('element');
1419
+
1420
+ $element.pumselect2('close');
1421
+ });
1422
+ });
1423
+ };
1424
+
1425
+ BaseSelection.prototype._detachCloseHandler = function (container) {
1426
+ $(document.body).off('mousedown.pumselect2.' + container.id);
1427
+ };
1428
+
1429
+ BaseSelection.prototype.position = function ($selection, $container) {
1430
+ var $selectionContainer = $container.find('.selection');
1431
+ $selectionContainer.append($selection);
1432
+ };
1433
+
1434
+ BaseSelection.prototype.destroy = function () {
1435
+ this._detachCloseHandler(this.container);
1436
+ };
1437
+
1438
+ BaseSelection.prototype.update = function (data) {
1439
+ throw new Error('The `update` method must be defined in child classes.');
1440
+ };
1441
+
1442
+ return BaseSelection;
1443
+ });
1444
+
1445
+ S2.define('pumselect2/selection/single',[
1446
+ 'jquery',
1447
+ './base',
1448
+ '../utils',
1449
+ '../keys'
1450
+ ], function ($, BaseSelection, Utils, KEYS) {
1451
+ function SingleSelection () {
1452
+ SingleSelection.__super__.constructor.apply(this, arguments);
1453
+ }
1454
+
1455
+ Utils.Extend(SingleSelection, BaseSelection);
1456
+
1457
+ SingleSelection.prototype.render = function () {
1458
+ var $selection = SingleSelection.__super__.render.call(this);
1459
+
1460
+ $selection.addClass('pumselect2-selection--single');
1461
+
1462
+ $selection.html(
1463
+ '<span class="pumselect2-selection__rendered"></span>' +
1464
+ '<span class="pumselect2-selection__arrow" role="presentation">' +
1465
+ '<b role="presentation"></b>' +
1466
+ '</span>'
1467
+ );
1468
+
1469
+ return $selection;
1470
+ };
1471
+
1472
+ SingleSelection.prototype.bind = function (container, $container) {
1473
+ var self = this;
1474
+
1475
+ SingleSelection.__super__.bind.apply(this, arguments);
1476
+
1477
+ var id = container.id + '-container';
1478
+
1479
+ this.$selection.find('.pumselect2-selection__rendered').attr('id', id);
1480
+ this.$selection.attr('aria-labelledby', id);
1481
+
1482
+ this.$selection.on('mousedown', function (evt) {
1483
+ // Only respond to left clicks
1484
+ if (evt.which !== 1) {
1485
+ return;
1486
+ }
1487
+
1488
+ self.trigger('toggle', {
1489
+ originalEvent: evt
1490
+ });
1491
+ });
1492
+
1493
+ this.$selection.on('focus', function (evt) {
1494
+ // User focuses on the container
1495
+ });
1496
+
1497
+ this.$selection.on('blur', function (evt) {
1498
+ // User exits the container
1499
+ });
1500
+
1501
+ container.on('selection:update', function (params) {
1502
+ self.update(params.data);
1503
+ });
1504
+ };
1505
+
1506
+ SingleSelection.prototype.clear = function () {
1507
+ this.$selection.find('.pumselect2-selection__rendered').empty();
1508
+ };
1509
+
1510
+ SingleSelection.prototype.display = function (data, container) {
1511
+ var template = this.options.get('templateSelection');
1512
+ var escapeMarkup = this.options.get('escapeMarkup');
1513
+
1514
+ return escapeMarkup(template(data, container));
1515
+ };
1516
+
1517
+ SingleSelection.prototype.selectionContainer = function () {
1518
+ return $('<span></span>');
1519
+ };
1520
+
1521
+ SingleSelection.prototype.update = function (data) {
1522
+ if (data.length === 0) {
1523
+ this.clear();
1524
+ return;
1525
+ }
1526
+
1527
+ var selection = data[0];
1528
+
1529
+ var $rendered = this.$selection.find('.pumselect2-selection__rendered');
1530
+ var formatted = this.display(selection, $rendered);
1531
+
1532
+ $rendered.empty().append(formatted);
1533
+ $rendered.prop('title', selection.title || selection.text);
1534
+ };
1535
+
1536
+ return SingleSelection;
1537
+ });
1538
+
1539
+ S2.define('pumselect2/selection/multiple',[
1540
+ 'jquery',
1541
+ './base',
1542
+ '../utils'
1543
+ ], function ($, BaseSelection, Utils) {
1544
+ function MultipleSelection ($element, options) {
1545
+ MultipleSelection.__super__.constructor.apply(this, arguments);
1546
+ }
1547
+
1548
+ Utils.Extend(MultipleSelection, BaseSelection);
1549
+
1550
+ MultipleSelection.prototype.render = function () {
1551
+ var $selection = MultipleSelection.__super__.render.call(this);
1552
+
1553
+ $selection.addClass('pumselect2-selection--multiple');
1554
+
1555
+ $selection.html(
1556
+ '<ul class="pumselect2-selection__rendered"></ul>'
1557
+ );
1558
+
1559
+ return $selection;
1560
+ };
1561
+
1562
+ MultipleSelection.prototype.bind = function (container, $container) {
1563
+ var self = this;
1564
+
1565
+ MultipleSelection.__super__.bind.apply(this, arguments);
1566
+
1567
+ this.$selection.on('click', function (evt) {
1568
+ self.trigger('toggle', {
1569
+ originalEvent: evt
1570
+ });
1571
+ });
1572
+
1573
+ this.$selection.on(
1574
+ 'click',
1575
+ '.pumselect2-selection__choice__remove',
1576
+ function (evt) {
1577
+ // Ignore the event if it is disabled
1578
+ if (self.options.get('disabled')) {
1579
+ return;
1580
+ }
1581
+
1582
+ var $remove = $(this);
1583
+ var $selection = $remove.parent();
1584
+
1585
+ var data = $selection.data('data');
1586
+
1587
+ self.trigger('unselect', {
1588
+ originalEvent: evt,
1589
+ data: data
1590
+ });
1591
+ }
1592
+ );
1593
+ };
1594
+
1595
+ MultipleSelection.prototype.clear = function () {
1596
+ this.$selection.find('.pumselect2-selection__rendered').empty();
1597
+ };
1598
+
1599
+ MultipleSelection.prototype.display = function (data, container) {
1600
+ var template = this.options.get('templateSelection');
1601
+ var escapeMarkup = this.options.get('escapeMarkup');
1602
+
1603
+ return escapeMarkup(template(data, container));
1604
+ };
1605
+
1606
+ MultipleSelection.prototype.selectionContainer = function () {
1607
+ var $container = $(
1608
+ '<li class="pumselect2-selection__choice">' +
1609
+ '<span class="pumselect2-selection__choice__remove" role="presentation">' +
1610
+ '&times;' +
1611
+ '</span>' +
1612
+ '</li>'
1613
+ );
1614
+
1615
+ return $container;
1616
+ };
1617
+
1618
+ MultipleSelection.prototype.update = function (data) {
1619
+ this.clear();
1620
+
1621
+ if (data.length === 0) {
1622
+ return;
1623
+ }
1624
+
1625
+ var $selections = [];
1626
+
1627
+ for (var d = 0; d < data.length; d++) {
1628
+ var selection = data[d];
1629
+
1630
+ var $selection = this.selectionContainer();
1631
+ var formatted = this.display(selection, $selection);
1632
+
1633
+ $selection.append(formatted);
1634
+ $selection.prop('title', selection.title || selection.text);
1635
+
1636
+ $selection.data('data', selection);
1637
+
1638
+ $selections.push($selection);
1639
+ }
1640
+
1641
+ var $rendered = this.$selection.find('.pumselect2-selection__rendered');
1642
+
1643
+ Utils.appendMany($rendered, $selections);
1644
+ };
1645
+
1646
+ return MultipleSelection;
1647
+ });
1648
+
1649
+ S2.define('pumselect2/selection/placeholder',[
1650
+ '../utils'
1651
+ ], function (Utils) {
1652
+ function Placeholder (decorated, $element, options) {
1653
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
1654
+
1655
+ decorated.call(this, $element, options);
1656
+ }
1657
+
1658
+ Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
1659
+ if (typeof placeholder === 'string') {
1660
+ placeholder = {
1661
+ id: '',
1662
+ text: placeholder
1663
+ };
1664
+ }
1665
+
1666
+ return placeholder;
1667
+ };
1668
+
1669
+ Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
1670
+ var $placeholder = this.selectionContainer();
1671
+
1672
+ $placeholder.html(this.display(placeholder));
1673
+ $placeholder.addClass('pumselect2-selection__placeholder')
1674
+ .removeClass('pumselect2-selection__choice');
1675
+
1676
+ return $placeholder;
1677
+ };
1678
+
1679
+ Placeholder.prototype.update = function (decorated, data) {
1680
+ var singlePlaceholder = (
1681
+ data.length == 1 && data[0].id != this.placeholder.id
1682
+ );
1683
+ var multipleSelections = data.length > 1;
1684
+
1685
+ if (multipleSelections || singlePlaceholder) {
1686
+ return decorated.call(this, data);
1687
+ }
1688
+
1689
+ this.clear();
1690
+
1691
+ var $placeholder = this.createPlaceholder(this.placeholder);
1692
+
1693
+ this.$selection.find('.pumselect2-selection__rendered').append($placeholder);
1694
+ };
1695
+
1696
+ return Placeholder;
1697
+ });
1698
+
1699
+ S2.define('pumselect2/selection/allowClear',[
1700
+ 'jquery',
1701
+ '../keys'
1702
+ ], function ($, KEYS) {
1703
+ function AllowClear () { }
1704
+
1705
+ AllowClear.prototype.bind = function (decorated, container, $container) {
1706
+ var self = this;
1707
+
1708
+ decorated.call(this, container, $container);
1709
+
1710
+ if (this.placeholder == null) {
1711
+ if (this.options.get('debug') && window.console && console.error) {
1712
+ console.error(
1713
+ 'Select2: The `allowClear` option should be used in combination ' +
1714
+ 'with the `placeholder` option.'
1715
+ );
1716
+ }
1717
+ }
1718
+
1719
+ this.$selection.on('mousedown', '.pumselect2-selection__clear',
1720
+ function (evt) {
1721
+ self._handleClear(evt);
1722
+ });
1723
+
1724
+ container.on('keypress', function (evt) {
1725
+ self._handleKeyboardClear(evt, container);
1726
+ });
1727
+ };
1728
+
1729
+ AllowClear.prototype._handleClear = function (_, evt) {
1730
+ // Ignore the event if it is disabled
1731
+ if (this.options.get('disabled')) {
1732
+ return;
1733
+ }
1734
+
1735
+ var $clear = this.$selection.find('.pumselect2-selection__clear');
1736
+
1737
+ // Ignore the event if nothing has been selected
1738
+ if ($clear.length === 0) {
1739
+ return;
1740
+ }
1741
+
1742
+ evt.stopPropagation();
1743
+
1744
+ var data = $clear.data('data');
1745
+
1746
+ for (var d = 0; d < data.length; d++) {
1747
+ var unselectData = {
1748
+ data: data[d]
1749
+ };
1750
+
1751
+ // Trigger the `unselect` event, so people can prevent it from being
1752
+ // cleared.
1753
+ this.trigger('unselect', unselectData);
1754
+
1755
+ // If the event was prevented, don't clear it out.
1756
+ if (unselectData.prevented) {
1757
+ return;
1758
+ }
1759
+ }
1760
+
1761
+ this.$element.val(this.placeholder.id).trigger('change');
1762
+
1763
+ this.trigger('toggle', {});
1764
+ };
1765
+
1766
+ AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
1767
+ if (container.isOpen()) {
1768
+ return;
1769
+ }
1770
+
1771
+ if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
1772
+ this._handleClear(evt);
1773
+ }
1774
+ };
1775
+
1776
+ AllowClear.prototype.update = function (decorated, data) {
1777
+ decorated.call(this, data);
1778
+
1779
+ if (this.$selection.find('.pumselect2-selection__placeholder').length > 0 ||
1780
+ data.length === 0) {
1781
+ return;
1782
+ }
1783
+
1784
+ var $remove = $(
1785
+ '<span class="pumselect2-selection__clear">' +
1786
+ '&times;' +
1787
+ '</span>'
1788
+ );
1789
+ $remove.data('data', data);
1790
+
1791
+ this.$selection.find('.pumselect2-selection__rendered').prepend($remove);
1792
+ };
1793
+
1794
+ return AllowClear;
1795
+ });
1796
+
1797
+ S2.define('pumselect2/selection/search',[
1798
+ 'jquery',
1799
+ '../utils',
1800
+ '../keys'
1801
+ ], function ($, Utils, KEYS) {
1802
+ function Search (decorated, $element, options) {
1803
+ decorated.call(this, $element, options);
1804
+ }
1805
+
1806
+ Search.prototype.render = function (decorated) {
1807
+ var $search = $(
1808
+ '<li class="pumselect2-search pumselect2-search--inline">' +
1809
+ '<input class="pumselect2-search__field" type="search" tabindex="-1"' +
1810
+ ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
1811
+ ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
1812
+ '</li>'
1813
+ );
1814
+
1815
+ this.$searchContainer = $search;
1816
+ this.$search = $search.find('input');
1817
+
1818
+ var $rendered = decorated.call(this);
1819
+
1820
+ this._transferTabIndex();
1821
+
1822
+ return $rendered;
1823
+ };
1824
+
1825
+ Search.prototype.bind = function (decorated, container, $container) {
1826
+ var self = this;
1827
+
1828
+ decorated.call(this, container, $container);
1829
+
1830
+ container.on('open', function () {
1831
+ self.$search.trigger('focus');
1832
+ });
1833
+
1834
+ container.on('close', function () {
1835
+ self.$search.val('');
1836
+ self.$search.removeAttr('aria-activedescendant');
1837
+ self.$search.trigger('focus');
1838
+ });
1839
+
1840
+ container.on('enable', function () {
1841
+ self.$search.prop('disabled', false);
1842
+
1843
+ self._transferTabIndex();
1844
+ });
1845
+
1846
+ container.on('disable', function () {
1847
+ self.$search.prop('disabled', true);
1848
+ });
1849
+
1850
+ container.on('focus', function (evt) {
1851
+ self.$search.trigger('focus');
1852
+ });
1853
+
1854
+ container.on('results:focus', function (params) {
1855
+ self.$search.attr('aria-activedescendant', params.id);
1856
+ });
1857
+
1858
+ this.$selection.on('focusin', '.pumselect2-search--inline', function (evt) {
1859
+ self.trigger('focus', evt);
1860
+ });
1861
+
1862
+ this.$selection.on('focusout', '.pumselect2-search--inline', function (evt) {
1863
+ self._handleBlur(evt);
1864
+ });
1865
+
1866
+ this.$selection.on('keydown', '.pumselect2-search--inline', function (evt) {
1867
+ evt.stopPropagation();
1868
+
1869
+ self.trigger('keypress', evt);
1870
+
1871
+ self._keyUpPrevented = evt.isDefaultPrevented();
1872
+
1873
+ var key = evt.which;
1874
+
1875
+ if (key === KEYS.BACKSPACE && self.$search.val() === '') {
1876
+ var $previousChoice = self.$searchContainer
1877
+ .prev('.pumselect2-selection__choice');
1878
+
1879
+ if ($previousChoice.length > 0) {
1880
+ var item = $previousChoice.data('data');
1881
+
1882
+ self.searchRemoveChoice(item);
1883
+
1884
+ evt.preventDefault();
1885
+ }
1886
+ }
1887
+ });
1888
+
1889
+ // Try to detect the IE version should the `documentMode` property that
1890
+ // is stored on the document. This is only implemented in IE and is
1891
+ // slightly cleaner than doing a user agent check.
1892
+ // This property is not available in Edge, but Edge also doesn't have
1893
+ // this bug.
1894
+ var msie = document.documentMode;
1895
+ var disableInputEvents = msie && msie <= 11;
1896
+
1897
+ // Workaround for browsers which do not support the `input` event
1898
+ // This will prevent double-triggering of events for browsers which support
1899
+ // both the `keyup` and `input` events.
1900
+ this.$selection.on(
1901
+ 'input.searchcheck',
1902
+ '.pumselect2-search--inline',
1903
+ function (evt) {
1904
+ // IE will trigger the `input` event when a placeholder is used on a
1905
+ // search box. To get around this issue, we are forced to ignore all
1906
+ // `input` events in IE and keep using `keyup`.
1907
+ if (disableInputEvents) {
1908
+ self.$selection.off('input.search input.searchcheck');
1909
+ return;
1910
+ }
1911
+
1912
+ // Unbind the duplicated `keyup` event
1913
+ self.$selection.off('keyup.search');
1914
+ }
1915
+ );
1916
+
1917
+ this.$selection.on(
1918
+ 'keyup.search input.search',
1919
+ '.pumselect2-search--inline',
1920
+ function (evt) {
1921
+ // IE will trigger the `input` event when a placeholder is used on a
1922
+ // search box. To get around this issue, we are forced to ignore all
1923
+ // `input` events in IE and keep using `keyup`.
1924
+ if (disableInputEvents && evt.type === 'input') {
1925
+ self.$selection.off('input.search input.searchcheck');
1926
+ return;
1927
+ }
1928
+
1929
+ var key = evt.which;
1930
+
1931
+ // We can freely ignore events from modifier keys
1932
+ if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
1933
+ return;
1934
+ }
1935
+
1936
+ // Tabbing will be handled during the `keydown` phase
1937
+ if (key == KEYS.TAB) {
1938
+ return;
1939
+ }
1940
+
1941
+ self.handleSearch(evt);
1942
+ }
1943
+ );
1944
+ };
1945
+
1946
+ /**
1947
+ * This method will transfer the tabindex attribute from the rendered
1948
+ * selection to the search box. This allows for the search box to be used as
1949
+ * the primary focus instead of the selection container.
1950
+ *
1951
+ * @private
1952
+ */
1953
+ Search.prototype._transferTabIndex = function (decorated) {
1954
+ this.$search.attr('tabindex', this.$selection.attr('tabindex'));
1955
+ this.$selection.attr('tabindex', '-1');
1956
+ };
1957
+
1958
+ Search.prototype.createPlaceholder = function (decorated, placeholder) {
1959
+ this.$search.attr('placeholder', placeholder.text);
1960
+ };
1961
+
1962
+ Search.prototype.update = function (decorated, data) {
1963
+ var searchHadFocus = this.$search[0] == document.activeElement;
1964
+
1965
+ this.$search.attr('placeholder', '');
1966
+
1967
+ decorated.call(this, data);
1968
+
1969
+ this.$selection.find('.pumselect2-selection__rendered')
1970
+ .append(this.$searchContainer);
1971
+
1972
+ this.resizeSearch();
1973
+ if (searchHadFocus) {
1974
+ this.$search.focus();
1975
+ }
1976
+ };
1977
+
1978
+ Search.prototype.handleSearch = function () {
1979
+ this.resizeSearch();
1980
+
1981
+ if (!this._keyUpPrevented) {
1982
+ var input = this.$search.val();
1983
+
1984
+ this.trigger('query', {
1985
+ term: input
1986
+ });
1987
+ }
1988
+
1989
+ this._keyUpPrevented = false;
1990
+ };
1991
+
1992
+ Search.prototype.searchRemoveChoice = function (decorated, item) {
1993
+ this.trigger('unselect', {
1994
+ data: item
1995
+ });
1996
+
1997
+ this.$search.val(item.text);
1998
+ this.handleSearch();
1999
+ };
2000
+
2001
+ Search.prototype.resizeSearch = function () {
2002
+ this.$search.css('width', '25px');
2003
+
2004
+ var width = '';
2005
+
2006
+ if (this.$search.attr('placeholder') !== '') {
2007
+ width = this.$selection.find('.pumselect2-selection__rendered').innerWidth();
2008
+ } else {
2009
+ var minimumWidth = this.$search.val().length + 1;
2010
+
2011
+ width = (minimumWidth * 0.75) + 'em';
2012
+ }
2013
+
2014
+ this.$search.css('width', width);
2015
+ };
2016
+
2017
+ return Search;
2018
+ });
2019
+
2020
+ S2.define('pumselect2/selection/eventRelay',[
2021
+ 'jquery'
2022
+ ], function ($) {
2023
+ function EventRelay () { }
2024
+
2025
+ EventRelay.prototype.bind = function (decorated, container, $container) {
2026
+ var self = this;
2027
+ var relayEvents = [
2028
+ 'open', 'opening',
2029
+ 'close', 'closing',
2030
+ 'select', 'selecting',
2031
+ 'unselect', 'unselecting'
2032
+ ];
2033
+
2034
+ var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
2035
+
2036
+ decorated.call(this, container, $container);
2037
+
2038
+ container.on('*', function (name, params) {
2039
+ // Ignore events that should not be relayed
2040
+ if ($.inArray(name, relayEvents) === -1) {
2041
+ return;
2042
+ }
2043
+
2044
+ // The parameters should always be an object
2045
+ params = params || {};
2046
+
2047
+ // Generate the jQuery event for the Select2 event
2048
+ var evt = $.Event('pumselect2:' + name, {
2049
+ params: params
2050
+ });
2051
+
2052
+ self.$element.trigger(evt);
2053
+
2054
+ // Only handle preventable events if it was one
2055
+ if ($.inArray(name, preventableEvents) === -1) {
2056
+ return;
2057
+ }
2058
+
2059
+ params.prevented = evt.isDefaultPrevented();
2060
+ });
2061
+ };
2062
+
2063
+ return EventRelay;
2064
+ });
2065
+
2066
+ S2.define('pumselect2/translation',[
2067
+ 'jquery',
2068
+ 'require'
2069
+ ], function ($, require) {
2070
+ function Translation (dict) {
2071
+ this.dict = dict || {};
2072
+ }
2073
+
2074
+ Translation.prototype.all = function () {
2075
+ return this.dict;
2076
+ };
2077
+
2078
+ Translation.prototype.get = function (key) {
2079
+ return this.dict[key];
2080
+ };
2081
+
2082
+ Translation.prototype.extend = function (translation) {
2083
+ this.dict = $.extend({}, translation.all(), this.dict);
2084
+ };
2085
+
2086
+ // Static functions
2087
+
2088
+ Translation._cache = {};
2089
+
2090
+ Translation.loadPath = function (path) {
2091
+ if (!(path in Translation._cache)) {
2092
+ var translations = require(path);
2093
+
2094
+ Translation._cache[path] = translations;
2095
+ }
2096
+
2097
+ return new Translation(Translation._cache[path]);
2098
+ };
2099
+
2100
+ return Translation;
2101
+ });
2102
+
2103
+ S2.define('pumselect2/diacritics',[
2104
+
2105
+ ], function () {
2106
+ var diacritics = {
2107
+ '\u24B6': 'A',
2108
+ '\uFF21': 'A',
2109
+ '\u00C0': 'A',
2110
+ '\u00C1': 'A',
2111
+ '\u00C2': 'A',
2112
+ '\u1EA6': 'A',
2113
+ '\u1EA4': 'A',
2114
+ '\u1EAA': 'A',
2115
+ '\u1EA8': 'A',
2116
+ '\u00C3': 'A',
2117
+ '\u0100': 'A',
2118
+ '\u0102': 'A',
2119
+ '\u1EB0': 'A',
2120
+ '\u1EAE': 'A',
2121
+ '\u1EB4': 'A',
2122
+ '\u1EB2': 'A',
2123
+ '\u0226': 'A',
2124
+ '\u01E0': 'A',
2125
+ '\u00C4': 'A',
2126
+ '\u01DE': 'A',
2127
+ '\u1EA2': 'A',
2128
+ '\u00C5': 'A',
2129
+ '\u01FA': 'A',
2130
+ '\u01CD': 'A',
2131
+ '\u0200': 'A',
2132
+ '\u0202': 'A',
2133
+ '\u1EA0': 'A',
2134
+ '\u1EAC': 'A',
2135
+ '\u1EB6': 'A',
2136
+ '\u1E00': 'A',
2137
+ '\u0104': 'A',
2138
+ '\u023A': 'A',
2139
+ '\u2C6F': 'A',
2140
+ '\uA732': 'AA',
2141
+ '\u00C6': 'AE',
2142
+ '\u01FC': 'AE',
2143
+ '\u01E2': 'AE',
2144
+ '\uA734': 'AO',
2145
+ '\uA736': 'AU',
2146
+ '\uA738': 'AV',
2147
+ '\uA73A': 'AV',
2148
+ '\uA73C': 'AY',
2149
+ '\u24B7': 'B',
2150
+ '\uFF22': 'B',
2151
+ '\u1E02': 'B',
2152
+ '\u1E04': 'B',
2153
+ '\u1E06': 'B',
2154
+ '\u0243': 'B',
2155
+ '\u0182': 'B',
2156
+ '\u0181': 'B',
2157
+ '\u24B8': 'C',
2158
+ '\uFF23': 'C',
2159
+ '\u0106': 'C',
2160
+ '\u0108': 'C',
2161
+ '\u010A': 'C',
2162
+ '\u010C': 'C',
2163
+ '\u00C7': 'C',
2164
+ '\u1E08': 'C',
2165
+ '\u0187': 'C',
2166
+ '\u023B': 'C',
2167
+ '\uA73E': 'C',
2168
+ '\u24B9': 'D',
2169
+ '\uFF24': 'D',
2170
+ '\u1E0A': 'D',
2171
+ '\u010E': 'D',
2172
+ '\u1E0C': 'D',
2173
+ '\u1E10': 'D',
2174
+ '\u1E12': 'D',
2175
+ '\u1E0E': 'D',
2176
+ '\u0110': 'D',
2177
+ '\u018B': 'D',
2178
+ '\u018A': 'D',
2179
+ '\u0189': 'D',
2180
+ '\uA779': 'D',
2181
+ '\u01F1': 'DZ',
2182
+ '\u01C4': 'DZ',
2183
+ '\u01F2': 'Dz',
2184
+ '\u01C5': 'Dz',
2185
+ '\u24BA': 'E',
2186
+ '\uFF25': 'E',
2187
+ '\u00C8': 'E',
2188
+ '\u00C9': 'E',
2189
+ '\u00CA': 'E',
2190
+ '\u1EC0': 'E',
2191
+ '\u1EBE': 'E',
2192
+ '\u1EC4': 'E',
2193
+ '\u1EC2': 'E',
2194
+ '\u1EBC': 'E',
2195
+ '\u0112': 'E',
2196
+ '\u1E14': 'E',
2197
+ '\u1E16': 'E',
2198
+ '\u0114': 'E',
2199
+ '\u0116': 'E',
2200
+ '\u00CB': 'E',
2201
+ '\u1EBA': 'E',
2202
+ '\u011A': 'E',
2203
+ '\u0204': 'E',
2204
+ '\u0206': 'E',
2205
+ '\u1EB8': 'E',
2206
+ '\u1EC6': 'E',
2207
+ '\u0228': 'E',
2208
+ '\u1E1C': 'E',
2209
+ '\u0118': 'E',
2210
+ '\u1E18': 'E',
2211
+ '\u1E1A': 'E',
2212
+ '\u0190': 'E',
2213
+ '\u018E': 'E',
2214
+ '\u24BB': 'F',
2215
+ '\uFF26': 'F',
2216
+ '\u1E1E': 'F',
2217
+ '\u0191': 'F',
2218
+ '\uA77B': 'F',
2219
+ '\u24BC': 'G',
2220
+ '\uFF27': 'G',
2221
+ '\u01F4': 'G',
2222
+ '\u011C': 'G',
2223
+ '\u1E20': 'G',
2224
+ '\u011E': 'G',
2225
+ '\u0120': 'G',
2226
+ '\u01E6': 'G',
2227
+ '\u0122': 'G',
2228
+ '\u01E4': 'G',
2229
+ '\u0193': 'G',
2230
+ '\uA7A0': 'G',
2231
+ '\uA77D': 'G',
2232
+ '\uA77E': 'G',
2233
+ '\u24BD': 'H',
2234
+ '\uFF28': 'H',
2235
+ '\u0124': 'H',
2236
+ '\u1E22': 'H',
2237
+ '\u1E26': 'H',
2238
+ '\u021E': 'H',
2239
+ '\u1E24': 'H',
2240
+ '\u1E28': 'H',
2241
+ '\u1E2A': 'H',
2242
+ '\u0126': 'H',
2243
+ '\u2C67': 'H',
2244
+ '\u2C75': 'H',
2245
+ '\uA78D': 'H',
2246
+ '\u24BE': 'I',
2247
+ '\uFF29': 'I',
2248
+ '\u00CC': 'I',
2249
+ '\u00CD': 'I',
2250
+ '\u00CE': 'I',
2251
+ '\u0128': 'I',
2252
+ '\u012A': 'I',
2253
+ '\u012C': 'I',
2254
+ '\u0130': 'I',
2255
+ '\u00CF': 'I',
2256
+ '\u1E2E': 'I',
2257
+ '\u1EC8': 'I',
2258
+ '\u01CF': 'I',
2259
+ '\u0208': 'I',
2260
+ '\u020A': 'I',
2261
+ '\u1ECA': 'I',
2262
+ '\u012E': 'I',
2263
+ '\u1E2C': 'I',
2264
+ '\u0197': 'I',
2265
+ '\u24BF': 'J',
2266
+ '\uFF2A': 'J',
2267
+ '\u0134': 'J',
2268
+ '\u0248': 'J',
2269
+ '\u24C0': 'K',
2270
+ '\uFF2B': 'K',
2271
+ '\u1E30': 'K',
2272
+ '\u01E8': 'K',
2273
+ '\u1E32': 'K',
2274
+ '\u0136': 'K',
2275
+ '\u1E34': 'K',
2276
+ '\u0198': 'K',
2277
+ '\u2C69': 'K',
2278
+ '\uA740': 'K',
2279
+ '\uA742': 'K',
2280
+ '\uA744': 'K',
2281
+ '\uA7A2': 'K',
2282
+ '\u24C1': 'L',
2283
+ '\uFF2C': 'L',
2284
+ '\u013F': 'L',
2285
+ '\u0139': 'L',
2286
+ '\u013D': 'L',
2287
+ '\u1E36': 'L',
2288
+ '\u1E38': 'L',
2289
+ '\u013B': 'L',
2290
+ '\u1E3C': 'L',
2291
+ '\u1E3A': 'L',
2292
+ '\u0141': 'L',
2293
+ '\u023D': 'L',
2294
+ '\u2C62': 'L',
2295
+ '\u2C60': 'L',
2296
+ '\uA748': 'L',
2297
+ '\uA746': 'L',
2298
+ '\uA780': 'L',
2299
+ '\u01C7': 'LJ',
2300
+ '\u01C8': 'Lj',
2301
+ '\u24C2': 'M',
2302
+ '\uFF2D': 'M',
2303
+ '\u1E3E': 'M',
2304
+ '\u1E40': 'M',
2305
+ '\u1E42': 'M',
2306
+ '\u2C6E': 'M',
2307
+ '\u019C': 'M',
2308
+ '\u24C3': 'N',
2309
+ '\uFF2E': 'N',
2310
+ '\u01F8': 'N',
2311
+ '\u0143': 'N',
2312
+ '\u00D1': 'N',
2313
+ '\u1E44': 'N',
2314
+ '\u0147': 'N',
2315
+ '\u1E46': 'N',
2316
+ '\u0145': 'N',
2317
+ '\u1E4A': 'N',
2318
+ '\u1E48': 'N',
2319
+ '\u0220': 'N',
2320
+ '\u019D': 'N',
2321
+ '\uA790': 'N',
2322
+ '\uA7A4': 'N',
2323
+ '\u01CA': 'NJ',
2324
+ '\u01CB': 'Nj',
2325
+ '\u24C4': 'O',
2326
+ '\uFF2F': 'O',
2327
+ '\u00D2': 'O',
2328
+ '\u00D3': 'O',
2329
+ '\u00D4': 'O',
2330
+ '\u1ED2': 'O',
2331
+ '\u1ED0': 'O',
2332
+ '\u1ED6': 'O',
2333
+ '\u1ED4': 'O',
2334
+ '\u00D5': 'O',
2335
+ '\u1E4C': 'O',
2336
+ '\u022C': 'O',
2337
+ '\u1E4E': 'O',
2338
+ '\u014C': 'O',
2339
+ '\u1E50': 'O',
2340
+ '\u1E52': 'O',
2341
+ '\u014E': 'O',
2342
+ '\u022E': 'O',
2343
+ '\u0230': 'O',
2344
+ '\u00D6': 'O',
2345
+ '\u022A': 'O',
2346
+ '\u1ECE': 'O',
2347
+ '\u0150': 'O',
2348
+ '\u01D1': 'O',
2349
+ '\u020C': 'O',
2350
+ '\u020E': 'O',
2351
+ '\u01A0': 'O',
2352
+ '\u1EDC': 'O',
2353
+ '\u1EDA': 'O',
2354
+ '\u1EE0': 'O',
2355
+ '\u1EDE': 'O',
2356
+ '\u1EE2': 'O',
2357
+ '\u1ECC': 'O',
2358
+ '\u1ED8': 'O',
2359
+ '\u01EA': 'O',
2360
+ '\u01EC': 'O',
2361
+ '\u00D8': 'O',
2362
+ '\u01FE': 'O',
2363
+ '\u0186': 'O',
2364
+ '\u019F': 'O',
2365
+ '\uA74A': 'O',
2366
+ '\uA74C': 'O',
2367
+ '\u01A2': 'OI',
2368
+ '\uA74E': 'OO',
2369
+ '\u0222': 'OU',
2370
+ '\u24C5': 'P',
2371
+ '\uFF30': 'P',
2372
+ '\u1E54': 'P',
2373
+ '\u1E56': 'P',
2374
+ '\u01A4': 'P',
2375
+ '\u2C63': 'P',
2376
+ '\uA750': 'P',
2377
+ '\uA752': 'P',
2378
+ '\uA754': 'P',
2379
+ '\u24C6': 'Q',
2380
+ '\uFF31': 'Q',
2381
+ '\uA756': 'Q',
2382
+ '\uA758': 'Q',
2383
+ '\u024A': 'Q',
2384
+ '\u24C7': 'R',
2385
+ '\uFF32': 'R',
2386
+ '\u0154': 'R',
2387
+ '\u1E58': 'R',
2388
+ '\u0158': 'R',
2389
+ '\u0210': 'R',
2390
+ '\u0212': 'R',
2391
+ '\u1E5A': 'R',
2392
+ '\u1E5C': 'R',
2393
+ '\u0156': 'R',
2394
+ '\u1E5E': 'R',
2395
+ '\u024C': 'R',
2396
+ '\u2C64': 'R',
2397
+ '\uA75A': 'R',
2398
+ '\uA7A6': 'R',
2399
+ '\uA782': 'R',
2400
+ '\u24C8': 'S',
2401
+ '\uFF33': 'S',
2402
+ '\u1E9E': 'S',
2403
+ '\u015A': 'S',
2404
+ '\u1E64': 'S',
2405
+ '\u015C': 'S',
2406
+ '\u1E60': 'S',
2407
+ '\u0160': 'S',
2408
+ '\u1E66': 'S',
2409
+ '\u1E62': 'S',
2410
+ '\u1E68': 'S',
2411
+ '\u0218': 'S',
2412
+ '\u015E': 'S',
2413
+ '\u2C7E': 'S',
2414
+ '\uA7A8': 'S',
2415
+ '\uA784': 'S',
2416
+ '\u24C9': 'T',
2417
+ '\uFF34': 'T',
2418
+ '\u1E6A': 'T',
2419
+ '\u0164': 'T',
2420
+ '\u1E6C': 'T',
2421
+ '\u021A': 'T',
2422
+ '\u0162': 'T',
2423
+ '\u1E70': 'T',
2424
+ '\u1E6E': 'T',
2425
+ '\u0166': 'T',
2426
+ '\u01AC': 'T',
2427
+ '\u01AE': 'T',
2428
+ '\u023E': 'T',
2429
+ '\uA786': 'T',
2430
+ '\uA728': 'TZ',
2431
+ '\u24CA': 'U',
2432
+ '\uFF35': 'U',
2433
+ '\u00D9': 'U',
2434
+ '\u00DA': 'U',
2435
+ '\u00DB': 'U',
2436
+ '\u0168': 'U',
2437
+ '\u1E78': 'U',
2438
+ '\u016A': 'U',
2439
+ '\u1E7A': 'U',
2440
+ '\u016C': 'U',
2441
+ '\u00DC': 'U',
2442
+ '\u01DB': 'U',
2443
+ '\u01D7': 'U',
2444
+ '\u01D5': 'U',
2445
+ '\u01D9': 'U',
2446
+ '\u1EE6': 'U',
2447
+ '\u016E': 'U',
2448
+ '\u0170': 'U',
2449
+ '\u01D3': 'U',
2450
+ '\u0214': 'U',
2451
+ '\u0216': 'U',
2452
+ '\u01AF': 'U',
2453
+ '\u1EEA': 'U',
2454
+ '\u1EE8': 'U',
2455
+ '\u1EEE': 'U',
2456
+ '\u1EEC': 'U',
2457
+ '\u1EF0': 'U',
2458
+ '\u1EE4': 'U',
2459
+ '\u1E72': 'U',
2460
+ '\u0172': 'U',
2461
+ '\u1E76': 'U',
2462
+ '\u1E74': 'U',
2463
+ '\u0244': 'U',
2464
+ '\u24CB': 'V',
2465
+ '\uFF36': 'V',
2466
+ '\u1E7C': 'V',
2467
+ '\u1E7E': 'V',
2468
+ '\u01B2': 'V',
2469
+ '\uA75E': 'V',
2470
+ '\u0245': 'V',
2471
+ '\uA760': 'VY',
2472
+ '\u24CC': 'W',
2473
+ '\uFF37': 'W',
2474
+ '\u1E80': 'W',
2475
+ '\u1E82': 'W',
2476
+ '\u0174': 'W',
2477
+ '\u1E86': 'W',
2478
+ '\u1E84': 'W',
2479
+ '\u1E88': 'W',
2480
+ '\u2C72': 'W',
2481
+ '\u24CD': 'X',
2482
+ '\uFF38': 'X',
2483
+ '\u1E8A': 'X',
2484
+ '\u1E8C': 'X',
2485
+ '\u24CE': 'Y',
2486
+ '\uFF39': 'Y',
2487
+ '\u1EF2': 'Y',
2488
+ '\u00DD': 'Y',
2489
+ '\u0176': 'Y',
2490
+ '\u1EF8': 'Y',
2491
+ '\u0232': 'Y',
2492
+ '\u1E8E': 'Y',
2493
+ '\u0178': 'Y',
2494
+ '\u1EF6': 'Y',
2495
+ '\u1EF4': 'Y',
2496
+ '\u01B3': 'Y',
2497
+ '\u024E': 'Y',
2498
+ '\u1EFE': 'Y',
2499
+ '\u24CF': 'Z',
2500
+ '\uFF3A': 'Z',
2501
+ '\u0179': 'Z',
2502
+ '\u1E90': 'Z',
2503
+ '\u017B': 'Z',
2504
+ '\u017D': 'Z',
2505
+ '\u1E92': 'Z',
2506
+ '\u1E94': 'Z',
2507
+ '\u01B5': 'Z',
2508
+ '\u0224': 'Z',
2509
+ '\u2C7F': 'Z',
2510
+ '\u2C6B': 'Z',
2511
+ '\uA762': 'Z',
2512
+ '\u24D0': 'a',
2513
+ '\uFF41': 'a',
2514
+ '\u1E9A': 'a',
2515
+ '\u00E0': 'a',
2516
+ '\u00E1': 'a',
2517
+ '\u00E2': 'a',
2518
+ '\u1EA7': 'a',
2519
+ '\u1EA5': 'a',
2520
+ '\u1EAB': 'a',
2521
+ '\u1EA9': 'a',
2522
+ '\u00E3': 'a',
2523
+ '\u0101': 'a',
2524
+ '\u0103': 'a',
2525
+ '\u1EB1': 'a',
2526
+ '\u1EAF': 'a',
2527
+ '\u1EB5': 'a',
2528
+ '\u1EB3': 'a',
2529
+ '\u0227': 'a',
2530
+ '\u01E1': 'a',
2531
+ '\u00E4': 'a',
2532
+ '\u01DF': 'a',
2533
+ '\u1EA3': 'a',
2534
+ '\u00E5': 'a',
2535
+ '\u01FB': 'a',
2536
+ '\u01CE': 'a',
2537
+ '\u0201': 'a',
2538
+ '\u0203': 'a',
2539
+ '\u1EA1': 'a',
2540
+ '\u1EAD': 'a',
2541
+ '\u1EB7': 'a',
2542
+ '\u1E01': 'a',
2543
+ '\u0105': 'a',
2544
+ '\u2C65': 'a',
2545
+ '\u0250': 'a',
2546
+ '\uA733': 'aa',
2547
+ '\u00E6': 'ae',
2548
+ '\u01FD': 'ae',
2549
+ '\u01E3': 'ae',
2550
+ '\uA735': 'ao',
2551
+ '\uA737': 'au',
2552
+ '\uA739': 'av',
2553
+ '\uA73B': 'av',
2554
+ '\uA73D': 'ay',
2555
+ '\u24D1': 'b',
2556
+ '\uFF42': 'b',
2557
+ '\u1E03': 'b',
2558
+ '\u1E05': 'b',
2559
+ '\u1E07': 'b',
2560
+ '\u0180': 'b',
2561
+ '\u0183': 'b',
2562
+ '\u0253': 'b',
2563
+ '\u24D2': 'c',
2564
+ '\uFF43': 'c',
2565
+ '\u0107': 'c',
2566
+ '\u0109': 'c',
2567
+ '\u010B': 'c',
2568
+ '\u010D': 'c',
2569
+ '\u00E7': 'c',
2570
+ '\u1E09': 'c',
2571
+ '\u0188': 'c',
2572
+ '\u023C': 'c',
2573
+ '\uA73F': 'c',
2574
+ '\u2184': 'c',
2575
+ '\u24D3': 'd',
2576
+ '\uFF44': 'd',
2577
+ '\u1E0B': 'd',
2578
+ '\u010F': 'd',
2579
+ '\u1E0D': 'd',
2580
+ '\u1E11': 'd',
2581
+ '\u1E13': 'd',
2582
+ '\u1E0F': 'd',
2583
+ '\u0111': 'd',
2584
+ '\u018C': 'd',
2585
+ '\u0256': 'd',
2586
+ '\u0257': 'd',
2587
+ '\uA77A': 'd',
2588
+ '\u01F3': 'dz',
2589
+ '\u01C6': 'dz',
2590
+ '\u24D4': 'e',
2591
+ '\uFF45': 'e',
2592
+ '\u00E8': 'e',
2593
+ '\u00E9': 'e',
2594
+ '\u00EA': 'e',
2595
+ '\u1EC1': 'e',
2596
+ '\u1EBF': 'e',
2597
+ '\u1EC5': 'e',
2598
+ '\u1EC3': 'e',
2599
+ '\u1EBD': 'e',
2600
+ '\u0113': 'e',
2601
+ '\u1E15': 'e',
2602
+ '\u1E17': 'e',
2603
+ '\u0115': 'e',
2604
+ '\u0117': 'e',
2605
+ '\u00EB': 'e',
2606
+ '\u1EBB': 'e',
2607
+ '\u011B': 'e',
2608
+ '\u0205': 'e',
2609
+ '\u0207': 'e',
2610
+ '\u1EB9': 'e',
2611
+ '\u1EC7': 'e',
2612
+ '\u0229': 'e',
2613
+ '\u1E1D': 'e',
2614
+ '\u0119': 'e',
2615
+ '\u1E19': 'e',
2616
+ '\u1E1B': 'e',
2617
+ '\u0247': 'e',
2618
+ '\u025B': 'e',
2619
+ '\u01DD': 'e',
2620
+ '\u24D5': 'f',
2621
+ '\uFF46': 'f',
2622
+ '\u1E1F': 'f',
2623
+ '\u0192': 'f',
2624
+ '\uA77C': 'f',
2625
+ '\u24D6': 'g',
2626
+ '\uFF47': 'g',
2627
+ '\u01F5': 'g',
2628
+ '\u011D': 'g',
2629
+ '\u1E21': 'g',
2630
+ '\u011F': 'g',
2631
+ '\u0121': 'g',
2632
+ '\u01E7': 'g',
2633
+ '\u0123': 'g',
2634
+ '\u01E5': 'g',
2635
+ '\u0260': 'g',
2636
+ '\uA7A1': 'g',
2637
+ '\u1D79': 'g',
2638
+ '\uA77F': 'g',
2639
+ '\u24D7': 'h',
2640
+ '\uFF48': 'h',
2641
+ '\u0125': 'h',
2642
+ '\u1E23': 'h',
2643
+ '\u1E27': 'h',
2644
+ '\u021F': 'h',
2645
+ '\u1E25': 'h',
2646
+ '\u1E29': 'h',
2647
+ '\u1E2B': 'h',
2648
+ '\u1E96': 'h',
2649
+ '\u0127': 'h',
2650
+ '\u2C68': 'h',
2651
+ '\u2C76': 'h',
2652
+ '\u0265': 'h',
2653
+ '\u0195': 'hv',
2654
+ '\u24D8': 'i',
2655
+ '\uFF49': 'i',
2656
+ '\u00EC': 'i',
2657
+ '\u00ED': 'i',
2658
+ '\u00EE': 'i',
2659
+ '\u0129': 'i',
2660
+ '\u012B': 'i',
2661
+ '\u012D': 'i',
2662
+ '\u00EF': 'i',
2663
+ '\u1E2F': 'i',
2664
+ '\u1EC9': 'i',
2665
+ '\u01D0': 'i',
2666
+ '\u0209': 'i',
2667
+ '\u020B': 'i',
2668
+ '\u1ECB': 'i',
2669
+ '\u012F': 'i',
2670
+ '\u1E2D': 'i',
2671
+ '\u0268': 'i',
2672
+ '\u0131': 'i',
2673
+ '\u24D9': 'j',
2674
+ '\uFF4A': 'j',
2675
+ '\u0135': 'j',
2676
+ '\u01F0': 'j',
2677
+ '\u0249': 'j',
2678
+ '\u24DA': 'k',
2679
+ '\uFF4B': 'k',
2680
+ '\u1E31': 'k',
2681
+ '\u01E9': 'k',
2682
+ '\u1E33': 'k',
2683
+ '\u0137': 'k',
2684
+ '\u1E35': 'k',
2685
+ '\u0199': 'k',
2686
+ '\u2C6A': 'k',
2687
+ '\uA741': 'k',
2688
+ '\uA743': 'k',
2689
+ '\uA745': 'k',
2690
+ '\uA7A3': 'k',
2691
+ '\u24DB': 'l',
2692
+ '\uFF4C': 'l',
2693
+ '\u0140': 'l',
2694
+ '\u013A': 'l',
2695
+ '\u013E': 'l',
2696
+ '\u1E37': 'l',
2697
+ '\u1E39': 'l',
2698
+ '\u013C': 'l',
2699
+ '\u1E3D': 'l',
2700
+ '\u1E3B': 'l',
2701
+ '\u017F': 'l',
2702
+ '\u0142': 'l',
2703
+ '\u019A': 'l',
2704
+ '\u026B': 'l',
2705
+ '\u2C61': 'l',
2706
+ '\uA749': 'l',
2707
+ '\uA781': 'l',
2708
+ '\uA747': 'l',
2709
+ '\u01C9': 'lj',
2710
+ '\u24DC': 'm',
2711
+ '\uFF4D': 'm',
2712
+ '\u1E3F': 'm',
2713
+ '\u1E41': 'm',
2714
+ '\u1E43': 'm',
2715
+ '\u0271': 'm',
2716
+ '\u026F': 'm',
2717
+ '\u24DD': 'n',
2718
+ '\uFF4E': 'n',
2719
+ '\u01F9': 'n',
2720
+ '\u0144': 'n',
2721
+ '\u00F1': 'n',
2722
+ '\u1E45': 'n',
2723
+ '\u0148': 'n',
2724
+ '\u1E47': 'n',
2725
+ '\u0146': 'n',
2726
+ '\u1E4B': 'n',
2727
+ '\u1E49': 'n',
2728
+ '\u019E': 'n',
2729
+ '\u0272': 'n',
2730
+ '\u0149': 'n',
2731
+ '\uA791': 'n',
2732
+ '\uA7A5': 'n',
2733
+ '\u01CC': 'nj',
2734
+ '\u24DE': 'o',
2735
+ '\uFF4F': 'o',
2736
+ '\u00F2': 'o',
2737
+ '\u00F3': 'o',
2738
+ '\u00F4': 'o',
2739
+ '\u1ED3': 'o',
2740
+ '\u1ED1': 'o',
2741
+ '\u1ED7': 'o',
2742
+ '\u1ED5': 'o',
2743
+ '\u00F5': 'o',
2744
+ '\u1E4D': 'o',
2745
+ '\u022D': 'o',
2746
+ '\u1E4F': 'o',
2747
+ '\u014D': 'o',
2748
+ '\u1E51': 'o',
2749
+ '\u1E53': 'o',
2750
+ '\u014F': 'o',
2751
+ '\u022F': 'o',
2752
+ '\u0231': 'o',
2753
+ '\u00F6': 'o',
2754
+ '\u022B': 'o',
2755
+ '\u1ECF': 'o',
2756
+ '\u0151': 'o',
2757
+ '\u01D2': 'o',
2758
+ '\u020D': 'o',
2759
+ '\u020F': 'o',
2760
+ '\u01A1': 'o',
2761
+ '\u1EDD': 'o',
2762
+ '\u1EDB': 'o',
2763
+ '\u1EE1': 'o',
2764
+ '\u1EDF': 'o',
2765
+ '\u1EE3': 'o',
2766
+ '\u1ECD': 'o',
2767
+ '\u1ED9': 'o',
2768
+ '\u01EB': 'o',
2769
+ '\u01ED': 'o',
2770
+ '\u00F8': 'o',
2771
+ '\u01FF': 'o',
2772
+ '\u0254': 'o',
2773
+ '\uA74B': 'o',
2774
+ '\uA74D': 'o',
2775
+ '\u0275': 'o',
2776
+ '\u01A3': 'oi',
2777
+ '\u0223': 'ou',
2778
+ '\uA74F': 'oo',
2779
+ '\u24DF': 'p',
2780
+ '\uFF50': 'p',
2781
+ '\u1E55': 'p',
2782
+ '\u1E57': 'p',
2783
+ '\u01A5': 'p',
2784
+ '\u1D7D': 'p',
2785
+ '\uA751': 'p',
2786
+ '\uA753': 'p',
2787
+ '\uA755': 'p',
2788
+ '\u24E0': 'q',
2789
+ '\uFF51': 'q',
2790
+ '\u024B': 'q',
2791
+ '\uA757': 'q',
2792
+ '\uA759': 'q',
2793
+ '\u24E1': 'r',
2794
+ '\uFF52': 'r',
2795
+ '\u0155': 'r',
2796
+ '\u1E59': 'r',
2797
+ '\u0159': 'r',
2798
+ '\u0211': 'r',
2799
+ '\u0213': 'r',
2800
+ '\u1E5B': 'r',
2801
+ '\u1E5D': 'r',
2802
+ '\u0157': 'r',
2803
+ '\u1E5F': 'r',
2804
+ '\u024D': 'r',
2805
+ '\u027D': 'r',
2806
+ '\uA75B': 'r',
2807
+ '\uA7A7': 'r',
2808
+ '\uA783': 'r',
2809
+ '\u24E2': 's',
2810
+ '\uFF53': 's',
2811
+ '\u00DF': 's',
2812
+ '\u015B': 's',
2813
+ '\u1E65': 's',
2814
+ '\u015D': 's',
2815
+ '\u1E61': 's',
2816
+ '\u0161': 's',
2817
+ '\u1E67': 's',
2818
+ '\u1E63': 's',
2819
+ '\u1E69': 's',
2820
+ '\u0219': 's',
2821
+ '\u015F': 's',
2822
+ '\u023F': 's',
2823
+ '\uA7A9': 's',
2824
+ '\uA785': 's',
2825
+ '\u1E9B': 's',
2826
+ '\u24E3': 't',
2827
+ '\uFF54': 't',
2828
+ '\u1E6B': 't',
2829
+ '\u1E97': 't',
2830
+ '\u0165': 't',
2831
+ '\u1E6D': 't',
2832
+ '\u021B': 't',
2833
+ '\u0163': 't',
2834
+ '\u1E71': 't',
2835
+ '\u1E6F': 't',
2836
+ '\u0167': 't',
2837
+ '\u01AD': 't',
2838
+ '\u0288': 't',
2839
+ '\u2C66': 't',
2840
+ '\uA787': 't',
2841
+ '\uA729': 'tz',
2842
+ '\u24E4': 'u',
2843
+ '\uFF55': 'u',
2844
+ '\u00F9': 'u',
2845
+ '\u00FA': 'u',
2846
+ '\u00FB': 'u',
2847
+ '\u0169': 'u',
2848
+ '\u1E79': 'u',
2849
+ '\u016B': 'u',
2850
+ '\u1E7B': 'u',
2851
+ '\u016D': 'u',
2852
+ '\u00FC': 'u',
2853
+ '\u01DC': 'u',
2854
+ '\u01D8': 'u',
2855
+ '\u01D6': 'u',
2856
+ '\u01DA': 'u',
2857
+ '\u1EE7': 'u',
2858
+ '\u016F': 'u',
2859
+ '\u0171': 'u',
2860
+ '\u01D4': 'u',
2861
+ '\u0215': 'u',
2862
+ '\u0217': 'u',
2863
+ '\u01B0': 'u',
2864
+ '\u1EEB': 'u',
2865
+ '\u1EE9': 'u',
2866
+ '\u1EEF': 'u',
2867
+ '\u1EED': 'u',
2868
+ '\u1EF1': 'u',
2869
+ '\u1EE5': 'u',
2870
+ '\u1E73': 'u',
2871
+ '\u0173': 'u',
2872
+ '\u1E77': 'u',
2873
+ '\u1E75': 'u',
2874
+ '\u0289': 'u',
2875
+ '\u24E5': 'v',
2876
+ '\uFF56': 'v',
2877
+ '\u1E7D': 'v',
2878
+ '\u1E7F': 'v',
2879
+ '\u028B': 'v',
2880
+ '\uA75F': 'v',
2881
+ '\u028C': 'v',
2882
+ '\uA761': 'vy',
2883
+ '\u24E6': 'w',
2884
+ '\uFF57': 'w',
2885
+ '\u1E81': 'w',
2886
+ '\u1E83': 'w',
2887
+ '\u0175': 'w',
2888
+ '\u1E87': 'w',
2889
+ '\u1E85': 'w',
2890
+ '\u1E98': 'w',
2891
+ '\u1E89': 'w',
2892
+ '\u2C73': 'w',
2893
+ '\u24E7': 'x',
2894
+ '\uFF58': 'x',
2895
+ '\u1E8B': 'x',
2896
+ '\u1E8D': 'x',
2897
+ '\u24E8': 'y',
2898
+ '\uFF59': 'y',
2899
+ '\u1EF3': 'y',
2900
+ '\u00FD': 'y',
2901
+ '\u0177': 'y',
2902
+ '\u1EF9': 'y',
2903
+ '\u0233': 'y',
2904
+ '\u1E8F': 'y',
2905
+ '\u00FF': 'y',
2906
+ '\u1EF7': 'y',
2907
+ '\u1E99': 'y',
2908
+ '\u1EF5': 'y',
2909
+ '\u01B4': 'y',
2910
+ '\u024F': 'y',
2911
+ '\u1EFF': 'y',
2912
+ '\u24E9': 'z',
2913
+ '\uFF5A': 'z',
2914
+ '\u017A': 'z',
2915
+ '\u1E91': 'z',
2916
+ '\u017C': 'z',
2917
+ '\u017E': 'z',
2918
+ '\u1E93': 'z',
2919
+ '\u1E95': 'z',
2920
+ '\u01B6': 'z',
2921
+ '\u0225': 'z',
2922
+ '\u0240': 'z',
2923
+ '\u2C6C': 'z',
2924
+ '\uA763': 'z',
2925
+ '\u0386': '\u0391',
2926
+ '\u0388': '\u0395',
2927
+ '\u0389': '\u0397',
2928
+ '\u038A': '\u0399',
2929
+ '\u03AA': '\u0399',
2930
+ '\u038C': '\u039F',
2931
+ '\u038E': '\u03A5',
2932
+ '\u03AB': '\u03A5',
2933
+ '\u038F': '\u03A9',
2934
+ '\u03AC': '\u03B1',
2935
+ '\u03AD': '\u03B5',
2936
+ '\u03AE': '\u03B7',
2937
+ '\u03AF': '\u03B9',
2938
+ '\u03CA': '\u03B9',
2939
+ '\u0390': '\u03B9',
2940
+ '\u03CC': '\u03BF',
2941
+ '\u03CD': '\u03C5',
2942
+ '\u03CB': '\u03C5',
2943
+ '\u03B0': '\u03C5',
2944
+ '\u03C9': '\u03C9',
2945
+ '\u03C2': '\u03C3'
2946
+ };
2947
+
2948
+ return diacritics;
2949
+ });
2950
+
2951
+ S2.define('pumselect2/data/base',[
2952
+ '../utils'
2953
+ ], function (Utils) {
2954
+ function BaseAdapter ($element, options) {
2955
+ BaseAdapter.__super__.constructor.call(this);
2956
+ }
2957
+
2958
+ Utils.Extend(BaseAdapter, Utils.Observable);
2959
+
2960
+ BaseAdapter.prototype.current = function (callback) {
2961
+ throw new Error('The `current` method must be defined in child classes.');
2962
+ };
2963
+
2964
+ BaseAdapter.prototype.query = function (params, callback) {
2965
+ throw new Error('The `query` method must be defined in child classes.');
2966
+ };
2967
+
2968
+ BaseAdapter.prototype.bind = function (container, $container) {
2969
+ // Can be implemented in subclasses
2970
+ };
2971
+
2972
+ BaseAdapter.prototype.destroy = function () {
2973
+ // Can be implemented in subclasses
2974
+ };
2975
+
2976
+ BaseAdapter.prototype.generateResultId = function (container, data) {
2977
+ var id = container.id + '-result-';
2978
+
2979
+ id += Utils.generateChars(4);
2980
+
2981
+ if (data.id != null) {
2982
+ id += '-' + data.id.toString();
2983
+ } else {
2984
+ id += '-' + Utils.generateChars(4);
2985
+ }
2986
+ return id;
2987
+ };
2988
+
2989
+ return BaseAdapter;
2990
+ });
2991
+
2992
+ S2.define('pumselect2/data/select',[
2993
+ './base',
2994
+ '../utils',
2995
+ 'jquery'
2996
+ ], function (BaseAdapter, Utils, $) {
2997
+ function SelectAdapter ($element, options) {
2998
+ this.$element = $element;
2999
+ this.options = options;
3000
+
3001
+ SelectAdapter.__super__.constructor.call(this);
3002
+ }
3003
+
3004
+ Utils.Extend(SelectAdapter, BaseAdapter);
3005
+
3006
+ SelectAdapter.prototype.current = function (callback) {
3007
+ var data = [];
3008
+ var self = this;
3009
+
3010
+ this.$element.find(':selected').each(function () {
3011
+ var $option = $(this);
3012
+
3013
+ var option = self.item($option);
3014
+
3015
+ data.push(option);
3016
+ });
3017
+
3018
+ callback(data);
3019
+ };
3020
+
3021
+ SelectAdapter.prototype.select = function (data) {
3022
+ var self = this;
3023
+
3024
+ data.selected = true;
3025
+
3026
+ // If data.element is a DOM node, use it instead
3027
+ if ($(data.element).is('option')) {
3028
+ data.element.selected = true;
3029
+
3030
+ this.$element.trigger('change');
3031
+
3032
+ return;
3033
+ }
3034
+
3035
+ if (this.$element.prop('multiple')) {
3036
+ this.current(function (currentData) {
3037
+ var val = [];
3038
+
3039
+ data = [data];
3040
+ data.push.apply(data, currentData);
3041
+
3042
+ for (var d = 0; d < data.length; d++) {
3043
+ var id = data[d].id;
3044
+
3045
+ if ($.inArray(id, val) === -1) {
3046
+ val.push(id);
3047
+ }
3048
+ }
3049
+
3050
+ self.$element.val(val);
3051
+ self.$element.trigger('change');
3052
+ });
3053
+ } else {
3054
+ var val = data.id;
3055
+
3056
+ this.$element.val(val);
3057
+ this.$element.trigger('change');
3058
+ }
3059
+ };
3060
+
3061
+ SelectAdapter.prototype.unselect = function (data) {
3062
+ var self = this;
3063
+
3064
+ if (!this.$element.prop('multiple')) {
3065
+ return;
3066
+ }
3067
+
3068
+ data.selected = false;
3069
+
3070
+ if ($(data.element).is('option')) {
3071
+ data.element.selected = false;
3072
+
3073
+ this.$element.trigger('change');
3074
+
3075
+ return;
3076
+ }
3077
+
3078
+ this.current(function (currentData) {
3079
+ var val = [];
3080
+
3081
+ for (var d = 0; d < currentData.length; d++) {
3082
+ var id = currentData[d].id;
3083
+
3084
+ if (id !== data.id && $.inArray(id, val) === -1) {
3085
+ val.push(id);
3086
+ }
3087
+ }
3088
+
3089
+ self.$element.val(val);
3090
+
3091
+ self.$element.trigger('change');
3092
+ });
3093
+ };
3094
+
3095
+ SelectAdapter.prototype.bind = function (container, $container) {
3096
+ var self = this;
3097
+
3098
+ this.container = container;
3099
+
3100
+ container.on('select', function (params) {
3101
+ self.select(params.data);
3102
+ });
3103
+
3104
+ container.on('unselect', function (params) {
3105
+ self.unselect(params.data);
3106
+ });
3107
+ };
3108
+
3109
+ SelectAdapter.prototype.destroy = function () {
3110
+ // Remove anything added to child elements
3111
+ this.$element.find('*').each(function () {
3112
+ // Remove any custom data set by Select2
3113
+ $.removeData(this, 'data');
3114
+ });
3115
+ };
3116
+
3117
+ SelectAdapter.prototype.query = function (params, callback) {
3118
+ var data = [];
3119
+ var self = this;
3120
+
3121
+ var $options = this.$element.children();
3122
+
3123
+ $options.each(function () {
3124
+ var $option = $(this);
3125
+
3126
+ if (!$option.is('option') && !$option.is('optgroup')) {
3127
+ return;
3128
+ }
3129
+
3130
+ var option = self.item($option);
3131
+
3132
+ var matches = self.matches(params, option);
3133
+
3134
+ if (matches !== null) {
3135
+ data.push(matches);
3136
+ }
3137
+ });
3138
+
3139
+ callback({
3140
+ results: data
3141
+ });
3142
+ };
3143
+
3144
+ SelectAdapter.prototype.addOptions = function ($options) {
3145
+ Utils.appendMany(this.$element, $options);
3146
+ };
3147
+
3148
+ SelectAdapter.prototype.option = function (data) {
3149
+ var option;
3150
+
3151
+ if (data.children) {
3152
+ option = document.createElement('optgroup');
3153
+ option.label = data.text;
3154
+ } else {
3155
+ option = document.createElement('option');
3156
+
3157
+ if (option.textContent !== undefined) {
3158
+ option.textContent = data.text;
3159
+ } else {
3160
+ option.innerText = data.text;
3161
+ }
3162
+ }
3163
+
3164
+ if (data.id) {
3165
+ option.value = data.id;
3166
+ }
3167
+
3168
+ if (data.disabled) {
3169
+ option.disabled = true;
3170
+ }
3171
+
3172
+ if (data.selected) {
3173
+ option.selected = true;
3174
+ }
3175
+
3176
+ if (data.title) {
3177
+ option.title = data.title;
3178
+ }
3179
+
3180
+ var $option = $(option);
3181
+
3182
+ var normalizedData = this._normalizeItem(data);
3183
+ normalizedData.element = option;
3184
+
3185
+ // Override the option's data with the combined data
3186
+ $.data(option, 'data', normalizedData);
3187
+
3188
+ return $option;
3189
+ };
3190
+
3191
+ SelectAdapter.prototype.item = function ($option) {
3192
+ var data = {};
3193
+
3194
+ data = $.data($option[0], 'data');
3195
+
3196
+ if (data != null) {
3197
+ return data;
3198
+ }
3199
+
3200
+ if ($option.is('option')) {
3201
+ data = {
3202
+ id: $option.val(),
3203
+ text: $option.text(),
3204
+ disabled: $option.prop('disabled'),
3205
+ selected: $option.prop('selected'),
3206
+ title: $option.prop('title')
3207
+ };
3208
+ } else if ($option.is('optgroup')) {
3209
+ data = {
3210
+ text: $option.prop('label'),
3211
+ children: [],
3212
+ title: $option.prop('title')
3213
+ };
3214
+
3215
+ var $children = $option.children('option');
3216
+ var children = [];
3217
+
3218
+ for (var c = 0; c < $children.length; c++) {
3219
+ var $child = $($children[c]);
3220
+
3221
+ var child = this.item($child);
3222
+
3223
+ children.push(child);
3224
+ }
3225
+
3226
+ data.children = children;
3227
+ }
3228
+
3229
+ data = this._normalizeItem(data);
3230
+ data.element = $option[0];
3231
+
3232
+ $.data($option[0], 'data', data);
3233
+
3234
+ return data;
3235
+ };
3236
+
3237
+ SelectAdapter.prototype._normalizeItem = function (item) {
3238
+ if (!$.isPlainObject(item)) {
3239
+ item = {
3240
+ id: item,
3241
+ text: item
3242
+ };
3243
+ }
3244
+
3245
+ item = $.extend({}, {
3246
+ text: ''
3247
+ }, item);
3248
+
3249
+ var defaults = {
3250
+ selected: false,
3251
+ disabled: false
3252
+ };
3253
+
3254
+ if (item.id != null) {
3255
+ item.id = item.id.toString();
3256
+ }
3257
+
3258
+ if (item.text != null) {
3259
+ item.text = item.text.toString();
3260
+ }
3261
+
3262
+ if (item._resultId == null && item.id && this.container != null) {
3263
+ item._resultId = this.generateResultId(this.container, item);
3264
+ }
3265
+
3266
+ return $.extend({}, defaults, item);
3267
+ };
3268
+
3269
+ SelectAdapter.prototype.matches = function (params, data) {
3270
+ var matcher = this.options.get('matcher');
3271
+
3272
+ return matcher(params, data);
3273
+ };
3274
+
3275
+ return SelectAdapter;
3276
+ });
3277
+
3278
+ S2.define('pumselect2/data/array',[
3279
+ './select',
3280
+ '../utils',
3281
+ 'jquery'
3282
+ ], function (SelectAdapter, Utils, $) {
3283
+ function ArrayAdapter ($element, options) {
3284
+ var data = options.get('data') || [];
3285
+
3286
+ ArrayAdapter.__super__.constructor.call(this, $element, options);
3287
+
3288
+ this.addOptions(this.convertToOptions(data));
3289
+ }
3290
+
3291
+ Utils.Extend(ArrayAdapter, SelectAdapter);
3292
+
3293
+ ArrayAdapter.prototype.select = function (data) {
3294
+ var $option = this.$element.find('option').filter(function (i, elm) {
3295
+ return elm.value == data.id.toString();
3296
+ });
3297
+
3298
+ if ($option.length === 0) {
3299
+ $option = this.option(data);
3300
+
3301
+ this.addOptions($option);
3302
+ }
3303
+
3304
+ ArrayAdapter.__super__.select.call(this, data);
3305
+ };
3306
+
3307
+ ArrayAdapter.prototype.convertToOptions = function (data) {
3308
+ var self = this;
3309
+
3310
+ var $existing = this.$element.find('option');
3311
+ var existingIds = $existing.map(function () {
3312
+ return self.item($(this)).id;
3313
+ }).get();
3314
+
3315
+ var $options = [];
3316
+
3317
+ // Filter out all items except for the one passed in the argument
3318
+ function onlyItem (item) {
3319
+ return function () {
3320
+ return $(this).val() == item.id;
3321
+ };
3322
+ }
3323
+
3324
+ for (var d = 0; d < data.length; d++) {
3325
+ var item = this._normalizeItem(data[d]);
3326
+
3327
+ // Skip items which were pre-loaded, only merge the data
3328
+ if ($.inArray(item.id, existingIds) >= 0) {
3329
+ var $existingOption = $existing.filter(onlyItem(item));
3330
+
3331
+ var existingData = this.item($existingOption);
3332
+ var newData = $.extend(true, {}, item, existingData);
3333
+
3334
+ var $newOption = this.option(newData);
3335
+
3336
+ $existingOption.replaceWith($newOption);
3337
+
3338
+ continue;
3339
+ }
3340
+
3341
+ var $option = this.option(item);
3342
+
3343
+ if (item.children) {
3344
+ var $children = this.convertToOptions(item.children);
3345
+
3346
+ Utils.appendMany($option, $children);
3347
+ }
3348
+
3349
+ $options.push($option);
3350
+ }
3351
+
3352
+ return $options;
3353
+ };
3354
+
3355
+ return ArrayAdapter;
3356
+ });
3357
+
3358
+ S2.define('pumselect2/data/ajax',[
3359
+ './array',
3360
+ '../utils',
3361
+ 'jquery'
3362
+ ], function (ArrayAdapter, Utils, $) {
3363
+ function AjaxAdapter ($element, options) {
3364
+ this.ajaxOptions = this._applyDefaults(options.get('ajax'));
3365
+
3366
+ if (this.ajaxOptions.processResults != null) {
3367
+ this.processResults = this.ajaxOptions.processResults;
3368
+ }
3369
+
3370
+ AjaxAdapter.__super__.constructor.call(this, $element, options);
3371
+ }
3372
+
3373
+ Utils.Extend(AjaxAdapter, ArrayAdapter);
3374
+
3375
+ AjaxAdapter.prototype._applyDefaults = function (options) {
3376
+ var defaults = {
3377
+ data: function (params) {
3378
+ return $.extend({}, params, {
3379
+ q: params.term
3380
+ });
3381
+ },
3382
+ transport: function (params, success, failure) {
3383
+ var $request = $.ajax(params);
3384
+
3385
+ $request.then(success);
3386
+ $request.fail(failure);
3387
+
3388
+ return $request;
3389
+ }
3390
+ };
3391
+
3392
+ return $.extend({}, defaults, options, true);
3393
+ };
3394
+
3395
+ AjaxAdapter.prototype.processResults = function (results) {
3396
+ return results;
3397
+ };
3398
+
3399
+ AjaxAdapter.prototype.query = function (params, callback) {
3400
+ var matches = [];
3401
+ var self = this;
3402
+
3403
+ if (this._request != null) {
3404
+ // JSONP requests cannot always be aborted
3405
+ if ($.isFunction(this._request.abort)) {
3406
+ this._request.abort();
3407
+ }
3408
+
3409
+ this._request = null;
3410
+ }
3411
+
3412
+ var options = $.extend({
3413
+ type: 'GET'
3414
+ }, this.ajaxOptions);
3415
+
3416
+ if (typeof options.url === 'function') {
3417
+ options.url = options.url.call(this.$element, params);
3418
+ }
3419
+
3420
+ if (typeof options.data === 'function') {
3421
+ options.data = options.data.call(this.$element, params);
3422
+ }
3423
+
3424
+ function request () {
3425
+ var $request = options.transport(options, function (data) {
3426
+ var results = self.processResults(data, params);
3427
+
3428
+ if (self.options.get('debug') && window.console && console.error) {
3429
+ // Check to make sure that the response included a `results` key.
3430
+ if (!results || !results.results || !$.isArray(results.results)) {
3431
+ console.error(
3432
+ 'Select2: The AJAX results did not return an array in the ' +
3433
+ '`results` key of the response.'
3434
+ );
3435
+ }
3436
+ }
3437
+
3438
+ callback(results);
3439
+ }, function () {
3440
+ self.trigger('results:message', {
3441
+ message: 'errorLoading'
3442
+ });
3443
+ });
3444
+
3445
+ self._request = $request;
3446
+ }
3447
+
3448
+ if (this.ajaxOptions.delay && params.term !== '') {
3449
+ if (this._queryTimeout) {
3450
+ window.clearTimeout(this._queryTimeout);
3451
+ }
3452
+
3453
+ this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
3454
+ } else {
3455
+ request();
3456
+ }
3457
+ };
3458
+
3459
+ return AjaxAdapter;
3460
+ });
3461
+
3462
+ S2.define('pumselect2/data/tags',[
3463
+ 'jquery'
3464
+ ], function ($) {
3465
+ function Tags (decorated, $element, options) {
3466
+ var tags = options.get('tags');
3467
+
3468
+ var createTag = options.get('createTag');
3469
+
3470
+ if (createTag !== undefined) {
3471
+ this.createTag = createTag;
3472
+ }
3473
+
3474
+ var insertTag = options.get('insertTag');
3475
+
3476
+ if (insertTag !== undefined) {
3477
+ this.insertTag = insertTag;
3478
+ }
3479
+
3480
+ decorated.call(this, $element, options);
3481
+
3482
+ if ($.isArray(tags)) {
3483
+ for (var t = 0; t < tags.length; t++) {
3484
+ var tag = tags[t];
3485
+ var item = this._normalizeItem(tag);
3486
+
3487
+ var $option = this.option(item);
3488
+
3489
+ this.$element.append($option);
3490
+ }
3491
+ }
3492
+ }
3493
+
3494
+ Tags.prototype.query = function (decorated, params, callback) {
3495
+ var self = this;
3496
+
3497
+ this._removeOldTags();
3498
+
3499
+ if (params.term == null || params.page != null) {
3500
+ decorated.call(this, params, callback);
3501
+ return;
3502
+ }
3503
+
3504
+ function wrapper (obj, child) {
3505
+ var data = obj.results;
3506
+
3507
+ for (var i = 0; i < data.length; i++) {
3508
+ var option = data[i];
3509
+
3510
+ var checkChildren = (
3511
+ option.children != null &&
3512
+ !wrapper({
3513
+ results: option.children
3514
+ }, true)
3515
+ );
3516
+
3517
+ var checkText = option.text === params.term;
3518
+
3519
+ if (checkText || checkChildren) {
3520
+ if (child) {
3521
+ return false;
3522
+ }
3523
+
3524
+ obj.data = data;
3525
+ callback(obj);
3526
+
3527
+ return;
3528
+ }
3529
+ }
3530
+
3531
+ if (child) {
3532
+ return true;
3533
+ }
3534
+
3535
+ var tag = self.createTag(params);
3536
+
3537
+ if (tag != null) {
3538
+ var $option = self.option(tag);
3539
+ $option.attr('data-pumselect2-tag', true);
3540
+
3541
+ self.addOptions([$option]);
3542
+
3543
+ self.insertTag(data, tag);
3544
+ }
3545
+
3546
+ obj.results = data;
3547
+
3548
+ callback(obj);
3549
+ }
3550
+
3551
+ decorated.call(this, params, wrapper);
3552
+ };
3553
+
3554
+ Tags.prototype.createTag = function (decorated, params) {
3555
+ var term = $.trim(params.term);
3556
+
3557
+ if (term === '') {
3558
+ return null;
3559
+ }
3560
+
3561
+ return {
3562
+ id: term,
3563
+ text: term
3564
+ };
3565
+ };
3566
+
3567
+ Tags.prototype.insertTag = function (_, data, tag) {
3568
+ data.unshift(tag);
3569
+ };
3570
+
3571
+ Tags.prototype._removeOldTags = function (_) {
3572
+ var tag = this._lastTag;
3573
+
3574
+ var $options = this.$element.find('option[data-pumselect2-tag]');
3575
+
3576
+ $options.each(function () {
3577
+ if (this.selected) {
3578
+ return;
3579
+ }
3580
+
3581
+ $(this).remove();
3582
+ });
3583
+ };
3584
+
3585
+ return Tags;
3586
+ });
3587
+
3588
+ S2.define('pumselect2/data/tokenizer',[
3589
+ 'jquery'
3590
+ ], function ($) {
3591
+ function Tokenizer (decorated, $element, options) {
3592
+ var tokenizer = options.get('tokenizer');
3593
+
3594
+ if (tokenizer !== undefined) {
3595
+ this.tokenizer = tokenizer;
3596
+ }
3597
+
3598
+ decorated.call(this, $element, options);
3599
+ }
3600
+
3601
+ Tokenizer.prototype.bind = function (decorated, container, $container) {
3602
+ decorated.call(this, container, $container);
3603
+
3604
+ this.$search = container.dropdown.$search || container.selection.$search ||
3605
+ $container.find('.pumselect2-search__field');
3606
+ };
3607
+
3608
+ Tokenizer.prototype.query = function (decorated, params, callback) {
3609
+ var self = this;
3610
+
3611
+ function select (data) {
3612
+ self.trigger('select', {
3613
+ data: data
3614
+ });
3615
+ }
3616
+
3617
+ params.term = params.term || '';
3618
+
3619
+ var tokenData = this.tokenizer(params, this.options, select);
3620
+
3621
+ if (tokenData.term !== params.term) {
3622
+ // Replace the search term if we have the search box
3623
+ if (this.$search.length) {
3624
+ this.$search.val(tokenData.term);
3625
+ this.$search.focus();
3626
+ }
3627
+
3628
+ params.term = tokenData.term;
3629
+ }
3630
+
3631
+ decorated.call(this, params, callback);
3632
+ };
3633
+
3634
+ Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
3635
+ var separators = options.get('tokenSeparators') || [];
3636
+ var term = params.term;
3637
+ var i = 0;
3638
+
3639
+ var createTag = this.createTag || function (params) {
3640
+ return {
3641
+ id: params.term,
3642
+ text: params.term
3643
+ };
3644
+ };
3645
+
3646
+ while (i < term.length) {
3647
+ var termChar = term[i];
3648
+
3649
+ if ($.inArray(termChar, separators) === -1) {
3650
+ i++;
3651
+
3652
+ continue;
3653
+ }
3654
+
3655
+ var part = term.substr(0, i);
3656
+ var partParams = $.extend({}, params, {
3657
+ term: part
3658
+ });
3659
+
3660
+ var data = createTag(partParams);
3661
+
3662
+ if (data == null) {
3663
+ i++;
3664
+ continue;
3665
+ }
3666
+
3667
+ callback(data);
3668
+
3669
+ // Reset the term to not include the tokenized portion
3670
+ term = term.substr(i + 1) || '';
3671
+ i = 0;
3672
+ }
3673
+
3674
+ return {
3675
+ term: term
3676
+ };
3677
+ };
3678
+
3679
+ return Tokenizer;
3680
+ });
3681
+
3682
+ S2.define('pumselect2/data/minimumInputLength',[
3683
+
3684
+ ], function () {
3685
+ function MinimumInputLength (decorated, $e, options) {
3686
+ this.minimumInputLength = options.get('minimumInputLength');
3687
+
3688
+ decorated.call(this, $e, options);
3689
+ }
3690
+
3691
+ MinimumInputLength.prototype.query = function (decorated, params, callback) {
3692
+ params.term = params.term || '';
3693
+
3694
+ if (params.term.length < this.minimumInputLength) {
3695
+ this.trigger('results:message', {
3696
+ message: 'inputTooShort',
3697
+ args: {
3698
+ minimum: this.minimumInputLength,
3699
+ input: params.term,
3700
+ params: params
3701
+ }
3702
+ });
3703
+
3704
+ return;
3705
+ }
3706
+
3707
+ decorated.call(this, params, callback);
3708
+ };
3709
+
3710
+ return MinimumInputLength;
3711
+ });
3712
+
3713
+ S2.define('pumselect2/data/maximumInputLength',[
3714
+
3715
+ ], function () {
3716
+ function MaximumInputLength (decorated, $e, options) {
3717
+ this.maximumInputLength = options.get('maximumInputLength');
3718
+
3719
+ decorated.call(this, $e, options);
3720
+ }
3721
+
3722
+ MaximumInputLength.prototype.query = function (decorated, params, callback) {
3723
+ params.term = params.term || '';
3724
+
3725
+ if (this.maximumInputLength > 0 &&
3726
+ params.term.length > this.maximumInputLength) {
3727
+ this.trigger('results:message', {
3728
+ message: 'inputTooLong',
3729
+ args: {
3730
+ maximum: this.maximumInputLength,
3731
+ input: params.term,
3732
+ params: params
3733
+ }
3734
+ });
3735
+
3736
+ return;
3737
+ }
3738
+
3739
+ decorated.call(this, params, callback);
3740
+ };
3741
+
3742
+ return MaximumInputLength;
3743
+ });
3744
+
3745
+ S2.define('pumselect2/data/maximumSelectionLength',[
3746
+
3747
+ ], function (){
3748
+ function MaximumSelectionLength (decorated, $e, options) {
3749
+ this.maximumSelectionLength = options.get('maximumSelectionLength');
3750
+
3751
+ decorated.call(this, $e, options);
3752
+ }
3753
+
3754
+ MaximumSelectionLength.prototype.query =
3755
+ function (decorated, params, callback) {
3756
+ var self = this;
3757
+
3758
+ this.current(function (currentData) {
3759
+ var count = currentData != null ? currentData.length : 0;
3760
+ if (self.maximumSelectionLength > 0 &&
3761
+ count >= self.maximumSelectionLength) {
3762
+ self.trigger('results:message', {
3763
+ message: 'maximumSelected',
3764
+ args: {
3765
+ maximum: self.maximumSelectionLength
3766
+ }
3767
+ });
3768
+ return;
3769
+ }
3770
+ decorated.call(self, params, callback);
3771
+ });
3772
+ };
3773
+
3774
+ return MaximumSelectionLength;
3775
+ });
3776
+
3777
+ S2.define('pumselect2/dropdown',[
3778
+ 'jquery',
3779
+ './utils'
3780
+ ], function ($, Utils) {
3781
+ function Dropdown ($element, options) {
3782
+ this.$element = $element;
3783
+ this.options = options;
3784
+
3785
+ Dropdown.__super__.constructor.call(this);
3786
+ }
3787
+
3788
+ Utils.Extend(Dropdown, Utils.Observable);
3789
+
3790
+ Dropdown.prototype.render = function () {
3791
+ var $dropdown = $(
3792
+ '<span class="pumselect2-dropdown">' +
3793
+ '<span class="pumselect2-results"></span>' +
3794
+ '</span>'
3795
+ );
3796
+
3797
+ $dropdown.attr('dir', this.options.get('dir'));
3798
+
3799
+ this.$dropdown = $dropdown;
3800
+
3801
+ return $dropdown;
3802
+ };
3803
+
3804
+ Dropdown.prototype.bind = function () {
3805
+ // Should be implemented in subclasses
3806
+ };
3807
+
3808
+ Dropdown.prototype.position = function ($dropdown, $container) {
3809
+ // Should be implmented in subclasses
3810
+ };
3811
+
3812
+ Dropdown.prototype.destroy = function () {
3813
+ // Remove the dropdown from the DOM
3814
+ this.$dropdown.remove();
3815
+ };
3816
+
3817
+ return Dropdown;
3818
+ });
3819
+
3820
+ S2.define('pumselect2/dropdown/search',[
3821
+ 'jquery',
3822
+ '../utils'
3823
+ ], function ($, Utils) {
3824
+ function Search () { }
3825
+
3826
+ Search.prototype.render = function (decorated) {
3827
+ var $rendered = decorated.call(this);
3828
+
3829
+ var $search = $(
3830
+ '<span class="pumselect2-search pumselect2-search--dropdown">' +
3831
+ '<input class="pumselect2-search__field" type="search" tabindex="-1"' +
3832
+ ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
3833
+ ' spellcheck="false" role="textbox" />' +
3834
+ '</span>'
3835
+ );
3836
+
3837
+ this.$searchContainer = $search;
3838
+ this.$search = $search.find('input');
3839
+
3840
+ $rendered.prepend($search);
3841
+
3842
+ return $rendered;
3843
+ };
3844
+
3845
+ Search.prototype.bind = function (decorated, container, $container) {
3846
+ var self = this;
3847
+
3848
+ decorated.call(this, container, $container);
3849
+
3850
+ this.$search.on('keydown', function (evt) {
3851
+ self.trigger('keypress', evt);
3852
+
3853
+ self._keyUpPrevented = evt.isDefaultPrevented();
3854
+ });
3855
+
3856
+ // Workaround for browsers which do not support the `input` event
3857
+ // This will prevent double-triggering of events for browsers which support
3858
+ // both the `keyup` and `input` events.
3859
+ this.$search.on('input', function (evt) {
3860
+ // Unbind the duplicated `keyup` event
3861
+ $(this).off('keyup');
3862
+ });
3863
+
3864
+ this.$search.on('keyup input', function (evt) {
3865
+ self.handleSearch(evt);
3866
+ });
3867
+
3868
+ container.on('open', function () {
3869
+ self.$search.attr('tabindex', 0);
3870
+
3871
+ self.$search.focus();
3872
+
3873
+ window.setTimeout(function () {
3874
+ self.$search.focus();
3875
+ }, 0);
3876
+ });
3877
+
3878
+ container.on('close', function () {
3879
+ self.$search.attr('tabindex', -1);
3880
+
3881
+ self.$search.val('');
3882
+ });
3883
+
3884
+ container.on('results:all', function (params) {
3885
+ if (params.query.term == null || params.query.term === '') {
3886
+ var showSearch = self.showSearch(params);
3887
+
3888
+ if (showSearch) {
3889
+ self.$searchContainer.removeClass('pumselect2-search--hide');
3890
+ } else {
3891
+ self.$searchContainer.addClass('pumselect2-search--hide');
3892
+ }
3893
+ }
3894
+ });
3895
+ };
3896
+
3897
+ Search.prototype.handleSearch = function (evt) {
3898
+ if (!this._keyUpPrevented) {
3899
+ var input = this.$search.val();
3900
+
3901
+ this.trigger('query', {
3902
+ term: input
3903
+ });
3904
+ }
3905
+
3906
+ this._keyUpPrevented = false;
3907
+ };
3908
+
3909
+ Search.prototype.showSearch = function (_, params) {
3910
+ return true;
3911
+ };
3912
+
3913
+ return Search;
3914
+ });
3915
+
3916
+ S2.define('pumselect2/dropdown/hidePlaceholder',[
3917
+
3918
+ ], function () {
3919
+ function HidePlaceholder (decorated, $element, options, dataAdapter) {
3920
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
3921
+
3922
+ decorated.call(this, $element, options, dataAdapter);
3923
+ }
3924
+
3925
+ HidePlaceholder.prototype.append = function (decorated, data) {
3926
+ data.results = this.removePlaceholder(data.results);
3927
+
3928
+ decorated.call(this, data);
3929
+ };
3930
+
3931
+ HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
3932
+ if (typeof placeholder === 'string') {
3933
+ placeholder = {
3934
+ id: '',
3935
+ text: placeholder
3936
+ };
3937
+ }
3938
+
3939
+ return placeholder;
3940
+ };
3941
+
3942
+ HidePlaceholder.prototype.removePlaceholder = function (_, data) {
3943
+ var modifiedData = data.slice(0);
3944
+
3945
+ for (var d = data.length - 1; d >= 0; d--) {
3946
+ var item = data[d];
3947
+
3948
+ if (this.placeholder.id === item.id) {
3949
+ modifiedData.splice(d, 1);
3950
+ }
3951
+ }
3952
+
3953
+ return modifiedData;
3954
+ };
3955
+
3956
+ return HidePlaceholder;
3957
+ });
3958
+
3959
+ S2.define('pumselect2/dropdown/infiniteScroll',[
3960
+ 'jquery'
3961
+ ], function ($) {
3962
+ function InfiniteScroll (decorated, $element, options, dataAdapter) {
3963
+ this.lastParams = {};
3964
+
3965
+ decorated.call(this, $element, options, dataAdapter);
3966
+
3967
+ this.$loadingMore = this.createLoadingMore();
3968
+ this.loading = false;
3969
+ }
3970
+
3971
+ InfiniteScroll.prototype.append = function (decorated, data) {
3972
+ this.$loadingMore.remove();
3973
+ this.loading = false;
3974
+
3975
+ decorated.call(this, data);
3976
+
3977
+ if (this.showLoadingMore(data)) {
3978
+ this.$results.append(this.$loadingMore);
3979
+ }
3980
+ };
3981
+
3982
+ InfiniteScroll.prototype.bind = function (decorated, container, $container) {
3983
+ var self = this;
3984
+
3985
+ decorated.call(this, container, $container);
3986
+
3987
+ container.on('query', function (params) {
3988
+ self.lastParams = params;
3989
+ self.loading = true;
3990
+ });
3991
+
3992
+ container.on('query:append', function (params) {
3993
+ self.lastParams = params;
3994
+ self.loading = true;
3995
+ });
3996
+
3997
+ this.$results.on('scroll', function () {
3998
+ var isLoadMoreVisible = $.contains(
3999
+ document.documentElement,
4000
+ self.$loadingMore[0]
4001
+ );
4002
+
4003
+ if (self.loading || !isLoadMoreVisible) {
4004
+ return;
4005
+ }
4006
+
4007
+ var currentOffset = self.$results.offset().top +
4008
+ self.$results.outerHeight(false);
4009
+ var loadingMoreOffset = self.$loadingMore.offset().top +
4010
+ self.$loadingMore.outerHeight(false);
4011
+
4012
+ if (currentOffset + 50 >= loadingMoreOffset) {
4013
+ self.loadMore();
4014
+ }
4015
+ });
4016
+ };
4017
+
4018
+ InfiniteScroll.prototype.loadMore = function () {
4019
+ this.loading = true;
4020
+
4021
+ var params = $.extend({}, {page: 1}, this.lastParams);
4022
+
4023
+ params.page++;
4024
+
4025
+ this.trigger('query:append', params);
4026
+ };
4027
+
4028
+ InfiniteScroll.prototype.showLoadingMore = function (_, data) {
4029
+ return data.pagination && data.pagination.more;
4030
+ };
4031
+
4032
+ InfiniteScroll.prototype.createLoadingMore = function () {
4033
+ var $option = $(
4034
+ '<li ' +
4035
+ 'class="pumselect2-results__option pumselect2-results__option--load-more"' +
4036
+ 'role="treeitem" aria-disabled="true"></li>'
4037
+ );
4038
+
4039
+ var message = this.options.get('translations').get('loadingMore');
4040
+
4041
+ $option.html(message(this.lastParams));
4042
+
4043
+ return $option;
4044
+ };
4045
+
4046
+ return InfiniteScroll;
4047
+ });
4048
+
4049
+ S2.define('pumselect2/dropdown/attachBody',[
4050
+ 'jquery',
4051
+ '../utils'
4052
+ ], function ($, Utils) {
4053
+ function AttachBody (decorated, $element, options) {
4054
+ this.$dropdownParent = options.get('dropdownParent') || $(document.body);
4055
+
4056
+ decorated.call(this, $element, options);
4057
+ }
4058
+
4059
+ AttachBody.prototype.bind = function (decorated, container, $container) {
4060
+ var self = this;
4061
+
4062
+ var setupResultsEvents = false;
4063
+
4064
+ decorated.call(this, container, $container);
4065
+
4066
+ container.on('open', function () {
4067
+ self._showDropdown();
4068
+ self._attachPositioningHandler(container);
4069
+
4070
+ if (!setupResultsEvents) {
4071
+ setupResultsEvents = true;
4072
+
4073
+ container.on('results:all', function () {
4074
+ self._positionDropdown();
4075
+ self._resizeDropdown();
4076
+ });
4077
+
4078
+ container.on('results:append', function () {
4079
+ self._positionDropdown();
4080
+ self._resizeDropdown();
4081
+ });
4082
+ }
4083
+ });
4084
+
4085
+ container.on('close', function () {
4086
+ self._hideDropdown();
4087
+ self._detachPositioningHandler(container);
4088
+ });
4089
+
4090
+ this.$dropdownContainer.on('mousedown', function (evt) {
4091
+ evt.stopPropagation();
4092
+ });
4093
+ };
4094
+
4095
+ AttachBody.prototype.destroy = function (decorated) {
4096
+ decorated.call(this);
4097
+
4098
+ this.$dropdownContainer.remove();
4099
+ };
4100
+
4101
+ AttachBody.prototype.position = function (decorated, $dropdown, $container) {
4102
+ // Clone all of the container classes
4103
+ $dropdown.attr('class', $container.attr('class'));
4104
+
4105
+ $dropdown.removeClass('pumselect2');
4106
+ $dropdown.addClass('pumselect2-container--open');
4107
+
4108
+ $dropdown.css({
4109
+ position: 'absolute',
4110
+ top: -999999
4111
+ });
4112
+
4113
+ this.$container = $container;
4114
+ };
4115
+
4116
+ AttachBody.prototype.render = function (decorated) {
4117
+ var $container = $('<span></span>');
4118
+
4119
+ var $dropdown = decorated.call(this);
4120
+ $container.append($dropdown);
4121
+
4122
+ this.$dropdownContainer = $container;
4123
+
4124
+ return $container;
4125
+ };
4126
+
4127
+ AttachBody.prototype._hideDropdown = function (decorated) {
4128
+ this.$dropdownContainer.detach();
4129
+ };
4130
+
4131
+ AttachBody.prototype._attachPositioningHandler =
4132
+ function (decorated, container) {
4133
+ var self = this;
4134
+
4135
+ var scrollEvent = 'scroll.pumselect2.' + container.id;
4136
+ var resizeEvent = 'resize.pumselect2.' + container.id;
4137
+ var orientationEvent = 'orientationchange.pumselect2.' + container.id;
4138
+
4139
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
4140
+ $watchers.each(function () {
4141
+ $(this).data('pumselect2-scroll-position', {
4142
+ x: $(this).scrollLeft(),
4143
+ y: $(this).scrollTop()
4144
+ });
4145
+ });
4146
+
4147
+ $watchers.on(scrollEvent, function (ev) {
4148
+ var position = $(this).data('pumselect2-scroll-position');
4149
+ $(this).scrollTop(position.y);
4150
+ });
4151
+
4152
+ $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
4153
+ function (e) {
4154
+ self._positionDropdown();
4155
+ self._resizeDropdown();
4156
+ });
4157
+ };
4158
+
4159
+ AttachBody.prototype._detachPositioningHandler =
4160
+ function (decorated, container) {
4161
+ var scrollEvent = 'scroll.pumselect2.' + container.id;
4162
+ var resizeEvent = 'resize.pumselect2.' + container.id;
4163
+ var orientationEvent = 'orientationchange.pumselect2.' + container.id;
4164
+
4165
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
4166
+ $watchers.off(scrollEvent);
4167
+
4168
+ $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
4169
+ };
4170
+
4171
+ AttachBody.prototype._positionDropdown = function () {
4172
+ var $window = $(window);
4173
+
4174
+ var isCurrentlyAbove = this.$dropdown.hasClass('pumselect2-dropdown--above');
4175
+ var isCurrentlyBelow = this.$dropdown.hasClass('pumselect2-dropdown--below');
4176
+
4177
+ var newDirection = null;
4178
+
4179
+ var offset = this.$container.offset();
4180
+
4181
+ offset.bottom = offset.top + this.$container.outerHeight(false);
4182
+
4183
+ var container = {
4184
+ height: this.$container.outerHeight(false)
4185
+ };
4186
+
4187
+ container.top = offset.top;
4188
+ container.bottom = offset.top + container.height;
4189
+
4190
+ var dropdown = {
4191
+ height: this.$dropdown.outerHeight(false)
4192
+ };
4193
+
4194
+ var viewport = {
4195
+ top: $window.scrollTop(),
4196
+ bottom: $window.scrollTop() + $window.height()
4197
+ };
4198
+
4199
+ var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
4200
+ var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
4201
+
4202
+ var css = {
4203
+ left: offset.left,
4204
+ top: container.bottom
4205
+ };
4206
+
4207
+ // Determine what the parent element is to use for calciulating the offset
4208
+ var $offsetParent = this.$dropdownParent;
4209
+
4210
+ // For statically positoned elements, we need to get the element
4211
+ // that is determining the offset
4212
+ if ($offsetParent.css('position') === 'static') {
4213
+ $offsetParent = $offsetParent.offsetParent();
4214
+ }
4215
+
4216
+ var parentOffset = $offsetParent.offset();
4217
+
4218
+ css.top -= parentOffset.top;
4219
+ css.left -= parentOffset.left;
4220
+
4221
+ if (!isCurrentlyAbove && !isCurrentlyBelow) {
4222
+ newDirection = 'below';
4223
+ }
4224
+
4225
+ if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
4226
+ newDirection = 'above';
4227
+ } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
4228
+ newDirection = 'below';
4229
+ }
4230
+
4231
+ if (newDirection == 'above' ||
4232
+ (isCurrentlyAbove && newDirection !== 'below')) {
4233
+ css.top = container.top - dropdown.height;
4234
+ }
4235
+
4236
+ if (newDirection != null) {
4237
+ this.$dropdown
4238
+ .removeClass('pumselect2-dropdown--below pumselect2-dropdown--above')
4239
+ .addClass('pumselect2-dropdown--' + newDirection);
4240
+ this.$container
4241
+ .removeClass('pumselect2-container--below pumselect2-container--above')
4242
+ .addClass('pumselect2-container--' + newDirection);
4243
+ }
4244
+
4245
+ this.$dropdownContainer.css(css);
4246
+ };
4247
+
4248
+ AttachBody.prototype._resizeDropdown = function () {
4249
+ var css = {
4250
+ width: this.$container.outerWidth(false) + 'px'
4251
+ };
4252
+
4253
+ if (this.options.get('dropdownAutoWidth')) {
4254
+ css.minWidth = css.width;
4255
+ css.width = 'auto';
4256
+ }
4257
+
4258
+ this.$dropdown.css(css);
4259
+ };
4260
+
4261
+ AttachBody.prototype._showDropdown = function (decorated) {
4262
+ this.$dropdownContainer.appendTo(this.$dropdownParent);
4263
+
4264
+ this._positionDropdown();
4265
+ this._resizeDropdown();
4266
+ };
4267
+
4268
+ return AttachBody;
4269
+ });
4270
+
4271
+ S2.define('pumselect2/dropdown/minimumResultsForSearch',[
4272
+
4273
+ ], function () {
4274
+ function countResults (data) {
4275
+ var count = 0;
4276
+
4277
+ for (var d = 0; d < data.length; d++) {
4278
+ var item = data[d];
4279
+
4280
+ if (item.children) {
4281
+ count += countResults(item.children);
4282
+ } else {
4283
+ count++;
4284
+ }
4285
+ }
4286
+
4287
+ return count;
4288
+ }
4289
+
4290
+ function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
4291
+ this.minimumResultsForSearch = options.get('minimumResultsForSearch');
4292
+
4293
+ if (this.minimumResultsForSearch < 0) {
4294
+ this.minimumResultsForSearch = Infinity;
4295
+ }
4296
+
4297
+ decorated.call(this, $element, options, dataAdapter);
4298
+ }
4299
+
4300
+ MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
4301
+ if (countResults(params.data.results) < this.minimumResultsForSearch) {
4302
+ return false;
4303
+ }
4304
+
4305
+ return decorated.call(this, params);
4306
+ };
4307
+
4308
+ return MinimumResultsForSearch;
4309
+ });
4310
+
4311
+ S2.define('pumselect2/dropdown/selectOnClose',[
4312
+
4313
+ ], function () {
4314
+ function SelectOnClose () { }
4315
+
4316
+ SelectOnClose.prototype.bind = function (decorated, container, $container) {
4317
+ var self = this;
4318
+
4319
+ decorated.call(this, container, $container);
4320
+
4321
+ container.on('close', function () {
4322
+ self._handleSelectOnClose();
4323
+ });
4324
+ };
4325
+
4326
+ SelectOnClose.prototype._handleSelectOnClose = function () {
4327
+ var $highlightedResults = this.getHighlightedResults();
4328
+
4329
+ // Only select highlighted results
4330
+ if ($highlightedResults.length < 1) {
4331
+ return;
4332
+ }
4333
+
4334
+ var data = $highlightedResults.data('data');
4335
+
4336
+ // Don't re-select already selected resulte
4337
+ if (
4338
+ (data.element != null && data.element.selected) ||
4339
+ (data.element == null && data.selected)
4340
+ ) {
4341
+ return;
4342
+ }
4343
+
4344
+ this.trigger('select', {
4345
+ data: data
4346
+ });
4347
+ };
4348
+
4349
+ return SelectOnClose;
4350
+ });
4351
+
4352
+ S2.define('pumselect2/dropdown/closeOnSelect',[
4353
+
4354
+ ], function () {
4355
+ function CloseOnSelect () { }
4356
+
4357
+ CloseOnSelect.prototype.bind = function (decorated, container, $container) {
4358
+ var self = this;
4359
+
4360
+ decorated.call(this, container, $container);
4361
+
4362
+ container.on('select', function (evt) {
4363
+ self._selectTriggered(evt);
4364
+ });
4365
+
4366
+ container.on('unselect', function (evt) {
4367
+ self._selectTriggered(evt);
4368
+ });
4369
+ };
4370
+
4371
+ CloseOnSelect.prototype._selectTriggered = function (_, evt) {
4372
+ var originalEvent = evt.originalEvent;
4373
+
4374
+ // Don't close if the control key is being held
4375
+ if (originalEvent && originalEvent.ctrlKey) {
4376
+ return;
4377
+ }
4378
+
4379
+ this.trigger('close', {});
4380
+ };
4381
+
4382
+ return CloseOnSelect;
4383
+ });
4384
+
4385
+ S2.define('pumselect2/i18n/en',[],function () {
4386
+ // English
4387
+ return {
4388
+ errorLoading: function () {
4389
+ return 'The results could not be loaded.';
4390
+ },
4391
+ inputTooLong: function (args) {
4392
+ var overChars = args.input.length - args.maximum;
4393
+
4394
+ var message = 'Please delete ' + overChars + ' character';
4395
+
4396
+ if (overChars != 1) {
4397
+ message += 's';
4398
+ }
4399
+
4400
+ return message;
4401
+ },
4402
+ inputTooShort: function (args) {
4403
+ var remainingChars = args.minimum - args.input.length;
4404
+
4405
+ var message = 'Please enter ' + remainingChars + ' or more characters';
4406
+
4407
+ return message;
4408
+ },
4409
+ loadingMore: function () {
4410
+ return 'Loading more results…';
4411
+ },
4412
+ maximumSelected: function (args) {
4413
+ var message = 'You can only select ' + args.maximum + ' item';
4414
+
4415
+ if (args.maximum != 1) {
4416
+ message += 's';
4417
+ }
4418
+
4419
+ return message;
4420
+ },
4421
+ noResults: function () {
4422
+ return 'No results found';
4423
+ },
4424
+ searching: function () {
4425
+ return 'Searching…';
4426
+ }
4427
+ };
4428
+ });
4429
+
4430
+ S2.define('pumselect2/defaults',[
4431
+ 'jquery',
4432
+ 'require',
4433
+
4434
+ './results',
4435
+
4436
+ './selection/single',
4437
+ './selection/multiple',
4438
+ './selection/placeholder',
4439
+ './selection/allowClear',
4440
+ './selection/search',
4441
+ './selection/eventRelay',
4442
+
4443
+ './utils',
4444
+ './translation',
4445
+ './diacritics',
4446
+
4447
+ './data/select',
4448
+ './data/array',
4449
+ './data/ajax',
4450
+ './data/tags',
4451
+ './data/tokenizer',
4452
+ './data/minimumInputLength',
4453
+ './data/maximumInputLength',
4454
+ './data/maximumSelectionLength',
4455
+
4456
+ './dropdown',
4457
+ './dropdown/search',
4458
+ './dropdown/hidePlaceholder',
4459
+ './dropdown/infiniteScroll',
4460
+ './dropdown/attachBody',
4461
+ './dropdown/minimumResultsForSearch',
4462
+ './dropdown/selectOnClose',
4463
+ './dropdown/closeOnSelect',
4464
+
4465
+ './i18n/en'
4466
+ ], function ($, require,
4467
+
4468
+ ResultsList,
4469
+
4470
+ SingleSelection, MultipleSelection, Placeholder, AllowClear,
4471
+ SelectionSearch, EventRelay,
4472
+
4473
+ Utils, Translation, DIACRITICS,
4474
+
4475
+ SelectData, ArrayData, AjaxData, Tags, Tokenizer,
4476
+ MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
4477
+
4478
+ Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
4479
+ AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
4480
+
4481
+ EnglishTranslation) {
4482
+ function Defaults () {
4483
+ this.reset();
4484
+ }
4485
+
4486
+ Defaults.prototype.apply = function (options) {
4487
+ options = $.extend(true, {}, this.defaults, options);
4488
+
4489
+ if (options.dataAdapter == null) {
4490
+ if (options.ajax != null) {
4491
+ options.dataAdapter = AjaxData;
4492
+ } else if (options.data != null) {
4493
+ options.dataAdapter = ArrayData;
4494
+ } else {
4495
+ options.dataAdapter = SelectData;
4496
+ }
4497
+
4498
+ if (options.minimumInputLength > 0) {
4499
+ options.dataAdapter = Utils.Decorate(
4500
+ options.dataAdapter,
4501
+ MinimumInputLength
4502
+ );
4503
+ }
4504
+
4505
+ if (options.maximumInputLength > 0) {
4506
+ options.dataAdapter = Utils.Decorate(
4507
+ options.dataAdapter,
4508
+ MaximumInputLength
4509
+ );
4510
+ }
4511
+
4512
+ if (options.maximumSelectionLength > 0) {
4513
+ options.dataAdapter = Utils.Decorate(
4514
+ options.dataAdapter,
4515
+ MaximumSelectionLength
4516
+ );
4517
+ }
4518
+
4519
+ if (options.tags) {
4520
+ options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
4521
+ }
4522
+
4523
+ if (options.tokenSeparators != null || options.tokenizer != null) {
4524
+ options.dataAdapter = Utils.Decorate(
4525
+ options.dataAdapter,
4526
+ Tokenizer
4527
+ );
4528
+ }
4529
+
4530
+ if (options.query != null) {
4531
+ var Query = require(options.amdBase + 'compat/query');
4532
+
4533
+ options.dataAdapter = Utils.Decorate(
4534
+ options.dataAdapter,
4535
+ Query
4536
+ );
4537
+ }
4538
+
4539
+ if (options.initSelection != null) {
4540
+ var InitSelection = require(options.amdBase + 'compat/initSelection');
4541
+
4542
+ options.dataAdapter = Utils.Decorate(
4543
+ options.dataAdapter,
4544
+ InitSelection
4545
+ );
4546
+ }
4547
+ }
4548
+
4549
+ if (options.resultsAdapter == null) {
4550
+ options.resultsAdapter = ResultsList;
4551
+
4552
+ if (options.ajax != null) {
4553
+ options.resultsAdapter = Utils.Decorate(
4554
+ options.resultsAdapter,
4555
+ InfiniteScroll
4556
+ );
4557
+ }
4558
+
4559
+ if (options.placeholder != null) {
4560
+ options.resultsAdapter = Utils.Decorate(
4561
+ options.resultsAdapter,
4562
+ HidePlaceholder
4563
+ );
4564
+ }
4565
+
4566
+ if (options.selectOnClose) {
4567
+ options.resultsAdapter = Utils.Decorate(
4568
+ options.resultsAdapter,
4569
+ SelectOnClose
4570
+ );
4571
+ }
4572
+ }
4573
+
4574
+ if (options.dropdownAdapter == null) {
4575
+ if (options.multiple) {
4576
+ options.dropdownAdapter = Dropdown;
4577
+ } else {
4578
+ var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
4579
+
4580
+ options.dropdownAdapter = SearchableDropdown;
4581
+ }
4582
+
4583
+ if (options.minimumResultsForSearch !== 0) {
4584
+ options.dropdownAdapter = Utils.Decorate(
4585
+ options.dropdownAdapter,
4586
+ MinimumResultsForSearch
4587
+ );
4588
+ }
4589
+
4590
+ if (options.closeOnSelect) {
4591
+ options.dropdownAdapter = Utils.Decorate(
4592
+ options.dropdownAdapter,
4593
+ CloseOnSelect
4594
+ );
4595
+ }
4596
+
4597
+ if (
4598
+ options.dropdownCssClass != null ||
4599
+ options.dropdownCss != null ||
4600
+ options.adaptDropdownCssClass != null
4601
+ ) {
4602
+ var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
4603
+
4604
+ options.dropdownAdapter = Utils.Decorate(
4605
+ options.dropdownAdapter,
4606
+ DropdownCSS
4607
+ );
4608
+ }
4609
+
4610
+ options.dropdownAdapter = Utils.Decorate(
4611
+ options.dropdownAdapter,
4612
+ AttachBody
4613
+ );
4614
+ }
4615
+
4616
+ if (options.selectionAdapter == null) {
4617
+ if (options.multiple) {
4618
+ options.selectionAdapter = MultipleSelection;
4619
+ } else {
4620
+ options.selectionAdapter = SingleSelection;
4621
+ }
4622
+
4623
+ // Add the placeholder mixin if a placeholder was specified
4624
+ if (options.placeholder != null) {
4625
+ options.selectionAdapter = Utils.Decorate(
4626
+ options.selectionAdapter,
4627
+ Placeholder
4628
+ );
4629
+ }
4630
+
4631
+ if (options.allowClear) {
4632
+ options.selectionAdapter = Utils.Decorate(
4633
+ options.selectionAdapter,
4634
+ AllowClear
4635
+ );
4636
+ }
4637
+
4638
+ if (options.multiple) {
4639
+ options.selectionAdapter = Utils.Decorate(
4640
+ options.selectionAdapter,
4641
+ SelectionSearch
4642
+ );
4643
+ }
4644
+
4645
+ if (
4646
+ options.containerCssClass != null ||
4647
+ options.containerCss != null ||
4648
+ options.adaptContainerCssClass != null
4649
+ ) {
4650
+ var ContainerCSS = require(options.amdBase + 'compat/containerCss');
4651
+
4652
+ options.selectionAdapter = Utils.Decorate(
4653
+ options.selectionAdapter,
4654
+ ContainerCSS
4655
+ );
4656
+ }
4657
+
4658
+ options.selectionAdapter = Utils.Decorate(
4659
+ options.selectionAdapter,
4660
+ EventRelay
4661
+ );
4662
+ }
4663
+
4664
+ if (typeof options.language === 'string') {
4665
+ // Check if the language is specified with a region
4666
+ if (options.language.indexOf('-') > 0) {
4667
+ // Extract the region information if it is included
4668
+ var languageParts = options.language.split('-');
4669
+ var baseLanguage = languageParts[0];
4670
+
4671
+ options.language = [options.language, baseLanguage];
4672
+ } else {
4673
+ options.language = [options.language];
4674
+ }
4675
+ }
4676
+
4677
+ if ($.isArray(options.language)) {
4678
+ var languages = new Translation();
4679
+ options.language.push('en');
4680
+
4681
+ var languageNames = options.language;
4682
+
4683
+ for (var l = 0; l < languageNames.length; l++) {
4684
+ var name = languageNames[l];
4685
+ var language = {};
4686
+
4687
+ try {
4688
+ // Try to load it with the original name
4689
+ language = Translation.loadPath(name);
4690
+ } catch (e) {
4691
+ try {
4692
+ // If we couldn't load it, check if it wasn't the full path
4693
+ name = this.defaults.amdLanguageBase + name;
4694
+ language = Translation.loadPath(name);
4695
+ } catch (ex) {
4696
+ // The translation could not be loaded at all. Sometimes this is
4697
+ // because of a configuration problem, other times this can be
4698
+ // because of how Select2 helps load all possible translation files.
4699
+ if (options.debug && window.console && console.warn) {
4700
+ console.warn(
4701
+ 'Select2: The language file for "' + name + '" could not be ' +
4702
+ 'automatically loaded. A fallback will be used instead.'
4703
+ );
4704
+ }
4705
+
4706
+ continue;
4707
+ }
4708
+ }
4709
+
4710
+ languages.extend(language);
4711
+ }
4712
+
4713
+ options.translations = languages;
4714
+ } else {
4715
+ var baseTranslation = Translation.loadPath(
4716
+ this.defaults.amdLanguageBase + 'en'
4717
+ );
4718
+ var customTranslation = new Translation(options.language);
4719
+
4720
+ customTranslation.extend(baseTranslation);
4721
+
4722
+ options.translations = customTranslation;
4723
+ }
4724
+
4725
+ return options;
4726
+ };
4727
+
4728
+ Defaults.prototype.reset = function () {
4729
+ function stripDiacritics (text) {
4730
+ // Used 'uni range + named function' from http://jsperf.com/diacritics/18
4731
+ function match(a) {
4732
+ return DIACRITICS[a] || a;
4733
+ }
4734
+
4735
+ return text.replace(/[^\u0000-\u007E]/g, match);
4736
+ }
4737
+
4738
+ function matcher (params, data) {
4739
+ // Always return the object if there is nothing to compare
4740
+ if ($.trim(params.term) === '') {
4741
+ return data;
4742
+ }
4743
+
4744
+ // Do a recursive check for options with children
4745
+ if (data.children && data.children.length > 0) {
4746
+ // Clone the data object if there are children
4747
+ // This is required as we modify the object to remove any non-matches
4748
+ var match = $.extend(true, {}, data);
4749
+
4750
+ // Check each child of the option
4751
+ for (var c = data.children.length - 1; c >= 0; c--) {
4752
+ var child = data.children[c];
4753
+
4754
+ var matches = matcher(params, child);
4755
+
4756
+ // If there wasn't a match, remove the object in the array
4757
+ if (matches == null) {
4758
+ match.children.splice(c, 1);
4759
+ }
4760
+ }
4761
+
4762
+ // If any children matched, return the new object
4763
+ if (match.children.length > 0) {
4764
+ return match;
4765
+ }
4766
+
4767
+ // If there were no matching children, check just the plain object
4768
+ return matcher(params, match);
4769
+ }
4770
+
4771
+ var original = stripDiacritics(data.text).toUpperCase();
4772
+ var term = stripDiacritics(params.term).toUpperCase();
4773
+
4774
+ // Check if the text contains the term
4775
+ if (original.indexOf(term) > -1) {
4776
+ return data;
4777
+ }
4778
+
4779
+ // If it doesn't contain the term, don't return anything
4780
+ return null;
4781
+ }
4782
+
4783
+ this.defaults = {
4784
+ amdBase: './',
4785
+ amdLanguageBase: './i18n/',
4786
+ closeOnSelect: true,
4787
+ debug: false,
4788
+ dropdownAutoWidth: false,
4789
+ escapeMarkup: Utils.escapeMarkup,
4790
+ language: EnglishTranslation,
4791
+ matcher: matcher,
4792
+ minimumInputLength: 0,
4793
+ maximumInputLength: 0,
4794
+ maximumSelectionLength: 0,
4795
+ minimumResultsForSearch: 0,
4796
+ selectOnClose: false,
4797
+ sorter: function (data) {
4798
+ return data;
4799
+ },
4800
+ templateResult: function (result) {
4801
+ return result.text;
4802
+ },
4803
+ templateSelection: function (selection) {
4804
+ return selection.text;
4805
+ },
4806
+ theme: 'default',
4807
+ width: 'resolve'
4808
+ };
4809
+ };
4810
+
4811
+ Defaults.prototype.set = function (key, value) {
4812
+ var camelKey = $.camelCase(key);
4813
+
4814
+ var data = {};
4815
+ data[camelKey] = value;
4816
+
4817
+ var convertedData = Utils._convertData(data);
4818
+
4819
+ $.extend(this.defaults, convertedData);
4820
+ };
4821
+
4822
+ var defaults = new Defaults();
4823
+
4824
+ return defaults;
4825
+ });
4826
+
4827
+ S2.define('pumselect2/options',[
4828
+ 'require',
4829
+ 'jquery',
4830
+ './defaults',
4831
+ './utils'
4832
+ ], function (require, $, Defaults, Utils) {
4833
+ function Options (options, $element) {
4834
+ this.options = options;
4835
+
4836
+ if ($element != null) {
4837
+ this.fromElement($element);
4838
+ }
4839
+
4840
+ this.options = Defaults.apply(this.options);
4841
+
4842
+ if ($element && $element.is('input')) {
4843
+ var InputCompat = require(this.get('amdBase') + 'compat/inputData');
4844
+
4845
+ this.options.dataAdapter = Utils.Decorate(
4846
+ this.options.dataAdapter,
4847
+ InputCompat
4848
+ );
4849
+ }
4850
+ }
4851
+
4852
+ Options.prototype.fromElement = function ($e) {
4853
+ var excludedData = ['pumselect2'];
4854
+
4855
+ if (this.options.multiple == null) {
4856
+ this.options.multiple = $e.prop('multiple');
4857
+ }
4858
+
4859
+ if (this.options.disabled == null) {
4860
+ this.options.disabled = $e.prop('disabled');
4861
+ }
4862
+
4863
+ if (this.options.language == null) {
4864
+ if ($e.prop('lang')) {
4865
+ this.options.language = $e.prop('lang').toLowerCase();
4866
+ } else if ($e.closest('[lang]').prop('lang')) {
4867
+ this.options.language = $e.closest('[lang]').prop('lang');
4868
+ }
4869
+ }
4870
+
4871
+ if (this.options.dir == null) {
4872
+ if ($e.prop('dir')) {
4873
+ this.options.dir = $e.prop('dir');
4874
+ } else if ($e.closest('[dir]').prop('dir')) {
4875
+ this.options.dir = $e.closest('[dir]').prop('dir');
4876
+ } else {
4877
+ this.options.dir = 'ltr';
4878
+ }
4879
+ }
4880
+
4881
+ $e.prop('disabled', this.options.disabled);
4882
+ $e.prop('multiple', this.options.multiple);
4883
+
4884
+ if ($e.data('pumselect2Tags')) {
4885
+ if (this.options.debug && window.console && console.warn) {
4886
+ console.warn(
4887
+ 'Select2: The `data-pumselect2-tags` attribute has been changed to ' +
4888
+ 'use the `data-data` and `data-tags="true"` attributes and will be ' +
4889
+ 'removed in future versions of Select2.'
4890
+ );
4891
+ }
4892
+
4893
+ $e.data('data', $e.data('pumselect2Tags'));
4894
+ $e.data('tags', true);
4895
+ }
4896
+
4897
+ if ($e.data('ajaxUrl')) {
4898
+ if (this.options.debug && window.console && console.warn) {
4899
+ console.warn(
4900
+ 'Select2: The `data-ajax-url` attribute has been changed to ' +
4901
+ '`data-ajax--url` and support for the old attribute will be removed' +
4902
+ ' in future versions of Select2.'
4903
+ );
4904
+ }
4905
+
4906
+ $e.attr('ajax--url', $e.data('ajaxUrl'));
4907
+ $e.data('ajax--url', $e.data('ajaxUrl'));
4908
+ }
4909
+
4910
+ var dataset = {};
4911
+
4912
+ // Prefer the element's `dataset` attribute if it exists
4913
+ // jQuery 1.x does not correctly handle data attributes with multiple dashes
4914
+ if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
4915
+ dataset = $.extend(true, {}, $e[0].dataset, $e.data());
4916
+ } else {
4917
+ dataset = $e.data();
4918
+ }
4919
+
4920
+ var data = $.extend(true, {}, dataset);
4921
+
4922
+ data = Utils._convertData(data);
4923
+
4924
+ for (var key in data) {
4925
+ if ($.inArray(key, excludedData) > -1) {
4926
+ continue;
4927
+ }
4928
+
4929
+ if ($.isPlainObject(this.options[key])) {
4930
+ $.extend(this.options[key], data[key]);
4931
+ } else {
4932
+ this.options[key] = data[key];
4933
+ }
4934
+ }
4935
+
4936
+ return this;
4937
+ };
4938
+
4939
+ Options.prototype.get = function (key) {
4940
+ return this.options[key];
4941
+ };
4942
+
4943
+ Options.prototype.set = function (key, val) {
4944
+ this.options[key] = val;
4945
+ };
4946
+
4947
+ return Options;
4948
+ });
4949
+
4950
+ S2.define('pumselect2/core',[
4951
+ 'jquery',
4952
+ './options',
4953
+ './utils',
4954
+ './keys'
4955
+ ], function ($, Options, Utils, KEYS) {
4956
+ var Select2 = function ($element, options) {
4957
+ if ($element.data('pumselect2') != null) {
4958
+ $element.data('pumselect2').destroy();
4959
+ }
4960
+
4961
+ this.$element = $element;
4962
+
4963
+ this.id = this._generateId($element);
4964
+
4965
+ options = options || {};
4966
+
4967
+ this.options = new Options(options, $element);
4968
+
4969
+ Select2.__super__.constructor.call(this);
4970
+
4971
+ // Set up the tabindex
4972
+
4973
+ var tabindex = $element.attr('tabindex') || 0;
4974
+ $element.data('old-tabindex', tabindex);
4975
+ $element.attr('tabindex', '-1');
4976
+
4977
+ // Set up containers and adapters
4978
+
4979
+ var DataAdapter = this.options.get('dataAdapter');
4980
+ this.dataAdapter = new DataAdapter($element, this.options);
4981
+
4982
+ var $container = this.render();
4983
+
4984
+ this._placeContainer($container);
4985
+
4986
+ var SelectionAdapter = this.options.get('selectionAdapter');
4987
+ this.selection = new SelectionAdapter($element, this.options);
4988
+ this.$selection = this.selection.render();
4989
+
4990
+ this.selection.position(this.$selection, $container);
4991
+
4992
+ var DropdownAdapter = this.options.get('dropdownAdapter');
4993
+ this.dropdown = new DropdownAdapter($element, this.options);
4994
+ this.$dropdown = this.dropdown.render();
4995
+
4996
+ this.dropdown.position(this.$dropdown, $container);
4997
+
4998
+ var ResultsAdapter = this.options.get('resultsAdapter');
4999
+ this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
5000
+ this.$results = this.results.render();
5001
+
5002
+ this.results.position(this.$results, this.$dropdown);
5003
+
5004
+ // Bind events
5005
+
5006
+ var self = this;
5007
+
5008
+ // Bind the container to all of the adapters
5009
+ this._bindAdapters();
5010
+
5011
+ // Register any DOM event handlers
5012
+ this._registerDomEvents();
5013
+
5014
+ // Register any internal event handlers
5015
+ this._registerDataEvents();
5016
+ this._registerSelectionEvents();
5017
+ this._registerDropdownEvents();
5018
+ this._registerResultsEvents();
5019
+ this._registerEvents();
5020
+
5021
+ // Set the initial state
5022
+ this.dataAdapter.current(function (initialData) {
5023
+ self.trigger('selection:update', {
5024
+ data: initialData
5025
+ });
5026
+ });
5027
+
5028
+ // Hide the original select
5029
+ $element.addClass('pumselect2-hidden-accessible');
5030
+ $element.attr('aria-hidden', 'true');
5031
+
5032
+ // Synchronize any monitored attributes
5033
+ this._syncAttributes();
5034
+
5035
+ $element.data('pumselect2', this);
5036
+ };
5037
+
5038
+ Utils.Extend(Select2, Utils.Observable);
5039
+
5040
+ Select2.prototype._generateId = function ($element) {
5041
+ var id = '';
5042
+
5043
+ if ($element.attr('id') != null) {
5044
+ id = $element.attr('id');
5045
+ } else if ($element.attr('name') != null) {
5046
+ id = $element.attr('name') + '-' + Utils.generateChars(2);
5047
+ } else {
5048
+ id = Utils.generateChars(4);
5049
+ }
5050
+
5051
+ id = id.replace(/(:|\.|\[|\]|,)/g, '');
5052
+ id = 'pumselect2-' + id;
5053
+
5054
+ return id;
5055
+ };
5056
+
5057
+ Select2.prototype._placeContainer = function ($container) {
5058
+ $container.insertAfter(this.$element);
5059
+
5060
+ var width = this._resolveWidth(this.$element, this.options.get('width'));
5061
+
5062
+ if (width != null) {
5063
+ $container.css('width', width);
5064
+ }
5065
+ };
5066
+
5067
+ Select2.prototype._resolveWidth = function ($element, method) {
5068
+ var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
5069
+
5070
+ if (method == 'resolve') {
5071
+ var styleWidth = this._resolveWidth($element, 'style');
5072
+
5073
+ if (styleWidth != null) {
5074
+ return styleWidth;
5075
+ }
5076
+
5077
+ return this._resolveWidth($element, 'element');
5078
+ }
5079
+
5080
+ if (method == 'element') {
5081
+ var elementWidth = $element.outerWidth(false);
5082
+
5083
+ if (elementWidth <= 0) {
5084
+ return 'auto';
5085
+ }
5086
+
5087
+ return elementWidth + 'px';
5088
+ }
5089
+
5090
+ if (method == 'style') {
5091
+ var style = $element.attr('style');
5092
+
5093
+ if (typeof(style) !== 'string') {
5094
+ return null;
5095
+ }
5096
+
5097
+ var attrs = style.split(';');
5098
+
5099
+ for (var i = 0, l = attrs.length; i < l; i = i + 1) {
5100
+ var attr = attrs[i].replace(/\s/g, '');
5101
+ var matches = attr.match(WIDTH);
5102
+
5103
+ if (matches !== null && matches.length >= 1) {
5104
+ return matches[1];
5105
+ }
5106
+ }
5107
+
5108
+ return null;
5109
+ }
5110
+
5111
+ return method;
5112
+ };
5113
+
5114
+ Select2.prototype._bindAdapters = function () {
5115
+ this.dataAdapter.bind(this, this.$container);
5116
+ this.selection.bind(this, this.$container);
5117
+
5118
+ this.dropdown.bind(this, this.$container);
5119
+ this.results.bind(this, this.$container);
5120
+ };
5121
+
5122
+ Select2.prototype._registerDomEvents = function () {
5123
+ var self = this;
5124
+
5125
+ this.$element.on('change.pumselect2', function () {
5126
+ self.dataAdapter.current(function (data) {
5127
+ self.trigger('selection:update', {
5128
+ data: data
5129
+ });
5130
+ });
5131
+ });
5132
+
5133
+ this._sync = Utils.bind(this._syncAttributes, this);
5134
+
5135
+ if (this.$element[0].attachEvent) {
5136
+ this.$element[0].attachEvent('onpropertychange', this._sync);
5137
+ }
5138
+
5139
+ var observer = window.MutationObserver ||
5140
+ window.WebKitMutationObserver ||
5141
+ window.MozMutationObserver
5142
+ ;
5143
+
5144
+ if (observer != null) {
5145
+ this._observer = new observer(function (mutations) {
5146
+ $.each(mutations, self._sync);
5147
+ });
5148
+ this._observer.observe(this.$element[0], {
5149
+ attributes: true,
5150
+ subtree: false
5151
+ });
5152
+ } else if (this.$element[0].addEventListener) {
5153
+ this.$element[0].addEventListener('DOMAttrModified', self._sync, false);
5154
+ }
5155
+ };
5156
+
5157
+ Select2.prototype._registerDataEvents = function () {
5158
+ var self = this;
5159
+
5160
+ this.dataAdapter.on('*', function (name, params) {
5161
+ self.trigger(name, params);
5162
+ });
5163
+ };
5164
+
5165
+ Select2.prototype._registerSelectionEvents = function () {
5166
+ var self = this;
5167
+ var nonRelayEvents = ['toggle', 'focus'];
5168
+
5169
+ this.selection.on('toggle', function () {
5170
+ self.toggleDropdown();
5171
+ });
5172
+
5173
+ this.selection.on('focus', function (params) {
5174
+ self.focus(params);
5175
+ });
5176
+
5177
+ this.selection.on('*', function (name, params) {
5178
+ if ($.inArray(name, nonRelayEvents) !== -1) {
5179
+ return;
5180
+ }
5181
+
5182
+ self.trigger(name, params);
5183
+ });
5184
+ };
5185
+
5186
+ Select2.prototype._registerDropdownEvents = function () {
5187
+ var self = this;
5188
+
5189
+ this.dropdown.on('*', function (name, params) {
5190
+ self.trigger(name, params);
5191
+ });
5192
+ };
5193
+
5194
+ Select2.prototype._registerResultsEvents = function () {
5195
+ var self = this;
5196
+
5197
+ this.results.on('*', function (name, params) {
5198
+ self.trigger(name, params);
5199
+ });
5200
+ };
5201
+
5202
+ Select2.prototype._registerEvents = function () {
5203
+ var self = this;
5204
+
5205
+ this.on('open', function () {
5206
+ self.$container.addClass('pumselect2-container--open');
5207
+ });
5208
+
5209
+ this.on('close', function () {
5210
+ self.$container.removeClass('pumselect2-container--open');
5211
+ });
5212
+
5213
+ this.on('enable', function () {
5214
+ self.$container.removeClass('pumselect2-container--disabled');
5215
+ });
5216
+
5217
+ this.on('disable', function () {
5218
+ self.$container.addClass('pumselect2-container--disabled');
5219
+ });
5220
+
5221
+ this.on('blur', function () {
5222
+ self.$container.removeClass('pumselect2-container--focus');
5223
+ });
5224
+
5225
+ this.on('query', function (params) {
5226
+ if (!self.isOpen()) {
5227
+ self.trigger('open', {});
5228
+ }
5229
+
5230
+ this.dataAdapter.query(params, function (data) {
5231
+ self.trigger('results:all', {
5232
+ data: data,
5233
+ query: params
5234
+ });
5235
+ });
5236
+ });
5237
+
5238
+ this.on('query:append', function (params) {
5239
+ this.dataAdapter.query(params, function (data) {
5240
+ self.trigger('results:append', {
5241
+ data: data,
5242
+ query: params
5243
+ });
5244
+ });
5245
+ });
5246
+
5247
+ this.on('keypress', function (evt) {
5248
+ var key = evt.which;
5249
+
5250
+ if (self.isOpen()) {
5251
+ if (key === KEYS.ESC || key === KEYS.TAB ||
5252
+ (key === KEYS.UP && evt.altKey)) {
5253
+ self.close();
5254
+
5255
+ evt.preventDefault();
5256
+ } else if (key === KEYS.ENTER) {
5257
+ self.trigger('results:select', {});
5258
+
5259
+ evt.preventDefault();
5260
+ } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
5261
+ self.trigger('results:toggle', {});
5262
+
5263
+ evt.preventDefault();
5264
+ } else if (key === KEYS.UP) {
5265
+ self.trigger('results:previous', {});
5266
+
5267
+ evt.preventDefault();
5268
+ } else if (key === KEYS.DOWN) {
5269
+ self.trigger('results:next', {});
5270
+
5271
+ evt.preventDefault();
5272
+ }
5273
+ } else {
5274
+ if (key === KEYS.ENTER || key === KEYS.SPACE ||
5275
+ (key === KEYS.DOWN && evt.altKey)) {
5276
+ self.open();
5277
+
5278
+ evt.preventDefault();
5279
+ }
5280
+ }
5281
+ });
5282
+ };
5283
+
5284
+ Select2.prototype._syncAttributes = function () {
5285
+ this.options.set('disabled', this.$element.prop('disabled'));
5286
+
5287
+ if (this.options.get('disabled')) {
5288
+ if (this.isOpen()) {
5289
+ this.close();
5290
+ }
5291
+
5292
+ this.trigger('disable', {});
5293
+ } else {
5294
+ this.trigger('enable', {});
5295
+ }
5296
+ };
5297
+
5298
+ /**
5299
+ * Override the trigger method to automatically trigger pre-events when
5300
+ * there are events that can be prevented.
5301
+ */
5302
+ Select2.prototype.trigger = function (name, args) {
5303
+ var actualTrigger = Select2.__super__.trigger;
5304
+ var preTriggerMap = {
5305
+ 'open': 'opening',
5306
+ 'close': 'closing',
5307
+ 'select': 'selecting',
5308
+ 'unselect': 'unselecting'
5309
+ };
5310
+
5311
+ if (args === undefined) {
5312
+ args = {};
5313
+ }
5314
+
5315
+ if (name in preTriggerMap) {
5316
+ var preTriggerName = preTriggerMap[name];
5317
+ var preTriggerArgs = {
5318
+ prevented: false,
5319
+ name: name,
5320
+ args: args
5321
+ };
5322
+
5323
+ actualTrigger.call(this, preTriggerName, preTriggerArgs);
5324
+
5325
+ if (preTriggerArgs.prevented) {
5326
+ args.prevented = true;
5327
+
5328
+ return;
5329
+ }
5330
+ }
5331
+
5332
+ actualTrigger.call(this, name, args);
5333
+ };
5334
+
5335
+ Select2.prototype.toggleDropdown = function () {
5336
+ if (this.options.get('disabled')) {
5337
+ return;
5338
+ }
5339
+
5340
+ if (this.isOpen()) {
5341
+ this.close();
5342
+ } else {
5343
+ this.open();
5344
+ }
5345
+ };
5346
+
5347
+ Select2.prototype.open = function () {
5348
+ if (this.isOpen()) {
5349
+ return;
5350
+ }
5351
+
5352
+ this.trigger('query', {});
5353
+ };
5354
+
5355
+ Select2.prototype.close = function () {
5356
+ if (!this.isOpen()) {
5357
+ return;
5358
+ }
5359
+
5360
+ this.trigger('close', {});
5361
+ };
5362
+
5363
+ Select2.prototype.isOpen = function () {
5364
+ return this.$container.hasClass('pumselect2-container--open');
5365
+ };
5366
+
5367
+ Select2.prototype.hasFocus = function () {
5368
+ return this.$container.hasClass('pumselect2-container--focus');
5369
+ };
5370
+
5371
+ Select2.prototype.focus = function (data) {
5372
+ // No need to re-trigger focus events if we are already focused
5373
+ if (this.hasFocus()) {
5374
+ return;
5375
+ }
5376
+
5377
+ this.$container.addClass('pumselect2-container--focus');
5378
+ this.trigger('focus', {});
5379
+ };
5380
+
5381
+ Select2.prototype.enable = function (args) {
5382
+ if (this.options.get('debug') && window.console && console.warn) {
5383
+ console.warn(
5384
+ 'Select2: The `pumselect2("enable")` method has been deprecated and will' +
5385
+ ' be removed in later Select2 versions. Use $element.prop("disabled")' +
5386
+ ' instead.'
5387
+ );
5388
+ }
5389
+
5390
+ if (args == null || args.length === 0) {
5391
+ args = [true];
5392
+ }
5393
+
5394
+ var disabled = !args[0];
5395
+
5396
+ this.$element.prop('disabled', disabled);
5397
+ };
5398
+
5399
+ Select2.prototype.data = function () {
5400
+ if (this.options.get('debug') &&
5401
+ arguments.length > 0 && window.console && console.warn) {
5402
+ console.warn(
5403
+ 'Select2: Data can no longer be set using `pumselect2("data")`. You ' +
5404
+ 'should consider setting the value instead using `$element.val()`.'
5405
+ );
5406
+ }
5407
+
5408
+ var data = [];
5409
+
5410
+ this.dataAdapter.current(function (currentData) {
5411
+ data = currentData;
5412
+ });
5413
+
5414
+ return data;
5415
+ };
5416
+
5417
+ Select2.prototype.val = function (args) {
5418
+ if (this.options.get('debug') && window.console && console.warn) {
5419
+ console.warn(
5420
+ 'Select2: The `pumselect2("val")` method has been deprecated and will be' +
5421
+ ' removed in later Select2 versions. Use $element.val() instead.'
5422
+ );
5423
+ }
5424
+
5425
+ if (args == null || args.length === 0) {
5426
+ return this.$element.val();
5427
+ }
5428
+
5429
+ var newVal = args[0];
5430
+
5431
+ if ($.isArray(newVal)) {
5432
+ newVal = $.map(newVal, function (obj) {
5433
+ return obj.toString();
5434
+ });
5435
+ }
5436
+
5437
+ this.$element.val(newVal).trigger('change');
5438
+ };
5439
+
5440
+ Select2.prototype.destroy = function () {
5441
+ this.$container.remove();
5442
+
5443
+ if (this.$element[0].detachEvent) {
5444
+ this.$element[0].detachEvent('onpropertychange', this._sync);
5445
+ }
5446
+
5447
+ if (this._observer != null) {
5448
+ this._observer.disconnect();
5449
+ this._observer = null;
5450
+ } else if (this.$element[0].removeEventListener) {
5451
+ this.$element[0]
5452
+ .removeEventListener('DOMAttrModified', this._sync, false);
5453
+ }
5454
+
5455
+ this._sync = null;
5456
+
5457
+ this.$element.off('.pumselect2');
5458
+ this.$element.attr('tabindex', this.$element.data('old-tabindex'));
5459
+
5460
+ this.$element.removeClass('pumselect2-hidden-accessible');
5461
+ this.$element.attr('aria-hidden', 'false');
5462
+ this.$element.removeData('pumselect2');
5463
+
5464
+ this.dataAdapter.destroy();
5465
+ this.selection.destroy();
5466
+ this.dropdown.destroy();
5467
+ this.results.destroy();
5468
+
5469
+ this.dataAdapter = null;
5470
+ this.selection = null;
5471
+ this.dropdown = null;
5472
+ this.results = null;
5473
+ };
5474
+
5475
+ Select2.prototype.render = function () {
5476
+ var $container = $(
5477
+ '<span class="pumselect2 pumselect2-container">' +
5478
+ '<span class="selection"></span>' +
5479
+ '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
5480
+ '</span>'
5481
+ );
5482
+
5483
+ $container.attr('dir', this.options.get('dir'));
5484
+
5485
+ this.$container = $container;
5486
+
5487
+ this.$container.addClass('pumselect2-container--' + this.options.get('theme'));
5488
+
5489
+ $container.data('element', this.$element);
5490
+
5491
+ return $container;
5492
+ };
5493
+
5494
+ return Select2;
5495
+ });
5496
+
5497
+ S2.define('pumselect2/compat/utils',[
5498
+ 'jquery'
5499
+ ], function ($) {
5500
+ function syncCssClasses ($dest, $src, adapter) {
5501
+ var classes, replacements = [], adapted;
5502
+
5503
+ classes = $.trim($dest.attr('class'));
5504
+
5505
+ if (classes) {
5506
+ classes = '' + classes; // for IE which returns object
5507
+
5508
+ $(classes.split(/\s+/)).each(function () {
5509
+ // Save all Select2 classes
5510
+ if (this.indexOf('pumselect2-') === 0) {
5511
+ replacements.push(this);
5512
+ }
5513
+ });
5514
+ }
5515
+
5516
+ classes = $.trim($src.attr('class'));
5517
+
5518
+ if (classes) {
5519
+ classes = '' + classes; // for IE which returns object
5520
+
5521
+ $(classes.split(/\s+/)).each(function () {
5522
+ // Only adapt non-Select2 classes
5523
+ if (this.indexOf('pumselect2-') !== 0) {
5524
+ adapted = adapter(this);
5525
+
5526
+ if (adapted != null) {
5527
+ replacements.push(adapted);
5528
+ }
5529
+ }
5530
+ });
5531
+ }
5532
+
5533
+ $dest.attr('class', replacements.join(' '));
5534
+ }
5535
+
5536
+ return {
5537
+ syncCssClasses: syncCssClasses
5538
+ };
5539
+ });
5540
+
5541
+ S2.define('pumselect2/compat/containerCss',[
5542
+ 'jquery',
5543
+ './utils'
5544
+ ], function ($, CompatUtils) {
5545
+ // No-op CSS adapter that discards all classes by default
5546
+ function _containerAdapter (clazz) {
5547
+ return null;
5548
+ }
5549
+
5550
+ function ContainerCSS () { }
5551
+
5552
+ ContainerCSS.prototype.render = function (decorated) {
5553
+ var $container = decorated.call(this);
5554
+
5555
+ var containerCssClass = this.options.get('containerCssClass') || '';
5556
+
5557
+ if ($.isFunction(containerCssClass)) {
5558
+ containerCssClass = containerCssClass(this.$element);
5559
+ }
5560
+
5561
+ var containerCssAdapter = this.options.get('adaptContainerCssClass');
5562
+ containerCssAdapter = containerCssAdapter || _containerAdapter;
5563
+
5564
+ if (containerCssClass.indexOf(':all:') !== -1) {
5565
+ containerCssClass = containerCssClass.replace(':all:', '');
5566
+
5567
+ var _cssAdapter = containerCssAdapter;
5568
+
5569
+ containerCssAdapter = function (clazz) {
5570
+ var adapted = _cssAdapter(clazz);
5571
+
5572
+ if (adapted != null) {
5573
+ // Append the old one along with the adapted one
5574
+ return adapted + ' ' + clazz;
5575
+ }
5576
+
5577
+ return clazz;
5578
+ };
5579
+ }
5580
+
5581
+ var containerCss = this.options.get('containerCss') || {};
5582
+
5583
+ if ($.isFunction(containerCss)) {
5584
+ containerCss = containerCss(this.$element);
5585
+ }
5586
+
5587
+ CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);
5588
+
5589
+ $container.css(containerCss);
5590
+ $container.addClass(containerCssClass);
5591
+
5592
+ return $container;
5593
+ };
5594
+
5595
+ return ContainerCSS;
5596
+ });
5597
+
5598
+ S2.define('pumselect2/compat/dropdownCss',[
5599
+ 'jquery',
5600
+ './utils'
5601
+ ], function ($, CompatUtils) {
5602
+ // No-op CSS adapter that discards all classes by default
5603
+ function _dropdownAdapter (clazz) {
5604
+ return null;
5605
+ }
5606
+
5607
+ function DropdownCSS () { }
5608
+
5609
+ DropdownCSS.prototype.render = function (decorated) {
5610
+ var $dropdown = decorated.call(this);
5611
+
5612
+ var dropdownCssClass = this.options.get('dropdownCssClass') || '';
5613
+
5614
+ if ($.isFunction(dropdownCssClass)) {
5615
+ dropdownCssClass = dropdownCssClass(this.$element);
5616
+ }
5617
+
5618
+ var dropdownCssAdapter = this.options.get('adaptDropdownCssClass');
5619
+ dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter;
5620
+
5621
+ if (dropdownCssClass.indexOf(':all:') !== -1) {
5622
+ dropdownCssClass = dropdownCssClass.replace(':all:', '');
5623
+
5624
+ var _cssAdapter = dropdownCssAdapter;
5625
+
5626
+ dropdownCssAdapter = function (clazz) {
5627
+ var adapted = _cssAdapter(clazz);
5628
+
5629
+ if (adapted != null) {
5630
+ // Append the old one along with the adapted one
5631
+ return adapted + ' ' + clazz;
5632
+ }
5633
+
5634
+ return clazz;
5635
+ };
5636
+ }
5637
+
5638
+ var dropdownCss = this.options.get('dropdownCss') || {};
5639
+
5640
+ if ($.isFunction(dropdownCss)) {
5641
+ dropdownCss = dropdownCss(this.$element);
5642
+ }
5643
+
5644
+ CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);
5645
+
5646
+ $dropdown.css(dropdownCss);
5647
+ $dropdown.addClass(dropdownCssClass);
5648
+
5649
+ return $dropdown;
5650
+ };
5651
+
5652
+ return DropdownCSS;
5653
+ });
5654
+
5655
+ S2.define('pumselect2/compat/initSelection',[
5656
+ 'jquery'
5657
+ ], function ($) {
5658
+ function InitSelection (decorated, $element, options) {
5659
+ if (options.get('debug') && window.console && console.warn) {
5660
+ console.warn(
5661
+ 'Select2: The `initSelection` option has been deprecated in favor' +
5662
+ ' of a custom data adapter that overrides the `current` method. ' +
5663
+ 'This method is now called multiple times instead of a single ' +
5664
+ 'time when the instance is initialized. Support will be removed ' +
5665
+ 'for the `initSelection` option in future versions of Select2'
5666
+ );
5667
+ }
5668
+
5669
+ this.initSelection = options.get('initSelection');
5670
+ this._isInitialized = false;
5671
+
5672
+ decorated.call(this, $element, options);
5673
+ }
5674
+
5675
+ InitSelection.prototype.current = function (decorated, callback) {
5676
+ var self = this;
5677
+
5678
+ if (this._isInitialized) {
5679
+ decorated.call(this, callback);
5680
+
5681
+ return;
5682
+ }
5683
+
5684
+ this.initSelection.call(null, this.$element, function (data) {
5685
+ self._isInitialized = true;
5686
+
5687
+ if (!$.isArray(data)) {
5688
+ data = [data];
5689
+ }
5690
+
5691
+ callback(data);
5692
+ });
5693
+ };
5694
+
5695
+ return InitSelection;
5696
+ });
5697
+
5698
+ S2.define('pumselect2/compat/inputData',[
5699
+ 'jquery'
5700
+ ], function ($) {
5701
+ function InputData (decorated, $element, options) {
5702
+ this._currentData = [];
5703
+ this._valueSeparator = options.get('valueSeparator') || ',';
5704
+
5705
+ if ($element.prop('type') === 'hidden') {
5706
+ if (options.get('debug') && console && console.warn) {
5707
+ console.warn(
5708
+ 'Select2: Using a hidden input with Select2 is no longer ' +
5709
+ 'supported and may stop working in the future. It is recommended ' +
5710
+ 'to use a `<select>` element instead.'
5711
+ );
5712
+ }
5713
+ }
5714
+
5715
+ decorated.call(this, $element, options);
5716
+ }
5717
+
5718
+ InputData.prototype.current = function (_, callback) {
5719
+ function getSelected (data, selectedIds) {
5720
+ var selected = [];
5721
+
5722
+ if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
5723
+ data.selected = true;
5724
+ selected.push(data);
5725
+ } else {
5726
+ data.selected = false;
5727
+ }
5728
+
5729
+ if (data.children) {
5730
+ selected.push.apply(selected, getSelected(data.children, selectedIds));
5731
+ }
5732
+
5733
+ return selected;
5734
+ }
5735
+
5736
+ var selected = [];
5737
+
5738
+ for (var d = 0; d < this._currentData.length; d++) {
5739
+ var data = this._currentData[d];
5740
+
5741
+ selected.push.apply(
5742
+ selected,
5743
+ getSelected(
5744
+ data,
5745
+ this.$element.val().split(
5746
+ this._valueSeparator
5747
+ )
5748
+ )
5749
+ );
5750
+ }
5751
+
5752
+ callback(selected);
5753
+ };
5754
+
5755
+ InputData.prototype.select = function (_, data) {
5756
+ if (!this.options.get('multiple')) {
5757
+ this.current(function (allData) {
5758
+ $.map(allData, function (data) {
5759
+ data.selected = false;
5760
+ });
5761
+ });
5762
+
5763
+ this.$element.val(data.id);
5764
+ this.$element.trigger('change');
5765
+ } else {
5766
+ var value = this.$element.val();
5767
+ value += this._valueSeparator + data.id;
5768
+
5769
+ this.$element.val(value);
5770
+ this.$element.trigger('change');
5771
+ }
5772
+ };
5773
+
5774
+ InputData.prototype.unselect = function (_, data) {
5775
+ var self = this;
5776
+
5777
+ data.selected = false;
5778
+
5779
+ this.current(function (allData) {
5780
+ var values = [];
5781
+
5782
+ for (var d = 0; d < allData.length; d++) {
5783
+ var item = allData[d];
5784
+
5785
+ if (data.id == item.id) {
5786
+ continue;
5787
+ }
5788
+
5789
+ values.push(item.id);
5790
+ }
5791
+
5792
+ self.$element.val(values.join(self._valueSeparator));
5793
+ self.$element.trigger('change');
5794
+ });
5795
+ };
5796
+
5797
+ InputData.prototype.query = function (_, params, callback) {
5798
+ var results = [];
5799
+
5800
+ for (var d = 0; d < this._currentData.length; d++) {
5801
+ var data = this._currentData[d];
5802
+
5803
+ var matches = this.matches(params, data);
5804
+
5805
+ if (matches !== null) {
5806
+ results.push(matches);
5807
+ }
5808
+ }
5809
+
5810
+ callback({
5811
+ results: results
5812
+ });
5813
+ };
5814
+
5815
+ InputData.prototype.addOptions = function (_, $options) {
5816
+ var options = $.map($options, function ($option) {
5817
+ return $.data($option[0], 'data');
5818
+ });
5819
+
5820
+ this._currentData.push.apply(this._currentData, options);
5821
+ };
5822
+
5823
+ return InputData;
5824
+ });
5825
+
5826
+ S2.define('pumselect2/compat/matcher',[
5827
+ 'jquery'
5828
+ ], function ($) {
5829
+ function oldMatcher (matcher) {
5830
+ function wrappedMatcher (params, data) {
5831
+ var match = $.extend(true, {}, data);
5832
+
5833
+ if (params.term == null || $.trim(params.term) === '') {
5834
+ return match;
5835
+ }
5836
+
5837
+ if (data.children) {
5838
+ for (var c = data.children.length - 1; c >= 0; c--) {
5839
+ var child = data.children[c];
5840
+
5841
+ // Check if the child object matches
5842
+ // The old matcher returned a boolean true or false
5843
+ var doesMatch = matcher(params.term, child.text, child);
5844
+
5845
+ // If the child didn't match, pop it off
5846
+ if (!doesMatch) {
5847
+ match.children.splice(c, 1);
5848
+ }
5849
+ }
5850
+
5851
+ if (match.children.length > 0) {
5852
+ return match;
5853
+ }
5854
+ }
5855
+
5856
+ if (matcher(params.term, data.text, data)) {
5857
+ return match;
5858
+ }
5859
+
5860
+ return null;
5861
+ }
5862
+
5863
+ return wrappedMatcher;
5864
+ }
5865
+
5866
+ return oldMatcher;
5867
+ });
5868
+
5869
+ S2.define('pumselect2/compat/query',[
5870
+
5871
+ ], function () {
5872
+ function Query (decorated, $element, options) {
5873
+ if (options.get('debug') && window.console && console.warn) {
5874
+ console.warn(
5875
+ 'Select2: The `query` option has been deprecated in favor of a ' +
5876
+ 'custom data adapter that overrides the `query` method. Support ' +
5877
+ 'will be removed for the `query` option in future versions of ' +
5878
+ 'Select2.'
5879
+ );
5880
+ }
5881
+
5882
+ decorated.call(this, $element, options);
5883
+ }
5884
+
5885
+ Query.prototype.query = function (_, params, callback) {
5886
+ params.callback = callback;
5887
+
5888
+ var query = this.options.get('query');
5889
+
5890
+ query.call(null, params);
5891
+ };
5892
+
5893
+ return Query;
5894
+ });
5895
+
5896
+ S2.define('pumselect2/dropdown/attachContainer',[
5897
+
5898
+ ], function () {
5899
+ function AttachContainer (decorated, $element, options) {
5900
+ decorated.call(this, $element, options);
5901
+ }
5902
+
5903
+ AttachContainer.prototype.position =
5904
+ function (decorated, $dropdown, $container) {
5905
+ var $dropdownContainer = $container.find('.dropdown-wrapper');
5906
+ $dropdownContainer.append($dropdown);
5907
+
5908
+ $dropdown.addClass('pumselect2-dropdown--below');
5909
+ $container.addClass('pumselect2-container--below');
5910
+ };
5911
+
5912
+ return AttachContainer;
5913
+ });
5914
+
5915
+ S2.define('pumselect2/dropdown/stopPropagation',[
5916
+
5917
+ ], function () {
5918
+ function StopPropagation () { }
5919
+
5920
+ StopPropagation.prototype.bind = function (decorated, container, $container) {
5921
+ decorated.call(this, container, $container);
5922
+
5923
+ var stoppedEvents = [
5924
+ 'blur',
5925
+ 'change',
5926
+ 'click',
5927
+ 'dblclick',
5928
+ 'focus',
5929
+ 'focusin',
5930
+ 'focusout',
5931
+ 'input',
5932
+ 'keydown',
5933
+ 'keyup',
5934
+ 'keypress',
5935
+ 'mousedown',
5936
+ 'mouseenter',
5937
+ 'mouseleave',
5938
+ 'mousemove',
5939
+ 'mouseover',
5940
+ 'mouseup',
5941
+ 'search',
5942
+ 'touchend',
5943
+ 'touchstart'
5944
+ ];
5945
+
5946
+ this.$dropdown.on(stoppedEvents.join(' '), function (evt) {
5947
+ evt.stopPropagation();
5948
+ });
5949
+ };
5950
+
5951
+ return StopPropagation;
5952
+ });
5953
+
5954
+ S2.define('pumselect2/selection/stopPropagation',[
5955
+
5956
+ ], function () {
5957
+ function StopPropagation () { }
5958
+
5959
+ StopPropagation.prototype.bind = function (decorated, container, $container) {
5960
+ decorated.call(this, container, $container);
5961
+
5962
+ var stoppedEvents = [
5963
+ 'blur',
5964
+ 'change',
5965
+ 'click',
5966
+ 'dblclick',
5967
+ 'focus',
5968
+ 'focusin',
5969
+ 'focusout',
5970
+ 'input',
5971
+ 'keydown',
5972
+ 'keyup',
5973
+ 'keypress',
5974
+ 'mousedown',
5975
+ 'mouseenter',
5976
+ 'mouseleave',
5977
+ 'mousemove',
5978
+ 'mouseover',
5979
+ 'mouseup',
5980
+ 'search',
5981
+ 'touchend',
5982
+ 'touchstart'
5983
+ ];
5984
+
5985
+ this.$selection.on(stoppedEvents.join(' '), function (evt) {
5986
+ evt.stopPropagation();
5987
+ });
5988
+ };
5989
+
5990
+ return StopPropagation;
5991
+ });
5992
+
5993
+ /*!
5994
+ * jQuery Mousewheel 3.1.13
5995
+ *
5996
+ * Copyright jQuery Foundation and other contributors
5997
+ * Released under the MIT license
5998
+ * http://jquery.org/license
5999
+ */
6000
+
6001
+ (function (factory) {
6002
+ if ( typeof S2.define === 'function' && S2.define.amd ) {
6003
+ // AMD. Register as an anonymous module.
6004
+ S2.define('jquery-mousewheel',['jquery'], factory);
6005
+ } else if (typeof exports === 'object') {
6006
+ // Node/CommonJS style for Browserify
6007
+ module.exports = factory;
6008
+ } else {
6009
+ // Browser globals
6010
+ factory(jQuery);
6011
+ }
6012
+ }(function ($) {
6013
+
6014
+ var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
6015
+ toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
6016
+ ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
6017
+ slice = Array.prototype.slice,
6018
+ nullLowestDeltaTimeout, lowestDelta;
6019
+
6020
+ if ( $.event.fixHooks ) {
6021
+ for ( var i = toFix.length; i; ) {
6022
+ $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
6023
+ }
6024
+ }
6025
+
6026
+ var special = $.event.special.mousewheel = {
6027
+ version: '3.1.12',
6028
+
6029
+ setup: function() {
6030
+ if ( this.addEventListener ) {
6031
+ for ( var i = toBind.length; i; ) {
6032
+ this.addEventListener( toBind[--i], handler, false );
6033
+ }
6034
+ } else {
6035
+ this.onmousewheel = handler;
6036
+ }
6037
+ // Store the line height and page height for this particular element
6038
+ $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
6039
+ $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
6040
+ },
6041
+
6042
+ teardown: function() {
6043
+ if ( this.removeEventListener ) {
6044
+ for ( var i = toBind.length; i; ) {
6045
+ this.removeEventListener( toBind[--i], handler, false );
6046
+ }
6047
+ } else {
6048
+ this.onmousewheel = null;
6049
+ }
6050
+ // Clean up the data we added to the element
6051
+ $.removeData(this, 'mousewheel-line-height');
6052
+ $.removeData(this, 'mousewheel-page-height');
6053
+ },
6054
+
6055
+ getLineHeight: function(elem) {
6056
+ var $elem = $(elem),
6057
+ $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
6058
+ if (!$parent.length) {
6059
+ $parent = $('body');
6060
+ }
6061
+ return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
6062
+ },
6063
+
6064
+ getPageHeight: function(elem) {
6065
+ return $(elem).height();
6066
+ },
6067
+
6068
+ settings: {
6069
+ adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
6070
+ normalizeOffset: true // calls getBoundingClientRect for each event
6071
+ }
6072
+ };
6073
+
6074
+ $.fn.extend({
6075
+ mousewheel: function(fn) {
6076
+ return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
6077
+ },
6078
+
6079
+ unmousewheel: function(fn) {
6080
+ return this.unbind('mousewheel', fn);
6081
+ }
6082
+ });
6083
+
6084
+
6085
+ function handler(event) {
6086
+ var orgEvent = event || window.event,
6087
+ args = slice.call(arguments, 1),
6088
+ delta = 0,
6089
+ deltaX = 0,
6090
+ deltaY = 0,
6091
+ absDelta = 0,
6092
+ offsetX = 0,
6093
+ offsetY = 0;
6094
+ event = $.event.fix(orgEvent);
6095
+ event.type = 'mousewheel';
6096
+
6097
+ // Old school scrollwheel delta
6098
+ if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
6099
+ if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
6100
+ if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
6101
+ if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
6102
+
6103
+ // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
6104
+ if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
6105
+ deltaX = deltaY * -1;
6106
+ deltaY = 0;
6107
+ }
6108
+
6109
+ // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
6110
+ delta = deltaY === 0 ? deltaX : deltaY;
6111
+
6112
+ // New school wheel delta (wheel event)
6113
+ if ( 'deltaY' in orgEvent ) {
6114
+ deltaY = orgEvent.deltaY * -1;
6115
+ delta = deltaY;
6116
+ }
6117
+ if ( 'deltaX' in orgEvent ) {
6118
+ deltaX = orgEvent.deltaX;
6119
+ if ( deltaY === 0 ) { delta = deltaX * -1; }
6120
+ }
6121
+
6122
+ // No change actually happened, no reason to go any further
6123
+ if ( deltaY === 0 && deltaX === 0 ) { return; }
6124
+
6125
+ // Need to convert lines and pages to pixels if we aren't already in pixels
6126
+ // There are three delta modes:
6127
+ // * deltaMode 0 is by pixels, nothing to do
6128
+ // * deltaMode 1 is by lines
6129
+ // * deltaMode 2 is by pages
6130
+ if ( orgEvent.deltaMode === 1 ) {
6131
+ var lineHeight = $.data(this, 'mousewheel-line-height');
6132
+ delta *= lineHeight;
6133
+ deltaY *= lineHeight;
6134
+ deltaX *= lineHeight;
6135
+ } else if ( orgEvent.deltaMode === 2 ) {
6136
+ var pageHeight = $.data(this, 'mousewheel-page-height');
6137
+ delta *= pageHeight;
6138
+ deltaY *= pageHeight;
6139
+ deltaX *= pageHeight;
6140
+ }
6141
+
6142
+ // Store lowest absolute delta to normalize the delta values
6143
+ absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
6144
+
6145
+ if ( !lowestDelta || absDelta < lowestDelta ) {
6146
+ lowestDelta = absDelta;
6147
+
6148
+ // Adjust older deltas if necessary
6149
+ if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
6150
+ lowestDelta /= 40;
6151
+ }
6152
+ }
6153
+
6154
+ // Adjust older deltas if necessary
6155
+ if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
6156
+ // Divide all the things by 40!
6157
+ delta /= 40;
6158
+ deltaX /= 40;
6159
+ deltaY /= 40;
6160
+ }
6161
+
6162
+ // Get a whole, normalized value for the deltas
6163
+ delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
6164
+ deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
6165
+ deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
6166
+
6167
+ // Normalise offsetX and offsetY properties
6168
+ if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
6169
+ var boundingRect = this.getBoundingClientRect();
6170
+ offsetX = event.clientX - boundingRect.left;
6171
+ offsetY = event.clientY - boundingRect.top;
6172
+ }
6173
+
6174
+ // Add information to the event object
6175
+ event.deltaX = deltaX;
6176
+ event.deltaY = deltaY;
6177
+ event.deltaFactor = lowestDelta;
6178
+ event.offsetX = offsetX;
6179
+ event.offsetY = offsetY;
6180
+ // Go ahead and set deltaMode to 0 since we converted to pixels
6181
+ // Although this is a little odd since we overwrite the deltaX/Y
6182
+ // properties with normalized deltas.
6183
+ event.deltaMode = 0;
6184
+
6185
+ // Add event and delta to the front of the arguments
6186
+ args.unshift(event, delta, deltaX, deltaY);
6187
+
6188
+ // Clearout lowestDelta after sometime to better
6189
+ // handle multiple device types that give different
6190
+ // a different lowestDelta
6191
+ // Ex: trackpad = 3 and mouse wheel = 120
6192
+ if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
6193
+ nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
6194
+
6195
+ return ($.event.dispatch || $.event.handle).apply(this, args);
6196
+ }
6197
+
6198
+ function nullLowestDelta() {
6199
+ lowestDelta = null;
6200
+ }
6201
+
6202
+ function shouldAdjustOldDeltas(orgEvent, absDelta) {
6203
+ // If this is an older event and the delta is divisable by 120,
6204
+ // then we are assuming that the browser is treating this as an
6205
+ // older mouse wheel event and that we should divide the deltas
6206
+ // by 40 to try and get a more usable deltaFactor.
6207
+ // Side note, this actually impacts the reported scroll distance
6208
+ // in older browsers and can cause scrolling to be slower than native.
6209
+ // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
6210
+ return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
6211
+ }
6212
+
6213
+ }));
6214
+
6215
+ S2.define('jquery.pumselect2',[
6216
+ 'jquery',
6217
+ 'jquery-mousewheel',
6218
+
6219
+ './pumselect2/core',
6220
+ './pumselect2/defaults'
6221
+ ], function ($, _, Select2, Defaults) {
6222
+ if ($.fn.pumselect2 == null) {
6223
+ // All methods that should return the element
6224
+ var thisMethods = ['open', 'close', 'destroy'];
6225
+
6226
+ $.fn.pumselect2 = function (options) {
6227
+ options = options || {};
6228
+
6229
+ if (typeof options === 'object') {
6230
+ this.each(function () {
6231
+ var instanceOptions = $.extend(true, {}, options);
6232
+
6233
+ var instance = new Select2($(this), instanceOptions);
6234
+ });
6235
+
6236
+ return this;
6237
+ } else if (typeof options === 'string') {
6238
+ var ret;
6239
+
6240
+ this.each(function () {
6241
+ var instance = $(this).data('pumselect2');
6242
+
6243
+ if (instance == null && window.console && console.error) {
6244
+ console.error(
6245
+ 'The pumselect2(\'' + options + '\') method was called on an ' +
6246
+ 'element that is not using Select2.'
6247
+ );
6248
+ }
6249
+
6250
+ var args = Array.prototype.slice.call(arguments, 1);
6251
+
6252
+ ret = instance[options].apply(instance, args);
6253
+ });
6254
+
6255
+ // Check if we should be returning `this`
6256
+ if ($.inArray(options, thisMethods) > -1) {
6257
+ return this;
6258
+ }
6259
+
6260
+ return ret;
6261
+ } else {
6262
+ throw new Error('Invalid arguments for Select2: ' + options);
6263
+ }
6264
+ };
6265
+ }
6266
+
6267
+ if ($.fn.pumselect2.defaults == null) {
6268
+ $.fn.pumselect2.defaults = Defaults;
6269
+ }
6270
+
6271
+ return Select2;
6272
+ });
6273
+
6274
+ // Return the AMD loader configuration so it can be used outside of this file
6275
+ return {
6276
+ define: S2.define,
6277
+ require: S2.require
6278
+ };
6279
+ }());
6280
+
6281
+ // Autoload the jQuery bindings
6282
+ // We know that all of the modules exist above this, so we're safe
6283
+ var pumselect2 = S2.require('jquery.pumselect2');
6284
+
6285
+ // Hold the AMD module references on the jQuery function that was just loaded
6286
+ // This allows Select2 to use the internal loader outside of this file, such
6287
+ // as in the language files.
6288
+ jQuery.fn.pumselect2.amd = S2;
6289
+
6290
+ // Return the Select2 instance for anyone who is importing it.
6291
+ return pumselect2;
6292
  }));
6293
+ /*******************************************************************************
6294
+ * Copyright (c) 2017, WP Popup Maker
6295
+ ******************************************************************************/
6296
+ (function ($) {
6297
+ "use strict";
6298
+
6299
+ function dismissAlert($alert) {
6300
+ var dismissible = $alert.data('dismissible'),
6301
+ expires = dismissible === '1' || dismissible === 1 || dismissible === true ? null: dismissible;
6302
+
6303
+ $.ajax({
6304
+ method: "POST",
6305
+ dataType: "json",
6306
+ url: ajaxurl,
6307
+ data: {
6308
+ action: 'pum_alerts_action',
6309
+ nonce: window.pum_alerts_nonce,
6310
+ code: $alert.data('code'),
6311
+ expires: expires
6312
+ }
6313
+ });
6314
+ }
6315
+
6316
+ function dismissReviewRequest(reason) {
6317
+ $.ajax({
6318
+ method: "POST",
6319
+ dataType: "json",
6320
+ url: ajaxurl,
6321
+ data: {
6322
+ action: 'pum_review_action',
6323
+ nonce: window.pum_review_nonce,
6324
+ group: window.pum_review_trigger.group,
6325
+ code: window.pum_review_trigger.code,
6326
+ pri: window.pum_review_trigger.pri,
6327
+ reason: reason
6328
+ }
6329
+ });
6330
+
6331
+ if (typeof window.pum_review_api_url !== 'undefined') {
6332
+ $.ajax({
6333
+ method: "POST",
6334
+ dataType: "json",
6335
+ url: window.pum_review_api_url,
6336
+ data: {
6337
+ trigger_group: window.pum_review_trigger.group,
6338
+ trigger_code: window.pum_review_trigger.code,
6339
+ reason: reason,
6340
+ uuid: window.pum_review_uuid || null
6341
+ }
6342
+ });
6343
+ }
6344
+ }
6345
+
6346
+ var $alerts = $('.pum-alerts'),
6347
+ $notice_counts = $('.pum-alert-count'),
6348
+ count = parseInt($notice_counts.eq(0).text());
6349
+
6350
+ function checkRemoveAlerts() {
6351
+ if ($alerts.find('.pum-alert-holder').length === 0) {
6352
+ $alerts.slideUp(100, function () {
6353
+ $alerts.remove();
6354
+ });
6355
+
6356
+ $('#menu-posts-popup .wp-menu-name .update-plugins').fadeOut();
6357
+ }
6358
+
6359
+ }
6360
+
6361
+ function removeAlert($alert) {
6362
+ count--;
6363
+
6364
+ $notice_counts.text(count);
6365
+
6366
+ $alert.fadeTo(100, 0, function () {
6367
+ $alert.slideUp(100, function () {
6368
+ $alert.remove();
6369
+
6370
+ checkRemoveAlerts();
6371
+ });
6372
+ });
6373
+ }
6374
+
6375
+ $(document)
6376
+ .on('pumDismissAlert', checkRemoveAlerts)
6377
+ .on('click', '.pum-alert-holder .pum-dismiss', function () {
6378
+ var $this = $(this),
6379
+ $alert = $this.parents('.pum-alert-holder'),
6380
+ reason = $this.data('reason') || 'maybe_later';
6381
+
6382
+ if ( 'review_request' !== $alert.data('code')) {
6383
+ dismissAlert($alert);
6384
+ } else {
6385
+ dismissReviewRequest(reason);
6386
+ }
6387
+
6388
+ removeAlert($alert);
6389
+
6390
+ });
6391
  }(jQuery));
6392
+ /*******************************************************************************
6393
+ * Copyright (c) 2017, WP Popup Maker
6394
+ ******************************************************************************/
6395
+ (function ($) {
6396
+ "use strict";
6397
+
6398
+ var colorpicker = {
6399
+ init: function () {
6400
+ $('.pum-color-picker').filter(':not(.pum-color-picker-initialized)')
6401
+ .addClass('pum-color-picker-initialized')
6402
+ .wpColorPicker({
6403
+ change: function (event, ui) {
6404
+ $(event.target).trigger('colorchange', ui);
6405
+ },
6406
+ clear: function (event) {
6407
+ $(event.target).prev().trigger('colorchange').wpColorPicker('close');
6408
+ },
6409
+ hide: true
6410
+ });
6411
+ }
6412
+ };
6413
+
6414
+ // Import this module.
6415
+ window.PUM_Admin = window.PUM_Admin || {};
6416
+ window.PUM_Admin.colorpicker = colorpicker;
6417
+
6418
+ $(document)
6419
+ .on('click', '.iris-palette', function () {
6420
+ $(this).parents('.wp-picker-active').find('input.pum-color-picker').trigger('change');
6421
+ })
6422
+ .on('colorchange', function (event, ui) {
6423
+ var $input = $(event.target),
6424
+ color = '';
6425
+
6426
+ if (ui !== undefined && ui.color !== undefined) {
6427
+ color = ui.color.toString();
6428
+ }
6429
+
6430
+ $input.val(color).trigger('change');
6431
+
6432
+ if ($('form#post input#post_type').val() === 'popup_theme') {
6433
+ PUM_Admin.utils.debounce(PUM_Admin.themeEditor.refresh_preview, 100);
6434
+ }
6435
+ })
6436
+ .on('pum_init', colorpicker.init);
6437
  }(jQuery));
6438
+ /*******************************************************************************
6439
+ * Copyright (c) 2017, WP Popup Maker
6440
+ ******************************************************************************/
6441
+
6442
+ (function ($) {
6443
+ "use strict";
6444
+
6445
+ var forms = {
6446
+ init: function () {
6447
+ forms.checkDependencies();
6448
+ },
6449
+ /**
6450
+ * dependencies should look like this:
6451
+ *
6452
+ * {
6453
+ * field_name_1: value, // Select, radio etc.
6454
+ * field_name_2: true // Checkbox
6455
+ * }
6456
+ *
6457
+ * Support for Multiple possible values of one field
6458
+ *
6459
+ * {
6460
+ * field_name_1: [ value_1, value_2 ]
6461
+ * }
6462
+ *
6463
+ */
6464
+ checkDependencies: function ($dependent_fields) {
6465
+ var _fields = $($dependent_fields);
6466
+
6467
+ // If no fields passed, only do those not already initialized.
6468
+ $dependent_fields = _fields.length ? _fields : $("[data-pum-dependencies]:not([data-pum-processed-dependencies])");
6469
+
6470
+ $dependent_fields.each(function () {
6471
+ var $dependent = $(this),
6472
+ dependentID = $dependent.data('id'),
6473
+ // The dependency object for this field.
6474
+ dependencies = $dependent.data("pum-processed-dependencies") || {},
6475
+ // Total number of fields this :input is dependent on.
6476
+ requiredCount = Object.keys(dependencies).length,
6477
+ // Current count of fields this :input matched properly.
6478
+ count = 0,
6479
+ // An array of fields this :input is dependent on.
6480
+ dependentFields = $dependent.data("pum-dependent-fields"),
6481
+ // Early declarations.
6482
+ key;
6483
+
6484
+ // Clean up & pre-process dependencies so we don't need to rebuild each time.
6485
+ if (!$dependent.data("pum-processed-dependencies")) {
6486
+ dependencies = $dependent.data("pum-dependencies");
6487
+ if (typeof dependencies === 'string') {
6488
+ dependencies = JSON.parse(dependencies);
6489
+ }
6490
+
6491
+ // Convert each key to an array of acceptable values.
6492
+ for (key in dependencies) {
6493
+ if (dependencies.hasOwnProperty(key)) {
6494
+ if (typeof dependencies[key] === "string") {
6495
+ // Leave boolean values alone as they are for checkboxes or checking if an input has any value.
6496
+
6497
+ if (dependencies[key].indexOf(',') !== -1) {
6498
+ dependencies[key] = dependencies[key].split(',');
6499
+ } else {
6500
+ dependencies[key] = [dependencies[key]];
6501
+ }
6502
+ } else if (typeof dependencies[key] === "number") {
6503
+ dependencies[key] = [dependencies[key]];
6504
+ }
6505
+ }
6506
+ }
6507
+
6508
+ // Update cache & counts.
6509
+ requiredCount = Object.keys(dependencies).length;
6510
+ $dependent.data("pum-processed-dependencies", dependencies).attr("data-pum-processed-dependencies", dependencies);
6511
+ }
6512
+
6513
+ if (!dependentFields) {
6514
+ dependentFields = $.map(dependencies, function (value, index) {
6515
+ var $wrapper = $('.pum-field[data-id="' + index + '"]');
6516
+
6517
+ return $wrapper.length ? $wrapper.eq(0) : null;
6518
+ });
6519
+
6520
+ $dependent.data("pum-dependent-fields", dependentFields);
6521
+ }
6522
+
6523
+ $(dependentFields).each(function () {
6524
+ var $wrapper = $(this),
6525
+ $field = $wrapper.find(':input:first'),
6526
+ id = $wrapper.data("id"),
6527
+ value = $field.val(),
6528
+ required = dependencies[id],
6529
+ matched,
6530
+ // Used for limiting the fields that get updated when this field is changed.
6531
+ all_this_fields_dependents = $wrapper.data('pum-field-dependents') || [];
6532
+
6533
+ if (all_this_fields_dependents.indexOf(dependentID) === -1) {
6534
+ all_this_fields_dependents.push(dependentID);
6535
+ $wrapper.data('pum-field-dependents', all_this_fields_dependents);
6536
+ }
6537
+
6538
+ // If no required values found bail early.
6539
+ if (typeof required === 'undefined' || required === null) {
6540
+ $dependent.removeClass('pum-dependencies-met').hide(0).trigger('pumFormDependencyUnmet');
6541
+ // Effectively breaks the .each for this $dependent and hides it.
6542
+ return false;
6543
+ }
6544
+
6545
+ if ($wrapper.hasClass('pum-field-radio')) {
6546
+ value = $wrapper.find(':input:checked').val();
6547
+ }
6548
+
6549
+ if ($wrapper.hasClass('pum-field-multicheck')) {
6550
+ value = [];
6551
+ $wrapper.find(':checkbox:checked').each(function (i) {
6552
+ value[i] = $(this).val();
6553
+
6554
+ if (typeof value[i] === 'string' && !isNaN(parseInt(value[i]))) {
6555
+ value[i] = parseInt(value[i]);
6556
+ }
6557
+
6558
+ });
6559
+ }
6560
+
6561
+ // Check if the value matches required values.
6562
+ if ($wrapper.hasClass('pum-field-select') || $wrapper.hasClass('pum-field-radio')) {
6563
+ matched = required && required.indexOf(value) !== -1;
6564
+ } else if ($wrapper.hasClass('pum-field-checkbox')) {
6565
+ matched = required === $field.is(':checked');
6566
+ } else if ($wrapper.hasClass('pum-field-multicheck')) {
6567
+ if (Array.isArray(required)) {
6568
+ matched = false;
6569
+ for (var i = 0; i < required.length; i++) {
6570
+ if (value.indexOf(required[i]) !== -1) {
6571
+ matched = true;
6572
+ }
6573
+ }
6574
+ } else {
6575
+ matched = value.indexOf(required) !== -1;
6576
+ }
6577
+ } else {
6578
+ matched = Array.isArray(required) ? required.indexOf(value) !== -1 : required == value;
6579
+ }
6580
+
6581
+ if (matched) {
6582
+ count++;
6583
+ } else {
6584
+ $dependent.removeClass('pum-dependencies-met').hide(0).trigger('pumFormDependencyUnmet');
6585
+ // Effectively breaks the .each for this $dependent and hides it.
6586
+ return false;
6587
+ }
6588
+
6589
+ if (count === requiredCount) {
6590
+ $dependent.addClass('pum-dependencies-met').show(0).trigger('pumFormDependencyMet');
6591
+ }
6592
+ });
6593
+ });
6594
+ },
6595
+ form_check: function () {
6596
+ $(document).trigger('pum_form_check');
6597
+ },
6598
+ is_field: function (data) {
6599
+ if (typeof data !== 'object') {
6600
+ return false;
6601
+ }
6602
+
6603
+ var field_tests = [
6604
+ data.type === undefined && (data.label !== undefined || data.desc !== undefined),
6605
+ data.type !== undefined && typeof data.type === 'string'
6606
+ ];
6607
+
6608
+ return field_tests.indexOf(true) >= 0;
6609
+ },
6610
+ flattenFields: function (data) {
6611
+ var form_fields = {},
6612
+ tabs = data.tabs || {},
6613
+ sections = data.sections || {},
6614
+ fields = data.fields || {};
6615
+
6616
+ if (Object.keys(tabs).length && Object.keys(sections).length) {
6617
+ // Loop Tabs
6618
+ _.each(fields, function (subTabs, tabID) {
6619
+
6620
+ // If not a valid tab or no subsections skip it.
6621
+ if (typeof subTabs !== 'object' || !Object.keys(subTabs).length) {
6622
+ return;
6623
+ }
6624
+
6625
+ // Loop Tab Sections
6626
+ _.each(subTabs, function (subTabFields, subTabID) {
6627
+
6628
+ // If not a valid subtab or no fields skip it.
6629
+ if (typeof subTabFields !== 'object' || !Object.keys(subTabFields).length) {
6630
+ return;
6631
+ }
6632
+
6633
+ // Move single fields into the main subtab.
6634
+ if (forms.is_field(subTabFields)) {
6635
+ var newSubTabFields = {};
6636
+ newSubTabFields[subTabID] = subTabFields;
6637
+ subTabID = 'main';
6638
+ subTabFields = newSubTabFields;
6639
+ }
6640
+
6641
+ // Loop Tab Section Fields
6642
+ _.each(subTabFields, function (field) {
6643
+ // Store the field by id for easy lookup later.
6644
+ form_fields[field.id] = field;
6645
+ });
6646
+ });
6647
+ });
6648
+ }
6649
+ else if (Object.keys(tabs).length) {
6650
+ // Loop Tabs
6651
+ _.each(fields, function (tabFields, tabID) {
6652
+
6653
+ // If not a valid tab or no subsections skip it.
6654
+ if (typeof tabFields !== 'object' || !Object.keys(tabFields).length) {
6655
+ return;
6656
+ }
6657
+
6658
+ // Loop Tab Fields
6659
+ _.each(tabFields, function (field) {
6660
+ // Store the field by id for easy lookup later.
6661
+ form_fields[field.id] = field;
6662
+ });
6663
+ });
6664
+ }
6665
+ else if (Object.keys(sections).length) {
6666
+
6667
+ // Loop Sections
6668
+ _.each(fields, function (sectionFields, sectionID) {
6669
+ // Loop Tab Section Fields
6670
+ _.each(sectionFields, function (field) {
6671
+ // Store the field by id for easy lookup later.
6672
+ form_fields[field.id] = field;
6673
+ });
6674
+ });
6675
+ }
6676
+ else {
6677
+ fields = forms.parseFields(fields, values);
6678
+
6679
+ // Replace the array with rendered fields.
6680
+ _.each(fields, function (field) {
6681
+ // Store the field by id for easy lookup later.
6682
+ form_fields[field.id] = field;
6683
+ });
6684
+ }
6685
+
6686
+ return form_fields;
6687
+ },
6688
+ parseFields: function (fields, values) {
6689
+
6690
+ values = values || {};
6691
+
6692
+ _.each(fields, function (field, fieldID) {
6693
+
6694
+ fields[fieldID] = PUM_Admin.models.field(field);
6695
+
6696
+ if (typeof fields[fieldID].meta !== 'object') {
6697
+ fields[fieldID].meta = {};
6698
+ }
6699
+
6700
+ if (undefined !== values[fieldID]) {
6701
+ fields[fieldID].value = values[fieldID];
6702
+ }
6703
+
6704
+ if (fields[fieldID].id === '') {
6705
+ fields[fieldID].id = fieldID;
6706
+ }
6707
+ });
6708
+
6709
+ return fields;
6710
+ },
6711
+ renderTab: function () {
6712
+
6713
+ },
6714
+ renderSection: function () {
6715
+
6716
+ },
6717
+ render: function (args, values, $container) {
6718
+ var form,
6719
+ sections = {},
6720
+ section = [],
6721
+ form_fields = {},
6722
+ data = $.extend(true, {
6723
+ id: "",
6724
+ tabs: {},
6725
+ sections: {},
6726
+ fields: {},
6727
+ maintabs: {},
6728
+ subtabs: {}
6729
+ }, args),
6730
+ maintabs = $.extend({
6731
+ id: data.id,
6732
+ classes: [],
6733
+ tabs: {},
6734
+ vertical: true,
6735
+ form: true,
6736
+ meta: {
6737
+ 'data-min-height': 250
6738
+ }
6739
+ }, data.maintabs),
6740
+ subtabs = $.extend({
6741
+ classes: ['link-tabs', 'sub-tabs'],
6742
+ tabs: {}
6743
+ }, data.subtabs),
6744
+ container_classes = ['pum-dynamic-form'];
6745
+
6746
+ values = values || {};
6747
+
6748
+ if (Object.keys(data.tabs).length && Object.keys(data.sections).length) {
6749
+ container_classes.push('tabbed-content');
6750
+
6751
+ // Loop Tabs
6752
+ _.each(data.fields, function (subTabs, tabID) {
6753
+
6754
+ // If not a valid tab or no subsections skip it.
6755
+ if (typeof subTabs !== 'object' || !Object.keys(subTabs).length) {
6756
+ return;
6757
+ }
6758
+
6759
+ // Define this tab.
6760
+ if (undefined === maintabs.tabs[tabID]) {
6761
+ maintabs.tabs[tabID] = {
6762
+ label: data.tabs[tabID],
6763
+ content: ''
6764
+ };
6765
+ }
6766
+
6767
+ // Define the sub tabs model.
6768
+ subtabs = $.extend(subtabs, {
6769
+ id: data.id + '-' + tabID + '-subtabs',
6770
+ tabs: {}
6771
+ });
6772
+
6773
+ // Loop Tab Sections
6774
+ _.each(subTabs, function (subTabFields, subTabID) {
6775
+
6776
+ // If not a valid subtab or no fields skip it.
6777
+ if (typeof subTabFields !== 'object' || !Object.keys(subTabFields).length) {
6778
+ return;
6779
+ }
6780
+
6781
+ // Move single fields into the main subtab.
6782
+ if (forms.is_field(subTabFields)) {
6783
+ var newSubTabFields = {};
6784
+ newSubTabFields[subTabID] = subTabFields;
6785
+ subTabID = 'main';
6786
+ subTabFields = newSubTabFields;
6787
+ }
6788
+
6789
+ // Define this subtab model.
6790
+ if (undefined === subtabs.tabs[subTabID]) {
6791
+ subtabs.tabs[subTabID] = {
6792
+ label: data.sections[tabID][subTabID],
6793
+ content: ''
6794
+ };
6795
+ }
6796
+
6797
+ subTabFields = forms.parseFields(subTabFields, values);
6798
+
6799
+ // Loop Tab Section Fields
6800
+ _.each(subTabFields, function (field) {
6801
+ // Store the field by id for easy lookup later.
6802
+ form_fields[field.id] = field;
6803
+
6804
+ // Push rendered fields into the subtab content.
6805
+ subtabs.tabs[subTabID].content += PUM_Admin.templates.field(field);
6806
+ });
6807
+
6808
+ // Remove any empty tabs.
6809
+ if ("" === subtabs.tabs[subTabID].content) {
6810
+ delete subtabs.tabs[subTabID];
6811
+ }
6812
+ });
6813
+
6814
+ // If there are subtabs, then render them into the main tabs content, otherwise remove this main tab.
6815
+ if (Object.keys(subtabs.tabs).length) {
6816
+ maintabs.tabs[tabID].content = PUM_Admin.templates.tabs(subtabs);
6817
+ } else {
6818
+ delete maintabs.tabs[tabID];
6819
+ }
6820
+ });
6821
+
6822
+ if (Object.keys(maintabs.tabs).length) {
6823
+ form = PUM_Admin.templates.tabs(maintabs);
6824
+ }
6825
+ }
6826
+ else if (Object.keys(data.tabs).length) {
6827
+ container_classes.push('tabbed-content');
6828
+
6829
+ // Loop Tabs
6830
+ _.each(data.fields, function (tabFields, tabID) {
6831
+
6832
+ // If not a valid tab or no subsections skip it.
6833
+ if (typeof tabFields !== 'object' || !Object.keys(tabFields).length) {
6834
+ return;
6835
+ }
6836
+
6837
+ // Define this tab.
6838
+ if (undefined === maintabs.tabs[tabID]) {
6839
+ maintabs.tabs[tabID] = {
6840
+ label: data.tabs[tabID],
6841
+ content: ''
6842
+ };
6843
+ }
6844
+
6845
+ section = [];
6846
+
6847
+ tabFields = forms.parseFields(tabFields, values);
6848
+
6849
+ // Loop Tab Fields
6850
+ _.each(tabFields, function (field) {
6851
+ // Store the field by id for easy lookup later.
6852
+ form_fields[field.id] = field;
6853
+
6854
+ // Push rendered fields into the subtab content.
6855
+ section.push(PUM_Admin.templates.field(field));
6856
+ });
6857
+
6858
+ // Push rendered tab into the tab.
6859
+ if (section.length) {
6860
+ // Push rendered sub tabs into the main tabs if not empty.
6861
+ maintabs.tabs[tabID].content = PUM_Admin.templates.section({
6862
+ fields: section
6863
+ });
6864
+ } else {
6865
+ delete (maintabs.tabs[tabID]);
6866
+ }
6867
+ });
6868
+
6869
+ if (Object.keys(maintabs.tabs).length) {
6870
+ form = PUM_Admin.templates.tabs(maintabs);
6871
+ }
6872
+ }
6873
+ else if (Object.keys(data.sections).length) {
6874
+
6875
+ // Loop Sections
6876
+ _.each(data.fields, function (sectionFields, sectionID) {
6877
+ section = [];
6878
+
6879
+ section.push(PUM_Admin.templates.field({
6880
+ type: 'heading',
6881
+ desc: data.sections[sectionID] || ''
6882
+ }));
6883
+
6884
+ sectionFields = forms.parseFields(sectionFields, values);
6885
+
6886
+ // Loop Tab Section Fields
6887
+ _.each(sectionFields, function (field) {
6888
+ // Store the field by id for easy lookup later.
6889
+ form_fields[field.id] = field;
6890
+
6891
+ // Push rendered fields into the section.
6892
+ section.push(PUM_Admin.templates.field(field));
6893
+ });
6894
+
6895
+ // Push rendered sections into the form.
6896
+ form += PUM_Admin.templates.section({
6897
+ fields: section
6898
+ });
6899
+ });
6900
+ }
6901
+ else {
6902
+ data.fields = forms.parseFields(data.fields, values);
6903
+
6904
+ // Replace the array with rendered fields.
6905
+ _.each(data.fields, function (field) {
6906
+ // Store the field by id for easy lookup later.
6907
+ form_fields[field.id] = field;
6908
+
6909
+ // Push rendered fields into the section.
6910
+ section.push(PUM_Admin.templates.field(field));
6911
+ });
6912
+
6913
+ // Render the section.
6914
+ form = PUM_Admin.templates.section({
6915
+ fields: section
6916
+ });
6917
+ }
6918
+
6919
+ if ($container !== undefined && $container.length) {
6920
+ $container
6921
+ .addClass(container_classes.join(' '))
6922
+ .data('form_fields', form_fields)
6923
+ .html(form)
6924
+ .trigger('pum_init');
6925
+ }
6926
+
6927
+ return form;
6928
+
6929
+ },
6930
+ parseValues: function (values, fields) {
6931
+ fields = fields || false
6932
+
6933
+ if (!fields) {
6934
+ return values;
6935
+ }
6936
+
6937
+ debugger;
6938
+
6939
+ for (var key in fields) {
6940
+ if (!fields.hasOwnProperty(key)) {
6941
+ continue;
6942
+ }
6943
+
6944
+ // Measure field value corrections.
6945
+ if (values.hasOwnProperty(key + "_unit")) {
6946
+ values[key] += values[key + "_unit"];
6947
+ delete values[key + "_unit"];
6948
+ }
6949
+
6950
+ // If the value key is empty and a checkbox set it to false. Then return.
6951
+ if (typeof values[key] === 'undefined') {
6952
+ if (fields[key].type === 'checkbox') {
6953
+ values[key] = false;
6954
+ }
6955
+ continue;
6956
+ }
6957
+
6958
+ if (fields[key].allow_html && !PUM_Admin.utils.htmlencoder.hasEncoded(values[key])) {
6959
+ values[key] = PUM_Admin.utils.htmlencoder.htmlEncode(values[key]);
6960
+ }
6961
+ }
6962
+
6963
+ return values;
6964
+ }
6965
+ };
6966
+
6967
+ // Import this module.
6968
+ window.PUM_Admin = window.PUM_Admin || {};
6969
+ window.PUM_Admin.forms = forms;
6970
+
6971
+ $(document)
6972
+ .on('pum_init pum_form_check', function () {
6973
+ PUM_Admin.forms.init();
6974
+ })
6975
+ .on('pumFieldChanged', '.pum-field', function () {
6976
+ var $wrapper = $(this),
6977
+ dependent_field_ids = $wrapper.data('pum-field-dependents') || [],
6978
+ $fields_with_dependencies = $(),
6979
+ i;
6980
+
6981
+ if (!dependent_field_ids || dependent_field_ids.length <= 0) {
6982
+ return;
6983
+ }
6984
+
6985
+ for (i = 0; i < dependent_field_ids.length; i++) {
6986
+ $fields_with_dependencies = $fields_with_dependencies.add('.pum-field[data-id="' + dependent_field_ids[i] + '"]');
6987
+ }
6988
+
6989
+ PUM_Admin.forms.checkDependencies($fields_with_dependencies);
6990
+ })
6991
+ .on('pumFieldChanged', '.pum-field-dynamic-desc', function () {
6992
+ var $this = $(this),
6993
+ $input = $this.find(':input'),
6994
+ $container = $this.parents('.pum-dynamic-form:first'),
6995
+ val = $input.val(),
6996
+ form_fields = $container.data('form_fields') || {},
6997
+ field = form_fields[$this.data('id')] || {},
6998
+ $desc = $this.find('.pum-desc'),
6999
+ desc = $this.data('pum-dynamic-desc');
7000
+
7001
+ switch (field.type) {
7002
+ case 'radio':
7003
+ val = $this.find(':input:checked').val();
7004
+ break;
7005
+ }
7006
+
7007
+ field.value = val;
7008
+
7009
+ if (desc && desc.length) {
7010
+ $desc.html(PUM_Admin.templates.renderInline(desc, field));
7011
+ }
7012
+ })
7013
+ .on('change', '.pum-field-select select', function () {
7014
+ $(this).parents('.pum-field').trigger('pumFieldChanged');
7015
+ })
7016
+ .on('click', '.pum-field-checkbox input', function () {
7017
+ $(this).parents('.pum-field').trigger('pumFieldChanged');
7018
+ })
7019
+ .on('click', '.pum-field-multicheck input', function () {
7020
+ $(this).parents('.pum-field').trigger('pumFieldChanged');
7021
+ })
7022
+ .on('click', '.pum-field-radio input', function (event) {
7023
+ var $this = $(this),
7024
+ $selected = $this.parents('li'),
7025
+ $wrapper = $this.parents('.pum-field');
7026
+
7027
+ $wrapper.trigger('pumFieldChanged');
7028
+
7029
+ $wrapper.find('li.pum-selected').removeClass('pum-selected');
7030
+
7031
+ $selected.addClass('pum-selected');
7032
+ });
7033
+
7034
  }(jQuery));
7035
+ function pumSelected(val1, val2, print) {
7036
+ "use strict";
7037
+
7038
+ var selected = false;
7039
+ if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
7040
+ selected = true;
7041
+ } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
7042
+ selected = true;
7043
+ } else if (val1 === val2) {
7044
+ selected = true;
7045
+ }
7046
+
7047
+ if (print !== undefined && print) {
7048
+ return selected ? ' selected="selected"' : '';
7049
+ }
7050
+ return selected;
7051
+ }
7052
+
7053
+ function pumChecked(val1, val2, print) {
7054
+ "use strict";
7055
+
7056
+ var checked = false;
7057
+ if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
7058
+ checked = true;
7059
+ } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
7060
+ checked = true;
7061
+ } else if (val1 === val2) {
7062
+ checked = true;
7063
+ }
7064
+
7065
+ if (print !== undefined && print) {
7066
+ return checked ? ' checked="checked"' : '';
7067
+ }
7068
+ return checked;
7069
+ }
7070
+
7071
+ /*******************************************************************************
7072
+ * Copyright (c) 2017, WP Popup Maker
7073
+ ******************************************************************************/
7074
+ (function ($) {
7075
+ "use strict";
7076
+
7077
+ var $html = $('html'),
7078
+ $document = $(document),
7079
+ $top_level_elements,
7080
+ focusableElementsString = "a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",
7081
+ previouslyFocused,
7082
+ modals = {
7083
+ _current: null,
7084
+ // Accessibility: Checks focus events to ensure they stay inside the modal.
7085
+ forceFocus: function (event) {
7086
+ if (PUM_Admin.modals._current && !PUM_Admin.modals._current.contains(event.target)) {
7087
+ event.stopPropagation();
7088
+ PUM_Admin.modals._current.focus();
7089
+ }
7090
+ },
7091
+ trapEscapeKey: function (e) {
7092
+ if (e.keyCode === 27) {
7093
+ PUM_Admin.modals.closeAll();
7094
+ e.preventDefault();
7095
+ }
7096
+ },
7097
+ trapTabKey: function (e) {
7098
+ // if tab or shift-tab pressed
7099
+ if (e.keyCode === 9) {
7100
+ // get list of focusable items
7101
+ var focusableItems = PUM_Admin.modals._current.find('*').filter(focusableElementsString).filter(':visible'),
7102
+ // get currently focused item
7103
+ focusedItem = $(':focus'),
7104
+ // get the number of focusable items
7105
+ numberOfFocusableItems = focusableItems.length,
7106
+ // get the index of the currently focused item
7107
+ focusedItemIndex = focusableItems.index(focusedItem);
7108
+
7109
+ if (e.shiftKey) {
7110
+ //back tab
7111
+ // if focused on first item and user preses back-tab, go to the last focusable item
7112
+ if (focusedItemIndex === 0) {
7113
+ focusableItems.get(numberOfFocusableItems - 1).focus();
7114
+ e.preventDefault();
7115
+ }
7116
+ } else {
7117
+ //forward tab
7118
+ // if focused on the last item and user preses tab, go to the first focusable item
7119
+ if (focusedItemIndex === numberOfFocusableItems - 1) {
7120
+ focusableItems.get(0).focus();
7121
+ e.preventDefault();
7122
+ }
7123
+ }
7124
+ }
7125
+ },
7126
+ setFocusToFirstItem: function () {
7127
+ // set focus to first focusable item
7128
+ PUM_Admin.modals._current.find('.pum-modal-content *').filter(focusableElementsString).filter(':visible').first().focus();
7129
+ },
7130
+ closeAll: function (callback) {
7131
+ $('.pum-modal-background')
7132
+ .off('keydown.pum_modal')
7133
+ .hide(0, function () {
7134
+ $('html').css({overflow: 'visible', width: 'auto'});
7135
+
7136
+ if ($top_level_elements) {
7137
+ $top_level_elements.attr('aria-hidden', 'false');
7138
+ $top_level_elements = null;
7139
+ }
7140
+
7141
+ // Accessibility: Focus back on the previously focused element.
7142
+ if (previouslyFocused.length) {
7143
+ previouslyFocused.focus();
7144
+ }
7145
+
7146
+ // Accessibility: Clears the PUM_Admin.modals._current var.
7147
+ PUM_Admin.modals._current = null;
7148
+
7149
+ // Accessibility: Removes the force focus check.
7150
+ $document.off('focus.pum_modal');
7151
+ if (undefined !== callback) {
7152
+ callback();
7153
+ }
7154
+ })
7155
+ .attr('aria-hidden', 'true');
7156
+
7157
+ },
7158
+ show: function (modal, callback) {
7159
+ $('.pum-modal-background')
7160
+ .off('keydown.pum_modal')
7161
+ .hide(0)
7162
+ .attr('aria-hidden', 'true');
7163
+
7164
+ $html
7165
+ .data('origwidth', $html.innerWidth())
7166
+ .css({overflow: 'hidden', 'width': $html.innerWidth()});
7167
+
7168
+ // Accessibility: Sets the previous focus element.
7169
+
7170
+ var $focused = $(':focus');
7171
+ if (!$focused.parents('.pum-modal-wrap').length) {
7172
+ previouslyFocused = $focused;
7173
+ }
7174
+
7175
+ // Accessibility: Sets the current modal for focus checks.
7176
+ PUM_Admin.modals._current = $(modal);
7177
+
7178
+ // Accessibility: Close on esc press.
7179
+ PUM_Admin.modals._current
7180
+ .on('keydown.pum_modal', function (e) {
7181
+ PUM_Admin.modals.trapEscapeKey(e);
7182
+ PUM_Admin.modals.trapTabKey(e);
7183
+ })
7184
+ .show(0, function () {
7185
+ $top_level_elements = $('body > *').filter(':visible').not(PUM_Admin.modals._current);
7186
+ $top_level_elements.attr('aria-hidden', 'true');
7187
+
7188
+ PUM_Admin.modals._current
7189
+ .trigger('pum_init')
7190
+ // Accessibility: Add focus check that prevents tabbing outside of modal.
7191
+ .on('focus.pum_modal', PUM_Admin.modals.forceFocus);
7192
+
7193
+ // Accessibility: Focus on the modal.
7194
+ PUM_Admin.modals.setFocusToFirstItem();
7195
+
7196
+ if (undefined !== callback) {
7197
+ callback();
7198
+ }
7199
+ })
7200
+ .attr('aria-hidden', 'false');
7201
+
7202
+ },
7203
+ remove: function (modal) {
7204
+ $(modal).remove();
7205
+ },
7206
+ replace: function (modal, replacement) {
7207
+ PUM_Admin.modals.remove($.trim(modal));
7208
+ $('body').append($.trim(replacement));
7209
+ },
7210
+ reload: function (modal, replacement, callback) {
7211
+ PUM_Admin.modals.replace(modal, replacement);
7212
+ PUM_Admin.modals.show(modal, callback);
7213
+ $(modal).trigger('pum_init');
7214
+ }
7215
+ };
7216
+
7217
+ // Import this module.
7218
+ window.PUM_Admin = window.PUM_Admin || {};
7219
+ window.PUM_Admin.modals = modals;
7220
+
7221
+ $(document).on('click', '.pum-modal-background, .pum-modal-wrap .cancel, .pum-modal-wrap .pum-modal-close', function (e) {
7222
+ var $target = $(e.target);
7223
+ if (/*$target.hasClass('pum-modal-background') || */$target.hasClass('cancel') || $target.hasClass('pum-modal-close') || $target.hasClass('submitdelete')) {
7224
+ PUM_Admin.modals.closeAll();
7225
+ e.preventDefault();
7226
+ e.stopPropagation();
7227
+ }
7228
+ });
7229
+
7230
  }(jQuery));
7231
+ /*******************************************************************************
7232
+ * Copyright (c) 2017, WP Popup Maker
7233
+ ******************************************************************************/
7234
+ (function ($) {
7235
+ "use strict";
7236
+
7237
+ var models = {
7238
+ field: function (args) {
7239
+ return $.extend(true, {}, {
7240
+ type: 'text',
7241
+ id: '',
7242
+ id_prefix: '',
7243
+ name: '',
7244
+ label: null,
7245
+ placeholder: '',
7246
+ desc: null,
7247
+ dynamic_desc: null,
7248
+ size: 'regular',
7249
+ classes: [],
7250
+ dependencies: "",
7251
+ value: null,
7252
+ select2: false,
7253
+ allow_html: false,
7254
+ multiple: false,
7255
+ as_array: false,
7256
+ options: [],
7257
+ object_type: null,
7258
+ object_key: null,
7259
+ std: null,
7260
+ min: 0,
7261
+ max: 50,
7262
+ force_minmax: false,
7263
+ step: 1,
7264
+ unit: 'px',
7265
+ units: {},
7266
+ required: false,
7267
+ desc_position: 'bottom',
7268
+ meta: {}
7269
+ }, args);
7270
+ }
7271
+ };
7272
+
7273
+ // Import this module.
7274
+ window.PUM_Admin = window.PUM_Admin || {};
7275
+ window.PUM_Admin.models = models;
7276
  }(jQuery));
7277
+ /*******************************************************************************
7278
+ * Copyright (c) 2017, WP Popup Maker
7279
+ ******************************************************************************/
7280
+ (function ($) {
7281
+ 'use strict';
7282
+ var rangesliders = {
7283
+ cloneables: {
7284
+ slider: $('<input type="range" class="pum-range-slider" />'),
7285
+ plus: $('<button type="button" class="pum-range-plus">+</button>'),
7286
+ minus: $('<button type="button" class="pum-range-minus">-</button>')
7287
+ },
7288
+ init: function () {
7289
+ $('.pum-field-rangeslider:not(.pum-rangeslider-initialized)').each(function () {
7290
+ var $this = $(this).addClass('pum-rangeslider-initialized'),
7291
+ $input = $this.find('input.pum-range-manual'),
7292
+ $slider = rangesliders.cloneables.slider.clone(),
7293
+ $plus = rangesliders.cloneables.plus.clone(),
7294
+ $minus = rangesliders.cloneables.minus.clone(),
7295
+ settings = {
7296
+ force: $input.data('force-minmax'),
7297
+ min: parseInt($input.attr('min'), 10) || 0,
7298
+ max: parseInt($input.attr('max'), 10) || 100,
7299
+ step: parseInt($input.attr('step'), 10) || 1,
7300
+ value: parseInt($input.attr('value'), 10) || 0
7301
+ };
7302
+
7303
+ if (settings.force && settings.value > settings.max) {
7304
+ settings.value = settings.max;
7305
+ $input.val(settings.value);
7306
+ }
7307
+
7308
+ $slider.prop({
7309
+ min: settings.min || 0,
7310
+ max: (settings.force || (settings.max && settings.max > settings.value)) ? settings.max : settings.value *
7311
+ 1.5,
7312
+ step: settings.step || settings.value * 1.5 / 100,
7313
+ value: settings.value
7314
+ }).on('change input', function () {
7315
+ $input.trigger('input');
7316
+ });
7317
+
7318
+ $input.next().after($minus, $plus);
7319
+ $input.before($slider);
7320
+
7321
+ });
7322
+ }
7323
+ };
7324
+
7325
+ // Import this module.
7326
+ window.PUM_Admin = window.PUM_Admin || {};
7327
+ window.PUM_Admin.rangesliders = rangesliders;
7328
+
7329
+ $(document)
7330
+ .on('pum_init', PUM_Admin.rangesliders.init)
7331
+ /**
7332
+ * Updates the input field when the slider is used.
7333
+ */
7334
+ .on('input', '.pum-field-rangeslider.pum-rangeslider-initialized .pum-range-slider', function () {
7335
+ var $slider = $(this);
7336
+ $slider.siblings('.pum-range-manual').val($slider.val());
7337
+ })
7338
+ /**
7339
+ * Update sliders value, min, & max when manual entry is detected.
7340
+ */
7341
+ .on('change', '.pum-range-manual', function () {
7342
+ var $input = $(this),
7343
+ max = parseInt($input.prop('max'), 0),
7344
+ min = parseInt($input.prop('min'), 0),
7345
+ step = parseInt($input.prop('step'), 0),
7346
+ force = $input.data('force-minmax'),
7347
+ value = parseInt($input.val(), 0),
7348
+ $slider = $input.prev();
7349
+
7350
+ if (isNaN(value)) {
7351
+ value = $slider.val();
7352
+ }
7353
+
7354
+ if (force && value > max) {
7355
+ value = max;
7356
+ } else if (force && value < min) {
7357
+ value = min;
7358
+ }
7359
+
7360
+ $input.val(value).trigger('input');
7361
+
7362
+ $slider.prop({
7363
+ 'max': force || (max && max > value) ? max : value * 1.5,
7364
+ 'step': step || value * 1.5 / 100,
7365
+ 'value': value
7366
+ });
7367
+ })
7368
+ .on('click', '.pum-range-plus', function (event) {
7369
+ var $input = $(this).siblings('.pum-range-manual'),
7370
+ max = parseInt($input.prop('max'), 0),
7371
+ step = parseInt($input.prop('step'), 0),
7372
+ force = $input.data('force-minmax'),
7373
+ value = parseInt($input.val(), 0),
7374
+ $slider = $input.prev();
7375
+
7376
+ event.preventDefault();
7377
+
7378
+ value += step;
7379
+
7380
+ if (isNaN(value)) {
7381
+ value = $slider.val();
7382
+ }
7383
+
7384
+ if (force && value > max) {
7385
+ value = max;
7386
+ }
7387
+
7388
+ $input.val(value).trigger('input');
7389
+ $slider.val(value);
7390
+ })
7391
+ .on('click', '.pum-range-minus', function (event) {
7392
+ var $input = $(this).siblings('.pum-range-manual'),
7393
+ min = parseInt($input.prop('min'), 0),
7394
+ step = parseInt($input.prop('step'), 0),
7395
+ force = $input.data('force-minmax'),
7396
+ value = parseInt($input.val(), 0),
7397
+ $slider = $input.prev();
7398
+
7399
+ event.preventDefault();
7400
+
7401
+ value -= step;
7402
+
7403
+ if (isNaN(value)) {
7404
+ value = $slider.val();
7405
+ }
7406
+
7407
+ if (force && value < min) {
7408
+ value = min;
7409
+ }
7410
+
7411
+ $input.val(value).trigger('input');
7412
+ $slider.val(value);
7413
+ });
7414
+
7415
  }(jQuery));
7416
+ /*******************************************************************************
7417
+ * Copyright (c) 2017, WP Popup Maker
7418
+ ******************************************************************************/
7419
+ (function ($) {
7420
+ "use strict";
7421
+
7422
+ // Here because some plugins load additional copies, big no-no. This is the best we can do.
7423
+ $.fn.pumselect2 = $.fn.pumselect2 || $.fn.select2;
7424
+
7425
+ var select2 = {
7426
+ init: function () {
7427
+ $('.pum-field-select2 select').filter(':not(.pumselect2-initialized)').each(function () {
7428
+ var $this = $(this),
7429
+ current = $this.data('current') || $this.val(),
7430
+ object_type = $this.data('objecttype'),
7431
+ object_key = $this.data('objectkey'),
7432
+ object_excludes = $this.data('objectexcludes') || null,
7433
+ options = {
7434
+ width: '100%',
7435
+ multiple: false,
7436
+ dropdownParent: $this.parent()
7437
+ };
7438
+
7439
+ if ($this.attr('multiple')) {
7440
+ options.multiple = true;
7441
+ }
7442
+
7443
+ if (object_type && object_key) {
7444
+ options = $.extend(options, {
7445
+ ajax: {
7446
+ url: ajaxurl,
7447
+ dataType: 'json',
7448
+ delay: 250,
7449
+ data: function (params) {
7450
+ return {
7451
+ s: params.term, // search term
7452
+ paged: params.page,
7453
+ action: "pum_object_search",
7454
+ object_type: object_type,
7455
+ object_key: object_key,
7456
+ exclude: object_excludes
7457
+ };
7458
+ },
7459
+ processResults: function (data, params) {
7460
+ // parse the results into the format expected by Select2
7461
+ // since we are using custom formatting functions we do not need to
7462
+ // alter the remote JSON data, except to indicate that infinite
7463
+ // scrolling can be used
7464
+ params.page = params.page || 1;
7465
+
7466
+ return {
7467
+ results: data.items,
7468
+ pagination: {
7469
+ more: (params.page * 10) < data.total_count
7470
+ }
7471
+ };
7472
+ },
7473
+ cache: true
7474
+ },
7475
+ cache: true,
7476
+ escapeMarkup: function (markup) {
7477
+ return markup;
7478
+ }, // let our custom formatter work
7479
+ maximumInputLength: 20,
7480
+ closeOnSelect: !options.multiple,
7481
+ templateResult: PUM_Admin.select2.formatObject,
7482
+ templateSelection: PUM_Admin.select2.formatObjectSelection
7483
+ });
7484
+ }
7485
+
7486
+ $this
7487
+ .addClass('pumselect2-initialized')
7488
+ .pumselect2(options);
7489
+
7490
+ if (current !== null && current !== undefined) {
7491
+
7492
+ if (options.multiple && 'object' !== typeof current && current !== "") {
7493
+ current = [current];
7494
+ } else if (!options.multiple && current === '') {
7495
+ current = null;
7496
+ }
7497
+ } else {
7498
+ current = null;
7499
+ }
7500
+
7501
+ if (object_type && object_key && current !== null && (typeof current === 'number' || current.length)) {
7502
+ $.ajax({
7503
+ url: ajaxurl,
7504
+ data: {
7505
+ action: "pum_object_search",
7506
+ object_type: object_type,
7507
+ object_key: object_key,
7508
+ exclude: object_excludes,
7509
+ include: current && current.length ? (typeof current === 'string' || typeof current === 'number') ? [current] : current : null
7510
+ },
7511
+ dataType: "json",
7512
+ success: function (data) {
7513
+ $.each(data.items, function (key, item) {
7514
+ // Add any option that doesn't already exist
7515
+ if (!$this.find('option[value="' + item.id + '"]').length) {
7516
+ $this.prepend('<option value="' + item.id + '">' + item.text + '</option>');
7517
+ }
7518
+ });
7519
+ // Update the options
7520
+ $this.val(current).trigger('change');
7521
+ }
7522
+ });
7523
+ } else if (current && ((options.multiple && current.length) || (!options.multiple && current !== ""))) {
7524
+ $this.val(current).trigger('change');
7525
+ } else if (current === null) {
7526
+ $this.val(current).trigger('change');
7527
+ }
7528
+ });
7529
+ },
7530
+ formatObject: function (object) {
7531
+ return object.text;
7532
+ },
7533
+ formatObjectSelection: function (object) {
7534
+ return object.text || object.text;
7535
+ }
7536
+ };
7537
+
7538
+ // Import this module.
7539
+ window.PUM_Admin = window.PUM_Admin || {};
7540
+ window.PUM_Admin.select2 = select2;
7541
+
7542
+ $(document)
7543
+ .on('pum_init', function () {
7544
+ PUM_Admin.select2.init();
7545
+ });
7546
  }(jQuery));
7547
+ /*
7548
+ * $$ Selector Cache
7549
+ * Cache your selectors, without messy code.
7550
+ * @author Stephen Kamenar
7551
+ */
7552
+ (function ($, undefined) {
7553
+ // '#a': $('#a')
7554
+ if (typeof window.$$ === 'function') {
7555
+ return;
7556
+ }
7557
+
7558
+ var cache = {},
7559
+ cacheByContext = {}, // '#context': (a cache object for the element)
7560
+ tmp, tmp2; // Here for performance/minification
7561
+
7562
+ window.$$ = function (selector, context) {
7563
+ if (context) {
7564
+ if (tmp = context.selector) {
7565
+ context = tmp;
7566
+ }
7567
+
7568
+ // tmp2 is contextCache
7569
+ tmp2 = cacheByContext[context];
7570
+
7571
+ if (tmp2 === undefined) {
7572
+ tmp2 = cacheByContext[context] = {};
7573
+ }
7574
+
7575
+ tmp = tmp2[selector];
7576
+
7577
+ if (tmp !== undefined) {
7578
+ return tmp;
7579
+ }
7580
+
7581
+ return tmp2[selector] = $(selector, $$(context));
7582
+ }
7583
+
7584
+ tmp = cache[selector];
7585
+
7586
+ if (tmp !== undefined) {
7587
+ return tmp;
7588
+ }
7589
+
7590
+ return cache[selector] = $(selector);
7591
+ };
7592
+
7593
+ window.$$clear = function (selector, context) {
7594
+ if (context) {
7595
+ if (tmp = context.selector) {
7596
+ context = tmp;
7597
+ }
7598
+
7599
+ if (selector && (tmp = cacheByContext[context])) {
7600
+ tmp[selector] = undefined;
7601
+ }
7602
+
7603
+ cacheByContext[context] = undefined;
7604
+ } else {
7605
+ if (selector) {
7606
+ cache[selector] = undefined;
7607
+ cacheByContext[selector] = undefined;
7608
+ } else {
7609
+ cache = {};
7610
+ cacheByContext = {};
7611
+ }
7612
+ }
7613
+ };
7614
+
7615
+ window.$$fresh = function (selector, context) {
7616
+ $$clear(selector, context);
7617
+ return $$(selector, context);
7618
+ };
7619
+
7620
  }(jQuery));
7621
+ /**
7622
+ * jQuery serializeObject
7623
+ * @copyright 2014, macek <paulmacek@gmail.com>
7624
+ * @link https://github.com/macek/jquery-serialize-object
7625
+ * @license BSD
7626
+ * @version 2.5.0
7627
+ */
7628
+ (function (root, factory) {
7629
+
7630
+ // AMD
7631
+ if (typeof define === "function" && define.amd) {
7632
+ define(["exports", "jquery"], function (exports, $) {
7633
+ return factory(exports, $);
7634
+ });
7635
+ }
7636
+
7637
+ // CommonJS
7638
+ else if (typeof exports !== "undefined") {
7639
+ var $ = require("jquery");
7640
+ factory(exports, $);
7641
+ }
7642
+
7643
+ // Browser
7644
+ else {
7645
+ factory(root, (root.jQuery || root.Zepto || root.ender || root.$));
7646
+ }
7647
+
7648
+ }(this, function (exports, $) {
7649
+
7650
+ var patterns = {
7651
+ validate: /^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,
7652
+ key: /[a-z0-9_]+|(?=\[\])/gi,
7653
+ push: /^$/,
7654
+ fixed: /^\d+$/,
7655
+ named: /^[a-z0-9_]+$/i
7656
+ };
7657
+
7658
+ function FormSerializer(helper, $form) {
7659
+
7660
+ // private variables
7661
+ var data = {},
7662
+ pushes = {};
7663
+
7664
+ // private API
7665
+ function build(base, key, value) {
7666
+ base[key] = value;
7667
+ return base;
7668
+ }
7669
+
7670
+ function makeObject(root, value) {
7671
+
7672
+ var keys = root.match(patterns.key), k;
7673
+
7674
+ try {
7675
+ value = JSON.parse(value);
7676
+ } catch (Error) {
7677
+ }
7678
+
7679
+ // nest, nest, ..., nest
7680
+ while ((k = keys.pop()) !== undefined) {
7681
+ // foo[]
7682
+ if (patterns.push.test(k)) {
7683
+ var idx = incrementPush(root.replace(/\[\]$/, ''));
7684
+ value = build([], idx, value);
7685
+ }
7686
+
7687
+ // foo[n]
7688
+ else if (patterns.fixed.test(k)) {
7689
+ value = build([], k, value);
7690
+ }
7691
+
7692
+ // foo; foo[bar]
7693
+ else if (patterns.named.test(k)) {
7694
+ value = build({}, k, value);
7695
+ }
7696
+ }
7697
+
7698
+ return value;
7699
+ }
7700
+
7701
+ function incrementPush(key) {
7702
+ if (pushes[key] === undefined) {
7703
+ pushes[key] = 0;
7704
+ }
7705
+ return pushes[key]++;
7706
+ }
7707
+
7708
+ function encode(pair) {
7709
+ switch ($('[name="' + pair.name + '"]', $form).attr("type")) {
7710
+ case "checkbox":
7711
+ return pair.value === "1" ? true : pair.value;
7712
+ default:
7713
+ return pair.value;
7714
+ }
7715
+ }
7716
+
7717
+ function addPair(pair) {
7718
+ if (!patterns.validate.test(pair.name)) return this;
7719
+ var obj = makeObject(pair.name, encode(pair));
7720
+
7721
+ data = helper.extend(true, data, obj);
7722
+ return this;
7723
+ }
7724
+
7725
+ function addPairs(pairs) {
7726
+ if (!helper.isArray(pairs)) {
7727
+ throw new Error("formSerializer.addPairs expects an Array");
7728
+ }
7729
+ for (var i = 0, len = pairs.length; i < len; i++) {
7730
+ this.addPair(pairs[i]);
7731
+ }
7732
+ return this;
7733
+ }
7734
+
7735
+ function serialize() {
7736
+ return data;
7737
+ }
7738
+
7739
+ function serializeJSON() {
7740
+ return JSON.stringify(serialize());
7741
+ }
7742
+
7743
+ // public API
7744
+ this.addPair = addPair;
7745
+ this.addPairs = addPairs;
7746
+ this.serialize = serialize;
7747
+ this.serializeJSON = serializeJSON;
7748
+ }
7749
+
7750
+ FormSerializer.patterns = patterns;
7751
+
7752
+ FormSerializer.serializeObject = function serializeObject() {
7753
+ var serialized;
7754
+
7755
+ if (this.is('form')) {
7756
+ serialized = this.serializeArray();
7757
+ } else {
7758
+ serialized = this.find(':input').serializeArray();
7759
+ }
7760
+
7761
+ return new FormSerializer($, this)
7762
+ .addPairs(serialized)
7763
+ .serialize();
7764
+ };
7765
+
7766
+ FormSerializer.serializeJSON = function serializeJSON() {
7767
+ var serialized;
7768
+
7769
+ if (this.is('form')) {
7770
+ serialized = this.serializeArray();
7771
+ } else {
7772
+ serialized = this.find(':input').serializeArray();
7773
+ }
7774
+
7775
+ return new FormSerializer($, this)
7776
+ .addPairs(serialized)
7777
+ .serializeJSON();
7778
+ };
7779
+
7780
+ if (typeof $.fn !== "undefined") {
7781
+ $.fn.pumSerializeObject = FormSerializer.serializeObject;
7782
+ $.fn.pumSerializeJSON = FormSerializer.serializeJSON;
7783
+ }
7784
+
7785
+ exports.FormSerializer = FormSerializer;
7786
+
7787
+ return FormSerializer;
7788
  }));
7789
+ /*******************************************************************************
7790
+ * Copyright (c) 2017, WP Popup Maker
7791
+ ******************************************************************************/
7792
+ (function ($) {
7793
+ "use strict";
7794
+ var tabs = {
7795
+ init: function () {
7796
+ $('.pum-tabs-container').filter(':not(.pum-tabs-initialized)').each(function () {
7797
+ var $this = $(this).addClass('pum-tabs-initialized'),
7798
+ $tabList = $this.find('> ul.tabs'),
7799
+ $firstTab = $tabList.find('> li:first'),
7800
+ forceMinHeight = $this.data('min-height');
7801
+
7802
+ if ($this.hasClass('vertical-tabs')) {
7803
+ var minHeight = forceMinHeight && forceMinHeight > 0 ? forceMinHeight : $tabList.eq(0).outerHeight(true);
7804
+
7805
+ $this.css({
7806
+ minHeight: minHeight + 'px'
7807
+ });
7808
+
7809
+ if ($this.parent().innerHeight < minHeight) {
7810
+ $this.parent().css({
7811
+ minHeight: minHeight + 'px'
7812
+ });
7813
+ }
7814
+ }
7815
+
7816
+ // Trigger first tab.
7817
+ $firstTab.trigger('click');
7818
+ });
7819
+ }
7820
+ };
7821
+
7822
+ // Import this module.
7823
+ window.PUM_Admin = window.PUM_Admin || {};
7824
+ window.PUM_Admin.tabs = tabs;
7825
+
7826
+ $(document)
7827
+ .on('pum_init', PUM_Admin.tabs.init)
7828
+ .on('click', '.pum-tabs-initialized li.tab', function (e) {
7829
+ var $this = $(this),
7830
+ $container = $this.parents('.pum-tabs-container:first'),
7831
+ $tabs = $container.find('> ul.tabs > li.tab'),
7832
+ $tab_contents = $container.find('> div.tab-content'),
7833
+ link = $this.find('a').attr('href');
7834
+
7835
+ $tabs.removeClass('active');
7836
+ $tab_contents.removeClass('active');
7837
+
7838
+ $this.addClass('active');
7839
+ $container.find('> div.tab-content' + link).addClass('active');
7840
+
7841
+ e.preventDefault();
7842
+ });
7843
  }(jQuery));
7844
+ /*******************************************************************************
7845
+ * Copyright (c) 2017, WP Popup Maker
7846
+ ******************************************************************************/
7847
+ (function ($) {
7848
+ "use strict";
7849
+ var I10n = pum_admin_vars.I10n,
7850
+ templates = {
7851
+ render: function (template, data) {
7852
+ var _template = wp.template(template);
7853
+
7854
+ data = data || {};
7855
+
7856
+ if (data.classes !== undefined && Array.isArray(data.classes)) {
7857
+ data.classes = data.classes.join(' ');
7858
+ }
7859
+
7860
+ // Prepare the meta data for templates.
7861
+ data = PUM_Admin.templates.prepareMeta(data);
7862
+
7863
+ return _template(data);
7864
+ },
7865
+ renderInline: function (content, data) {
7866
+ var options = {
7867
+ evaluate: /<#([\s\S]+?)#>/g,
7868
+ interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
7869
+ escape: /\{\{([^\}]+?)\}\}(?!\})/g,
7870
+ variable: 'data'
7871
+ },
7872
+ template = _.template(content, null, options);
7873
+
7874
+ return template(data);
7875
+ },
7876
+ shortcode: function (args) {
7877
+ var data = $.extend(true, {}, {
7878
+ tag: '',
7879
+ meta: {},
7880
+ has_content: false,
7881
+ content: ''
7882
+ }, args),
7883
+ template = data.has_content ? 'pum-shortcode-w-content' : 'pum-shortcode';
7884
+
7885
+ return PUM_Admin.templates.render(template, data);
7886
+ },
7887
+ modal: function (args) {
7888
+ var data = $.extend(true, {}, {
7889
+ id: '',
7890
+ title: '',
7891
+ description: '',
7892
+ classes: '',
7893
+ save_button: I10n.save,
7894
+ cancel_button: I10n.cancel,
7895
+ content: ''
7896
+ }, args);
7897
+
7898
+ return PUM_Admin.templates.render('pum-modal', data);
7899
+ },
7900
+ tabs: function (data) {
7901
+ data = $.extend(true, {}, {
7902
+ id: '',
7903
+ vertical: false,
7904
+ form: false,
7905
+ classes: [],
7906
+ tabs: {},
7907
+ meta: {}
7908
+ }, data);
7909
+
7910
+ if (typeof data.classes === 'string') {
7911
+ data.classes = [data.classes];
7912
+ }
7913
+
7914
+ if (data.form) {
7915
+ data.classes.push('pum-tabbed-form');
7916
+ }
7917
+
7918
+ data.meta['data-tab-count'] = Object.keys(data.tabs).length;
7919
+
7920
+ data.classes.push(data.vertical ? 'vertical-tabs' : 'horizontal-tabs');
7921
+
7922
+ data.classes = data.classes.join(' ');
7923
+
7924
+ return PUM_Admin.templates.render('pum-tabs', data);
7925
+ },
7926
+ section: function (args) {
7927
+ var data = $.extend(true, {}, {
7928
+ classes: [],
7929
+ fields: []
7930
+ }, args);
7931
+
7932
+
7933
+ return PUM_Admin.templates.render('pum-field-section', data);
7934
+ },
7935
+ fieldArgs: function (args) {
7936
+ var options = [],
7937
+ data = $.extend(true, {}, PUM_Admin.models.field(args));
7938
+
7939
+ if (args.std !== undefined && args.type !== 'checkbox' && (data.value === null || data.value === false)) {
7940
+ data.value = args.std;
7941
+ }
7942
+
7943
+ if ('string' === typeof data.classes) {
7944
+ data.classes = data.classes.split(' ');
7945
+ }
7946
+
7947
+ if (args.class !== undefined) {
7948
+ data.classes.push(args.class);
7949
+ }
7950
+
7951
+ if (args.dependencies !== undefined && typeof args.dependencies === 'object') {
7952
+ data.dependencies = JSON.stringify(args.dependencies);
7953
+ }
7954
+
7955
+ if (data.required) {
7956
+ data.meta.required = true;
7957
+ data.classes.push('pum-required');
7958
+ }
7959
+
7960
+ if (typeof data.dynamic_desc === 'string' && data.dynamic_desc.length) {
7961
+ data.classes.push('pum-field-dynamic-desc');
7962
+ data.desc = PUM_Admin.templates.renderInline(data.dynamic_desc, data);
7963
+ }
7964
+
7965
+ if (data.allow_html) {
7966
+ data.classes.push('pum-field-' + data.type + '--html');
7967
+ if ( typeof data.value === 'string' && data.value !== '' && PUM_Admin.utils.htmlencoder.hasEncoded(data.value)) {
7968
+ data.value = PUM_Admin.utils.htmlencoder.htmlDecode(data.value);
7969
+ }
7970
+ }
7971
+
7972
+ switch (args.type) {
7973
+ case 'select':
7974
+ case 'objectselect':
7975
+ case 'postselect':
7976
+ case 'taxonomyselect':
7977
+ if (data.options !== undefined) {
7978
+ _.each(data.options, function (label, value) {
7979
+ var selected = false,
7980
+ optgroup,
7981
+ optgroup_options;
7982
+
7983
+ // Check if the label is an object. If so this is a optgroup and the label is sub options array.
7984
+ // NOTE: The value in the case its an optgroup is the optgroup label.
7985
+ if (typeof label !== 'object') {
7986
+
7987
+ if (data.value !== null) {
7988
+ if (data.multiple && ((typeof data.value === 'string' && data.value == value) || (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined))) {
7989
+ selected = 'selected';
7990
+ } else if (!data.multiple && data.value == value) {
7991
+ selected = 'selected';
7992
+ }
7993
+ }
7994
+
7995
+ options.push(
7996
+ PUM_Admin.templates.prepareMeta({
7997
+ label: label,
7998
+ value: value,
7999
+ meta: {
8000
+ selected: selected
8001
+ }
8002
+ })
8003
+ );
8004
+
8005
+ } else {
8006
+ // Process Option Groups
8007
+
8008
+ // Swap label & value due to group labels being used as keys.
8009
+ optgroup = value;
8010
+ optgroup_options = [];
8011
+
8012
+ _.each(label, function (label, value) {
8013
+ var selected = false;
8014
+
8015
+ if (data.value !== null) {
8016
+ if (data.multiple && ((typeof data.value === 'string' && data.value == value) || (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined))) {
8017
+ selected = 'selected';
8018
+ } else if (!data.multiple && data.value == value) {
8019
+ selected = 'selected';
8020
+ }
8021
+ }
8022
+ optgroup_options.push(
8023
+ PUM_Admin.templates.prepareMeta({
8024
+ label: label,
8025
+ value: value,
8026
+ meta: {
8027
+ selected: selected
8028
+ }
8029
+ })
8030
+ );
8031
+
8032
+ });
8033
+
8034
+ options.push({
8035
+ label: optgroup,
8036
+ options: optgroup_options
8037
+ });
8038
+
8039
+ }
8040
+
8041
+ });
8042
+
8043
+ data.options = options;
8044
+
8045
+ }
8046
+
8047
+ if (data.multiple) {
8048
+
8049
+ data.meta.multiple = true;
8050
+
8051
+ if (data.as_array) {
8052
+ data.name += '[]';
8053
+ }
8054
+
8055
+ if (!data.value || !data.value.length) {
8056
+ data.value = [];
8057
+ }
8058
+
8059
+ if (typeof data.value === 'string') {
8060
+ data.value = [data.value];
8061
+ }
8062
+
8063
+ }
8064
+
8065
+ if (args.type !== 'select') {
8066
+ data.select2 = true;
8067
+ data.classes.push('pum-field-objectselect');
8068
+ data.classes.push(args.type === 'postselect' ? 'pum-field-postselect' : 'pum-field-taxonomyselect');
8069
+ data.meta['data-objecttype'] = args.type === 'postselect' ? 'post_type' : 'taxonomy';
8070
+ data.meta['data-objectkey'] = args.type === 'postselect' ? args.post_type : args.taxonomy;
8071
+ data.meta['data-current'] = typeof data.value === 'object' || Array.isArray(data.value) ? JSON.stringify(data.value) : data.value;
8072
+ }
8073
+
8074
+ if (data.select2) {
8075
+ data.classes.push('pum-field-select2');
8076
+
8077
+ if (data.placeholder) {
8078
+ data.meta['data-placeholder'] = data.placeholder;
8079
+ }
8080
+ }
8081
+
8082
+ break;
8083
+ case 'radio':
8084
+ if (data.options !== undefined) {
8085
+ _.each(data.options, function (label, value) {
8086
+
8087
+ options.push(
8088
+ PUM_Admin.templates.prepareMeta({
8089
+ label: label,
8090
+ value: value,
8091
+ meta: {
8092
+ checked: data.value === value
8093
+ }
8094
+ })
8095
+ );
8096
+
8097
+ });
8098
+
8099
+ data.options = options;
8100
+ }
8101
+ break;
8102
+ case 'multicheck':
8103
+ if (data.options !== undefined) {
8104
+
8105
+ if (data.value === false || data.value === null) {
8106
+ data.value = [];
8107
+ }
8108
+
8109
+ debugger;
8110
+
8111
+ if (typeof data.value === 'string' && data.value.indexOf(',')) {
8112
+ data.value = data.value.split(',');
8113
+ }
8114
+
8115
+ if (data.as_array) {
8116
+ data.name += '[]';
8117
+ }
8118
+
8119
+ _.each(data.options, function (label, value) {
8120
+
8121
+ options.push(
8122
+ PUM_Admin.templates.prepareMeta({
8123
+ label: label,
8124
+ value: value,
8125
+ meta: {
8126
+ checked: (Array.isArray(data.value) && data.value.indexOf(value) !== -1) || (!Array.isArray(data.value) && typeof data.value === 'object' && Object.keys(data.value).length && data.value[value] !== undefined)
8127
+ }
8128
+ })
8129
+ );
8130
+
8131
+ });
8132
+
8133
+ data.options = options;
8134
+ }
8135
+ break;
8136
+ case 'checkbox':
8137
+ switch (typeof data.value) {
8138
+ case 'object':
8139
+ if (Array.isArray(data.value) && data.value.length === 1 && data.value[0].toString() === '1') {
8140
+ data.value = true;
8141
+ data.meta.checked = true;
8142
+ } else {
8143
+
8144
+ }
8145
+ break;
8146
+ case 'boolean':
8147
+ if (data.value) {
8148
+ data.meta.checked = true;
8149
+ }
8150
+ break;
8151
+ case 'string':
8152
+ if (data.value === 'true' || data.value === 'yes' || data.value === '1') {
8153
+ data.meta.checked = true;
8154
+ }
8155
+ break;
8156
+ case 'number':
8157
+ if (parseInt(data.value, 10) === 1 || parseInt(data.value, 10) > 0) {
8158
+ data.meta.checked = true;
8159
+ }
8160
+ }
8161
+ break;
8162
+ case 'rangeslider':
8163
+ // data.meta.readonly = true;
8164
+ data.meta.step = data.step;
8165
+ data.meta.min = data.min;
8166
+ data.meta.max = data.max;
8167
+ data.meta['data-force-minmax'] = data.force_minmax.toString();
8168
+ break;
8169
+ case 'textarea':
8170
+ data.meta.cols = data.cols;
8171
+ data.meta.rows = data.rows;
8172
+ break;
8173
+ case 'measure':
8174
+ if (typeof data.value === 'string' && data.value !== '') {
8175
+ data.number = parseInt(data.value);
8176
+ data.unitValue = data.value.replace(data.number, "");
8177
+ data.value = data.number;
8178
+ } else {
8179
+ data.unitValue = null;
8180
+ }
8181
+
8182
+ if (data.units !== undefined) {
8183
+ _.each(data.units, function (label, value) {
8184
+ var selected = false;
8185
+
8186
+ if (data.unitValue == value) {
8187
+ selected = 'selected';
8188
+ }
8189
+
8190
+ options.push(
8191
+ PUM_Admin.templates.prepareMeta({
8192
+ label: label,
8193
+ value: value,
8194
+ meta: {
8195
+ selected: selected
8196
+ }
8197
+ })
8198
+ );
8199
+
8200
+ });
8201
+
8202
+ data.units = options;
8203
+ }
8204
+ break;
8205
+ case 'color':
8206
+ if ( typeof data.value === 'string' && data.value !== '') {
8207
+ data.meta['data-default-color'] = data.value;
8208
+ }
8209
+ break;
8210
+ case 'license_key':
8211
+
8212
+ data.value = $.extend({
8213
+ key: '',
8214
+ license: {},
8215
+ messages: [],
8216
+ status: 'empty',
8217
+ expires: false,
8218
+ classes: false
8219
+ }, data.value);
8220
+
8221
+ data.classes.push('pum-license-' + data.value.status + '-notice');
8222
+
8223
+ if (data.value.classes) {
8224
+ data.classes.push(data.value.classes);
8225
+ }
8226
+ break;
8227
+ }
8228
+
8229
+ return data;
8230
+ },
8231
+ field: function (args) {
8232
+ var fieldTemplate,
8233
+ data = PUM_Admin.templates.fieldArgs(args);
8234
+
8235
+ fieldTemplate = 'pum-field-' + data.type;
8236
+
8237
+ if (data.type === 'objectselfect' || data.type === 'postselect' || data.type === 'taxonomyselect') {
8238
+ fieldTemplate = 'pum-field-select';
8239
+ }
8240
+
8241
+ if (!$('#tmpl-' + fieldTemplate).length) {
8242
+ console.warn('No field template found for type:' + data.type + ' fieldID: ' + data.id);
8243
+ return '';
8244
+ }
8245
+
8246
+ data.field = PUM_Admin.templates.render(fieldTemplate, data);
8247
+
8248
+ return PUM_Admin.templates.render('pum-field-wrapper', data);
8249
+ },
8250
+ prepareMeta: function (data) {
8251
+ // Convert meta JSON to attribute string.
8252
+ var _meta = [],
8253
+ key;
8254
+
8255
+ for (key in data.meta) {
8256
+ if (data.meta.hasOwnProperty(key)) {
8257
+ // Boolean attributes can only require attribute key, not value.
8258
+ if ('boolean' === typeof data.meta[key]) {
8259
+ // Only set truthy boolean attributes.
8260
+ if (data.meta[key]) {
8261
+ _meta.push(_.escape(key));
8262
+ }
8263
+ } else {
8264
+ _meta.push(_.escape(key) + '="' + _.escape(data.meta[key]) + '"');
8265
+ }
8266
+ }
8267
+ }
8268
+
8269
+ data.meta = _meta.join(' ');
8270
+ return data;
8271
+ }
8272
+ };
8273
+
8274
+ // Import this module.
8275
+ window.PUM_Admin = window.PUM_Admin || {};
8276
+ window.PUM_Admin.templates = templates;
8277
  }(window.jQuery));
8278
+ /*******************************************************************************
8279
+ * Copyright (c) 2017, WP Popup Maker
8280
+ ******************************************************************************/
8281
+ (function ($) {
8282
+ "use strict";
8283
+
8284
+ String.prototype.capitalize = function () {
8285
+ return this.charAt(0).toUpperCase() + this.slice(1);
8286
+ };
8287
+
8288
+ var root = this,
8289
+ inputTypes = 'color,date,datetime,datetime-local,email,hidden,month,number,password,range,search,tel,text,time,url,week'.split(','),
8290
+ inputNodes = 'select,textarea'.split(','),
8291
+ rName = /\[([^\]]*)\]/g;
8292
+
8293
+ // ugly hack for IE7-8
8294
+ function isInArray(array, needle) {
8295
+ return $.inArray(needle, array) !== -1;
8296
+ }
8297
+
8298
+ function storeValue(container, parsedName, value) {
8299
+
8300
+ var part = parsedName[0];
8301
+
8302
+ if (parsedName.length > 1) {
8303
+ if (!container[part]) {
8304
+ // If the next part is eq to '' it means we are processing complex name (i.e. `some[]`)
8305
+ // for this case we need to use Array instead of an Object for the index increment purpose
8306
+ container[part] = parsedName[1] ? {} : [];
8307
+ }
8308
+ storeValue(container[part], parsedName.slice(1), value);
8309
+ } else {
8310
+
8311
+ // Increment Array index for `some[]` case
8312
+ if (!part) {
8313
+ part = container.length;
8314
+ }
8315
+
8316
+ container[part] = value;
8317
+ }
8318
+ }
8319
+
8320
+ /**
8321
+ * A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding
8322
+ * Author: R Reid
8323
+ * source: http://www.strictly-software.com/htmlencode
8324
+ * Licences: GPL, The MIT License (MIT)
8325
+ * Copyright: (c) 2011 Robert Reid - Strictly-Software.com
8326
+ *
8327
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8328
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8329
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8330
+ *
8331
+ * Revision:
8332
+ * 2011-07-14, Jacques-Yves Bleau:
8333
+ * - fixed conversion error with capitalized accentuated characters
8334
+ * + converted arr1 and arr2 to object property to remove redundancy
8335
+ *
8336
+ * Revision:
8337
+ * 2011-11-10, Ce-Yi Hio:
8338
+ * - fixed conversion error with a number of capitalized entity characters
8339
+ *
8340
+ * Revision:
8341
+ * 2011-11-10, Rob Reid:
8342
+ * - changed array format
8343
+ *
8344
+ * Revision:
8345
+ * 2012-09-23, Alex Oss:
8346
+ * - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid
8347
+ */
8348
+
8349
+ var Encoder = {
8350
+
8351
+ // When encoding do we convert characters into html or numerical entities
8352
+ EncodeType : "entity", // entity OR numerical
8353
+
8354
+ isEmpty : function(val){
8355
+ if(val){
8356
+ return ((val===null) || val.length==0 || /^\s+$/.test(val));
8357
+ }else{
8358
+ return true;
8359
+ }
8360
+ },
8361
+
8362
+ // arrays for conversion from HTML Entities to Numerical values
8363
+ arr1: ['&nbsp;','&iexcl;','&cent;','&pound;','&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','&shy;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&sup1;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;','&quot;','&amp;','&lt;','&gt;','&OElig;','&oelig;','&Scaron;','&scaron;','&Yuml;','&circ;','&tilde;','&ensp;','&emsp;','&thinsp;','&zwnj;','&zwj;','&lrm;','&rlm;','&ndash;','&mdash;','&lsquo;','&rsquo;','&sbquo;','&ldquo;','&rdquo;','&bdquo;','&dagger;','&Dagger;','&permil;','&lsaquo;','&rsaquo;','&euro;','&fnof;','&Alpha;','&Beta;','&Gamma;','&Delta;','&Epsilon;','&Zeta;','&Eta;','&Theta;','&Iota;','&Kappa;','&Lambda;','&Mu;','&Nu;','&Xi;','&Omicron;','&Pi;','&Rho;','&Sigma;','&Tau;','&Upsilon;','&Phi;','&Chi;','&Psi;','&Omega;','&alpha;','&beta;','&gamma;','&delta;','&epsilon;','&zeta;','&eta;','&theta;','&iota;','&kappa;','&lambda;','&mu;','&nu;','&xi;','&omicron;','&pi;','&rho;','&sigmaf;','&sigma;','&tau;','&upsilon;','&phi;','&chi;','&psi;','&omega;','&thetasym;','&upsih;','&piv;','&bull;','&hellip;','&prime;','&Prime;','&oline;','&frasl;','&weierp;','&image;','&real;','&trade;','&alefsym;','&larr;','&uarr;','&rarr;','&darr;','&harr;','&crarr;','&lArr;','&uArr;','&rArr;','&dArr;','&hArr;','&forall;','&part;','&exist;','&empty;','&nabla;','&isin;','&notin;','&ni;','&prod;','&sum;','&minus;','&lowast;','&radic;','&prop;','&infin;','&ang;','&and;','&or;','&cap;','&cup;','&int;','&there4;','&sim;','&cong;','&asymp;','&ne;','&equiv;','&le;','&ge;','&sub;','&sup;','&nsub;','&sube;','&supe;','&oplus;','&otimes;','&perp;','&sdot;','&lceil;','&rceil;','&lfloor;','&rfloor;','&lang;','&rang;','&loz;','&spades;','&clubs;','&hearts;','&diams;'],
8364
+ arr2: ['&#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;','&#194;','&#195;','&#196;','&#197;','&#198;','&#199;','&#200;','&#201;','&#202;','&#203;','&#204;','&#205;','&#206;','&#207;','&#208;','&#209;','&#210;','&#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;','&#253;','&#254;','&#255;','&#34;','&#38;','&#60;','&#62;','&#338;','&#339;','&#352;','&#353;','&#376;','&#710;','&#732;','&#8194;','&#8195;','&#8201;','&#8204;','&#8205;','&#8206;','&#8207;','&#8211;','&#8212;','&#8216;','&#8217;','&#8218;','&#8220;','&#8221;','&#8222;','&#8224;','&#8225;','&#8240;','&#8249;','&#8250;','&#8364;','&#402;','&#913;','&#914;','&#915;','&#916;','&#917;','&#918;','&#919;','&#920;','&#921;','&#922;','&#923;','&#924;','&#925;','&#926;','&#927;','&#928;','&#929;','&#931;','&#932;','&#933;','&#934;','&#935;','&#936;','&#937;','&#945;','&#946;','&#947;','&#948;','&#949;','&#950;','&#951;','&#952;','&#953;','&#954;','&#955;','&#956;','&#957;','&#958;','&#959;','&#960;','&#961;','&#962;','&#963;','&#964;','&#965;','&#966;','&#967;','&#968;','&#969;','&#977;','&#978;','&#982;','&#8226;','&#8230;','&#8242;','&#8243;','&#8254;','&#8260;','&#8472;','&#8465;','&#8476;','&#8482;','&#8501;','&#8592;','&#8593;','&#8594;','&#8595;','&#8596;','&#8629;','&#8656;','&#8657;','&#8658;','&#8659;','&#8660;','&#8704;','&#8706;','&#8707;','&#8709;','&#8711;','&#8712;','&#8713;','&#8715;','&#8719;','&#8721;','&#8722;','&#8727;','&#8730;','&#8733;','&#8734;','&#8736;','&#8743;','&#8744;','&#8745;','&#8746;','&#8747;','&#8756;','&#8764;','&#8773;','&#8776;','&#8800;','&#8801;','&#8804;','&#8805;','&#8834;','&#8835;','&#8836;','&#8838;','&#8839;','&#8853;','&#8855;','&#8869;','&#8901;','&#8968;','&#8969;','&#8970;','&#8971;','&#9001;','&#9002;','&#9674;','&#9824;','&#9827;','&#9829;','&#9830;'],
8365
+
8366
+ // Convert HTML entities into numerical entities
8367
+ HTML2Numerical : function(s){
8368
+ return this.swapArrayVals(s,this.arr1,this.arr2);
8369
+ },
8370
+
8371
+ // Convert Numerical entities into HTML entities
8372
+ NumericalToHTML : function(s){
8373
+ return this.swapArrayVals(s,this.arr2,this.arr1);
8374
+ },
8375
+
8376
+
8377
+ // Numerically encodes all unicode characters
8378
+ numEncode : function(s){
8379
+ if(this.isEmpty(s)) return "";
8380
+
8381
+ var a = [],
8382
+ l = s.length;
8383
+
8384
+ for (var i=0;i<l;i++){
8385
+ var c = s.charAt(i);
8386
+ if (c < " " || c > "~"){
8387
+ a.push("&#");
8388
+ a.push(c.charCodeAt()); //numeric value of code point
8389
+ a.push(";");
8390
+ }else{
8391
+ a.push(c);
8392
+ }
8393
+ }
8394
+
8395
+ return a.join("");
8396
+ },
8397
+
8398
+ // HTML Decode numerical and HTML entities back to original values
8399
+ htmlDecode : function(s){
8400
+
8401
+ var c,m,d = s;
8402
+
8403
+ if(this.isEmpty(d)) return "";
8404
+
8405
+ // convert HTML entites back to numerical entites first
8406
+ d = this.HTML2Numerical(d);
8407
+
8408
+ // look for numerical entities &#34;
8409
+ var arr=d.match(/&#[0-9]{1,5};/g);
8410
+
8411
+ // if no matches found in string then skip
8412
+ if(arr!=null){
8413
+ for(var x=0;x<arr.length;x++){
8414
+ m = arr[x];
8415
+ c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
8416
+ // if its a valid number we can decode
8417
+ if(c >= -32768 && c <= 65535){
8418
+ // decode every single match within string
8419
+ d = d.replace(m, String.fromCharCode(c));
8420
+ }else{
8421
+ d = d.replace(m, ""); //invalid so replace with nada
8422
+ }
8423
+ }
8424
+ }
8425
+
8426
+ return d;
8427
+ },
8428
+
8429
+ // encode an input string into either numerical or HTML entities
8430
+ htmlEncode : function(s,dbl){
8431
+
8432
+ if(this.isEmpty(s)) return "";
8433
+
8434
+ // do we allow double encoding? E.g will &amp; be turned into &amp;amp;
8435
+ dbl = dbl || false; //default to prevent double encoding
8436
+
8437
+ // if allowing double encoding we do ampersands first
8438
+ if(dbl){
8439
+ if(this.EncodeType=="numerical"){
8440
+ s = s.replace(/&/g, "&#38;");
8441
+ }else{
8442
+ s = s.replace(/&/g, "&amp;");
8443
+ }
8444
+ }
8445
+
8446
+ // convert the xss chars to numerical entities ' " < >
8447
+ s = this.XSSEncode(s,false);
8448
+
8449
+ if(this.EncodeType=="numerical" || !dbl){
8450
+ // Now call function that will convert any HTML entities to numerical codes
8451
+ s = this.HTML2Numerical(s);
8452
+ }
8453
+
8454
+ // Now encode all chars above 127 e.g unicode
8455
+ s = this.numEncode(s);
8456
+
8457
+ // now we know anything that needs to be encoded has been converted to numerical entities we
8458
+ // can encode any ampersands & that are not part of encoded entities
8459
+ // to handle the fact that I need to do a negative check and handle multiple ampersands &&&
8460
+ // I am going to use a placeholder
8461
+
8462
+ // if we don't want double encoded entities we ignore the & in existing entities
8463
+ if(!dbl){
8464
+ s = s.replace(/&#/g,"##AMPHASH##");
8465
+
8466
+ if(this.EncodeType=="numerical"){
8467
+ s = s.replace(/&/g, "&#38;");
8468
+ }else{
8469
+ s = s.replace(/&/g, "&amp;");
8470
+ }
8471
+
8472
+ s = s.replace(/##AMPHASH##/g,"&#");
8473
+ }
8474
+
8475
+ // replace any malformed entities
8476
+ s = s.replace(/&#\d*([^\d;]|$)/g, "$1");
8477
+
8478
+ if(!dbl){
8479
+ // safety check to correct any double encoded &amp;
8480
+ s = this.correctEncoding(s);
8481
+ }
8482
+
8483
+ // now do we need to convert our numerical encoded string into entities
8484
+ if(this.EncodeType=="entity"){
8485
+ s = this.NumericalToHTML(s);
8486
+ }
8487
+
8488
+ return s;
8489
+ },
8490
+
8491
+ // Encodes the basic 4 characters used to malform HTML in XSS hacks
8492
+ XSSEncode : function(s,en){
8493
+ if(!this.isEmpty(s)){
8494
+ en = en || true;
8495
+ // do we convert to numerical or html entity?
8496
+ if(en){
8497
+ s = s.replace(/\'/g,"&#39;"); //no HTML equivalent as &apos is not cross browser supported
8498
+ s = s.replace(/\"/g,"&quot;");
8499
+ s = s.replace(/</g,"&lt;");
8500
+ s = s.replace(/>/g,"&gt;");
8501
+ }else{
8502
+ s = s.replace(/\'/g,"&#39;"); //no HTML equivalent as &apos is not cross browser supported
8503
+ s = s.replace(/\"/g,"&#34;");
8504
+ s = s.replace(/</g,"&#60;");
8505
+ s = s.replace(/>/g,"&#62;");
8506
+ }
8507
+ return s;
8508
+ }else{
8509
+ return "";
8510
+ }
8511
+ },
8512
+
8513
+ // returns true if a string contains html or numerical encoded entities
8514
+ hasEncoded : function(s){
8515
+ if(/&#[0-9]{1,5};/g.test(s)){
8516
+ return true;
8517
+ }else if(/&[A-Z]{2,6};/gi.test(s)){
8518
+ return true;
8519
+ }else{
8520
+ return false;
8521
+ }
8522
+ },
8523
+
8524
+ // will remove any unicode characters
8525
+ stripUnicode : function(s){
8526
+ return s.replace(/[^\x20-\x7E]/g,"");
8527
+
8528
+ },
8529
+
8530
+ // corrects any double encoded &amp; entities e.g &amp;amp;
8531
+ correctEncoding : function(s){
8532
+ return s.replace(/(&amp;)(amp;)+/,"$1");
8533
+ },
8534
+
8535
+
8536
+ // Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals
8537
+ swapArrayVals : function(s,arr1,arr2){
8538
+ if(this.isEmpty(s)) return "";
8539
+ var re;
8540
+ if(arr1 && arr2){
8541
+ //ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length)
8542
+ // array lengths must match
8543
+ if(arr1.length == arr2.length){
8544
+ for(var x=0,i=arr1.length;x<i;x++){
8545
+ re = new RegExp(arr1[x], 'g');
8546
+ s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2
8547
+ }
8548
+ }
8549
+ }
8550
+ return s;
8551
+ },
8552
+
8553
+ inArray : function( item, arr ) {
8554
+ for ( var i = 0, x = arr.length; i < x; i++ ){
8555
+ if ( arr[i] === item ){
8556
+ return i;
8557
+ }
8558
+ }
8559
+ return -1;
8560
+ }
8561
+
8562
+ };
8563
+
8564
+ Encoder.EncodeType = "entity";
8565
+
8566
+ var utils = {
8567
+ htmlencoder: Encoder,
8568
+ convert_meta_to_object: function (data) {
8569
+ var converted_data = {},
8570
+ element,
8571
+ property,
8572
+ key;
8573
+
8574
+ for (key in data) {
8575
+ if (data.hasOwnProperty(key)) {
8576
+ element = key.split(/_(.+)?/)[0];
8577
+ property = key.split(/_(.+)?/)[1];
8578
+ if (converted_data[element] === undefined) {
8579
+ converted_data[element] = {};
8580
+ }
8581
+ converted_data[element][property] = data[key];
8582
+ }
8583
+ }
8584
+ return converted_data;
8585
+ },
8586
+ object_to_array: function (object) {
8587
+ var array = [],
8588
+ i;
8589
+
8590
+ // Convert facets to array (JSON.stringify breaks arrays).
8591
+ if (typeof object === 'object') {
8592
+ for (i in object) {
8593
+ array.push(object[i]);
8594
+ }
8595
+ object = array;
8596
+ }
8597
+
8598
+ return object;
8599
+ },
8600
+ checked: function (val1, val2, print) {
8601
+ var checked = false;
8602
+ if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
8603
+ checked = true;
8604
+ } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
8605
+ checked = true;
8606
+ } else if (val1 === val2) {
8607
+ checked = true;
8608
+ } else if (val1 == val2) {
8609
+ checked = true;
8610
+ }
8611
+
8612
+ if (print !== undefined && print) {
8613
+ return checked ? ' checked="checked"' : '';
8614
+ }
8615
+ return checked;
8616
+ },
8617
+ selected: function (val1, val2, print) {
8618
+ var selected = false;
8619
+ if (typeof val1 === 'object' && typeof val2 === 'string' && jQuery.inArray(val2, val1) !== -1) {
8620
+ selected = true;
8621
+ } else if (typeof val2 === 'object' && typeof val1 === 'string' && jQuery.inArray(val1, val2) !== -1) {
8622
+ selected = true;
8623
+ } else if (val1 === val2) {
8624
+ selected = true;
8625
+ }
8626
+
8627
+ if (print !== undefined && print) {
8628
+ return selected ? ' selected="selected"' : '';
8629
+ }
8630
+ return selected;
8631
+ },
8632
+ convert_hex: function (hex, opacity) {
8633
+ if (undefined === hex) {
8634
+ return '';
8635
+ }
8636
+ if (undefined === opacity) {
8637
+ opacity = 100;
8638
+ }
8639
+
8640
+ hex = hex.replace('#', '');
8641
+ var r = parseInt(hex.substring(0, 2), 16),
8642
+ g = parseInt(hex.substring(2, 4), 16),
8643
+ b = parseInt(hex.substring(4, 6), 16),
8644
+ result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')';
8645
+ return result;
8646
+ },
8647
+ debounce: function (callback, threshold) {
8648
+ var timeout;
8649
+ return function () {
8650
+ var context = this, params = arguments;
8651
+ window.clearTimeout(timeout);
8652
+ timeout = window.setTimeout(function () {
8653
+ callback.apply(context, params);
8654
+ }, threshold);
8655
+ };
8656
+ },
8657
+ throttle: function (callback, threshold) {
8658
+ var suppress = false,
8659
+ clear = function () {
8660
+ suppress = false;
8661
+ };
8662
+ return function () {
8663
+ if (!suppress) {
8664
+ callback();
8665
+ window.setTimeout(clear, threshold);
8666
+ suppress = true;
8667
+ }
8668
+ };
8669
+ },
8670
+ serializeForm: function (options) {
8671
+ $.extend({}, options);
8672
+
8673
+ var values = {},
8674
+ settings = $.extend(true, {
8675
+ include: [],
8676
+ exclude: [],
8677
+ includeByClass: ''
8678
+ }, options);
8679
+
8680
+ this.find(':input').each(function () {
8681
+
8682
+ var parsedName;
8683
+
8684
+ // Apply simple checks and filters
8685
+ if (!this.name || this.disabled ||
8686
+ isInArray(settings.exclude, this.name) ||
8687
+ (settings.include.length && !isInArray(settings.include, this.name)) ||
8688
+ this.className.indexOf(settings.includeByClass) === -1) {
8689
+ return;
8690
+ }
8691
+
8692
+ // Parse complex names
8693
+ // JS RegExp doesn't support "positive look behind" :( that's why so weird parsing is used
8694
+ parsedName = this.name.replace(rName, '[$1').split('[');
8695
+ if (!parsedName[0]) {
8696
+ return;
8697
+ }
8698
+
8699
+ if (this.checked ||
8700
+ isInArray(inputTypes, this.type) ||
8701
+ isInArray(inputNodes, this.nodeName.toLowerCase())) {
8702
+
8703
+ // Simulate control with a complex name (i.e. `some[]`)
8704
+ // as it handled in the same way as Checkboxes should
8705
+ if (this.type === 'checkbox') {
8706
+ parsedName.push('');
8707
+ }
8708
+
8709
+ // jQuery.val() is used to simplify of getting values
8710
+ // from the custom controls (which follow jQuery .val() API) and Multiple Select
8711
+ storeValue(values, parsedName, $(this).val());
8712
+ }
8713
+ });
8714
+
8715
+ return values;
8716
+ }
8717
+
8718
+ };
8719
+
8720
+ // Import this module.
8721
+ window.PUM_Admin = window.PUM_Admin || {};
8722
+ window.PUM_Admin.utils = utils;
8723
+
8724
+ // @deprecated 1.7.0 Here for backward compatibility.
8725
+ window.PUMUtils = utils;
8726
+
8727
+ $.fn.pumSerializeForm = utils.serializeForm;
8728
  }(jQuery));
assets/js/admin-general.min.js CHANGED
@@ -1 +1 @@
1
- function pumSelected(e,t,n){"use strict";var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' selected="selected"':"":i}function pumChecked(e,t,n){"use strict";var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' checked="checked"':"":i}!function(e){"function"==typeof define&&void 0!==define.amd&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)}(function(i){var e=function(){if(i&&i.fn&&i.fn.pumselect2&&i.fn.pumselect2.amd)var e=i.fn.pumselect2.amd;var t,r,u,n;return e&&e.requirejs||(e?r=e:e={},function(p){var s,o,h,m,f={},g={},v={},y={},n=Object.prototype.hasOwnProperty,i=[].slice,_=/\.js$/;function b(e,t){return n.call(e,t)}function a(e,t){var n,i,r,s,o,a,l,u,c,d,p,h=t&&t.split("/"),m=v.map,f=m&&m["*"]||{};if(e&&"."===e.charAt(0))if(t){for(o=(e=e.split("/")).length-1,v.nodeIdCompat&&_.test(e[o])&&(e[o]=e[o].replace(_,"")),e=h.slice(0,h.length-1).concat(e),c=0;c<e.length;c+=1)if("."===(p=e[c]))e.splice(c,1),c-=1;else if(".."===p){if(1===c&&(".."===e[2]||".."===e[0]))break;0<c&&(e.splice(c-1,2),c-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((h||f)&&m){for(c=(n=e.split("/")).length;0<c;c-=1){if(i=n.slice(0,c).join("/"),h)for(d=h.length;0<d;d-=1)if((r=m[h.slice(0,d).join("/")])&&(r=r[i])){s=r,a=c;break}if(s)break;!l&&f&&f[i]&&(l=f[i],u=c)}!s&&l&&(s=l,a=u),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function w(t,n){return function(){var e=i.call(arguments,0);return"string"!=typeof e[0]&&1===e.length&&e.push(null),o.apply(p,e.concat([t,n]))}}function A(t){return function(e){f[t]=e}}function x(e){if(b(g,e)){var t=g[e];delete g[e],y[e]=!0,s.apply(p,t)}if(!b(f,e)&&!b(y,e))throw new Error("No "+e);return f[e]}function l(e){var t,n=e?e.indexOf("!"):-1;return-1<n&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}h=function(e,t){var n,i,r=l(e),s=r[0];return e=r[1],s&&(n=x(s=a(s,t))),s?e=n&&n.normalize?n.normalize(e,(i=t,function(e){return a(e,i)})):a(e,t):(s=(r=l(e=a(e,t)))[0],e=r[1],s&&(n=x(s))),{f:s?s+"!"+e:e,n:e,pr:s,p:n}},m={require:function(e){return w(e)},exports:function(e){var t=f[e];return void 0!==t?t:f[e]={}},module:function(e){return{id:e,uri:"",exports:f[e],config:(t=e,function(){return v&&v.config&&v.config[t]||{}})};var t}},s=function(e,t,n,i){var r,s,o,a,l,u,c=[],d=typeof n;if(i=i||e,"undefined"===d||"function"===d){for(t=!t.length&&n.length?["require","exports","module"]:t,l=0;l<t.length;l+=1)if("require"===(s=(a=h(t[l],i)).f))c[l]=m.require(e);else if("exports"===s)c[l]=m.exports(e),u=!0;else if("module"===s)r=c[l]=m.module(e);else if(b(f,s)||b(g,s)||b(y,s))c[l]=x(s);else{if(!a.p)throw new Error(e+" missing "+s);a.p.load(a.n,w(i,!0),A(s),{}),c[l]=f[s]}o=n?n.apply(f[e],c):void 0,e&&(r&&r.exports!==p&&r.exports!==f[e]?f[e]=r.exports:o===p&&u||(f[e]=o))}else e&&(f[e]=n)},t=r=o=function(e,t,n,i,r){if("string"==typeof e)return m[e]?m[e](t):x(h(e,t).f);if(!e.splice){if((v=e).deps&&o(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=p}return t=t||function(){},"function"==typeof n&&(n=i,i=r),i?s(p,e,t,n):setTimeout(function(){s(p,e,t,n)},4),o},o.config=function(e){return o(e)},t._defined=f,(u=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),b(f,e)||b(g,e)||(g[e]=[e,t,n])}).amd={jQuery:!0}}(),e.requirejs=t,e.require=r,e.define=u),e.define("almond",function(){}),e.define("jquery",[],function(){var e=i||$;return null==e&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),e}),e.define("pumselect2/utils",["jquery"],function(s){var e={};function c(e){var t=e.prototype,n=[];for(var i in t){"function"==typeof t[i]&&("constructor"!==i&&n.push(i))}return n}e.Extend=function(e,t){var n={}.hasOwnProperty;function i(){this.constructor=e}for(var r in t)n.call(t,r)&&(e[r]=t[r]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e},e.Decorate=function(i,r){var e=c(r),t=c(i);function s(){var e=Array.prototype.unshift,t=r.prototype.constructor.length,n=i.prototype.constructor;0<t&&(e.call(arguments,i.prototype.constructor),n=r.prototype.constructor),n.apply(this,arguments)}r.displayName=i.displayName,s.prototype=new function(){this.constructor=s};for(var n=0;n<t.length;n++){var o=t[n];s.prototype[o]=i.prototype[o]}for(var a=function(e){var t=function(){};e in s.prototype&&(t=s.prototype[e]);var n=r.prototype[e];return function(){return Array.prototype.unshift.call(arguments,t),n.apply(this,arguments)}},l=0;l<e.length;l++){var u=e[l];s.prototype[u]=a(u)}return s};var t=function(){this.listeners={}};return t.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},t.prototype.trigger=function(e){var t=Array.prototype.slice;this.listeners=this.listeners||{},e in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},t.prototype.invoke=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n].apply(this,t)},e.Observable=t,e.generateChars=function(e){for(var t="",n=0;n<e;n++){t+=Math.floor(36*Math.random()).toString(36)}return t},e.bind=function(e,t){return function(){e.apply(t,arguments)}},e._convertData=function(e){for(var t in e){var n=t.split("-"),i=e;if(1!==n.length){for(var r=0;r<n.length;r++){var s=n[r];(s=s.substring(0,1).toLowerCase()+s.substring(1))in i||(i[s]={}),r==n.length-1&&(i[s]=e[t]),i=i[s]}delete e[t]}}return e},e.hasScroll=function(e,t){var n=s(t),i=t.style.overflowX,r=t.style.overflowY;return(i!==r||"hidden"!==r&&"visible"!==r)&&("scroll"===i||"scroll"===r||(n.innerHeight()<t.scrollHeight||n.innerWidth()<t.scrollWidth))},e.escapeMarkup=function(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.appendMany=function(e,t){if("1.7"===s.fn.jquery.substr(0,3)){var n=s();s.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e}),e.define("pumselect2/results",["jquery","./utils"],function(p,e){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=p('<ul class="pumselect2-results__options" role="tree"></ul>');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=p('<li role="treeitem" aria-live="assertive" class="pumselect2-results__option"></li>'),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" pumselect2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".pumselect2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var i=e.results[n],r=this.option(i);t.push(r)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},i.prototype.position=function(e,t){t.find(".pumselect2-results").append(e)},i.prototype.sort=function(e){return this.options.get("sorter")(e)},i.prototype.setClasses=function(){var r=this;this.data.current(function(e){var i=p.map(e,function(e){return e.id.toString()}),t=r.$results.find(".pumselect2-results__option[aria-selected]");t.each(function(){var e=p(this),t=p.data(this,"data"),n=""+t.id;null!=t.element&&t.element.selected||null==t.element&&-1<p.inArray(n,i)?e.attr("aria-selected","true"):e.attr("aria-selected","false")});var n=t.filter("[aria-selected=true]");0<n.length?n.first().trigger("mouseenter"):t.first().trigger("mouseenter")})},i.prototype.showLoading=function(e){this.hideLoading();var t={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},n=this.option(t);n.className+=" loading-results",this.$results.prepend(n)},i.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},i.prototype.option=function(e){var t=document.createElement("li");t.className="pumselect2-results__option";var n={role:"treeitem","aria-selected":"false"};for(var i in e.disabled&&(delete n["aria-selected"],n["aria-disabled"]="true"),null==e.id&&delete n["aria-selected"],null!=e._resultId&&(t.id=e._resultId),e.title&&(t.title=e.title),e.children&&(n.role="group",n["aria-label"]=e.text,delete n["aria-selected"]),n){var r=n[i];t.setAttribute(i,r)}if(e.children){var s=p(t),o=document.createElement("strong");o.className="pumselect2-results__group";p(o);this.template(e,o);for(var a=[],l=0;l<e.children.length;l++){var u=e.children[l],c=this.option(u);a.push(c)}var d=p("<ul></ul>",{class:"pumselect2-results__options pumselect2-results__options--nested"});d.append(a),s.append(o),s.append(d)}else this.template(e,t);return p.data(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&l.setClasses()}),t.on("unselect",function(){t.isOpen()&&l.setClasses()}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("aria-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e);if(0!==n){var i=n-1;0===e.length&&(i=0);var r=t.eq(i);r.trigger("mouseenter");var s=l.$results.offset().top,o=r.offset().top,a=l.$results.scrollTop()+(o-s);0===i?l.$results.scrollTop(0):o-s<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var r=l.$results.offset().top+l.$results.outerHeight(!1),s=i.offset().top+i.outerHeight(!1),o=l.$results.scrollTop()+s-r;0===n?l.$results.scrollTop(0):r<s&&l.$results.scrollTop(o)}}),t.on("results:focus",function(e){e.element.addClass("pumselect2-results__option--highlighted")}),t.on("results:message",function(e){l.displayMessage(e)}),p.fn.mousewheel&&this.$results.on("mousewheel",function(e){var t=l.$results.scrollTop(),n=l.$results.get(0).scrollHeight-t+e.deltaY,i=0<e.deltaY&&t-e.deltaY<=0,r=e.deltaY<0&&n<=l.$results.height();i?(l.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):r&&(l.$results.scrollTop(l.$results.get(0).scrollHeight-l.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".pumselect2-results__option[aria-selected]",function(e){var t=p(this),n=t.data("data");"true"!==t.attr("aria-selected")?l.trigger("select",{originalEvent:e,data:n}):l.options.get("multiple")?l.trigger("unselect",{originalEvent:e,data:n}):l.trigger("close",{})}),this.$results.on("mouseenter",".pumselect2-results__option[aria-selected]",function(e){var t=p(this).data("data");l.getHighlightedResults().removeClass("pumselect2-results__option--highlighted"),l.trigger("results:focus",{data:t,element:p(this)})})},i.prototype.getHighlightedResults=function(){return this.$results.find(".pumselect2-results__option--highlighted")},i.prototype.destroy=function(){this.$results.remove()},i.prototype.ensureHighlightVisible=function(){var e=this.getHighlightedResults();if(0!==e.length){var t=this.$results.find("[aria-selected]").index(e),n=this.$results.offset().top,i=e.offset().top,r=this.$results.scrollTop()+(i-n),s=i-n;r-=2*e.outerHeight(!1),t<=2?this.$results.scrollTop(0):(s>this.$results.outerHeight()||s<0)&&this.$results.scrollTop(r)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),r=n(e,t);null==r?t.style.display="none":"string"==typeof r?t.innerHTML=i(r):p(t).append(r)},i}),e.define("pumselect2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("pumselect2/selection/base",["jquery","../utils","../keys"],function(n,e,r){function i(e,t){this.$element=e,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=n('<span class="pumselect2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},i.prototype.bind=function(e,t){var n=this,i=(e.id,e.id+"-results");this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===r.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.focus(),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},i.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},i.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.pumselect2."+e.id,function(e){var t=n(e.target).closest(".pumselect2");n(".pumselect2.pumselect2-container--open").each(function(){var e=n(this);this!=t[0]&&e.data("element").pumselect2("close")})})},i.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.pumselect2."+e.id)},i.prototype.position=function(e,t){t.find(".selection").append(e)},i.prototype.destroy=function(){this._detachCloseHandler(this.container)},i.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},i}),e.define("pumselect2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,i){function r(){r.__super__.constructor.apply(this,arguments)}return n.Extend(r,t),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("pumselect2-selection--single"),e.html('<span class="pumselect2-selection__rendered"></span><span class="pumselect2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},r.prototype.bind=function(e,t){var n=this;r.__super__.bind.apply(this,arguments);var i=e.id+"-container";this.$selection.find(".pumselect2-selection__rendered").attr("id",i),this.$selection.attr("aria-labelledby",i),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),e.on("selection:update",function(e){n.update(e.data)})},r.prototype.clear=function(){this.$selection.find(".pumselect2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return e("<span></span>")},r.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".pumselect2-selection__rendered"),i=this.display(t,n);n.empty().append(i),n.prop("title",t.title||t.text)}else this.clear()},r}),e.define("pumselect2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function r(e,t){r.__super__.constructor.apply(this,arguments)}return a.Extend(r,e),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("pumselect2-selection--multiple"),e.html('<ul class="pumselect2-selection__rendered"></ul>'),e},r.prototype.bind=function(e,t){var n=this;r.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".pumselect2-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=i(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}})},r.prototype.clear=function(){this.$selection.find(".pumselect2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return i('<li class="pumselect2-selection__choice"><span class="pumselect2-selection__choice__remove" role="presentation">&times;</span></li>')},r.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n<e.length;n++){var i=e[n],r=this.selectionContainer(),s=this.display(i,r);r.append(s),r.prop("title",i.title||i.text),r.data("data",i),t.push(r)}var o=this.$selection.find(".pumselect2-selection__rendered");a.appendMany(o,t)}},r}),e.define("pumselect2/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("pumselect2-selection__placeholder").removeClass("pumselect2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(1<t.length||n)return e.call(this,t);this.clear();var i=this.createPlaceholder(this.placeholder);this.$selection.find(".pumselect2-selection__rendered").append(i)},t}),e.define("pumselect2/selection/allowClear",["jquery","../keys"],function(i,r){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".pumselect2-selection__clear",function(e){i._handleClear(e)}),t.on("keypress",function(e){i._handleKeyboardClear(e,t)})},e.prototype._handleClear=function(e,t){if(!this.options.get("disabled")){var n=this.$selection.find(".pumselect2-selection__clear");if(0!==n.length){t.stopPropagation();for(var i=n.data("data"),r=0;r<i.length;r++){var s={data:i[r]};if(this.trigger("unselect",s),s.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},e.prototype._handleKeyboardClear=function(e,t,n){n.isOpen()||t.which!=r.DELETE&&t.which!=r.BACKSPACE||this._handleClear(t)},e.prototype.update=function(e,t){if(e.call(this,t),!(0<this.$selection.find(".pumselect2-selection__placeholder").length||0===t.length)){var n=i('<span class="pumselect2-selection__clear">&times;</span>');n.data("data",t),this.$selection.find(".pumselect2-selection__rendered").prepend(n)}},e}),e.define("pumselect2/selection/search",["jquery","../utils","../keys"],function(i,e,o){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=i('<li class="pumselect2-search pumselect2-search--inline"><input class="pumselect2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("open",function(){i.$search.trigger("focus")}),t.on("close",function(){i.$search.val(""),i.$search.removeAttr("aria-activedescendant"),i.$search.trigger("focus")}),t.on("enable",function(){i.$search.prop("disabled",!1),i._transferTabIndex()}),t.on("disable",function(){i.$search.prop("disabled",!0)}),t.on("focus",function(e){i.$search.trigger("focus")}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.id)}),this.$selection.on("focusin",".pumselect2-search--inline",function(e){i.trigger("focus",e)}),this.$selection.on("focusout",".pumselect2-search--inline",function(e){i._handleBlur(e)}),this.$selection.on("keydown",".pumselect2-search--inline",function(e){if(e.stopPropagation(),i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented(),e.which===o.BACKSPACE&&""===i.$search.val()){var t=i.$searchContainer.prev(".pumselect2-selection__choice");if(0<t.length){var n=t.data("data");i.searchRemoveChoice(n),e.preventDefault()}}});var r=document.documentMode,s=r&&r<=11;this.$selection.on("input.searchcheck",".pumselect2-search--inline",function(e){s?i.$selection.off("input.search input.searchcheck"):i.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".pumselect2-search--inline",function(e){if(s&&"input"===e.type)i.$selection.off("input.search input.searchcheck");else{var t=e.which;t!=o.SHIFT&&t!=o.CTRL&&t!=o.ALT&&t!=o.TAB&&i.handleSearch(e)}})},t.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},t.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},t.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".pumselect2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.focus()},t.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var e=this.$search.val();this.trigger("query",{term:e})}this._keyUpPrevented=!1},t.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},t.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";""!==this.$search.attr("placeholder")?e=this.$selection.find(".pumselect2-selection__rendered").innerWidth():e=.75*(this.$search.val().length+1)+"em";this.$search.css("width",e)},t}),e.define("pumselect2/selection/eventRelay",["jquery"],function(o){function e(){}return e.prototype.bind=function(e,t,n){var i=this,r=["open","opening","close","closing","select","selecting","unselect","unselecting"],s=["opening","closing","selecting","unselecting"];e.call(this,t,n),t.on("*",function(e,t){if(-1!==o.inArray(e,r)){t=t||{};var n=o.Event("pumselect2:"+e,{params:t});i.$element.trigger(n),-1!==o.inArray(e,s)&&(t.prevented=n.isDefaultPrevented())}})},e}),e.define("pumselect2/translation",["jquery","require"],function(t,n){function i(e){this.dict=e||{}}return i.prototype.all=function(){return this.dict},i.prototype.get=function(e){return this.dict[e]},i.prototype.extend=function(e){this.dict=t.extend({},e.all(),this.dict)},i._cache={},i.loadPath=function(e){if(!(e in i._cache)){var t=n(e);i._cache[e]=t}return new i(i._cache[e])},i}),e.define("pumselect2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"}}),e.define("pumselect2/data/base",["../utils"],function(i){function n(e,t){n.__super__.constructor.call(this)}return i.Extend(n,i.Observable),n.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},n.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},n.prototype.bind=function(e,t){},n.prototype.destroy=function(){},n.prototype.generateResultId=function(e,t){var n=e.id+"-result-";return n+=i.generateChars(4),null!=t.id?n+="-"+t.id.toString():n+="-"+i.generateChars(4),n},n}),e.define("pumselect2/data/select",["./base","../utils","jquery"],function(e,t,a){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,e),n.prototype.current=function(e){var n=[],i=this;this.$element.find(":selected").each(function(){var e=a(this),t=i.item(e);n.push(t)}),e(n)},n.prototype.select=function(r){var s=this;if(r.selected=!0,a(r.element).is("option"))return r.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(e){var t=[];(r=[r]).push.apply(r,e);for(var n=0;n<r.length;n++){var i=r[n].id;-1===a.inArray(i,t)&&t.push(i)}s.$element.val(t),s.$element.trigger("change")});else{var e=r.id;this.$element.val(e),this.$element.trigger("change")}},n.prototype.unselect=function(r){var s=this;if(this.$element.prop("multiple")){if(r.selected=!1,a(r.element).is("option"))return r.element.selected=!1,void this.$element.trigger("change");this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n].id;i!==r.id&&-1===a.inArray(i,t)&&t.push(i)}s.$element.val(t),s.$element.trigger("change")})}},n.prototype.bind=function(e,t){var n=this;(this.container=e).on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},n.prototype.destroy=function(){this.$element.find("*").each(function(){a.removeData(this,"data")})},n.prototype.query=function(i,e){var r=[],s=this;this.$element.children().each(function(){var e=a(this);if(e.is("option")||e.is("optgroup")){var t=s.item(e),n=s.matches(i,t);null!==n&&r.push(n)}}),e({results:r})},n.prototype.addOptions=function(e){t.appendMany(this.$element,e)},n.prototype.option=function(e){var t;e.children?(t=document.createElement("optgroup")).label=e.text:void 0!==(t=document.createElement("option")).textContent?t.textContent=e.text:t.innerText=e.text,e.id&&(t.value=e.id),e.disabled&&(t.disabled=!0),e.selected&&(t.selected=!0),e.title&&(t.title=e.title);var n=a(t),i=this._normalizeItem(e);return i.element=t,a.data(t,"data",i),n},n.prototype.item=function(e){var t={};if(null!=(t=a.data(e[0],"data")))return t;if(e.is("option"))t={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){t={text:e.prop("label"),children:[],title:e.prop("title")};for(var n=e.children("option"),i=[],r=0;r<n.length;r++){var s=a(n[r]),o=this.item(s);i.push(o)}t.children=i}return(t=this._normalizeItem(t)).element=e[0],a.data(e[0],"data",t),t},n.prototype._normalizeItem=function(e){a.isPlainObject(e)||(e={id:e,text:e});return null!=(e=a.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),a.extend({},{selected:!1,disabled:!1},e)},n.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},n}),e.define("pumselect2/data/array",["./select","../utils","jquery"],function(e,m,f){function i(e,t){var n=t.get("data")||[];i.__super__.constructor.call(this,e,t),this.addOptions(this.convertToOptions(n))}return m.Extend(i,e),i.prototype.select=function(n){var e=this.$element.find("option").filter(function(e,t){return t.value==n.id.toString()});0===e.length&&(e=this.option(n),this.addOptions(e)),i.__super__.select.call(this,n)},i.prototype.convertToOptions=function(e){var t=this,n=this.$element.find("option"),i=n.map(function(){return t.item(f(this)).id}).get(),r=[];function s(e){return function(){return f(this).val()==e.id}}for(var o=0;o<e.length;o++){var a=this._normalizeItem(e[o]);if(0<=f.inArray(a.id,i)){var l=n.filter(s(a)),u=this.item(l),c=f.extend(!0,{},a,u),d=this.option(c);l.replaceWith(d)}else{var p=this.option(a);if(a.children){var h=this.convertToOptions(a.children);m.appendMany(p,h)}r.push(p)}}return r},i}),e.define("pumselect2/data/ajax",["./array","../utils","jquery"],function(e,t,s){function n(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype._applyDefaults=function(e){var t={data:function(e){return s.extend({},e,{q:e.term})},transport:function(e,t,n){var i=s.ajax(e);return i.then(t),i.fail(n),i}};return s.extend({},t,e,!0)},n.prototype.processResults=function(e){return e},n.prototype.query=function(n,i){var r=this;null!=this._request&&(s.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var t=s.extend({type:"GET"},this.ajaxOptions);function e(){var e=t.transport(t,function(e){var t=r.processResults(e,n);r.options.get("debug")&&window.console&&console.error&&(t&&t.results&&s.isArray(t.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),i(t)},function(){r.trigger("results:message",{message:"errorLoading"})});r._request=e}"function"==typeof t.url&&(t.url=t.url.call(this.$element,n)),"function"==typeof t.data&&(t.data=t.data.call(this.$element,n)),this.ajaxOptions.delay&&""!==n.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(e,this.ajaxOptions.delay)):e()},n}),e.define("pumselect2/data/tags",["jquery"],function(c){function e(e,t,n){var i=n.get("tags"),r=n.get("createTag");void 0!==r&&(this.createTag=r);var s=n.get("insertTag");if(void 0!==s&&(this.insertTag=s),e.call(this,t,n),c.isArray(i))for(var o=0;o<i.length;o++){var a=i[o],l=this._normalizeItem(a),u=this.option(l);this.$element.append(u)}}return e.prototype.query=function(e,u,c){var d=this;this._removeOldTags(),null!=u.term&&null==u.page?e.call(this,u,function e(t,n){for(var i=t.results,r=0;r<i.length;r++){var s=i[r],o=null!=s.children&&!e({results:s.children},!0);if(s.text===u.term||o)return!n&&(t.data=i,void c(t))}if(n)return!0;var a=d.createTag(u);if(null!=a){var l=d.option(a);l.attr("data-pumselect2-tag",!0),d.addOptions([l]),d.insertTag(i,a)}t.results=i,c(t)}):e.call(this,u,c)},e.prototype.createTag=function(e,t){var n=c.trim(t.term);return""===n?null:{id:n,text:n}},e.prototype.insertTag=function(e,t,n){t.unshift(n)},e.prototype._removeOldTags=function(e){this._lastTag;this.$element.find("option[data-pumselect2-tag]").each(function(){this.selected||c(this).remove()})},e}),e.define("pumselect2/data/tokenizer",["jquery"],function(d){function e(e,t,n){var i=n.get("tokenizer");void 0!==i&&(this.tokenizer=i),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".pumselect2-search__field")},e.prototype.query=function(e,t,n){var i=this;t.term=t.term||"";var r=this.tokenizer(t,this.options,function(e){i.trigger("select",{data:e})});r.term!==t.term&&(this.$search.length&&(this.$search.val(r.term),this.$search.focus()),t.term=r.term),e.call(this,t,n)},e.prototype.tokenizer=function(e,t,n,i){for(var r=n.get("tokenSeparators")||[],s=t.term,o=0,a=this.createTag||function(e){return{id:e.term,text:e.term}};o<s.length;){var l=s[o];if(-1!==d.inArray(l,r)){var u=s.substr(0,o),c=a(d.extend({},t,{term:u}));null!=c?(i(c),s=s.substr(o+1)||"",o=0):o++}else o++}return{term:s}},e}),e.define("pumselect2/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("pumselect2/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",0<this.maximumInputLength&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("pumselect2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var s=this;this.current(function(e){var t=null!=e?e.length:0;0<s.maximumSelectionLength&&t>=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,r)})},e}),e.define("pumselect2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('<span class="pumselect2-dropdown"><span class="pumselect2-results"></span></span>');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("pumselect2/dropdown/search",["jquery","../utils"],function(r,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=r('<span class="pumselect2-search pumselect2-search--dropdown"><input class="pumselect2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){r(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.val("")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("pumselect2-search--hide"):i.$searchContainer.addClass("pumselect2-search--hide"))})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("pumselect2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("pumselect2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('<li class="pumselect2-results__option pumselect2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("pumselect2/dropdown/attachBody",["jquery","../utils"],function(m,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||m(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("pumselect2"),t.addClass("pumselect2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=m("<span></span>"),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.pumselect2."+t.id,r="resize.pumselect2."+t.id,s="orientationchange.pumselect2."+t.id,o=this.$container.parents().filter(a.hasScroll);o.each(function(){m(this).data("pumselect2-scroll-position",{x:m(this).scrollLeft(),y:m(this).scrollTop()})}),o.on(i,function(e){var t=m(this).data("pumselect2-scroll-position");m(this).scrollTop(t.y)}),m(window).on(i+" "+r+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.pumselect2."+t.id,i="resize.pumselect2."+t.id,r="orientationchange.pumselect2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),m(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=m(window),t=this.$dropdown.hasClass("pumselect2-dropdown--above"),n=this.$dropdown.hasClass("pumselect2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=r.top,s.bottom=r.top+s.height;var o=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),u=a<r.top-o,c=l>r.bottom+o,d={left:r.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),c||!u||t?!u&&c&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-o),null!=i&&(this.$dropdown.removeClass("pumselect2-dropdown--below pumselect2-dropdown--above").addClass("pumselect2-dropdown--"+i),this.$container.removeClass("pumselect2-container--below pumselect2-container--above").addClass("pumselect2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("pumselect2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,i=0;i<t.length;i++){var r=t[i];r.children?n+=e(r.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),e.define("pumselect2/dropdown/selectOnClose",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("close",function(){i._handleSelectOnClose()})},e.prototype._handleSelectOnClose=function(){var e=this.getHighlightedResults();if(!(e.length<1)){var t=e.data("data");null!=t.element&&t.element.selected||null==t.element&&t.selected||this.trigger("select",{data:t})}},e}),e.define("pumselect2/dropdown/closeOnSelect",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",function(e){i._selectTriggered(e)}),t.on("unselect",function(e){i._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&n.ctrlKey||this.trigger("close",{})},e}),e.define("pumselect2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return 1!=t&&(n+="s"),n},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),e.define("pumselect2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(m,f,g,v,y,_,b,w,A,x,$,t,j,C,P,k,O,M,S,E,U,T,D,q,I,z,L,H,e){function n(){this.reset()}return n.prototype.apply=function(t){if(null==(t=m.extend(!0,{},this.defaults,t)).dataAdapter){if(null!=t.ajax?t.dataAdapter=P:null!=t.data?t.dataAdapter=C:t.dataAdapter=j,0<t.minimumInputLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,M)),0<t.maximumInputLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,S)),0<t.maximumSelectionLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,E)),t.tags&&(t.dataAdapter=x.Decorate(t.dataAdapter,k)),null==t.tokenSeparators&&null==t.tokenizer||(t.dataAdapter=x.Decorate(t.dataAdapter,O)),null!=t.query){var e=f(t.amdBase+"compat/query");t.dataAdapter=x.Decorate(t.dataAdapter,e)}if(null!=t.initSelection){var n=f(t.amdBase+"compat/initSelection");t.dataAdapter=x.Decorate(t.dataAdapter,n)}}if(null==t.resultsAdapter&&(t.resultsAdapter=g,null!=t.ajax&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,q)),null!=t.placeholder&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,D)),t.selectOnClose&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,L))),null==t.dropdownAdapter){if(t.multiple)t.dropdownAdapter=U;else{var i=x.Decorate(U,T);t.dropdownAdapter=i}if(0!==t.minimumResultsForSearch&&(t.dropdownAdapter=x.Decorate(t.dropdownAdapter,z)),t.closeOnSelect&&(t.dropdownAdapter=x.Decorate(t.dropdownAdapter,H)),null!=t.dropdownCssClass||null!=t.dropdownCss||null!=t.adaptDropdownCssClass){var r=f(t.amdBase+"compat/dropdownCss");t.dropdownAdapter=x.Decorate(t.dropdownAdapter,r)}t.dropdownAdapter=x.Decorate(t.dropdownAdapter,I)}if(null==t.selectionAdapter){if(t.multiple?t.selectionAdapter=y:t.selectionAdapter=v,null!=t.placeholder&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,_)),t.allowClear&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,b)),t.multiple&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,w)),null!=t.containerCssClass||null!=t.containerCss||null!=t.adaptContainerCssClass){var s=f(t.amdBase+"compat/containerCss");t.selectionAdapter=x.Decorate(t.selectionAdapter,s)}t.selectionAdapter=x.Decorate(t.selectionAdapter,A)}if("string"==typeof t.language)if(0<t.language.indexOf("-")){var o=t.language.split("-")[0];t.language=[t.language,o]}else t.language=[t.language];if(m.isArray(t.language)){var a=new $;t.language.push("en");for(var l=t.language,u=0;u<l.length;u++){var c=l[u],d={};try{d=$.loadPath(c)}catch(e){try{c=this.defaults.amdLanguageBase+c,d=$.loadPath(c)}catch(e){t.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+c+'" could not be automatically loaded. A fallback will be used instead.');continue}}a.extend(d)}t.translations=a}else{var p=$.loadPath(this.defaults.amdLanguageBase+"en"),h=new $(t.language);h.extend(p),t.translations=h}return t},n.prototype.reset=function(){function a(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:x.escapeMarkup,language:e,matcher:function e(t,n){if(""===m.trim(t.term))return n;if(n.children&&0<n.children.length){for(var i=m.extend(!0,{},n),r=n.children.length-1;0<=r;r--)null==e(t,n.children[r])&&i.children.splice(r,1);return 0<i.children.length?i:e(t,i)}var s=a(n.text).toUpperCase(),o=a(t.term).toUpperCase();return-1<s.indexOf(o)?n:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},n.prototype.set=function(e,t){var n={};n[m.camelCase(e)]=t;var i=x._convertData(n);m.extend(this.defaults,i)},new n}),e.define("pumselect2/options",["require","jquery","./defaults","./utils"],function(i,s,r,o){function e(e,t){if(this.options=e,null!=t&&this.fromElement(t),this.options=r.apply(this.options),t&&t.is("input")){var n=i(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=o.Decorate(this.options.dataAdapter,n)}}return e.prototype.fromElement=function(e){var t=["pumselect2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.language&&(e.prop("lang")?this.options.language=e.prop("lang").toLowerCase():e.closest("[lang]").prop("lang")&&(this.options.language=e.closest("[lang]").prop("lang"))),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),e.data("pumselect2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-pumselect2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),e.data("data",e.data("pumselect2Tags")),e.data("tags",!0)),e.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",e.data("ajaxUrl")),e.data("ajax--url",e.data("ajaxUrl")));var n={};n=s.fn.jquery&&"1."==s.fn.jquery.substr(0,2)&&e[0].dataset?s.extend(!0,{},e[0].dataset,e.data()):e.data();var i=s.extend(!0,{},n);for(var r in i=o._convertData(i))-1<s.inArray(r,t)||(s.isPlainObject(this.options[r])?s.extend(this.options[r],i[r]):this.options[r]=i[r]);return this},e.prototype.get=function(e){return this.options[e]},e.prototype.set=function(e,t){this.options[e]=t},e}),e.define("pumselect2/core",["jquery","./options","./utils","./keys"],function(r,u,n,i){var c=function(e,t){null!=e.data("pumselect2")&&e.data("pumselect2").destroy(),this.$element=e,this.id=this._generateId(e),t=t||{},this.options=new u(t,e),c.__super__.constructor.call(this);var n=e.attr("tabindex")||0;e.data("old-tabindex",n),e.attr("tabindex","-1");var i=this.options.get("dataAdapter");this.dataAdapter=new i(e,this.options);var r=this.render();this._placeContainer(r);var s=this.options.get("selectionAdapter");this.selection=new s(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,r);var o=this.options.get("dropdownAdapter");this.dropdown=new o(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,r);var a=this.options.get("resultsAdapter");this.results=new a(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var l=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){l.trigger("selection:update",{data:e})}),e.addClass("pumselect2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),e.data("pumselect2",this)};return n.Extend(c,n.Observable),c.prototype._generateId=function(e){return"pumselect2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+n.generateChars(2):n.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},c.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},c.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var i=this._resolveWidth(e,"style");return null!=i?i:this._resolveWidth(e,"element")}if("element"==t){var r=e.outerWidth(!1);return r<=0?"auto":r+"px"}if("style"!=t)return t;var s=e.attr("style");if("string"!=typeof s)return null;for(var o=s.split(";"),a=0,l=o.length;a<l;a+=1){var u=o[a].replace(/\s/g,"").match(n);if(null!==u&&1<=u.length)return u[1]}return null},c.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},c.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.pumselect2",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this._sync=n.bind(this._syncAttributes,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._sync);var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=e?(this._observer=new e(function(e){r.each(e,t._sync)}),this._observer.observe(this.$element[0],{attributes:!0,subtree:!1})):this.$element[0].addEventListener&&this.$element[0].addEventListener("DOMAttrModified",t._sync,!1)},c.prototype._registerDataEvents=function(){var n=this;this.dataAdapter.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerSelectionEvents=function(){var n=this,i=["toggle","focus"];this.selection.on("toggle",function(){n.toggleDropdown()}),this.selection.on("focus",function(e){n.focus(e)}),this.selection.on("*",function(e,t){-1===r.inArray(e,i)&&n.trigger(e,t)})},c.prototype._registerDropdownEvents=function(){var n=this;this.dropdown.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerResultsEvents=function(){var n=this;this.results.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerEvents=function(){var n=this;this.on("open",function(){n.$container.addClass("pumselect2-container--open")}),this.on("close",function(){n.$container.removeClass("pumselect2-container--open")}),this.on("enable",function(){n.$container.removeClass("pumselect2-container--disabled")}),this.on("disable",function(){n.$container.addClass("pumselect2-container--disabled")}),this.on("blur",function(){n.$container.removeClass("pumselect2-container--focus")}),this.on("query",function(t){n.isOpen()||n.trigger("open",{}),this.dataAdapter.query(t,function(e){n.trigger("results:all",{data:e,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(e){n.trigger("results:append",{data:e,query:t})})}),this.on("keypress",function(e){var t=e.which;n.isOpen()?t===i.ESC||t===i.TAB||t===i.UP&&e.altKey?(n.close(),e.preventDefault()):t===i.ENTER?(n.trigger("results:select",{}),e.preventDefault()):t===i.SPACE&&e.ctrlKey?(n.trigger("results:toggle",{}),e.preventDefault()):t===i.UP?(n.trigger("results:previous",{}),e.preventDefault()):t===i.DOWN&&(n.trigger("results:next",{}),e.preventDefault()):(t===i.ENTER||t===i.SPACE||t===i.DOWN&&e.altKey)&&(n.open(),e.preventDefault())})},c.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},c.prototype.trigger=function(e,t){var n=c.__super__.trigger,i={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===t&&(t={}),e in i){var r=i[e],s={prevented:!1,name:e,args:t};if(n.call(this,r,s),s.prevented)return void(t.prevented=!0)}n.call(this,e,t)},c.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},c.prototype.open=function(){this.isOpen()||this.trigger("query",{})},c.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},c.prototype.isOpen=function(){return this.$container.hasClass("pumselect2-container--open")},c.prototype.hasFocus=function(){return this.$container.hasClass("pumselect2-container--focus")},c.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("pumselect2-container--focus"),this.trigger("focus",{}))},c.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `pumselect2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);var t=!e[0];this.$element.prop("disabled",t)},c.prototype.data=function(){this.options.get("debug")&&0<arguments.length&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `pumselect2("data")`. You should consider setting the value instead using `$element.val()`.');var t=[];return this.dataAdapter.current(function(e){t=e}),t},c.prototype.val=function(e){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `pumselect2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==e||0===e.length)return this.$element.val();var t=e[0];r.isArray(t)&&(t=r.map(t,function(e){return e.toString()})),this.$element.val(t).trigger("change")},c.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._sync),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&this.$element[0].removeEventListener("DOMAttrModified",this._sync,!1),this._sync=null,this.$element.off(".pumselect2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("pumselect2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("pumselect2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},c.prototype.render=function(){var e=r('<span class="pumselect2 pumselect2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("pumselect2-container--"+this.options.get("theme")),e.data("element",this.$element),e},c}),e.define("pumselect2/compat/utils",["jquery"],function(o){return{syncCssClasses:function(e,t,n){var i,r,s=[];(i=o.trim(e.attr("class")))&&o((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("pumselect2-")&&s.push(this)}),(i=o.trim(t.attr("class")))&&o((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("pumselect2-")&&null!=(r=n(this))&&s.push(r)}),e.attr("class",s.join(" "))}}}),e.define("pumselect2/compat/containerCss",["jquery","./utils"],function(o,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";o.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var r=i;i=function(e){var t=r(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return o.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("pumselect2/compat/dropdownCss",["jquery","./utils"],function(o,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";o.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var r=i;i=function(e){var t=r(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return o.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("pumselect2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("pumselect2/compat/inputData",["jquery"],function(o){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `<select>` element instead."),e.call(this,t,n)}return e.prototype.current=function(e,t){function i(e,t){var n=[];return e.selected||-1!==o.inArray(e.id,t)?(e.selected=!0,n.push(e)):e.selected=!1,e.children&&n.push.apply(n,i(e.children,t)),n}for(var n=[],r=0;r<this._currentData.length;r++){var s=this._currentData[r];n.push.apply(n,i(s,this.$element.val().split(this._valueSeparator)))}t(n)},e.prototype.select=function(e,t){if(this.options.get("multiple")){var n=this.$element.val();n+=this._valueSeparator+t.id,this.$element.val(n),this.$element.trigger("change")}else this.current(function(e){o.map(e,function(e){e.selected=!1})}),this.$element.val(t.id),this.$element.trigger("change")},e.prototype.unselect=function(e,r){var s=this;r.selected=!1,this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];r.id!=i.id&&t.push(i.id)}s.$element.val(t.join(s._valueSeparator)),s.$element.trigger("change")})},e.prototype.query=function(e,t,n){for(var i=[],r=0;r<this._currentData.length;r++){var s=this._currentData[r],o=this.matches(t,s);null!==o&&i.push(o)}n({results:i})},e.prototype.addOptions=function(e,t){var n=o.map(t,function(e){return o.data(e[0],"data")});this._currentData.push.apply(this._currentData,n)},e}),e.define("pumselect2/compat/matcher",["jquery"],function(o){return function(s){return function(e,t){var n=o.extend(!0,{},t);if(null==e.term||""===o.trim(e.term))return n;if(t.children){for(var i=t.children.length-1;0<=i;i--){var r=t.children[i];s(e.term,r.text,r)||n.children.splice(i,1)}if(0<n.children.length)return n}return s(e.term,t.text,t)?n:null}}}),e.define("pumselect2/compat/query",[],function(){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `query` option has been deprecated in favor of a custom data adapter that overrides the `query` method. Support will be removed for the `query` option in future versions of Select2."),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.callback=n,this.options.get("query").call(null,t)},e}),e.define("pumselect2/dropdown/attachContainer",[],function(){function e(e,t,n){e.call(this,t,n)}return e.prototype.position=function(e,t,n){n.find(".dropdown-wrapper").append(t),t.addClass("pumselect2-dropdown--below"),n.addClass("pumselect2-container--below")},e}),e.define("pumselect2/dropdown/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$dropdown.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),e.define("pumselect2/selection/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$selection.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),n=function(p){var h,m,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],t="onwheel"in document||9<=document.documentMode?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],f=Array.prototype.slice;if(p.event.fixHooks)for(var n=e.length;n;)p.event.fixHooks[e[--n]]=p.event.mouseHooks;var g=p.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],i,!1);else this.onmousewheel=i;p.data(this,"mousewheel-line-height",g.getLineHeight(this)),p.data(this,"mousewheel-page-height",g.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],i,!1);else this.onmousewheel=null;p.removeData(this,"mousewheel-line-height"),p.removeData(this,"mousewheel-page-height")},getLineHeight:function(e){var t=p(e),n=t["offsetParent"in p.fn?"offsetParent":"parent"]();return n.length||(n=p("body")),parseInt(n.css("fontSize"),10)||parseInt(t.css("fontSize"),10)||16},getPageHeight:function(e){return p(e).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function i(e){var t,n=e||window.event,i=f.call(arguments,1),r=0,s=0,o=0,a=0,l=0;if((e=p.event.fix(n)).type="mousewheel","detail"in n&&(o=-1*n.detail),"wheelDelta"in n&&(o=n.wheelDelta),"wheelDeltaY"in n&&(o=n.wheelDeltaY),"wheelDeltaX"in n&&(s=-1*n.wheelDeltaX),"axis"in n&&n.axis===n.HORIZONTAL_AXIS&&(s=-1*o,o=0),r=0===o?s:o,"deltaY"in n&&(r=o=-1*n.deltaY),"deltaX"in n&&(s=n.deltaX,0===o&&(r=-1*s)),0!==o||0!==s){if(1===n.deltaMode){var u=p.data(this,"mousewheel-line-height");r*=u,o*=u,s*=u}else if(2===n.deltaMode){var c=p.data(this,"mousewheel-page-height");r*=c,o*=c,s*=c}if(t=Math.max(Math.abs(o),Math.abs(s)),(!m||t<m)&&y(n,m=t)&&(m/=40),y(n,t)&&(r/=40,s/=40,o/=40),r=Math[1<=r?"floor":"ceil"](r/m),s=Math[1<=s?"floor":"ceil"](s/m),o=Math[1<=o?"floor":"ceil"](o/m),g.settings.normalizeOffset&&this.getBoundingClientRect){var d=this.getBoundingClientRect();a=e.clientX-d.left,l=e.clientY-d.top}return e.deltaX=s,e.deltaY=o,e.deltaFactor=m,e.offsetX=a,e.offsetY=l,e.deltaMode=0,i.unshift(e,r,s,o),h&&clearTimeout(h),h=setTimeout(v,200),(p.event.dispatch||p.event.handle).apply(this,i)}}function v(){m=null}function y(e,t){return g.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}p.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})},"function"==typeof e.define&&e.define.amd?e.define("jquery-mousewheel",["jquery"],n):"object"==typeof exports?module.exports=n:n(i),e.define("jquery.pumselect2",["jquery","jquery-mousewheel","./pumselect2/core","./pumselect2/defaults"],function(r,e,t,n){if(null==r.fn.pumselect2){var s=["open","close","destroy"];r.fn.pumselect2=function(n){if("object"==typeof(n=n||{}))return this.each(function(){var e=r.extend(!0,{},n);new t(r(this),e)}),this;if("string"!=typeof n)throw new Error("Invalid arguments for Select2: "+n);var i;return this.each(function(){var e=r(this).data("pumselect2");null==e&&window.console&&console.error&&console.error("The pumselect2('"+n+"') method was called on an element that is not using Select2.");var t=Array.prototype.slice.call(arguments,1);i=e[n].apply(e,t)}),-1<r.inArray(n,s)?this:i}}return null==r.fn.pumselect2.defaults&&(r.fn.pumselect2.defaults=n),t}),{define:e.define,require:e.require}}(),t=e.require("jquery.pumselect2");return i.fn.pumselect2.amd=e,t}),function(l){"use strict";var e=l(".pum-alerts"),u=l(".pum-alert-count"),c=parseInt(u.eq(0).text());function d(){0===e.find(".pum-alert-holder").length&&(e.slideUp(100,function(){e.remove()}),l("#menu-posts-popup .wp-menu-name .update-plugins").fadeOut())}l(document).on("pumDismissAlert",d).on("click",".pum-alert-holder .pum-dismiss",function(){var e,t,n,i,r,s=l(this),o=s.parents(".pum-alert-holder"),a=s.data("reason")||"maybe_later";"review_request"!==o.data("code")?(n=(t=o).data("dismissible"),i="1"===n||1===n||!0===n?null:n,l.ajax({method:"POST",dataType:"json",url:ajaxurl,data:{action:"pum_alerts_action",nonce:window.pum_alerts_nonce,code:t.data("code"),expires:i}})):(e=a,l.ajax({method:"POST",dataType:"json",url:ajaxurl,data:{action:"pum_review_action",nonce:window.pum_review_nonce,group:window.pum_review_trigger.group,code:window.pum_review_trigger.code,pri:window.pum_review_trigger.pri,reason:e}}),void 0!==window.pum_review_api_url&&l.ajax({method:"POST",dataType:"json",url:window.pum_review_api_url,data:{trigger_group:window.pum_review_trigger.group,trigger_code:window.pum_review_trigger.code,reason:e,uuid:window.pum_review_uuid||null}})),r=o,c--,u.text(c),r.fadeTo(100,0,function(){r.slideUp(100,function(){r.remove(),d()})})})}(jQuery),function(r){"use strict";var e={init:function(){r(".pum-color-picker").filter(":not(.pum-color-picker-initialized)").addClass("pum-color-picker-initialized").wpColorPicker({change:function(e,t){r(e.target).trigger("colorchange",t)},clear:function(e){r(e.target).prev().trigger("colorchange").wpColorPicker("close")},hide:!0})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.colorpicker=e,r(document).on("click",".iris-palette",function(){r(this).parents(".wp-picker-active").find("input.pum-color-picker").trigger("change")}).on("colorchange",function(e,t){var n=r(e.target),i="";void 0!==t&&void 0!==t.color&&(i=t.color.toString()),n.val(i).trigger("change"),"popup_theme"===r("form#post input#post_type").val()&&PUM_Admin.utils.debounce(PUM_Admin.themeEditor.refresh_preview,100)}).on("pum_init",e.init)}(jQuery),function(h){"use strict";var c={init:function(){c.checkDependencies()},checkDependencies:function(e){var t=h(e);(e=t.length?t:h("[data-pum-dependencies]:not([data-pum-processed-dependencies])")).each(function(){var e,l=h(this),u=l.data("id"),c=l.data("pum-processed-dependencies")||{},d=Object.keys(c).length,p=0,t=l.data("pum-dependent-fields");if(!l.data("pum-processed-dependencies")){for(e in"string"==typeof(c=l.data("pum-dependencies"))&&(c=JSON.parse(c)),c)c.hasOwnProperty(e)&&("string"==typeof c[e]?-1!==c[e].indexOf(",")?c[e]=c[e].split(","):c[e]=[c[e]]:"number"==typeof c[e]&&(c[e]=[c[e]]));d=Object.keys(c).length,l.data("pum-processed-dependencies",c).attr("data-pum-processed-dependencies",c)}t||(t=h.map(c,function(e,t){var n=h('.pum-field[data-id="'+t+'"]');return n.length?n.eq(0):null}),l.data("pum-dependent-fields",t)),h(t).each(function(){var e,t=h(this),n=t.find(":input:first"),i=t.data("id"),r=n.val(),s=c[i],o=t.data("pum-field-dependents")||[];if(-1===o.indexOf(u)&&(o.push(u),t.data("pum-field-dependents",o)),null==s)return l.removeClass("pum-dependencies-met").hide(0).trigger("pumFormDependencyUnmet"),!1;if(t.hasClass("pum-field-radio")&&(r=t.find(":input:checked").val()),t.hasClass("pum-field-multicheck")&&(r=[],t.find(":checkbox:checked").each(function(e){r[e]=h(this).val(),"string"!=typeof r[e]||isNaN(parseInt(r[e]))||(r[e]=parseInt(r[e]))})),t.hasClass("pum-field-select")||t.hasClass("pum-field-radio"))e=s&&-1!==s.indexOf(r);else if(t.hasClass("pum-field-checkbox"))e=s===n.is(":checked");else if(t.hasClass("pum-field-multicheck"))if(Array.isArray(s)){e=!1;for(var a=0;a<s.length;a++)-1!==r.indexOf(s[a])&&(e=!0)}else e=-1!==r.indexOf(s);else e=Array.isArray(s)?-1!==s.indexOf(r):s==r;if(!e)return l.removeClass("pum-dependencies-met").hide(0).trigger("pumFormDependencyUnmet"),!1;++p===d&&l.addClass("pum-dependencies-met").show(0).trigger("pumFormDependencyMet")})})},form_check:function(){h(document).trigger("pum_form_check")},is_field:function(e){return"object"==typeof e&&0<=[void 0===e.type&&(void 0!==e.label||void 0!==e.desc),void 0!==e.type&&"string"==typeof e.type].indexOf(!0)},flattenFields:function(e){var i={},t=e.tabs||{},n=e.sections||{},r=e.fields||{};return Object.keys(t).length&&Object.keys(n).length?_.each(r,function(e,t){"object"==typeof e&&Object.keys(e).length&&_.each(e,function(e,t){if("object"==typeof e&&Object.keys(e).length){if(c.is_field(e)){var n={};n[t]=e,t="main",e=n}_.each(e,function(e){i[e.id]=e})}})}):Object.keys(t).length?_.each(r,function(e,t){"object"==typeof e&&Object.keys(e).length&&_.each(e,function(e){i[e.id]=e})}):Object.keys(n).length?_.each(r,function(e,t){_.each(e,function(e){i[e.id]=e})}):(r=c.parseFields(r,values),_.each(r,function(e){i[e.id]=e})),i},parseFields:function(n,i){return i=i||{},_.each(n,function(e,t){n[t]=PUM_Admin.models.field(e),"object"!=typeof n[t].meta&&(n[t].meta={}),void 0!==i[t]&&(n[t].value=i[t]),""===n[t].id&&(n[t].id=t)}),n},renderTab:function(){},renderSection:function(){},render:function(e,r,t){var n,i=[],s={},o=h.extend(!0,{id:"",tabs:{},sections:{},fields:{},maintabs:{},subtabs:{}},e),a=h.extend({id:o.id,classes:[],tabs:{},vertical:!0,form:!0,meta:{"data-min-height":250}},o.maintabs),l=h.extend({classes:["link-tabs","sub-tabs"],tabs:{}},o.subtabs),u=["pum-dynamic-form"];return r=r||{},Object.keys(o.tabs).length&&Object.keys(o.sections).length?(u.push("tabbed-content"),_.each(o.fields,function(e,i){"object"==typeof e&&Object.keys(e).length&&(void 0===a.tabs[i]&&(a.tabs[i]={label:o.tabs[i],content:""}),l=h.extend(l,{id:o.id+"-"+i+"-subtabs",tabs:{}}),_.each(e,function(e,t){if("object"==typeof e&&Object.keys(e).length){if(c.is_field(e)){var n={};n[t]=e,t="main",e=n}void 0===l.tabs[t]&&(l.tabs[t]={label:o.sections[i][t],content:""}),e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,l.tabs[t].content+=PUM_Admin.templates.field(e)}),""===l.tabs[t].content&&delete l.tabs[t]}}),Object.keys(l.tabs).length?a.tabs[i].content=PUM_Admin.templates.tabs(l):delete a.tabs[i])}),Object.keys(a.tabs).length&&(n=PUM_Admin.templates.tabs(a))):Object.keys(o.tabs).length?(u.push("tabbed-content"),_.each(o.fields,function(e,t){"object"==typeof e&&Object.keys(e).length&&(void 0===a.tabs[t]&&(a.tabs[t]={label:o.tabs[t],content:""}),i=[],e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),i.length?a.tabs[t].content=PUM_Admin.templates.section({fields:i}):delete a.tabs[t])}),Object.keys(a.tabs).length&&(n=PUM_Admin.templates.tabs(a))):Object.keys(o.sections).length?_.each(o.fields,function(e,t){(i=[]).push(PUM_Admin.templates.field({type:"heading",desc:o.sections[t]||""})),e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),n+=PUM_Admin.templates.section({fields:i})}):(o.fields=c.parseFields(o.fields,r),_.each(o.fields,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),n=PUM_Admin.templates.section({fields:i})),void 0!==t&&t.length&&t.addClass(u.join(" ")).data("form_fields",s).html(n).trigger("pum_init"),n},parseValues:function(e,t){if(!(t=t||!1))return e;for(var n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n+"_unit")&&(e[n]+=e[n+"_unit"],delete e[n+"_unit"]),void 0!==e[n]?t[n].allow_html&&!PUM_Admin.utils.htmlencoder.hasEncoded(e[n])&&(e[n]=PUM_Admin.utils.htmlencoder.htmlEncode(e[n])):"checkbox"===t[n].type&&(e[n]=!1));return e}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.forms=c,h(document).on("pum_init pum_form_check",function(){PUM_Admin.forms.init()}).on("pumFieldChanged",".pum-field",function(){var e,t=h(this).data("pum-field-dependents")||[],n=h();if(t&&!(t.length<=0)){for(e=0;e<t.length;e++)n=n.add('.pum-field[data-id="'+t[e]+'"]');PUM_Admin.forms.checkDependencies(n)}}).on("pumFieldChanged",".pum-field-dynamic-desc",function(){var e=h(this),t=e.find(":input"),n=e.parents(".pum-dynamic-form:first"),i=t.val(),r=(n.data("form_fields")||{})[e.data("id")]||{},s=e.find(".pum-desc"),o=e.data("pum-dynamic-desc");switch(r.type){case"radio":i=e.find(":input:checked").val()}r.value=i,o&&o.length&&s.html(PUM_Admin.templates.renderInline(o,r))}).on("change",".pum-field-select select",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-checkbox input",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-multicheck input",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-radio input",function(e){var t=h(this),n=t.parents("li"),i=t.parents(".pum-field");i.trigger("pumFieldChanged"),i.find("li.pum-selected").removeClass("pum-selected"),n.addClass("pum-selected")})}(jQuery),function(s){"use strict";var i,r,o=s("html"),t=s(document),a="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",e={_current:null,forceFocus:function(e){PUM_Admin.modals._current&&!PUM_Admin.modals._current.contains(e.target)&&(e.stopPropagation(),PUM_Admin.modals._current.focus())},trapEscapeKey:function(e){27===e.keyCode&&(PUM_Admin.modals.closeAll(),e.preventDefault())},trapTabKey:function(e){if(9===e.keyCode){var t=PUM_Admin.modals._current.find("*").filter(a).filter(":visible"),n=s(":focus"),i=t.length,r=t.index(n);e.shiftKey?0===r&&(t.get(i-1).focus(),e.preventDefault()):r===i-1&&(t.get(0).focus(),e.preventDefault())}},setFocusToFirstItem:function(){PUM_Admin.modals._current.find(".pum-modal-content *").filter(a).filter(":visible").first().focus()},closeAll:function(e){s(".pum-modal-background").off("keydown.pum_modal").hide(0,function(){s("html").css({overflow:"visible",width:"auto"}),i&&(i.attr("aria-hidden","false"),i=null),r.length&&r.focus(),PUM_Admin.modals._current=null,t.off("focus.pum_modal"),void 0!==e&&e()}).attr("aria-hidden","true")},show:function(e,t){s(".pum-modal-background").off("keydown.pum_modal").hide(0).attr("aria-hidden","true"),o.data("origwidth",o.innerWidth()).css({overflow:"hidden",width:o.innerWidth()});var n=s(":focus");n.parents(".pum-modal-wrap").length||(r=n),PUM_Admin.modals._current=s(e),PUM_Admin.modals._current.on("keydown.pum_modal",function(e){PUM_Admin.modals.trapEscapeKey(e),PUM_Admin.modals.trapTabKey(e)}).show(0,function(){(i=s("body > *").filter(":visible").not(PUM_Admin.modals._current)).attr("aria-hidden","true"),PUM_Admin.modals._current.trigger("pum_init").on("focus.pum_modal",PUM_Admin.modals.forceFocus),PUM_Admin.modals.setFocusToFirstItem(),void 0!==t&&t()}).attr("aria-hidden","false")},remove:function(e){s(e).remove()},replace:function(e,t){PUM_Admin.modals.remove(s.trim(e)),s("body").append(s.trim(t))},reload:function(e,t,n){PUM_Admin.modals.replace(e,t),PUM_Admin.modals.show(e,n),s(e).trigger("pum_init")}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.modals=e,s(document).on("click",".pum-modal-background, .pum-modal-wrap .cancel, .pum-modal-wrap .pum-modal-close",function(e){var t=s(e.target);(t.hasClass("cancel")||t.hasClass("pum-modal-close")||t.hasClass("submitdelete"))&&(PUM_Admin.modals.closeAll(),e.preventDefault(),e.stopPropagation())})}(jQuery),function(t){"use strict";var e={field:function(e){return t.extend(!0,{},{type:"text",id:"",id_prefix:"",name:"",label:null,placeholder:"",desc:null,dynamic_desc:null,size:"regular",classes:[],dependencies:"",value:null,select2:!1,allow_html:!1,multiple:!1,as_array:!1,options:[],object_type:null,object_key:null,std:null,min:0,max:50,step:1,unit:"px",units:{},required:!1,desc_position:"bottom",meta:{}},e)}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.models=e}(jQuery),function(a){"use strict";var s={cloneables:{slider:a('<input type="range" class="pum-range-slider" />'),plus:a('<button type="button" class="pum-range-plus">+</button>'),minus:a('<button type="button" class="pum-range-minus">-</button>')},init:function(){a(".pum-field-rangeslider:not(.pum-rangeslider-initialized)").each(function(){var e=a(this).addClass("pum-rangeslider-initialized").find("input.pum-range-manual"),t=s.cloneables.slider.clone(),n=s.cloneables.plus.clone(),i=s.cloneables.minus.clone(),r={force:e.data("force-minmax"),min:parseInt(e.attr("min"),10)||0,max:parseInt(e.attr("max"),10)||100,step:parseInt(e.attr("step"),10)||1,value:parseInt(e.attr("value"),10)||0};r.force&&r.value>r.max&&(r.value=r.max,e.val(r.value)),t.prop({min:r.min||0,max:r.force||r.max&&r.max>r.value?r.max:1.5*r.value,step:r.step||1.5*r.value/100,value:r.value}).on("change input",function(){e.trigger("input")}),e.next().after(i,n),e.before(t)})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.rangesliders=s,a(document).on("pum_init",PUM_Admin.rangesliders.init).on("input",".pum-field-rangeslider.pum-rangeslider-initialized .pum-range-slider",function(){var e=a(this);e.siblings(".pum-range-manual").val(e.val())}).on("change",".pum-range-manual",function(){var e=a(this),t=parseInt(e.prop("max"),0),n=parseInt(e.prop("min"),0),i=parseInt(e.prop("step"),0),r=e.data("force-minmax"),s=parseInt(e.val(),0),o=e.prev();isNaN(s)&&(s=o.val()),r&&t<s?s=t:r&&s<n&&(s=n),e.val(s).trigger("input"),o.prop({max:r||t&&s<t?t:1.5*s,step:i||1.5*s/100,value:s})}).on("click",".pum-range-plus",function(e){var t=a(this).siblings(".pum-range-manual"),n=parseInt(t.prop("max"),0),i=parseInt(t.prop("step"),0),r=t.data("force-minmax"),s=parseInt(t.val(),0),o=t.prev();e.preventDefault(),s+=i,isNaN(s)&&(s=o.val()),r&&n<s&&(s=n),t.val(s).trigger("input"),o.val(s)}).on("click",".pum-range-minus",function(e){var t=a(this).siblings(".pum-range-manual"),n=parseInt(t.prop("min"),0),i=parseInt(t.prop("step"),0),r=t.data("force-minmax"),s=parseInt(t.val(),0),o=t.prev();e.preventDefault(),s-=i,isNaN(s)&&(s=o.val()),r&&s<n&&(s=n),t.val(s).trigger("input"),o.val(s)})}(jQuery),function(o){"use strict";o.fn.pumselect2=o.fn.pumselect2||o.fn.select2;var e={init:function(){o(".pum-field-select2 select").filter(":not(.pumselect2-initialized)").each(function(){var n=o(this),t=n.data("current")||n.val(),i=n.data("objecttype"),r=n.data("objectkey"),s=n.data("objectexcludes")||null,e={width:"100%",multiple:!1,dropdownParent:n.parent()};n.attr("multiple")&&(e.multiple=!0),i&&r&&(e=o.extend(e,{ajax:{url:ajaxurl,dataType:"json",delay:250,data:function(e){return{s:e.term,paged:e.page,action:"pum_object_search",object_type:i,object_key:r,exclude:s}},processResults:function(e,t){return t.page=t.page||1,{results:e.items,pagination:{more:10*t.page<e.total_count}}},cache:!0},cache:!0,escapeMarkup:function(e){return e},maximumInputLength:20,closeOnSelect:!e.multiple,templateResult:PUM_Admin.select2.formatObject,templateSelection:PUM_Admin.select2.formatObjectSelection})),n.addClass("pumselect2-initialized").pumselect2(e),null!=t?e.multiple&&"object"!=typeof t&&""!==t?t=[t]:e.multiple||""!==t||(t=null):t=null,i&&r&&null!==t&&("number"==typeof t||t.length)?o.ajax({url:ajaxurl,data:{action:"pum_object_search",object_type:i,object_key:r,exclude:s,include:t&&t.length?"string"==typeof t||"number"==typeof t?[t]:t:null},dataType:"json",success:function(e){o.each(e.items,function(e,t){n.find('option[value="'+t.id+'"]').length||n.prepend('<option value="'+t.id+'">'+t.text+"</option>")}),n.val(t).trigger("change")}}):t&&(e.multiple&&t.length||!e.multiple&&""!==t)?n.val(t).trigger("change"):null===t&&n.val(t).trigger("change")})},formatObject:function(e){return e.text},formatObjectSelection:function(e){return e.text||e.text}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.select2=e,o(document).on("pum_init",function(){PUM_Admin.select2.init()})}(jQuery),function(n,i){if("function"!=typeof window.$$){var r,s,o={},a={};window.$$=function(e,t){return t?((r=t.selector)&&(t=r),(s=a[t])===i&&(s=a[t]={}),(r=s[e])!==i?r:s[e]=n(e,$$(t))):(r=o[e])!==i?r:o[e]=n(e)},window.$$clear=function(e,t){t?((r=t.selector)&&(t=r),e&&(r=a[t])&&(r[e]=i),a[t]=i):e?(o[e]=i,a[e]=i):(o={},a={})},window.$$fresh=function(e,t){return $$clear(e,t),$$(e,t)}}}(jQuery),function(e,n){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,t){return n(e,t)});else if("undefined"!=typeof exports){var t=require("jquery");n(exports,t)}else n(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,a){var l={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};function t(i,n){var r={},s={};function o(e,t,n){return e[t]=n,e}function e(){return r}this.addPair=function(e){if(!l.validate.test(e.name))return this;var t=function(e,t){var n,i,r=e.match(l.key);try{t=JSON.parse(t)}catch(e){}for(;void 0!==(n=r.pop());)l.push.test(n)?t=o([],(i=e.replace(/\[\]$/,""),void 0===s[i]&&(s[i]=0),s[i]++),t):l.fixed.test(n)?t=o([],n,t):l.named.test(n)&&(t=o({},n,t));return t}(e.name,function(e){switch(a('[name="'+e.name+'"]',n).attr("type")){case"checkbox":return"1"===e.value||e.value;default:return e.value}}(e));return r=i.extend(!0,r,t),this},this.addPairs=function(e){if(!i.isArray(e))throw new Error("formSerializer.addPairs expects an Array");for(var t=0,n=e.length;t<n;t++)this.addPair(e[t]);return this},this.serialize=e,this.serializeJSON=function(){return JSON.stringify(e())}}return t.patterns=l,t.serializeObject=function(){var e;return e=this.is("form")?this.serializeArray():this.find(":input").serializeArray(),new t(a,this).addPairs(e).serialize()},t.serializeJSON=function(){var e;return e=this.is("form")?this.serializeArray():this.find(":input").serializeArray(),new t(a,this).addPairs(e).serializeJSON()},void 0!==a.fn&&(a.fn.pumSerializeObject=t.serializeObject,a.fn.pumSerializeJSON=t.serializeJSON),e.FormSerializer=t}),function(o){"use strict";var e={init:function(){o(".pum-tabs-container").filter(":not(.pum-tabs-initialized)").each(function(){var e=o(this).addClass("pum-tabs-initialized"),t=e.find("> ul.tabs"),n=t.find("> li:first"),i=e.data("min-height");if(e.hasClass("vertical-tabs")){var r=i&&0<i?i:t.eq(0).outerHeight(!0);e.css({minHeight:r+"px"}),e.parent().innerHeight<r&&e.parent().css({minHeight:r+"px"})}n.trigger("click")})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.tabs=e,o(document).on("pum_init",PUM_Admin.tabs.init).on("click",".pum-tabs-initialized li.tab",function(e){var t=o(this),n=t.parents(".pum-tabs-container:first"),i=n.find("> ul.tabs > li.tab"),r=n.find("> div.tab-content"),s=t.find("a").attr("href");i.removeClass("active"),r.removeClass("active"),t.addClass("active"),n.find("> div.tab-content"+s).addClass("active"),e.preventDefault()})}(jQuery),function(i){"use strict";var n=pum_admin_vars.I10n,e={render:function(e,t){var n=wp.template(e);return void 0!==(t=t||{}).classes&&Array.isArray(t.classes)&&(t.classes=t.classes.join(" ")),n(t=PUM_Admin.templates.prepareMeta(t))},renderInline:function(e,t){return _.template(e,null,{evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"})(t)},shortcode:function(e){var t=i.extend(!0,{},{tag:"",meta:{},has_content:!1,content:""},e),n=t.has_content?"pum-shortcode-w-content":"pum-shortcode";return PUM_Admin.templates.render(n,t)},modal:function(e){var t=i.extend(!0,{},{id:"",title:"",description:"",classes:"",save_button:n.save,cancel_button:n.cancel,content:""},e);return PUM_Admin.templates.render("pum-modal",t)},tabs:function(e){return"string"==typeof(e=i.extend(!0,{},{id:"",vertical:!1,form:!1,classes:[],tabs:{},meta:{}},e)).classes&&(e.classes=[e.classes]),e.form&&e.classes.push("pum-tabbed-form"),e.meta["data-tab-count"]=Object.keys(e.tabs).length,e.classes.push(e.vertical?"vertical-tabs":"horizontal-tabs"),e.classes=e.classes.join(" "),PUM_Admin.templates.render("pum-tabs",e)},section:function(e){var t=i.extend(!0,{},{classes:[],fields:[]},e);return PUM_Admin.templates.render("pum-field-section",t)},fieldArgs:function(e){var s=[],o=i.extend(!0,{},PUM_Admin.models.field(e));switch(void 0===e.std||"checkbox"===e.type||null!==o.value&&!1!==o.value||(o.value=e.std),"string"==typeof o.classes&&(o.classes=o.classes.split(" ")),void 0!==e.class&&o.classes.push(e.class),void 0!==e.dependencies&&"object"==typeof e.dependencies&&(o.dependencies=JSON.stringify(e.dependencies)),o.required&&(o.meta.required=!0,o.classes.push("pum-required")),"string"==typeof o.dynamic_desc&&o.dynamic_desc.length&&(o.classes.push("pum-field-dynamic-desc"),o.desc=PUM_Admin.templates.renderInline(o.dynamic_desc,o)),o.allow_html&&(o.classes.push("pum-field-"+o.type+"--html"),"string"==typeof o.value&&""!==o.value&&PUM_Admin.utils.htmlencoder.hasEncoded(o.value)&&(o.value=PUM_Admin.utils.htmlencoder.htmlDecode(o.value))),e.type){case"select":case"objectselect":case"postselect":case"taxonomyselect":void 0!==o.options&&(_.each(o.options,function(e,t){var n,i,r=!1;"object"!=typeof e?(null!==o.value&&(o.multiple&&("string"==typeof o.value&&o.value==t||Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t])?r="selected":o.multiple||o.value!=t||(r="selected")),s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:r}}))):(n=t,i=[],_.each(e,function(e,t){var n=!1;null!==o.value&&(o.multiple&&("string"==typeof o.value&&o.value==t||Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t])?n="selected":o.multiple||o.value!=t||(n="selected")),i.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:n}}))}),s.push({label:n,options:i}))}),o.options=s),o.multiple&&(o.meta.multiple=!0,o.as_array&&(o.name+="[]"),o.value&&o.value.length||(o.value=[]),"string"==typeof o.value&&(o.value=[o.value])),"select"!==e.type&&(o.select2=!0,o.classes.push("pum-field-objectselect"),o.classes.push("postselect"===e.type?"pum-field-postselect":"pum-field-taxonomyselect"),o.meta["data-objecttype"]="postselect"===e.type?"post_type":"taxonomy",o.meta["data-objectkey"]="postselect"===e.type?e.post_type:e.taxonomy,o.meta["data-current"]="object"==typeof o.value||Array.isArray(o.value)?JSON.stringify(o.value):o.value),o.select2&&(o.classes.push("pum-field-select2"),o.placeholder&&(o.meta["data-placeholder"]=o.placeholder));break;case"radio":void 0!==o.options&&(_.each(o.options,function(e,t){s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{checked:o.value===t}}))}),o.options=s);break;case"multicheck":void 0!==o.options&&(!1!==o.value&&null!==o.value||(o.value=[]),"string"==typeof o.value&&o.value.indexOf(",")&&(o.value=o.value.split(",")),o.as_array&&(o.name+="[]"),_.each(o.options,function(e,t){s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{checked:Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t]}}))}),o.options=s);break;case"checkbox":switch(typeof o.value){case"object":Array.isArray(o.value)&&1===o.value.length&&"1"===o.value[0].toString()&&(o.value=!0,o.meta.checked=!0);break;case"boolean":o.value&&(o.meta.checked=!0);break;case"string":"true"!==o.value&&"yes"!==o.value&&"1"!==o.value||(o.meta.checked=!0);break;case"number":(1===parseInt(o.value,10)||0<parseInt(o.value,10))&&(o.meta.checked=!0)}break;case"rangeslider":o.meta.step=o.step,o.meta.min=o.min,o.meta.max=o.max,o.meta["data-force-minmax"]=o.force_minmax.toString();break;case"textarea":o.meta.cols=o.cols,o.meta.rows=o.rows;break;case"measure":"string"==typeof o.value&&""!==o.value?(o.number=parseInt(o.value),o.unitValue=o.value.replace(o.number,""),o.value=o.number):o.unitValue=null,void 0!==o.units&&(_.each(o.units,function(e,t){var n=!1;o.unitValue==t&&(n="selected"),s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:n}}))}),o.units=s);break;case"color":"string"==typeof o.value&&""!==o.value&&(o.meta["data-default-color"]=o.value);break;case"license_key":o.value=i.extend({key:"",license:{},messages:[],status:"empty",expires:!1,classes:!1},o.value),o.classes.push("pum-license-"+o.value.status+"-notice"),o.value.classes&&o.classes.push(o.value.classes)}return o},field:function(e){var t,n=PUM_Admin.templates.fieldArgs(e);return t="pum-field-"+n.type,"objectselfect"!==n.type&&"postselect"!==n.type&&"taxonomyselect"!==n.type||(t="pum-field-select"),i("#tmpl-"+t).length?(n.field=PUM_Admin.templates.render(t,n),PUM_Admin.templates.render("pum-field-wrapper",n)):(console.warn("No field template found for type:"+n.type+" fieldID: "+n.id),"")},prepareMeta:function(e){var t,n=[];for(t in e.meta)e.meta.hasOwnProperty(t)&&("boolean"==typeof e.meta[t]?e.meta[t]&&n.push(_.escape(t)):n.push(_.escape(t)+'="'+_.escape(e.meta[t])+'"'));return e.meta=n.join(" "),e}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.templates=e}(window.jQuery),function(i){"use strict";String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};var r="color,date,datetime,datetime-local,email,hidden,month,number,password,range,search,tel,text,time,url,week".split(","),s="select,textarea".split(","),o=/\[([^\]]*)\]/g;function a(e,t){return-1!==i.inArray(t,e)}var e={EncodeType:"entity",isEmpty:function(e){return!e||(null===e||0==e.length||/^\s+$/.test(e))},arr1:["&nbsp;","&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&copy;","&ordf;","&laquo;","&not;","&shy;","&reg;","&macr;","&deg;","&plusmn;","&sup2;","&sup3;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;","&quot;","&amp;","&lt;","&gt;","&OElig;","&oelig;","&Scaron;","&scaron;","&Yuml;","&circ;","&tilde;","&ensp;","&emsp;","&thinsp;","&zwnj;","&zwj;","&lrm;","&rlm;","&ndash;","&mdash;","&lsquo;","&rsquo;","&sbquo;","&ldquo;","&rdquo;","&bdquo;","&dagger;","&Dagger;","&permil;","&lsaquo;","&rsaquo;","&euro;","&fnof;","&Alpha;","&Beta;","&Gamma;","&Delta;","&Epsilon;","&Zeta;","&Eta;","&Theta;","&Iota;","&Kappa;","&Lambda;","&Mu;","&Nu;","&Xi;","&Omicron;","&Pi;","&Rho;","&Sigma;","&Tau;","&Upsilon;","&Phi;","&Chi;","&Psi;","&Omega;","&alpha;","&beta;","&gamma;","&delta;","&epsilon;","&zeta;","&eta;","&theta;","&iota;","&kappa;","&lambda;","&mu;","&nu;","&xi;","&omicron;","&pi;","&rho;","&sigmaf;","&sigma;","&tau;","&upsilon;","&phi;","&chi;","&psi;","&omega;","&thetasym;","&upsih;","&piv;","&bull;","&hellip;","&prime;","&Prime;","&oline;","&frasl;","&weierp;","&image;","&real;","&trade;","&alefsym;","&larr;","&uarr;","&rarr;","&darr;","&harr;","&crarr;","&lArr;","&uArr;","&rArr;","&dArr;","&hArr;","&forall;","&part;","&exist;","&empty;","&nabla;","&isin;","&notin;","&ni;","&prod;","&sum;","&minus;","&lowast;","&radic;","&prop;","&infin;","&ang;","&and;","&or;","&cap;","&cup;","&int;","&there4;","&sim;","&cong;","&asymp;","&ne;","&equiv;","&le;","&ge;","&sub;","&sup;","&nsub;","&sube;","&supe;","&oplus;","&otimes;","&perp;","&sdot;","&lceil;","&rceil;","&lfloor;","&rfloor;","&lang;","&rang;","&loz;","&spades;","&clubs;","&hearts;","&diams;"],arr2:["&#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;","&#194;","&#195;","&#196;","&#197;","&#198;","&#199;","&#200;","&#201;","&#202;","&#203;","&#204;","&#205;","&#206;","&#207;","&#208;","&#209;","&#210;","&#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;","&#253;","&#254;","&#255;","&#34;","&#38;","&#60;","&#62;","&#338;","&#339;","&#352;","&#353;","&#376;","&#710;","&#732;","&#8194;","&#8195;","&#8201;","&#8204;","&#8205;","&#8206;","&#8207;","&#8211;","&#8212;","&#8216;","&#8217;","&#8218;","&#8220;","&#8221;","&#8222;","&#8224;","&#8225;","&#8240;","&#8249;","&#8250;","&#8364;","&#402;","&#913;","&#914;","&#915;","&#916;","&#917;","&#918;","&#919;","&#920;","&#921;","&#922;","&#923;","&#924;","&#925;","&#926;","&#927;","&#928;","&#929;","&#931;","&#932;","&#933;","&#934;","&#935;","&#936;","&#937;","&#945;","&#946;","&#947;","&#948;","&#949;","&#950;","&#951;","&#952;","&#953;","&#954;","&#955;","&#956;","&#957;","&#958;","&#959;","&#960;","&#961;","&#962;","&#963;","&#964;","&#965;","&#966;","&#967;","&#968;","&#969;","&#977;","&#978;","&#982;","&#8226;","&#8230;","&#8242;","&#8243;","&#8254;","&#8260;","&#8472;","&#8465;","&#8476;","&#8482;","&#8501;","&#8592;","&#8593;","&#8594;","&#8595;","&#8596;","&#8629;","&#8656;","&#8657;","&#8658;","&#8659;","&#8660;","&#8704;","&#8706;","&#8707;","&#8709;","&#8711;","&#8712;","&#8713;","&#8715;","&#8719;","&#8721;","&#8722;","&#8727;","&#8730;","&#8733;","&#8734;","&#8736;","&#8743;","&#8744;","&#8745;","&#8746;","&#8747;","&#8756;","&#8764;","&#8773;","&#8776;","&#8800;","&#8801;","&#8804;","&#8805;","&#8834;","&#8835;","&#8836;","&#8838;","&#8839;","&#8853;","&#8855;","&#8869;","&#8901;","&#8968;","&#8969;","&#8970;","&#8971;","&#9001;","&#9002;","&#9674;","&#9824;","&#9827;","&#9829;","&#9830;"],HTML2Numerical:function(e){return this.swapArrayVals(e,this.arr1,this.arr2)},NumericalToHTML:function(e){return this.swapArrayVals(e,this.arr2,this.arr1)},numEncode:function(e){if(this.isEmpty(e))return"";for(var t=[],n=e.length,i=0;i<n;i++){var r=e.charAt(i);r<" "||"~"<r?(t.push("&#"),t.push(r.charCodeAt()),t.push(";")):t.push(r)}return t.join("")},htmlDecode:function(e){var t,n,i=e;if(this.isEmpty(i))return"";var r=(i=this.HTML2Numerical(i)).match(/&#[0-9]{1,5};/g);if(null!=r)for(var s=0;s<r.length;s++)i=-32768<=(t=(n=r[s]).substring(2,n.length-1))&&t<=65535?i.replace(n,String.fromCharCode(t)):i.replace(n,"");return i},htmlEncode:function(e,t){return this.isEmpty(e)?"":((t=t||!1)&&(e="numerical"==this.EncodeType?e.replace(/&/g,"&#38;"):e.replace(/&/g,"&amp;")),e=this.XSSEncode(e,!1),"numerical"!=this.EncodeType&&t||(e=this.HTML2Numerical(e)),e=this.numEncode(e),t||(e=e.replace(/&#/g,"##AMPHASH##"),e=(e="numerical"==this.EncodeType?e.replace(/&/g,"&#38;"):e.replace(/&/g,"&amp;")).replace(/##AMPHASH##/g,"&#")),e=e.replace(/&#\d*([^\d;]|$)/g,"$1"),t||(e=this.correctEncoding(e)),"entity"==this.EncodeType&&(e=this.NumericalToHTML(e)),e)},XSSEncode:function(e,t){return this.isEmpty(e)?"":e=(t=t||!0)?(e=(e=(e=e.replace(/\'/g,"&#39;")).replace(/\"/g,"&quot;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;"):(e=(e=(e=e.replace(/\'/g,"&#39;")).replace(/\"/g,"&#34;")).replace(/</g,"&#60;")).replace(/>/g,"&#62;")},hasEncoded:function(e){return!!/&#[0-9]{1,5};/g.test(e)||!!/&[A-Z]{2,6};/gi.test(e)},stripUnicode:function(e){return e.replace(/[^\x20-\x7E]/g,"")},correctEncoding:function(e){return e.replace(/(&amp;)(amp;)+/,"$1")},swapArrayVals:function(e,t,n){if(this.isEmpty(e))return"";var i;if(t&&n&&t.length==n.length)for(var r=0,s=t.length;r<s;r++)i=new RegExp(t[r],"g"),e=e.replace(i,n[r]);return e},inArray:function(e,t){for(var n=0,i=t.length;n<i;n++)if(t[n]===e)return n;return-1}};e.EncodeType="entity";var t={htmlencoder:e,convert_meta_to_object:function(e){var t,n,i,r={};for(i in e)e.hasOwnProperty(i)&&(t=i.split(/_(.+)?/)[0],n=i.split(/_(.+)?/)[1],void 0===r[t]&&(r[t]={}),r[t][n]=e[i]);return r},object_to_array:function(e){var t,n=[];if("object"==typeof e){for(t in e)n.push(e[t]);e=n}return e},checked:function(e,t,n){var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t?i=!0:e==t&&(i=!0),void 0!==n&&n?i?' checked="checked"':"":i},selected:function(e,t,n){var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' selected="selected"':"":i},convert_hex:function(e,t){return void 0===e?"":(void 0===t&&(t=100),e=e.replace("#",""),"rgba("+parseInt(e.substring(0,2),16)+","+parseInt(e.substring(2,4),16)+","+parseInt(e.substring(4,6),16)+","+t/100+")")},debounce:function(n,i){var r;return function(){var e=this,t=arguments;window.clearTimeout(r),r=window.setTimeout(function(){n.apply(e,t)},i)}},throttle:function(e,t){var n=!1,i=function(){n=!1};return function(){n||(e(),window.setTimeout(i,t),n=!0)}},serializeForm:function(e){i.extend({},e);var t={},n=i.extend(!0,{include:[],exclude:[],includeByClass:""},e);return this.find(":input").each(function(){var e;!this.name||this.disabled||a(n.exclude,this.name)||n.include.length&&!a(n.include,this.name)||-1===this.className.indexOf(n.includeByClass)||(e=this.name.replace(o,"[$1").split("["))[0]&&(this.checked||a(r,this.type)||a(s,this.nodeName.toLowerCase()))&&("checkbox"===this.type&&e.push(""),function e(t,n,i){var r=n[0];1<n.length?(t[r]||(t[r]=n[1]?{}:[]),e(t[r],n.slice(1),i)):(r||(r=t.length),t[r]=i)}(t,e,i(this).val()))}),t}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.utils=t,window.PUMUtils=t,i.fn.pumSerializeForm=t.serializeForm}(jQuery);
1
+ function pumSelected(e,t,n){"use strict";var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' selected="selected"':"":i}function pumChecked(e,t,n){"use strict";var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' checked="checked"':"":i}!function(e){"function"==typeof define&&void 0!==define.amd&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)}(function(i){var e=function(){if(i&&i.fn&&i.fn.pumselect2&&i.fn.pumselect2.amd)var e=i.fn.pumselect2.amd;var t,r,u,n;return e&&e.requirejs||(e?r=e:e={},function(p){var s,o,h,m,f={},g={},v={},y={},n=Object.prototype.hasOwnProperty,i=[].slice,_=/\.js$/;function b(e,t){return n.call(e,t)}function a(e,t){var n,i,r,s,o,a,l,u,c,d,p,h=t&&t.split("/"),m=v.map,f=m&&m["*"]||{};if(e&&"."===e.charAt(0))if(t){for(o=(e=e.split("/")).length-1,v.nodeIdCompat&&_.test(e[o])&&(e[o]=e[o].replace(_,"")),e=h.slice(0,h.length-1).concat(e),c=0;c<e.length;c+=1)if("."===(p=e[c]))e.splice(c,1),c-=1;else if(".."===p){if(1===c&&(".."===e[2]||".."===e[0]))break;0<c&&(e.splice(c-1,2),c-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((h||f)&&m){for(c=(n=e.split("/")).length;0<c;c-=1){if(i=n.slice(0,c).join("/"),h)for(d=h.length;0<d;d-=1)if((r=m[h.slice(0,d).join("/")])&&(r=r[i])){s=r,a=c;break}if(s)break;!l&&f&&f[i]&&(l=f[i],u=c)}!s&&l&&(s=l,a=u),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function w(t,n){return function(){var e=i.call(arguments,0);return"string"!=typeof e[0]&&1===e.length&&e.push(null),o.apply(p,e.concat([t,n]))}}function A(t){return function(e){f[t]=e}}function x(e){if(b(g,e)){var t=g[e];delete g[e],y[e]=!0,s.apply(p,t)}if(!b(f,e)&&!b(y,e))throw new Error("No "+e);return f[e]}function l(e){var t,n=e?e.indexOf("!"):-1;return-1<n&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}h=function(e,t){var n,i=l(e),r=i[0];return e=i[1],r&&(n=x(r=a(r,t))),r?e=n&&n.normalize?n.normalize(e,function(t){return function(e){return a(e,t)}}(t)):a(e,t):(r=(i=l(e=a(e,t)))[0],e=i[1],r&&(n=x(r))),{f:r?r+"!"+e:e,n:e,pr:r,p:n}},m={require:function(e){return w(e)},exports:function(e){var t=f[e];return void 0!==t?t:f[e]={}},module:function(e){return{id:e,uri:"",exports:f[e],config:function(e){return function(){return v&&v.config&&v.config[e]||{}}}(e)}}},s=function(e,t,n,i){var r,s,o,a,l,u,c=[],d=typeof n;if(i=i||e,"undefined"==d||"function"==d){for(t=!t.length&&n.length?["require","exports","module"]:t,l=0;l<t.length;l+=1)if("require"===(s=(a=h(t[l],i)).f))c[l]=m.require(e);else if("exports"===s)c[l]=m.exports(e),u=!0;else if("module"===s)r=c[l]=m.module(e);else if(b(f,s)||b(g,s)||b(y,s))c[l]=x(s);else{if(!a.p)throw new Error(e+" missing "+s);a.p.load(a.n,w(i,!0),A(s),{}),c[l]=f[s]}o=n?n.apply(f[e],c):void 0,e&&(r&&r.exports!==p&&r.exports!==f[e]?f[e]=r.exports:o===p&&u||(f[e]=o))}else e&&(f[e]=n)},t=r=o=function(e,t,n,i,r){if("string"==typeof e)return m[e]?m[e](t):x(h(e,t).f);if(!e.splice){if((v=e).deps&&o(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=p}return t=t||function(){},"function"==typeof n&&(n=i,i=r),i?s(p,e,t,n):setTimeout(function(){s(p,e,t,n)},4),o},o.config=function(e){return o(e)},t._defined=f,(u=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),b(f,e)||b(g,e)||(g[e]=[e,t,n])}).amd={jQuery:!0}}(),e.requirejs=t,e.require=r,e.define=u),e.define("almond",function(){}),e.define("jquery",[],function(){var e=i||$;return null==e&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),e}),e.define("pumselect2/utils",["jquery"],function(s){var e={};function c(e){var t=e.prototype,n=[];for(var i in t){"function"==typeof t[i]&&("constructor"!==i&&n.push(i))}return n}e.Extend=function(e,t){var n={}.hasOwnProperty;function i(){this.constructor=e}for(var r in t)n.call(t,r)&&(e[r]=t[r]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e},e.Decorate=function(i,r){var e=c(r),t=c(i);function s(){var e=Array.prototype.unshift,t=r.prototype.constructor.length,n=i.prototype.constructor;0<t&&(e.call(arguments,i.prototype.constructor),n=r.prototype.constructor),n.apply(this,arguments)}r.displayName=i.displayName,s.prototype=new function(){this.constructor=s};for(var n=0;n<t.length;n++){var o=t[n];s.prototype[o]=i.prototype[o]}for(var a=function(e){var t=function(){};e in s.prototype&&(t=s.prototype[e]);var n=r.prototype[e];return function(){return Array.prototype.unshift.call(arguments,t),n.apply(this,arguments)}},l=0;l<e.length;l++){var u=e[l];s.prototype[u]=a(u)}return s};var t=function(){this.listeners={}};return t.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},t.prototype.trigger=function(e){var t=Array.prototype.slice;this.listeners=this.listeners||{},e in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},t.prototype.invoke=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n].apply(this,t)},e.Observable=t,e.generateChars=function(e){for(var t="",n=0;n<e;n++){t+=Math.floor(36*Math.random()).toString(36)}return t},e.bind=function(e,t){return function(){e.apply(t,arguments)}},e._convertData=function(e){for(var t in e){var n=t.split("-"),i=e;if(1!==n.length){for(var r=0;r<n.length;r++){var s=n[r];(s=s.substring(0,1).toLowerCase()+s.substring(1))in i||(i[s]={}),r==n.length-1&&(i[s]=e[t]),i=i[s]}delete e[t]}}return e},e.hasScroll=function(e,t){var n=s(t),i=t.style.overflowX,r=t.style.overflowY;return(i!==r||"hidden"!==r&&"visible"!==r)&&("scroll"===i||"scroll"===r||(n.innerHeight()<t.scrollHeight||n.innerWidth()<t.scrollWidth))},e.escapeMarkup=function(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.appendMany=function(e,t){if("1.7"===s.fn.jquery.substr(0,3)){var n=s();s.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e}),e.define("pumselect2/results",["jquery","./utils"],function(p,e){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=p('<ul class="pumselect2-results__options" role="tree"></ul>');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=p('<li role="treeitem" aria-live="assertive" class="pumselect2-results__option"></li>'),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" pumselect2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".pumselect2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var i=e.results[n],r=this.option(i);t.push(r)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},i.prototype.position=function(e,t){t.find(".pumselect2-results").append(e)},i.prototype.sort=function(e){return this.options.get("sorter")(e)},i.prototype.setClasses=function(){var r=this;this.data.current(function(e){var i=p.map(e,function(e){return e.id.toString()}),t=r.$results.find(".pumselect2-results__option[aria-selected]");t.each(function(){var e=p(this),t=p.data(this,"data"),n=""+t.id;null!=t.element&&t.element.selected||null==t.element&&-1<p.inArray(n,i)?e.attr("aria-selected","true"):e.attr("aria-selected","false")});var n=t.filter("[aria-selected=true]");0<n.length?n.first().trigger("mouseenter"):t.first().trigger("mouseenter")})},i.prototype.showLoading=function(e){this.hideLoading();var t={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},n=this.option(t);n.className+=" loading-results",this.$results.prepend(n)},i.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},i.prototype.option=function(e){var t=document.createElement("li");t.className="pumselect2-results__option";var n={role:"treeitem","aria-selected":"false"};for(var i in e.disabled&&(delete n["aria-selected"],n["aria-disabled"]="true"),null==e.id&&delete n["aria-selected"],null!=e._resultId&&(t.id=e._resultId),e.title&&(t.title=e.title),e.children&&(n.role="group",n["aria-label"]=e.text,delete n["aria-selected"]),n){var r=n[i];t.setAttribute(i,r)}if(e.children){var s=p(t),o=document.createElement("strong");o.className="pumselect2-results__group";p(o);this.template(e,o);for(var a=[],l=0;l<e.children.length;l++){var u=e.children[l],c=this.option(u);a.push(c)}var d=p("<ul></ul>",{class:"pumselect2-results__options pumselect2-results__options--nested"});d.append(a),s.append(o),s.append(d)}else this.template(e,t);return p.data(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&l.setClasses()}),t.on("unselect",function(){t.isOpen()&&l.setClasses()}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("aria-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e);if(0!==n){var i=n-1;0===e.length&&(i=0);var r=t.eq(i);r.trigger("mouseenter");var s=l.$results.offset().top,o=r.offset().top,a=l.$results.scrollTop()+(o-s);0===i?l.$results.scrollTop(0):o-s<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var r=l.$results.offset().top+l.$results.outerHeight(!1),s=i.offset().top+i.outerHeight(!1),o=l.$results.scrollTop()+s-r;0===n?l.$results.scrollTop(0):r<s&&l.$results.scrollTop(o)}}),t.on("results:focus",function(e){e.element.addClass("pumselect2-results__option--highlighted")}),t.on("results:message",function(e){l.displayMessage(e)}),p.fn.mousewheel&&this.$results.on("mousewheel",function(e){var t=l.$results.scrollTop(),n=l.$results.get(0).scrollHeight-t+e.deltaY,i=0<e.deltaY&&t-e.deltaY<=0,r=e.deltaY<0&&n<=l.$results.height();i?(l.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):r&&(l.$results.scrollTop(l.$results.get(0).scrollHeight-l.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".pumselect2-results__option[aria-selected]",function(e){var t=p(this),n=t.data("data");"true"!==t.attr("aria-selected")?l.trigger("select",{originalEvent:e,data:n}):l.options.get("multiple")?l.trigger("unselect",{originalEvent:e,data:n}):l.trigger("close",{})}),this.$results.on("mouseenter",".pumselect2-results__option[aria-selected]",function(e){var t=p(this).data("data");l.getHighlightedResults().removeClass("pumselect2-results__option--highlighted"),l.trigger("results:focus",{data:t,element:p(this)})})},i.prototype.getHighlightedResults=function(){return this.$results.find(".pumselect2-results__option--highlighted")},i.prototype.destroy=function(){this.$results.remove()},i.prototype.ensureHighlightVisible=function(){var e=this.getHighlightedResults();if(0!==e.length){var t=this.$results.find("[aria-selected]").index(e),n=this.$results.offset().top,i=e.offset().top,r=this.$results.scrollTop()+(i-n),s=i-n;r-=2*e.outerHeight(!1),t<=2?this.$results.scrollTop(0):(s>this.$results.outerHeight()||s<0)&&this.$results.scrollTop(r)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),r=n(e,t);null==r?t.style.display="none":"string"==typeof r?t.innerHTML=i(r):p(t).append(r)},i}),e.define("pumselect2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("pumselect2/selection/base",["jquery","../utils","../keys"],function(n,e,r){function i(e,t){this.$element=e,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=n('<span class="pumselect2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},i.prototype.bind=function(e,t){var n=this,i=(e.id,e.id+"-results");this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===r.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.focus(),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},i.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},i.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.pumselect2."+e.id,function(e){var t=n(e.target).closest(".pumselect2");n(".pumselect2.pumselect2-container--open").each(function(){var e=n(this);this!=t[0]&&e.data("element").pumselect2("close")})})},i.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.pumselect2."+e.id)},i.prototype.position=function(e,t){t.find(".selection").append(e)},i.prototype.destroy=function(){this._detachCloseHandler(this.container)},i.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},i}),e.define("pumselect2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,i){function r(){r.__super__.constructor.apply(this,arguments)}return n.Extend(r,t),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("pumselect2-selection--single"),e.html('<span class="pumselect2-selection__rendered"></span><span class="pumselect2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},r.prototype.bind=function(e,t){var n=this;r.__super__.bind.apply(this,arguments);var i=e.id+"-container";this.$selection.find(".pumselect2-selection__rendered").attr("id",i),this.$selection.attr("aria-labelledby",i),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),e.on("selection:update",function(e){n.update(e.data)})},r.prototype.clear=function(){this.$selection.find(".pumselect2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return e("<span></span>")},r.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".pumselect2-selection__rendered"),i=this.display(t,n);n.empty().append(i),n.prop("title",t.title||t.text)}else this.clear()},r}),e.define("pumselect2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function r(e,t){r.__super__.constructor.apply(this,arguments)}return a.Extend(r,e),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("pumselect2-selection--multiple"),e.html('<ul class="pumselect2-selection__rendered"></ul>'),e},r.prototype.bind=function(e,t){var n=this;r.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".pumselect2-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=i(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}})},r.prototype.clear=function(){this.$selection.find(".pumselect2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return i('<li class="pumselect2-selection__choice"><span class="pumselect2-selection__choice__remove" role="presentation">&times;</span></li>')},r.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n<e.length;n++){var i=e[n],r=this.selectionContainer(),s=this.display(i,r);r.append(s),r.prop("title",i.title||i.text),r.data("data",i),t.push(r)}var o=this.$selection.find(".pumselect2-selection__rendered");a.appendMany(o,t)}},r}),e.define("pumselect2/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("pumselect2-selection__placeholder").removeClass("pumselect2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(1<t.length||n)return e.call(this,t);this.clear();var i=this.createPlaceholder(this.placeholder);this.$selection.find(".pumselect2-selection__rendered").append(i)},t}),e.define("pumselect2/selection/allowClear",["jquery","../keys"],function(i,r){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".pumselect2-selection__clear",function(e){i._handleClear(e)}),t.on("keypress",function(e){i._handleKeyboardClear(e,t)})},e.prototype._handleClear=function(e,t){if(!this.options.get("disabled")){var n=this.$selection.find(".pumselect2-selection__clear");if(0!==n.length){t.stopPropagation();for(var i=n.data("data"),r=0;r<i.length;r++){var s={data:i[r]};if(this.trigger("unselect",s),s.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},e.prototype._handleKeyboardClear=function(e,t,n){n.isOpen()||t.which!=r.DELETE&&t.which!=r.BACKSPACE||this._handleClear(t)},e.prototype.update=function(e,t){if(e.call(this,t),!(0<this.$selection.find(".pumselect2-selection__placeholder").length||0===t.length)){var n=i('<span class="pumselect2-selection__clear">&times;</span>');n.data("data",t),this.$selection.find(".pumselect2-selection__rendered").prepend(n)}},e}),e.define("pumselect2/selection/search",["jquery","../utils","../keys"],function(i,e,o){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=i('<li class="pumselect2-search pumselect2-search--inline"><input class="pumselect2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("open",function(){i.$search.trigger("focus")}),t.on("close",function(){i.$search.val(""),i.$search.removeAttr("aria-activedescendant"),i.$search.trigger("focus")}),t.on("enable",function(){i.$search.prop("disabled",!1),i._transferTabIndex()}),t.on("disable",function(){i.$search.prop("disabled",!0)}),t.on("focus",function(e){i.$search.trigger("focus")}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.id)}),this.$selection.on("focusin",".pumselect2-search--inline",function(e){i.trigger("focus",e)}),this.$selection.on("focusout",".pumselect2-search--inline",function(e){i._handleBlur(e)}),this.$selection.on("keydown",".pumselect2-search--inline",function(e){if(e.stopPropagation(),i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented(),e.which===o.BACKSPACE&&""===i.$search.val()){var t=i.$searchContainer.prev(".pumselect2-selection__choice");if(0<t.length){var n=t.data("data");i.searchRemoveChoice(n),e.preventDefault()}}});var r=document.documentMode,s=r&&r<=11;this.$selection.on("input.searchcheck",".pumselect2-search--inline",function(e){s?i.$selection.off("input.search input.searchcheck"):i.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".pumselect2-search--inline",function(e){if(s&&"input"===e.type)i.$selection.off("input.search input.searchcheck");else{var t=e.which;t!=o.SHIFT&&t!=o.CTRL&&t!=o.ALT&&t!=o.TAB&&i.handleSearch(e)}})},t.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},t.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},t.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".pumselect2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.focus()},t.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var e=this.$search.val();this.trigger("query",{term:e})}this._keyUpPrevented=!1},t.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},t.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";""!==this.$search.attr("placeholder")?e=this.$selection.find(".pumselect2-selection__rendered").innerWidth():e=.75*(this.$search.val().length+1)+"em";this.$search.css("width",e)},t}),e.define("pumselect2/selection/eventRelay",["jquery"],function(o){function e(){}return e.prototype.bind=function(e,t,n){var i=this,r=["open","opening","close","closing","select","selecting","unselect","unselecting"],s=["opening","closing","selecting","unselecting"];e.call(this,t,n),t.on("*",function(e,t){if(-1!==o.inArray(e,r)){t=t||{};var n=o.Event("pumselect2:"+e,{params:t});i.$element.trigger(n),-1!==o.inArray(e,s)&&(t.prevented=n.isDefaultPrevented())}})},e}),e.define("pumselect2/translation",["jquery","require"],function(t,n){function i(e){this.dict=e||{}}return i.prototype.all=function(){return this.dict},i.prototype.get=function(e){return this.dict[e]},i.prototype.extend=function(e){this.dict=t.extend({},e.all(),this.dict)},i._cache={},i.loadPath=function(e){if(!(e in i._cache)){var t=n(e);i._cache[e]=t}return new i(i._cache[e])},i}),e.define("pumselect2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"}}),e.define("pumselect2/data/base",["../utils"],function(i){function n(e,t){n.__super__.constructor.call(this)}return i.Extend(n,i.Observable),n.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},n.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},n.prototype.bind=function(e,t){},n.prototype.destroy=function(){},n.prototype.generateResultId=function(e,t){var n=e.id+"-result-";return n+=i.generateChars(4),null!=t.id?n+="-"+t.id.toString():n+="-"+i.generateChars(4),n},n}),e.define("pumselect2/data/select",["./base","../utils","jquery"],function(e,t,a){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,e),n.prototype.current=function(e){var n=[],i=this;this.$element.find(":selected").each(function(){var e=a(this),t=i.item(e);n.push(t)}),e(n)},n.prototype.select=function(r){var s=this;if(r.selected=!0,a(r.element).is("option"))return r.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(e){var t=[];(r=[r]).push.apply(r,e);for(var n=0;n<r.length;n++){var i=r[n].id;-1===a.inArray(i,t)&&t.push(i)}s.$element.val(t),s.$element.trigger("change")});else{var e=r.id;this.$element.val(e),this.$element.trigger("change")}},n.prototype.unselect=function(r){var s=this;if(this.$element.prop("multiple")){if(r.selected=!1,a(r.element).is("option"))return r.element.selected=!1,void this.$element.trigger("change");this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n].id;i!==r.id&&-1===a.inArray(i,t)&&t.push(i)}s.$element.val(t),s.$element.trigger("change")})}},n.prototype.bind=function(e,t){var n=this;(this.container=e).on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},n.prototype.destroy=function(){this.$element.find("*").each(function(){a.removeData(this,"data")})},n.prototype.query=function(i,e){var r=[],s=this;this.$element.children().each(function(){var e=a(this);if(e.is("option")||e.is("optgroup")){var t=s.item(e),n=s.matches(i,t);null!==n&&r.push(n)}}),e({results:r})},n.prototype.addOptions=function(e){t.appendMany(this.$element,e)},n.prototype.option=function(e){var t;e.children?(t=document.createElement("optgroup")).label=e.text:void 0!==(t=document.createElement("option")).textContent?t.textContent=e.text:t.innerText=e.text,e.id&&(t.value=e.id),e.disabled&&(t.disabled=!0),e.selected&&(t.selected=!0),e.title&&(t.title=e.title);var n=a(t),i=this._normalizeItem(e);return i.element=t,a.data(t,"data",i),n},n.prototype.item=function(e){var t={};if(null!=(t=a.data(e[0],"data")))return t;if(e.is("option"))t={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){t={text:e.prop("label"),children:[],title:e.prop("title")};for(var n=e.children("option"),i=[],r=0;r<n.length;r++){var s=a(n[r]),o=this.item(s);i.push(o)}t.children=i}return(t=this._normalizeItem(t)).element=e[0],a.data(e[0],"data",t),t},n.prototype._normalizeItem=function(e){a.isPlainObject(e)||(e={id:e,text:e});return null!=(e=a.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),a.extend({},{selected:!1,disabled:!1},e)},n.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},n}),e.define("pumselect2/data/array",["./select","../utils","jquery"],function(e,m,f){function i(e,t){var n=t.get("data")||[];i.__super__.constructor.call(this,e,t),this.addOptions(this.convertToOptions(n))}return m.Extend(i,e),i.prototype.select=function(n){var e=this.$element.find("option").filter(function(e,t){return t.value==n.id.toString()});0===e.length&&(e=this.option(n),this.addOptions(e)),i.__super__.select.call(this,n)},i.prototype.convertToOptions=function(e){var t=this,n=this.$element.find("option"),i=n.map(function(){return t.item(f(this)).id}).get(),r=[];function s(e){return function(){return f(this).val()==e.id}}for(var o=0;o<e.length;o++){var a=this._normalizeItem(e[o]);if(0<=f.inArray(a.id,i)){var l=n.filter(s(a)),u=this.item(l),c=f.extend(!0,{},a,u),d=this.option(c);l.replaceWith(d)}else{var p=this.option(a);if(a.children){var h=this.convertToOptions(a.children);m.appendMany(p,h)}r.push(p)}}return r},i}),e.define("pumselect2/data/ajax",["./array","../utils","jquery"],function(e,t,s){function n(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype._applyDefaults=function(e){var t={data:function(e){return s.extend({},e,{q:e.term})},transport:function(e,t,n){var i=s.ajax(e);return i.then(t),i.fail(n),i}};return s.extend({},t,e,!0)},n.prototype.processResults=function(e){return e},n.prototype.query=function(n,i){var r=this;null!=this._request&&(s.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var t=s.extend({type:"GET"},this.ajaxOptions);function e(){var e=t.transport(t,function(e){var t=r.processResults(e,n);r.options.get("debug")&&window.console&&console.error&&(t&&t.results&&s.isArray(t.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),i(t)},function(){r.trigger("results:message",{message:"errorLoading"})});r._request=e}"function"==typeof t.url&&(t.url=t.url.call(this.$element,n)),"function"==typeof t.data&&(t.data=t.data.call(this.$element,n)),this.ajaxOptions.delay&&""!==n.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(e,this.ajaxOptions.delay)):e()},n}),e.define("pumselect2/data/tags",["jquery"],function(c){function e(e,t,n){var i=n.get("tags"),r=n.get("createTag");void 0!==r&&(this.createTag=r);var s=n.get("insertTag");if(void 0!==s&&(this.insertTag=s),e.call(this,t,n),c.isArray(i))for(var o=0;o<i.length;o++){var a=i[o],l=this._normalizeItem(a),u=this.option(l);this.$element.append(u)}}return e.prototype.query=function(e,u,c){var d=this;this._removeOldTags(),null!=u.term&&null==u.page?e.call(this,u,function e(t,n){for(var i=t.results,r=0;r<i.length;r++){var s=i[r],o=null!=s.children&&!e({results:s.children},!0);if(s.text===u.term||o)return!n&&(t.data=i,void c(t))}if(n)return!0;var a=d.createTag(u);if(null!=a){var l=d.option(a);l.attr("data-pumselect2-tag",!0),d.addOptions([l]),d.insertTag(i,a)}t.results=i,c(t)}):e.call(this,u,c)},e.prototype.createTag=function(e,t){var n=c.trim(t.term);return""===n?null:{id:n,text:n}},e.prototype.insertTag=function(e,t,n){t.unshift(n)},e.prototype._removeOldTags=function(e){this._lastTag;this.$element.find("option[data-pumselect2-tag]").each(function(){this.selected||c(this).remove()})},e}),e.define("pumselect2/data/tokenizer",["jquery"],function(d){function e(e,t,n){var i=n.get("tokenizer");void 0!==i&&(this.tokenizer=i),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".pumselect2-search__field")},e.prototype.query=function(e,t,n){var i=this;t.term=t.term||"";var r=this.tokenizer(t,this.options,function(e){i.trigger("select",{data:e})});r.term!==t.term&&(this.$search.length&&(this.$search.val(r.term),this.$search.focus()),t.term=r.term),e.call(this,t,n)},e.prototype.tokenizer=function(e,t,n,i){for(var r=n.get("tokenSeparators")||[],s=t.term,o=0,a=this.createTag||function(e){return{id:e.term,text:e.term}};o<s.length;){var l=s[o];if(-1!==d.inArray(l,r)){var u=s.substr(0,o),c=a(d.extend({},t,{term:u}));null!=c?(i(c),s=s.substr(o+1)||"",o=0):o++}else o++}return{term:s}},e}),e.define("pumselect2/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("pumselect2/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",0<this.maximumInputLength&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("pumselect2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var s=this;this.current(function(e){var t=null!=e?e.length:0;0<s.maximumSelectionLength&&t>=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,r)})},e}),e.define("pumselect2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('<span class="pumselect2-dropdown"><span class="pumselect2-results"></span></span>');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("pumselect2/dropdown/search",["jquery","../utils"],function(r,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=r('<span class="pumselect2-search pumselect2-search--dropdown"><input class="pumselect2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){r(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.val("")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("pumselect2-search--hide"):i.$searchContainer.addClass("pumselect2-search--hide"))})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("pumselect2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("pumselect2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('<li class="pumselect2-results__option pumselect2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("pumselect2/dropdown/attachBody",["jquery","../utils"],function(m,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||m(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("pumselect2"),t.addClass("pumselect2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=m("<span></span>"),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.pumselect2."+t.id,r="resize.pumselect2."+t.id,s="orientationchange.pumselect2."+t.id,o=this.$container.parents().filter(a.hasScroll);o.each(function(){m(this).data("pumselect2-scroll-position",{x:m(this).scrollLeft(),y:m(this).scrollTop()})}),o.on(i,function(e){var t=m(this).data("pumselect2-scroll-position");m(this).scrollTop(t.y)}),m(window).on(i+" "+r+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.pumselect2."+t.id,i="resize.pumselect2."+t.id,r="orientationchange.pumselect2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),m(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=m(window),t=this.$dropdown.hasClass("pumselect2-dropdown--above"),n=this.$dropdown.hasClass("pumselect2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=r.top,s.bottom=r.top+s.height;var o=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),u=a<r.top-o,c=l>r.bottom+o,d={left:r.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),c||!u||t?!u&&c&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-o),null!=i&&(this.$dropdown.removeClass("pumselect2-dropdown--below pumselect2-dropdown--above").addClass("pumselect2-dropdown--"+i),this.$container.removeClass("pumselect2-container--below pumselect2-container--above").addClass("pumselect2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("pumselect2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,i=0;i<t.length;i++){var r=t[i];r.children?n+=e(r.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),e.define("pumselect2/dropdown/selectOnClose",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("close",function(){i._handleSelectOnClose()})},e.prototype._handleSelectOnClose=function(){var e=this.getHighlightedResults();if(!(e.length<1)){var t=e.data("data");null!=t.element&&t.element.selected||null==t.element&&t.selected||this.trigger("select",{data:t})}},e}),e.define("pumselect2/dropdown/closeOnSelect",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",function(e){i._selectTriggered(e)}),t.on("unselect",function(e){i._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&n.ctrlKey||this.trigger("close",{})},e}),e.define("pumselect2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return 1!=t&&(n+="s"),n},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),e.define("pumselect2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(m,f,g,v,y,_,b,w,A,x,$,t,j,C,P,k,O,M,S,E,U,T,D,q,I,z,L,H,e){function n(){this.reset()}return n.prototype.apply=function(t){if(null==(t=m.extend(!0,{},this.defaults,t)).dataAdapter){if(null!=t.ajax?t.dataAdapter=P:null!=t.data?t.dataAdapter=C:t.dataAdapter=j,0<t.minimumInputLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,M)),0<t.maximumInputLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,S)),0<t.maximumSelectionLength&&(t.dataAdapter=x.Decorate(t.dataAdapter,E)),t.tags&&(t.dataAdapter=x.Decorate(t.dataAdapter,k)),null==t.tokenSeparators&&null==t.tokenizer||(t.dataAdapter=x.Decorate(t.dataAdapter,O)),null!=t.query){var e=f(t.amdBase+"compat/query");t.dataAdapter=x.Decorate(t.dataAdapter,e)}if(null!=t.initSelection){var n=f(t.amdBase+"compat/initSelection");t.dataAdapter=x.Decorate(t.dataAdapter,n)}}if(null==t.resultsAdapter&&(t.resultsAdapter=g,null!=t.ajax&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,q)),null!=t.placeholder&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,D)),t.selectOnClose&&(t.resultsAdapter=x.Decorate(t.resultsAdapter,L))),null==t.dropdownAdapter){if(t.multiple)t.dropdownAdapter=U;else{var i=x.Decorate(U,T);t.dropdownAdapter=i}if(0!==t.minimumResultsForSearch&&(t.dropdownAdapter=x.Decorate(t.dropdownAdapter,z)),t.closeOnSelect&&(t.dropdownAdapter=x.Decorate(t.dropdownAdapter,H)),null!=t.dropdownCssClass||null!=t.dropdownCss||null!=t.adaptDropdownCssClass){var r=f(t.amdBase+"compat/dropdownCss");t.dropdownAdapter=x.Decorate(t.dropdownAdapter,r)}t.dropdownAdapter=x.Decorate(t.dropdownAdapter,I)}if(null==t.selectionAdapter){if(t.multiple?t.selectionAdapter=y:t.selectionAdapter=v,null!=t.placeholder&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,_)),t.allowClear&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,b)),t.multiple&&(t.selectionAdapter=x.Decorate(t.selectionAdapter,w)),null!=t.containerCssClass||null!=t.containerCss||null!=t.adaptContainerCssClass){var s=f(t.amdBase+"compat/containerCss");t.selectionAdapter=x.Decorate(t.selectionAdapter,s)}t.selectionAdapter=x.Decorate(t.selectionAdapter,A)}if("string"==typeof t.language)if(0<t.language.indexOf("-")){var o=t.language.split("-")[0];t.language=[t.language,o]}else t.language=[t.language];if(m.isArray(t.language)){var a=new $;t.language.push("en");for(var l=t.language,u=0;u<l.length;u++){var c=l[u],d={};try{d=$.loadPath(c)}catch(e){try{c=this.defaults.amdLanguageBase+c,d=$.loadPath(c)}catch(e){t.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+c+'" could not be automatically loaded. A fallback will be used instead.');continue}}a.extend(d)}t.translations=a}else{var p=$.loadPath(this.defaults.amdLanguageBase+"en"),h=new $(t.language);h.extend(p),t.translations=h}return t},n.prototype.reset=function(){function a(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:x.escapeMarkup,language:e,matcher:function e(t,n){if(""===m.trim(t.term))return n;if(n.children&&0<n.children.length){for(var i=m.extend(!0,{},n),r=n.children.length-1;0<=r;r--)null==e(t,n.children[r])&&i.children.splice(r,1);return 0<i.children.length?i:e(t,i)}var s=a(n.text).toUpperCase(),o=a(t.term).toUpperCase();return-1<s.indexOf(o)?n:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},n.prototype.set=function(e,t){var n={};n[m.camelCase(e)]=t;var i=x._convertData(n);m.extend(this.defaults,i)},new n}),e.define("pumselect2/options",["require","jquery","./defaults","./utils"],function(i,s,r,o){function e(e,t){if(this.options=e,null!=t&&this.fromElement(t),this.options=r.apply(this.options),t&&t.is("input")){var n=i(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=o.Decorate(this.options.dataAdapter,n)}}return e.prototype.fromElement=function(e){var t=["pumselect2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.language&&(e.prop("lang")?this.options.language=e.prop("lang").toLowerCase():e.closest("[lang]").prop("lang")&&(this.options.language=e.closest("[lang]").prop("lang"))),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),e.data("pumselect2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-pumselect2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),e.data("data",e.data("pumselect2Tags")),e.data("tags",!0)),e.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",e.data("ajaxUrl")),e.data("ajax--url",e.data("ajaxUrl")));var n={};n=s.fn.jquery&&"1."==s.fn.jquery.substr(0,2)&&e[0].dataset?s.extend(!0,{},e[0].dataset,e.data()):e.data();var i=s.extend(!0,{},n);for(var r in i=o._convertData(i))-1<s.inArray(r,t)||(s.isPlainObject(this.options[r])?s.extend(this.options[r],i[r]):this.options[r]=i[r]);return this},e.prototype.get=function(e){return this.options[e]},e.prototype.set=function(e,t){this.options[e]=t},e}),e.define("pumselect2/core",["jquery","./options","./utils","./keys"],function(r,u,n,i){var c=function(e,t){null!=e.data("pumselect2")&&e.data("pumselect2").destroy(),this.$element=e,this.id=this._generateId(e),t=t||{},this.options=new u(t,e),c.__super__.constructor.call(this);var n=e.attr("tabindex")||0;e.data("old-tabindex",n),e.attr("tabindex","-1");var i=this.options.get("dataAdapter");this.dataAdapter=new i(e,this.options);var r=this.render();this._placeContainer(r);var s=this.options.get("selectionAdapter");this.selection=new s(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,r);var o=this.options.get("dropdownAdapter");this.dropdown=new o(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,r);var a=this.options.get("resultsAdapter");this.results=new a(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var l=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){l.trigger("selection:update",{data:e})}),e.addClass("pumselect2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),e.data("pumselect2",this)};return n.Extend(c,n.Observable),c.prototype._generateId=function(e){return"pumselect2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+n.generateChars(2):n.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},c.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},c.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var i=this._resolveWidth(e,"style");return null!=i?i:this._resolveWidth(e,"element")}if("element"==t){var r=e.outerWidth(!1);return r<=0?"auto":r+"px"}if("style"!=t)return t;var s=e.attr("style");if("string"!=typeof s)return null;for(var o=s.split(";"),a=0,l=o.length;a<l;a+=1){var u=o[a].replace(/\s/g,"").match(n);if(null!==u&&1<=u.length)return u[1]}return null},c.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},c.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.pumselect2",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this._sync=n.bind(this._syncAttributes,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._sync);var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=e?(this._observer=new e(function(e){r.each(e,t._sync)}),this._observer.observe(this.$element[0],{attributes:!0,subtree:!1})):this.$element[0].addEventListener&&this.$element[0].addEventListener("DOMAttrModified",t._sync,!1)},c.prototype._registerDataEvents=function(){var n=this;this.dataAdapter.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerSelectionEvents=function(){var n=this,i=["toggle","focus"];this.selection.on("toggle",function(){n.toggleDropdown()}),this.selection.on("focus",function(e){n.focus(e)}),this.selection.on("*",function(e,t){-1===r.inArray(e,i)&&n.trigger(e,t)})},c.prototype._registerDropdownEvents=function(){var n=this;this.dropdown.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerResultsEvents=function(){var n=this;this.results.on("*",function(e,t){n.trigger(e,t)})},c.prototype._registerEvents=function(){var n=this;this.on("open",function(){n.$container.addClass("pumselect2-container--open")}),this.on("close",function(){n.$container.removeClass("pumselect2-container--open")}),this.on("enable",function(){n.$container.removeClass("pumselect2-container--disabled")}),this.on("disable",function(){n.$container.addClass("pumselect2-container--disabled")}),this.on("blur",function(){n.$container.removeClass("pumselect2-container--focus")}),this.on("query",function(t){n.isOpen()||n.trigger("open",{}),this.dataAdapter.query(t,function(e){n.trigger("results:all",{data:e,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(e){n.trigger("results:append",{data:e,query:t})})}),this.on("keypress",function(e){var t=e.which;n.isOpen()?t===i.ESC||t===i.TAB||t===i.UP&&e.altKey?(n.close(),e.preventDefault()):t===i.ENTER?(n.trigger("results:select",{}),e.preventDefault()):t===i.SPACE&&e.ctrlKey?(n.trigger("results:toggle",{}),e.preventDefault()):t===i.UP?(n.trigger("results:previous",{}),e.preventDefault()):t===i.DOWN&&(n.trigger("results:next",{}),e.preventDefault()):(t===i.ENTER||t===i.SPACE||t===i.DOWN&&e.altKey)&&(n.open(),e.preventDefault())})},c.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},c.prototype.trigger=function(e,t){var n=c.__super__.trigger,i={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===t&&(t={}),e in i){var r=i[e],s={prevented:!1,name:e,args:t};if(n.call(this,r,s),s.prevented)return void(t.prevented=!0)}n.call(this,e,t)},c.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},c.prototype.open=function(){this.isOpen()||this.trigger("query",{})},c.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},c.prototype.isOpen=function(){return this.$container.hasClass("pumselect2-container--open")},c.prototype.hasFocus=function(){return this.$container.hasClass("pumselect2-container--focus")},c.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("pumselect2-container--focus"),this.trigger("focus",{}))},c.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `pumselect2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);var t=!e[0];this.$element.prop("disabled",t)},c.prototype.data=function(){this.options.get("debug")&&0<arguments.length&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `pumselect2("data")`. You should consider setting the value instead using `$element.val()`.');var t=[];return this.dataAdapter.current(function(e){t=e}),t},c.prototype.val=function(e){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `pumselect2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==e||0===e.length)return this.$element.val();var t=e[0];r.isArray(t)&&(t=r.map(t,function(e){return e.toString()})),this.$element.val(t).trigger("change")},c.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._sync),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&this.$element[0].removeEventListener("DOMAttrModified",this._sync,!1),this._sync=null,this.$element.off(".pumselect2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("pumselect2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("pumselect2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},c.prototype.render=function(){var e=r('<span class="pumselect2 pumselect2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("pumselect2-container--"+this.options.get("theme")),e.data("element",this.$element),e},c}),e.define("pumselect2/compat/utils",["jquery"],function(o){return{syncCssClasses:function(e,t,n){var i,r,s=[];(i=o.trim(e.attr("class")))&&o((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("pumselect2-")&&s.push(this)}),(i=o.trim(t.attr("class")))&&o((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("pumselect2-")&&null!=(r=n(this))&&s.push(r)}),e.attr("class",s.join(" "))}}}),e.define("pumselect2/compat/containerCss",["jquery","./utils"],function(o,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";o.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var r=i;i=function(e){var t=r(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return o.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("pumselect2/compat/dropdownCss",["jquery","./utils"],function(o,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";o.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var r=i;i=function(e){var t=r(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return o.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("pumselect2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("pumselect2/compat/inputData",["jquery"],function(o){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `<select>` element instead."),e.call(this,t,n)}return e.prototype.current=function(e,t){function i(e,t){var n=[];return e.selected||-1!==o.inArray(e.id,t)?(e.selected=!0,n.push(e)):e.selected=!1,e.children&&n.push.apply(n,i(e.children,t)),n}for(var n=[],r=0;r<this._currentData.length;r++){var s=this._currentData[r];n.push.apply(n,i(s,this.$element.val().split(this._valueSeparator)))}t(n)},e.prototype.select=function(e,t){if(this.options.get("multiple")){var n=this.$element.val();n+=this._valueSeparator+t.id,this.$element.val(n),this.$element.trigger("change")}else this.current(function(e){o.map(e,function(e){e.selected=!1})}),this.$element.val(t.id),this.$element.trigger("change")},e.prototype.unselect=function(e,r){var s=this;r.selected=!1,this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];r.id!=i.id&&t.push(i.id)}s.$element.val(t.join(s._valueSeparator)),s.$element.trigger("change")})},e.prototype.query=function(e,t,n){for(var i=[],r=0;r<this._currentData.length;r++){var s=this._currentData[r],o=this.matches(t,s);null!==o&&i.push(o)}n({results:i})},e.prototype.addOptions=function(e,t){var n=o.map(t,function(e){return o.data(e[0],"data")});this._currentData.push.apply(this._currentData,n)},e}),e.define("pumselect2/compat/matcher",["jquery"],function(o){return function(s){return function(e,t){var n=o.extend(!0,{},t);if(null==e.term||""===o.trim(e.term))return n;if(t.children){for(var i=t.children.length-1;0<=i;i--){var r=t.children[i];s(e.term,r.text,r)||n.children.splice(i,1)}if(0<n.children.length)return n}return s(e.term,t.text,t)?n:null}}}),e.define("pumselect2/compat/query",[],function(){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `query` option has been deprecated in favor of a custom data adapter that overrides the `query` method. Support will be removed for the `query` option in future versions of Select2."),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.callback=n,this.options.get("query").call(null,t)},e}),e.define("pumselect2/dropdown/attachContainer",[],function(){function e(e,t,n){e.call(this,t,n)}return e.prototype.position=function(e,t,n){n.find(".dropdown-wrapper").append(t),t.addClass("pumselect2-dropdown--below"),n.addClass("pumselect2-container--below")},e}),e.define("pumselect2/dropdown/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$dropdown.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),e.define("pumselect2/selection/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$selection.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),n=function(p){var h,m,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],t="onwheel"in document||9<=document.documentMode?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],f=Array.prototype.slice;if(p.event.fixHooks)for(var n=e.length;n;)p.event.fixHooks[e[--n]]=p.event.mouseHooks;var g=p.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],i,!1);else this.onmousewheel=i;p.data(this,"mousewheel-line-height",g.getLineHeight(this)),p.data(this,"mousewheel-page-height",g.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],i,!1);else this.onmousewheel=null;p.removeData(this,"mousewheel-line-height"),p.removeData(this,"mousewheel-page-height")},getLineHeight:function(e){var t=p(e),n=t["offsetParent"in p.fn?"offsetParent":"parent"]();return n.length||(n=p("body")),parseInt(n.css("fontSize"),10)||parseInt(t.css("fontSize"),10)||16},getPageHeight:function(e){return p(e).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function i(e){var t,n=e||window.event,i=f.call(arguments,1),r=0,s=0,o=0,a=0,l=0;if((e=p.event.fix(n)).type="mousewheel","detail"in n&&(o=-1*n.detail),"wheelDelta"in n&&(o=n.wheelDelta),"wheelDeltaY"in n&&(o=n.wheelDeltaY),"wheelDeltaX"in n&&(s=-1*n.wheelDeltaX),"axis"in n&&n.axis===n.HORIZONTAL_AXIS&&(s=-1*o,o=0),r=0===o?s:o,"deltaY"in n&&(r=o=-1*n.deltaY),"deltaX"in n&&(s=n.deltaX,0===o&&(r=-1*s)),0!==o||0!==s){if(1===n.deltaMode){var u=p.data(this,"mousewheel-line-height");r*=u,o*=u,s*=u}else if(2===n.deltaMode){var c=p.data(this,"mousewheel-page-height");r*=c,o*=c,s*=c}if(t=Math.max(Math.abs(o),Math.abs(s)),(!m||t<m)&&y(n,m=t)&&(m/=40),y(n,t)&&(r/=40,s/=40,o/=40),r=Math[1<=r?"floor":"ceil"](r/m),s=Math[1<=s?"floor":"ceil"](s/m),o=Math[1<=o?"floor":"ceil"](o/m),g.settings.normalizeOffset&&this.getBoundingClientRect){var d=this.getBoundingClientRect();a=e.clientX-d.left,l=e.clientY-d.top}return e.deltaX=s,e.deltaY=o,e.deltaFactor=m,e.offsetX=a,e.offsetY=l,e.deltaMode=0,i.unshift(e,r,s,o),h&&clearTimeout(h),h=setTimeout(v,200),(p.event.dispatch||p.event.handle).apply(this,i)}}function v(){m=null}function y(e,t){return g.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}p.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})},"function"==typeof e.define&&e.define.amd?e.define("jquery-mousewheel",["jquery"],n):"object"==typeof exports?module.exports=n:n(i),e.define("jquery.pumselect2",["jquery","jquery-mousewheel","./pumselect2/core","./pumselect2/defaults"],function(r,e,t,n){if(null==r.fn.pumselect2){var s=["open","close","destroy"];r.fn.pumselect2=function(n){if("object"==typeof(n=n||{}))return this.each(function(){var e=r.extend(!0,{},n);new t(r(this),e)}),this;if("string"!=typeof n)throw new Error("Invalid arguments for Select2: "+n);var i;return this.each(function(){var e=r(this).data("pumselect2");null==e&&window.console&&console.error&&console.error("The pumselect2('"+n+"') method was called on an element that is not using Select2.");var t=Array.prototype.slice.call(arguments,1);i=e[n].apply(e,t)}),-1<r.inArray(n,s)?this:i}}return null==r.fn.pumselect2.defaults&&(r.fn.pumselect2.defaults=n),t}),{define:e.define,require:e.require}}(),t=e.require("jquery.pumselect2");return i.fn.pumselect2.amd=e,t}),function(i){"use strict";var e=i(".pum-alerts"),r=i(".pum-alert-count"),s=parseInt(r.eq(0).text());function o(){0===e.find(".pum-alert-holder").length&&(e.slideUp(100,function(){e.remove()}),i("#menu-posts-popup .wp-menu-name .update-plugins").fadeOut())}i(document).on("pumDismissAlert",o).on("click",".pum-alert-holder .pum-dismiss",function(){var e=i(this),t=e.parents(".pum-alert-holder"),n=e.data("reason")||"maybe_later";"review_request"!==t.data("code")?function(e){var t=e.data("dismissible"),n="1"===t||1===t||!0===t?null:t;i.ajax({method:"POST",dataType:"json",url:ajaxurl,data:{action:"pum_alerts_action",nonce:window.pum_alerts_nonce,code:e.data("code"),expires:n}})}(t):function(e){i.ajax({method:"POST",dataType:"json",url:ajaxurl,data:{action:"pum_review_action",nonce:window.pum_review_nonce,group:window.pum_review_trigger.group,code:window.pum_review_trigger.code,pri:window.pum_review_trigger.pri,reason:e}}),void 0!==window.pum_review_api_url&&i.ajax({method:"POST",dataType:"json",url:window.pum_review_api_url,data:{trigger_group:window.pum_review_trigger.group,trigger_code:window.pum_review_trigger.code,reason:e,uuid:window.pum_review_uuid||null}})}(n),function(e){s--,r.text(s),e.fadeTo(100,0,function(){e.slideUp(100,function(){e.remove(),o()})})}(t)})}(jQuery),function(r){"use strict";var e={init:function(){r(".pum-color-picker").filter(":not(.pum-color-picker-initialized)").addClass("pum-color-picker-initialized").wpColorPicker({change:function(e,t){r(e.target).trigger("colorchange",t)},clear:function(e){r(e.target).prev().trigger("colorchange").wpColorPicker("close")},hide:!0})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.colorpicker=e,r(document).on("click",".iris-palette",function(){r(this).parents(".wp-picker-active").find("input.pum-color-picker").trigger("change")}).on("colorchange",function(e,t){var n=r(e.target),i="";void 0!==t&&void 0!==t.color&&(i=t.color.toString()),n.val(i).trigger("change"),"popup_theme"===r("form#post input#post_type").val()&&PUM_Admin.utils.debounce(PUM_Admin.themeEditor.refresh_preview,100)}).on("pum_init",e.init)}(jQuery),function(h){"use strict";var c={init:function(){c.checkDependencies()},checkDependencies:function(e){var t=h(e);(e=t.length?t:h("[data-pum-dependencies]:not([data-pum-processed-dependencies])")).each(function(){var e,l=h(this),u=l.data("id"),c=l.data("pum-processed-dependencies")||{},d=Object.keys(c).length,p=0,t=l.data("pum-dependent-fields");if(!l.data("pum-processed-dependencies")){for(e in"string"==typeof(c=l.data("pum-dependencies"))&&(c=JSON.parse(c)),c)c.hasOwnProperty(e)&&("string"==typeof c[e]?-1!==c[e].indexOf(",")?c[e]=c[e].split(","):c[e]=[c[e]]:"number"==typeof c[e]&&(c[e]=[c[e]]));d=Object.keys(c).length,l.data("pum-processed-dependencies",c).attr("data-pum-processed-dependencies",c)}t||(t=h.map(c,function(e,t){var n=h('.pum-field[data-id="'+t+'"]');return n.length?n.eq(0):null}),l.data("pum-dependent-fields",t)),h(t).each(function(){var e,t=h(this),n=t.find(":input:first"),i=t.data("id"),r=n.val(),s=c[i],o=t.data("pum-field-dependents")||[];if(-1===o.indexOf(u)&&(o.push(u),t.data("pum-field-dependents",o)),null==s)return l.removeClass("pum-dependencies-met").hide(0).trigger("pumFormDependencyUnmet"),!1;if(t.hasClass("pum-field-radio")&&(r=t.find(":input:checked").val()),t.hasClass("pum-field-multicheck")&&(r=[],t.find(":checkbox:checked").each(function(e){r[e]=h(this).val(),"string"!=typeof r[e]||isNaN(parseInt(r[e]))||(r[e]=parseInt(r[e]))})),t.hasClass("pum-field-select")||t.hasClass("pum-field-radio"))e=s&&-1!==s.indexOf(r);else if(t.hasClass("pum-field-checkbox"))e=s===n.is(":checked");else if(t.hasClass("pum-field-multicheck"))if(Array.isArray(s)){e=!1;for(var a=0;a<s.length;a++)-1!==r.indexOf(s[a])&&(e=!0)}else e=-1!==r.indexOf(s);else e=Array.isArray(s)?-1!==s.indexOf(r):s==r;if(!e)return l.removeClass("pum-dependencies-met").hide(0).trigger("pumFormDependencyUnmet"),!1;++p===d&&l.addClass("pum-dependencies-met").show(0).trigger("pumFormDependencyMet")})})},form_check:function(){h(document).trigger("pum_form_check")},is_field:function(e){return"object"==typeof e&&0<=[void 0===e.type&&(void 0!==e.label||void 0!==e.desc),void 0!==e.type&&"string"==typeof e.type].indexOf(!0)},flattenFields:function(e){var i={},t=e.tabs||{},n=e.sections||{},r=e.fields||{};return Object.keys(t).length&&Object.keys(n).length?_.each(r,function(e,t){"object"==typeof e&&Object.keys(e).length&&_.each(e,function(e,t){if("object"==typeof e&&Object.keys(e).length){if(c.is_field(e)){var n={};n[t]=e,t="main",e=n}_.each(e,function(e){i[e.id]=e})}})}):Object.keys(t).length?_.each(r,function(e,t){"object"==typeof e&&Object.keys(e).length&&_.each(e,function(e){i[e.id]=e})}):Object.keys(n).length?_.each(r,function(e,t){_.each(e,function(e){i[e.id]=e})}):(r=c.parseFields(r,values),_.each(r,function(e){i[e.id]=e})),i},parseFields:function(n,i){return i=i||{},_.each(n,function(e,t){n[t]=PUM_Admin.models.field(e),"object"!=typeof n[t].meta&&(n[t].meta={}),void 0!==i[t]&&(n[t].value=i[t]),""===n[t].id&&(n[t].id=t)}),n},renderTab:function(){},renderSection:function(){},render:function(e,r,t){var n,i=[],s={},o=h.extend(!0,{id:"",tabs:{},sections:{},fields:{},maintabs:{},subtabs:{}},e),a=h.extend({id:o.id,classes:[],tabs:{},vertical:!0,form:!0,meta:{"data-min-height":250}},o.maintabs),l=h.extend({classes:["link-tabs","sub-tabs"],tabs:{}},o.subtabs),u=["pum-dynamic-form"];return r=r||{},Object.keys(o.tabs).length&&Object.keys(o.sections).length?(u.push("tabbed-content"),_.each(o.fields,function(e,i){"object"==typeof e&&Object.keys(e).length&&(void 0===a.tabs[i]&&(a.tabs[i]={label:o.tabs[i],content:""}),l=h.extend(l,{id:o.id+"-"+i+"-subtabs",tabs:{}}),_.each(e,function(e,t){if("object"==typeof e&&Object.keys(e).length){if(c.is_field(e)){var n={};n[t]=e,t="main",e=n}void 0===l.tabs[t]&&(l.tabs[t]={label:o.sections[i][t],content:""}),e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,l.tabs[t].content+=PUM_Admin.templates.field(e)}),""===l.tabs[t].content&&delete l.tabs[t]}}),Object.keys(l.tabs).length?a.tabs[i].content=PUM_Admin.templates.tabs(l):delete a.tabs[i])}),Object.keys(a.tabs).length&&(n=PUM_Admin.templates.tabs(a))):Object.keys(o.tabs).length?(u.push("tabbed-content"),_.each(o.fields,function(e,t){"object"==typeof e&&Object.keys(e).length&&(void 0===a.tabs[t]&&(a.tabs[t]={label:o.tabs[t],content:""}),i=[],e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),i.length?a.tabs[t].content=PUM_Admin.templates.section({fields:i}):delete a.tabs[t])}),Object.keys(a.tabs).length&&(n=PUM_Admin.templates.tabs(a))):Object.keys(o.sections).length?_.each(o.fields,function(e,t){(i=[]).push(PUM_Admin.templates.field({type:"heading",desc:o.sections[t]||""})),e=c.parseFields(e,r),_.each(e,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),n+=PUM_Admin.templates.section({fields:i})}):(o.fields=c.parseFields(o.fields,r),_.each(o.fields,function(e){s[e.id]=e,i.push(PUM_Admin.templates.field(e))}),n=PUM_Admin.templates.section({fields:i})),void 0!==t&&t.length&&t.addClass(u.join(" ")).data("form_fields",s).html(n).trigger("pum_init"),n},parseValues:function(e,t){if(!(t=t||!1))return e;for(var n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n+"_unit")&&(e[n]+=e[n+"_unit"],delete e[n+"_unit"]),void 0!==e[n]?t[n].allow_html&&!PUM_Admin.utils.htmlencoder.hasEncoded(e[n])&&(e[n]=PUM_Admin.utils.htmlencoder.htmlEncode(e[n])):"checkbox"===t[n].type&&(e[n]=!1));return e}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.forms=c,h(document).on("pum_init pum_form_check",function(){PUM_Admin.forms.init()}).on("pumFieldChanged",".pum-field",function(){var e,t=h(this).data("pum-field-dependents")||[],n=h();if(t&&!(t.length<=0)){for(e=0;e<t.length;e++)n=n.add('.pum-field[data-id="'+t[e]+'"]');PUM_Admin.forms.checkDependencies(n)}}).on("pumFieldChanged",".pum-field-dynamic-desc",function(){var e=h(this),t=e.find(":input"),n=e.parents(".pum-dynamic-form:first"),i=t.val(),r=(n.data("form_fields")||{})[e.data("id")]||{},s=e.find(".pum-desc"),o=e.data("pum-dynamic-desc");switch(r.type){case"radio":i=e.find(":input:checked").val()}r.value=i,o&&o.length&&s.html(PUM_Admin.templates.renderInline(o,r))}).on("change",".pum-field-select select",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-checkbox input",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-multicheck input",function(){h(this).parents(".pum-field").trigger("pumFieldChanged")}).on("click",".pum-field-radio input",function(e){var t=h(this),n=t.parents("li"),i=t.parents(".pum-field");i.trigger("pumFieldChanged"),i.find("li.pum-selected").removeClass("pum-selected"),n.addClass("pum-selected")})}(jQuery),function(s){"use strict";var i,r,o=s("html"),t=s(document),a="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",e={_current:null,forceFocus:function(e){PUM_Admin.modals._current&&!PUM_Admin.modals._current.contains(e.target)&&(e.stopPropagation(),PUM_Admin.modals._current.focus())},trapEscapeKey:function(e){27===e.keyCode&&(PUM_Admin.modals.closeAll(),e.preventDefault())},trapTabKey:function(e){if(9===e.keyCode){var t=PUM_Admin.modals._current.find("*").filter(a).filter(":visible"),n=s(":focus"),i=t.length,r=t.index(n);e.shiftKey?0===r&&(t.get(i-1).focus(),e.preventDefault()):r===i-1&&(t.get(0).focus(),e.preventDefault())}},setFocusToFirstItem:function(){PUM_Admin.modals._current.find(".pum-modal-content *").filter(a).filter(":visible").first().focus()},closeAll:function(e){s(".pum-modal-background").off("keydown.pum_modal").hide(0,function(){s("html").css({overflow:"visible",width:"auto"}),i&&(i.attr("aria-hidden","false"),i=null),r.length&&r.focus(),PUM_Admin.modals._current=null,t.off("focus.pum_modal"),void 0!==e&&e()}).attr("aria-hidden","true")},show:function(e,t){s(".pum-modal-background").off("keydown.pum_modal").hide(0).attr("aria-hidden","true"),o.data("origwidth",o.innerWidth()).css({overflow:"hidden",width:o.innerWidth()});var n=s(":focus");n.parents(".pum-modal-wrap").length||(r=n),PUM_Admin.modals._current=s(e),PUM_Admin.modals._current.on("keydown.pum_modal",function(e){PUM_Admin.modals.trapEscapeKey(e),PUM_Admin.modals.trapTabKey(e)}).show(0,function(){(i=s("body > *").filter(":visible").not(PUM_Admin.modals._current)).attr("aria-hidden","true"),PUM_Admin.modals._current.trigger("pum_init").on("focus.pum_modal",PUM_Admin.modals.forceFocus),PUM_Admin.modals.setFocusToFirstItem(),void 0!==t&&t()}).attr("aria-hidden","false")},remove:function(e){s(e).remove()},replace:function(e,t){PUM_Admin.modals.remove(s.trim(e)),s("body").append(s.trim(t))},reload:function(e,t,n){PUM_Admin.modals.replace(e,t),PUM_Admin.modals.show(e,n),s(e).trigger("pum_init")}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.modals=e,s(document).on("click",".pum-modal-background, .pum-modal-wrap .cancel, .pum-modal-wrap .pum-modal-close",function(e){var t=s(e.target);(t.hasClass("cancel")||t.hasClass("pum-modal-close")||t.hasClass("submitdelete"))&&(PUM_Admin.modals.closeAll(),e.preventDefault(),e.stopPropagation())})}(jQuery),function(t){"use strict";var e={field:function(e){return t.extend(!0,{},{type:"text",id:"",id_prefix:"",name:"",label:null,placeholder:"",desc:null,dynamic_desc:null,size:"regular",classes:[],dependencies:"",value:null,select2:!1,allow_html:!1,multiple:!1,as_array:!1,options:[],object_type:null,object_key:null,std:null,min:0,max:50,force_minmax:!1,step:1,unit:"px",units:{},required:!1,desc_position:"bottom",meta:{}},e)}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.models=e}(jQuery),function(a){"use strict";var s={cloneables:{slider:a('<input type="range" class="pum-range-slider" />'),plus:a('<button type="button" class="pum-range-plus">+</button>'),minus:a('<button type="button" class="pum-range-minus">-</button>')},init:function(){a(".pum-field-rangeslider:not(.pum-rangeslider-initialized)").each(function(){var e=a(this).addClass("pum-rangeslider-initialized").find("input.pum-range-manual"),t=s.cloneables.slider.clone(),n=s.cloneables.plus.clone(),i=s.cloneables.minus.clone(),r={force:e.data("force-minmax"),min:parseInt(e.attr("min"),10)||0,max:parseInt(e.attr("max"),10)||100,step:parseInt(e.attr("step"),10)||1,value:parseInt(e.attr("value"),10)||0};r.force&&r.value>r.max&&(r.value=r.max,e.val(r.value)),t.prop({min:r.min||0,max:r.force||r.max&&r.max>r.value?r.max:1.5*r.value,step:r.step||1.5*r.value/100,value:r.value}).on("change input",function(){e.trigger("input")}),e.next().after(i,n),e.before(t)})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.rangesliders=s,a(document).on("pum_init",PUM_Admin.rangesliders.init).on("input",".pum-field-rangeslider.pum-rangeslider-initialized .pum-range-slider",function(){var e=a(this);e.siblings(".pum-range-manual").val(e.val())}).on("change",".pum-range-manual",function(){var e=a(this),t=parseInt(e.prop("max"),0),n=parseInt(e.prop("min"),0),i=parseInt(e.prop("step"),0),r=e.data("force-minmax"),s=parseInt(e.val(),0),o=e.prev();isNaN(s)&&(s=o.val()),r&&t<s?s=t:r&&s<n&&(s=n),e.val(s).trigger("input"),o.prop({max:r||t&&s<t?t:1.5*s,step:i||1.5*s/100,value:s})}).on("click",".pum-range-plus",function(e){var t=a(this).siblings(".pum-range-manual"),n=parseInt(t.prop("max"),0),i=parseInt(t.prop("step"),0),r=t.data("force-minmax"),s=parseInt(t.val(),0),o=t.prev();e.preventDefault(),s+=i,isNaN(s)&&(s=o.val()),r&&n<s&&(s=n),t.val(s).trigger("input"),o.val(s)}).on("click",".pum-range-minus",function(e){var t=a(this).siblings(".pum-range-manual"),n=parseInt(t.prop("min"),0),i=parseInt(t.prop("step"),0),r=t.data("force-minmax"),s=parseInt(t.val(),0),o=t.prev();e.preventDefault(),s-=i,isNaN(s)&&(s=o.val()),r&&s<n&&(s=n),t.val(s).trigger("input"),o.val(s)})}(jQuery),function(o){"use strict";o.fn.pumselect2=o.fn.pumselect2||o.fn.select2;var e={init:function(){o(".pum-field-select2 select").filter(":not(.pumselect2-initialized)").each(function(){var n=o(this),t=n.data("current")||n.val(),i=n.data("objecttype"),r=n.data("objectkey"),s=n.data("objectexcludes")||null,e={width:"100%",multiple:!1,dropdownParent:n.parent()};n.attr("multiple")&&(e.multiple=!0),i&&r&&(e=o.extend(e,{ajax:{url:ajaxurl,dataType:"json",delay:250,data:function(e){return{s:e.term,paged:e.page,action:"pum_object_search",object_type:i,object_key:r,exclude:s}},processResults:function(e,t){return t.page=t.page||1,{results:e.items,pagination:{more:10*t.page<e.total_count}}},cache:!0},cache:!0,escapeMarkup:function(e){return e},maximumInputLength:20,closeOnSelect:!e.multiple,templateResult:PUM_Admin.select2.formatObject,templateSelection:PUM_Admin.select2.formatObjectSelection})),n.addClass("pumselect2-initialized").pumselect2(e),null!=t?e.multiple&&"object"!=typeof t&&""!==t?t=[t]:e.multiple||""!==t||(t=null):t=null,i&&r&&null!==t&&("number"==typeof t||t.length)?o.ajax({url:ajaxurl,data:{action:"pum_object_search",object_type:i,object_key:r,exclude:s,include:t&&t.length?"string"==typeof t||"number"==typeof t?[t]:t:null},dataType:"json",success:function(e){o.each(e.items,function(e,t){n.find('option[value="'+t.id+'"]').length||n.prepend('<option value="'+t.id+'">'+t.text+"</option>")}),n.val(t).trigger("change")}}):t&&(e.multiple&&t.length||!e.multiple&&""!==t)?n.val(t).trigger("change"):null===t&&n.val(t).trigger("change")})},formatObject:function(e){return e.text},formatObjectSelection:function(e){return e.text||e.text}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.select2=e,o(document).on("pum_init",function(){PUM_Admin.select2.init()})}(jQuery),function(n,i){if("function"!=typeof window.$$){var r,s,o={},a={};window.$$=function(e,t){return t?((r=t.selector)&&(t=r),(s=a[t])===i&&(s=a[t]={}),(r=s[e])!==i?r:s[e]=n(e,$$(t))):(r=o[e])!==i?r:o[e]=n(e)},window.$$clear=function(e,t){t?((r=t.selector)&&(t=r),e&&(r=a[t])&&(r[e]=i),a[t]=i):e?(o[e]=i,a[e]=i):(o={},a={})},window.$$fresh=function(e,t){return $$clear(e,t),$$(e,t)}}}(jQuery),function(e,n){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,t){return n(e,t)});else if("undefined"!=typeof exports){var t=require("jquery");n(exports,t)}else n(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,a){var l={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};function t(i,n){var r={},s={};function o(e,t,n){return e[t]=n,e}function e(){return r}this.addPair=function(e){if(!l.validate.test(e.name))return this;var t=function(e,t){var n,i,r=e.match(l.key);try{t=JSON.parse(t)}catch(e){}for(;void 0!==(n=r.pop());)l.push.test(n)?t=o([],(i=e.replace(/\[\]$/,""),void 0===s[i]&&(s[i]=0),s[i]++),t):l.fixed.test(n)?t=o([],n,t):l.named.test(n)&&(t=o({},n,t));return t}(e.name,function(e){switch(a('[name="'+e.name+'"]',n).attr("type")){case"checkbox":return"1"===e.value||e.value;default:return e.value}}(e));return r=i.extend(!0,r,t),this},this.addPairs=function(e){if(!i.isArray(e))throw new Error("formSerializer.addPairs expects an Array");for(var t=0,n=e.length;t<n;t++)this.addPair(e[t]);return this},this.serialize=e,this.serializeJSON=function(){return JSON.stringify(e())}}return t.patterns=l,t.serializeObject=function(){var e;return e=this.is("form")?this.serializeArray():this.find(":input").serializeArray(),new t(a,this).addPairs(e).serialize()},t.serializeJSON=function(){var e;return e=this.is("form")?this.serializeArray():this.find(":input").serializeArray(),new t(a,this).addPairs(e).serializeJSON()},void 0!==a.fn&&(a.fn.pumSerializeObject=t.serializeObject,a.fn.pumSerializeJSON=t.serializeJSON),e.FormSerializer=t}),function(o){"use strict";var e={init:function(){o(".pum-tabs-container").filter(":not(.pum-tabs-initialized)").each(function(){var e=o(this).addClass("pum-tabs-initialized"),t=e.find("> ul.tabs"),n=t.find("> li:first"),i=e.data("min-height");if(e.hasClass("vertical-tabs")){var r=i&&0<i?i:t.eq(0).outerHeight(!0);e.css({minHeight:r+"px"}),e.parent().innerHeight<r&&e.parent().css({minHeight:r+"px"})}n.trigger("click")})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.tabs=e,o(document).on("pum_init",PUM_Admin.tabs.init).on("click",".pum-tabs-initialized li.tab",function(e){var t=o(this),n=t.parents(".pum-tabs-container:first"),i=n.find("> ul.tabs > li.tab"),r=n.find("> div.tab-content"),s=t.find("a").attr("href");i.removeClass("active"),r.removeClass("active"),t.addClass("active"),n.find("> div.tab-content"+s).addClass("active"),e.preventDefault()})}(jQuery),function(i){"use strict";var n=pum_admin_vars.I10n,e={render:function(e,t){var n=wp.template(e);return void 0!==(t=t||{}).classes&&Array.isArray(t.classes)&&(t.classes=t.classes.join(" ")),n(t=PUM_Admin.templates.prepareMeta(t))},renderInline:function(e,t){return _.template(e,null,{evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"})(t)},shortcode:function(e){var t=i.extend(!0,{},{tag:"",meta:{},has_content:!1,content:""},e),n=t.has_content?"pum-shortcode-w-content":"pum-shortcode";return PUM_Admin.templates.render(n,t)},modal:function(e){var t=i.extend(!0,{},{id:"",title:"",description:"",classes:"",save_button:n.save,cancel_button:n.cancel,content:""},e);return PUM_Admin.templates.render("pum-modal",t)},tabs:function(e){return"string"==typeof(e=i.extend(!0,{},{id:"",vertical:!1,form:!1,classes:[],tabs:{},meta:{}},e)).classes&&(e.classes=[e.classes]),e.form&&e.classes.push("pum-tabbed-form"),e.meta["data-tab-count"]=Object.keys(e.tabs).length,e.classes.push(e.vertical?"vertical-tabs":"horizontal-tabs"),e.classes=e.classes.join(" "),PUM_Admin.templates.render("pum-tabs",e)},section:function(e){var t=i.extend(!0,{},{classes:[],fields:[]},e);return PUM_Admin.templates.render("pum-field-section",t)},fieldArgs:function(e){var s=[],o=i.extend(!0,{},PUM_Admin.models.field(e));switch(void 0===e.std||"checkbox"===e.type||null!==o.value&&!1!==o.value||(o.value=e.std),"string"==typeof o.classes&&(o.classes=o.classes.split(" ")),void 0!==e.class&&o.classes.push(e.class),void 0!==e.dependencies&&"object"==typeof e.dependencies&&(o.dependencies=JSON.stringify(e.dependencies)),o.required&&(o.meta.required=!0,o.classes.push("pum-required")),"string"==typeof o.dynamic_desc&&o.dynamic_desc.length&&(o.classes.push("pum-field-dynamic-desc"),o.desc=PUM_Admin.templates.renderInline(o.dynamic_desc,o)),o.allow_html&&(o.classes.push("pum-field-"+o.type+"--html"),"string"==typeof o.value&&""!==o.value&&PUM_Admin.utils.htmlencoder.hasEncoded(o.value)&&(o.value=PUM_Admin.utils.htmlencoder.htmlDecode(o.value))),e.type){case"select":case"objectselect":case"postselect":case"taxonomyselect":void 0!==o.options&&(_.each(o.options,function(e,t){var n,i,r=!1;"object"!=typeof e?(null!==o.value&&(o.multiple&&("string"==typeof o.value&&o.value==t||Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t])?r="selected":o.multiple||o.value!=t||(r="selected")),s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:r}}))):(n=t,i=[],_.each(e,function(e,t){var n=!1;null!==o.value&&(o.multiple&&("string"==typeof o.value&&o.value==t||Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t])?n="selected":o.multiple||o.value!=t||(n="selected")),i.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:n}}))}),s.push({label:n,options:i}))}),o.options=s),o.multiple&&(o.meta.multiple=!0,o.as_array&&(o.name+="[]"),o.value&&o.value.length||(o.value=[]),"string"==typeof o.value&&(o.value=[o.value])),"select"!==e.type&&(o.select2=!0,o.classes.push("pum-field-objectselect"),o.classes.push("postselect"===e.type?"pum-field-postselect":"pum-field-taxonomyselect"),o.meta["data-objecttype"]="postselect"===e.type?"post_type":"taxonomy",o.meta["data-objectkey"]="postselect"===e.type?e.post_type:e.taxonomy,o.meta["data-current"]="object"==typeof o.value||Array.isArray(o.value)?JSON.stringify(o.value):o.value),o.select2&&(o.classes.push("pum-field-select2"),o.placeholder&&(o.meta["data-placeholder"]=o.placeholder));break;case"radio":void 0!==o.options&&(_.each(o.options,function(e,t){s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{checked:o.value===t}}))}),o.options=s);break;case"multicheck":void 0!==o.options&&(!1!==o.value&&null!==o.value||(o.value=[]),"string"==typeof o.value&&o.value.indexOf(",")&&(o.value=o.value.split(",")),o.as_array&&(o.name+="[]"),_.each(o.options,function(e,t){s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{checked:Array.isArray(o.value)&&-1!==o.value.indexOf(t)||!Array.isArray(o.value)&&"object"==typeof o.value&&Object.keys(o.value).length&&void 0!==o.value[t]}}))}),o.options=s);break;case"checkbox":switch(typeof o.value){case"object":Array.isArray(o.value)&&1===o.value.length&&"1"===o.value[0].toString()&&(o.value=!0,o.meta.checked=!0);break;case"boolean":o.value&&(o.meta.checked=!0);break;case"string":"true"!==o.value&&"yes"!==o.value&&"1"!==o.value||(o.meta.checked=!0);break;case"number":(1===parseInt(o.value,10)||0<parseInt(o.value,10))&&(o.meta.checked=!0)}break;case"rangeslider":o.meta.step=o.step,o.meta.min=o.min,o.meta.max=o.max,o.meta["data-force-minmax"]=o.force_minmax.toString();break;case"textarea":o.meta.cols=o.cols,o.meta.rows=o.rows;break;case"measure":"string"==typeof o.value&&""!==o.value?(o.number=parseInt(o.value),o.unitValue=o.value.replace(o.number,""),o.value=o.number):o.unitValue=null,void 0!==o.units&&(_.each(o.units,function(e,t){var n=!1;o.unitValue==t&&(n="selected"),s.push(PUM_Admin.templates.prepareMeta({label:e,value:t,meta:{selected:n}}))}),o.units=s);break;case"color":"string"==typeof o.value&&""!==o.value&&(o.meta["data-default-color"]=o.value);break;case"license_key":o.value=i.extend({key:"",license:{},messages:[],status:"empty",expires:!1,classes:!1},o.value),o.classes.push("pum-license-"+o.value.status+"-notice"),o.value.classes&&o.classes.push(o.value.classes)}return o},field:function(e){var t,n=PUM_Admin.templates.fieldArgs(e);return t="pum-field-"+n.type,"objectselfect"!==n.type&&"postselect"!==n.type&&"taxonomyselect"!==n.type||(t="pum-field-select"),i("#tmpl-"+t).length?(n.field=PUM_Admin.templates.render(t,n),PUM_Admin.templates.render("pum-field-wrapper",n)):(console.warn("No field template found for type:"+n.type+" fieldID: "+n.id),"")},prepareMeta:function(e){var t,n=[];for(t in e.meta)e.meta.hasOwnProperty(t)&&("boolean"==typeof e.meta[t]?e.meta[t]&&n.push(_.escape(t)):n.push(_.escape(t)+'="'+_.escape(e.meta[t])+'"'));return e.meta=n.join(" "),e}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.templates=e}(window.jQuery),function(i){"use strict";String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};var r="color,date,datetime,datetime-local,email,hidden,month,number,password,range,search,tel,text,time,url,week".split(","),s="select,textarea".split(","),o=/\[([^\]]*)\]/g;function a(e,t){return-1!==i.inArray(t,e)}var e={EncodeType:"entity",isEmpty:function(e){return!e||(null===e||0==e.length||/^\s+$/.test(e))},arr1:["&nbsp;","&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&copy;","&ordf;","&laquo;","&not;","&shy;","&reg;","&macr;","&deg;","&plusmn;","&sup2;","&sup3;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;","&quot;","&amp;","&lt;","&gt;","&OElig;","&oelig;","&Scaron;","&scaron;","&Yuml;","&circ;","&tilde;","&ensp;","&emsp;","&thinsp;","&zwnj;","&zwj;","&lrm;","&rlm;","&ndash;","&mdash;","&lsquo;","&rsquo;","&sbquo;","&ldquo;","&rdquo;","&bdquo;","&dagger;","&Dagger;","&permil;","&lsaquo;","&rsaquo;","&euro;","&fnof;","&Alpha;","&Beta;","&Gamma;","&Delta;","&Epsilon;","&Zeta;","&Eta;","&Theta;","&Iota;","&Kappa;","&Lambda;","&Mu;","&Nu;","&Xi;","&Omicron;","&Pi;","&Rho;","&Sigma;","&Tau;","&Upsilon;","&Phi;","&Chi;","&Psi;","&Omega;","&alpha;","&beta;","&gamma;","&delta;","&epsilon;","&zeta;","&eta;","&theta;","&iota;","&kappa;","&lambda;","&mu;","&nu;","&xi;","&omicron;","&pi;","&rho;","&sigmaf;","&sigma;","&tau;","&upsilon;","&phi;","&chi;","&psi;","&omega;","&thetasym;","&upsih;","&piv;","&bull;","&hellip;","&prime;","&Prime;","&oline;","&frasl;","&weierp;","&image;","&real;","&trade;","&alefsym;","&larr;","&uarr;","&rarr;","&darr;","&harr;","&crarr;","&lArr;","&uArr;","&rArr;","&dArr;","&hArr;","&forall;","&part;","&exist;","&empty;","&nabla;","&isin;","&notin;","&ni;","&prod;","&sum;","&minus;","&lowast;","&radic;","&prop;","&infin;","&ang;","&and;","&or;","&cap;","&cup;","&int;","&there4;","&sim;","&cong;","&asymp;","&ne;","&equiv;","&le;","&ge;","&sub;","&sup;","&nsub;","&sube;","&supe;","&oplus;","&otimes;","&perp;","&sdot;","&lceil;","&rceil;","&lfloor;","&rfloor;","&lang;","&rang;","&loz;","&spades;","&clubs;","&hearts;","&diams;"],arr2:["&#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;","&#194;","&#195;","&#196;","&#197;","&#198;","&#199;","&#200;","&#201;","&#202;","&#203;","&#204;","&#205;","&#206;","&#207;","&#208;","&#209;","&#210;","&#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;","&#253;","&#254;","&#255;","&#34;","&#38;","&#60;","&#62;","&#338;","&#339;","&#352;","&#353;","&#376;","&#710;","&#732;","&#8194;","&#8195;","&#8201;","&#8204;","&#8205;","&#8206;","&#8207;","&#8211;","&#8212;","&#8216;","&#8217;","&#8218;","&#8220;","&#8221;","&#8222;","&#8224;","&#8225;","&#8240;","&#8249;","&#8250;","&#8364;","&#402;","&#913;","&#914;","&#915;","&#916;","&#917;","&#918;","&#919;","&#920;","&#921;","&#922;","&#923;","&#924;","&#925;","&#926;","&#927;","&#928;","&#929;","&#931;","&#932;","&#933;","&#934;","&#935;","&#936;","&#937;","&#945;","&#946;","&#947;","&#948;","&#949;","&#950;","&#951;","&#952;","&#953;","&#954;","&#955;","&#956;","&#957;","&#958;","&#959;","&#960;","&#961;","&#962;","&#963;","&#964;","&#965;","&#966;","&#967;","&#968;","&#969;","&#977;","&#978;","&#982;","&#8226;","&#8230;","&#8242;","&#8243;","&#8254;","&#8260;","&#8472;","&#8465;","&#8476;","&#8482;","&#8501;","&#8592;","&#8593;","&#8594;","&#8595;","&#8596;","&#8629;","&#8656;","&#8657;","&#8658;","&#8659;","&#8660;","&#8704;","&#8706;","&#8707;","&#8709;","&#8711;","&#8712;","&#8713;","&#8715;","&#8719;","&#8721;","&#8722;","&#8727;","&#8730;","&#8733;","&#8734;","&#8736;","&#8743;","&#8744;","&#8745;","&#8746;","&#8747;","&#8756;","&#8764;","&#8773;","&#8776;","&#8800;","&#8801;","&#8804;","&#8805;","&#8834;","&#8835;","&#8836;","&#8838;","&#8839;","&#8853;","&#8855;","&#8869;","&#8901;","&#8968;","&#8969;","&#8970;","&#8971;","&#9001;","&#9002;","&#9674;","&#9824;","&#9827;","&#9829;","&#9830;"],HTML2Numerical:function(e){return this.swapArrayVals(e,this.arr1,this.arr2)},NumericalToHTML:function(e){return this.swapArrayVals(e,this.arr2,this.arr1)},numEncode:function(e){if(this.isEmpty(e))return"";for(var t=[],n=e.length,i=0;i<n;i++){var r=e.charAt(i);r<" "||"~"<r?(t.push("&#"),t.push(r.charCodeAt()),t.push(";")):t.push(r)}return t.join("")},htmlDecode:function(e){var t,n,i=e;if(this.isEmpty(i))return"";var r=(i=this.HTML2Numerical(i)).match(/&#[0-9]{1,5};/g);if(null!=r)for(var s=0;s<r.length;s++)i=-32768<=(t=(n=r[s]).substring(2,n.length-1))&&t<=65535?i.replace(n,String.fromCharCode(t)):i.replace(n,"");return i},htmlEncode:function(e,t){return this.isEmpty(e)?"":((t=t||!1)&&(e="numerical"==this.EncodeType?e.replace(/&/g,"&#38;"):e.replace(/&/g,"&amp;")),e=this.XSSEncode(e,!1),"numerical"!=this.EncodeType&&t||(e=this.HTML2Numerical(e)),e=this.numEncode(e),t||(e=e.replace(/&#/g,"##AMPHASH##"),e=(e="numerical"==this.EncodeType?e.replace(/&/g,"&#38;"):e.replace(/&/g,"&amp;")).replace(/##AMPHASH##/g,"&#")),e=e.replace(/&#\d*([^\d;]|$)/g,"$1"),t||(e=this.correctEncoding(e)),"entity"==this.EncodeType&&(e=this.NumericalToHTML(e)),e)},XSSEncode:function(e,t){return this.isEmpty(e)?"":e=(t=t||!0)?(e=(e=(e=e.replace(/\'/g,"&#39;")).replace(/\"/g,"&quot;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;"):(e=(e=(e=e.replace(/\'/g,"&#39;")).replace(/\"/g,"&#34;")).replace(/</g,"&#60;")).replace(/>/g,"&#62;")},hasEncoded:function(e){return!!/&#[0-9]{1,5};/g.test(e)||!!/&[A-Z]{2,6};/gi.test(e)},stripUnicode:function(e){return e.replace(/[^\x20-\x7E]/g,"")},correctEncoding:function(e){return e.replace(/(&amp;)(amp;)+/,"$1")},swapArrayVals:function(e,t,n){if(this.isEmpty(e))return"";var i;if(t&&n&&t.length==n.length)for(var r=0,s=t.length;r<s;r++)i=new RegExp(t[r],"g"),e=e.replace(i,n[r]);return e},inArray:function(e,t){for(var n=0,i=t.length;n<i;n++)if(t[n]===e)return n;return-1}};e.EncodeType="entity";var t={htmlencoder:e,convert_meta_to_object:function(e){var t,n,i,r={};for(i in e)e.hasOwnProperty(i)&&(t=i.split(/_(.+)?/)[0],n=i.split(/_(.+)?/)[1],void 0===r[t]&&(r[t]={}),r[t][n]=e[i]);return r},object_to_array:function(e){var t,n=[];if("object"==typeof e){for(t in e)n.push(e[t]);e=n}return e},checked:function(e,t,n){var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t?i=!0:e==t&&(i=!0),void 0!==n&&n?i?' checked="checked"':"":i},selected:function(e,t,n){var i=!1;return"object"==typeof e&&"string"==typeof t&&-1!==jQuery.inArray(t,e)?i=!0:"object"==typeof t&&"string"==typeof e&&-1!==jQuery.inArray(e,t)?i=!0:e===t&&(i=!0),void 0!==n&&n?i?' selected="selected"':"":i},convert_hex:function(e,t){return void 0===e?"":(void 0===t&&(t=100),e=e.replace("#",""),"rgba("+parseInt(e.substring(0,2),16)+","+parseInt(e.substring(2,4),16)+","+parseInt(e.substring(4,6),16)+","+t/100+")")},debounce:function(n,i){var r;return function(){var e=this,t=arguments;window.clearTimeout(r),r=window.setTimeout(function(){n.apply(e,t)},i)}},throttle:function(e,t){var n=!1,i=function(){n=!1};return function(){n||(e(),window.setTimeout(i,t),n=!0)}},serializeForm:function(e){i.extend({},e);var t={},n=i.extend(!0,{include:[],exclude:[],includeByClass:""},e);return this.find(":input").each(function(){var e;!this.name||this.disabled||a(n.exclude,this.name)||n.include.length&&!a(n.include,this.name)||-1===this.className.indexOf(n.includeByClass)||(e=this.name.replace(o,"[$1").split("["))[0]&&(this.checked||a(r,this.type)||a(s,this.nodeName.toLowerCase()))&&("checkbox"===this.type&&e.push(""),function e(t,n,i){var r=n[0];1<n.length?(t[r]||(t[r]=n[1]?{}:[]),e(t[r],n.slice(1),i)):(r||(r=t.length),t[r]=i)}(t,e,i(this).val()))}),t}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.utils=t,window.PUMUtils=t,i.fn.pumSerializeForm=t.serializeForm}(jQuery);
assets/js/admin-marketing.js CHANGED
@@ -1,13 +1,13 @@
1
- /*******************************************************************************
2
- * Copyright (c) 2017, WP Popup Maker
3
- ******************************************************************************/
4
- (function ($) {
5
- "use strict";
6
-
7
- window.PUM_Admin = window.PUM_Admin || {};
8
-
9
- $(document).ready(function () {
10
- $('a[href="edit.php?post_type=popup&page=pum-extensions"]').css({color: "#a0d468"});
11
- });
12
-
13
  }(jQuery));
1
+ /*******************************************************************************
2
+ * Copyright (c) 2017, WP Popup Maker
3
+ ******************************************************************************/
4
+ (function ($) {
5
+ "use strict";
6
+
7
+ window.PUM_Admin = window.PUM_Admin || {};
8
+
9
+ $(document).ready(function () {
10
+ $('a[href="edit.php?post_type=popup&page=pum-extensions"]').css({color: "#a0d468"});
11
+ });
12
+
13
  }(jQuery));
assets/js/admin-popup-editor.js CHANGED
@@ -1,1247 +1,1247 @@
1
- (function ($, document, undefined) {
2
- "use strict";
3
-
4
- $(document)
5
- .on('click', '#popup_reset_open_count', function () {
6
- var $this = $(this);
7
- if ($this.is(':checked') && !confirm(pum_admin_vars.I10n.confirm_count_reset)) {
8
- $this.prop('checked', false);
9
- }
10
- });
11
  }(jQuery, document));
12
- (function ($) {
13
- "use strict";
14
-
15
- var conditions = {
16
- get_conditions: function () {
17
- return window.pum_popup_settings_editor.conditions_selectlist;
18
- },
19
- not_operand_checkbox: function ($element) {
20
-
21
- $element = $element || $('.pum-not-operand');
22
-
23
- return $element.each(function () {
24
- var $this = $(this),
25
- $input = $this.find('input');
26
-
27
- $input.prop('checked', !$input.is(':checked'));
28
-
29
- conditions.toggle_not_operand($this);
30
- });
31
-
32
- },
33
- toggle_not_operand: function ($element) {
34
- $element = $element || $('.pum-not-operand');
35
-
36
- return $element.each(function () {
37
- var $this = $(this),
38
- $input = $this.find('input'),
39
- // $is = $this.find('.is'),
40
- // $not = $this.find('.not'),
41
- $container = $this.parents('.facet-target');
42
-
43
- if ($input.is(':checked')) {
44
- // $is.hide();
45
- // $not.show();
46
- $container.addClass('not-operand-checked');
47
- } else {
48
- // $is.show();
49
- // $not.hide();
50
- $container.removeClass('not-operand-checked');
51
- }
52
- });
53
- },
54
- template: {
55
- editor: function (args) {
56
- var data = $.extend(true, {}, {
57
- groups: []
58
- }, args);
59
-
60
- data.groups = PUM_Admin.utils.object_to_array(data.groups);
61
-
62
- return PUM_Admin.templates.render('pum-condition-editor', data);
63
- },
64
- group: function (args) {
65
- var data = $.extend(true, {}, {
66
- index: '',
67
- facets: []
68
- }, args),
69
- i;
70
-
71
- data.facets = PUM_Admin.utils.object_to_array(data.facets);
72
-
73
- for (i = 0; data.facets.length > i; i++) {
74
- data.facets[i].index = i;
75
- data.facets[i].group = data.index;
76
- }
77
-
78
- return PUM_Admin.templates.render('pum-condition-group', data);
79
- },
80
- facet: function (args) {
81
- var data = $.extend(true, {}, {
82
- group: '',
83
- index: '',
84
- target: '',
85
- not_operand: false,
86
- settings: {}
87
- }, args);
88
-
89
- return PUM_Admin.templates.render('pum-condition-facet', data);
90
- },
91
- settings: function (args, values) {
92
- var fields = [],
93
- data = $.extend(true, {}, {
94
- index: '',
95
- group: '',
96
- target: null,
97
- fields: []
98
- }, args);
99
-
100
- if (!data.fields.length && pum_popup_settings_editor.conditions[args.target] !== undefined) {
101
- data.fields = pum_popup_settings_editor.conditions[args.target].fields;
102
- }
103
-
104
- if (undefined === values) {
105
- values = {};
106
- }
107
-
108
- // Replace the array with rendered fields.
109
- _.each(data.fields, function (field, fieldID) {
110
-
111
- field = PUM_Admin.models.field(field);
112
-
113
- if (typeof field.meta !== 'object') {
114
- field.meta = {};
115
- }
116
-
117
- if (undefined !== values[fieldID]) {
118
- field.value = values[fieldID];
119
- }
120
-
121
- field.name = 'popup_settings[conditions][' + data.group + '][' + data.index + '][settings][' + fieldID + ']';
122
-
123
- if (field.id === '') {
124
- field.id = 'popup_settings_conditions_' + data.group + '_' + data.index + '_settings_' + fieldID;
125
- }
126
-
127
- fields.push(PUM_Admin.templates.field(field));
128
- });
129
-
130
- // Render the section.
131
- return PUM_Admin.templates.section({
132
- fields: fields
133
- });
134
- },
135
- selectbox: function (args) {
136
- var data = $.extend(true, {}, {
137
- id: null,
138
- name: null,
139
- type: 'select',
140
- group: '',
141
- index: '',
142
- value: null,
143
- select2: true,
144
- classes: [],
145
- options: conditions.get_conditions()
146
- }, args);
147
-
148
- if (data.id === null) {
149
- data.id = 'popup_settings_conditions_' + data.group + '_' + data.index + '_target';
150
- }
151
-
152
- if (data.name === null) {
153
- data.name = 'popup_settings[conditions][' + data.group + '][' + data.index + '][target]';
154
- }
155
-
156
- return PUM_Admin.templates.field(data);
157
- }
158
- },
159
- groups: {
160
- add: function (editor, target, not_operand) {
161
- var $editor = $(editor),
162
- data = {
163
- index: $editor.find('.facet-group-wrap').length,
164
- facets: [
165
- {
166
- target: target || null,
167
- not_operand: not_operand || false,
168
- settings: {}
169
- }
170
- ]
171
- };
172
-
173
-
174
- $editor.find('.facet-groups').append(conditions.template.group(data));
175
- $editor.addClass('has-conditions');
176
- },
177
- remove: function ($group) {
178
- var $editor = $group.parents('.facet-builder');
179
-
180
- $group.prev('.facet-group-wrap').find('.and .add-facet').removeClass('disabled');
181
- $group.remove();
182
-
183
- conditions.renumber();
184
-
185
- if ($editor.find('.facet-group-wrap').length === 0) {
186
- $editor.removeClass('has-conditions');
187
-
188
- $('#pum-first-condition')
189
- .val(null)
190
- .trigger('change');
191
- }
192
- }
193
- },
194
- facets: {
195
- add: function ($group, target, not_operand) {
196
- var data = {
197
- group: $group.data('index'),
198
- index: $group.find('.facet').length,
199
- target: target || null,
200
- not_operand: not_operand || false,
201
- settings: {}
202
- };
203
-
204
- $group.find('.facet-list').append(conditions.template.facet(data));
205
- },
206
- remove: function ($facet) {
207
- var $group = $facet.parents('.facet-group-wrap');
208
-
209
- $facet.remove();
210
-
211
- if ($group.find('.facet').length === 0) {
212
- conditions.groups.remove($group);
213
- } else {
214
- conditions.renumber();
215
- }
216
- }
217
- },
218
- renumber: function () {
219
- $('.facet-builder .facet-group-wrap').each(function () {
220
- var $group = $(this),
221
- groupIndex = $group.parent().children().index($group);
222
-
223
- $group
224
- .data('index', groupIndex)
225
- .find('.facet').each(function () {
226
- var $facet = $(this),
227
- facetIndex = $facet.parent().children().index($facet);
228
-
229
- $facet
230
- .data('index', facetIndex)
231
- .find('[name]').each(function () {
232
- this.name = this.name.replace(/popup_settings\[conditions\]\[\d*?\]\[\d*?\]/, "popup_settings[conditions][" + groupIndex + "][" + facetIndex + "]");
233
- this.id = this.id.replace(/popup_settings_conditions_\d*?_\d*?_/, "popup_settings_conditions_" + groupIndex + "_" + facetIndex + "_");
234
- });
235
- });
236
- });
237
- }
238
- };
239
-
240
- // Import this module.
241
- window.PUM_Admin = window.PUM_Admin || {};
242
- window.PUM_Admin.conditions = conditions;
243
-
244
- $(document)
245
- .on('pum_init', function () {
246
- conditions.renumber();
247
- conditions.toggle_not_operand();
248
- })
249
- .on('select2:select pumselect2:select', '#pum-first-condition', function (event) {
250
- var $field = $(this),
251
- $editor = $field.parents('.facet-builder').eq(0),
252
- target = $field.val(),
253
- $operand = $editor.find('#pum-first-facet-operand'),
254
- not_operand = $operand.is(':checked');
255
-
256
- conditions.groups.add($editor, target, not_operand);
257
-
258
- $field
259
- .val(null)
260
- .trigger('change');
261
-
262
- $operand.prop('checked', false).parents('.facet-target').removeClass('not-operand-checked');
263
- $(document).trigger('pum_init');
264
- })
265
- .on('click', '.facet-builder .pum-not-operand', function () {
266
- conditions.not_operand_checkbox($(this));
267
- })
268
- .on('change', '.facet-builder .facet-target select', function (event) {
269
- var $this = $(this),
270
- $facet = $this.parents('.facet'),
271
- target = $this.val(),
272
- data = {
273
- target: target
274
- };
275
-
276
- if (target === '' || target === $facet.data('target')) {
277
- return;
278
- }
279
-
280
- $facet.data('target', target).find('.facet-settings').html(conditions.template.settings(data));
281
- $(document).trigger('pum_init');
282
- })
283
- .on('click', '.facet-builder .facet-group-wrap:last-child .and .add-facet', function () {
284
- conditions.groups.add($(this).parents('.facet-builder').eq(0));
285
- $(document).trigger('pum_init');
286
- })
287
- .on('click', '.facet-builder .add-or .add-facet:not(.disabled)', function () {
288
- conditions.facets.add($(this).parents('.facet-group-wrap').eq(0));
289
- $(document).trigger('pum_init');
290
- })
291
- .on('click', '.facet-builder .remove-facet', function () {
292
- conditions.facets.remove($(this).parents('.facet').eq(0));
293
- $(document).trigger('pum_init');
294
- });
295
-
296
  }(jQuery));
297
- var cookies;
298
- (function ($, document, undefined) {
299
- "use strict";
300
-
301
- var I10n = pum_admin_vars.I10n,
302
- current_editor,
303
- cookies = {
304
- get_cookies: function () {
305
- return window.pum_popup_settings_editor.cookies;
306
- },
307
- get_cookie: function (event) {
308
- var cookies = this.get_cookies(),
309
- cookie = cookies[event] !== 'undefined' ? cookies[event] : false;
310
-
311
- if (!cookie) {
312
- return false;
313
- }
314
-
315
- if (cookie && typeof cookie === 'object' && typeof cookie.fields === 'object' && Object.keys(cookie.fields).length) {
316
- cookie = this.parseFields(cookie);
317
- }
318
-
319
- return cookie;
320
- },
321
- parseFields: function (cookie) {
322
- _.each(cookie.fields, function (fields, tabID) {
323
- _.each(fields, function (field, fieldID) {
324
- cookie.fields[tabID][fieldID].name = 'cookie_settings[' + fieldID + ']';
325
-
326
- if (cookie.fields[tabID][fieldID].id === '') {
327
- cookie.fields[tabID][fieldID].id = 'cookie_settings_' + fieldID;
328
- }
329
- });
330
- });
331
-
332
- return cookie;
333
- },
334
- parseValues: function (values, type) {
335
- return values;
336
- },
337
- select_list: function () {
338
- var i,
339
- _cookies = PUM_Admin.utils.object_to_array(cookies.get_cookies()),
340
- options = {};
341
-
342
- for (i = 0; i < _cookies.length; i++) {
343
- options[_cookies[i].id] = _cookies[i].name;
344
- }
345
-
346
- return options;
347
- },
348
- /**
349
- * @deprecated
350
- *
351
- * @param event
352
- */
353
- getLabel: function (event) {
354
- var cookie = cookies.get_cookie(event);
355
-
356
- if (!cookie) {
357
- return false;
358
- }
359
-
360
- return cookie.name;
361
- },
362
- /**
363
- * @param event
364
- * @param values
365
- */
366
- getSettingsDesc: function (event, values) {
367
- var cookie = cookies.get_cookie(event);
368
-
369
- if (!cookie) {
370
- return false;
371
- }
372
-
373
- return PUM_Admin.templates.renderInline(cookie.settings_column, values);
374
- },
375
- /**
376
- * Refresh all cookie row descriptions.
377
- */
378
- refreshDescriptions: function () {
379
- $('.pum-popup-cookie-editor table.list-table tbody tr').each(function () {
380
- var $row = $(this),
381
- event = $row.find('.popup_cookies_field_event').val(),
382
- values = JSON.parse($row.find('.popup_cookies_field_settings:first').val());
383
-
384
- $row.find('td.settings-column').html(cookies.getSettingsDesc(event, values));
385
- });
386
- },
387
- /**
388
- * Insert a new cookie when needed.
389
- *
390
- * @param $editor
391
- * @param args
392
- */
393
- insertCookie: function ($editor, args) {
394
- args = $.extend(true, {}, {
395
- event: 'on_popup_close',
396
- settings: {
397
- name: name || 'pum-' + $('#post_ID').val()
398
- }
399
- }, args);
400
-
401
- cookies.rows.add($editor, args);
402
- },
403
- template: {
404
- form: function (event, values, callback) {
405
- var cookie = cookies.get_cookie(event),
406
- modalID = 'pum_cookie_settings',
407
- firstTab = Object.keys(cookie.fields)[0];
408
-
409
- values = values || {};
410
- values.event = event;
411
- values.index = values.index >= 0 ? values.index : null;
412
-
413
- // Add hidden index & event fields.
414
- cookie.fields[firstTab] = $.extend(true, cookie.fields[firstTab], {
415
- index: {
416
- type: 'hidden',
417
- name: 'index'
418
- },
419
- event: {
420
- type: 'hidden',
421
- name: 'event'
422
- }
423
- });
424
-
425
- if (typeof values.key !== 'string' || values.key === '') {
426
- delete cookie.fields.advanced.key;
427
- }
428
-
429
- PUM_Admin.modals.reload('#' + modalID, PUM_Admin.templates.modal({
430
- id: modalID,
431
- title: cookie.modal_title || cookie.name,
432
- classes: 'tabbed-content',
433
- save_button: values.index !== null ? I10n.update : I10n.add,
434
- content: PUM_Admin.forms.render({
435
- id: 'pum_cookie_settings_form',
436
- tabs: cookie.tabs || {},
437
- fields: cookie.fields || {}
438
- }, values || {})
439
- }));
440
-
441
- $('#' + modalID + ' form').on('submit', callback || function (e) {
442
- e.preventDefault();
443
- PUM_Admin.modals.closeAll();
444
- });
445
- },
446
- editor: function (args) {
447
- var data = $.extend(true, {}, {
448
- cookies: [],
449
- name: ''
450
- }, args);
451
-
452
- data.cookies = PUM_Admin.utils.object_to_array(data.cookies);
453
-
454
- return PUM_Admin.templates.render('pum-cookie-editor', data);
455
- },
456
- row: function (args) {
457
- var data = $.extend(true, {}, {
458
- index: '',
459
- event: '',
460
- name: '',
461
- settings: {
462
- name: "",
463
- key: "",
464
- session: false,
465
- time: '30 days',
466
- path: true
467
- }
468
- }, args);
469
-
470
- return PUM_Admin.templates.render('pum-cookie-row', data);
471
- },
472
- selectbox: function (args) {
473
- var data = $.extend(true, {}, {
474
- id: null,
475
- name: null,
476
- type: 'select',
477
- group: '',
478
- index: '',
479
- value: null,
480
- select2: true,
481
- classes: [],
482
- options: cookies.select_list()
483
- }, args);
484
-
485
- if (data.id === null) {
486
- data.id = 'popup_settings_cookies_' + data.index + '_event';
487
- }
488
-
489
- if (data.name === null) {
490
- data.name = 'popup_settings[cookies][' + data.index + '][event]';
491
- }
492
-
493
- return PUM_Admin.templates.field(data);
494
- }
495
- },
496
- rows: {
497
- add: function (editor, cookie) {
498
- var $editor = $(editor),
499
- data = {
500
- index: cookie.index !== null && cookie.index >= 0 ? cookie.index : $editor.find('table.list-table tbody tr').length,
501
- event: cookie.event,
502
- name: $editor.data('field_name'),
503
- settings: cookie.settings || {}
504
- },
505
- $row = $editor.find('tbody tr').eq(data.index),
506
- $new_row = PUM_Admin.templates.render('pum-cookie-row', data);
507
-
508
- if ($row.length) {
509
- $row.replaceWith($new_row);
510
- } else {
511
- $editor.find('tbody').append($new_row);
512
- }
513
-
514
- $editor.addClass('has-list-items');
515
-
516
- cookies.rows.renumber();
517
- cookies.refreshDescriptions();
518
- },
519
- /**
520
- * Remove a cookie editor table row.
521
- *
522
- * @param $cookie
523
- */
524
- remove: function ($cookie) {
525
- var $editor = $cookie.parents('.pum-popup-cookie-editor');
526
-
527
- $cookie.remove();
528
- cookies.rows.renumber();
529
-
530
- if ($editor.find('table.list-table tbody tr').length === 0) {
531
- $editor.removeClass('has-list-items');
532
-
533
- $('#pum-first-cookie')
534
- .val(null)
535
- .trigger('change');
536
- }
537
- },
538
- /**
539
- * Renumber all rows for all editors.
540
- */
541
- renumber: function () {
542
- $('.pum-popup-cookie-editor table.list-table tbody tr').each(function () {
543
- var $this = $(this),
544
- index = $this.parent().children().index($this);
545
-
546
- $this.attr('data-index', index).data('index', index);
547
-
548
- $this.find(':input, [name]').each(function () {
549
- if (this.name && this.name !== '') {
550
- this.name = this.name.replace(/\[\d*?\]/, "[" + index + "]");
551
- }
552
- });
553
- });
554
- }
555
- }
556
- };
557
-
558
- // Import this module.
559
- window.PUM_Admin = window.PUM_Admin || {};
560
- window.PUM_Admin.cookies = cookies;
561
-
562
- $(document)
563
- .on('pum_init', function () {
564
- cookies.refreshDescriptions();
565
- })
566
- .on('select2:select pumselect2:select', '#pum-first-cookie', function () {
567
- var $this = $(this),
568
- $editor = $this.parents('.pum-popup-cookie-editor'),
569
- event = $this.val(),
570
- values = {
571
- indes: $editor.find('table.list-table tbody tr').length,
572
- name: 'pum-' + $('#post_ID').val()
573
- };
574
-
575
- $this
576
- .val(null)
577
- .trigger('change');
578
-
579
- cookies.template.form(event, values, function (e) {
580
- var $form = $(this),
581
- event = $form.find('input#event').val(),
582
- index = $form.find('input#index').val(),
583
- values = $form.pumSerializeObject();
584
-
585
- e.preventDefault();
586
-
587
- if (!index || index < 0) {
588
- index = $editor.find('tbody tr').length;
589
- }
590
-
591
- cookies.rows.add($editor, {
592
- index: index,
593
- event: event,
594
- settings: values.cookie_settings
595
- });
596
-
597
- PUM_Admin.modals.closeAll();
598
- });
599
- })
600
- .on('click', '.pum-popup-cookie-editor .pum-add-new', function () {
601
- current_editor = $(this).parents('.pum-popup-cookie-editor');
602
- var template = wp.template('pum-cookie-add-event');
603
- PUM_Admin.modals.reload('#pum_cookie_add_event_modal', template({I10n: I10n}));
604
- })
605
- .on('click', '.pum-popup-cookie-editor .edit', function (e) {
606
- var $this = $(this),
607
- $editor = $this.parents('.pum-popup-cookie-editor'),
608
- $row = $this.parents('tr:first'),
609
- event = $row.find('.popup_cookies_field_event').val(),
610
- values = _.extend({}, JSON.parse($row.find('.popup_cookies_field_settings:first').val()), {
611
- index: $row.parent().children().index($row),
612
- event: event
613
- });
614
-
615
- e.preventDefault();
616
-
617
- cookies.template.form(event, values, function (e) {
618
- var $form = $(this),
619
- event = $form.find('input#event').val(),
620
- index = $form.find('input#index').val(),
621
- values = $form.pumSerializeObject();
622
-
623
- e.preventDefault();
624
-
625
- if (index === false || index < 0) {
626
- index = $editor.find('tbody tr').length;
627
- }
628
-
629
- cookies.rows.add($editor, {
630
- index: index,
631
- event: event,
632
- settings: values.cookie_settings
633
- });
634
-
635
- PUM_Admin.modals.closeAll();
636
- });
637
- })
638
- .on('click', '.pum-popup-cookie-editor .remove', function (e) {
639
- var $this = $(this),
640
- $row = $this.parents('tr:first');
641
-
642
- e.preventDefault();
643
-
644
- if (window.confirm(I10n.confirm_delete_cookie)) {
645
- cookies.rows.remove($row);
646
- }
647
- })
648
- .on('click', '.pum-field-cookie_key button.reset', function (e) {
649
- var $this = $(this),
650
- newKey = (new Date().getTime()).toString(16);
651
-
652
- $this.siblings('input[type="text"]:first').val(newKey);
653
- })
654
- .on('submit', '#pum_cookie_add_event_modal .pum-form', function (e) {
655
- var $editor = current_editor,
656
- event = $('#popup_cookie_add_event').val(),
657
- values = {
658
- index: $editor.find('table.list-table tbody tr').length,
659
- name: 'pum-' + $('#post_ID').val(),
660
- path: '1'
661
- };
662
-
663
- e.preventDefault();
664
-
665
- cookies.template.form(event, values, function (e) {
666
- var $form = $(this),
667
- event = $form.find('input#event').val(),
668
- index = $form.find('input#index').val(),
669
- values = $form.pumSerializeObject();
670
-
671
- e.preventDefault();
672
-
673
- if (index === false || index < 0) {
674
- index = $editor.find('tbody tr').length;
675
- }
676
-
677
- cookies.rows.add($editor, {
678
- index: index,
679
- event: event,
680
- settings: values.cookie_settings
681
- });
682
-
683
- PUM_Admin.modals.closeAll();
684
-
685
- if (typeof PUM_Admin.triggers !== 'undefined' && PUM_Admin.triggers.new_cookie !== false && PUM_Admin.triggers.new_cookie >= 0) {
686
- var $trigger = PUM_Admin.triggers.current_editor.find('tbody tr').eq(PUM_Admin.triggers.new_cookie).find('.popup_triggers_field_settings:first'),
687
- trigger_settings = JSON.parse($trigger.val());
688
-
689
- if (typeof trigger_settings.cookie_name === 'string') {
690
- trigger_settings.cookie_name = trigger_settings.cookie_name.replace('add_new', values.cookie_settings.name);
691
- } else {
692
- trigger_settings.cookie_name[trigger_settings.cookie_name.indexOf('add_new')] = values.cookie_settings.name;
693
- trigger_settings.cookie_name = trigger_settings.cookie_name.filter(function(element, index, array) {
694
- return element in this ? false : this[element] = true;
695
- }, {});
696
- }
697
-
698
- $trigger.val(JSON.stringify(trigger_settings));
699
-
700
- PUM_Admin.triggers.new_cookie = false;
701
- PUM_Admin.triggers.refreshDescriptions();
702
- }
703
- });
704
- });
705
-
706
  }(jQuery, document));
707
- (function ($, document, undefined) {
708
- "use strict";
709
-
710
- var I10n = pum_admin_vars.I10n;
711
-
712
- var triggers = {
713
- current_editor: null,
714
- new_cookie: false,
715
- get_triggers: function () {
716
- return window.pum_popup_settings_editor.triggers;
717
- },
718
- get_trigger: function (type) {
719
- var triggers = this.get_triggers(),
720
- trigger = triggers[type] !== 'undefined' ? triggers[type] : false;
721
-
722
- if (!trigger) {
723
- return false;
724
- }
725
-
726
- if (trigger && typeof trigger === 'object' && typeof trigger.fields === 'object' && Object.keys(trigger.fields).length) {
727
- trigger = this.parseFields(trigger);
728
- }
729
-
730
- return trigger;
731
- },
732
- parseFields: function (trigger) {
733
- _.each(trigger.fields, function (fields, tabID) {
734
- _.each(fields, function (field, fieldID) {
735
-
736
- trigger.fields[tabID][fieldID].name = 'trigger_settings[' + fieldID + ']';
737
-
738
- if (trigger.fields[tabID][fieldID].id === '') {
739
- trigger.fields[tabID][fieldID].id = 'trigger_settings_' + fieldID;
740
- }
741
- });
742
- });
743
-
744
- return trigger;
745
- },
746
- parseValues: function (values, type) {
747
- for (var key in values) {
748
- if (!values.hasOwnProperty(key)) {
749
- continue;
750
- }
751
-
752
- // Clean measurement fields.
753
- if (values.hasOwnProperty(key + "_unit")) {
754
- values[key] += values[key + "_unit"];
755
- delete values[key + "_unit"];
756
- }
757
- }
758
-
759
- return values;
760
- },
761
- select_list: function () {
762
- var i,
763
- _triggers = PUM_Admin.utils.object_to_array(triggers.get_triggers()),
764
- options = {};
765
-
766
- for (i = 0; i < _triggers.length; i++) {
767
- options[_triggers[i].id] = _triggers[i].name;
768
- }
769
-
770
- return options;
771
- },
772
- rows: {
773
- add: function (editor, trigger) {
774
- var $editor = $(editor),
775
- data = {
776
- index: trigger.index !== null && trigger.index >= 0 ? trigger.index : $editor.find('table.list-table tbody tr').length,
777
- type: trigger.type,
778
- name: $editor.data('field_name'),
779
- settings: trigger.settings || {}
780
- },
781
- $row = $editor.find('tbody tr').eq(data.index),
782
- $new_row = PUM_Admin.templates.render('pum-trigger-row', data);
783
-
784
- if ($row.length) {
785
- $row.replaceWith($new_row);
786
- } else {
787
- $editor.find('tbody').append($new_row);
788
- }
789
-
790
- $editor.addClass('has-list-items');
791
-
792
- triggers.renumber();
793
- triggers.refreshDescriptions();
794
- },
795
- remove: function ($trigger) {
796
- var $editor = $trigger.parents('.pum-popup-trigger-editor');
797
-
798
- $trigger.remove();
799
- triggers.renumber();
800
-
801
- if ($editor.find('table.list-table tbody tr').length === 0) {
802
- $editor.removeClass('has-list-items');
803
-
804
- $('#pum-first-trigger')
805
- .val(null)
806
- .trigger('change');
807
- }
808
- }
809
- },
810
- template: {
811
- form: function (type, values, callback) {
812
- var trigger = triggers.get_trigger(type),
813
- modalID = 'pum_trigger_settings',
814
- firstTab = Object.keys(trigger.fields)[0],
815
- $cookies = $('.pum-field-cookies .list-table tbody tr');
816
-
817
- values = values || {};
818
- values.type = type;
819
- values.index = values.index >= 0 ? values.index : null;
820
-
821
- // Add hidden index & type fields.
822
- trigger.fields[firstTab] = $.extend(true, trigger.fields[firstTab], {
823
- index: {
824
- type: 'hidden',
825
- name: 'index'
826
- },
827
- type: {
828
- type: 'hidden',
829
- name: 'type'
830
- }
831
- });
832
-
833
- $cookies.each(function () {
834
- var settings = JSON.parse($(this).find('.popup_cookies_field_settings:first').val());
835
- if (typeof trigger.fields[firstTab].cookie_name.options[settings.name] === 'undefined') {
836
- trigger.fields[firstTab].cookie_name.options[settings.name] = settings.name;
837
- }
838
- });
839
-
840
- PUM_Admin.modals.reload('#' + modalID, PUM_Admin.templates.modal({
841
- id: modalID,
842
- title: trigger.modal_title || trigger.name,
843
- classes: 'tabbed-content',
844
- save_button: values.index !== null ? I10n.update : I10n.add,
845
- content: PUM_Admin.forms.render({
846
- id: 'pum_trigger_settings_form',
847
- tabs: trigger.tabs || {},
848
- fields: trigger.fields || {}
849
- }, values || {})
850
- }));
851
-
852
- $('#' + modalID + ' form').on('submit', callback || function (event) {
853
- event.preventDefault();
854
- PUM_Admin.modals.closeAll();
855
- });
856
- },
857
- editor: function (args) {
858
- var data = $.extend(true, {}, {
859
- triggers: [],
860
- name: ''
861
- }, args);
862
-
863
- data.triggers = PUM_Admin.utils.object_to_array(data.triggers);
864
-
865
- return PUM_Admin.templates.render('pum-trigger-editor', data);
866
- },
867
- row: function (args) {
868
- var data = $.extend(true, {}, {
869
- index: '',
870
- type: '',
871
- name: '',
872
- settings: {
873
- cookie_name: ""
874
- }
875
- }, args);
876
-
877
- return PUM_Admin.templates.render('pum-trigger-row', data);
878
- },
879
- selectbox: function (args) {
880
- var data = $.extend(true, {}, {
881
- id: null,
882
- name: null,
883
- type: 'select',
884
- group: '',
885
- index: '',
886
- value: null,
887
- select2: true,
888
- classes: [],
889
- options: triggers.select_list()
890
- }, args);
891
-
892
- if (data.id === null) {
893
- data.id = 'popup_settings_triggers_' + data.index + '_type';
894
- }
895
-
896
- if (data.name === null) {
897
- data.name = 'popup_settings[triggers][' + data.index + '][type]';
898
- }
899
-
900
- return PUM_Admin.templates.field(data);
901
- }
902
- },
903
- /* @deprecated */
904
- getLabel: function (type) {
905
- var trigger = triggers.get_trigger(type);
906
-
907
- if (!trigger) {
908
- return false;
909
- }
910
-
911
- return trigger.name;
912
- },
913
- getSettingsDesc: function (type, values) {
914
- var trigger = triggers.get_trigger(type);
915
-
916
- if (!trigger) {
917
- return false;
918
- }
919
-
920
- return PUM_Admin.templates.renderInline(trigger.settings_column, values);
921
- },
922
- renumber: function () {
923
- $('.pum-popup-trigger-editor table.list-table tbody tr').each(function () {
924
- var $this = $(this),
925
- index = $this.parent().children().index($this);
926
-
927
- $this.attr('data-index', index).data('index', index);
928
-
929
- $this.find(':input, [name]').each(function () {
930
- if (this.name && this.name !== '') {
931
- this.name = this.name.replace(/\[\d*?\]/, "[" + index + "]");
932
- }
933
- });
934
- });
935
- },
936
- refreshDescriptions: function () {
937
- $('.pum-popup-trigger-editor table.list-table tbody tr').each(function () {
938
- var $row = $(this),
939
- type = $row.find('.popup_triggers_field_type').val(),
940
- values = JSON.parse($row.find('.popup_triggers_field_settings:first').val()),
941
- cookie_text = PUM_Admin.triggers.cookie_column_value(values.cookie_name);
942
-
943
- $row.find('td.settings-column').html(PUM_Admin.triggers.getSettingsDesc(type, values));
944
- $row.find('td.cookie-column code').text(cookie_text);
945
- });
946
- },
947
- cookie_column_value: function (cookie_name) {
948
- var cookie_text = I10n.no_cookie;
949
-
950
- if (cookie_name instanceof Array) {
951
- cookie_text = cookie_name.join(', ');
952
- } else if (cookie_name !== null && cookie_name !== undefined && cookie_name !== '') {
953
- cookie_text = cookie_name;
954
- }
955
- return cookie_text;
956
- },
957
- append_click_selector_presets: function () {
958
- var $field = $('#extra_selectors'),
959
- template,
960
- $presets;
961
-
962
- if (!$field.length || $field.hasClass('pum-click-selector-presets-initialized')) {
963
- return;
964
- }
965
-
966
- template = PUM_Admin.templates.render('pum-click-selector-presets');
967
- $presets = $field.parents('.pum-field').find('.pum-click-selector-presets');
968
-
969
- if (!$presets.length) {
970
- $field.before(template);
971
- $field.addClass('pum-click-selector-presets-initialized');
972
- $presets = $field.parents('.pum-field').find('.pum-click-selector-presets');
973
- }
974
-
975
- $presets.position({
976
- my: 'right center',
977
- at: 'right center',
978
- of: $field
979
- });
980
- },
981
- toggle_click_selector_presets: function () {
982
- $(this).parent().toggleClass('open');
983
- },
984
- reset_click_selector_presets: function (e) {
985
- if (e !== undefined && $(e.target).parents('.pum-click-selector-presets').length) {
986
- return;
987
- }
988
-
989
- $('.pum-click-selector-presets').removeClass('open');
990
- },
991
- insert_click_selector_preset: function () {
992
- var $this = $(this),
993
- $input = $('#extra_selectors'),
994
- val = $input.val();
995
-
996
- if (val !== "") {
997
- val = val + ', ';
998
- }
999
-
1000
- $input.val(val + $this.data('preset'));
1001
- PUM_Admin.triggers.reset_click_selector_presets();
1002
- }
1003
- };
1004
-
1005
- // Import this module.
1006
- window.PUM_Admin = window.PUM_Admin || {};
1007
- window.PUM_Admin.triggers = triggers;
1008
-
1009
- $(document)
1010
- .on('pum_init', function () {
1011
- PUM_Admin.triggers.append_click_selector_presets();
1012
- PUM_Admin.triggers.refreshDescriptions();
1013
- })
1014
- .on('click', '.pum-click-selector-presets > span', PUM_Admin.triggers.toggle_click_selector_presets)
1015
- .on('click', '.pum-click-selector-presets li', PUM_Admin.triggers.insert_click_selector_preset)
1016
- .on('click', PUM_Admin.triggers.reset_click_selector_presets)
1017
- /**
1018
- * @deprecated 1.7.0
1019
- */
1020
- .on('select2:select pumselect2:select', '#pum-first-trigger', function () {
1021
- var $this = $(this),
1022
- $editor = $this.parents('.pum-popup-trigger-editor'),
1023
- type = $this.val(),
1024
- values = {};
1025
-
1026
- // Set Current Editor.
1027
- PUM_Admin.triggers.current_editor = $editor;
1028
-
1029
- if (type !== 'click_open') {
1030
- values.cookie_name = 'pum-' + $('#post_ID').val();
1031
- }
1032
-
1033
- triggers.template.form(type, values, function (event) {
1034
- var $form = $(this),
1035
- type = $form.find('input#type').val(),
1036
- values = $form.pumSerializeObject(),
1037
- trigger_settings = triggers.parseValues(values.trigger_settings || {}),
1038
- index = parseInt(values.index);
1039
-
1040
- event.preventDefault();
1041
-
1042
- if (index === false || index < 0) {
1043
- index = $editor.find('tbody tr').length;
1044
- }
1045
-
1046
- triggers.rows.add($editor, {
1047
- index: index,
1048
- type: type,
1049
- settings: trigger_settings
1050
- });
1051
-
1052
- PUM_Admin.modals.closeAll();
1053
-
1054
- if (trigger_settings.cookie_name !== undefined && trigger_settings.cookie_name !== null && (trigger_settings.cookie_name === 'add_new' || trigger_settings.cookie_name.indexOf('add_new') >= 0)) {
1055
- PUM_Admin.triggers.new_cookie = values.index;
1056
- $('#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new').trigger('click');
1057
- }
1058
- });
1059
-
1060
- $this
1061
- .val(null)
1062
- .trigger('change');
1063
- })
1064
- // Add New Triggers
1065
- .on('click', '.pum-popup-trigger-editor .pum-add-new', function () {
1066
- PUM_Admin.triggers.current_editor = $(this).parents('.pum-popup-trigger-editor');
1067
- var template = wp.template('pum-trigger-add-type');
1068
- PUM_Admin.modals.reload('#pum_trigger_add_type_modal', template({I10n: I10n}));
1069
- })
1070
- .on('click', '.pum-popup-trigger-editor .edit', function (event) {
1071
- var $this = $(this),
1072
- $editor = $this.parents('.pum-popup-trigger-editor'),
1073
- $row = $this.parents('tr:first'),
1074
- type = $row.find('.popup_triggers_field_type').val(),
1075
- values = _.extend({}, JSON.parse($row.find('.popup_triggers_field_settings:first').val()), {
1076
- index: $row.parent().children().index($row),
1077
- type: type
1078
- });
1079
-
1080
- event.preventDefault();
1081
-
1082
- triggers.template.form(type, values, function (event) {
1083
- var $form = $(this),
1084
- type = $form.find('input#type').val(),
1085
- index = $form.find('input#index').val(),
1086
- values = $form.pumSerializeObject(),
1087
- trigger_settings = triggers.parseValues(values.trigger_settings || {});
1088
-
1089
-
1090
- // Set Current Editor.
1091
- PUM_Admin.triggers.current_editor = $editor;
1092
-
1093
- event.preventDefault();
1094
-
1095
- if (index === false || index < 0) {
1096
- index = $editor.find('tbody tr').length;
1097
- }
1098
-
1099
- triggers.rows.add($editor, {
1100
- index: index,
1101
- type: type,
1102
- settings: trigger_settings
1103
- });
1104
-
1105
- PUM_Admin.modals.closeAll();
1106
-
1107
- if (trigger_settings.cookie_name !== undefined && trigger_settings.cookie_name !== null && (trigger_settings.cookie_name === 'add_new' || trigger_settings.cookie_name.indexOf('add_new') >= 0)) {
1108
- PUM_Admin.triggers.new_cookie = values.index;
1109
- $('#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new').trigger('click');
1110
- }
1111
- });
1112
- })
1113
- .on('click', '.pum-popup-trigger-editor .remove', function (event) {
1114
- var $this = $(this),
1115
- $editor = $this.parents('.pum-popup-trigger-editor'),
1116
- $row = $this.parents('tr:first');
1117
-
1118
- // Set Current Editor.
1119
- PUM_Admin.triggers.current_editor = $editor;
1120
-
1121
- event.preventDefault();
1122
-
1123
- if (window.confirm(I10n.confirm_delete_trigger)) {
1124
- triggers.rows.remove($row);
1125
- }
1126
- })
1127
- .on('submit', '#pum_trigger_add_type_modal .pum-form', function (event) {
1128
- var $editor = PUM_Admin.triggers.current_editor,
1129
- $cookie_editor = $editor.parents('#pum-popup-settings-triggers-subtabs_main').find('.pum-field-cookies .pum-popup-cookie-editor'),
1130
- type = $('#popup_trigger_add_type').val(),
1131
- add_cookie = $('#popup_trigger_add_cookie').is(':checked'),
1132
- add_cookie_event = $('#popup_trigger_add_cookie_event').val(),
1133
- values = {};
1134
-
1135
- event.preventDefault();
1136
-
1137
- if (add_cookie) {
1138
- values.cookie_name = 'pum-' + $('#post_ID').val();
1139
- PUM_Admin.cookies.insertCookie($cookie_editor, {
1140
- event: add_cookie_event,
1141
- settings: {
1142
- time: '1 month',
1143
- path: '1',
1144
- name: values.cookie_name
1145
- }
1146
- });
1147
- }
1148
-
1149
- triggers.template.form(type, values, function (event) {
1150
- var $form = $(this),
1151
- type = $form.find('input#type').val(),
1152
- values = $form.pumSerializeObject(),
1153
- trigger_settings = triggers.parseValues(values.trigger_settings || {}),
1154
- index = parseInt(values.index);
1155
-
1156
- // Set Current Editor.
1157
- PUM_Admin.triggers.current_editor = $editor;
1158
-
1159
- event.preventDefault();
1160
-
1161
- if (!index || index < 0) {
1162
- index = $editor.find('tbody tr').length;
1163
- }
1164
-
1165
- triggers.rows.add($editor, {
1166
- index: index,
1167
- type: type,
1168
- settings: trigger_settings
1169
- });
1170
-
1171
- PUM_Admin.modals.closeAll();
1172
-
1173
- if (trigger_settings.cookie_name !== undefined && trigger_settings.cookie_name !== null && (trigger_settings.cookie_name === 'add_new' || trigger_settings.cookie_name.indexOf('add_new') >= 0)) {
1174
- PUM_Admin.triggers.new_cookie = values.index;
1175
- $('#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new').trigger('click');
1176
- }
1177
- });
1178
- });
1179
-
1180
- }(jQuery, document));
1181
-
1182
- /*******************************************************************************
1183
- * Copyright (c) 2018, WP Popup Maker
1184
- ******************************************************************************/
1185
- (function ($) {
1186
- "use strict";
1187
-
1188
- window.PUM_Admin = window.PUM_Admin || {};
1189
-
1190
- window.pum_popup_settings_editor = window.pum_popup_settings_editor || {
1191
- form_args: {},
1192
- current_values: {}
1193
- };
1194
-
1195
- $(document)
1196
- .ready(function () {
1197
- $(this).trigger('pum_init');
1198
-
1199
- $('#title').prop('required', true);
1200
-
1201
- var $container = $('#pum-popup-settings-container'),
1202
- args = pum_popup_settings_editor.form_args || {},
1203
- values = pum_popup_settings_editor.current_values || {};
1204
-
1205
- if ($container.length) {
1206
- $container.find('.pum-no-js').hide();
1207
- PUM_Admin.forms.render(args, values, $container);
1208
- }
1209
-
1210
- $('a.page-title-action')
1211
- .clone()
1212
- .attr('target', '_blank')
1213
- .attr('href', pum_admin_vars.homeurl + '?popup_preview=true&popup=' + $('#post_ID').val())
1214
- .text(pum_admin_vars.I10n.preview_popup)
1215
- .insertAfter('a.page-title-action');
1216
-
1217
- // TODO Can't figure out why this is needed, but it looks stupid otherwise when the first condition field defaults to something other than the placeholder.
1218
- $('#pum-first-condition, #pum-first-trigger, #pum-first-cookie')
1219
- .val(null)
1220
- .trigger('change');
1221
- })
1222
- .on('keydown', '#popup-title', function (event) {
1223
- var keyCode = event.keyCode || event.which;
1224
- if (9 === keyCode) {
1225
- event.preventDefault();
1226
- $('#title').focus();
1227
- }
1228
- })
1229
- .on('keydown', '#title, #popup-title', function (event) {
1230
- var keyCode = event.keyCode || event.which,
1231
- target;
1232
- if (!event.shiftKey && 9 === keyCode) {
1233
- event.preventDefault();
1234
- target = $(this).attr('id') === 'title' ? '#popup-title' : '#insert-media-button';
1235
- $(target).focus();
1236
- }
1237
- })
1238
- .on('keydown', '#popup-title, #insert-media-button', function (event) {
1239
- var keyCode = event.keyCode || event.which,
1240
- target;
1241
- if (event.shiftKey && 9 === keyCode) {
1242
- event.preventDefault();
1243
- target = $(this).attr('id') === 'popup-title' ? '#title' : '#popup-title';
1244
- $(target).focus();
1245
- }
1246
- });
1
+ (function ($, document, undefined) {
2
+ "use strict";
3
+
4
+ $(document)
5
+ .on('click', '#popup_reset_open_count', function () {
6
+ var $this = $(this);
7
+ if ($this.is(':checked') && !confirm(pum_admin_vars.I10n.confirm_count_reset)) {
8
+ $this.prop('checked', false);
9
+ }
10
+ });
11
  }(jQuery, document));
12
+ (function ($) {
13
+ "use strict";
14
+
15
+ var conditions = {
16
+ get_conditions: function () {
17
+ return window.pum_popup_settings_editor.conditions_selectlist;
18
+ },
19
+ not_operand_checkbox: function ($element) {
20
+
21
+ $element = $element || $('.pum-not-operand');
22
+
23
+ return $element.each(function () {
24
+ var $this = $(this),
25
+ $input = $this.find('input');
26
+
27
+ $input.prop('checked', !$input.is(':checked'));
28
+
29
+ conditions.toggle_not_operand($this);
30
+ });
31
+
32
+ },
33
+ toggle_not_operand: function ($element) {
34
+ $element = $element || $('.pum-not-operand');
35
+
36
+ return $element.each(function () {
37
+ var $this = $(this),
38
+ $input = $this.find('input'),
39
+ // $is = $this.find('.is'),
40
+ // $not = $this.find('.not'),
41
+ $container = $this.parents('.facet-target');
42
+
43
+ if ($input.is(':checked')) {
44
+ // $is.hide();
45
+ // $not.show();
46
+ $container.addClass('not-operand-checked');
47
+ } else {
48
+ // $is.show();
49
+ // $not.hide();
50
+ $container.removeClass('not-operand-checked');
51
+ }
52
+ });
53
+ },
54
+ template: {
55
+ editor: function (args) {
56
+ var data = $.extend(true, {}, {
57
+ groups: []
58
+ }, args);
59
+
60
+ data.groups = PUM_Admin.utils.object_to_array(data.groups);
61
+
62
+ return PUM_Admin.templates.render('pum-condition-editor', data);
63
+ },
64
+ group: function (args) {
65
+ var data = $.extend(true, {}, {
66
+ index: '',
67
+ facets: []
68
+ }, args),
69
+ i;
70
+
71
+ data.facets = PUM_Admin.utils.object_to_array(data.facets);
72
+
73
+ for (i = 0; data.facets.length > i; i++) {
74
+ data.facets[i].index = i;
75
+ data.facets[i].group = data.index;
76
+ }
77
+
78
+ return PUM_Admin.templates.render('pum-condition-group', data);
79
+ },
80
+ facet: function (args) {
81
+ var data = $.extend(true, {}, {
82
+ group: '',
83
+ index: '',
84
+ target: '',
85
+ not_operand: false,
86
+ settings: {}
87
+ }, args);
88
+
89
+ return PUM_Admin.templates.render('pum-condition-facet', data);
90
+ },
91
+ settings: function (args, values) {
92
+ var fields = [],
93
+ data = $.extend(true, {}, {
94
+ index: '',
95
+ group: '',
96
+ target: null,
97
+ fields: []
98
+ }, args);
99
+
100
+ if (!data.fields.length && pum_popup_settings_editor.conditions[args.target] !== undefined) {
101
+ data.fields = pum_popup_settings_editor.conditions[args.target].fields;
102
+ }
103
+
104
+ if (undefined === values) {
105
+ values = {};
106
+ }
107
+
108
+ // Replace the array with rendered fields.
109
+ _.each(data.fields, function (field, fieldID) {
110
+
111
+ field = PUM_Admin.models.field(field);
112
+
113
+ if (typeof field.meta !== 'object') {
114
+ field.meta = {};
115
+ }
116
+
117
+ if (undefined !== values[fieldID]) {
118
+ field.value = values[fieldID];
119
+ }
120
+
121
+ field.name = 'popup_settings[conditions][' + data.group + '][' + data.index + '][settings][' + fieldID + ']';
122
+
123
+ if (field.id === '') {
124
+ field.id = 'popup_settings_conditions_' + data.group + '_' + data.index + '_settings_' + fieldID;
125
+ }
126
+
127
+ fields.push(PUM_Admin.templates.field(field));
128
+ });
129
+
130
+ // Render the section.
131
+ return PUM_Admin.templates.section({
132
+ fields: fields
133
+ });
134
+ },
135
+ selectbox: function (args) {
136
+ var data = $.extend(true, {}, {
137
+ id: null,
138
+ name: null,
139
+ type: 'select',
140
+ group: '',
141
+ index: '',
142
+ value: null,
143
+ select2: true,
144
+ classes: [],
145
+ options: conditions.get_conditions()
146
+ }, args);
147
+
148
+ if (data.id === null) {
149
+ data.id = 'popup_settings_conditions_' + data.group + '_' + data.index + '_target';
150
+ }
151
+
152
+ if (data.name === null) {
153
+ data.name = 'popup_settings[conditions][' + data.group + '][' + data.index + '][target]';
154
+ }
155
+
156
+ return PUM_Admin.templates.field(data);
157
+ }
158
+ },
159
+ groups: {
160
+ add: function (editor, target, not_operand) {
161
+ var $editor = $(editor),
162
+ data = {
163
+ index: $editor.find('.facet-group-wrap').length,
164
+ facets: [
165
+ {
166
+ target: target || null,
167
+ not_operand: not_operand || false,
168
+ settings: {}
169
+ }
170
+ ]
171
+ };
172
+
173
+
174
+ $editor.find('.facet-groups').append(conditions.template.group(data));
175
+ $editor.addClass('has-conditions');
176
+ },
177
+ remove: function ($group) {
178
+ var $editor = $group.parents('.facet-builder');
179
+
180
+ $group.prev('.facet-group-wrap').find('.and .add-facet').removeClass('disabled');
181
+ $group.remove();
182
+
183
+ conditions.renumber();
184
+
185
+ if ($editor.find('.facet-group-wrap').length === 0) {
186
+ $editor.removeClass('has-conditions');
187
+
188
+ $('#pum-first-condition')
189
+ .val(null)
190
+ .trigger('change');
191
+ }
192
+ }
193
+ },
194
+ facets: {
195
+ add: function ($group, target, not_operand) {
196
+ var data = {
197
+ group: $group.data('index'),
198
+ index: $group.find('.facet').length,
199
+ target: target || null,
200
+ not_operand: not_operand || false,
201
+ settings: {}
202
+ };
203
+
204
+ $group.find('.facet-list').append(conditions.template.facet(data));
205
+ },
206
+ remove: function ($facet) {
207
+ var $group = $facet.parents('.facet-group-wrap');
208
+
209
+ $facet.remove();
210
+
211
+ if ($group.find('.facet').length === 0) {
212
+ conditions.groups.remove($group);
213
+ } else {
214
+ conditions.renumber();
215
+ }
216
+ }
217
+ },
218
+ renumber: function () {
219
+ $('.facet-builder .facet-group-wrap').each(function () {
220
+ var $group = $(this),
221
+ groupIndex = $group.parent().children().index($group);
222
+
223
+ $group
224
+ .data('index', groupIndex)
225
+ .find('.facet').each(function () {
226
+ var $facet = $(this),
227
+ facetIndex = $facet.parent().children().index($facet);
228
+
229
+ $facet
230
+ .data('index', facetIndex)
231
+ .find('[name]').each(function () {
232
+ this.name = this.name.replace(/popup_settings\[conditions\]\[\d*?\]\[\d*?\]/, "popup_settings[conditions][" + groupIndex + "][" + facetIndex + "]");
233
+ this.id = this.id.replace(/popup_settings_conditions_\d*?_\d*?_/, "popup_settings_conditions_" + groupIndex + "_" + facetIndex + "_");
234
+ });
235
+ });
236
+ });
237
+ }
238
+ };
239
+
240
+ // Import this module.
241
+ window.PUM_Admin = window.PUM_Admin || {};
242
+ window.PUM_Admin.conditions = conditions;
243
+
244
+ $(document)
245
+ .on('pum_init', function () {
246
+ conditions.renumber();
247
+ conditions.toggle_not_operand();
248
+ })
249
+ .on('select2:select pumselect2:select', '#pum-first-condition', function (event) {
250
+ var $field = $(this),
251
+ $editor = $field.parents('.facet-builder').eq(0),
252
+ target = $field.val(),
253
+ $operand = $editor.find('#pum-first-facet-operand'),
254
+ not_operand = $operand.is(':checked');
255
+
256
+ conditions.groups.add($editor, target, not_operand);
257
+
258
+ $field
259
+ .val(null)
260
+ .trigger('change');
261
+
262
+ $operand.prop('checked', false).parents('.facet-target').removeClass('not-operand-checked');
263
+ $(document).trigger('pum_init');
264
+ })
265
+ .on('click', '.facet-builder .pum-not-operand', function () {
266
+ conditions.not_operand_checkbox($(this));
267
+ })
268
+ .on('change', '.facet-builder .facet-target select', function (event) {
269
+ var $this = $(this),
270
+ $facet = $this.parents('.facet'),
271
+ target = $this.val(),
272
+ data = {
273
+ target: target
274
+ };
275
+
276
+ if (target === '' || target === $facet.data('target')) {
277
+ return;
278
+ }
279
+
280
+ $facet.data('target', target).find('.facet-settings').html(conditions.template.settings(data));
281
+ $(document).trigger('pum_init');
282
+ })
283
+ .on('click', '.facet-builder .facet-group-wrap:last-child .and .add-facet', function () {
284
+ conditions.groups.add($(this).parents('.facet-builder').eq(0));
285
+ $(document).trigger('pum_init');
286
+ })
287
+ .on('click', '.facet-builder .add-or .add-facet:not(.disabled)', function () {
288
+ conditions.facets.add($(this).parents('.facet-group-wrap').eq(0));
289
+ $(document).trigger('pum_init');
290
+ })
291
+ .on('click', '.facet-builder .remove-facet', function () {
292
+ conditions.facets.remove($(this).parents('.facet').eq(0));
293
+ $(document).trigger('pum_init');
294
+ });
295
+
296
  }(jQuery));
297
+ var cookies;
298
+ (function ($, document, undefined) {
299
+ "use strict";
300
+
301
+ var I10n = pum_admin_vars.I10n,
302
+ current_editor,
303
+ cookies = {
304
+ get_cookies: function () {
305
+ return window.pum_popup_settings_editor.cookies;
306
+ },
307
+ get_cookie: function (event) {
308
+ var cookies = this.get_cookies(),
309
+ cookie = cookies[event] !== 'undefined' ? cookies[event] : false;
310
+
311
+ if (!cookie) {
312
+ return false;
313
+ }
314
+
315
+ if (cookie && typeof cookie === 'object' && typeof cookie.fields === 'object' && Object.keys(cookie.fields).length) {
316
+ cookie = this.parseFields(cookie);
317
+ }
318
+
319
+ return cookie;
320
+ },
321
+ parseFields: function (cookie) {
322
+ _.each(cookie.fields, function (fields, tabID) {
323
+ _.each(fields, function (field, fieldID) {
324
+ cookie.fields[tabID][fieldID].name = 'cookie_settings[' + fieldID + ']';
325
+
326
+ if (cookie.fields[tabID][fieldID].id === '') {
327
+ cookie.fields[tabID][fieldID].id = 'cookie_settings_' + fieldID;
328
+ }
329
+ });
330
+ });
331
+
332
+ return cookie;
333
+ },
334
+ parseValues: function (values, type) {
335
+ return values;
336
+ },
337
+ select_list: function () {
338
+ var i,
339
+ _cookies = PUM_Admin.utils.object_to_array(cookies.get_cookies()),
340
+ options = {};
341
+
342
+ for (i = 0; i < _cookies.length; i++) {
343
+ options[_cookies[i].id] = _cookies[i].name;
344
+ }
345
+
346
+ return options;
347
+ },
348
+ /**
349
+ * @deprecated
350
+ *
351
+ * @param event
352
+ */
353
+ getLabel: function (event) {
354
+ var cookie = cookies.get_cookie(event);
355
+
356
+ if (!cookie) {
357
+ return false;
358
+ }
359
+
360
+ return cookie.name;
361
+ },
362
+ /**
363
+ * @param event
364
+ * @param values
365
+ */
366
+ getSettingsDesc: function (event, values) {
367
+ var cookie = cookies.get_cookie(event);
368
+
369
+ if (!cookie) {
370
+ return false;
371
+ }
372
+
373
+ return PUM_Admin.templates.renderInline(cookie.settings_column, values);
374
+ },
375
+ /**
376
+ * Refresh all cookie row descriptions.
377
+ */
378
+ refreshDescriptions: function () {
379
+ $('.pum-popup-cookie-editor table.list-table tbody tr').each(function () {
380
+ var $row = $(this),
381
+ event = $row.find('.popup_cookies_field_event').val(),
382
+ values = JSON.parse($row.find('.popup_cookies_field_settings:first').val());
383
+
384
+ $row.find('td.settings-column').html(cookies.getSettingsDesc(event, values));
385
+ });
386
+ },
387
+ /**
388
+ * Insert a new cookie when needed.
389
+ *
390
+ * @param $editor
391
+ * @param args
392
+ */
393
+ insertCookie: function ($editor, args) {
394
+ args = $.extend(true, {}, {
395
+ event: 'on_popup_close',
396
+ settings: {
397
+ name: name || 'pum-' + $('#post_ID').val()
398
+ }
399
+ }, args);
400
+
401
+ cookies.rows.add($editor, args);
402
+ },
403
+ template: {
404
+ form: function (event, values, callback) {
405
+ var cookie = cookies.get_cookie(event),
406
+ modalID = 'pum_cookie_settings',
407
+ firstTab = Object.keys(cookie.fields)[0];
408
+
409
+ values = values || {};
410
+ values.event = event;
411
+ values.index = values.index >= 0 ? values.index : null;
412
+
413
+ // Add hidden index & event fields.
414
+ cookie.fields[firstTab] = $.extend(true, cookie.fields[firstTab], {
415
+ index: {
416
+ type: 'hidden',
417
+ name: 'index'
418
+ },
419
+ event: {
420
+ type: 'hidden',
421
+ name: 'event'
422
+ }
423
+ });
424
+
425
+ if (typeof values.key !== 'string' || values.key === '') {
426
+ delete cookie.fields.advanced.key;
427
+ }
428
+
429
+ PUM_Admin.modals.reload('#' + modalID, PUM_Admin.templates.modal({
430
+ id: modalID,
431
+ title: cookie.modal_title || cookie.name,
432
+ classes: 'tabbed-content',
433
+ save_button: values.index !== null ? I10n.update : I10n.add,
434
+ content: PUM_Admin.forms.render({
435
+ id: 'pum_cookie_settings_form',
436
+ tabs: cookie.tabs || {},
437
+ fields: cookie.fields || {}
438
+ }, values || {})
439
+ }));
440
+
441
+ $('#' + modalID + ' form').on('submit', callback || function (e) {
442
+ e.preventDefault();
443
+ PUM_Admin.modals.closeAll();
444
+ });
445
+ },
446
+ editor: function (args) {
447
+ var data = $.extend(true, {}, {
448
+ cookies: [],
449
+ name: ''
450
+ }, args);
451
+
452
+ data.cookies = PUM_Admin.utils.object_to_array(data.cookies);
453
+
454
+ return PUM_Admin.templates.render('pum-cookie-editor', data);
455
+ },
456
+ row: function (args) {
457
+ var data = $.extend(true, {}, {
458
+ index: '',
459
+ event: '',
460
+ name: '',
461
+ settings: {
462
+ name: "",
463
+ key: "",
464
+ session: false,
465
+ time: '30 days',
466
+ path: true
467
+ }
468
+ }, args);
469
+
470
+ return PUM_Admin.templates.render('pum-cookie-row', data);
471
+ },
472
+ selectbox: function (args) {
473
+ var data = $.extend(true, {}, {
474
+ id: null,
475
+ name: null,
476
+ type: 'select',
477
+ group: '',
478
+ index: '',
479
+ value: null,
480
+ select2: true,
481
+ classes: [],
482
+ options: cookies.select_list()
483
+ }, args);
484
+
485
+ if (data.id === null) {
486
+ data.id = 'popup_settings_cookies_' + data.index + '_event';
487
+ }
488
+
489
+ if (data.name === null) {
490
+ data.name = 'popup_settings[cookies][' + data.index + '][event]';
491
+ }
492
+
493
+ return PUM_Admin.templates.field(data);
494
+ }
495
+ },
496
+ rows: {
497
+ add: function (editor, cookie) {
498
+ var $editor = $(editor),
499
+ data = {
500
+ index: cookie.index !== null && cookie.index >= 0 ? cookie.index : $editor.find('table.list-table tbody tr').length,
501
+ event: cookie.event,
502
+ name: $editor.data('field_name'),
503
+ settings: cookie.settings || {}
504
+ },
505
+ $row = $editor.find('tbody tr').eq(data.index),
506
+ $new_row = PUM_Admin.templates.render('pum-cookie-row', data);
507
+
508
+ if ($row.length) {
509
+ $row.replaceWith($new_row);
510
+ } else {
511
+ $editor.find('tbody').append($new_row);
512
+ }
513
+
514
+ $editor.addClass('has-list-items');
515
+
516
+ cookies.rows.renumber();
517
+ cookies.refreshDescriptions();
518
+ },
519
+ /**
520
+ * Remove a cookie editor table row.
521
+ *
522
+ * @param $cookie
523
+ */
524
+ remove: function ($cookie) {
525
+ var $editor = $cookie.parents('.pum-popup-cookie-editor');
526
+
527
+ $cookie.remove();
528
+ cookies.rows.renumber();
529
+
530
+ if ($editor.find('table.list-table tbody tr').length === 0) {
531
+ $editor.removeClass('has-list-items');
532
+
533
+ $('#pum-first-cookie')
534
+ .val(null)
535
+ .trigger('change');
536
+ }
537
+ },
538
+ /**
539
+ * Renumber all rows for all editors.
540
+ */
541
+ renumber: function () {
542
+ $('.pum-popup-cookie-editor table.list-table tbody tr').each(function () {
543
+ var $this = $(this),
544
+ index = $this.parent().children().index($this);
545
+
546
+ $this.attr('data-index', index).data('index', index);
547
+
548
+ $this.find(':input, [name]').each(function () {
549
+ if (this.name && this.name !== '') {
550
+ this.name = this.name.replace(/\[\d*?\]/, "[" + index + "]");
551
+ }
552
+ });
553
+ });
554
+ }
555
+ }
556
+ };
557
+
558
+ // Import this module.
559
+ window.PUM_Admin = window.PUM_Admin || {};
560
+ window.PUM_Admin.cookies = cookies;
561
+
562
+ $(document)
563
+ .on('pum_init', function () {
564
+ cookies.refreshDescriptions();
565
+ })
566
+ .on('select2:select pumselect2:select', '#pum-first-cookie', function () {
567
+ var $this = $(this),
568
+ $editor = $this.parents('.pum-popup-cookie-editor'),
569
+ event = $this.val(),
570
+ values = {
571
+ indes: $editor.find('table.list-table tbody tr').length,
572
+ name: 'pum-' + $('#post_ID').val()
573
+ };
574
+
575
+ $this
576
+ .val(null)
577
+ .trigger('change');
578
+
579
+ cookies.template.form(event, values, function (e) {
580
+ var $form = $(this),
581
+ event = $form.find('input#event').val(),
582
+ index = $form.find('input#index').val(),
583
+ values = $form.pumSerializeObject();
584
+
585
+ e.preventDefault();
586
+
587
+ if (!index || index < 0) {
588
+ index = $editor.find('tbody tr').length;
589
+ }
590
+
591
+ cookies.rows.add($editor, {
592
+ index: index,
593
+ event: event,
594
+ settings: values.cookie_settings
595
+ });
596
+
597
+ PUM_Admin.modals.closeAll();
598
+ });
599
+ })
600
+ .on('click', '.pum-popup-cookie-editor .pum-add-new', function () {
601
+ current_editor = $(this).parents('.pum-popup-cookie-editor');
602
+ var template = wp.template('pum-cookie-add-event');
603
+ PUM_Admin.modals.reload('#pum_cookie_add_event_modal', template({I10n: I10n}));
604
+ })
605
+ .on('click', '.pum-popup-cookie-editor .edit', function (e) {
606
+ var $this = $(this),
607
+ $editor = $this.parents('.pum-popup-cookie-editor'),
608
+ $row = $this.parents('tr:first'),
609
+ event = $row.find('.popup_cookies_field_event').val(),
610
+ values = _.extend({}, JSON.parse($row.find('.popup_cookies_field_settings:first').val()), {
611
+ index: $row.parent().children().index($row),
612
+ event: event
613
+ });
614
+
615
+ e.preventDefault();
616
+
617
+ cookies.template.form(event, values, function (e) {
618
+ var $form = $(this),
619
+ event = $form.find('input#event').val(),
620
+ index = $form.find('input#index').val(),
621
+ values = $form.pumSerializeObject();
622
+
623
+ e.preventDefault();
624
+
625
+ if (index === false || index < 0) {
626
+ index = $editor.find('tbody tr').length;
627
+ }
628
+
629
+ cookies.rows.add($editor, {
630
+ index: index,
631
+ event: event,
632
+ settings: values.cookie_settings
633
+ });
634
+
635
+ PUM_Admin.modals.closeAll();
636
+ });
637
+ })
638
+ .on('click', '.pum-popup-cookie-editor .remove', function (e) {
639
+ var $this = $(this),
640
+ $row = $this.parents('tr:first');
641
+
642
+ e.preventDefault();
643
+
644
+ if (window.confirm(I10n.confirm_delete_cookie)) {
645
+ cookies.rows.remove($row);
646
+ }
647
+ })
648
+ .on('click', '.pum-field-cookie_key button.reset', function (e) {
649
+ var $this = $(this),
650
+ newKey = (new Date().getTime()).toString(16);
651
+
652
+ $this.siblings('input[type="text"]:first').val(newKey);
653
+ })
654
+ .on('submit', '#pum_cookie_add_event_modal .pum-form', function (e) {
655
+ var $editor = current_editor,
656
+ event = $('#popup_cookie_add_event').val(),
657
+ values = {
658
+ index: $editor.find('table.list-table tbody tr').length,
659
+ name: 'pum-' + $('#post_ID').val(),
660
+ path: '1'
661
+ };
662
+
663
+ e.preventDefault();
664
+
665
+ cookies.template.form(event, values, function (e) {
666
+ var $form = $(this),
667
+ event = $form.find('input#event').val(),
668
+ index = $form.find('input#index').val(),
669
+ values = $form.pumSerializeObject();
670
+
671
+ e.preventDefault();
672
+
673
+ if (index === false || index < 0) {
674
+ index = $editor.find('tbody tr').length;
675
+ }
676
+
677
+ cookies.rows.add($editor, {
678
+ index: index,
679
+ event: event,
680
+ settings: values.cookie_settings
681
+ });
682
+
683
+ PUM_Admin.modals.closeAll();
684
+
685
+ if (typeof PUM_Admin.triggers !== 'undefined' && PUM_Admin.triggers.new_cookie !== false && PUM_Admin.triggers.new_cookie >= 0) {
686
+ var $trigger = PUM_Admin.triggers.current_editor.find('tbody tr').eq(PUM_Admin.triggers.new_cookie).find('.popup_triggers_field_settings:first'),
687
+ trigger_settings = JSON.parse($trigger.val());
688
+
689
+ if (typeof trigger_settings.cookie_name === 'string') {
690
+ trigger_settings.cookie_name = trigger_settings.cookie_name.replace('add_new', values.cookie_settings.name);
691
+ } else {
692
+ trigger_settings.cookie_name[trigger_settings.cookie_name.indexOf('add_new')] = values.cookie_settings.name;
693
+ trigger_settings.cookie_name = trigger_settings.cookie_name.filter(function(element, index, array) {
694
+ return element in this ? false : this[element] = true;
695
+ }, {});
696
+ }
697
+
698
+ $trigger.val(JSON.stringify(trigger_settings));
699
+
700
+ PUM_Admin.triggers.new_cookie = false;
701
+ PUM_Admin.triggers.refreshDescriptions();
702
+ }
703
+ });
704
+ });
705
+
706
  }(jQuery, document));
707
+ (function ($, document, undefined) {
708
+ "use strict";
709
+
710
+ var I10n = pum_admin_vars.I10n;
711
+
712
+ var triggers = {
713
+ current_editor: null,
714
+ new_cookie: false,
715
+ get_triggers: function () {
716
+ return window.pum_popup_settings_editor.triggers;
717
+ },
718
+ get_trigger: function (type) {
719
+ var triggers = this.get_triggers(),
720
+ trigger = triggers[type] !== 'undefined' ? triggers[type] : false;
721
+
722
+ if (!trigger) {
723
+ return false;
724
+ }
725
+
726
+ if (trigger && typeof trigger === 'object' && typeof trigger.fields === 'object' && Object.keys(trigger.fields).length) {
727
+ trigger = this.parseFields(trigger);
728
+ }
729
+
730
+ return trigger;
731
+ },
732
+ parseFields: function (trigger) {
733
+ _.each(trigger.fields, function (fields, tabID) {
734
+ _.each(fields, function (field, fieldID) {
735
+
736
+ trigger.fields[tabID][fieldID].name = 'trigger_settings[' + fieldID + ']';
737
+
738
+ if (trigger.fields[tabID][fieldID].id === '') {
739
+ trigger.fields[tabID][fieldID].id = 'trigger_settings_' + fieldID;
740
+ }
741
+ });
742
+ });
743
+
744
+ return trigger;
745
+ },
746
+ parseValues: function (values, type) {
747
+ for (var key in values) {
748
+ if (!values.hasOwnProperty(key)) {
749
+ continue;
750
+ }
751
+
752
+ // Clean measurement fields.
753
+ if (values.hasOwnProperty(key + "_unit")) {
754
+ values[key] += values[key + "_unit"];
755
+ delete values[key + "_unit"];
756
+ }
757
+ }
758
+
759
+ return values;
760
+ },
761
+ select_list: function () {
762
+ var i,
763
+ _triggers = PUM_Admin.utils.object_to_array(triggers.get_triggers()),
764
+ options = {};
765
+
766
+ for (i = 0; i < _triggers.length; i++) {
767
+ options[_triggers[i].id] = _triggers[i].name;
768
+ }
769
+
770
+ return options;
771
+ },
772
+ rows: {
773
+ add: function (editor, trigger) {
774
+ var $editor = $(editor),
775
+ data = {
776
+ index: trigger.index !== null && trigger.index >= 0 ? trigger.index : $editor.find('table.list-table tbody tr').length,
777
+ type: trigger.type,
778
+ name: $editor.data('field_name'),
779
+ settings: trigger.settings || {}
780
+ },
781
+ $row = $editor.find('tbody tr').eq(data.index),
782
+ $new_row = PUM_Admin.templates.render('pum-trigger-row', data);
783
+
784
+ if ($row.length) {
785
+ $row.replaceWith($new_row);
786
+ } else {
787
+ $editor.find('tbody').append($new_row);
788
+ }
789
+
790
+ $editor.addClass('has-list-items');
791
+
792
+ triggers.renumber();
793
+ triggers.refreshDescriptions();
794
+ },
795
+ remove: function ($trigger) {
796
+ var $editor = $trigger.parents('.pum-popup-trigger-editor');
797
+
798
+ $trigger.remove();
799
+ triggers.renumber();
800
+
801
+ if ($editor.find('table.list-table tbody tr').length === 0) {
802
+ $editor.removeClass('has-list-items');
803
+
804
+ $('#pum-first-trigger')
805
+ .val(null)
806
+ .trigger('change');
807
+ }
808
+ }
809
+ },
810
+ template: {
811
+ form: function (type, values, callback) {
812
+ var trigger = triggers.get_trigger(type),
813
+ modalID = 'pum_trigger_settings',
814
+ firstTab = Object.keys(trigger.fields)[0],
815
+ $cookies = $('.pum-field-cookies .list-table tbody tr');
816
+
817
+ values = values || {};
818
+ values.type = type;
819
+ values.index = values.index >= 0 ? values.index : null;
820
+
821
+ // Add hidden index & type fields.
822
+ trigger.fields[firstTab] = $.extend(true, trigger.fields[firstTab], {
823
+ index: {
824
+ type: 'hidden',
825
+ name: 'index'
826
+ },
827
+ type: {
828
+ type: 'hidden',
829
+ name: 'type'
830
+ }
831
+ });
832
+
833
+ $cookies.each(function () {
834
+ var settings = JSON.parse($(this).find('.popup_cookies_field_settings:first').val());
835
+ if (typeof trigger.fields[firstTab].cookie_name.options[settings.name] === 'undefined') {
836
+ trigger.fields[firstTab].cookie_name.options[settings.name] = settings.name;
837
+ }
838
+ });
839
+
840
+ PUM_Admin.modals.reload('#' + modalID, PUM_Admin.templates.modal({
841
+ id: modalID,
842
+ title: trigger.modal_title || trigger.name,
843
+ classes: 'tabbed-content',
844
+ save_button: values.index !== null ? I10n.update : I10n.add,
845
+ content: PUM_Admin.forms.render({
846
+ id: 'pum_trigger_settings_form',
847
+ tabs: trigger.tabs || {},
848
+ fields: trigger.fields || {}
849
+ }, values || {})
850
+ }));
851
+
852
+ $('#' + modalID + ' form').on('submit', callback || function (event) {
853
+ event.preventDefault();
854
+ PUM_Admin.modals.closeAll();
855
+ });
856
+ },
857
+ editor: function (args) {
858
+ var data = $.extend(true, {}, {
859
+ triggers: [],
860
+ name: ''
861
+ }, args);
862
+
863
+ data.triggers = PUM_Admin.utils.object_to_array(data.triggers);
864
+
865
+ return PUM_Admin.templates.render('pum-trigger-editor', data);
866
+ },
867
+ row: function (args) {
868
+ var data = $.extend(true, {}, {
869
+ index: '',
870
+ type: '',
871
+ name: '',
872
+ settings: {
873
+ cookie_name: ""
874
+ }
875
+ }, args);
876
+
877
+ return PUM_Admin.templates.render('pum-trigger-row', data);
878
+ },
879
+ selectbox: function (args) {
880
+ var data = $.extend(true, {}, {
881
+ id: null,
882
+ name: null,
883
+ type: 'select',
884
+ group: '',
885
+ index: '',
886
+ value: null,
887
+ select2: true,
888
+ classes: [],
889
+ options: triggers.select_list()
890
+ }, args);
891
+
892
+ if (data.id === null) {
893
+ data.id = 'popup_settings_triggers_' + data.index + '_type';
894
+ }
895
+
896
+ if (data.name === null) {
897
+ data.name = 'popup_settings[triggers][' + data.index + '][type]';
898
+ }
899
+
900
+ return PUM_Admin.templates.field(data);
901
+ }
902
+ },
903
+ /* @deprecated */
904
+ getLabel: function (type) {
905
+ var trigger = triggers.get_trigger(type);
906
+
907
+ if (!trigger) {
908
+ return false;
909
+ }
910
+
911
+ return trigger.name;
912
+ },
913
+ getSettingsDesc: function (type, values) {
914
+ var trigger = triggers.get_trigger(type);
915
+
916
+ if (!trigger) {
917
+ return false;
918
+ }
919
+
920
+ return PUM_Admin.templates.renderInline(trigger.settings_column, values);
921
+ },
922
+ renumber: function () {
923
+ $('.pum-popup-trigger-editor table.list-table tbody tr').each(function () {
924
+ var $this = $(this),
925
+ index = $this.parent().children().index($this);
926
+
927
+ $this.attr('data-index', index).data('index', index);
928
+
929
+ $this.find(':input, [name]').each(function () {
930
+ if (this.name && this.name !== '') {
931
+ this.name = this.name.replace(/\[\d*?\]/, "[" + index + "]");
932
+ }
933
+ });
934
+ });
935
+ },
936
+ refreshDescriptions: function () {
937
+ $('.pum-popup-trigger-editor table.list-table tbody tr').each(function () {
938
+ var $row = $(this),
939
+ type = $row.find('.popup_triggers_field_type').val(),
940
+ values = JSON.parse($row.find('.popup_triggers_field_settings:first').val()),
941
+ cookie_text = PUM_Admin.triggers.cookie_column_value(values.cookie_name);
942
+
943
+ $row.find('td.settings-column').html(PUM_Admin.triggers.getSettingsDesc(type, values));
944
+ $row.find('td.cookie-column code').text(cookie_text);
945
+ });
946
+ },
947
+ cookie_column_value: function (cookie_name) {
948
+ var cookie_text = I10n.no_cookie;
949
+
950
+ if (cookie_name instanceof Array) {
951
+ cookie_text = cookie_name.join(', ');
952
+ } else if (cookie_name !== null && cookie_name !== undefined && cookie_name !== '') {
953
+ cookie_text = cookie_name;
954
+ }
955
+ return cookie_text;
956
+ },
957
+ append_click_selector_presets: function () {
958
+ var $field = $('#extra_selectors'),
959
+ template,
960
+ $presets;
961
+
962
+ if (!$field.length || $field.hasClass('pum-click-selector-presets-initialized')) {
963
+ return;
964
+ }
965
+
966
+ template = PUM_Admin.templates.render('pum-click-selector-presets');
967
+ $presets = $field.parents('.pum-field').find('.pum-click-selector-presets');
968
+
969
+ if (!$presets.length) {
970
+ $field.before(template);
971
+ $field.addClass('pum-click-selector-presets-initialized');
972
+ $presets = $field.parents('.pum-field').find('.pum-click-selector-presets');
973
+ }
974
+
975
+ $presets.position({
976
+ my: 'right center',
977
+ at: 'right center',
978
+ of: $field
979
+ });
980
+ },
981
+ toggle_click_selector_presets: function () {
982
+ $(this).parent().toggleClass('open');
983
+ },
984
+ reset_click_selector_presets: function (e) {
985
+ if (e !== undefined && $(e.target).parents('.pum-click-selector-presets').length) {
986
+ return;
987
+ }
988
+
989
+ $('.pum-click-selector-presets').removeClass('open');
990
+ },
991
+ insert_click_selector_preset: function () {
992
+ var $this = $(this),
993
+ $input = $('#extra_selectors'),
994
+ val = $input.val();
995
+
996
+ if (val !== "") {
997
+ val = val + ', ';
998
+ }
999
+
1000
+ $input.val(val + $this.data('preset'));
1001
+ PUM_Admin.triggers.reset_click_selector_presets();
1002
+ }
1003
+ };
1004
+
1005
+ // Import this module.
1006
+ window.PUM_Admin = window.PUM_Admin || {};
1007
+ window.PUM_Admin.triggers = triggers;
1008
+
1009
+ $(document)
1010
+ .on('pum_init', function () {
1011
+ PUM_Admin.triggers.append_click_selector_presets();
1012
+ PUM_Admin.triggers.refreshDescriptions();
1013
+ })
1014
+ .on('click', '.pum-click-selector-presets > span', PUM_Admin.triggers.toggle_click_selector_presets)
1015
+ .on('click', '.pum-click-selector-presets li', PUM_Admin.triggers.insert_click_selector_preset)
1016
+ .on('click', PUM_Admin.triggers.reset_click_selector_presets)
1017
+ /**
1018
+ * @deprecated 1.7.0
1019
+ */
1020
+ .on('select2:select pumselect2:select', '#pum-first-trigger', function () {
1021
+ var $this = $(this),
1022
+ $editor = $this.parents('.pum-popup-trigger-editor'),
1023
+ type = $this.val(),
1024
+ values = {};
1025
+
1026
+ // Set Current Editor.
1027
+ PUM_Admin.triggers.current_editor = $editor;
1028
+
1029
+ if (type !== 'click_open') {
1030
+ values.cookie_name = 'pum-' + $('#post_ID').val();
1031
+ }
1032
+
1033
+ triggers.template.form(type, values, function (event) {
1034
+ var $form = $(this),
1035
+ type = $form.find('input#type').val(),
1036
+ values = $form.pumSerializeObject(),
1037
+ trigger_settings = triggers.parseValues(values.trigger_settings || {}),
1038
+ index = parseInt(values.index);
1039
+
1040
+ event.preventDefault();
1041
+
1042
+ if (index === false || index < 0) {
1043
+ index = $editor.find('tbody tr').length;
1044
+ }
1045
+
1046
+ triggers.rows.add($editor, {
1047
+ index: index,
1048
+ type: type,
1049
+ settings: trigger_settings
1050
+ });
1051
+
1052
+ PUM_Admin.modals.closeAll();
1053
+
1054
+ if (trigger_settings.cookie_name !== undefined && trigger_settings.cookie_name !== null && (trigger_settings.cookie_name === 'add_new' || trigger_settings.cookie_name.indexOf('add_new') >= 0)) {
1055
+ PUM_Admin.triggers.new_cookie = values.index;
1056
+ $('#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new').trigger('click');
1057
+ }
1058
+ });
1059
+
1060
+ $this
1061
+ .val(null)
1062
+ .trigger('change');
1063
+ })
1064
+ // Add New Triggers
1065
+ .on('click', '.pum-popup-trigger-editor .pum-add-new', function () {
1066
+ PUM_Admin.triggers.current_editor = $(this).parents('.pum-popup-trigger-editor');
1067
+ var template = wp.template('pum-trigger-add-type');
1068
+ PUM_Admin.modals.reload('#pum_trigger_add_type_modal', template({I10n: I10n}));
1069
+ })
1070
+ .on('click', '.pum-popup-trigger-editor .edit', function (event) {
1071
+ var $this = $(this),
1072
+ $editor = $this.parents('.pum-popup-trigger-editor'),
1073
+ $row = $this.parents('tr:first'),
1074
+ type = $row.find('.popup_triggers_field_type').val(),
1075
+ values = _.extend({}, JSON.parse($row.find('.popup_triggers_field_settings:first').val()), {
1076
+ index: $row.parent().children().index($row),
1077
+ type: type
1078
+ });
1079
+
1080
+ event.preventDefault();
1081
+
1082
+ triggers.template.form(type, values, function (event) {
1083
+ var $form = $(this),
1084
+ type = $form.find('input#type').val(),
1085
+ index = $form.find('input#index').val(),
1086
+ values = $form.pumSerializeObject(),
1087
+ trigger_settings = triggers.parseValues(values.trigger_settings || {});
1088
+
1089
+
1090
+ // Set Current Editor.
1091
+ PUM_Admin.triggers.current_editor = $editor;
1092
+
1093
+ event.preventDefault();
1094
+
1095
+ if (index === false || index < 0) {
1096
+ index = $editor.find('tbody tr').length;
1097
+ }
1098
+
1099
+ triggers.rows.add($editor, {
1100
+ index: index,
1101
+ type: type,
1102
+ settings: trigger_settings
1103
+ });
1104
+
1105
+ PUM_Admin.modals.closeAll();
1106
+
1107
+ if (trigger_settings.cookie_name !== undefined && trigger_settings.cookie_name !== null && (trigger_settings.cookie_name === 'add_new' || trigger_settings.cookie_name.indexOf('add_new') >= 0)) {
1108
+ PUM_Admin.triggers.new_cookie = values.index;
1109
+ $('#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new').trigger('click');
1110
+ }
1111
+ });
1112
+ })
1113
+ .on('click', '.pum-popup-trigger-editor .remove', function (event) {
1114
+ var $this = $(this),
1115
+ $editor = $this.parents('.pum-popup-trigger-editor'),
1116
+ $row = $this.parents('tr:first');
1117
+
1118
+ // Set Current Editor.
1119
+ PUM_Admin.triggers.current_editor = $editor;
1120
+
1121
+ eve