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