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