scripts.js
5 years ago
scripts.js.map
5 years ago
scripts_admin.js
5 years ago
scripts_admin_all_pages.js
5 years ago
scripts_es6.js
5 years ago
scripts.js
4019 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 = 0); |
| 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_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js"); |
| 99 | /* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__); |
| 100 | /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"); |
| 101 | /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__); |
| 102 | /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"); |
| 103 | /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__); |
| 104 | /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); |
| 105 | /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__); |
| 106 | /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"); |
| 107 | /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_4__); |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
| 117 | |
| 118 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
| 119 | |
| 120 | var cf7signature_resized = 0; // for compatibility with contact-form-7-signature-addon |
| 121 | |
| 122 | var wpcf7cf_timeout; |
| 123 | var wpcf7cf_change_time_ms = 100; |
| 124 | |
| 125 | if (window.wpcf7 && !wpcf7.setStatus) { |
| 126 | wpcf7.setStatus = function (form, status) { |
| 127 | form = form.length ? form[0] : form; // if form is a jQuery object, only grab te html-element |
| 128 | |
| 129 | var defaultStatuses = new Map([// 0: Status in API response, 1: Status in HTML class |
| 130 | ['init', 'init'], ['validation_failed', 'invalid'], ['acceptance_missing', 'unaccepted'], ['spam', 'spam'], ['aborted', 'aborted'], ['mail_sent', 'sent'], ['mail_failed', 'failed'], ['submitting', 'submitting'], ['resetting', 'resetting']]); |
| 131 | |
| 132 | if (defaultStatuses.has(status)) { |
| 133 | status = defaultStatuses.get(status); |
| 134 | } |
| 135 | |
| 136 | if (!Array.from(defaultStatuses.values()).includes(status)) { |
| 137 | status = status.replace(/[^0-9a-z]+/i, ' ').trim(); |
| 138 | status = status.replace(/\s+/, '-'); |
| 139 | status = "custom-".concat(status); |
| 140 | } |
| 141 | |
| 142 | var prevStatus = form.getAttribute('data-status'); |
| 143 | form.wpcf7.status = status; |
| 144 | form.setAttribute('data-status', status); |
| 145 | form.classList.add(status); |
| 146 | |
| 147 | if (prevStatus && prevStatus !== status) { |
| 148 | form.classList.remove(prevStatus); |
| 149 | } |
| 150 | |
| 151 | return status; |
| 152 | }; |
| 153 | } |
| 154 | |
| 155 | if (window.wpcf7cf_running_tests) { |
| 156 | jQuery('input[name="_wpcf7cf_options"]').each(function (e) { |
| 157 | var $input = jQuery(this); |
| 158 | var opt = JSON.parse($input.val()); |
| 159 | opt.settings.animation_intime = 0; |
| 160 | opt.settings.animation_outtime = 0; |
| 161 | $input.val(JSON.stringify(opt)); |
| 162 | }); |
| 163 | wpcf7cf_change_time_ms = 0; |
| 164 | } |
| 165 | |
| 166 | var wpcf7cf_show_animation = { |
| 167 | "height": "show", |
| 168 | "marginTop": "show", |
| 169 | "marginBottom": "show", |
| 170 | "paddingTop": "show", |
| 171 | "paddingBottom": "show" |
| 172 | }; |
| 173 | var wpcf7cf_hide_animation = { |
| 174 | "height": "hide", |
| 175 | "marginTop": "hide", |
| 176 | "marginBottom": "hide", |
| 177 | "paddingTop": "hide", |
| 178 | "paddingBottom": "hide" |
| 179 | }; |
| 180 | var wpcf7cf_show_step_animation = { |
| 181 | "opacity": "show" |
| 182 | }; |
| 183 | var wpcf7cf_hide_step_animation = { |
| 184 | "opacity": "hide" |
| 185 | }; |
| 186 | var wpcf7cf_change_events = 'input.wpcf7cf paste.wpcf7cf change.wpcf7cf click.wpcf7cf propertychange.wpcf7cf'; |
| 187 | var wpcf7cf_forms = []; |
| 188 | window.wpcf7cf_dom = {}; |
| 189 | |
| 190 | var wpcf7cf_reload_dom = function wpcf7cf_reload_dom($form) { |
| 191 | wpcf7cf_dom = wpcf7cf.get_simplified_dom_model($form[0]); |
| 192 | }; |
| 193 | |
| 194 | var wpcf7cf_getFieldsByOriginalName = function wpcf7cf_getFieldsByOriginalName(originalName) { |
| 195 | return Object.values(wpcf7cf_dom).filter(function (inputField) { |
| 196 | return inputField.original_name === originalName || inputField.original_name === originalName + '[]'; |
| 197 | }); |
| 198 | }; |
| 199 | |
| 200 | var wpcf7cf_getFieldByName = function wpcf7cf_getFieldByName(name) { |
| 201 | return wpcf7cf_dom[name] || wpcf7cf_dom[name + '[]']; |
| 202 | }; // endsWith polyfill |
| 203 | |
| 204 | |
| 205 | if (!String.prototype.endsWith) { |
| 206 | String.prototype.endsWith = function (search, this_len) { |
| 207 | if (this_len === undefined || this_len > this.length) { |
| 208 | this_len = this.length; |
| 209 | } |
| 210 | |
| 211 | return this.substring(this_len - search.length, this_len) === search; |
| 212 | }; |
| 213 | } // Object.values polyfill |
| 214 | |
| 215 | |
| 216 | if (!Object.values) Object.values = function (o) { |
| 217 | return Object.keys(o).map(function (k) { |
| 218 | return o[k]; |
| 219 | }); |
| 220 | }; // Array.from polyfill |
| 221 | |
| 222 | if (!Array.from) { |
| 223 | Array.from = function () { |
| 224 | var toStr = Object.prototype.toString; |
| 225 | |
| 226 | var isCallable = function isCallable(fn) { |
| 227 | return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; |
| 228 | }; |
| 229 | |
| 230 | var toInteger = function toInteger(value) { |
| 231 | var number = Number(value); |
| 232 | |
| 233 | if (isNaN(number)) { |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | if (number === 0 || !isFinite(number)) { |
| 238 | return number; |
| 239 | } |
| 240 | |
| 241 | return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); |
| 242 | }; |
| 243 | |
| 244 | var maxSafeInteger = Math.pow(2, 53) - 1; |
| 245 | |
| 246 | var toLength = function toLength(value) { |
| 247 | var len = toInteger(value); |
| 248 | return Math.min(Math.max(len, 0), maxSafeInteger); |
| 249 | }; // The length property of the from method is 1. |
| 250 | |
| 251 | |
| 252 | return function from(arrayLike |
| 253 | /*, mapFn, thisArg */ |
| 254 | ) { |
| 255 | // 1. Let C be the this value. |
| 256 | var C = this; // 2. Let items be ToObject(arrayLike). |
| 257 | |
| 258 | var items = Object(arrayLike); // 3. ReturnIfAbrupt(items). |
| 259 | |
| 260 | if (arrayLike == null) { |
| 261 | throw new TypeError("Array.from requires an array-like object - not null or undefined"); |
| 262 | } // 4. If mapfn is undefined, then let mapping be false. |
| 263 | |
| 264 | |
| 265 | var mapFn = arguments.length > 1 ? arguments[1] : void undefined; |
| 266 | var T; |
| 267 | |
| 268 | if (typeof mapFn !== 'undefined') { |
| 269 | // 5. else |
| 270 | // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. |
| 271 | if (!isCallable(mapFn)) { |
| 272 | throw new TypeError('Array.from: when provided, the second argument must be a function'); |
| 273 | } // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. |
| 274 | |
| 275 | |
| 276 | if (arguments.length > 2) { |
| 277 | T = arguments[2]; |
| 278 | } |
| 279 | } // 10. Let lenValue be Get(items, "length"). |
| 280 | // 11. Let len be ToLength(lenValue). |
| 281 | |
| 282 | |
| 283 | var len = toLength(items.length); // 13. If IsConstructor(C) is true, then |
| 284 | // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len. |
| 285 | // 14. a. Else, Let A be ArrayCreate(len). |
| 286 | |
| 287 | var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0. |
| 288 | |
| 289 | var k = 0; // 17. Repeat, while k < len… (also steps a - h) |
| 290 | |
| 291 | var kValue; |
| 292 | |
| 293 | while (k < len) { |
| 294 | kValue = items[k]; |
| 295 | |
| 296 | if (mapFn) { |
| 297 | A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); |
| 298 | } else { |
| 299 | A[k] = kValue; |
| 300 | } |
| 301 | |
| 302 | k += 1; |
| 303 | } // 18. Let putStatus be Put(A, "length", len, true). |
| 304 | |
| 305 | |
| 306 | A.length = len; // 20. Return A. |
| 307 | |
| 308 | return A; |
| 309 | }; |
| 310 | }(); |
| 311 | } |
| 312 | |
| 313 | var Wpcf7cfForm = function Wpcf7cfForm($form) { |
| 314 | var options_element = $form.find('input[name="_wpcf7cf_options"]').eq(0); |
| 315 | |
| 316 | if (!options_element.length || !options_element.val()) { |
| 317 | // doesn't look like a CF7 form created with conditional fields plugin enabled. |
| 318 | return false; |
| 319 | } |
| 320 | |
| 321 | var form = this; |
| 322 | var form_options = JSON.parse(options_element.val()); |
| 323 | form.$form = $form; |
| 324 | form.$input_hidden_group_fields = $form.find('[name="_wpcf7cf_hidden_group_fields"]'); |
| 325 | form.$input_hidden_groups = $form.find('[name="_wpcf7cf_hidden_groups"]'); |
| 326 | form.$input_visible_groups = $form.find('[name="_wpcf7cf_visible_groups"]'); |
| 327 | form.$input_repeaters = $form.find('[name="_wpcf7cf_repeaters"]'); |
| 328 | form.$input_steps = $form.find('[name="_wpcf7cf_steps"]'); |
| 329 | form.unit_tag = $form.closest('.wpcf7').attr('id'); |
| 330 | form.conditions = form_options['conditions']; // Wrapper around jQuery(selector, form.$form) |
| 331 | |
| 332 | form.get = function (selector) { |
| 333 | // TODO: implement some caching here. |
| 334 | return jQuery(selector, form.$form); |
| 335 | }; // compatibility with conditional forms created with older versions of the plugin ( < 1.4 ) |
| 336 | |
| 337 | |
| 338 | for (var i = 0; i < form.conditions.length; i++) { |
| 339 | var condition = form.conditions[i]; |
| 340 | |
| 341 | if (!('and_rules' in condition)) { |
| 342 | condition.and_rules = [{ |
| 343 | 'if_field': condition.if_field, |
| 344 | 'if_value': condition.if_value, |
| 345 | 'operator': condition.operator |
| 346 | }]; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | form.initial_conditions = form.conditions; |
| 351 | form.settings = form_options['settings']; |
| 352 | form.$groups = jQuery(); // empty jQuery set |
| 353 | |
| 354 | form.repeaters = []; |
| 355 | form.multistep = null; |
| 356 | form.fields = []; |
| 357 | form.settings.animation_intime = parseInt(form.settings.animation_intime); |
| 358 | form.settings.animation_outtime = parseInt(form.settings.animation_outtime); |
| 359 | |
| 360 | if (form.settings.animation === 'no') { |
| 361 | form.settings.animation_intime = 0; |
| 362 | form.settings.animation_outtime = 0; |
| 363 | } |
| 364 | |
| 365 | form.updateGroups(); |
| 366 | form.updateEventListeners(); |
| 367 | form.displayFields(); // bring form in initial state if the reset event is fired on it. |
| 368 | |
| 369 | form.$form.on('reset.wpcf7cf', form, function (e) { |
| 370 | var form = e.data; |
| 371 | setTimeout(function () { |
| 372 | form.displayFields(); |
| 373 | form.resetRepeaters(); |
| 374 | |
| 375 | if (form.multistep != null) { |
| 376 | form.multistep.moveToStep(1); |
| 377 | } |
| 378 | }, 200); |
| 379 | }); // PRO ONLY |
| 380 | |
| 381 | form.get('.wpcf7cf_repeater:not(.wpcf7cf_repeater .wpcf7cf_repeater)').each(function () { |
| 382 | form.repeaters.push(new Wpcf7cfRepeater(jQuery(this), form)); |
| 383 | }); |
| 384 | form.$input_repeaters.val(JSON.stringify(form.repeaters.map(function (item) { |
| 385 | return item.params.$repeater.id; |
| 386 | }))); |
| 387 | var $multistep = form.get('.wpcf7cf_multistep'); |
| 388 | |
| 389 | if ($multistep.length) { |
| 390 | form.multistep = new Wpcf7cfMultistep($multistep, form); // window.wpcf7cf.updateMultistepState(form.multistep); |
| 391 | } // END PRO ONLY |
| 392 | |
| 393 | }; |
| 394 | /** |
| 395 | * reset initial number of subs for each repeater. |
| 396 | * (does not clear values) |
| 397 | */ |
| 398 | |
| 399 | |
| 400 | Wpcf7cfForm.prototype.resetRepeaters = function () { |
| 401 | var form = this; |
| 402 | form.repeaters.forEach(function (repeater) { |
| 403 | repeater.updateSubs(repeater.params.$repeater.initial_subs); |
| 404 | }); |
| 405 | }; |
| 406 | |
| 407 | Wpcf7cfForm.prototype.displayFields = function () { |
| 408 | var form = this; |
| 409 | var wpcf7cf_conditions = this.conditions; |
| 410 | var wpcf7cf_settings = this.settings; //for compatibility with contact-form-7-signature-addon |
| 411 | |
| 412 | if (cf7signature_resized === 0 && typeof signatures !== 'undefined' && signatures.constructor === Array && signatures.length > 0) { |
| 413 | for (var i = 0; i < signatures.length; i++) { |
| 414 | if (signatures[i].canvas.width === 0) { |
| 415 | var $sig_canvas = jQuery(".wpcf7-form-control-signature-body>canvas"); |
| 416 | var $sig_wrap = jQuery(".wpcf7-form-control-signature-wrap"); |
| 417 | $sig_canvas.eq(i).attr('width', $sig_wrap.width()); |
| 418 | $sig_canvas.eq(i).attr('height', $sig_wrap.height()); |
| 419 | cf7signature_resized = 1; |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | form.$groups.addClass('wpcf7cf-hidden'); |
| 425 | wpcf7cf_reload_dom(form.$form); |
| 426 | |
| 427 | for (var i = 0; i < wpcf7cf_conditions.length; i++) { |
| 428 | var condition = wpcf7cf_conditions[i]; |
| 429 | var show_group = window.wpcf7cf.should_group_be_shown(condition, form); |
| 430 | |
| 431 | if (show_group) { |
| 432 | form.get('[data-id="' + condition.then_field + '"]').removeClass('wpcf7cf-hidden'); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | var animation_intime = wpcf7cf_settings.animation_intime; |
| 437 | var animation_outtime = wpcf7cf_settings.animation_outtime; |
| 438 | form.$groups.each(function (index) { |
| 439 | var $group = jQuery(this); |
| 440 | |
| 441 | if ($group.is(':animated')) { |
| 442 | $group.finish(); // stop any current animations on the group |
| 443 | } |
| 444 | |
| 445 | if ($group.css('display') === 'none' && !$group.hasClass('wpcf7cf-hidden')) { |
| 446 | if ($group.prop('tagName') === 'SPAN') { |
| 447 | $group.show().trigger('wpcf7cf_show_group'); // show instantly |
| 448 | } else { |
| 449 | $group.animate(wpcf7cf_show_animation, animation_intime).trigger('wpcf7cf_show_group'); // show with animation |
| 450 | } |
| 451 | |
| 452 | if ($group.attr('data-disable_on_hide') !== undefined) { |
| 453 | $group.find(':input').prop('disabled', false); |
| 454 | } |
| 455 | } else if ($group.css('display') !== 'none' && $group.hasClass('wpcf7cf-hidden')) { |
| 456 | if ($group.attr('data-clear_on_hide') !== undefined) { |
| 457 | var $inputs = jQuery(':input', $group).not(':button, :submit, :reset, :hidden'); |
| 458 | $inputs.each(function () { |
| 459 | var $this = jQuery(this); |
| 460 | $this.val(this.defaultValue); |
| 461 | $this.prop('checked', this.defaultChecked); |
| 462 | }); |
| 463 | jQuery('option', $group).each(function () { |
| 464 | this.selected = this.defaultSelected; |
| 465 | }); |
| 466 | jQuery('select', $group).each(function () { |
| 467 | var $select = jQuery(this); |
| 468 | |
| 469 | if ($select.val() === null) { |
| 470 | $select.val(jQuery("option:first", $select).val()); |
| 471 | } |
| 472 | }); |
| 473 | $inputs.trigger('change'); |
| 474 | } |
| 475 | |
| 476 | if ($group.prop('tagName') === 'SPAN') { |
| 477 | $group.hide().trigger('wpcf7cf_hide_group'); |
| 478 | } else { |
| 479 | $group.animate(wpcf7cf_hide_animation, animation_outtime).trigger('wpcf7cf_hide_group'); // hide |
| 480 | } |
| 481 | } |
| 482 | }); |
| 483 | form.updateHiddenFields(); |
| 484 | form.updateSummaryFields(); |
| 485 | }; |
| 486 | |
| 487 | Wpcf7cfForm.prototype.updateSummaryFields = function () { |
| 488 | var form = this; |
| 489 | var $summary = form.get('.wpcf7cf-summary'); |
| 490 | if ($summary.length == 0 || !$summary.is(':visible')) return; |
| 491 | var fd = new FormData(); |
| 492 | var formdata = form.$form.serializeArray(); |
| 493 | jQuery.each(formdata, function (key, input) { |
| 494 | fd.append(input.name, input.value); |
| 495 | }); // Make sure to add file fields to FormData |
| 496 | |
| 497 | jQuery.each(form.$form.find('input[type="file"]'), function (index, el) { |
| 498 | if (!el.files.length) return true; // continue |
| 499 | |
| 500 | var fieldName = el.name; |
| 501 | fd.append(fieldName, new Blob(), Array.from(el.files).map(function (file) { |
| 502 | return file.name; |
| 503 | }).join(', ')); |
| 504 | }); // add file fields to form-data |
| 505 | |
| 506 | jQuery.ajax({ |
| 507 | url: wpcf7cf_global_settings.ajaxurl + '?action=wpcf7cf_get_summary', |
| 508 | type: 'POST', |
| 509 | data: fd, |
| 510 | processData: false, |
| 511 | contentType: false, |
| 512 | dataType: 'json', |
| 513 | success: function success(json) { |
| 514 | $summary.html(json.summaryHtml); |
| 515 | } |
| 516 | }); |
| 517 | }; |
| 518 | |
| 519 | Wpcf7cfForm.prototype.updateHiddenFields = function () { |
| 520 | var form = this; |
| 521 | var hidden_fields = []; |
| 522 | var hidden_groups = []; |
| 523 | var visible_groups = []; |
| 524 | var disabled_fields = []; |
| 525 | form.$groups.each(function () { |
| 526 | var $group = jQuery(this); |
| 527 | |
| 528 | if ($group.hasClass('wpcf7cf-hidden')) { |
| 529 | hidden_groups.push($group.attr('data-id')); |
| 530 | $group.find('input,select,textarea').each(function () { |
| 531 | hidden_fields.push(jQuery(this).attr('name')); |
| 532 | }); |
| 533 | |
| 534 | if ($group.attr('data-disable_on_hide') !== undefined) { |
| 535 | console.log('disabling'); |
| 536 | $group.find(':input').prop('disabled', true); |
| 537 | } |
| 538 | } else { |
| 539 | visible_groups.push($group.attr('data-id')); |
| 540 | } |
| 541 | }); |
| 542 | form.hidden_fields = hidden_fields; |
| 543 | form.hidden_groups = hidden_groups; |
| 544 | form.visible_groups = visible_groups; |
| 545 | form.$input_hidden_group_fields.val(JSON.stringify(hidden_fields)); |
| 546 | form.$input_hidden_groups.val(JSON.stringify(hidden_groups)); |
| 547 | form.$input_visible_groups.val(JSON.stringify(visible_groups)); |
| 548 | return true; |
| 549 | }; |
| 550 | |
| 551 | Wpcf7cfForm.prototype.updateGroups = function () { |
| 552 | var form = this; |
| 553 | form.$groups = form.$form.find('[data-class="wpcf7cf_group"]'); |
| 554 | form.conditions = window.wpcf7cf.get_nested_conditions(form.initial_conditions, form.$form); |
| 555 | }; |
| 556 | |
| 557 | Wpcf7cfForm.prototype.updateEventListeners = function () { |
| 558 | var form = this; // monitor input changes, and call displayFields() if something has changed |
| 559 | |
| 560 | form.get('input, select, textarea, button').not('.wpcf7cf_add, .wpcf7cf_remove').off(wpcf7cf_change_events).on(wpcf7cf_change_events, form, function (e) { |
| 561 | var form = e.data; |
| 562 | clearTimeout(wpcf7cf_timeout); |
| 563 | wpcf7cf_timeout = setTimeout(function () { |
| 564 | form.displayFields(); |
| 565 | }, wpcf7cf_change_time_ms); |
| 566 | }); // PRO ONLY |
| 567 | |
| 568 | form.get('.wpcf7cf-togglebutton').off('click.toggle_wpcf7cf').on('click.toggle_wpcf7cf', function () { |
| 569 | var $this = jQuery(this); |
| 570 | |
| 571 | if ($this.text() === $this.attr('data-val-1')) { |
| 572 | $this.text($this.attr('data-val-2')); |
| 573 | $this.val($this.attr('data-val-2')); |
| 574 | } else { |
| 575 | $this.text($this.attr('data-val-1')); |
| 576 | $this.val($this.attr('data-val-1')); |
| 577 | } |
| 578 | }); // END PRO ONLY |
| 579 | }; // PRO ONLY |
| 580 | |
| 581 | |
| 582 | function Wpcf7cfRepeater($repeater, form) { |
| 583 | var $ = jQuery; |
| 584 | var repeater = this; |
| 585 | var wpcf7cf_settings = form.settings; |
| 586 | repeater.form = form; |
| 587 | $repeater.parentRepeaters = Array.from($repeater.parents('.wpcf7cf_repeater').map(function () { |
| 588 | return this.getAttribute('data-id'); |
| 589 | })).reverse(); |
| 590 | $repeater.num_subs = 0; |
| 591 | $repeater.id = $repeater.attr('data-id'); |
| 592 | $repeater.orig_id = $repeater.attr('data-orig_data_id'); |
| 593 | $repeater.min = typeof $repeater.attr('data-min') !== 'undefined' ? parseInt($repeater.attr('data-min')) : 1; |
| 594 | $repeater.max = typeof $repeater.attr('data-max') !== 'undefined' ? parseInt($repeater.attr('data-max')) : 200; |
| 595 | $repeater.initial_subs = typeof $repeater.attr('data-initial') !== 'undefined' ? parseInt($repeater.attr('data-initial')) : $repeater.min; |
| 596 | if ($repeater.initial_subs > $repeater.max) $repeater.initial_subs = $repeater.max; |
| 597 | var $repeater_sub = $repeater.children('.wpcf7cf_repeater_sub').eq(0); |
| 598 | var $repeater_controls = $repeater.children('.wpcf7cf_repeater_controls').eq(0); |
| 599 | var $repeater_sub_clone = $repeater_sub.clone(); |
| 600 | $repeater_sub_clone.find('.wpcf7cf_repeater_sub').addBack('.wpcf7cf_repeater_sub').each(function () { |
| 601 | var $this = jQuery(this); |
| 602 | var prev_suffix = $this.attr('data-repeater_sub_suffix'); |
| 603 | var new_suffix = prev_suffix + '__{{repeater_sub_suffix}}'; |
| 604 | $this.attr('data-repeater_sub_suffix', new_suffix); |
| 605 | }); |
| 606 | $repeater_sub_clone.find('[name]').each(function () { |
| 607 | var $this = jQuery(this); |
| 608 | var prev_name = $this.attr('name'); |
| 609 | var new_name = repeater.getNewName(prev_name); |
| 610 | var orig_name = $this.attr('data-orig_name') != null ? $this.attr('data-orig_name') : prev_name; |
| 611 | $this.attr('name', new_name); |
| 612 | $this.attr('data-orig_name', orig_name); |
| 613 | $this.closest('.wpcf7-form-control-wrap').addClass(new_name.replace('[]', '')); |
| 614 | }); |
| 615 | $repeater_sub_clone.find('.wpcf7cf_repeater,[data-class="wpcf7cf_group"]').each(function () { |
| 616 | var $this = jQuery(this); |
| 617 | var prev_data_id = $this.attr('data-id'); |
| 618 | var orig_data_id = $this.attr('data-orig_data_id') != null ? $this.attr('data-orig_data_id') : prev_data_id; |
| 619 | var new_data_id = repeater.getNewName(prev_data_id); |
| 620 | |
| 621 | if (prev_data_id.endsWith('_count')) { |
| 622 | new_data_id = prev_data_id.replace('_count', '__{{repeater_sub_suffix}}_count'); |
| 623 | } |
| 624 | |
| 625 | $this.attr('data-id', new_data_id); |
| 626 | $this.attr('data-orig_data_id', orig_data_id); |
| 627 | }); |
| 628 | $repeater_sub_clone.find('[id]').each(function () { |
| 629 | var $this = jQuery(this); |
| 630 | var prev_id = $this.attr('id'); |
| 631 | var orig_id = $this.attr('data-orig_id') != null ? $this.attr('data-orig_id') : prev_id; |
| 632 | var new_id = repeater.getNewName(prev_id); |
| 633 | $this.attr('id', new_id); |
| 634 | $this.attr('data-orig_id', orig_id); |
| 635 | }); |
| 636 | $repeater_sub_clone.find('[for]').each(function () { |
| 637 | var $this = jQuery(this); |
| 638 | var prev_for = $this.attr('for'); |
| 639 | var orig_for = $this.attr('data-orig_for') != null ? $this.attr('data-orig_for') : prev_for; |
| 640 | var new_for = repeater.getNewName(prev_for); |
| 641 | $this.attr('for', new_for); |
| 642 | $this.attr('data-orig_for', orig_for); |
| 643 | }); |
| 644 | var repeater_sub_html = $repeater_sub_clone[0].outerHTML; |
| 645 | var $repeater_count_field = $repeater.find('[name=' + $repeater.id + '_count]').eq(0); |
| 646 | var $button_add = $repeater_controls.find('.wpcf7cf_add').eq(0); |
| 647 | var $button_remove = $repeater_controls.find('.wpcf7cf_remove').eq(0); |
| 648 | var params = { |
| 649 | $repeater: $repeater, |
| 650 | $repeater_count_field: $repeater_count_field, |
| 651 | repeater_sub_html: repeater_sub_html, |
| 652 | $repeater_controls: $repeater_controls, |
| 653 | $button_add: $button_add, |
| 654 | $button_remove: $button_remove, |
| 655 | wpcf7cf_settings: wpcf7cf_settings |
| 656 | }; |
| 657 | this.params = params; |
| 658 | $button_add.on('click', null, repeater, function (e) { |
| 659 | var repeater = e.data; |
| 660 | repeater.updateSubs(params.$repeater.num_subs + 1); |
| 661 | }); |
| 662 | $button_remove.on('click', null, repeater, function (e) { |
| 663 | var repeater = e.data; |
| 664 | repeater.updateSubs(params.$repeater.num_subs - 1); |
| 665 | }); |
| 666 | jQuery('> .wpcf7cf_repeater_sub', params.$repeater).eq(0).remove(); // remove the first sub, it's just a template. |
| 667 | |
| 668 | repeater.updateSubs($repeater.initial_subs); |
| 669 | repeater.updateButtons(); |
| 670 | } |
| 671 | |
| 672 | Wpcf7cfRepeater.prototype.getNewName = function (previousName) { |
| 673 | var prev_parts = previousName.split('['); |
| 674 | previousName = prev_parts[0]; |
| 675 | var prev_suff = prev_parts.length > 1 ? '[' + prev_parts.splice(1).join('[') : ''; |
| 676 | var newName = previousName + '__{{repeater_sub_suffix}}' + prev_suff; |
| 677 | |
| 678 | if (previousName.endsWith('_count')) { |
| 679 | newName = previousName.replace('_count', '__{{repeater_sub_suffix}}_count'); |
| 680 | } |
| 681 | |
| 682 | return newName; |
| 683 | }; |
| 684 | |
| 685 | Wpcf7cfRepeater.prototype.updateButtons = function () { |
| 686 | var repeater = this; |
| 687 | var params = repeater.params; |
| 688 | var num_subs = params.$repeater.num_subs; |
| 689 | var showButtonRemove = false; |
| 690 | var showButtonAdd = false; |
| 691 | |
| 692 | if (params.$repeater.num_subs < params.$repeater.max) { |
| 693 | showButtonAdd = true; |
| 694 | } |
| 695 | |
| 696 | if (params.$repeater.num_subs > params.$repeater.min) { |
| 697 | showButtonRemove = true; |
| 698 | } |
| 699 | |
| 700 | if (showButtonAdd) { |
| 701 | params.$button_add.show(); |
| 702 | } else { |
| 703 | params.$button_add.hide(); |
| 704 | } |
| 705 | |
| 706 | if (showButtonRemove) { |
| 707 | params.$button_remove.show(); |
| 708 | } else { |
| 709 | params.$button_remove.hide(); |
| 710 | } |
| 711 | |
| 712 | params.$repeater_count_field.val(num_subs); |
| 713 | }; |
| 714 | |
| 715 | Wpcf7cfRepeater.prototype.updateSubs = function (subs_to_show) { |
| 716 | var repeater = this; |
| 717 | var params = repeater.params; // make sure subs_to_show is a valid number |
| 718 | |
| 719 | subs_to_show = subs_to_show < params.$repeater.min ? params.$repeater.min : subs_to_show; |
| 720 | subs_to_show = subs_to_show > params.$repeater.max ? params.$repeater.max : subs_to_show; |
| 721 | var subs_to_add = subs_to_show - params.$repeater.num_subs; |
| 722 | |
| 723 | if (subs_to_add < 0) { |
| 724 | repeater.removeSubs(-subs_to_add); |
| 725 | } else if (subs_to_add > 0) { |
| 726 | repeater.addSubs(subs_to_add); |
| 727 | } |
| 728 | }; |
| 729 | /** |
| 730 | * add Subs to repeater |
| 731 | * @param {Number} subs_to_add |
| 732 | * @param {Number} index - zero-based. leave blank (or null) to append at the end |
| 733 | */ |
| 734 | |
| 735 | |
| 736 | Wpcf7cfRepeater.prototype.addSubs = function (subs_to_add) { |
| 737 | var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 738 | var $ = jQuery; |
| 739 | var params = this.params; |
| 740 | var repeater = this; |
| 741 | var form = repeater.form; |
| 742 | var $repeater = params.$repeater; |
| 743 | var $repeater_controls = params.$repeater_controls; |
| 744 | |
| 745 | if (subs_to_add + $repeater.num_subs > $repeater.max) { |
| 746 | subs_to_add = $repeater.max - $repeater.num_subs; |
| 747 | } |
| 748 | |
| 749 | var html_str = ''; |
| 750 | |
| 751 | for (var i = 1; i <= subs_to_add; i++) { |
| 752 | var sub_suffix = $repeater.num_subs + i; |
| 753 | html_str += params.repeater_sub_html.replace(/\{\{repeater_sub_suffix\}\}/g, sub_suffix).replace(new RegExp('\{\{' + $repeater.orig_id + '_index\}\}', 'g'), '<span class="wpcf7cf-index wpcf7cf__' + $repeater.orig_id + '">' + sub_suffix + '</span>'); |
| 754 | } |
| 755 | |
| 756 | var $html = jQuery(html_str); |
| 757 | jQuery('> .wpcf7cf_repeater_sub', $repeater).finish(); // finish any currently running animations immediately. |
| 758 | // Add the newly created fields to the form |
| 759 | |
| 760 | if (index === null) { |
| 761 | $html.hide().insertBefore($repeater_controls).animate(wpcf7cf_show_animation, params.wpcf7cf_settings.animation_intime).trigger('wpcf7cf_repeater_added'); |
| 762 | } else { |
| 763 | $html.hide().insertBefore(jQuery('> .wpcf7cf_repeater_sub', $repeater).eq(index)).animate(wpcf7cf_show_animation, params.wpcf7cf_settings.animation_intime).trigger('wpcf7cf_repeater_added'); |
| 764 | } |
| 765 | |
| 766 | jQuery('.wpcf7cf_repeater', $html).each(function () { |
| 767 | form.repeaters.push(new Wpcf7cfRepeater(jQuery(this), form)); |
| 768 | }); |
| 769 | form.$input_repeaters.val(JSON.stringify(form.repeaters.map(function (item) { |
| 770 | return item.params.$repeater.id; |
| 771 | }))); |
| 772 | $repeater.num_subs += subs_to_add; |
| 773 | |
| 774 | if (index !== null) { |
| 775 | repeater.updateSuffixes(); |
| 776 | } |
| 777 | |
| 778 | window.wpcf7cf.updateMultistepState(form.multistep); |
| 779 | form.updateGroups(); |
| 780 | form.updateEventListeners(); |
| 781 | form.displayFields(); |
| 782 | repeater.updateButtons(); // Exclusive Checkbox |
| 783 | |
| 784 | $html.on('click', '.wpcf7-exclusive-checkbox input:checkbox', function () { |
| 785 | var name = $(this).attr('name'); |
| 786 | $html.find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false); |
| 787 | }); //basic compatibility with material-design-for-contact-form-7 |
| 788 | |
| 789 | if (typeof window.cf7mdInit === "function") { |
| 790 | window.cf7mdInit(); |
| 791 | } |
| 792 | |
| 793 | return false; |
| 794 | }; |
| 795 | /** TODO: implement this */ |
| 796 | |
| 797 | |
| 798 | Wpcf7cfRepeater.prototype.updateSuffixes = function () { |
| 799 | // Loop trough all subs |
| 800 | // -- 1. update all fields, groups and repeaters names, id's, for's, ... |
| 801 | // -- 2. loop trough all repeaters |
| 802 | // -- update sub_html template for nested repeater |
| 803 | // -- call updateSuffixes() for nested repeater |
| 804 | var $repeater = this.params.$repeater; |
| 805 | var num_subs = this.params.$repeater.num_subs; |
| 806 | var form = this.form; |
| 807 | var orig_id = $repeater.attr('data-orig_data_id'); |
| 808 | var repeater_id = $repeater.attr('data-id'); |
| 809 | var repeater_suffix = repeater_id.replace(orig_id, ''); |
| 810 | var simplifiedDomArray = Object.values(wpcf7cf.get_simplified_dom_model(form.$form[0])); |
| 811 | |
| 812 | var _loop = function _loop(i) { |
| 813 | var $sub = jQuery('> .wpcf7cf_repeater_sub', $repeater).eq(i); |
| 814 | var newIndex = i + 1; |
| 815 | var currentSuffix = $sub.attr('data-repeater_sub_suffix'); |
| 816 | var newSuffix = repeater_suffix + '__' + newIndex; |
| 817 | $sub.attr('data-repeater_sub_suffix', newSuffix); // update sub attr |
| 818 | |
| 819 | $sub.find('.wpcf7cf__' + orig_id).html(newIndex); // update {{r_index}} parts |
| 820 | |
| 821 | simplifiedDomArray.forEach(function (el) { |
| 822 | if (el.suffix !== currentSuffix) return; // TODO: may need an extra check to verify that the element is inside the current repeater |
| 823 | // (orig_id) . Otherwise problems may occur if there are repeaters on the same level. |
| 824 | |
| 825 | var newName = el.name.replace(currentSuffix, newSuffix); |
| 826 | var pureElName = el.name.replace('[]', ''); |
| 827 | var pureNewName = newName.replace('[]', ''); |
| 828 | jQuery('[name="' + el.name + '"]', $sub).attr('name', newName); |
| 829 | jQuery('[id="' + el.name + '"]', $sub).attr('id', newName); |
| 830 | jQuery('label[for="' + el.name + '"]', $sub).attr('for', newName); |
| 831 | var $nested_repeater = jQuery('[data-id="' + el.name + '"]', $sub); |
| 832 | $nested_repeater.attr('data-id', newName); |
| 833 | jQuery('.wpcf7-form-control-wrap.' + pureElName, $sub).removeClass(pureElName).addClass(pureNewName); |
| 834 | |
| 835 | if (el.type === 'repeater') { |
| 836 | var nested_repeater = form.repeaters.find(function (repeater) { |
| 837 | return repeater.params.$repeater.get(0) === $nested_repeater.get(0); |
| 838 | }); |
| 839 | if (!nested_repeater) return; |
| 840 | nested_repeater.params.repeater_sub_html = wpcf7cf.updateRepeaterSubHTML(nested_repeater.params.repeater_sub_html, currentSuffix, newSuffix, nested_repeater.params.$repeater.parentRepeaters); |
| 841 | nested_repeater.updateSuffixes(); |
| 842 | } |
| 843 | }); |
| 844 | }; |
| 845 | |
| 846 | for (var i = 0; i < num_subs; i++) { |
| 847 | _loop(i); |
| 848 | } |
| 849 | }; |
| 850 | /** |
| 851 | * Return the parent repeaters, order is not guaranteed. |
| 852 | */ |
| 853 | |
| 854 | |
| 855 | Wpcf7cfRepeater.prototype.getParentRepeaters = function () { |
| 856 | var simplifiedDomArray = Object.values(wpcf7cf.get_simplified_dom_model(form.$form[0])); |
| 857 | form.repeaters.map(function (repeater) {}); |
| 858 | }; |
| 859 | |
| 860 | Wpcf7cfRepeater.prototype.removeSubs = function (subs_to_remove) { |
| 861 | var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 862 | var $ = jQuery; |
| 863 | var repeater = this; |
| 864 | var params = repeater.params; |
| 865 | var form = repeater.form; |
| 866 | var $repeater = params.$repeater; |
| 867 | |
| 868 | if ($repeater.num_subs - subs_to_remove < $repeater.min) { |
| 869 | subs_to_remove = $repeater.num_subs - $repeater.min; |
| 870 | } |
| 871 | |
| 872 | if (index === null) { |
| 873 | index = $repeater.num_subs - subs_to_remove; |
| 874 | } |
| 875 | |
| 876 | $repeater.num_subs -= subs_to_remove; |
| 877 | jQuery('> .wpcf7cf_repeater_sub', $repeater).finish(); // finish any currently running animations immediately. |
| 878 | |
| 879 | jQuery('> .wpcf7cf_repeater_sub', $repeater).slice(index, index + subs_to_remove).animate(wpcf7cf_hide_animation, { |
| 880 | duration: params.wpcf7cf_settings.animation_intime, |
| 881 | done: function done() { |
| 882 | var $this = jQuery(this); //remove the actual fields from the form |
| 883 | |
| 884 | $this.remove(); |
| 885 | params.$repeater.trigger('wpcf7cf_repeater_removed'); |
| 886 | window.wpcf7cf.updateMultistepState(form.multistep); |
| 887 | form.updateGroups(); |
| 888 | form.updateEventListeners(); |
| 889 | form.displayFields(); |
| 890 | repeater.updateButtons(); |
| 891 | |
| 892 | if (index !== null) { |
| 893 | repeater.updateSuffixes(); |
| 894 | } |
| 895 | } |
| 896 | }); |
| 897 | return false; |
| 898 | }; |
| 899 | |
| 900 | function Wpcf7cfMultistep($multistep, form) { |
| 901 | var multistep = this; |
| 902 | multistep.$multistep = $multistep; |
| 903 | multistep.form = form; |
| 904 | multistep.$steps = $multistep.find('.wpcf7cf_step'); |
| 905 | multistep.$btn_next = $multistep.find('.wpcf7cf_next'); |
| 906 | multistep.$btn_prev = $multistep.find('.wpcf7cf_prev'); |
| 907 | multistep.$dots = $multistep.find('.wpcf7cf_steps-dots'); |
| 908 | multistep.currentStep = 0; |
| 909 | multistep.numSteps = multistep.$steps.length; |
| 910 | multistep.$dots.html(''); |
| 911 | |
| 912 | for (var i = 1; i <= multistep.numSteps; i++) { |
| 913 | 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).attr('data-title'), "</div>\n </div>\n ")); |
| 914 | } |
| 915 | |
| 916 | multistep.$btn_next.on('click.wpcf7cf_step', /*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee() { |
| 917 | var result; |
| 918 | return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee$(_context) { |
| 919 | while (1) { |
| 920 | switch (_context.prev = _context.next) { |
| 921 | case 0: |
| 922 | multistep.$btn_next.addClass('disabled').attr('disabled', true); |
| 923 | _context.next = 3; |
| 924 | return multistep.validateStep(multistep.currentStep); |
| 925 | |
| 926 | case 3: |
| 927 | result = _context.sent; |
| 928 | |
| 929 | if (result === 'success') { |
| 930 | multistep.moveToStep(multistep.currentStep + 1); |
| 931 | } |
| 932 | |
| 933 | case 5: |
| 934 | case "end": |
| 935 | return _context.stop(); |
| 936 | } |
| 937 | } |
| 938 | }, _callee); |
| 939 | }))); // If form is submitted (by pressing Enter for example), and if we are not on the last step, |
| 940 | // then trigger click event on the $btn_next button instead. |
| 941 | |
| 942 | multistep.form.$form.on('submit.wpcf7cf_step', function (e) { |
| 943 | if (multistep.currentStep !== multistep.numSteps) { |
| 944 | multistep.$btn_next.trigger('click.wpcf7cf_step'); |
| 945 | e.stopImmediatePropagation(); |
| 946 | return false; |
| 947 | } |
| 948 | }); |
| 949 | multistep.$btn_prev.on('click', function () { |
| 950 | multistep.moveToStep(multistep.currentStep - 1); |
| 951 | }); |
| 952 | multistep.moveToStep(1); |
| 953 | } |
| 954 | |
| 955 | jQuery(document).ajaxComplete(function (e, xhr, settings) { |
| 956 | if (xhr.hasOwnProperty('responseJSON') && xhr.responseJSON != null && xhr.responseJSON.hasOwnProperty('status') && xhr.responseJSON.hasOwnProperty('into') && xhr.responseJSON.status === "mail_success") { |
| 957 | jQuery(xhr.responseJSON.into).trigger('reset.wpcf7cf'); |
| 958 | } |
| 959 | }); |
| 960 | |
| 961 | Wpcf7cfMultistep.prototype.validateStep = function (step_index) { |
| 962 | var multistep = this; |
| 963 | var $multistep = multistep.$multistep; |
| 964 | var $form = multistep.form.$form; |
| 965 | var form = multistep.form; |
| 966 | $form.find('.wpcf7-response-output').addClass('wpcf7-display-none'); |
| 967 | return new Promise(function (resolve) { |
| 968 | var fd = new FormData(); // Make sure to add file fields to FormData |
| 969 | |
| 970 | jQuery.each($form.find('[data-id="step-' + step_index + '"] input[type="file"]'), function (index, el) { |
| 971 | if (!el.files.length) return true; // = continue |
| 972 | |
| 973 | var file = el.files[0]; |
| 974 | var fieldName = el.name; |
| 975 | fd.append(fieldName, file); |
| 976 | }); |
| 977 | var formdata = $form.serializeArray(); |
| 978 | jQuery.each(formdata, function (key, input) { |
| 979 | fd.append(input.name, input.value); |
| 980 | }); |
| 981 | jQuery.ajax({ |
| 982 | url: wpcf7cf_global_settings.ajaxurl + '?action=wpcf7cf_validate_step', |
| 983 | type: 'POST', |
| 984 | data: fd, |
| 985 | processData: false, |
| 986 | contentType: false, |
| 987 | dataType: 'json' |
| 988 | }).done(function (json) { |
| 989 | $multistep.find('.wpcf7-form-control-wrap .wpcf7-not-valid-tip').remove(); |
| 990 | $multistep.find('.wpcf7-not-valid').removeClass('wpcf7-not-valid'); |
| 991 | $multistep.find('.wpcf7-response-output').remove(); |
| 992 | $multistep.find('.wpcf7-response-output.wpcf7-validation-errors').removeClass('wpcf7-validation-errors'); |
| 993 | multistep.$btn_next.removeClass('disabled').attr('disabled', false); |
| 994 | |
| 995 | if (!json.success) { |
| 996 | var checkError = 0; |
| 997 | jQuery.each(json.invalid_fields, function (index, el) { |
| 998 | 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) { |
| 999 | checkError = checkError + 1; |
| 1000 | var controlWrap = form.get('.wpcf7-form-control-wrap.' + index); |
| 1001 | controlWrap.find('.wpcf7-form-control').addClass('wpcf7-not-valid'); |
| 1002 | controlWrap.find('span.wpcf7-not-valid-tip').remove(); |
| 1003 | controlWrap.append('<span role="alert" class="wpcf7-not-valid-tip">' + el.reason + '</span>'); |
| 1004 | } |
| 1005 | }); |
| 1006 | resolve('failed'); |
| 1007 | $multistep.parent().find('.wpcf7-response-output').removeClass('wpcf7-display-none').html(json.message); |
| 1008 | wpcf7.setStatus($form, 'invalid'); |
| 1009 | multistep.$steps.trigger('wpcf7cf_step_invalid'); // wpcf7.triggerEvent( data.into, 'invalid', detail ); |
| 1010 | } else if (json.success) { |
| 1011 | wpcf7.setStatus($form, 'init'); |
| 1012 | resolve('success'); |
| 1013 | return false; |
| 1014 | } |
| 1015 | }).fail(function () { |
| 1016 | resolve('error'); |
| 1017 | }).always(function () {// do nothing |
| 1018 | }); |
| 1019 | }); |
| 1020 | }; |
| 1021 | |
| 1022 | Wpcf7cfMultistep.prototype.moveToStep = function (step_index) { |
| 1023 | var multistep = this; |
| 1024 | var previousStep = multistep.currentStep; |
| 1025 | multistep.currentStep = step_index > multistep.numSteps ? multistep.numSteps : step_index < 1 ? 1 : step_index; // ANIMATION DISABLED FOR NOW cause it's ugly |
| 1026 | // multistep.$steps.animate(wpcf7cf_hide_step_animation, multistep.form.settings.animation_outtime); |
| 1027 | // multistep.$steps.eq(multistep.currentStep-1).animate(wpcf7cf_show_step_animation, multistep.form.settings.animation_intime); |
| 1028 | |
| 1029 | multistep.$multistep.attr('data-current_step', multistep.currentStep); |
| 1030 | multistep.$steps.hide(); |
| 1031 | multistep.$steps.eq(multistep.currentStep - 1).show().trigger('wpcf7cf_change_step', [previousStep, multistep.currentStep]); |
| 1032 | var formEl = multistep.form.$form[0]; |
| 1033 | var topOffset = formEl.getBoundingClientRect().top; |
| 1034 | |
| 1035 | if (topOffset < 0 && previousStep > 0) { |
| 1036 | formEl.scrollIntoView({ |
| 1037 | behavior: "smooth" |
| 1038 | }); |
| 1039 | } |
| 1040 | |
| 1041 | multistep.form.updateSummaryFields(); |
| 1042 | window.wpcf7cf.updateMultistepState(multistep); |
| 1043 | }; |
| 1044 | |
| 1045 | Wpcf7cfMultistep.prototype.getFieldsInStep = function (step_index) { |
| 1046 | wpcf7cf_reload_dom(this.form.$form); |
| 1047 | var inStep = false; |
| 1048 | return Object.values(wpcf7cf_dom).filter(function (item, i) { |
| 1049 | if (item.type == 'step') { |
| 1050 | inStep = item.val == step_index + ''; |
| 1051 | } |
| 1052 | |
| 1053 | return inStep && item.type == 'input'; |
| 1054 | }).map(function (item) { |
| 1055 | return item.name; |
| 1056 | }); |
| 1057 | }; // END PRO ONLY |
| 1058 | |
| 1059 | /** |
| 1060 | * @global |
| 1061 | * @namespace wpcf7cf |
| 1062 | */ |
| 1063 | |
| 1064 | |
| 1065 | window.wpcf7cf = { |
| 1066 | hideGroup: function hideGroup($group, animate) {}, |
| 1067 | showGroup: function showGroup($group, animate) {}, |
| 1068 | updateRepeaterSubHTML: function updateRepeaterSubHTML(html, oldSuffix, newSuffix, parentRepeaters) { |
| 1069 | var oldIndexes = oldSuffix.split('__'); |
| 1070 | oldIndexes.shift(); // remove first empty element |
| 1071 | |
| 1072 | var newIndexes = newSuffix.split('__'); |
| 1073 | newIndexes.shift(); // remove first empty element |
| 1074 | |
| 1075 | var returnHtml = html; |
| 1076 | |
| 1077 | if (oldIndexes && newIndexes && oldIndexes.length === parentRepeaters.length && newIndexes.length === parentRepeaters.length) { |
| 1078 | var parentRepeatersInfo = parentRepeaters.map(function (repeaterId, i) { |
| 1079 | return _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()({}, repeaterId.split('__')[0], [oldIndexes[i], newIndexes[i]]); |
| 1080 | }); |
| 1081 | var length = parentRepeatersInfo.length; |
| 1082 | var replacements = oldIndexes.map(function (oldIndex, i) { |
| 1083 | return ['__' + oldIndexes.slice(0, length - i).join('__'), '__' + newIndexes.slice(0, length - i).join('__')]; |
| 1084 | }); |
| 1085 | |
| 1086 | for (var i = 0; i < length; i++) { |
| 1087 | var id = Object.keys(parentRepeatersInfo[i])[0]; |
| 1088 | var find = parentRepeatersInfo[i][id][0]; |
| 1089 | var repl = parentRepeatersInfo[i][id][1]; |
| 1090 | replacements.push(["<span class=\"wpcf7cf-index wpcf7cf__".concat(id, "\">").concat(find, "<\\/span>"), "<span class=\"wpcf7cf-index wpcf7cf__".concat(id, "\">").concat(repl, "</span>")]); |
| 1091 | } |
| 1092 | |
| 1093 | replacements.forEach(function (_ref3) { |
| 1094 | var _ref4 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_ref3, 2), |
| 1095 | oldSuffix = _ref4[0], |
| 1096 | newSuffix = _ref4[1]; |
| 1097 | |
| 1098 | returnHtml = returnHtml.replace(new RegExp(oldSuffix, 'g'), newSuffix); |
| 1099 | }); |
| 1100 | } |
| 1101 | |
| 1102 | return returnHtml; |
| 1103 | }, |
| 1104 | // keep this for backwards compatibility |
| 1105 | initForm: function initForm($forms) { |
| 1106 | $forms.each(function () { |
| 1107 | var $form = jQuery(this); // only add form is its class is "wpcf7-form" and if the form was not previously added |
| 1108 | |
| 1109 | if ($form.hasClass('wpcf7-form') && !wpcf7cf_forms.some(function (form) { |
| 1110 | return form.$form.get(0) === $form.get(0); |
| 1111 | })) { |
| 1112 | wpcf7cf_forms.push(new Wpcf7cfForm($form)); |
| 1113 | } |
| 1114 | }); |
| 1115 | }, |
| 1116 | getWpcf7cfForm: function getWpcf7cfForm($form) { |
| 1117 | var matched_forms = wpcf7cf_forms.filter(function (form) { |
| 1118 | var f1 = form.$form.get(0); |
| 1119 | var f2 = $form.get(0); |
| 1120 | return form.$form.get(0) === $form.get(0); |
| 1121 | }); |
| 1122 | |
| 1123 | if (matched_forms.length) { |
| 1124 | return matched_forms[0]; |
| 1125 | } |
| 1126 | |
| 1127 | return false; |
| 1128 | }, |
| 1129 | get_nested_conditions: function get_nested_conditions(conditions, $current_form) { |
| 1130 | //loop trough conditions. Then loop trough the dom, and each repeater we pass we should update all sub_values we encounter with __index |
| 1131 | wpcf7cf_reload_dom($current_form); |
| 1132 | var groups = Object.values(wpcf7cf_dom).filter(function (item, i) { |
| 1133 | return item.type === 'group'; |
| 1134 | }); |
| 1135 | var sub_conditions = []; |
| 1136 | |
| 1137 | for (var i = 0; i < groups.length; i++) { |
| 1138 | var g = groups[i]; |
| 1139 | var relevant_conditions = conditions.filter(function (condition, i) { |
| 1140 | return condition.then_field === g.original_name; |
| 1141 | }); |
| 1142 | var relevant_conditions = relevant_conditions.map(function (item, i) { |
| 1143 | return { |
| 1144 | then_field: g.name, |
| 1145 | and_rules: item.and_rules.map(function (and_rule, i) { |
| 1146 | return { |
| 1147 | if_field: and_rule.if_field + g.suffix, |
| 1148 | if_value: and_rule.if_value, |
| 1149 | operator: and_rule.operator |
| 1150 | }; |
| 1151 | }) |
| 1152 | }; |
| 1153 | }); |
| 1154 | sub_conditions = sub_conditions.concat(relevant_conditions); |
| 1155 | } |
| 1156 | |
| 1157 | return sub_conditions; |
| 1158 | }, |
| 1159 | get_simplified_dom_model: function get_simplified_dom_model(currentNode) { |
| 1160 | var simplified_dom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| 1161 | var parentGroups = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
| 1162 | var parentRepeaters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; |
| 1163 | var type = currentNode.classList && currentNode.classList.contains('wpcf7cf_repeater') ? 'repeater' : currentNode.dataset["class"] == 'wpcf7cf_group' ? 'group' : currentNode.className == 'wpcf7cf_step' ? 'step' : currentNode.hasAttribute('name') && !currentNode.disabled ? 'input' : false; |
| 1164 | |
| 1165 | var newParentRepeaters = _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(parentRepeaters); |
| 1166 | |
| 1167 | var newParentGroups = _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(parentGroups); |
| 1168 | |
| 1169 | if (type) { |
| 1170 | var name = type === 'input' ? currentNode.getAttribute('name') : currentNode.dataset.id; |
| 1171 | |
| 1172 | if (type === 'repeater') { |
| 1173 | newParentRepeaters.push(name); |
| 1174 | } |
| 1175 | |
| 1176 | if (type === 'group') { |
| 1177 | newParentGroups.push(name); |
| 1178 | } // skip _wpcf7 hidden fields |
| 1179 | |
| 1180 | |
| 1181 | if (name.substring(0, 6) === '_wpcf7') return {}; |
| 1182 | var original_name = type === 'repeater' || type === 'group' ? currentNode.dataset.orig_data_id : type === 'input' ? currentNode.getAttribute('data-orig_name') || name : name; |
| 1183 | var nameWithoutBrackets = name.replace('[]', ''); |
| 1184 | var originalNameWithoutBrackets = original_name.replace('[]', ''); |
| 1185 | var val = type === 'step' ? [currentNode.dataset.id.substring(5)] : []; |
| 1186 | var parentGroup = 'parent-group'; |
| 1187 | var suffix = nameWithoutBrackets.replace(originalNameWithoutBrackets, ''); |
| 1188 | |
| 1189 | if (!simplified_dom[name]) { |
| 1190 | // init entry |
| 1191 | simplified_dom[name] = { |
| 1192 | name: name, |
| 1193 | type: type, |
| 1194 | original_name: original_name, |
| 1195 | suffix: suffix, |
| 1196 | val: val, |
| 1197 | parentGroups: parentGroups, |
| 1198 | parentRepeaters: parentRepeaters |
| 1199 | }; |
| 1200 | } |
| 1201 | |
| 1202 | if (type === 'input') { |
| 1203 | // skip unchecked checkboxes and radiobuttons |
| 1204 | if ((currentNode.type === 'checkbox' || currentNode.type === 'radio') && !currentNode.checked) return {}; // if multiselect, make sure to add all the values |
| 1205 | |
| 1206 | if (currentNode.multiple && currentNode.options) { |
| 1207 | simplified_dom[name].val = Object.values(currentNode.options).filter(function (o) { |
| 1208 | return o.selected; |
| 1209 | }).map(function (o) { |
| 1210 | return o.value; |
| 1211 | }); |
| 1212 | } else { |
| 1213 | simplified_dom[name].val.push(currentNode.value); |
| 1214 | } |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | Array.from(currentNode.children).forEach(function (childNode) { |
| 1219 | var dom = wpcf7cf.get_simplified_dom_model(childNode, simplified_dom, newParentGroups, newParentRepeaters); |
| 1220 | simplified_dom = _objectSpread(_objectSpread({}, dom), simplified_dom); |
| 1221 | }); |
| 1222 | return simplified_dom; |
| 1223 | }, |
| 1224 | updateMultistepState: function updateMultistepState(multistep) { |
| 1225 | if (multistep == null) return; // update hidden input field |
| 1226 | |
| 1227 | var stepsData = { |
| 1228 | currentStep: multistep.currentStep, |
| 1229 | numSteps: multistep.numSteps, |
| 1230 | fieldsInCurrentStep: multistep.getFieldsInStep(multistep.currentStep) |
| 1231 | }; |
| 1232 | multistep.form.$input_steps.val(JSON.stringify(stepsData)); // update Buttons |
| 1233 | |
| 1234 | multistep.$btn_prev.removeClass('disabled').attr('disabled', false); |
| 1235 | multistep.$btn_next.removeClass('disabled').attr('disabled', false); |
| 1236 | |
| 1237 | if (multistep.currentStep == multistep.numSteps) { |
| 1238 | multistep.$btn_next.addClass('disabled').attr('disabled', true); |
| 1239 | } |
| 1240 | |
| 1241 | if (multistep.currentStep == 1) { |
| 1242 | multistep.$btn_prev.addClass('disabled').attr('disabled', true); |
| 1243 | } // replace next button with submit button on last step. |
| 1244 | // TODO: make this depend on a setting |
| 1245 | |
| 1246 | |
| 1247 | var $submit_button = multistep.form.$form.find('input[type="submit"]').eq(0); |
| 1248 | var $ajax_loader = multistep.form.$form.find('.ajax-loader').eq(0); |
| 1249 | |
| 1250 | if (multistep.currentStep == multistep.numSteps) { |
| 1251 | multistep.$btn_next.hide(); |
| 1252 | $ajax_loader.detach().appendTo(multistep.$btn_next.parent()); |
| 1253 | $submit_button.detach().appendTo(multistep.$btn_next.parent()); |
| 1254 | $submit_button.show(); |
| 1255 | } else { |
| 1256 | $submit_button.hide(); |
| 1257 | multistep.$btn_next.show(); |
| 1258 | } // update dots |
| 1259 | |
| 1260 | |
| 1261 | var $dots = multistep.$dots.find('.dot'); |
| 1262 | $dots.removeClass('active').removeClass('completed'); |
| 1263 | |
| 1264 | for (var step = 1; step <= multistep.numSteps; step++) { |
| 1265 | if (step < multistep.currentStep) { |
| 1266 | $dots.eq(step - 1).addClass('completed'); |
| 1267 | } else if (step == multistep.currentStep) { |
| 1268 | $dots.eq(step - 1).addClass('active'); |
| 1269 | } |
| 1270 | } |
| 1271 | }, |
| 1272 | should_group_be_shown: function should_group_be_shown(condition) { |
| 1273 | var show_group = true; |
| 1274 | |
| 1275 | for (var and_rule_i = 0; and_rule_i < condition.and_rules.length; and_rule_i++) { |
| 1276 | var condition_ok = false; |
| 1277 | var condition_and_rule = condition.and_rules[and_rule_i]; |
| 1278 | var inputField = wpcf7cf_getFieldByName(condition_and_rule.if_field); |
| 1279 | if (!inputField) continue; // field not found |
| 1280 | |
| 1281 | var if_val = condition_and_rule.if_value; |
| 1282 | var operator = condition_and_rule.operator; //backwards compat |
| 1283 | |
| 1284 | operator = operator === '≤' ? 'less than or equals' : operator; |
| 1285 | operator = operator === '≥' ? 'greater than or equals' : operator; |
| 1286 | operator = operator === '>' ? 'greater than' : operator; |
| 1287 | operator = operator === '<' ? 'less than' : operator; |
| 1288 | var $field = operator === 'function' && jQuery("[name=\"".concat(inputField.name, "\"]")).eq(0); |
| 1289 | condition_ok = this.isConditionTrue(inputField.val, operator, if_val, $field); |
| 1290 | show_group = show_group && condition_ok; |
| 1291 | } |
| 1292 | |
| 1293 | return show_group; |
| 1294 | }, |
| 1295 | isConditionTrue: function isConditionTrue(values, operator) { |
| 1296 | var testValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; |
| 1297 | var $field = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : jQuery(); |
| 1298 | |
| 1299 | if (!Array.isArray(values)) { |
| 1300 | values = [values]; |
| 1301 | } |
| 1302 | |
| 1303 | var condition_ok = false; // start by assuming that the condition is not met |
| 1304 | // Considered EMPTY: [] [''] [null] ['',null] [,,''] |
| 1305 | // Considered NOT EMPTY: [0] ['ab','c'] ['',0,null] |
| 1306 | |
| 1307 | var valuesAreEmpty = values.length === 0 || values.every(function (v) { |
| 1308 | return !v && v !== 0; |
| 1309 | }); // 0 is not considered empty |
| 1310 | // special cases: [] equals '' => TRUE; [] not equals '' => FALSE |
| 1311 | |
| 1312 | if (operator === 'equals' && testValue === '' && valuesAreEmpty) { |
| 1313 | return true; |
| 1314 | } |
| 1315 | |
| 1316 | if (operator === 'not equals' && testValue === '' && valuesAreEmpty) { |
| 1317 | return false; |
| 1318 | } |
| 1319 | |
| 1320 | if (valuesAreEmpty) { |
| 1321 | if (operator === 'is empty') { |
| 1322 | condition_ok = true; |
| 1323 | } |
| 1324 | } else { |
| 1325 | if (operator === 'not empty') { |
| 1326 | condition_ok = true; |
| 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | var testValueNumber = isFinite(parseFloat(testValue)) ? parseFloat(testValue) : NaN; |
| 1331 | |
| 1332 | if (operator === 'not equals' || operator === 'not equals (regex)') { |
| 1333 | // start by assuming that the condition is met |
| 1334 | condition_ok = true; |
| 1335 | } |
| 1336 | |
| 1337 | if (operator === 'function' && typeof window[testValue] == 'function' && window[testValue]($field) // here we call the actual user defined function |
| 1338 | ) { |
| 1339 | condition_ok = true; |
| 1340 | } |
| 1341 | |
| 1342 | var regex_patt = /.*/i; // fallback regex pattern |
| 1343 | |
| 1344 | var isValidRegex = true; |
| 1345 | |
| 1346 | if (operator === 'equals (regex)' || operator === 'not equals (regex)') { |
| 1347 | try { |
| 1348 | regex_patt = new RegExp(testValue, 'i'); |
| 1349 | } catch (e) { |
| 1350 | isValidRegex = false; |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | for (var i = 0; i < values.length; i++) { |
| 1355 | var value = values[i]; |
| 1356 | var valueNumber = isFinite(parseFloat(value)) ? parseFloat(value) : NaN; |
| 1357 | var valsAreNumbers = !isNaN(valueNumber) && !isNaN(testValueNumber); |
| 1358 | |
| 1359 | if (operator === 'equals' && value === testValue || operator === 'equals (regex)' && regex_patt.test(value) || operator === 'greater than' && valsAreNumbers && valueNumber > testValueNumber || operator === 'less than' && valsAreNumbers && valueNumber < testValueNumber || operator === 'greater than or equals' && valsAreNumbers && valueNumber >= testValueNumber || operator === 'less than or equals' && valsAreNumbers && valueNumber <= testValueNumber) { |
| 1360 | condition_ok = true; |
| 1361 | break; |
| 1362 | } else if (operator === 'not equals' && value === testValue || operator === 'not equals (regex)' && regex_patt.test(value)) { |
| 1363 | condition_ok = false; |
| 1364 | break; |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | return condition_ok; |
| 1369 | }, |
| 1370 | getFormObj: function getFormObj($form) { |
| 1371 | if (typeof $form === 'string') { |
| 1372 | $form = jQuery($form).eq(0); |
| 1373 | } |
| 1374 | |
| 1375 | return wpcf7cf.getWpcf7cfForm($form); |
| 1376 | }, |
| 1377 | getRepeaterObj: function getRepeaterObj($form, repeaterDataId) { |
| 1378 | var form = wpcf7cf.getFormObj($form); |
| 1379 | var repeater = form.repeaters.find(function (repeater) { |
| 1380 | return repeater.params.$repeater.attr('data-id') === repeaterDataId; |
| 1381 | }); |
| 1382 | return repeater; |
| 1383 | }, |
| 1384 | getMultiStepObj: function getMultiStepObj($form) { |
| 1385 | var form = wpcf7cf.getFormObj($form); |
| 1386 | return form.multistep; |
| 1387 | }, |
| 1388 | |
| 1389 | /** |
| 1390 | * Append a new sub-entry to the repeater with the name `repeaterDataId` inside the form `$form` |
| 1391 | * @memberof wpcf7cf |
| 1392 | * @function wpcf7cf.repeaterAddSub |
| 1393 | * @link |
| 1394 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1395 | * @param {String} repeaterDataId - *data-id* attribute of the repeater. Normally this is simply the name of the repeater. However, in case of a nested repeater you need to append the name with the correct suffix. For example `my-nested-repeater__1__3`. Hint (check the `data-id` attribute in the HTML code to find the correct suffix) |
| 1396 | */ |
| 1397 | repeaterAddSub: function repeaterAddSub($form, repeaterDataId) { |
| 1398 | var repeater = wpcf7cf.getRepeaterObj($form, repeaterDataId); |
| 1399 | repeater.updateSubs(repeater.params.$repeater.num_subs + 1); |
| 1400 | }, |
| 1401 | |
| 1402 | /** |
| 1403 | * Insert a new sub-entry at the given `index` of the repeater with the name `repeaterDataId` inside the form `$form` |
| 1404 | * @memberof wpcf7cf |
| 1405 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1406 | * @param {String} repeaterDataId - *data-id* attribute of the repeater. |
| 1407 | * @param {Number} index - position where to insert the new sub-entry within the repeater |
| 1408 | */ |
| 1409 | repeaterAddSubAtIndex: function repeaterAddSubAtIndex($form, repeaterDataId, index) { |
| 1410 | var repeater = wpcf7cf.getRepeaterObj($form, repeaterDataId); |
| 1411 | repeater.addSubs(1, index); |
| 1412 | }, |
| 1413 | |
| 1414 | /** |
| 1415 | * Remove the sub-entry at the given `index` of the repeater with the *data-id* attribute of `repeaterDataId` inside the form `$form` |
| 1416 | * @memberof wpcf7cf |
| 1417 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1418 | * @param {String} repeaterDataId - *data-id* attribute of the repeater. |
| 1419 | * @param {Number} index - position where to insert the new sub-entry within the repeater |
| 1420 | */ |
| 1421 | repeaterRemoveSubAtIndex: function repeaterRemoveSubAtIndex($form, repeaterDataId, index) { |
| 1422 | var repeater = wpcf7cf.getRepeaterObj($form, repeaterDataId); |
| 1423 | repeater.removeSubs(1, index); |
| 1424 | }, |
| 1425 | |
| 1426 | /** |
| 1427 | * Remove the last sub-entry from the repeater with the *data-id* attribute of `repeaterDataId` inside the form `$form` |
| 1428 | * @memberof wpcf7cf |
| 1429 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1430 | * @param {String} repeaterDataId - *data-id* attribute of the repeater. |
| 1431 | * @param {Number} index - position where to insert the new sub-entry within the repeater |
| 1432 | */ |
| 1433 | repeaterRemoveSub: function repeaterRemoveSub($form, repeaterDataId) { |
| 1434 | var repeater = wpcf7cf.getRepeaterObj($form, repeaterDataId); |
| 1435 | repeater.updateSubs(repeater.params.$repeater.num_subs - 1); |
| 1436 | }, |
| 1437 | |
| 1438 | /** |
| 1439 | * Set the number of subs for the repeater with the *data-id* attribute of `repeaterDataId` inside the form `$form`. |
| 1440 | * Subs are either appended to or removed from the end of the repeater. |
| 1441 | * @memberof wpcf7cf |
| 1442 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1443 | * @param {String} repeaterDataId - *data-id* attribute of the repeater. |
| 1444 | * @param {Number} numberOfSubs - position where to insert the new sub-entry within the repeater |
| 1445 | */ |
| 1446 | repeaterSetNumberOfSubs: function repeaterSetNumberOfSubs($form, repeaterDataId, numberOfSubs) { |
| 1447 | var repeater = wpcf7cf.getRepeaterObj($form, repeaterDataId); |
| 1448 | repeater.updateSubs(numberOfSubs); |
| 1449 | }, |
| 1450 | |
| 1451 | /** |
| 1452 | * Move to step number `step`, ignoring any validation. |
| 1453 | * @memberof wpcf7cf |
| 1454 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1455 | * @param {*} step |
| 1456 | */ |
| 1457 | multistepMoveToStep: function multistepMoveToStep($form, step) { |
| 1458 | var multistep = wpcf7cf.getMultiStepObj($form); |
| 1459 | multistep.moveToStep(step); |
| 1460 | }, |
| 1461 | |
| 1462 | /** |
| 1463 | * Validate the current step, and move to step number `step` if validation passes. |
| 1464 | * @memberof wpcf7cf |
| 1465 | * @param {String|JQuery} $form - JQuery object or css-selector representing the form |
| 1466 | * @param {Number} step |
| 1467 | */ |
| 1468 | multistepMoveToStepWithValidation: function multistepMoveToStepWithValidation($form, step) { |
| 1469 | return _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee2() { |
| 1470 | var multistep, result; |
| 1471 | return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee2$(_context2) { |
| 1472 | while (1) { |
| 1473 | switch (_context2.prev = _context2.next) { |
| 1474 | case 0: |
| 1475 | multistep = wpcf7cf.getMultiStepObj($form); |
| 1476 | _context2.next = 3; |
| 1477 | return multistep.validateStep(multistep.currentStep); |
| 1478 | |
| 1479 | case 3: |
| 1480 | result = _context2.sent; |
| 1481 | |
| 1482 | if (result === 'success') { |
| 1483 | multistep.moveToStep(step); |
| 1484 | } |
| 1485 | |
| 1486 | case 5: |
| 1487 | case "end": |
| 1488 | return _context2.stop(); |
| 1489 | } |
| 1490 | } |
| 1491 | }, _callee2); |
| 1492 | }))(); |
| 1493 | } |
| 1494 | }; |
| 1495 | jQuery('.wpcf7-form').each(function () { |
| 1496 | wpcf7cf_forms.push(new Wpcf7cfForm(jQuery(this))); |
| 1497 | }); // Call displayFields again on all forms |
| 1498 | // Necessary in case some theme or plugin changed a form value by the time the entire page is fully loaded. |
| 1499 | |
| 1500 | jQuery('document').on('ready', function () { |
| 1501 | wpcf7cf_forms.forEach(function (f) { |
| 1502 | f.displayFields(); |
| 1503 | }); |
| 1504 | }); // fix for exclusive checkboxes in IE (this will call the change-event again after all other checkboxes are unchecked, triggering the display_fields() function) |
| 1505 | |
| 1506 | var old_wpcf7ExclusiveCheckbox = jQuery.fn.wpcf7ExclusiveCheckbox; |
| 1507 | |
| 1508 | jQuery.fn.wpcf7ExclusiveCheckbox = function () { |
| 1509 | return this.find('input:checkbox').on('click', function () { |
| 1510 | var name = jQuery(this).attr('name'); |
| 1511 | jQuery(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false).eq(0).change(); |
| 1512 | }); |
| 1513 | }; |
| 1514 | |
| 1515 | /***/ }), |
| 1516 | |
| 1517 | /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": |
| 1518 | /*!*****************************************************************!*\ |
| 1519 | !*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***! |
| 1520 | \*****************************************************************/ |
| 1521 | /*! no static exports found */ |
| 1522 | /***/ (function(module, exports) { |
| 1523 | |
| 1524 | function _arrayLikeToArray(arr, len) { |
| 1525 | if (len == null || len > arr.length) len = arr.length; |
| 1526 | |
| 1527 | for (var i = 0, arr2 = new Array(len); i < len; i++) { |
| 1528 | arr2[i] = arr[i]; |
| 1529 | } |
| 1530 | |
| 1531 | return arr2; |
| 1532 | } |
| 1533 | |
| 1534 | module.exports = _arrayLikeToArray; |
| 1535 | |
| 1536 | /***/ }), |
| 1537 | |
| 1538 | /***/ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js": |
| 1539 | /*!***************************************************************!*\ |
| 1540 | !*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***! |
| 1541 | \***************************************************************/ |
| 1542 | /*! no static exports found */ |
| 1543 | /***/ (function(module, exports) { |
| 1544 | |
| 1545 | function _arrayWithHoles(arr) { |
| 1546 | if (Array.isArray(arr)) return arr; |
| 1547 | } |
| 1548 | |
| 1549 | module.exports = _arrayWithHoles; |
| 1550 | |
| 1551 | /***/ }), |
| 1552 | |
| 1553 | /***/ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js": |
| 1554 | /*!******************************************************************!*\ |
| 1555 | !*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***! |
| 1556 | \******************************************************************/ |
| 1557 | /*! no static exports found */ |
| 1558 | /***/ (function(module, exports, __webpack_require__) { |
| 1559 | |
| 1560 | var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js"); |
| 1561 | |
| 1562 | function _arrayWithoutHoles(arr) { |
| 1563 | if (Array.isArray(arr)) return arrayLikeToArray(arr); |
| 1564 | } |
| 1565 | |
| 1566 | module.exports = _arrayWithoutHoles; |
| 1567 | |
| 1568 | /***/ }), |
| 1569 | |
| 1570 | /***/ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js": |
| 1571 | /*!*****************************************************************!*\ |
| 1572 | !*** ./node_modules/@babel/runtime/helpers/asyncToGenerator.js ***! |
| 1573 | \*****************************************************************/ |
| 1574 | /*! no static exports found */ |
| 1575 | /***/ (function(module, exports) { |
| 1576 | |
| 1577 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
| 1578 | try { |
| 1579 | var info = gen[key](arg); |
| 1580 | var value = info.value; |
| 1581 | } catch (error) { |
| 1582 | reject(error); |
| 1583 | return; |
| 1584 | } |
| 1585 | |
| 1586 | if (info.done) { |
| 1587 | resolve(value); |
| 1588 | } else { |
| 1589 | Promise.resolve(value).then(_next, _throw); |
| 1590 | } |
| 1591 | } |
| 1592 | |
| 1593 | function _asyncToGenerator(fn) { |
| 1594 | return function () { |
| 1595 | var self = this, |
| 1596 | args = arguments; |
| 1597 | return new Promise(function (resolve, reject) { |
| 1598 | var gen = fn.apply(self, args); |
| 1599 | |
| 1600 | function _next(value) { |
| 1601 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
| 1602 | } |
| 1603 | |
| 1604 | function _throw(err) { |
| 1605 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
| 1606 | } |
| 1607 | |
| 1608 | _next(undefined); |
| 1609 | }); |
| 1610 | }; |
| 1611 | } |
| 1612 | |
| 1613 | module.exports = _asyncToGenerator; |
| 1614 | |
| 1615 | /***/ }), |
| 1616 | |
| 1617 | /***/ "./node_modules/@babel/runtime/helpers/defineProperty.js": |
| 1618 | /*!***************************************************************!*\ |
| 1619 | !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! |
| 1620 | \***************************************************************/ |
| 1621 | /*! no static exports found */ |
| 1622 | /***/ (function(module, exports) { |
| 1623 | |
| 1624 | function _defineProperty(obj, key, value) { |
| 1625 | if (key in obj) { |
| 1626 | Object.defineProperty(obj, key, { |
| 1627 | value: value, |
| 1628 | enumerable: true, |
| 1629 | configurable: true, |
| 1630 | writable: true |
| 1631 | }); |
| 1632 | } else { |
| 1633 | obj[key] = value; |
| 1634 | } |
| 1635 | |
| 1636 | return obj; |
| 1637 | } |
| 1638 | |
| 1639 | module.exports = _defineProperty; |
| 1640 | |
| 1641 | /***/ }), |
| 1642 | |
| 1643 | /***/ "./node_modules/@babel/runtime/helpers/iterableToArray.js": |
| 1644 | /*!****************************************************************!*\ |
| 1645 | !*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***! |
| 1646 | \****************************************************************/ |
| 1647 | /*! no static exports found */ |
| 1648 | /***/ (function(module, exports) { |
| 1649 | |
| 1650 | function _iterableToArray(iter) { |
| 1651 | if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
| 1652 | } |
| 1653 | |
| 1654 | module.exports = _iterableToArray; |
| 1655 | |
| 1656 | /***/ }), |
| 1657 | |
| 1658 | /***/ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js": |
| 1659 | /*!*********************************************************************!*\ |
| 1660 | !*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***! |
| 1661 | \*********************************************************************/ |
| 1662 | /*! no static exports found */ |
| 1663 | /***/ (function(module, exports) { |
| 1664 | |
| 1665 | function _iterableToArrayLimit(arr, i) { |
| 1666 | if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; |
| 1667 | var _arr = []; |
| 1668 | var _n = true; |
| 1669 | var _d = false; |
| 1670 | var _e = undefined; |
| 1671 | |
| 1672 | try { |
| 1673 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
| 1674 | _arr.push(_s.value); |
| 1675 | |
| 1676 | if (i && _arr.length === i) break; |
| 1677 | } |
| 1678 | } catch (err) { |
| 1679 | _d = true; |
| 1680 | _e = err; |
| 1681 | } finally { |
| 1682 | try { |
| 1683 | if (!_n && _i["return"] != null) _i["return"](); |
| 1684 | } finally { |
| 1685 | if (_d) throw _e; |
| 1686 | } |
| 1687 | } |
| 1688 | |
| 1689 | return _arr; |
| 1690 | } |
| 1691 | |
| 1692 | module.exports = _iterableToArrayLimit; |
| 1693 | |
| 1694 | /***/ }), |
| 1695 | |
| 1696 | /***/ "./node_modules/@babel/runtime/helpers/nonIterableRest.js": |
| 1697 | /*!****************************************************************!*\ |
| 1698 | !*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***! |
| 1699 | \****************************************************************/ |
| 1700 | /*! no static exports found */ |
| 1701 | /***/ (function(module, exports) { |
| 1702 | |
| 1703 | function _nonIterableRest() { |
| 1704 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 1705 | } |
| 1706 | |
| 1707 | module.exports = _nonIterableRest; |
| 1708 | |
| 1709 | /***/ }), |
| 1710 | |
| 1711 | /***/ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js": |
| 1712 | /*!******************************************************************!*\ |
| 1713 | !*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***! |
| 1714 | \******************************************************************/ |
| 1715 | /*! no static exports found */ |
| 1716 | /***/ (function(module, exports) { |
| 1717 | |
| 1718 | function _nonIterableSpread() { |
| 1719 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 1720 | } |
| 1721 | |
| 1722 | module.exports = _nonIterableSpread; |
| 1723 | |
| 1724 | /***/ }), |
| 1725 | |
| 1726 | /***/ "./node_modules/@babel/runtime/helpers/slicedToArray.js": |
| 1727 | /*!**************************************************************!*\ |
| 1728 | !*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***! |
| 1729 | \**************************************************************/ |
| 1730 | /*! no static exports found */ |
| 1731 | /***/ (function(module, exports, __webpack_require__) { |
| 1732 | |
| 1733 | var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles */ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js"); |
| 1734 | |
| 1735 | var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit */ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"); |
| 1736 | |
| 1737 | var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"); |
| 1738 | |
| 1739 | var nonIterableRest = __webpack_require__(/*! ./nonIterableRest */ "./node_modules/@babel/runtime/helpers/nonIterableRest.js"); |
| 1740 | |
| 1741 | function _slicedToArray(arr, i) { |
| 1742 | return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); |
| 1743 | } |
| 1744 | |
| 1745 | module.exports = _slicedToArray; |
| 1746 | |
| 1747 | /***/ }), |
| 1748 | |
| 1749 | /***/ "./node_modules/@babel/runtime/helpers/toConsumableArray.js": |
| 1750 | /*!******************************************************************!*\ |
| 1751 | !*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***! |
| 1752 | \******************************************************************/ |
| 1753 | /*! no static exports found */ |
| 1754 | /***/ (function(module, exports, __webpack_require__) { |
| 1755 | |
| 1756 | var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles */ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js"); |
| 1757 | |
| 1758 | var iterableToArray = __webpack_require__(/*! ./iterableToArray */ "./node_modules/@babel/runtime/helpers/iterableToArray.js"); |
| 1759 | |
| 1760 | var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"); |
| 1761 | |
| 1762 | var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread */ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js"); |
| 1763 | |
| 1764 | function _toConsumableArray(arr) { |
| 1765 | return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); |
| 1766 | } |
| 1767 | |
| 1768 | module.exports = _toConsumableArray; |
| 1769 | |
| 1770 | /***/ }), |
| 1771 | |
| 1772 | /***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js": |
| 1773 | /*!***************************************************************************!*\ |
| 1774 | !*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***! |
| 1775 | \***************************************************************************/ |
| 1776 | /*! no static exports found */ |
| 1777 | /***/ (function(module, exports, __webpack_require__) { |
| 1778 | |
| 1779 | var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js"); |
| 1780 | |
| 1781 | function _unsupportedIterableToArray(o, minLen) { |
| 1782 | if (!o) return; |
| 1783 | if (typeof o === "string") return arrayLikeToArray(o, minLen); |
| 1784 | var n = Object.prototype.toString.call(o).slice(8, -1); |
| 1785 | if (n === "Object" && o.constructor) n = o.constructor.name; |
| 1786 | if (n === "Map" || n === "Set") return Array.from(o); |
| 1787 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); |
| 1788 | } |
| 1789 | |
| 1790 | module.exports = _unsupportedIterableToArray; |
| 1791 | |
| 1792 | /***/ }), |
| 1793 | |
| 1794 | /***/ "./node_modules/@babel/runtime/regenerator/index.js": |
| 1795 | /*!**********************************************************!*\ |
| 1796 | !*** ./node_modules/@babel/runtime/regenerator/index.js ***! |
| 1797 | \**********************************************************/ |
| 1798 | /*! no static exports found */ |
| 1799 | /***/ (function(module, exports, __webpack_require__) { |
| 1800 | |
| 1801 | module.exports = __webpack_require__(/*! regenerator-runtime */ "./node_modules/regenerator-runtime/runtime.js"); |
| 1802 | |
| 1803 | /***/ }), |
| 1804 | |
| 1805 | /***/ "./node_modules/es6-promise-promise/index.js": |
| 1806 | /*!***************************************************!*\ |
| 1807 | !*** ./node_modules/es6-promise-promise/index.js ***! |
| 1808 | \***************************************************/ |
| 1809 | /*! no static exports found */ |
| 1810 | /***/ (function(module, exports, __webpack_require__) { |
| 1811 | |
| 1812 | module.exports = __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js").Promise; |
| 1813 | |
| 1814 | /***/ }), |
| 1815 | |
| 1816 | /***/ "./node_modules/es6-promise/dist/es6-promise.js": |
| 1817 | /*!******************************************************!*\ |
| 1818 | !*** ./node_modules/es6-promise/dist/es6-promise.js ***! |
| 1819 | \******************************************************/ |
| 1820 | /*! no static exports found */ |
| 1821 | /***/ (function(module, exports, __webpack_require__) { |
| 1822 | |
| 1823 | /* WEBPACK VAR INJECTION */(function(process, global) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;function _typeof(obj) { "@babel/helpers - typeof"; 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); } |
| 1824 | |
| 1825 | /*! |
| 1826 | * @overview es6-promise - a tiny implementation of Promises/A+. |
| 1827 | * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) |
| 1828 | * @license Licensed under MIT license |
| 1829 | * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE |
| 1830 | * @version 3.3.1 |
| 1831 | */ |
| 1832 | (function (global, factory) { |
| 1833 | ( false ? undefined : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
| 1834 | __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
| 1835 | (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : |
| 1836 | __WEBPACK_AMD_DEFINE_FACTORY__), |
| 1837 | __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined; |
| 1838 | })(this, function () { |
| 1839 | 'use strict'; |
| 1840 | |
| 1841 | function objectOrFunction(x) { |
| 1842 | return typeof x === 'function' || _typeof(x) === 'object' && x !== null; |
| 1843 | } |
| 1844 | |
| 1845 | function isFunction(x) { |
| 1846 | return typeof x === 'function'; |
| 1847 | } |
| 1848 | |
| 1849 | var _isArray = undefined; |
| 1850 | |
| 1851 | if (!Array.isArray) { |
| 1852 | _isArray = function _isArray(x) { |
| 1853 | return Object.prototype.toString.call(x) === '[object Array]'; |
| 1854 | }; |
| 1855 | } else { |
| 1856 | _isArray = Array.isArray; |
| 1857 | } |
| 1858 | |
| 1859 | var isArray = _isArray; |
| 1860 | var len = 0; |
| 1861 | var vertxNext = undefined; |
| 1862 | var customSchedulerFn = undefined; |
| 1863 | |
| 1864 | var asap = function asap(callback, arg) { |
| 1865 | queue[len] = callback; |
| 1866 | queue[len + 1] = arg; |
| 1867 | len += 2; |
| 1868 | |
| 1869 | if (len === 2) { |
| 1870 | // If len is 2, that means that we need to schedule an async flush. |
| 1871 | // If additional callbacks are queued before the queue is flushed, they |
| 1872 | // will be processed by this flush that we are scheduling. |
| 1873 | if (customSchedulerFn) { |
| 1874 | customSchedulerFn(flush); |
| 1875 | } else { |
| 1876 | scheduleFlush(); |
| 1877 | } |
| 1878 | } |
| 1879 | }; |
| 1880 | |
| 1881 | function setScheduler(scheduleFn) { |
| 1882 | customSchedulerFn = scheduleFn; |
| 1883 | } |
| 1884 | |
| 1885 | function setAsap(asapFn) { |
| 1886 | asap = asapFn; |
| 1887 | } |
| 1888 | |
| 1889 | var browserWindow = typeof window !== 'undefined' ? window : undefined; |
| 1890 | var browserGlobal = browserWindow || {}; |
| 1891 | var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; |
| 1892 | var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; // test for web worker but not in IE10 |
| 1893 | |
| 1894 | var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; // node |
| 1895 | |
| 1896 | function useNextTick() { |
| 1897 | // node version 0.10.x displays a deprecation warning when nextTick is used recursively |
| 1898 | // see https://github.com/cujojs/when/issues/410 for details |
| 1899 | return function () { |
| 1900 | return process.nextTick(flush); |
| 1901 | }; |
| 1902 | } // vertx |
| 1903 | |
| 1904 | |
| 1905 | function useVertxTimer() { |
| 1906 | return function () { |
| 1907 | vertxNext(flush); |
| 1908 | }; |
| 1909 | } |
| 1910 | |
| 1911 | function useMutationObserver() { |
| 1912 | var iterations = 0; |
| 1913 | var observer = new BrowserMutationObserver(flush); |
| 1914 | var node = document.createTextNode(''); |
| 1915 | observer.observe(node, { |
| 1916 | characterData: true |
| 1917 | }); |
| 1918 | return function () { |
| 1919 | node.data = iterations = ++iterations % 2; |
| 1920 | }; |
| 1921 | } // web worker |
| 1922 | |
| 1923 | |
| 1924 | function useMessageChannel() { |
| 1925 | var channel = new MessageChannel(); |
| 1926 | channel.port1.onmessage = flush; |
| 1927 | return function () { |
| 1928 | return channel.port2.postMessage(0); |
| 1929 | }; |
| 1930 | } |
| 1931 | |
| 1932 | function useSetTimeout() { |
| 1933 | // Store setTimeout reference so es6-promise will be unaffected by |
| 1934 | // other code modifying setTimeout (like sinon.useFakeTimers()) |
| 1935 | var globalSetTimeout = setTimeout; |
| 1936 | return function () { |
| 1937 | return globalSetTimeout(flush, 1); |
| 1938 | }; |
| 1939 | } |
| 1940 | |
| 1941 | var queue = new Array(1000); |
| 1942 | |
| 1943 | function flush() { |
| 1944 | for (var i = 0; i < len; i += 2) { |
| 1945 | var callback = queue[i]; |
| 1946 | var arg = queue[i + 1]; |
| 1947 | callback(arg); |
| 1948 | queue[i] = undefined; |
| 1949 | queue[i + 1] = undefined; |
| 1950 | } |
| 1951 | |
| 1952 | len = 0; |
| 1953 | } |
| 1954 | |
| 1955 | function attemptVertx() { |
| 1956 | try { |
| 1957 | var r = require; |
| 1958 | var vertx = __webpack_require__(/*! vertx */ 1); |
| 1959 | vertxNext = vertx.runOnLoop || vertx.runOnContext; |
| 1960 | return useVertxTimer(); |
| 1961 | } catch (e) { |
| 1962 | return useSetTimeout(); |
| 1963 | } |
| 1964 | } |
| 1965 | |
| 1966 | var scheduleFlush = undefined; // Decide what async method to use to triggering processing of queued callbacks: |
| 1967 | |
| 1968 | if (isNode) { |
| 1969 | scheduleFlush = useNextTick(); |
| 1970 | } else if (BrowserMutationObserver) { |
| 1971 | scheduleFlush = useMutationObserver(); |
| 1972 | } else if (isWorker) { |
| 1973 | scheduleFlush = useMessageChannel(); |
| 1974 | } else if (browserWindow === undefined && "function" === 'function') { |
| 1975 | scheduleFlush = attemptVertx(); |
| 1976 | } else { |
| 1977 | scheduleFlush = useSetTimeout(); |
| 1978 | } |
| 1979 | |
| 1980 | function then(onFulfillment, onRejection) { |
| 1981 | var _arguments = arguments; |
| 1982 | var parent = this; |
| 1983 | var child = new this.constructor(noop); |
| 1984 | |
| 1985 | if (child[PROMISE_ID] === undefined) { |
| 1986 | makePromise(child); |
| 1987 | } |
| 1988 | |
| 1989 | var _state = parent._state; |
| 1990 | |
| 1991 | if (_state) { |
| 1992 | (function () { |
| 1993 | var callback = _arguments[_state - 1]; |
| 1994 | asap(function () { |
| 1995 | return invokeCallback(_state, child, callback, parent._result); |
| 1996 | }); |
| 1997 | })(); |
| 1998 | } else { |
| 1999 | subscribe(parent, child, onFulfillment, onRejection); |
| 2000 | } |
| 2001 | |
| 2002 | return child; |
| 2003 | } |
| 2004 | /** |
| 2005 | `Promise.resolve` returns a promise that will become resolved with the |
| 2006 | passed `value`. It is shorthand for the following: |
| 2007 | |
| 2008 | ```javascript |
| 2009 | let promise = new Promise(function(resolve, reject){ |
| 2010 | resolve(1); |
| 2011 | }); |
| 2012 | |
| 2013 | promise.then(function(value){ |
| 2014 | // value === 1 |
| 2015 | }); |
| 2016 | ``` |
| 2017 | |
| 2018 | Instead of writing the above, your code now simply becomes the following: |
| 2019 | |
| 2020 | ```javascript |
| 2021 | let promise = Promise.resolve(1); |
| 2022 | |
| 2023 | promise.then(function(value){ |
| 2024 | // value === 1 |
| 2025 | }); |
| 2026 | ``` |
| 2027 | |
| 2028 | @method resolve |
| 2029 | @static |
| 2030 | @param {Any} value value that the returned promise will be resolved with |
| 2031 | Useful for tooling. |
| 2032 | @return {Promise} a promise that will become fulfilled with the given |
| 2033 | `value` |
| 2034 | */ |
| 2035 | |
| 2036 | |
| 2037 | function resolve(object) { |
| 2038 | /*jshint validthis:true */ |
| 2039 | var Constructor = this; |
| 2040 | |
| 2041 | if (object && _typeof(object) === 'object' && object.constructor === Constructor) { |
| 2042 | return object; |
| 2043 | } |
| 2044 | |
| 2045 | var promise = new Constructor(noop); |
| 2046 | |
| 2047 | _resolve(promise, object); |
| 2048 | |
| 2049 | return promise; |
| 2050 | } |
| 2051 | |
| 2052 | var PROMISE_ID = Math.random().toString(36).substring(16); |
| 2053 | |
| 2054 | function noop() {} |
| 2055 | |
| 2056 | var PENDING = void 0; |
| 2057 | var FULFILLED = 1; |
| 2058 | var REJECTED = 2; |
| 2059 | var GET_THEN_ERROR = new ErrorObject(); |
| 2060 | |
| 2061 | function selfFulfillment() { |
| 2062 | return new TypeError("You cannot resolve a promise with itself"); |
| 2063 | } |
| 2064 | |
| 2065 | function cannotReturnOwn() { |
| 2066 | return new TypeError('A promises callback cannot return that same promise.'); |
| 2067 | } |
| 2068 | |
| 2069 | function getThen(promise) { |
| 2070 | try { |
| 2071 | return promise.then; |
| 2072 | } catch (error) { |
| 2073 | GET_THEN_ERROR.error = error; |
| 2074 | return GET_THEN_ERROR; |
| 2075 | } |
| 2076 | } |
| 2077 | |
| 2078 | function tryThen(then, value, fulfillmentHandler, rejectionHandler) { |
| 2079 | try { |
| 2080 | then.call(value, fulfillmentHandler, rejectionHandler); |
| 2081 | } catch (e) { |
| 2082 | return e; |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | function handleForeignThenable(promise, thenable, then) { |
| 2087 | asap(function (promise) { |
| 2088 | var sealed = false; |
| 2089 | var error = tryThen(then, thenable, function (value) { |
| 2090 | if (sealed) { |
| 2091 | return; |
| 2092 | } |
| 2093 | |
| 2094 | sealed = true; |
| 2095 | |
| 2096 | if (thenable !== value) { |
| 2097 | _resolve(promise, value); |
| 2098 | } else { |
| 2099 | fulfill(promise, value); |
| 2100 | } |
| 2101 | }, function (reason) { |
| 2102 | if (sealed) { |
| 2103 | return; |
| 2104 | } |
| 2105 | |
| 2106 | sealed = true; |
| 2107 | |
| 2108 | _reject(promise, reason); |
| 2109 | }, 'Settle: ' + (promise._label || ' unknown promise')); |
| 2110 | |
| 2111 | if (!sealed && error) { |
| 2112 | sealed = true; |
| 2113 | |
| 2114 | _reject(promise, error); |
| 2115 | } |
| 2116 | }, promise); |
| 2117 | } |
| 2118 | |
| 2119 | function handleOwnThenable(promise, thenable) { |
| 2120 | if (thenable._state === FULFILLED) { |
| 2121 | fulfill(promise, thenable._result); |
| 2122 | } else if (thenable._state === REJECTED) { |
| 2123 | _reject(promise, thenable._result); |
| 2124 | } else { |
| 2125 | subscribe(thenable, undefined, function (value) { |
| 2126 | return _resolve(promise, value); |
| 2127 | }, function (reason) { |
| 2128 | return _reject(promise, reason); |
| 2129 | }); |
| 2130 | } |
| 2131 | } |
| 2132 | |
| 2133 | function handleMaybeThenable(promise, maybeThenable, then$$) { |
| 2134 | if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { |
| 2135 | handleOwnThenable(promise, maybeThenable); |
| 2136 | } else { |
| 2137 | if (then$$ === GET_THEN_ERROR) { |
| 2138 | _reject(promise, GET_THEN_ERROR.error); |
| 2139 | } else if (then$$ === undefined) { |
| 2140 | fulfill(promise, maybeThenable); |
| 2141 | } else if (isFunction(then$$)) { |
| 2142 | handleForeignThenable(promise, maybeThenable, then$$); |
| 2143 | } else { |
| 2144 | fulfill(promise, maybeThenable); |
| 2145 | } |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | function _resolve(promise, value) { |
| 2150 | if (promise === value) { |
| 2151 | _reject(promise, selfFulfillment()); |
| 2152 | } else if (objectOrFunction(value)) { |
| 2153 | handleMaybeThenable(promise, value, getThen(value)); |
| 2154 | } else { |
| 2155 | fulfill(promise, value); |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | function publishRejection(promise) { |
| 2160 | if (promise._onerror) { |
| 2161 | promise._onerror(promise._result); |
| 2162 | } |
| 2163 | |
| 2164 | publish(promise); |
| 2165 | } |
| 2166 | |
| 2167 | function fulfill(promise, value) { |
| 2168 | if (promise._state !== PENDING) { |
| 2169 | return; |
| 2170 | } |
| 2171 | |
| 2172 | promise._result = value; |
| 2173 | promise._state = FULFILLED; |
| 2174 | |
| 2175 | if (promise._subscribers.length !== 0) { |
| 2176 | asap(publish, promise); |
| 2177 | } |
| 2178 | } |
| 2179 | |
| 2180 | function _reject(promise, reason) { |
| 2181 | if (promise._state !== PENDING) { |
| 2182 | return; |
| 2183 | } |
| 2184 | |
| 2185 | promise._state = REJECTED; |
| 2186 | promise._result = reason; |
| 2187 | asap(publishRejection, promise); |
| 2188 | } |
| 2189 | |
| 2190 | function subscribe(parent, child, onFulfillment, onRejection) { |
| 2191 | var _subscribers = parent._subscribers; |
| 2192 | var length = _subscribers.length; |
| 2193 | parent._onerror = null; |
| 2194 | _subscribers[length] = child; |
| 2195 | _subscribers[length + FULFILLED] = onFulfillment; |
| 2196 | _subscribers[length + REJECTED] = onRejection; |
| 2197 | |
| 2198 | if (length === 0 && parent._state) { |
| 2199 | asap(publish, parent); |
| 2200 | } |
| 2201 | } |
| 2202 | |
| 2203 | function publish(promise) { |
| 2204 | var subscribers = promise._subscribers; |
| 2205 | var settled = promise._state; |
| 2206 | |
| 2207 | if (subscribers.length === 0) { |
| 2208 | return; |
| 2209 | } |
| 2210 | |
| 2211 | var child = undefined, |
| 2212 | callback = undefined, |
| 2213 | detail = promise._result; |
| 2214 | |
| 2215 | for (var i = 0; i < subscribers.length; i += 3) { |
| 2216 | child = subscribers[i]; |
| 2217 | callback = subscribers[i + settled]; |
| 2218 | |
| 2219 | if (child) { |
| 2220 | invokeCallback(settled, child, callback, detail); |
| 2221 | } else { |
| 2222 | callback(detail); |
| 2223 | } |
| 2224 | } |
| 2225 | |
| 2226 | promise._subscribers.length = 0; |
| 2227 | } |
| 2228 | |
| 2229 | function ErrorObject() { |
| 2230 | this.error = null; |
| 2231 | } |
| 2232 | |
| 2233 | var TRY_CATCH_ERROR = new ErrorObject(); |
| 2234 | |
| 2235 | function tryCatch(callback, detail) { |
| 2236 | try { |
| 2237 | return callback(detail); |
| 2238 | } catch (e) { |
| 2239 | TRY_CATCH_ERROR.error = e; |
| 2240 | return TRY_CATCH_ERROR; |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | function invokeCallback(settled, promise, callback, detail) { |
| 2245 | var hasCallback = isFunction(callback), |
| 2246 | value = undefined, |
| 2247 | error = undefined, |
| 2248 | succeeded = undefined, |
| 2249 | failed = undefined; |
| 2250 | |
| 2251 | if (hasCallback) { |
| 2252 | value = tryCatch(callback, detail); |
| 2253 | |
| 2254 | if (value === TRY_CATCH_ERROR) { |
| 2255 | failed = true; |
| 2256 | error = value.error; |
| 2257 | value = null; |
| 2258 | } else { |
| 2259 | succeeded = true; |
| 2260 | } |
| 2261 | |
| 2262 | if (promise === value) { |
| 2263 | _reject(promise, cannotReturnOwn()); |
| 2264 | |
| 2265 | return; |
| 2266 | } |
| 2267 | } else { |
| 2268 | value = detail; |
| 2269 | succeeded = true; |
| 2270 | } |
| 2271 | |
| 2272 | if (promise._state !== PENDING) {// noop |
| 2273 | } else if (hasCallback && succeeded) { |
| 2274 | _resolve(promise, value); |
| 2275 | } else if (failed) { |
| 2276 | _reject(promise, error); |
| 2277 | } else if (settled === FULFILLED) { |
| 2278 | fulfill(promise, value); |
| 2279 | } else if (settled === REJECTED) { |
| 2280 | _reject(promise, value); |
| 2281 | } |
| 2282 | } |
| 2283 | |
| 2284 | function initializePromise(promise, resolver) { |
| 2285 | try { |
| 2286 | resolver(function resolvePromise(value) { |
| 2287 | _resolve(promise, value); |
| 2288 | }, function rejectPromise(reason) { |
| 2289 | _reject(promise, reason); |
| 2290 | }); |
| 2291 | } catch (e) { |
| 2292 | _reject(promise, e); |
| 2293 | } |
| 2294 | } |
| 2295 | |
| 2296 | var id = 0; |
| 2297 | |
| 2298 | function nextId() { |
| 2299 | return id++; |
| 2300 | } |
| 2301 | |
| 2302 | function makePromise(promise) { |
| 2303 | promise[PROMISE_ID] = id++; |
| 2304 | promise._state = undefined; |
| 2305 | promise._result = undefined; |
| 2306 | promise._subscribers = []; |
| 2307 | } |
| 2308 | |
| 2309 | function Enumerator(Constructor, input) { |
| 2310 | this._instanceConstructor = Constructor; |
| 2311 | this.promise = new Constructor(noop); |
| 2312 | |
| 2313 | if (!this.promise[PROMISE_ID]) { |
| 2314 | makePromise(this.promise); |
| 2315 | } |
| 2316 | |
| 2317 | if (isArray(input)) { |
| 2318 | this._input = input; |
| 2319 | this.length = input.length; |
| 2320 | this._remaining = input.length; |
| 2321 | this._result = new Array(this.length); |
| 2322 | |
| 2323 | if (this.length === 0) { |
| 2324 | fulfill(this.promise, this._result); |
| 2325 | } else { |
| 2326 | this.length = this.length || 0; |
| 2327 | |
| 2328 | this._enumerate(); |
| 2329 | |
| 2330 | if (this._remaining === 0) { |
| 2331 | fulfill(this.promise, this._result); |
| 2332 | } |
| 2333 | } |
| 2334 | } else { |
| 2335 | _reject(this.promise, validationError()); |
| 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | function validationError() { |
| 2340 | return new Error('Array Methods must be provided an Array'); |
| 2341 | } |
| 2342 | |
| 2343 | ; |
| 2344 | |
| 2345 | Enumerator.prototype._enumerate = function () { |
| 2346 | var length = this.length; |
| 2347 | var _input = this._input; |
| 2348 | |
| 2349 | for (var i = 0; this._state === PENDING && i < length; i++) { |
| 2350 | this._eachEntry(_input[i], i); |
| 2351 | } |
| 2352 | }; |
| 2353 | |
| 2354 | Enumerator.prototype._eachEntry = function (entry, i) { |
| 2355 | var c = this._instanceConstructor; |
| 2356 | var resolve$$ = c.resolve; |
| 2357 | |
| 2358 | if (resolve$$ === resolve) { |
| 2359 | var _then = getThen(entry); |
| 2360 | |
| 2361 | if (_then === then && entry._state !== PENDING) { |
| 2362 | this._settledAt(entry._state, i, entry._result); |
| 2363 | } else if (typeof _then !== 'function') { |
| 2364 | this._remaining--; |
| 2365 | this._result[i] = entry; |
| 2366 | } else if (c === Promise) { |
| 2367 | var promise = new c(noop); |
| 2368 | handleMaybeThenable(promise, entry, _then); |
| 2369 | |
| 2370 | this._willSettleAt(promise, i); |
| 2371 | } else { |
| 2372 | this._willSettleAt(new c(function (resolve$$) { |
| 2373 | return resolve$$(entry); |
| 2374 | }), i); |
| 2375 | } |
| 2376 | } else { |
| 2377 | this._willSettleAt(resolve$$(entry), i); |
| 2378 | } |
| 2379 | }; |
| 2380 | |
| 2381 | Enumerator.prototype._settledAt = function (state, i, value) { |
| 2382 | var promise = this.promise; |
| 2383 | |
| 2384 | if (promise._state === PENDING) { |
| 2385 | this._remaining--; |
| 2386 | |
| 2387 | if (state === REJECTED) { |
| 2388 | _reject(promise, value); |
| 2389 | } else { |
| 2390 | this._result[i] = value; |
| 2391 | } |
| 2392 | } |
| 2393 | |
| 2394 | if (this._remaining === 0) { |
| 2395 | fulfill(promise, this._result); |
| 2396 | } |
| 2397 | }; |
| 2398 | |
| 2399 | Enumerator.prototype._willSettleAt = function (promise, i) { |
| 2400 | var enumerator = this; |
| 2401 | subscribe(promise, undefined, function (value) { |
| 2402 | return enumerator._settledAt(FULFILLED, i, value); |
| 2403 | }, function (reason) { |
| 2404 | return enumerator._settledAt(REJECTED, i, reason); |
| 2405 | }); |
| 2406 | }; |
| 2407 | /** |
| 2408 | `Promise.all` accepts an array of promises, and returns a new promise which |
| 2409 | is fulfilled with an array of fulfillment values for the passed promises, or |
| 2410 | rejected with the reason of the first passed promise to be rejected. It casts all |
| 2411 | elements of the passed iterable to promises as it runs this algorithm. |
| 2412 | |
| 2413 | Example: |
| 2414 | |
| 2415 | ```javascript |
| 2416 | let promise1 = resolve(1); |
| 2417 | let promise2 = resolve(2); |
| 2418 | let promise3 = resolve(3); |
| 2419 | let promises = [ promise1, promise2, promise3 ]; |
| 2420 | |
| 2421 | Promise.all(promises).then(function(array){ |
| 2422 | // The array here would be [ 1, 2, 3 ]; |
| 2423 | }); |
| 2424 | ``` |
| 2425 | |
| 2426 | If any of the `promises` given to `all` are rejected, the first promise |
| 2427 | that is rejected will be given as an argument to the returned promises's |
| 2428 | rejection handler. For example: |
| 2429 | |
| 2430 | Example: |
| 2431 | |
| 2432 | ```javascript |
| 2433 | let promise1 = resolve(1); |
| 2434 | let promise2 = reject(new Error("2")); |
| 2435 | let promise3 = reject(new Error("3")); |
| 2436 | let promises = [ promise1, promise2, promise3 ]; |
| 2437 | |
| 2438 | Promise.all(promises).then(function(array){ |
| 2439 | // Code here never runs because there are rejected promises! |
| 2440 | }, function(error) { |
| 2441 | // error.message === "2" |
| 2442 | }); |
| 2443 | ``` |
| 2444 | |
| 2445 | @method all |
| 2446 | @static |
| 2447 | @param {Array} entries array of promises |
| 2448 | @param {String} label optional string for labeling the promise. |
| 2449 | Useful for tooling. |
| 2450 | @return {Promise} promise that is fulfilled when all `promises` have been |
| 2451 | fulfilled, or rejected if any of them become rejected. |
| 2452 | @static |
| 2453 | */ |
| 2454 | |
| 2455 | |
| 2456 | function all(entries) { |
| 2457 | return new Enumerator(this, entries).promise; |
| 2458 | } |
| 2459 | /** |
| 2460 | `Promise.race` returns a new promise which is settled in the same way as the |
| 2461 | first passed promise to settle. |
| 2462 | |
| 2463 | Example: |
| 2464 | |
| 2465 | ```javascript |
| 2466 | let promise1 = new Promise(function(resolve, reject){ |
| 2467 | setTimeout(function(){ |
| 2468 | resolve('promise 1'); |
| 2469 | }, 200); |
| 2470 | }); |
| 2471 | |
| 2472 | let promise2 = new Promise(function(resolve, reject){ |
| 2473 | setTimeout(function(){ |
| 2474 | resolve('promise 2'); |
| 2475 | }, 100); |
| 2476 | }); |
| 2477 | |
| 2478 | Promise.race([promise1, promise2]).then(function(result){ |
| 2479 | // result === 'promise 2' because it was resolved before promise1 |
| 2480 | // was resolved. |
| 2481 | }); |
| 2482 | ``` |
| 2483 | |
| 2484 | `Promise.race` is deterministic in that only the state of the first |
| 2485 | settled promise matters. For example, even if other promises given to the |
| 2486 | `promises` array argument are resolved, but the first settled promise has |
| 2487 | become rejected before the other promises became fulfilled, the returned |
| 2488 | promise will become rejected: |
| 2489 | |
| 2490 | ```javascript |
| 2491 | let promise1 = new Promise(function(resolve, reject){ |
| 2492 | setTimeout(function(){ |
| 2493 | resolve('promise 1'); |
| 2494 | }, 200); |
| 2495 | }); |
| 2496 | |
| 2497 | let promise2 = new Promise(function(resolve, reject){ |
| 2498 | setTimeout(function(){ |
| 2499 | reject(new Error('promise 2')); |
| 2500 | }, 100); |
| 2501 | }); |
| 2502 | |
| 2503 | Promise.race([promise1, promise2]).then(function(result){ |
| 2504 | // Code here never runs |
| 2505 | }, function(reason){ |
| 2506 | // reason.message === 'promise 2' because promise 2 became rejected before |
| 2507 | // promise 1 became fulfilled |
| 2508 | }); |
| 2509 | ``` |
| 2510 | |
| 2511 | An example real-world use case is implementing timeouts: |
| 2512 | |
| 2513 | ```javascript |
| 2514 | Promise.race([ajax('foo.json'), timeout(5000)]) |
| 2515 | ``` |
| 2516 | |
| 2517 | @method race |
| 2518 | @static |
| 2519 | @param {Array} promises array of promises to observe |
| 2520 | Useful for tooling. |
| 2521 | @return {Promise} a promise which settles in the same way as the first passed |
| 2522 | promise to settle. |
| 2523 | */ |
| 2524 | |
| 2525 | |
| 2526 | function race(entries) { |
| 2527 | /*jshint validthis:true */ |
| 2528 | var Constructor = this; |
| 2529 | |
| 2530 | if (!isArray(entries)) { |
| 2531 | return new Constructor(function (_, reject) { |
| 2532 | return reject(new TypeError('You must pass an array to race.')); |
| 2533 | }); |
| 2534 | } else { |
| 2535 | return new Constructor(function (resolve, reject) { |
| 2536 | var length = entries.length; |
| 2537 | |
| 2538 | for (var i = 0; i < length; i++) { |
| 2539 | Constructor.resolve(entries[i]).then(resolve, reject); |
| 2540 | } |
| 2541 | }); |
| 2542 | } |
| 2543 | } |
| 2544 | /** |
| 2545 | `Promise.reject` returns a promise rejected with the passed `reason`. |
| 2546 | It is shorthand for the following: |
| 2547 | |
| 2548 | ```javascript |
| 2549 | let promise = new Promise(function(resolve, reject){ |
| 2550 | reject(new Error('WHOOPS')); |
| 2551 | }); |
| 2552 | |
| 2553 | promise.then(function(value){ |
| 2554 | // Code here doesn't run because the promise is rejected! |
| 2555 | }, function(reason){ |
| 2556 | // reason.message === 'WHOOPS' |
| 2557 | }); |
| 2558 | ``` |
| 2559 | |
| 2560 | Instead of writing the above, your code now simply becomes the following: |
| 2561 | |
| 2562 | ```javascript |
| 2563 | let promise = Promise.reject(new Error('WHOOPS')); |
| 2564 | |
| 2565 | promise.then(function(value){ |
| 2566 | // Code here doesn't run because the promise is rejected! |
| 2567 | }, function(reason){ |
| 2568 | // reason.message === 'WHOOPS' |
| 2569 | }); |
| 2570 | ``` |
| 2571 | |
| 2572 | @method reject |
| 2573 | @static |
| 2574 | @param {Any} reason value that the returned promise will be rejected with. |
| 2575 | Useful for tooling. |
| 2576 | @return {Promise} a promise rejected with the given `reason`. |
| 2577 | */ |
| 2578 | |
| 2579 | |
| 2580 | function reject(reason) { |
| 2581 | /*jshint validthis:true */ |
| 2582 | var Constructor = this; |
| 2583 | var promise = new Constructor(noop); |
| 2584 | |
| 2585 | _reject(promise, reason); |
| 2586 | |
| 2587 | return promise; |
| 2588 | } |
| 2589 | |
| 2590 | function needsResolver() { |
| 2591 | throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); |
| 2592 | } |
| 2593 | |
| 2594 | function needsNew() { |
| 2595 | throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); |
| 2596 | } |
| 2597 | /** |
| 2598 | Promise objects represent the eventual result of an asynchronous operation. The |
| 2599 | primary way of interacting with a promise is through its `then` method, which |
| 2600 | registers callbacks to receive either a promise's eventual value or the reason |
| 2601 | why the promise cannot be fulfilled. |
| 2602 | |
| 2603 | Terminology |
| 2604 | ----------- |
| 2605 | |
| 2606 | - `promise` is an object or function with a `then` method whose behavior conforms to this specification. |
| 2607 | - `thenable` is an object or function that defines a `then` method. |
| 2608 | - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). |
| 2609 | - `exception` is a value that is thrown using the throw statement. |
| 2610 | - `reason` is a value that indicates why a promise was rejected. |
| 2611 | - `settled` the final resting state of a promise, fulfilled or rejected. |
| 2612 | |
| 2613 | A promise can be in one of three states: pending, fulfilled, or rejected. |
| 2614 | |
| 2615 | Promises that are fulfilled have a fulfillment value and are in the fulfilled |
| 2616 | state. Promises that are rejected have a rejection reason and are in the |
| 2617 | rejected state. A fulfillment value is never a thenable. |
| 2618 | |
| 2619 | Promises can also be said to *resolve* a value. If this value is also a |
| 2620 | promise, then the original promise's settled state will match the value's |
| 2621 | settled state. So a promise that *resolves* a promise that rejects will |
| 2622 | itself reject, and a promise that *resolves* a promise that fulfills will |
| 2623 | itself fulfill. |
| 2624 | |
| 2625 | |
| 2626 | Basic Usage: |
| 2627 | ------------ |
| 2628 | |
| 2629 | ```js |
| 2630 | let promise = new Promise(function(resolve, reject) { |
| 2631 | // on success |
| 2632 | resolve(value); |
| 2633 | |
| 2634 | // on failure |
| 2635 | reject(reason); |
| 2636 | }); |
| 2637 | |
| 2638 | promise.then(function(value) { |
| 2639 | // on fulfillment |
| 2640 | }, function(reason) { |
| 2641 | // on rejection |
| 2642 | }); |
| 2643 | ``` |
| 2644 | |
| 2645 | Advanced Usage: |
| 2646 | --------------- |
| 2647 | |
| 2648 | Promises shine when abstracting away asynchronous interactions such as |
| 2649 | `XMLHttpRequest`s. |
| 2650 | |
| 2651 | ```js |
| 2652 | function getJSON(url) { |
| 2653 | return new Promise(function(resolve, reject){ |
| 2654 | let xhr = new XMLHttpRequest(); |
| 2655 | |
| 2656 | xhr.open('GET', url); |
| 2657 | xhr.onreadystatechange = handler; |
| 2658 | xhr.responseType = 'json'; |
| 2659 | xhr.setRequestHeader('Accept', 'application/json'); |
| 2660 | xhr.send(); |
| 2661 | |
| 2662 | function handler() { |
| 2663 | if (this.readyState === this.DONE) { |
| 2664 | if (this.status === 200) { |
| 2665 | resolve(this.response); |
| 2666 | } else { |
| 2667 | reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); |
| 2668 | } |
| 2669 | } |
| 2670 | }; |
| 2671 | }); |
| 2672 | } |
| 2673 | |
| 2674 | getJSON('/posts.json').then(function(json) { |
| 2675 | // on fulfillment |
| 2676 | }, function(reason) { |
| 2677 | // on rejection |
| 2678 | }); |
| 2679 | ``` |
| 2680 | |
| 2681 | Unlike callbacks, promises are great composable primitives. |
| 2682 | |
| 2683 | ```js |
| 2684 | Promise.all([ |
| 2685 | getJSON('/posts'), |
| 2686 | getJSON('/comments') |
| 2687 | ]).then(function(values){ |
| 2688 | values[0] // => postsJSON |
| 2689 | values[1] // => commentsJSON |
| 2690 | |
| 2691 | return values; |
| 2692 | }); |
| 2693 | ``` |
| 2694 | |
| 2695 | @class Promise |
| 2696 | @param {function} resolver |
| 2697 | Useful for tooling. |
| 2698 | @constructor |
| 2699 | */ |
| 2700 | |
| 2701 | |
| 2702 | function Promise(resolver) { |
| 2703 | this[PROMISE_ID] = nextId(); |
| 2704 | this._result = this._state = undefined; |
| 2705 | this._subscribers = []; |
| 2706 | |
| 2707 | if (noop !== resolver) { |
| 2708 | typeof resolver !== 'function' && needsResolver(); |
| 2709 | this instanceof Promise ? initializePromise(this, resolver) : needsNew(); |
| 2710 | } |
| 2711 | } |
| 2712 | |
| 2713 | Promise.all = all; |
| 2714 | Promise.race = race; |
| 2715 | Promise.resolve = resolve; |
| 2716 | Promise.reject = reject; |
| 2717 | Promise._setScheduler = setScheduler; |
| 2718 | Promise._setAsap = setAsap; |
| 2719 | Promise._asap = asap; |
| 2720 | Promise.prototype = { |
| 2721 | constructor: Promise, |
| 2722 | |
| 2723 | /** |
| 2724 | The primary way of interacting with a promise is through its `then` method, |
| 2725 | which registers callbacks to receive either a promise's eventual value or the |
| 2726 | reason why the promise cannot be fulfilled. |
| 2727 | |
| 2728 | ```js |
| 2729 | findUser().then(function(user){ |
| 2730 | // user is available |
| 2731 | }, function(reason){ |
| 2732 | // user is unavailable, and you are given the reason why |
| 2733 | }); |
| 2734 | ``` |
| 2735 | |
| 2736 | Chaining |
| 2737 | -------- |
| 2738 | |
| 2739 | The return value of `then` is itself a promise. This second, 'downstream' |
| 2740 | promise is resolved with the return value of the first promise's fulfillment |
| 2741 | or rejection handler, or rejected if the handler throws an exception. |
| 2742 | |
| 2743 | ```js |
| 2744 | findUser().then(function (user) { |
| 2745 | return user.name; |
| 2746 | }, function (reason) { |
| 2747 | return 'default name'; |
| 2748 | }).then(function (userName) { |
| 2749 | // If `findUser` fulfilled, `userName` will be the user's name, otherwise it |
| 2750 | // will be `'default name'` |
| 2751 | }); |
| 2752 | |
| 2753 | findUser().then(function (user) { |
| 2754 | throw new Error('Found user, but still unhappy'); |
| 2755 | }, function (reason) { |
| 2756 | throw new Error('`findUser` rejected and we're unhappy'); |
| 2757 | }).then(function (value) { |
| 2758 | // never reached |
| 2759 | }, function (reason) { |
| 2760 | // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. |
| 2761 | // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. |
| 2762 | }); |
| 2763 | ``` |
| 2764 | If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. |
| 2765 | |
| 2766 | ```js |
| 2767 | findUser().then(function (user) { |
| 2768 | throw new PedagogicalException('Upstream error'); |
| 2769 | }).then(function (value) { |
| 2770 | // never reached |
| 2771 | }).then(function (value) { |
| 2772 | // never reached |
| 2773 | }, function (reason) { |
| 2774 | // The `PedgagocialException` is propagated all the way down to here |
| 2775 | }); |
| 2776 | ``` |
| 2777 | |
| 2778 | Assimilation |
| 2779 | ------------ |
| 2780 | |
| 2781 | Sometimes the value you want to propagate to a downstream promise can only be |
| 2782 | retrieved asynchronously. This can be achieved by returning a promise in the |
| 2783 | fulfillment or rejection handler. The downstream promise will then be pending |
| 2784 | until the returned promise is settled. This is called *assimilation*. |
| 2785 | |
| 2786 | ```js |
| 2787 | findUser().then(function (user) { |
| 2788 | return findCommentsByAuthor(user); |
| 2789 | }).then(function (comments) { |
| 2790 | // The user's comments are now available |
| 2791 | }); |
| 2792 | ``` |
| 2793 | |
| 2794 | If the assimliated promise rejects, then the downstream promise will also reject. |
| 2795 | |
| 2796 | ```js |
| 2797 | findUser().then(function (user) { |
| 2798 | return findCommentsByAuthor(user); |
| 2799 | }).then(function (comments) { |
| 2800 | // If `findCommentsByAuthor` fulfills, we'll have the value here |
| 2801 | }, function (reason) { |
| 2802 | // If `findCommentsByAuthor` rejects, we'll have the reason here |
| 2803 | }); |
| 2804 | ``` |
| 2805 | |
| 2806 | Simple Example |
| 2807 | -------------- |
| 2808 | |
| 2809 | Synchronous Example |
| 2810 | |
| 2811 | ```javascript |
| 2812 | let result; |
| 2813 | |
| 2814 | try { |
| 2815 | result = findResult(); |
| 2816 | // success |
| 2817 | } catch(reason) { |
| 2818 | // failure |
| 2819 | } |
| 2820 | ``` |
| 2821 | |
| 2822 | Errback Example |
| 2823 | |
| 2824 | ```js |
| 2825 | findResult(function(result, err){ |
| 2826 | if (err) { |
| 2827 | // failure |
| 2828 | } else { |
| 2829 | // success |
| 2830 | } |
| 2831 | }); |
| 2832 | ``` |
| 2833 | |
| 2834 | Promise Example; |
| 2835 | |
| 2836 | ```javascript |
| 2837 | findResult().then(function(result){ |
| 2838 | // success |
| 2839 | }, function(reason){ |
| 2840 | // failure |
| 2841 | }); |
| 2842 | ``` |
| 2843 | |
| 2844 | Advanced Example |
| 2845 | -------------- |
| 2846 | |
| 2847 | Synchronous Example |
| 2848 | |
| 2849 | ```javascript |
| 2850 | let author, books; |
| 2851 | |
| 2852 | try { |
| 2853 | author = findAuthor(); |
| 2854 | books = findBooksByAuthor(author); |
| 2855 | // success |
| 2856 | } catch(reason) { |
| 2857 | // failure |
| 2858 | } |
| 2859 | ``` |
| 2860 | |
| 2861 | Errback Example |
| 2862 | |
| 2863 | ```js |
| 2864 | |
| 2865 | function foundBooks(books) { |
| 2866 | |
| 2867 | } |
| 2868 | |
| 2869 | function failure(reason) { |
| 2870 | |
| 2871 | } |
| 2872 | |
| 2873 | findAuthor(function(author, err){ |
| 2874 | if (err) { |
| 2875 | failure(err); |
| 2876 | // failure |
| 2877 | } else { |
| 2878 | try { |
| 2879 | findBoooksByAuthor(author, function(books, err) { |
| 2880 | if (err) { |
| 2881 | failure(err); |
| 2882 | } else { |
| 2883 | try { |
| 2884 | foundBooks(books); |
| 2885 | } catch(reason) { |
| 2886 | failure(reason); |
| 2887 | } |
| 2888 | } |
| 2889 | }); |
| 2890 | } catch(error) { |
| 2891 | failure(err); |
| 2892 | } |
| 2893 | // success |
| 2894 | } |
| 2895 | }); |
| 2896 | ``` |
| 2897 | |
| 2898 | Promise Example; |
| 2899 | |
| 2900 | ```javascript |
| 2901 | findAuthor(). |
| 2902 | then(findBooksByAuthor). |
| 2903 | then(function(books){ |
| 2904 | // found books |
| 2905 | }).catch(function(reason){ |
| 2906 | // something went wrong |
| 2907 | }); |
| 2908 | ``` |
| 2909 | |
| 2910 | @method then |
| 2911 | @param {Function} onFulfilled |
| 2912 | @param {Function} onRejected |
| 2913 | Useful for tooling. |
| 2914 | @return {Promise} |
| 2915 | */ |
| 2916 | then: then, |
| 2917 | |
| 2918 | /** |
| 2919 | `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same |
| 2920 | as the catch block of a try/catch statement. |
| 2921 | |
| 2922 | ```js |
| 2923 | function findAuthor(){ |
| 2924 | throw new Error('couldn't find that author'); |
| 2925 | } |
| 2926 | |
| 2927 | // synchronous |
| 2928 | try { |
| 2929 | findAuthor(); |
| 2930 | } catch(reason) { |
| 2931 | // something went wrong |
| 2932 | } |
| 2933 | |
| 2934 | // async with promises |
| 2935 | findAuthor().catch(function(reason){ |
| 2936 | // something went wrong |
| 2937 | }); |
| 2938 | ``` |
| 2939 | |
| 2940 | @method catch |
| 2941 | @param {Function} onRejection |
| 2942 | Useful for tooling. |
| 2943 | @return {Promise} |
| 2944 | */ |
| 2945 | 'catch': function _catch(onRejection) { |
| 2946 | return this.then(null, onRejection); |
| 2947 | } |
| 2948 | }; |
| 2949 | |
| 2950 | function polyfill() { |
| 2951 | var local = undefined; |
| 2952 | |
| 2953 | if (typeof global !== 'undefined') { |
| 2954 | local = global; |
| 2955 | } else if (typeof self !== 'undefined') { |
| 2956 | local = self; |
| 2957 | } else { |
| 2958 | try { |
| 2959 | local = Function('return this')(); |
| 2960 | } catch (e) { |
| 2961 | throw new Error('polyfill failed because global object is unavailable in this environment'); |
| 2962 | } |
| 2963 | } |
| 2964 | |
| 2965 | var P = local.Promise; |
| 2966 | |
| 2967 | if (P) { |
| 2968 | var promiseToString = null; |
| 2969 | |
| 2970 | try { |
| 2971 | promiseToString = Object.prototype.toString.call(P.resolve()); |
| 2972 | } catch (e) {// silently ignored |
| 2973 | } |
| 2974 | |
| 2975 | if (promiseToString === '[object Promise]' && !P.cast) { |
| 2976 | return; |
| 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | local.Promise = Promise; |
| 2981 | } |
| 2982 | |
| 2983 | polyfill(); // Strange compat.. |
| 2984 | |
| 2985 | Promise.polyfill = polyfill; |
| 2986 | Promise.Promise = Promise; |
| 2987 | return Promise; |
| 2988 | }); |
| 2989 | /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) |
| 2990 | |
| 2991 | /***/ }), |
| 2992 | |
| 2993 | /***/ "./node_modules/process/browser.js": |
| 2994 | /*!*****************************************!*\ |
| 2995 | !*** ./node_modules/process/browser.js ***! |
| 2996 | \*****************************************/ |
| 2997 | /*! no static exports found */ |
| 2998 | /***/ (function(module, exports) { |
| 2999 | |
| 3000 | // shim for using process in browser |
| 3001 | var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it |
| 3002 | // don't break things. But we need to wrap it in a try catch in case it is |
| 3003 | // wrapped in strict mode code which doesn't define any globals. It's inside a |
| 3004 | // function because try/catches deoptimize in certain engines. |
| 3005 | |
| 3006 | var cachedSetTimeout; |
| 3007 | var cachedClearTimeout; |
| 3008 | |
| 3009 | function defaultSetTimout() { |
| 3010 | throw new Error('setTimeout has not been defined'); |
| 3011 | } |
| 3012 | |
| 3013 | function defaultClearTimeout() { |
| 3014 | throw new Error('clearTimeout has not been defined'); |
| 3015 | } |
| 3016 | |
| 3017 | (function () { |
| 3018 | try { |
| 3019 | if (typeof setTimeout === 'function') { |
| 3020 | cachedSetTimeout = setTimeout; |
| 3021 | } else { |
| 3022 | cachedSetTimeout = defaultSetTimout; |
| 3023 | } |
| 3024 | } catch (e) { |
| 3025 | cachedSetTimeout = defaultSetTimout; |
| 3026 | } |
| 3027 | |
| 3028 | try { |
| 3029 | if (typeof clearTimeout === 'function') { |
| 3030 | cachedClearTimeout = clearTimeout; |
| 3031 | } else { |
| 3032 | cachedClearTimeout = defaultClearTimeout; |
| 3033 | } |
| 3034 | } catch (e) { |
| 3035 | cachedClearTimeout = defaultClearTimeout; |
| 3036 | } |
| 3037 | })(); |
| 3038 | |
| 3039 | function runTimeout(fun) { |
| 3040 | if (cachedSetTimeout === setTimeout) { |
| 3041 | //normal enviroments in sane situations |
| 3042 | return setTimeout(fun, 0); |
| 3043 | } // if setTimeout wasn't available but was latter defined |
| 3044 | |
| 3045 | |
| 3046 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
| 3047 | cachedSetTimeout = setTimeout; |
| 3048 | return setTimeout(fun, 0); |
| 3049 | } |
| 3050 | |
| 3051 | try { |
| 3052 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 3053 | return cachedSetTimeout(fun, 0); |
| 3054 | } catch (e) { |
| 3055 | try { |
| 3056 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 3057 | return cachedSetTimeout.call(null, fun, 0); |
| 3058 | } catch (e) { |
| 3059 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error |
| 3060 | return cachedSetTimeout.call(this, fun, 0); |
| 3061 | } |
| 3062 | } |
| 3063 | } |
| 3064 | |
| 3065 | function runClearTimeout(marker) { |
| 3066 | if (cachedClearTimeout === clearTimeout) { |
| 3067 | //normal enviroments in sane situations |
| 3068 | return clearTimeout(marker); |
| 3069 | } // if clearTimeout wasn't available but was latter defined |
| 3070 | |
| 3071 | |
| 3072 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
| 3073 | cachedClearTimeout = clearTimeout; |
| 3074 | return clearTimeout(marker); |
| 3075 | } |
| 3076 | |
| 3077 | try { |
| 3078 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 3079 | return cachedClearTimeout(marker); |
| 3080 | } catch (e) { |
| 3081 | try { |
| 3082 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 3083 | return cachedClearTimeout.call(null, marker); |
| 3084 | } catch (e) { |
| 3085 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. |
| 3086 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout |
| 3087 | return cachedClearTimeout.call(this, marker); |
| 3088 | } |
| 3089 | } |
| 3090 | } |
| 3091 | |
| 3092 | var queue = []; |
| 3093 | var draining = false; |
| 3094 | var currentQueue; |
| 3095 | var queueIndex = -1; |
| 3096 | |
| 3097 | function cleanUpNextTick() { |
| 3098 | if (!draining || !currentQueue) { |
| 3099 | return; |
| 3100 | } |
| 3101 | |
| 3102 | draining = false; |
| 3103 | |
| 3104 | if (currentQueue.length) { |
| 3105 | queue = currentQueue.concat(queue); |
| 3106 | } else { |
| 3107 | queueIndex = -1; |
| 3108 | } |
| 3109 | |
| 3110 | if (queue.length) { |
| 3111 | drainQueue(); |
| 3112 | } |
| 3113 | } |
| 3114 | |
| 3115 | function drainQueue() { |
| 3116 | if (draining) { |
| 3117 | return; |
| 3118 | } |
| 3119 | |
| 3120 | var timeout = runTimeout(cleanUpNextTick); |
| 3121 | draining = true; |
| 3122 | var len = queue.length; |
| 3123 | |
| 3124 | while (len) { |
| 3125 | currentQueue = queue; |
| 3126 | queue = []; |
| 3127 | |
| 3128 | while (++queueIndex < len) { |
| 3129 | if (currentQueue) { |
| 3130 | currentQueue[queueIndex].run(); |
| 3131 | } |
| 3132 | } |
| 3133 | |
| 3134 | queueIndex = -1; |
| 3135 | len = queue.length; |
| 3136 | } |
| 3137 | |
| 3138 | currentQueue = null; |
| 3139 | draining = false; |
| 3140 | runClearTimeout(timeout); |
| 3141 | } |
| 3142 | |
| 3143 | process.nextTick = function (fun) { |
| 3144 | var args = new Array(arguments.length - 1); |
| 3145 | |
| 3146 | if (arguments.length > 1) { |
| 3147 | for (var i = 1; i < arguments.length; i++) { |
| 3148 | args[i - 1] = arguments[i]; |
| 3149 | } |
| 3150 | } |
| 3151 | |
| 3152 | queue.push(new Item(fun, args)); |
| 3153 | |
| 3154 | if (queue.length === 1 && !draining) { |
| 3155 | runTimeout(drainQueue); |
| 3156 | } |
| 3157 | }; // v8 likes predictible objects |
| 3158 | |
| 3159 | |
| 3160 | function Item(fun, array) { |
| 3161 | this.fun = fun; |
| 3162 | this.array = array; |
| 3163 | } |
| 3164 | |
| 3165 | Item.prototype.run = function () { |
| 3166 | this.fun.apply(null, this.array); |
| 3167 | }; |
| 3168 | |
| 3169 | process.title = 'browser'; |
| 3170 | process.browser = true; |
| 3171 | process.env = {}; |
| 3172 | process.argv = []; |
| 3173 | process.version = ''; // empty string to avoid regexp issues |
| 3174 | |
| 3175 | process.versions = {}; |
| 3176 | |
| 3177 | function noop() {} |
| 3178 | |
| 3179 | process.on = noop; |
| 3180 | process.addListener = noop; |
| 3181 | process.once = noop; |
| 3182 | process.off = noop; |
| 3183 | process.removeListener = noop; |
| 3184 | process.removeAllListeners = noop; |
| 3185 | process.emit = noop; |
| 3186 | process.prependListener = noop; |
| 3187 | process.prependOnceListener = noop; |
| 3188 | |
| 3189 | process.listeners = function (name) { |
| 3190 | return []; |
| 3191 | }; |
| 3192 | |
| 3193 | process.binding = function (name) { |
| 3194 | throw new Error('process.binding is not supported'); |
| 3195 | }; |
| 3196 | |
| 3197 | process.cwd = function () { |
| 3198 | return '/'; |
| 3199 | }; |
| 3200 | |
| 3201 | process.chdir = function (dir) { |
| 3202 | throw new Error('process.chdir is not supported'); |
| 3203 | }; |
| 3204 | |
| 3205 | process.umask = function () { |
| 3206 | return 0; |
| 3207 | }; |
| 3208 | |
| 3209 | /***/ }), |
| 3210 | |
| 3211 | /***/ "./node_modules/regenerator-runtime/runtime.js": |
| 3212 | /*!*****************************************************!*\ |
| 3213 | !*** ./node_modules/regenerator-runtime/runtime.js ***! |
| 3214 | \*****************************************************/ |
| 3215 | /*! no static exports found */ |
| 3216 | /***/ (function(module, exports, __webpack_require__) { |
| 3217 | |
| 3218 | /* WEBPACK VAR INJECTION */(function(module) {function _typeof(obj) { "@babel/helpers - typeof"; 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); } |
| 3219 | |
| 3220 | /** |
| 3221 | * Copyright (c) 2014-present, Facebook, Inc. |
| 3222 | * |
| 3223 | * This source code is licensed under the MIT license found in the |
| 3224 | * LICENSE file in the root directory of this source tree. |
| 3225 | */ |
| 3226 | var runtime = function (exports) { |
| 3227 | "use strict"; |
| 3228 | |
| 3229 | var Op = Object.prototype; |
| 3230 | var hasOwn = Op.hasOwnProperty; |
| 3231 | var undefined; // More compressible than void 0. |
| 3232 | |
| 3233 | var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
| 3234 | var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
| 3235 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
| 3236 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
| 3237 | |
| 3238 | function wrap(innerFn, outerFn, self, tryLocsList) { |
| 3239 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
| 3240 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
| 3241 | var generator = Object.create(protoGenerator.prototype); |
| 3242 | var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, |
| 3243 | // .throw, and .return methods. |
| 3244 | |
| 3245 | generator._invoke = makeInvokeMethod(innerFn, self, context); |
| 3246 | return generator; |
| 3247 | } |
| 3248 | |
| 3249 | exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion |
| 3250 | // record like context.tryEntries[i].completion. This interface could |
| 3251 | // have been (and was previously) designed to take a closure to be |
| 3252 | // invoked without arguments, but in all the cases we care about we |
| 3253 | // already have an existing method we want to call, so there's no need |
| 3254 | // to create a new function object. We can even get away with assuming |
| 3255 | // the method takes exactly one argument, since that happens to be true |
| 3256 | // in every case, so we don't have to touch the arguments object. The |
| 3257 | // only additional allocation required is the completion record, which |
| 3258 | // has a stable shape and so hopefully should be cheap to allocate. |
| 3259 | |
| 3260 | function tryCatch(fn, obj, arg) { |
| 3261 | try { |
| 3262 | return { |
| 3263 | type: "normal", |
| 3264 | arg: fn.call(obj, arg) |
| 3265 | }; |
| 3266 | } catch (err) { |
| 3267 | return { |
| 3268 | type: "throw", |
| 3269 | arg: err |
| 3270 | }; |
| 3271 | } |
| 3272 | } |
| 3273 | |
| 3274 | var GenStateSuspendedStart = "suspendedStart"; |
| 3275 | var GenStateSuspendedYield = "suspendedYield"; |
| 3276 | var GenStateExecuting = "executing"; |
| 3277 | var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as |
| 3278 | // breaking out of the dispatch switch statement. |
| 3279 | |
| 3280 | var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and |
| 3281 | // .constructor.prototype properties for functions that return Generator |
| 3282 | // objects. For full spec compliance, you may wish to configure your |
| 3283 | // minifier not to mangle the names of these two functions. |
| 3284 | |
| 3285 | function Generator() {} |
| 3286 | |
| 3287 | function GeneratorFunction() {} |
| 3288 | |
| 3289 | function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that |
| 3290 | // don't natively support it. |
| 3291 | |
| 3292 | |
| 3293 | var IteratorPrototype = {}; |
| 3294 | |
| 3295 | IteratorPrototype[iteratorSymbol] = function () { |
| 3296 | return this; |
| 3297 | }; |
| 3298 | |
| 3299 | var getProto = Object.getPrototypeOf; |
| 3300 | var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
| 3301 | |
| 3302 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
| 3303 | // This environment has a native %IteratorPrototype%; use it instead |
| 3304 | // of the polyfill. |
| 3305 | IteratorPrototype = NativeIteratorPrototype; |
| 3306 | } |
| 3307 | |
| 3308 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
| 3309 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
| 3310 | GeneratorFunctionPrototype.constructor = GeneratorFunction; |
| 3311 | GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the |
| 3312 | // Iterator interface in terms of a single ._invoke method. |
| 3313 | |
| 3314 | function defineIteratorMethods(prototype) { |
| 3315 | ["next", "throw", "return"].forEach(function (method) { |
| 3316 | prototype[method] = function (arg) { |
| 3317 | return this._invoke(method, arg); |
| 3318 | }; |
| 3319 | }); |
| 3320 | } |
| 3321 | |
| 3322 | exports.isGeneratorFunction = function (genFun) { |
| 3323 | var ctor = typeof genFun === "function" && genFun.constructor; |
| 3324 | return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can |
| 3325 | // do is to check its .name property. |
| 3326 | (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
| 3327 | }; |
| 3328 | |
| 3329 | exports.mark = function (genFun) { |
| 3330 | if (Object.setPrototypeOf) { |
| 3331 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
| 3332 | } else { |
| 3333 | genFun.__proto__ = GeneratorFunctionPrototype; |
| 3334 | |
| 3335 | if (!(toStringTagSymbol in genFun)) { |
| 3336 | genFun[toStringTagSymbol] = "GeneratorFunction"; |
| 3337 | } |
| 3338 | } |
| 3339 | |
| 3340 | genFun.prototype = Object.create(Gp); |
| 3341 | return genFun; |
| 3342 | }; // Within the body of any async function, `await x` is transformed to |
| 3343 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
| 3344 | // `hasOwn.call(value, "__await")` to determine if the yielded value is |
| 3345 | // meant to be awaited. |
| 3346 | |
| 3347 | |
| 3348 | exports.awrap = function (arg) { |
| 3349 | return { |
| 3350 | __await: arg |
| 3351 | }; |
| 3352 | }; |
| 3353 | |
| 3354 | function AsyncIterator(generator, PromiseImpl) { |
| 3355 | function invoke(method, arg, resolve, reject) { |
| 3356 | var record = tryCatch(generator[method], generator, arg); |
| 3357 | |
| 3358 | if (record.type === "throw") { |
| 3359 | reject(record.arg); |
| 3360 | } else { |
| 3361 | var result = record.arg; |
| 3362 | var value = result.value; |
| 3363 | |
| 3364 | if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) { |
| 3365 | return PromiseImpl.resolve(value.__await).then(function (value) { |
| 3366 | invoke("next", value, resolve, reject); |
| 3367 | }, function (err) { |
| 3368 | invoke("throw", err, resolve, reject); |
| 3369 | }); |
| 3370 | } |
| 3371 | |
| 3372 | return PromiseImpl.resolve(value).then(function (unwrapped) { |
| 3373 | // When a yielded Promise is resolved, its final value becomes |
| 3374 | // the .value of the Promise<{value,done}> result for the |
| 3375 | // current iteration. |
| 3376 | result.value = unwrapped; |
| 3377 | resolve(result); |
| 3378 | }, function (error) { |
| 3379 | // If a rejected Promise was yielded, throw the rejection back |
| 3380 | // into the async generator function so it can be handled there. |
| 3381 | return invoke("throw", error, resolve, reject); |
| 3382 | }); |
| 3383 | } |
| 3384 | } |
| 3385 | |
| 3386 | var previousPromise; |
| 3387 | |
| 3388 | function enqueue(method, arg) { |
| 3389 | function callInvokeWithMethodAndArg() { |
| 3390 | return new PromiseImpl(function (resolve, reject) { |
| 3391 | invoke(method, arg, resolve, reject); |
| 3392 | }); |
| 3393 | } |
| 3394 | |
| 3395 | return previousPromise = // If enqueue has been called before, then we want to wait until |
| 3396 | // all previous Promises have been resolved before calling invoke, |
| 3397 | // so that results are always delivered in the correct order. If |
| 3398 | // enqueue has not been called before, then it is important to |
| 3399 | // call invoke immediately, without waiting on a callback to fire, |
| 3400 | // so that the async generator function has the opportunity to do |
| 3401 | // any necessary setup in a predictable way. This predictability |
| 3402 | // is why the Promise constructor synchronously invokes its |
| 3403 | // executor callback, and why async functions synchronously |
| 3404 | // execute code before the first await. Since we implement simple |
| 3405 | // async functions in terms of async generators, it is especially |
| 3406 | // important to get this right, even though it requires care. |
| 3407 | previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later |
| 3408 | // invocations of the iterator. |
| 3409 | callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
| 3410 | } // Define the unified helper method that is used to implement .next, |
| 3411 | // .throw, and .return (see defineIteratorMethods). |
| 3412 | |
| 3413 | |
| 3414 | this._invoke = enqueue; |
| 3415 | } |
| 3416 | |
| 3417 | defineIteratorMethods(AsyncIterator.prototype); |
| 3418 | |
| 3419 | AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
| 3420 | return this; |
| 3421 | }; |
| 3422 | |
| 3423 | exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of |
| 3424 | // AsyncIterator objects; they just return a Promise for the value of |
| 3425 | // the final result produced by the iterator. |
| 3426 | |
| 3427 | exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { |
| 3428 | if (PromiseImpl === void 0) PromiseImpl = Promise; |
| 3429 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); |
| 3430 | return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. |
| 3431 | : iter.next().then(function (result) { |
| 3432 | return result.done ? result.value : iter.next(); |
| 3433 | }); |
| 3434 | }; |
| 3435 | |
| 3436 | function makeInvokeMethod(innerFn, self, context) { |
| 3437 | var state = GenStateSuspendedStart; |
| 3438 | return function invoke(method, arg) { |
| 3439 | if (state === GenStateExecuting) { |
| 3440 | throw new Error("Generator is already running"); |
| 3441 | } |
| 3442 | |
| 3443 | if (state === GenStateCompleted) { |
| 3444 | if (method === "throw") { |
| 3445 | throw arg; |
| 3446 | } // Be forgiving, per 25.3.3.3.3 of the spec: |
| 3447 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
| 3448 | |
| 3449 | |
| 3450 | return doneResult(); |
| 3451 | } |
| 3452 | |
| 3453 | context.method = method; |
| 3454 | context.arg = arg; |
| 3455 | |
| 3456 | while (true) { |
| 3457 | var delegate = context.delegate; |
| 3458 | |
| 3459 | if (delegate) { |
| 3460 | var delegateResult = maybeInvokeDelegate(delegate, context); |
| 3461 | |
| 3462 | if (delegateResult) { |
| 3463 | if (delegateResult === ContinueSentinel) continue; |
| 3464 | return delegateResult; |
| 3465 | } |
| 3466 | } |
| 3467 | |
| 3468 | if (context.method === "next") { |
| 3469 | // Setting context._sent for legacy support of Babel's |
| 3470 | // function.sent implementation. |
| 3471 | context.sent = context._sent = context.arg; |
| 3472 | } else if (context.method === "throw") { |
| 3473 | if (state === GenStateSuspendedStart) { |
| 3474 | state = GenStateCompleted; |
| 3475 | throw context.arg; |
| 3476 | } |
| 3477 | |
| 3478 | context.dispatchException(context.arg); |
| 3479 | } else if (context.method === "return") { |
| 3480 | context.abrupt("return", context.arg); |
| 3481 | } |
| 3482 | |
| 3483 | state = GenStateExecuting; |
| 3484 | var record = tryCatch(innerFn, self, context); |
| 3485 | |
| 3486 | if (record.type === "normal") { |
| 3487 | // If an exception is thrown from innerFn, we leave state === |
| 3488 | // GenStateExecuting and loop back for another invocation. |
| 3489 | state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
| 3490 | |
| 3491 | if (record.arg === ContinueSentinel) { |
| 3492 | continue; |
| 3493 | } |
| 3494 | |
| 3495 | return { |
| 3496 | value: record.arg, |
| 3497 | done: context.done |
| 3498 | }; |
| 3499 | } else if (record.type === "throw") { |
| 3500 | state = GenStateCompleted; // Dispatch the exception by looping back around to the |
| 3501 | // context.dispatchException(context.arg) call above. |
| 3502 | |
| 3503 | context.method = "throw"; |
| 3504 | context.arg = record.arg; |
| 3505 | } |
| 3506 | } |
| 3507 | }; |
| 3508 | } // Call delegate.iterator[context.method](context.arg) and handle the |
| 3509 | // result, either by returning a { value, done } result from the |
| 3510 | // delegate iterator, or by modifying context.method and context.arg, |
| 3511 | // setting context.delegate to null, and returning the ContinueSentinel. |
| 3512 | |
| 3513 | |
| 3514 | function maybeInvokeDelegate(delegate, context) { |
| 3515 | var method = delegate.iterator[context.method]; |
| 3516 | |
| 3517 | if (method === undefined) { |
| 3518 | // A .throw or .return when the delegate iterator has no .throw |
| 3519 | // method always terminates the yield* loop. |
| 3520 | context.delegate = null; |
| 3521 | |
| 3522 | if (context.method === "throw") { |
| 3523 | // Note: ["return"] must be used for ES3 parsing compatibility. |
| 3524 | if (delegate.iterator["return"]) { |
| 3525 | // If the delegate iterator has a return method, give it a |
| 3526 | // chance to clean up. |
| 3527 | context.method = "return"; |
| 3528 | context.arg = undefined; |
| 3529 | maybeInvokeDelegate(delegate, context); |
| 3530 | |
| 3531 | if (context.method === "throw") { |
| 3532 | // If maybeInvokeDelegate(context) changed context.method from |
| 3533 | // "return" to "throw", let that override the TypeError below. |
| 3534 | return ContinueSentinel; |
| 3535 | } |
| 3536 | } |
| 3537 | |
| 3538 | context.method = "throw"; |
| 3539 | context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
| 3540 | } |
| 3541 | |
| 3542 | return ContinueSentinel; |
| 3543 | } |
| 3544 | |
| 3545 | var record = tryCatch(method, delegate.iterator, context.arg); |
| 3546 | |
| 3547 | if (record.type === "throw") { |
| 3548 | context.method = "throw"; |
| 3549 | context.arg = record.arg; |
| 3550 | context.delegate = null; |
| 3551 | return ContinueSentinel; |
| 3552 | } |
| 3553 | |
| 3554 | var info = record.arg; |
| 3555 | |
| 3556 | if (!info) { |
| 3557 | context.method = "throw"; |
| 3558 | context.arg = new TypeError("iterator result is not an object"); |
| 3559 | context.delegate = null; |
| 3560 | return ContinueSentinel; |
| 3561 | } |
| 3562 | |
| 3563 | if (info.done) { |
| 3564 | // Assign the result of the finished delegate to the temporary |
| 3565 | // variable specified by delegate.resultName (see delegateYield). |
| 3566 | context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). |
| 3567 | |
| 3568 | context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the |
| 3569 | // exception, let the outer generator proceed normally. If |
| 3570 | // context.method was "next", forget context.arg since it has been |
| 3571 | // "consumed" by the delegate iterator. If context.method was |
| 3572 | // "return", allow the original .return call to continue in the |
| 3573 | // outer generator. |
| 3574 | |
| 3575 | if (context.method !== "return") { |
| 3576 | context.method = "next"; |
| 3577 | context.arg = undefined; |
| 3578 | } |
| 3579 | } else { |
| 3580 | // Re-yield the result returned by the delegate method. |
| 3581 | return info; |
| 3582 | } // The delegate iterator is finished, so forget it and continue with |
| 3583 | // the outer generator. |
| 3584 | |
| 3585 | |
| 3586 | context.delegate = null; |
| 3587 | return ContinueSentinel; |
| 3588 | } // Define Generator.prototype.{next,throw,return} in terms of the |
| 3589 | // unified ._invoke helper method. |
| 3590 | |
| 3591 | |
| 3592 | defineIteratorMethods(Gp); |
| 3593 | Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the |
| 3594 | // @@iterator function is called on it. Some browsers' implementations of the |
| 3595 | // iterator prototype chain incorrectly implement this, causing the Generator |
| 3596 | // object to not be returned from this call. This ensures that doesn't happen. |
| 3597 | // See https://github.com/facebook/regenerator/issues/274 for more details. |
| 3598 | |
| 3599 | Gp[iteratorSymbol] = function () { |
| 3600 | return this; |
| 3601 | }; |
| 3602 | |
| 3603 | Gp.toString = function () { |
| 3604 | return "[object Generator]"; |
| 3605 | }; |
| 3606 | |
| 3607 | function pushTryEntry(locs) { |
| 3608 | var entry = { |
| 3609 | tryLoc: locs[0] |
| 3610 | }; |
| 3611 | |
| 3612 | if (1 in locs) { |
| 3613 | entry.catchLoc = locs[1]; |
| 3614 | } |
| 3615 | |
| 3616 | if (2 in locs) { |
| 3617 | entry.finallyLoc = locs[2]; |
| 3618 | entry.afterLoc = locs[3]; |
| 3619 | } |
| 3620 | |
| 3621 | this.tryEntries.push(entry); |
| 3622 | } |
| 3623 | |
| 3624 | function resetTryEntry(entry) { |
| 3625 | var record = entry.completion || {}; |
| 3626 | record.type = "normal"; |
| 3627 | delete record.arg; |
| 3628 | entry.completion = record; |
| 3629 | } |
| 3630 | |
| 3631 | function Context(tryLocsList) { |
| 3632 | // The root entry object (effectively a try statement without a catch |
| 3633 | // or a finally block) gives us a place to store values thrown from |
| 3634 | // locations where there is no enclosing try statement. |
| 3635 | this.tryEntries = [{ |
| 3636 | tryLoc: "root" |
| 3637 | }]; |
| 3638 | tryLocsList.forEach(pushTryEntry, this); |
| 3639 | this.reset(true); |
| 3640 | } |
| 3641 | |
| 3642 | exports.keys = function (object) { |
| 3643 | var keys = []; |
| 3644 | |
| 3645 | for (var key in object) { |
| 3646 | keys.push(key); |
| 3647 | } |
| 3648 | |
| 3649 | keys.reverse(); // Rather than returning an object with a next method, we keep |
| 3650 | // things simple and return the next function itself. |
| 3651 | |
| 3652 | return function next() { |
| 3653 | while (keys.length) { |
| 3654 | var key = keys.pop(); |
| 3655 | |
| 3656 | if (key in object) { |
| 3657 | next.value = key; |
| 3658 | next.done = false; |
| 3659 | return next; |
| 3660 | } |
| 3661 | } // To avoid creating an additional object, we just hang the .value |
| 3662 | // and .done properties off the next function object itself. This |
| 3663 | // also ensures that the minifier will not anonymize the function. |
| 3664 | |
| 3665 | |
| 3666 | next.done = true; |
| 3667 | return next; |
| 3668 | }; |
| 3669 | }; |
| 3670 | |
| 3671 | function values(iterable) { |
| 3672 | if (iterable) { |
| 3673 | var iteratorMethod = iterable[iteratorSymbol]; |
| 3674 | |
| 3675 | if (iteratorMethod) { |
| 3676 | return iteratorMethod.call(iterable); |
| 3677 | } |
| 3678 | |
| 3679 | if (typeof iterable.next === "function") { |
| 3680 | return iterable; |
| 3681 | } |
| 3682 | |
| 3683 | if (!isNaN(iterable.length)) { |
| 3684 | var i = -1, |
| 3685 | next = function next() { |
| 3686 | while (++i < iterable.length) { |
| 3687 | if (hasOwn.call(iterable, i)) { |
| 3688 | next.value = iterable[i]; |
| 3689 | next.done = false; |
| 3690 | return next; |
| 3691 | } |
| 3692 | } |
| 3693 | |
| 3694 | next.value = undefined; |
| 3695 | next.done = true; |
| 3696 | return next; |
| 3697 | }; |
| 3698 | |
| 3699 | return next.next = next; |
| 3700 | } |
| 3701 | } // Return an iterator with no values. |
| 3702 | |
| 3703 | |
| 3704 | return { |
| 3705 | next: doneResult |
| 3706 | }; |
| 3707 | } |
| 3708 | |
| 3709 | exports.values = values; |
| 3710 | |
| 3711 | function doneResult() { |
| 3712 | return { |
| 3713 | value: undefined, |
| 3714 | done: true |
| 3715 | }; |
| 3716 | } |
| 3717 | |
| 3718 | Context.prototype = { |
| 3719 | constructor: Context, |
| 3720 | reset: function reset(skipTempReset) { |
| 3721 | this.prev = 0; |
| 3722 | this.next = 0; // Resetting context._sent for legacy support of Babel's |
| 3723 | // function.sent implementation. |
| 3724 | |
| 3725 | this.sent = this._sent = undefined; |
| 3726 | this.done = false; |
| 3727 | this.delegate = null; |
| 3728 | this.method = "next"; |
| 3729 | this.arg = undefined; |
| 3730 | this.tryEntries.forEach(resetTryEntry); |
| 3731 | |
| 3732 | if (!skipTempReset) { |
| 3733 | for (var name in this) { |
| 3734 | // Not sure about the optimal order of these conditions: |
| 3735 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { |
| 3736 | this[name] = undefined; |
| 3737 | } |
| 3738 | } |
| 3739 | } |
| 3740 | }, |
| 3741 | stop: function stop() { |
| 3742 | this.done = true; |
| 3743 | var rootEntry = this.tryEntries[0]; |
| 3744 | var rootRecord = rootEntry.completion; |
| 3745 | |
| 3746 | if (rootRecord.type === "throw") { |
| 3747 | throw rootRecord.arg; |
| 3748 | } |
| 3749 | |
| 3750 | return this.rval; |
| 3751 | }, |
| 3752 | dispatchException: function dispatchException(exception) { |
| 3753 | if (this.done) { |
| 3754 | throw exception; |
| 3755 | } |
| 3756 | |
| 3757 | var context = this; |
| 3758 | |
| 3759 | function handle(loc, caught) { |
| 3760 | record.type = "throw"; |
| 3761 | record.arg = exception; |
| 3762 | context.next = loc; |
| 3763 | |
| 3764 | if (caught) { |
| 3765 | // If the dispatched exception was caught by a catch block, |
| 3766 | // then let that catch block handle the exception normally. |
| 3767 | context.method = "next"; |
| 3768 | context.arg = undefined; |
| 3769 | } |
| 3770 | |
| 3771 | return !!caught; |
| 3772 | } |
| 3773 | |
| 3774 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 3775 | var entry = this.tryEntries[i]; |
| 3776 | var record = entry.completion; |
| 3777 | |
| 3778 | if (entry.tryLoc === "root") { |
| 3779 | // Exception thrown outside of any try block that could handle |
| 3780 | // it, so set the completion value of the entire function to |
| 3781 | // throw the exception. |
| 3782 | return handle("end"); |
| 3783 | } |
| 3784 | |
| 3785 | if (entry.tryLoc <= this.prev) { |
| 3786 | var hasCatch = hasOwn.call(entry, "catchLoc"); |
| 3787 | var hasFinally = hasOwn.call(entry, "finallyLoc"); |
| 3788 | |
| 3789 | if (hasCatch && hasFinally) { |
| 3790 | if (this.prev < entry.catchLoc) { |
| 3791 | return handle(entry.catchLoc, true); |
| 3792 | } else if (this.prev < entry.finallyLoc) { |
| 3793 | return handle(entry.finallyLoc); |
| 3794 | } |
| 3795 | } else if (hasCatch) { |
| 3796 | if (this.prev < entry.catchLoc) { |
| 3797 | return handle(entry.catchLoc, true); |
| 3798 | } |
| 3799 | } else if (hasFinally) { |
| 3800 | if (this.prev < entry.finallyLoc) { |
| 3801 | return handle(entry.finallyLoc); |
| 3802 | } |
| 3803 | } else { |
| 3804 | throw new Error("try statement without catch or finally"); |
| 3805 | } |
| 3806 | } |
| 3807 | } |
| 3808 | }, |
| 3809 | abrupt: function abrupt(type, arg) { |
| 3810 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 3811 | var entry = this.tryEntries[i]; |
| 3812 | |
| 3813 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
| 3814 | var finallyEntry = entry; |
| 3815 | break; |
| 3816 | } |
| 3817 | } |
| 3818 | |
| 3819 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { |
| 3820 | // Ignore the finally entry if control is not jumping to a |
| 3821 | // location outside the try/catch block. |
| 3822 | finallyEntry = null; |
| 3823 | } |
| 3824 | |
| 3825 | var record = finallyEntry ? finallyEntry.completion : {}; |
| 3826 | record.type = type; |
| 3827 | record.arg = arg; |
| 3828 | |
| 3829 | if (finallyEntry) { |
| 3830 | this.method = "next"; |
| 3831 | this.next = finallyEntry.finallyLoc; |
| 3832 | return ContinueSentinel; |
| 3833 | } |
| 3834 | |
| 3835 | return this.complete(record); |
| 3836 | }, |
| 3837 | complete: function complete(record, afterLoc) { |
| 3838 | if (record.type === "throw") { |
| 3839 | throw record.arg; |
| 3840 | } |
| 3841 | |
| 3842 | if (record.type === "break" || record.type === "continue") { |
| 3843 | this.next = record.arg; |
| 3844 | } else if (record.type === "return") { |
| 3845 | this.rval = this.arg = record.arg; |
| 3846 | this.method = "return"; |
| 3847 | this.next = "end"; |
| 3848 | } else if (record.type === "normal" && afterLoc) { |
| 3849 | this.next = afterLoc; |
| 3850 | } |
| 3851 | |
| 3852 | return ContinueSentinel; |
| 3853 | }, |
| 3854 | finish: function finish(finallyLoc) { |
| 3855 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 3856 | var entry = this.tryEntries[i]; |
| 3857 | |
| 3858 | if (entry.finallyLoc === finallyLoc) { |
| 3859 | this.complete(entry.completion, entry.afterLoc); |
| 3860 | resetTryEntry(entry); |
| 3861 | return ContinueSentinel; |
| 3862 | } |
| 3863 | } |
| 3864 | }, |
| 3865 | "catch": function _catch(tryLoc) { |
| 3866 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 3867 | var entry = this.tryEntries[i]; |
| 3868 | |
| 3869 | if (entry.tryLoc === tryLoc) { |
| 3870 | var record = entry.completion; |
| 3871 | |
| 3872 | if (record.type === "throw") { |
| 3873 | var thrown = record.arg; |
| 3874 | resetTryEntry(entry); |
| 3875 | } |
| 3876 | |
| 3877 | return thrown; |
| 3878 | } |
| 3879 | } // The context.catch method must only be called with a location |
| 3880 | // argument that corresponds to a known catch block. |
| 3881 | |
| 3882 | |
| 3883 | throw new Error("illegal catch attempt"); |
| 3884 | }, |
| 3885 | delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
| 3886 | this.delegate = { |
| 3887 | iterator: values(iterable), |
| 3888 | resultName: resultName, |
| 3889 | nextLoc: nextLoc |
| 3890 | }; |
| 3891 | |
| 3892 | if (this.method === "next") { |
| 3893 | // Deliberately forget the last sent value so that we don't |
| 3894 | // accidentally pass it on to the delegate. |
| 3895 | this.arg = undefined; |
| 3896 | } |
| 3897 | |
| 3898 | return ContinueSentinel; |
| 3899 | } |
| 3900 | }; // Regardless of whether this script is executing as a CommonJS module |
| 3901 | // or not, return the runtime object so that we can declare the variable |
| 3902 | // regeneratorRuntime in the outer scope, which allows this module to be |
| 3903 | // injected easily by `bin/regenerator --include-runtime script.js`. |
| 3904 | |
| 3905 | return exports; |
| 3906 | }( // If this script is executing as a CommonJS module, use module.exports |
| 3907 | // as the regeneratorRuntime namespace. Otherwise create a new empty |
| 3908 | // object. Either way, the resulting object will be used to initialize |
| 3909 | // the regeneratorRuntime variable at the top of this file. |
| 3910 | ( false ? undefined : _typeof(module)) === "object" ? module.exports : {}); |
| 3911 | |
| 3912 | try { |
| 3913 | regeneratorRuntime = runtime; |
| 3914 | } catch (accidentalStrictMode) { |
| 3915 | // This module should not be running in strict mode, so the above |
| 3916 | // assignment should always work unless something is misconfigured. Just |
| 3917 | // in case runtime.js accidentally runs in strict mode, we can escape |
| 3918 | // strict mode using a global Function call. This could conceivably fail |
| 3919 | // if a Content Security Policy forbids using Function, but in that case |
| 3920 | // the proper solution is to fix the accidental strict mode problem. If |
| 3921 | // you've misconfigured your bundler to force strict mode and applied a |
| 3922 | // CSP to forbid Function, and you're not willing to fix either of those |
| 3923 | // problems, please detail your unique predicament in a GitHub issue. |
| 3924 | Function("r", "regeneratorRuntime = r")(runtime); |
| 3925 | } |
| 3926 | /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module))) |
| 3927 | |
| 3928 | /***/ }), |
| 3929 | |
| 3930 | /***/ "./node_modules/webpack/buildin/global.js": |
| 3931 | /*!***********************************!*\ |
| 3932 | !*** (webpack)/buildin/global.js ***! |
| 3933 | \***********************************/ |
| 3934 | /*! no static exports found */ |
| 3935 | /***/ (function(module, exports) { |
| 3936 | |
| 3937 | function _typeof(obj) { "@babel/helpers - typeof"; 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); } |
| 3938 | |
| 3939 | var g; // This works in non-strict mode |
| 3940 | |
| 3941 | g = function () { |
| 3942 | return this; |
| 3943 | }(); |
| 3944 | |
| 3945 | try { |
| 3946 | // This works if eval is allowed (see CSP) |
| 3947 | g = g || new Function("return this")(); |
| 3948 | } catch (e) { |
| 3949 | // This works if the window reference is available |
| 3950 | if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; |
| 3951 | } // g can still be undefined, but nothing to do about it... |
| 3952 | // We return undefined, instead of nothing here, so it's |
| 3953 | // easier to handle this case. if(!global) { ...} |
| 3954 | |
| 3955 | |
| 3956 | module.exports = g; |
| 3957 | |
| 3958 | /***/ }), |
| 3959 | |
| 3960 | /***/ "./node_modules/webpack/buildin/module.js": |
| 3961 | /*!***********************************!*\ |
| 3962 | !*** (webpack)/buildin/module.js ***! |
| 3963 | \***********************************/ |
| 3964 | /*! no static exports found */ |
| 3965 | /***/ (function(module, exports) { |
| 3966 | |
| 3967 | module.exports = function (module) { |
| 3968 | if (!module.webpackPolyfill) { |
| 3969 | module.deprecate = function () {}; |
| 3970 | |
| 3971 | module.paths = []; // module.parent = undefined by default |
| 3972 | |
| 3973 | if (!module.children) module.children = []; |
| 3974 | Object.defineProperty(module, "loaded", { |
| 3975 | enumerable: true, |
| 3976 | get: function get() { |
| 3977 | return module.l; |
| 3978 | } |
| 3979 | }); |
| 3980 | Object.defineProperty(module, "id", { |
| 3981 | enumerable: true, |
| 3982 | get: function get() { |
| 3983 | return module.i; |
| 3984 | } |
| 3985 | }); |
| 3986 | module.webpackPolyfill = 1; |
| 3987 | } |
| 3988 | |
| 3989 | return module; |
| 3990 | }; |
| 3991 | |
| 3992 | /***/ }), |
| 3993 | |
| 3994 | /***/ 0: |
| 3995 | /*!*****************************************************!*\ |
| 3996 | !*** multi es6-promise-promise ./js/scripts_es6.js ***! |
| 3997 | \*****************************************************/ |
| 3998 | /*! no static exports found */ |
| 3999 | /***/ (function(module, exports, __webpack_require__) { |
| 4000 | |
| 4001 | __webpack_require__(/*! es6-promise-promise */"./node_modules/es6-promise-promise/index.js"); |
| 4002 | module.exports = __webpack_require__(/*! ./js/scripts_es6.js */"./js/scripts_es6.js"); |
| 4003 | |
| 4004 | |
| 4005 | /***/ }), |
| 4006 | |
| 4007 | /***/ 1: |
| 4008 | /*!***********************!*\ |
| 4009 | !*** vertx (ignored) ***! |
| 4010 | \***********************/ |
| 4011 | /*! no static exports found */ |
| 4012 | /***/ (function(module, exports) { |
| 4013 | |
| 4014 | /* (ignored) */ |
| 4015 | |
| 4016 | /***/ }) |
| 4017 | |
| 4018 | /******/ }); |
| 4019 | //# sourceMappingURL=scripts.js.map |