PluginProbe ʕ •ᴥ•ʔ
Conditional Fields for Contact Form 7 / 1.8.3
Conditional Fields for Contact Form 7 v1.8.3
2.7.10 2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 2.7.3 2.7.2 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6.1 1.6.2 1.6.3 1.6.5 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2 2.2.1 2.2.10 2.2.11 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.10 2.3.11 2.3.12 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.7 2.7.1 trunk 0.1 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.2 0.2.1 0.2.2 0.2.3
cf7-conditional-fields / js / scripts.js
cf7-conditional-fields / js Last commit date
scripts.js 6 years ago scripts.js.map 6 years ago scripts_admin.js 6 years ago scripts_es6.js 6 years ago
scripts.js
1748 lines
1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
4 /******/
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
7 /******/
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
11 /******/ }
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
14 /******/ i: moduleId,
15 /******/ l: false,
16 /******/ exports: {}
17 /******/ };
18 /******/
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
24 /******/
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
27 /******/ }
28 /******/
29 /******/
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
32 /******/
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
35 /******/
36 /******/ // define getter function for harmony exports
37 /******/ __webpack_require__.d = function(exports, name, getter) {
38 /******/ if(!__webpack_require__.o(exports, name)) {
39 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/ }
41 /******/ };
42 /******/
43 /******/ // define __esModule on exports
44 /******/ __webpack_require__.r = function(exports) {
45 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/ }
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
49 /******/ };
50 /******/
51 /******/ // create a fake namespace object
52 /******/ // mode & 1: value is a module id, require it
53 /******/ // mode & 2: merge all properties of value into the ns
54 /******/ // mode & 4: return value when already ns object
55 /******/ // mode & 8|1: behave like require
56 /******/ __webpack_require__.t = function(value, mode) {
57 /******/ if(mode & 1) value = __webpack_require__(value);
58 /******/ if(mode & 8) return value;
59 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/ var ns = Object.create(null);
61 /******/ __webpack_require__.r(ns);
62 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/ return ns;
65 /******/ };
66 /******/
67 /******/ // getDefaultExport function for compatibility with non-harmony modules
68 /******/ __webpack_require__.n = function(module) {
69 /******/ var getter = module && module.__esModule ?
70 /******/ function getDefault() { return module['default']; } :
71 /******/ function getModuleExports() { return module; };
72 /******/ __webpack_require__.d(getter, 'a', getter);
73 /******/ return getter;
74 /******/ };
75 /******/
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = "./js/scripts_es6.js");
85 /******/ })
86 /************************************************************************/
87 /******/ ({
88
89 /***/ "./js/scripts_es6.js":
90 /*!***************************!*\
91 !*** ./js/scripts_es6.js ***!
92 \***************************/
93 /*! no exports provided */
94 /***/ (function(module, __webpack_exports__, __webpack_require__) {
95
96 "use strict";
97 __webpack_require__.r(__webpack_exports__);
98 /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js");
99 /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__);
100
101
102
103 var cf7signature_resized = 0; // for compatibility with contact-form-7-signature-addon
104
105 var wpcf7cf_timeout;
106 var wpcf7cf_show_animation = {
107 "height": "show",
108 "marginTop": "show",
109 "marginBottom": "show",
110 "paddingTop": "show",
111 "paddingBottom": "show"
112 };
113 var wpcf7cf_hide_animation = {
114 "height": "hide",
115 "marginTop": "hide",
116 "marginBottom": "hide",
117 "paddingTop": "hide",
118 "paddingBottom": "hide"
119 };
120 var wpcf7cf_show_step_animation = {
121 "opacity": "show"
122 };
123 var wpcf7cf_hide_step_animation = {
124 "opacity": "hide"
125 };
126 var wpcf7cf_change_events = 'input.wpcf7cf paste.wpcf7cf change.wpcf7cf click.wpcf7cf propertychange.wpcf7cf';
127 var wpcf7cf_forms = []; // endswith polyfill
128
129 if (!String.prototype.endsWith) {
130 String.prototype.endsWith = function (search, this_len) {
131 if (this_len === undefined || this_len > this.length) {
132 this_len = this.length;
133 }
134
135 return this.substring(this_len - search.length, this_len) === search;
136 };
137 }
138
139 var Wpcf7cfForm = function Wpcf7cfForm($form) {
140 var options_element = $form.find('input[name="_wpcf7cf_options"]').eq(0);
141
142 if (!options_element.length || !options_element.val()) {
143 // doesn't look like a CF7 form created with conditional fields plugin enabled.
144 return false;
145 }
146
147 var form = this;
148 var form_options = JSON.parse(options_element.val());
149 form.$form = $form;
150 form.$input_hidden_group_fields = $form.find('[name="_wpcf7cf_hidden_group_fields"]');
151 form.$input_hidden_groups = $form.find('[name="_wpcf7cf_hidden_groups"]');
152 form.$input_visible_groups = $form.find('[name="_wpcf7cf_visible_groups"]');
153 form.$input_repeaters = $form.find('[name="_wpcf7cf_repeaters"]');
154 form.$input_steps = $form.find('[name="_wpcf7cf_steps"]');
155 form.unit_tag = $form.closest('.wpcf7').attr('id');
156 form.conditions = form_options['conditions']; // compatibility with conditional forms created with older versions of the plugin ( < 1.4 )
157
158 for (var i = 0; i < form.conditions.length; i++) {
159 var condition = form.conditions[i];
160
161 if (!('and_rules' in condition)) {
162 condition.and_rules = [{
163 'if_field': condition.if_field,
164 'if_value': condition.if_value,
165 'operator': condition.operator
166 }];
167 }
168 }
169
170 form.initial_conditions = form.conditions;
171 form.settings = form_options['settings'];
172 form.$groups = jQuery(); // empty jQuery set
173
174 form.repeaters = [];
175 form.multistep = null;
176 form.fields = [];
177 form.settings.animation_intime = parseInt(form.settings.animation_intime);
178 form.settings.animation_outtime = parseInt(form.settings.animation_outtime);
179
180 if (form.settings.animation === 'no') {
181 form.settings.animation_intime = 0;
182 form.settings.animation_outtime = 0;
183 }
184
185 form.updateGroups();
186 form.updateEventListeners();
187 form.displayFields(); // bring form in initial state if the reset event is fired on it.
188
189 form.$form.on('reset.wpcf7cf', form, function (e) {
190 var form = e.data;
191 setTimeout(function () {
192 form.displayFields();
193 form.resetRepeaters();
194
195 if (form.multistep != null) {
196 form.multistep.moveToStep(1);
197 }
198 }, 200);
199 }); // PRO ONLY
200
201 jQuery('.wpcf7cf_repeater:not(.wpcf7cf_repeater .wpcf7cf_repeater)', $form).each(function () {
202 form.repeaters.push(new Wpcf7cfRepeater(jQuery(this), form));
203 });
204 form.$input_repeaters.val(JSON.stringify(form.repeaters.map(function (item) {
205 return item.params.$repeater.id;
206 })));
207 var $multistep = jQuery('.wpcf7cf_multistep', $form);
208
209 if ($multistep.length) {
210 form.multistep = new Wpcf7cfMultistep($multistep, form); // window.wpcf7cf.updateMultistepState(form.multistep);
211 } // END PRO ONLY
212
213 };
214 /**
215 * reset initial number of subs for each repeater.
216 * (does not clear values)
217 */
218
219
220 Wpcf7cfForm.prototype.resetRepeaters = function () {
221 var form = this;
222 form.repeaters.forEach(function (repeater) {
223 repeater.updateSubs(repeater.params.$repeater.initial_subs);
224 });
225 };
226
227 Wpcf7cfForm.prototype.displayFields = function () {
228 var form = this;
229 window.wpcf7cf.get_simplified_dom_model(form.$form);
230 var unit_tag = this.unit_tag;
231 var wpcf7cf_conditions = this.conditions;
232 var wpcf7cf_settings = this.settings; //for compatibility with contact-form-7-signature-addon
233
234 if (cf7signature_resized === 0 && typeof signatures !== 'undefined' && signatures.constructor === Array && signatures.length > 0) {
235 for (var i = 0; i < signatures.length; i++) {
236 if (signatures[i].canvas.width === 0) {
237 var $sig_canvas = jQuery(".wpcf7-form-control-signature-body>canvas");
238 var $sig_wrap = jQuery(".wpcf7-form-control-signature-wrap");
239 $sig_canvas.eq(i).attr('width', $sig_wrap.width());
240 $sig_canvas.eq(i).attr('height', $sig_wrap.height());
241 cf7signature_resized = 1;
242 }
243 }
244 }
245
246 form.$groups.addClass('wpcf7cf-hidden');
247
248 for (var i = 0; i < wpcf7cf_conditions.length; i++) {
249 var condition = wpcf7cf_conditions[i];
250 var show_group = window.wpcf7cf.should_group_be_shown(condition, form.$form);
251
252 if (show_group) {
253 jQuery('[data-id=' + condition.then_field + ']', form.$form).eq(0).removeClass('wpcf7cf-hidden');
254 }
255 }
256
257 var animation_intime = wpcf7cf_settings.animation_intime;
258 var animation_outtime = wpcf7cf_settings.animation_outtime;
259 form.$groups.each(function (index) {
260 var $group = jQuery(this);
261 if ($group.is(':animated')) $group.finish(); // stop any current animations on the group
262
263 if ($group.css('display') === 'none' && !$group.hasClass('wpcf7cf-hidden')) {
264 if ($group.prop('tagName') === 'SPAN') {
265 $group.show().trigger('wpcf7cf_show_group');
266 } else {
267 $group.animate(wpcf7cf_show_animation, animation_intime).trigger('wpcf7cf_show_group'); // show
268 }
269 } else if ($group.css('display') !== 'none' && $group.hasClass('wpcf7cf-hidden')) {
270 if ($group.attr('data-clear_on_hide') !== undefined) {
271 var $inputs = jQuery(':input', $group).not(':button, :submit, :reset, :hidden');
272 $inputs.each(function () {
273 var $this = jQuery(this);
274 $this.val(this.defaultValue);
275 $this.prop('checked', this.defaultChecked);
276 });
277 $inputs.change(); //display_fields();
278 }
279
280 if ($group.prop('tagName') === 'SPAN') {
281 $group.hide().trigger('wpcf7cf_hide_group');
282 } else {
283 $group.animate(wpcf7cf_hide_animation, animation_outtime).trigger('wpcf7cf_hide_group'); // hide
284 }
285 }
286 });
287 form.updateHiddenFields();
288 form.updateSummaryFields();
289 };
290
291 Wpcf7cfForm.prototype.updateSummaryFields = function () {
292 var $summary = jQuery('.wpcf7cf-summary', this.$form);
293 if ($summary.length == 0 || !$summary.is(':visible')) return;
294 var fd = new FormData();
295 var formdata = this.$form.serializeArray();
296 jQuery.each(formdata, function (key, input) {
297 fd.append(input.name, input.value);
298 });
299 jQuery.ajax({
300 url: wpcf7cf_global_settings.ajaxurl + '?action=wpcf7cf_get_summary',
301 type: 'POST',
302 data: fd,
303 processData: false,
304 contentType: false,
305 dataType: 'json',
306 success: function success(json) {
307 $summary.html(json.summaryHtml);
308 }
309 });
310 };
311
312 Wpcf7cfForm.prototype.updateHiddenFields = function () {
313 var form = this;
314 var hidden_fields = [];
315 var hidden_groups = [];
316 var visible_groups = [];
317 form.$groups.each(function () {
318 var $this = jQuery(this);
319
320 if ($this.hasClass('wpcf7cf-hidden')) {
321 hidden_groups.push($this.data('id'));
322 $this.find('input,select,textarea').each(function () {
323 hidden_fields.push(jQuery(this).attr('name'));
324 });
325 } else {
326 visible_groups.push($this.data('id'));
327 }
328 });
329 form.hidden_fields = hidden_fields;
330 form.hidden_groups = hidden_groups;
331 form.visible_groups = visible_groups;
332 form.$input_hidden_group_fields.val(JSON.stringify(hidden_fields));
333 form.$input_hidden_groups.val(JSON.stringify(hidden_groups));
334 form.$input_visible_groups.val(JSON.stringify(visible_groups));
335 return true;
336 };
337
338 Wpcf7cfForm.prototype.updateGroups = function () {
339 var form = this;
340 form.$groups = form.$form.find('[data-class="wpcf7cf_group"]');
341 form.conditions = window.wpcf7cf.get_nested_conditions(form.initial_conditions, form.$form);
342 };
343
344 Wpcf7cfForm.prototype.updateEventListeners = function () {
345 var form = this; // monitor input changes, and call display_fields() if something has changed
346
347 jQuery('input, select, textarea, button', form.$form).not('.wpcf7cf_add, .wpcf7cf_remove').off(wpcf7cf_change_events).on(wpcf7cf_change_events, form, function (e) {
348 var form = e.data;
349 clearTimeout(wpcf7cf_timeout);
350 wpcf7cf_timeout = setTimeout(function () {
351 form.displayFields();
352 }, 100);
353 }); // PRO ONLY
354
355 jQuery('.wpcf7cf-togglebutton', form.$form).off('click.toggle_wpcf7cf').on('click.toggle_wpcf7cf', function () {
356 var $this = jQuery(this);
357
358 if ($this.text() === $this.data('val-1')) {
359 $this.text($this.data('val-2'));
360 $this.val($this.data('val-2'));
361 } else {
362 $this.text($this.data('val-1'));
363 $this.val($this.data('val-1'));
364 }
365 }); // END PRO ONLY
366 }; // PRO ONLY
367
368
369 function Wpcf7cfRepeater($repeater, form) {
370 var $ = jQuery;
371 var repeater = this;
372 var wpcf7cf_settings = form.settings;
373 repeater.form = form;
374 $repeater.num_subs = 0;
375 $repeater.id = $repeater.data('id');
376 $repeater.orig_id = $repeater.data('orig_data_id');
377 $repeater.min = typeof $repeater.data('min') !== 'undefined' ? parseInt($repeater.data('min')) : 1;
378 $repeater.max = typeof $repeater.data('max') !== 'undefined' ? parseInt($repeater.data('max')) : 200;
379 $repeater.initial_subs = typeof $repeater.data('initial') !== 'undefined' ? parseInt($repeater.data('initial')) : $repeater.min;
380 if ($repeater.initial_subs > $repeater.max) $repeater.initial_subs = $repeater.max;
381 var $repeater_sub = $repeater.children('.wpcf7cf_repeater_sub').eq(0);
382 var $repeater_controls = $repeater.children('.wpcf7cf_repeater_controls').eq(0);
383 var $repeater_sub_clone = $repeater_sub.clone();
384 $repeater_sub_clone.find('.wpcf7cf_repeater_sub').addBack('.wpcf7cf_repeater_sub').each(function () {
385 var $this = jQuery(this);
386 var prev_suffix = $this.attr('data-repeater_sub_suffix');
387 var new_suffix = prev_suffix + '__{{repeater_sub_suffix}}';
388 $this.attr('data-repeater_sub_suffix', new_suffix);
389 });
390 $repeater_sub_clone.find('[name]').each(function () {
391 var $this = jQuery(this);
392 var prev_name = $this.attr('name');
393 var orig_name = $this.attr('data-orig_name') != null ? $this.attr('data-orig_name') : prev_name;
394 var new_name = prev_name + '__{{repeater_sub_suffix}}';
395
396 if (prev_name.endsWith('_count')) {
397 new_name = prev_name.replace('_count', '__{{repeater_sub_suffix}}_count');
398 }
399
400 $this.attr('name', new_name);
401 $this.attr('data-orig_name', orig_name);
402 $this.closest('.wpcf7-form-control-wrap').addClass(new_name);
403 });
404 $repeater_sub_clone.find('.wpcf7cf_repeater,[data-class="wpcf7cf_group"]').each(function () {
405 var $this = jQuery(this);
406 var prev_data_id = $this.attr('data-id');
407 var orig_data_id = $this.attr('data-orig_data_id') != null ? $this.attr('data-orig_data_id') : prev_data_id;
408 var new_data_id = prev_data_id + '__{{repeater_sub_suffix}}';
409
410 if (prev_data_id.endsWith('_count')) {
411 new_data_id = prev_data_id.replace('_count', '__{{repeater_sub_suffix}}_count');
412 }
413
414 $this.attr('data-id', new_data_id);
415 $this.attr('data-orig_data_id', orig_data_id);
416 $this.closest('.wpcf7-form-control-wrap').addClass(new_data_id);
417 });
418 $repeater_sub_clone.find('[id]').each(function () {
419 var $this = jQuery(this);
420 var prev_id = $this.attr('id');
421 var orig_id = $this.attr('data-orig_id') != null ? $this.attr('data-orig_id') : prev_id;
422 var new_id = prev_id + '__{{repeater_sub_suffix}}';
423 $this.attr('id', new_id);
424 $this.attr('data-orig_id', orig_id);
425 $this.closest('.wpcf7-form-control-wrap').addClass(new_id);
426 });
427 $repeater_sub_clone.find('[for]').each(function () {
428 var $this = jQuery(this);
429 var prev_for = $this.attr('for');
430 var orig_for = $this.attr('data-orig_for') != null ? $this.attr('data-orig_for') : prev_for;
431 var new_for = prev_for + '__{{repeater_sub_suffix}}';
432 $this.attr('for', new_for);
433 $this.attr('data-orig_for', orig_for);
434 $this.closest('.wpcf7-form-control-wrap').addClass(new_for);
435 });
436 var repeater_sub_html = $repeater_sub_clone[0].outerHTML;
437 var $repeater_count_field = $repeater.find('[name=' + $repeater.id + '_count]').eq(0);
438 var $button_add = $repeater_controls.find('.wpcf7cf_add').eq(0);
439 var $button_remove = $repeater_controls.find('.wpcf7cf_remove').eq(0);
440 var params = {
441 $repeater: $repeater,
442 $repeater_count_field: $repeater_count_field,
443 repeater_sub_html: repeater_sub_html,
444 $repeater_controls: $repeater_controls,
445 $button_add: $button_add,
446 $button_remove: $button_remove,
447 wpcf7cf_settings: wpcf7cf_settings
448 };
449 this.params = params;
450 $button_add.click(repeater, function (e) {
451 var repeater = e.data;
452 repeater.updateSubs(params.$repeater.num_subs + 1);
453 });
454 $button_remove.click(repeater, function (e) {
455 var repeater = e.data;
456 repeater.updateSubs(params.$repeater.num_subs - 1);
457 });
458 jQuery('> .wpcf7cf_repeater_sub', params.$repeater).eq(0).remove(); // remove the first sub, it's just a template.
459
460 repeater.updateSubs($repeater.initial_subs);
461 }
462
463 Wpcf7cfRepeater.prototype.updateSubs = function (subs_to_show) {
464 var repeater = this;
465 var params = repeater.params;
466 var subs_to_add = subs_to_show - params.$repeater.num_subs;
467
468 if (subs_to_add < 0) {
469 repeater.removeSubs(-subs_to_add);
470 } else if (subs_to_add > 0) {
471 repeater.addSubs(subs_to_add);
472 }
473
474 var showButtonRemove = false;
475 var showButtonAdd = false;
476
477 if (params.$repeater.num_subs < params.$repeater.max) {
478 showButtonAdd = true;
479 }
480
481 if (params.$repeater.num_subs > params.$repeater.min) {
482 showButtonRemove = true;
483 }
484
485 if (showButtonAdd) {
486 params.$button_add.show();
487 } else {
488 params.$button_add.hide();
489 }
490
491 if (showButtonRemove) {
492 params.$button_remove.show();
493 } else {
494 params.$button_remove.hide();
495 }
496
497 params.$repeater_count_field.val(subs_to_show);
498 };
499
500 Wpcf7cfRepeater.prototype.addSubs = function (subs_to_add) {
501 var $ = jQuery;
502 var params = this.params;
503 var repeater = this;
504 var form = repeater.form;
505 var $repeater = params.$repeater;
506 var $repeater_controls = params.$repeater_controls; //jQuery(params.repeater_sub_html.replace(/name="(.*?)"/g,'name="wpcf7cf_repeater['+$repeater.id+']['+$repeater.num_subs+'][$1]" data-original-name="$1"')).hide().insertBefore($repeater_controls).animate(wpcf7cf_show_animation, params.wpcf7cf_settings.animation_intime);
507
508 var html_str = '';
509
510 for (var i = 1; i <= subs_to_add; i++) {
511 var sub_suffix = $repeater.num_subs + i;
512 html_str += params.repeater_sub_html.replace(/\{\{repeater_sub_suffix\}\}/g, sub_suffix).replace(new RegExp('\{\{' + $repeater.orig_id + '_index\}\}', 'g'), sub_suffix);
513 }
514
515 var $html = jQuery(html_str); // Add the newly created fields to the form
516
517 $html.hide().insertBefore($repeater_controls).animate(wpcf7cf_show_animation, params.wpcf7cf_settings.animation_intime).trigger('wpcf7cf_repeater_added');
518 jQuery('.wpcf7cf_repeater', $html).each(function () {
519 form.repeaters.push(new Wpcf7cfRepeater(jQuery(this), form));
520 });
521 form.$input_repeaters.val(JSON.stringify(form.repeaters.map(function (item) {
522 return item.params.$repeater.id;
523 })));
524 $repeater.num_subs += subs_to_add;
525 window.wpcf7cf.updateMultistepState(form.multistep);
526 form.updateGroups();
527 form.updateEventListeners();
528 form.displayFields(); // Exclusive Checkbox
529
530 $html.on('click', '.wpcf7-exclusive-checkbox input:checkbox', function () {
531 var name = $(this).attr('name');
532 $html.find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false);
533 }); //basic compatibility with material-design-for-contact-form-7
534
535 if (typeof window.cf7mdInit === "function") {
536 window.cf7mdInit();
537 }
538
539 return false;
540 };
541
542 Wpcf7cfRepeater.prototype.removeSubs = function (num_subs) {
543 var $ = jQuery;
544 var params = this.params;
545 var form = this.form;
546 params.$repeater.num_subs -= num_subs;
547 jQuery('> .wpcf7cf_repeater_sub', params.$repeater).slice(-num_subs).animate(wpcf7cf_hide_animation, {
548 duration: params.wpcf7cf_settings.animation_intime,
549 done: function done() {
550 var $this = jQuery(this); //remove the actual fields from the form
551
552 $this.remove();
553 params.$repeater.trigger('wpcf7cf_repeater_removed');
554 window.wpcf7cf.updateMultistepState(form.multistep);
555 form.updateGroups();
556 form.updateEventListeners();
557 form.displayFields();
558 }
559 });
560 return false;
561 };
562
563 function Wpcf7cfMultistep($multistep, form) {
564 var multistep = this;
565 multistep.$multistep = $multistep;
566 multistep.form = form;
567 multistep.$steps = $multistep.find('.wpcf7cf_step');
568 multistep.$btn_next = $multistep.find('.wpcf7cf_next');
569 multistep.$btn_prev = $multistep.find('.wpcf7cf_prev');
570 multistep.$dots = $multistep.find('.wpcf7cf_steps-dots');
571 multistep.currentStep = 0;
572 multistep.numSteps = multistep.$steps.length;
573 multistep.$dots.html('');
574
575 for (var i = 1; i <= multistep.numSteps; i++) {
576 multistep.$dots.append("\n <div class=\"dot\" data-step=\"".concat(i, "\">\n <div class=\"step-index\">").concat(i, "</div>\n <div class=\"step-title\">").concat(multistep.$steps.eq(i - 1).data('title'), "</div>\n </div>\n "));
577 }
578
579 multistep.$btn_next.on('click.wpcf7cf_step', function _callee() {
580 var result;
581 return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.async(function _callee$(_context) {
582 while (1) {
583 switch (_context.prev = _context.next) {
584 case 0:
585 _context.next = 2;
586 return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.awrap(multistep.validateStep(multistep.currentStep));
587
588 case 2:
589 result = _context.sent;
590
591 if (result === 'success') {
592 multistep.moveToStep(multistep.currentStep + 1);
593 }
594
595 case 4:
596 case "end":
597 return _context.stop();
598 }
599 }
600 });
601 }); // If form is submitted (by pressing retrun for example), and if we are not on the last step,
602 // then trigger click event on the $next button instead.
603
604 multistep.form.$form.on('submit.wpcf7cf_step', function (e) {
605 if (multistep.currentStep !== multistep.numSteps) {
606 multistep.$btn_next.trigger('click.wpcf7cf_step');
607 e.stopImmediatePropagation();
608 return false;
609 }
610 });
611 multistep.$btn_prev.click(function () {
612 multistep.moveToStep(multistep.currentStep - 1);
613 });
614 multistep.moveToStep(1);
615 }
616
617 jQuery(document).ajaxComplete(function (e, xhr, settings) {
618 if (xhr.hasOwnProperty('responseJSON') && xhr.responseJSON != null && xhr.responseJSON.hasOwnProperty('status') && xhr.responseJSON.hasOwnProperty('into') && xhr.responseJSON.status === "mail_success") {
619 jQuery(xhr.responseJSON.into).trigger('reset.wpcf7cf');
620 }
621 });
622
623 Wpcf7cfMultistep.prototype.validateStep = function (step_index) {
624 var multistep = this;
625 var $multistep = multistep.$multistep;
626 var $form = multistep.form.$form;
627 $form.find('.wpcf7-response-output').addClass('wpcf7-display-none');
628 return new Promise(function (resolve) {
629 var fd = new FormData(); // TEST IF FILES UPLOADS WORK? THEN REMOVE THIS
630 // jQuery.each($form.find('[data-id="step'+step_index+'"] input[type="file"]'), function(index, el) {
631 // fd.append(jQuery(el).attr('name'), jQuery(el)[0].files[0]);
632 // });
633
634 var formdata = $form.serializeArray();
635 jQuery.each(formdata, function (key, input) {
636 fd.append(input.name, input.value);
637 });
638 jQuery.ajax({
639 url: wpcf7cf_global_settings.ajaxurl + '?action=wpcf7cf_validate_step',
640 type: 'POST',
641 data: fd,
642 processData: false,
643 contentType: false,
644 dataType: 'json'
645 }).done(function (json) {
646 /*
647 * Insert _form_data_id if 'json variable' has
648 */
649 if (typeof json._cf7mls_db_form_data_id != 'undefined') {
650 if (!form.find('input[name="_cf7mls_db_form_data_id"]').length) {
651 form.append('<input type="hidden" name="_cf7mls_db_form_data_id" value="' + json._cf7mls_db_form_data_id + '" />');
652 }
653 } //reset error messages
654
655
656 $multistep.find('.wpcf7-form-control-wrap').removeClass('cf7mls-invalid');
657 $multistep.find('.wpcf7-form-control-wrap .wpcf7-not-valid-tip').remove();
658 $multistep.find('.wpcf7-response-output').remove();
659 $multistep.find('.wpcf7-response-output.wpcf7-validation-errors').removeClass('wpcf7-validation-errors');
660
661 if (!json.success) {
662 var checkError = 0;
663 jQuery.each(json.invalid_fields, function (index, el) {
664 if ($multistep.find('input[name="' + index + '"]').length || $multistep.find('input[name="' + index + '[]"]').length || $multistep.find('select[name="' + index + '"]').length || $multistep.find('select[name="' + index + '[]"]').length || $multistep.find('textarea[name="' + index + '"]').length || $multistep.find('textarea[name="' + index + '[]"]').length) {
665 checkError = checkError + 1;
666 var controlWrap = jQuery('.wpcf7-form-control-wrap.' + index, $form);
667 controlWrap.addClass('cf7mls-invalid');
668 controlWrap.find('span.wpcf7-not-valid-tip').remove();
669 controlWrap.append('<span role="alert" class="wpcf7-not-valid-tip">' + el.reason + '</span>'); //return false;
670 }
671 });
672 resolve('failed'); //$multistep.append('<div class="wpcf7-response-output wpcf7-display-none wpcf7-validation-errors" style="display: block;" role="alert">' + json.message + '</div>');
673
674 console.log($multistep.parent().find('.wpcf7-response-output'));
675 $multistep.parent().find('.wpcf7-response-output').removeClass('wpcf7-display-none').html(json.message);
676 } else if (json.success) {
677 resolve('success');
678 return false;
679 }
680 }).fail(function () {
681 resolve('error');
682 }).always(function () {// do nothing
683 });
684 });
685 };
686
687 Wpcf7cfMultistep.prototype.moveToStep = function (step_index) {
688 var multistep = this;
689 var previousStep = multistep.currentStep;
690 multistep.currentStep = step_index > multistep.numSteps ? multistep.numSteps : step_index < 1 ? 1 : step_index; // ANIMATION DISABLED FOR NOW cause it's ugly
691 // multistep.$steps.animate(wpcf7cf_hide_step_animation, multistep.form.settings.animation_outtime);
692 // multistep.$steps.eq(multistep.currentStep-1).animate(wpcf7cf_show_step_animation, multistep.form.settings.animation_intime);
693
694 multistep.$multistep.attr('data-current_step', multistep.currentStep);
695 multistep.$steps.hide();
696 multistep.$steps.eq(multistep.currentStep - 1).show().trigger('wpcf7cf_change_step', [previousStep, multistep.currentStep]);
697 multistep.form.$form[0].scrollIntoView();
698 multistep.form.updateSummaryFields();
699 window.wpcf7cf.updateMultistepState(multistep);
700 };
701
702 Wpcf7cfMultistep.prototype.getFieldsInStep = function (step_index) {
703 var simpleDom = window.wpcf7cf.get_simplified_dom_model(this.form.$form);
704 var inStep = false;
705 return simpleDom.filter(function (item, i) {
706 if (item.type == 'step') {
707 inStep = item.step == step_index + '';
708 }
709
710 return inStep && item.type == 'input';
711 }).map(function (item) {
712 return item.name;
713 });
714 }; // END PRO ONLY
715
716
717 window.wpcf7cf = {
718 // keep this for backwards compatibility
719 initForm: function initForm($form) {
720 wpcf7cf_forms.push(new Wpcf7cfForm($form));
721 },
722 get_nested_conditions: function get_nested_conditions(conditions, $current_form) {
723 //loop trough conditions. Then loop trough the dom, and each repeater we pass we should update all sub_values we encounter with __index
724 var simplified_dom = window.wpcf7cf.get_simplified_dom_model($current_form);
725 var groups = simplified_dom.filter(function (item, i) {
726 return item.type === 'group';
727 });
728 var sub_conditions = [];
729
730 for (var i = 0; i < groups.length; i++) {
731 var g = groups[i];
732 var relevant_conditions = conditions.filter(function (condition, i) {
733 return condition.then_field === g.original_name;
734 });
735 var relevant_conditions = relevant_conditions.map(function (item, i) {
736 return {
737 then_field: g.name,
738 and_rules: item.and_rules.map(function (and_rule, i) {
739 return {
740 if_field: and_rule.if_field + g.suffix,
741 if_value: and_rule.if_value,
742 operator: and_rule.operator
743 };
744 })
745 };
746 });
747 sub_conditions = sub_conditions.concat(relevant_conditions);
748 }
749
750 return conditions.concat(sub_conditions);
751 },
752 get_simplified_dom_model: function get_simplified_dom_model($current_form) {
753 // if the dom is something like:
754 // <form>
755 // <repeater ra>
756 // <group ga__1>
757 // <repeater rb__1>
758 // <input txta__1__1 />
759 // <input txta__1__2 />
760 // </repeater>
761 // <group gb__1>
762 // <input txtb__1 />
763 // </group>
764 // </group>
765 // <group ga__2>
766 // <repeater rb__2>
767 // <input txta__2__1 />
768 // </repeater>
769 // <group gb__2>
770 // <input txtb__2 />
771 // </group>
772 // </group>
773 // </repeater>
774 // </form>
775 //
776 // return something like:
777 // [{type:repeater, name:'ra', suffix: '__1'}, {type: group, name:'ga', suffix: '__1'}, ...]
778 var currentNode;
779 var ni = document.createNodeIterator($current_form[0], NodeFilter.SHOW_ELEMENT, null, false); //, NodeFilter.SHOW_ELEMENT, function(){ return NodeFilter.FILTER_ACCEPT; }
780
781 var simplified_dom = [];
782
783 while (currentNode = ni.nextNode()) {
784 if (currentNode.classList.contains('wpcf7cf_repeater')) {
785 simplified_dom.push({
786 type: 'repeater',
787 name: currentNode.dataset.id,
788 original_name: currentNode.dataset.orig_data_id
789 });
790 } else if (currentNode.dataset["class"] == 'wpcf7cf_group') {
791 simplified_dom.push({
792 type: 'group',
793 name: currentNode.dataset.id,
794 original_name: currentNode.dataset.orig_data_id
795 });
796 } else if (currentNode.className == 'wpcf7cf_step') {
797 simplified_dom.push({
798 type: 'step',
799 name: currentNode.dataset.id,
800 original_name: currentNode.dataset.id,
801 step: currentNode.dataset.id.substring(5)
802 });
803 } else if (currentNode.hasAttribute('name')) {
804 simplified_dom.push({
805 type: 'input',
806 name: currentNode.getAttribute('name'),
807 original_name: currentNode.getAttribute('data-orig_name')
808 });
809 }
810 }
811
812 simplified_dom = simplified_dom.map(function (item, i) {
813 var original_name_length = item.original_name == null ? item.name.length : item.original_name.length;
814 item.suffix = item.name.substring(original_name_length);
815 return item;
816 }); //console.table(simplified_dom);
817
818 return simplified_dom;
819 },
820 updateMultistepState: function updateMultistepState(multistep) {
821 if (multistep == null) return; // update hidden input field
822
823 var stepsData = {
824 currentStep: multistep.currentStep,
825 numSteps: multistep.numSteps,
826 fieldsInCurrentStep: multistep.getFieldsInStep(multistep.currentStep)
827 };
828 multistep.form.$input_steps.val(JSON.stringify(stepsData)); // update Buttons
829
830 multistep.$btn_prev.removeClass('disabled');
831 multistep.$btn_next.removeClass('disabled');
832
833 if (multistep.currentStep == multistep.numSteps) {
834 multistep.$btn_next.addClass('disabled');
835 }
836
837 if (multistep.currentStep == 1) {
838 multistep.$btn_prev.addClass('disabled');
839 } // replace next button with submit button on last step.
840 // TODO: make this depend on a setting
841
842
843 var $submit_button = multistep.form.$form.find('input[type="submit"]').eq(0);
844 var $ajax_loader = multistep.form.$form.find('.ajax-loader').eq(0);
845
846 if (multistep.currentStep == multistep.numSteps) {
847 multistep.$btn_next.hide();
848 $ajax_loader.detach().appendTo(multistep.$btn_next.parent());
849 $submit_button.detach().appendTo(multistep.$btn_next.parent());
850 $submit_button.show();
851 } else {
852 $submit_button.hide();
853 multistep.$btn_next.show();
854 } // update dots
855
856
857 var $dots = multistep.$dots.find('.dot');
858 $dots.removeClass('active').removeClass('completed');
859
860 for (var step = 1; step <= multistep.numSteps; step++) {
861 if (step < multistep.currentStep) {
862 $dots.eq(step - 1).addClass('completed');
863 } else if (step == multistep.currentStep) {
864 $dots.eq(step - 1).addClass('active');
865 }
866 }
867 },
868 should_group_be_shown: function should_group_be_shown(condition, $current_form) {
869 var $ = jQuery;
870 var show_group = true;
871
872 for (var and_rule_i = 0; and_rule_i < condition.and_rules.length; and_rule_i++) {
873 var condition_ok = false;
874 var condition_and_rule = condition.and_rules[and_rule_i];
875 var $field = jQuery('[name="' + condition_and_rule.if_field + '"], [name="' + condition_and_rule.if_field + '[]"], [data-original-name="' + condition_and_rule.if_field + '"], [data-original-name="' + condition_and_rule.if_field + '[]"]', $current_form);
876 var if_val = condition_and_rule.if_value;
877 var if_val_as_number = isFinite(parseFloat(if_val)) ? parseFloat(if_val) : 0;
878 var operator = condition_and_rule.operator;
879 var regex_patt = /.*/i; // fallback regex pattern
880
881 var isValidRegex = true;
882
883 try {
884 regex_patt = new RegExp(if_val, 'i');
885 } catch (e) {
886 isValidRegex = false;
887 } //backwards compat
888
889
890 operator = operator === '' ? 'less than or equals' : operator;
891 operator = operator === '' ? 'greater than or equals' : operator;
892 operator = operator === '>' ? 'greater than' : operator;
893 operator = operator === '<' ? 'less than' : operator;
894
895 if ($field.length === 1) {
896 // single field (tested with text field, single checkbox, select with single value (dropdown), select with multiple values)
897 if ($field.is('select')) {
898 if (operator === 'not equals') {
899 condition_ok = true;
900 }
901
902 $field.find('option:selected').each(function () {
903 var $option = jQuery(this);
904 var option_val = $option.val();
905
906 if (operator === 'equals' && option_val === if_val || operator === 'equals (regex)' && regex_patt.test($option.val())) {
907 condition_ok = true;
908 } else if (operator === 'not equals' && option_val === if_val || operator === 'not equals (regex)' && !regex_patt.test($option.val())) {
909 condition_ok = false;
910 return false; // break out of the loop
911 }
912 });
913 show_group = show_group && condition_ok;
914 }
915
916 var field_val = $field.val();
917 var field_val_as_number = isFinite(parseFloat(field_val)) ? parseFloat(field_val) : 0;
918
919 if ($field.attr('type') === 'checkbox') {
920 var field_is_checked = $field.is(':checked');
921
922 if (operator === 'equals' && field_is_checked && field_val === if_val || operator === 'not equals' && !field_is_checked || operator === 'is empty' && !field_is_checked || operator === 'not empty' && field_is_checked || operator === 'greater than' && field_is_checked && field_val_as_number > if_val_as_number || operator === 'less than' && field_is_checked && field_val_as_number < if_val_as_number || operator === 'greater than or equals' && field_is_checked && field_val_as_number >= if_val_as_number || operator === 'less than or equals' && field_is_checked && field_val_as_number <= if_val_as_number || operator === 'equals (regex)' && field_is_checked && regex_patt.test(field_val) || operator === 'not equals (regex)' && !field_is_checked) {
923 condition_ok = true;
924 }
925 } else if (operator === 'equals' && field_val === if_val || operator === 'not equals' && field_val !== if_val || operator === 'equals (regex)' && regex_patt.test(field_val) || operator === 'not equals (regex)' && !regex_patt.test(field_val) || operator === 'greater than' && field_val_as_number > if_val_as_number || operator === 'less than' && field_val_as_number < if_val_as_number || operator === 'greater than or equals' && field_val_as_number >= if_val_as_number || operator === 'less than or equals' && field_val_as_number <= if_val_as_number || operator === 'is empty' && field_val === '' || operator === 'not empty' && field_val !== '' || operator === 'function' && typeof window[if_val] == 'function' && window[if_val]($field)) {
926 condition_ok = true;
927 }
928 } else if ($field.length > 1) {
929 // multiple fields (tested with checkboxes, exclusive checkboxes, dropdown with multiple values)
930 var all_values = [];
931 var checked_values = [];
932 $field.each(function () {
933 all_values.push(jQuery(this).val());
934
935 if (jQuery(this).is(':checked')) {
936 checked_values.push(jQuery(this).val());
937 }
938 });
939 var checked_value_index = jQuery.inArray(if_val, checked_values);
940 var value_index = jQuery.inArray(if_val, all_values);
941
942 if (operator === 'is empty' && checked_values.length === 0 || operator === 'not empty' && checked_values.length > 0) {
943 condition_ok = true;
944 }
945
946 for (var ind = 0; ind < checked_values.length; ind++) {
947 var checked_val = checked_values[ind];
948 var checked_val_as_number = isFinite(parseFloat(checked_val)) ? parseFloat(checked_val) : 0;
949
950 if (operator === 'equals' && checked_val === if_val || operator === 'not equals' && checked_val !== if_val || operator === 'equals (regex)' && regex_patt.test(checked_val) || operator === 'not equals (regex)' && !regex_patt.test(checked_val) || operator === 'greater than' && checked_val_as_number > if_val_as_number || operator === 'less than' && checked_val_as_number < if_val_as_number || operator === 'greater than or equals' && checked_val_as_number >= if_val_as_number || operator === 'less than or equals' && checked_val_as_number <= if_val_as_number) {
951 condition_ok = true;
952 }
953 }
954 }
955
956 show_group = show_group && condition_ok;
957 }
958
959 return show_group;
960 }
961 };
962 jQuery('.wpcf7-form').each(function () {
963 wpcf7cf_forms.push(new Wpcf7cfForm(jQuery(this)));
964 }); // Call displayFields again on all forms
965 // Necessary in case some theme or plugin changed a form value by the time the entire page is fully loaded.
966
967 jQuery('document').ready(function () {
968 wpcf7cf_forms.forEach(function (f) {
969 f.displayFields();
970 });
971 }); // fix for exclusive checkboxes in IE (this will call the change-event again after all other checkboxes are unchecked, triggering the display_fields() function)
972
973 var old_wpcf7ExclusiveCheckbox = jQuery.fn.wpcf7ExclusiveCheckbox;
974
975 jQuery.fn.wpcf7ExclusiveCheckbox = function () {
976 return this.find('input:checkbox').click(function () {
977 var name = jQuery(this).attr('name');
978 jQuery(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false).eq(0).change();
979 });
980 };
981
982 /***/ }),
983
984 /***/ "./node_modules/@babel/runtime/regenerator/index.js":
985 /*!**********************************************************!*\
986 !*** ./node_modules/@babel/runtime/regenerator/index.js ***!
987 \**********************************************************/
988 /*! no static exports found */
989 /***/ (function(module, exports, __webpack_require__) {
990
991 module.exports = __webpack_require__(/*! regenerator-runtime */ "./node_modules/regenerator-runtime/runtime.js");
992
993 /***/ }),
994
995 /***/ "./node_modules/regenerator-runtime/runtime.js":
996 /*!*****************************************************!*\
997 !*** ./node_modules/regenerator-runtime/runtime.js ***!
998 \*****************************************************/
999 /*! no static exports found */
1000 /***/ (function(module, exports, __webpack_require__) {
1001
1002 /* WEBPACK VAR INJECTION */(function(module) {function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1003
1004 /**
1005 * Copyright (c) 2014-present, Facebook, Inc.
1006 *
1007 * This source code is licensed under the MIT license found in the
1008 * LICENSE file in the root directory of this source tree.
1009 */
1010 var runtime = function (exports) {
1011 "use strict";
1012
1013 var Op = Object.prototype;
1014 var hasOwn = Op.hasOwnProperty;
1015 var undefined; // More compressible than void 0.
1016
1017 var $Symbol = typeof Symbol === "function" ? Symbol : {};
1018 var iteratorSymbol = $Symbol.iterator || "@@iterator";
1019 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1020 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1021
1022 function wrap(innerFn, outerFn, self, tryLocsList) {
1023 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1024 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1025 var generator = Object.create(protoGenerator.prototype);
1026 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
1027 // .throw, and .return methods.
1028
1029 generator._invoke = makeInvokeMethod(innerFn, self, context);
1030 return generator;
1031 }
1032
1033 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
1034 // record like context.tryEntries[i].completion. This interface could
1035 // have been (and was previously) designed to take a closure to be
1036 // invoked without arguments, but in all the cases we care about we
1037 // already have an existing method we want to call, so there's no need
1038 // to create a new function object. We can even get away with assuming
1039 // the method takes exactly one argument, since that happens to be true
1040 // in every case, so we don't have to touch the arguments object. The
1041 // only additional allocation required is the completion record, which
1042 // has a stable shape and so hopefully should be cheap to allocate.
1043
1044 function tryCatch(fn, obj, arg) {
1045 try {
1046 return {
1047 type: "normal",
1048 arg: fn.call(obj, arg)
1049 };
1050 } catch (err) {
1051 return {
1052 type: "throw",
1053 arg: err
1054 };
1055 }
1056 }
1057
1058 var GenStateSuspendedStart = "suspendedStart";
1059 var GenStateSuspendedYield = "suspendedYield";
1060 var GenStateExecuting = "executing";
1061 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
1062 // breaking out of the dispatch switch statement.
1063
1064 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
1065 // .constructor.prototype properties for functions that return Generator
1066 // objects. For full spec compliance, you may wish to configure your
1067 // minifier not to mangle the names of these two functions.
1068
1069 function Generator() {}
1070
1071 function GeneratorFunction() {}
1072
1073 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
1074 // don't natively support it.
1075
1076
1077 var IteratorPrototype = {};
1078
1079 IteratorPrototype[iteratorSymbol] = function () {
1080 return this;
1081 };
1082
1083 var getProto = Object.getPrototypeOf;
1084 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1085
1086 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1087 // This environment has a native %IteratorPrototype%; use it instead
1088 // of the polyfill.
1089 IteratorPrototype = NativeIteratorPrototype;
1090 }
1091
1092 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1093 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
1094 GeneratorFunctionPrototype.constructor = GeneratorFunction;
1095 GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the
1096 // Iterator interface in terms of a single ._invoke method.
1097
1098 function defineIteratorMethods(prototype) {
1099 ["next", "throw", "return"].forEach(function (method) {
1100 prototype[method] = function (arg) {
1101 return this._invoke(method, arg);
1102 };
1103 });
1104 }
1105
1106 exports.isGeneratorFunction = function (genFun) {
1107 var ctor = typeof genFun === "function" && genFun.constructor;
1108 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
1109 // do is to check its .name property.
1110 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
1111 };
1112
1113 exports.mark = function (genFun) {
1114 if (Object.setPrototypeOf) {
1115 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1116 } else {
1117 genFun.__proto__ = GeneratorFunctionPrototype;
1118
1119 if (!(toStringTagSymbol in genFun)) {
1120 genFun[toStringTagSymbol] = "GeneratorFunction";
1121 }
1122 }
1123
1124 genFun.prototype = Object.create(Gp);
1125 return genFun;
1126 }; // Within the body of any async function, `await x` is transformed to
1127 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1128 // `hasOwn.call(value, "__await")` to determine if the yielded value is
1129 // meant to be awaited.
1130
1131
1132 exports.awrap = function (arg) {
1133 return {
1134 __await: arg
1135 };
1136 };
1137
1138 function AsyncIterator(generator) {
1139 function invoke(method, arg, resolve, reject) {
1140 var record = tryCatch(generator[method], generator, arg);
1141
1142 if (record.type === "throw") {
1143 reject(record.arg);
1144 } else {
1145 var result = record.arg;
1146 var value = result.value;
1147
1148 if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
1149 return Promise.resolve(value.__await).then(function (value) {
1150 invoke("next", value, resolve, reject);
1151 }, function (err) {
1152 invoke("throw", err, resolve, reject);
1153 });
1154 }
1155
1156 return Promise.resolve(value).then(function (unwrapped) {
1157 // When a yielded Promise is resolved, its final value becomes
1158 // the .value of the Promise<{value,done}> result for the
1159 // current iteration.
1160 result.value = unwrapped;
1161 resolve(result);
1162 }, function (error) {
1163 // If a rejected Promise was yielded, throw the rejection back
1164 // into the async generator function so it can be handled there.
1165 return invoke("throw", error, resolve, reject);
1166 });
1167 }
1168 }
1169
1170 var previousPromise;
1171
1172 function enqueue(method, arg) {
1173 function callInvokeWithMethodAndArg() {
1174 return new Promise(function (resolve, reject) {
1175 invoke(method, arg, resolve, reject);
1176 });
1177 }
1178
1179 return previousPromise = // If enqueue has been called before, then we want to wait until
1180 // all previous Promises have been resolved before calling invoke,
1181 // so that results are always delivered in the correct order. If
1182 // enqueue has not been called before, then it is important to
1183 // call invoke immediately, without waiting on a callback to fire,
1184 // so that the async generator function has the opportunity to do
1185 // any necessary setup in a predictable way. This predictability
1186 // is why the Promise constructor synchronously invokes its
1187 // executor callback, and why async functions synchronously
1188 // execute code before the first await. Since we implement simple
1189 // async functions in terms of async generators, it is especially
1190 // important to get this right, even though it requires care.
1191 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
1192 // invocations of the iterator.
1193 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1194 } // Define the unified helper method that is used to implement .next,
1195 // .throw, and .return (see defineIteratorMethods).
1196
1197
1198 this._invoke = enqueue;
1199 }
1200
1201 defineIteratorMethods(AsyncIterator.prototype);
1202
1203 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
1204 return this;
1205 };
1206
1207 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
1208 // AsyncIterator objects; they just return a Promise for the value of
1209 // the final result produced by the iterator.
1210
1211 exports.async = function (innerFn, outerFn, self, tryLocsList) {
1212 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
1213 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
1214 : iter.next().then(function (result) {
1215 return result.done ? result.value : iter.next();
1216 });
1217 };
1218
1219 function makeInvokeMethod(innerFn, self, context) {
1220 var state = GenStateSuspendedStart;
1221 return function invoke(method, arg) {
1222 if (state === GenStateExecuting) {
1223 throw new Error("Generator is already running");
1224 }
1225
1226 if (state === GenStateCompleted) {
1227 if (method === "throw") {
1228 throw arg;
1229 } // Be forgiving, per 25.3.3.3.3 of the spec:
1230 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1231
1232
1233 return doneResult();
1234 }
1235
1236 context.method = method;
1237 context.arg = arg;
1238
1239 while (true) {
1240 var delegate = context.delegate;
1241
1242 if (delegate) {
1243 var delegateResult = maybeInvokeDelegate(delegate, context);
1244
1245 if (delegateResult) {
1246 if (delegateResult === ContinueSentinel) continue;
1247 return delegateResult;
1248 }
1249 }
1250
1251 if (context.method === "next") {
1252 // Setting context._sent for legacy support of Babel's
1253 // function.sent implementation.
1254 context.sent = context._sent = context.arg;
1255 } else if (context.method === "throw") {
1256 if (state === GenStateSuspendedStart) {
1257 state = GenStateCompleted;
1258 throw context.arg;
1259 }
1260
1261 context.dispatchException(context.arg);
1262 } else if (context.method === "return") {
1263 context.abrupt("return", context.arg);
1264 }
1265
1266 state = GenStateExecuting;
1267 var record = tryCatch(innerFn, self, context);
1268
1269 if (record.type === "normal") {
1270 // If an exception is thrown from innerFn, we leave state ===
1271 // GenStateExecuting and loop back for another invocation.
1272 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
1273
1274 if (record.arg === ContinueSentinel) {
1275 continue;
1276 }
1277
1278 return {
1279 value: record.arg,
1280 done: context.done
1281 };
1282 } else if (record.type === "throw") {
1283 state = GenStateCompleted; // Dispatch the exception by looping back around to the
1284 // context.dispatchException(context.arg) call above.
1285
1286 context.method = "throw";
1287 context.arg = record.arg;
1288 }
1289 }
1290 };
1291 } // Call delegate.iterator[context.method](context.arg) and handle the
1292 // result, either by returning a { value, done } result from the
1293 // delegate iterator, or by modifying context.method and context.arg,
1294 // setting context.delegate to null, and returning the ContinueSentinel.
1295
1296
1297 function maybeInvokeDelegate(delegate, context) {
1298 var method = delegate.iterator[context.method];
1299
1300 if (method === undefined) {
1301 // A .throw or .return when the delegate iterator has no .throw
1302 // method always terminates the yield* loop.
1303 context.delegate = null;
1304
1305 if (context.method === "throw") {
1306 // Note: ["return"] must be used for ES3 parsing compatibility.
1307 if (delegate.iterator["return"]) {
1308 // If the delegate iterator has a return method, give it a
1309 // chance to clean up.
1310 context.method = "return";
1311 context.arg = undefined;
1312 maybeInvokeDelegate(delegate, context);
1313
1314 if (context.method === "throw") {
1315 // If maybeInvokeDelegate(context) changed context.method from
1316 // "return" to "throw", let that override the TypeError below.
1317 return ContinueSentinel;
1318 }
1319 }
1320
1321 context.method = "throw";
1322 context.arg = new TypeError("The iterator does not provide a 'throw' method");
1323 }
1324
1325 return ContinueSentinel;
1326 }
1327
1328 var record = tryCatch(method, delegate.iterator, context.arg);
1329
1330 if (record.type === "throw") {
1331 context.method = "throw";
1332 context.arg = record.arg;
1333 context.delegate = null;
1334 return ContinueSentinel;
1335 }
1336
1337 var info = record.arg;
1338
1339 if (!info) {
1340 context.method = "throw";
1341 context.arg = new TypeError("iterator result is not an object");
1342 context.delegate = null;
1343 return ContinueSentinel;
1344 }
1345
1346 if (info.done) {
1347 // Assign the result of the finished delegate to the temporary
1348 // variable specified by delegate.resultName (see delegateYield).
1349 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
1350
1351 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
1352 // exception, let the outer generator proceed normally. If
1353 // context.method was "next", forget context.arg since it has been
1354 // "consumed" by the delegate iterator. If context.method was
1355 // "return", allow the original .return call to continue in the
1356 // outer generator.
1357
1358 if (context.method !== "return") {
1359 context.method = "next";
1360 context.arg = undefined;
1361 }
1362 } else {
1363 // Re-yield the result returned by the delegate method.
1364 return info;
1365 } // The delegate iterator is finished, so forget it and continue with
1366 // the outer generator.
1367
1368
1369 context.delegate = null;
1370 return ContinueSentinel;
1371 } // Define Generator.prototype.{next,throw,return} in terms of the
1372 // unified ._invoke helper method.
1373
1374
1375 defineIteratorMethods(Gp);
1376 Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the
1377 // @@iterator function is called on it. Some browsers' implementations of the
1378 // iterator prototype chain incorrectly implement this, causing the Generator
1379 // object to not be returned from this call. This ensures that doesn't happen.
1380 // See https://github.com/facebook/regenerator/issues/274 for more details.
1381
1382 Gp[iteratorSymbol] = function () {
1383 return this;
1384 };
1385
1386 Gp.toString = function () {
1387 return "[object Generator]";
1388 };
1389
1390 function pushTryEntry(locs) {
1391 var entry = {
1392 tryLoc: locs[0]
1393 };
1394
1395 if (1 in locs) {
1396 entry.catchLoc = locs[1];
1397 }
1398
1399 if (2 in locs) {
1400 entry.finallyLoc = locs[2];
1401 entry.afterLoc = locs[3];
1402 }
1403
1404 this.tryEntries.push(entry);
1405 }
1406
1407 function resetTryEntry(entry) {
1408 var record = entry.completion || {};
1409 record.type = "normal";
1410 delete record.arg;
1411 entry.completion = record;
1412 }
1413
1414 function Context(tryLocsList) {
1415 // The root entry object (effectively a try statement without a catch
1416 // or a finally block) gives us a place to store values thrown from
1417 // locations where there is no enclosing try statement.
1418 this.tryEntries = [{
1419 tryLoc: "root"
1420 }];
1421 tryLocsList.forEach(pushTryEntry, this);
1422 this.reset(true);
1423 }
1424
1425 exports.keys = function (object) {
1426 var keys = [];
1427
1428 for (var key in object) {
1429 keys.push(key);
1430 }
1431
1432 keys.reverse(); // Rather than returning an object with a next method, we keep
1433 // things simple and return the next function itself.
1434
1435 return function next() {
1436 while (keys.length) {
1437 var key = keys.pop();
1438
1439 if (key in object) {
1440 next.value = key;
1441 next.done = false;
1442 return next;
1443 }
1444 } // To avoid creating an additional object, we just hang the .value
1445 // and .done properties off the next function object itself. This
1446 // also ensures that the minifier will not anonymize the function.
1447
1448
1449 next.done = true;
1450 return next;
1451 };
1452 };
1453
1454 function values(iterable) {
1455 if (iterable) {
1456 var iteratorMethod = iterable[iteratorSymbol];
1457
1458 if (iteratorMethod) {
1459 return iteratorMethod.call(iterable);
1460 }
1461
1462 if (typeof iterable.next === "function") {
1463 return iterable;
1464 }
1465
1466 if (!isNaN(iterable.length)) {
1467 var i = -1,
1468 next = function next() {
1469 while (++i < iterable.length) {
1470 if (hasOwn.call(iterable, i)) {
1471 next.value = iterable[i];
1472 next.done = false;
1473 return next;
1474 }
1475 }
1476
1477 next.value = undefined;
1478 next.done = true;
1479 return next;
1480 };
1481
1482 return next.next = next;
1483 }
1484 } // Return an iterator with no values.
1485
1486
1487 return {
1488 next: doneResult
1489 };
1490 }
1491
1492 exports.values = values;
1493
1494 function doneResult() {
1495 return {
1496 value: undefined,
1497 done: true
1498 };
1499 }
1500
1501 Context.prototype = {
1502 constructor: Context,
1503 reset: function reset(skipTempReset) {
1504 this.prev = 0;
1505 this.next = 0; // Resetting context._sent for legacy support of Babel's
1506 // function.sent implementation.
1507
1508 this.sent = this._sent = undefined;
1509 this.done = false;
1510 this.delegate = null;
1511 this.method = "next";
1512 this.arg = undefined;
1513 this.tryEntries.forEach(resetTryEntry);
1514
1515 if (!skipTempReset) {
1516 for (var name in this) {
1517 // Not sure about the optimal order of these conditions:
1518 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1519 this[name] = undefined;
1520 }
1521 }
1522 }
1523 },
1524 stop: function stop() {
1525 this.done = true;
1526 var rootEntry = this.tryEntries[0];
1527 var rootRecord = rootEntry.completion;
1528
1529 if (rootRecord.type === "throw") {
1530 throw rootRecord.arg;
1531 }
1532
1533 return this.rval;
1534 },
1535 dispatchException: function dispatchException(exception) {
1536 if (this.done) {
1537 throw exception;
1538 }
1539
1540 var context = this;
1541
1542 function handle(loc, caught) {
1543 record.type = "throw";
1544 record.arg = exception;
1545 context.next = loc;
1546
1547 if (caught) {
1548 // If the dispatched exception was caught by a catch block,
1549 // then let that catch block handle the exception normally.
1550 context.method = "next";
1551 context.arg = undefined;
1552 }
1553
1554 return !!caught;
1555 }
1556
1557 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1558 var entry = this.tryEntries[i];
1559 var record = entry.completion;
1560
1561 if (entry.tryLoc === "root") {
1562 // Exception thrown outside of any try block that could handle
1563 // it, so set the completion value of the entire function to
1564 // throw the exception.
1565 return handle("end");
1566 }
1567
1568 if (entry.tryLoc <= this.prev) {
1569 var hasCatch = hasOwn.call(entry, "catchLoc");
1570 var hasFinally = hasOwn.call(entry, "finallyLoc");
1571
1572 if (hasCatch && hasFinally) {
1573 if (this.prev < entry.catchLoc) {
1574 return handle(entry.catchLoc, true);
1575 } else if (this.prev < entry.finallyLoc) {
1576 return handle(entry.finallyLoc);
1577 }
1578 } else if (hasCatch) {
1579 if (this.prev < entry.catchLoc) {
1580 return handle(entry.catchLoc, true);
1581 }
1582 } else if (hasFinally) {
1583 if (this.prev < entry.finallyLoc) {
1584 return handle(entry.finallyLoc);
1585 }
1586 } else {
1587 throw new Error("try statement without catch or finally");
1588 }
1589 }
1590 }
1591 },
1592 abrupt: function abrupt(type, arg) {
1593 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1594 var entry = this.tryEntries[i];
1595
1596 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1597 var finallyEntry = entry;
1598 break;
1599 }
1600 }
1601
1602 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1603 // Ignore the finally entry if control is not jumping to a
1604 // location outside the try/catch block.
1605 finallyEntry = null;
1606 }
1607
1608 var record = finallyEntry ? finallyEntry.completion : {};
1609 record.type = type;
1610 record.arg = arg;
1611
1612 if (finallyEntry) {
1613 this.method = "next";
1614 this.next = finallyEntry.finallyLoc;
1615 return ContinueSentinel;
1616 }
1617
1618 return this.complete(record);
1619 },
1620 complete: function complete(record, afterLoc) {
1621 if (record.type === "throw") {
1622 throw record.arg;
1623 }
1624
1625 if (record.type === "break" || record.type === "continue") {
1626 this.next = record.arg;
1627 } else if (record.type === "return") {
1628 this.rval = this.arg = record.arg;
1629 this.method = "return";
1630 this.next = "end";
1631 } else if (record.type === "normal" && afterLoc) {
1632 this.next = afterLoc;
1633 }
1634
1635 return ContinueSentinel;
1636 },
1637 finish: function finish(finallyLoc) {
1638 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1639 var entry = this.tryEntries[i];
1640
1641 if (entry.finallyLoc === finallyLoc) {
1642 this.complete(entry.completion, entry.afterLoc);
1643 resetTryEntry(entry);
1644 return ContinueSentinel;
1645 }
1646 }
1647 },
1648 "catch": function _catch(tryLoc) {
1649 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1650 var entry = this.tryEntries[i];
1651
1652 if (entry.tryLoc === tryLoc) {
1653 var record = entry.completion;
1654
1655 if (record.type === "throw") {
1656 var thrown = record.arg;
1657 resetTryEntry(entry);
1658 }
1659
1660 return thrown;
1661 }
1662 } // The context.catch method must only be called with a location
1663 // argument that corresponds to a known catch block.
1664
1665
1666 throw new Error("illegal catch attempt");
1667 },
1668 delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1669 this.delegate = {
1670 iterator: values(iterable),
1671 resultName: resultName,
1672 nextLoc: nextLoc
1673 };
1674
1675 if (this.method === "next") {
1676 // Deliberately forget the last sent value so that we don't
1677 // accidentally pass it on to the delegate.
1678 this.arg = undefined;
1679 }
1680
1681 return ContinueSentinel;
1682 }
1683 }; // Regardless of whether this script is executing as a CommonJS module
1684 // or not, return the runtime object so that we can declare the variable
1685 // regeneratorRuntime in the outer scope, which allows this module to be
1686 // injected easily by `bin/regenerator --include-runtime script.js`.
1687
1688 return exports;
1689 }( // If this script is executing as a CommonJS module, use module.exports
1690 // as the regeneratorRuntime namespace. Otherwise create a new empty
1691 // object. Either way, the resulting object will be used to initialize
1692 // the regeneratorRuntime variable at the top of this file.
1693 ( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
1694
1695 try {
1696 regeneratorRuntime = runtime;
1697 } catch (accidentalStrictMode) {
1698 // This module should not be running in strict mode, so the above
1699 // assignment should always work unless something is misconfigured. Just
1700 // in case runtime.js accidentally runs in strict mode, we can escape
1701 // strict mode using a global Function call. This could conceivably fail
1702 // if a Content Security Policy forbids using Function, but in that case
1703 // the proper solution is to fix the accidental strict mode problem. If
1704 // you've misconfigured your bundler to force strict mode and applied a
1705 // CSP to forbid Function, and you're not willing to fix either of those
1706 // problems, please detail your unique predicament in a GitHub issue.
1707 Function("r", "regeneratorRuntime = r")(runtime);
1708 }
1709 /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
1710
1711 /***/ }),
1712
1713 /***/ "./node_modules/webpack/buildin/module.js":
1714 /*!***********************************!*\
1715 !*** (webpack)/buildin/module.js ***!
1716 \***********************************/
1717 /*! no static exports found */
1718 /***/ (function(module, exports) {
1719
1720 module.exports = function (module) {
1721 if (!module.webpackPolyfill) {
1722 module.deprecate = function () {};
1723
1724 module.paths = []; // module.parent = undefined by default
1725
1726 if (!module.children) module.children = [];
1727 Object.defineProperty(module, "loaded", {
1728 enumerable: true,
1729 get: function get() {
1730 return module.l;
1731 }
1732 });
1733 Object.defineProperty(module, "id", {
1734 enumerable: true,
1735 get: function get() {
1736 return module.i;
1737 }
1738 });
1739 module.webpackPolyfill = 1;
1740 }
1741
1742 return module;
1743 };
1744
1745 /***/ })
1746
1747 /******/ });
1748 //# sourceMappingURL=scripts.js.map