hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1 | /*! |
| 2 | * Intro.js v4.2.2 |
| 3 | * https://introjs.com |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4 | * |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 5 | * Copyright (C) 2012-2021 Afshin Mehrabani (@afshinmeh). |
| 6 | * https://raw.githubusercontent.com/usablica/intro.js/master/license.md |
| 7 | * |
| 8 | * Date: Fri, 27 Aug 2021 12:07:05 GMT |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 11 | (function (global, factory) { |
| 12 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 13 | typeof define === 'function' && define.amd ? define(factory) : |
| 14 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.introJs = factory()); |
| 15 | }(this, (function () { 'use strict'; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 16 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 17 | function _typeof(obj) { |
| 18 | "@babel/helpers - typeof"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 19 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 20 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
| 21 | _typeof = function (obj) { |
| 22 | return typeof obj; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 23 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 24 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 25 | _typeof = function (obj) { |
| 26 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| 27 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 28 | } |
| 29 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 30 | return _typeof(obj); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 34 | * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 |
| 35 | * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 36 | * |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 37 | * @param obj1 |
| 38 | * @param obj2 |
| 39 | * @returns obj3 a new object based on obj1 and obj2 |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 40 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 41 | function mergeOptions(obj1, obj2) { |
| 42 | var obj3 = {}; |
| 43 | var attrname; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 44 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 45 | for (attrname in obj1) { |
| 46 | obj3[attrname] = obj1[attrname]; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 47 | } |
| 48 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 49 | for (attrname in obj2) { |
| 50 | obj3[attrname] = obj2[attrname]; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 51 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 52 | |
| 53 | return obj3; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 57 | * Mark any object with an incrementing number |
| 58 | * used for keeping track of objects |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 59 | * |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 60 | * @param Object obj Any object or DOM Element |
| 61 | * @param String key |
| 62 | * @return Object |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 63 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 64 | var stamp = function () { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 65 | var keys = {}; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 66 | return function stamp(obj) { |
| 67 | var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "introjs-stamp"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 68 | // each group increments from 0 |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 69 | keys[key] = keys[key] || 0; // stamp only once per object |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 70 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 71 | if (obj[key] === undefined) { |
| 72 | // increment key for each new object |
| 73 | obj[key] = keys[key]++; |
| 74 | } |
| 75 | |
| 76 | return obj[key]; |
| 77 | }; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 78 | }(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 79 | |
| 80 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 81 | * Iterates arrays |
| 82 | * |
| 83 | * @param {Array} arr |
| 84 | * @param {Function} forEachFnc |
| 85 | * @param {Function} [completeFnc] |
| 86 | * @return {Null} |
| 87 | */ |
| 88 | function forEach(arr, forEachFnc, completeFnc) { |
| 89 | // in case arr is an empty query selector node list |
| 90 | if (arr) { |
| 91 | for (var i = 0, len = arr.length; i < len; i++) { |
| 92 | forEachFnc(arr[i], i); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if (typeof completeFnc === "function") { |
| 97 | completeFnc(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * DOMEvent Handles all DOM events |
| 103 | * |
| 104 | * methods: |
| 105 | * |
| 106 | * on - add event handler |
| 107 | * off - remove event |
| 108 | */ |
| 109 | |
| 110 | var DOMEvent = function () { |
| 111 | function DOMEvent() { |
| 112 | var events_key = "introjs_event"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 113 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 114 | * Gets a unique ID for an event listener |
| 115 | * |
| 116 | * @param obj Object |
| 117 | * @param type event type |
| 118 | * @param listener Function |
| 119 | * @param context Object |
| 120 | * @return String |
| 121 | */ |
| 122 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 123 | this._id = function (obj, type, listener, context) { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 124 | return type + stamp(listener) + (context ? "_".concat(stamp(context)) : ""); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 125 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 126 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 127 | * Adds event listener |
| 128 | * |
| 129 | * @param obj Object obj |
| 130 | * @param type String |
| 131 | * @param listener Function |
| 132 | * @param context Object |
| 133 | * @param useCapture Boolean |
| 134 | * @return null |
| 135 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 136 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 137 | |
| 138 | this.on = function (obj, type, listener, context, useCapture) { |
| 139 | var id = this._id.apply(this, arguments); |
| 140 | |
| 141 | var handler = function handler(e) { |
| 142 | return listener.call(context || obj, e || window.event); |
| 143 | }; |
| 144 | |
| 145 | if ("addEventListener" in obj) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 146 | obj.addEventListener(type, handler, useCapture); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 147 | } else if ("attachEvent" in obj) { |
| 148 | obj.attachEvent("on".concat(type), handler); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | obj[events_key] = obj[events_key] || {}; |
| 152 | obj[events_key][id] = handler; |
| 153 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 154 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 155 | * Removes event listener |
| 156 | * |
| 157 | * @param obj Object |
| 158 | * @param type String |
| 159 | * @param listener Function |
| 160 | * @param context Object |
| 161 | * @param useCapture Boolean |
| 162 | * @return null |
| 163 | */ |
| 164 | |
| 165 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 166 | this.off = function (obj, type, listener, context, useCapture) { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 167 | var id = this._id.apply(this, arguments); |
| 168 | |
| 169 | var handler = obj[events_key] && obj[events_key][id]; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 170 | |
| 171 | if (!handler) { |
| 172 | return; |
| 173 | } |
| 174 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 175 | if ("removeEventListener" in obj) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 176 | obj.removeEventListener(type, handler, useCapture); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 177 | } else if ("detachEvent" in obj) { |
| 178 | obj.detachEvent("on".concat(type), handler); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | obj[events_key][id] = null; |
| 182 | }; |
| 183 | } |
| 184 | |
| 185 | return new DOMEvent(); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 186 | }(); |
| 187 | |
| 188 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; |
| 189 | |
| 190 | function createCommonjsModule(fn, module) { |
| 191 | return module = { exports: {} }, fn(module, module.exports), module.exports; |
| 192 | } |
| 193 | |
| 194 | var check = function (it) { |
| 195 | return it && it.Math == Math && it; |
| 196 | }; |
| 197 | |
| 198 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 |
| 199 | var global_1 = |
| 200 | // eslint-disable-next-line es/no-global-this -- safe |
| 201 | check(typeof globalThis == 'object' && globalThis) || |
| 202 | check(typeof window == 'object' && window) || |
| 203 | // eslint-disable-next-line no-restricted-globals -- safe |
| 204 | check(typeof self == 'object' && self) || |
| 205 | check(typeof commonjsGlobal == 'object' && commonjsGlobal) || |
| 206 | // eslint-disable-next-line no-new-func -- fallback |
| 207 | (function () { return this; })() || Function('return this')(); |
| 208 | |
| 209 | var fails = function (exec) { |
| 210 | try { |
| 211 | return !!exec(); |
| 212 | } catch (error) { |
| 213 | return true; |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | // Detect IE8's incomplete defineProperty implementation |
| 218 | var descriptors = !fails(function () { |
| 219 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing |
| 220 | return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; |
| 221 | }); |
| 222 | |
| 223 | var $propertyIsEnumerable = {}.propertyIsEnumerable; |
| 224 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 225 | var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; |
| 226 | |
| 227 | // Nashorn ~ JDK8 bug |
| 228 | var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1); |
| 229 | |
| 230 | // `Object.prototype.propertyIsEnumerable` method implementation |
| 231 | // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable |
| 232 | var f$4 = NASHORN_BUG ? function propertyIsEnumerable(V) { |
| 233 | var descriptor = getOwnPropertyDescriptor$1(this, V); |
| 234 | return !!descriptor && descriptor.enumerable; |
| 235 | } : $propertyIsEnumerable; |
| 236 | |
| 237 | var objectPropertyIsEnumerable = { |
| 238 | f: f$4 |
| 239 | }; |
| 240 | |
| 241 | var createPropertyDescriptor = function (bitmap, value) { |
| 242 | return { |
| 243 | enumerable: !(bitmap & 1), |
| 244 | configurable: !(bitmap & 2), |
| 245 | writable: !(bitmap & 4), |
| 246 | value: value |
| 247 | }; |
| 248 | }; |
| 249 | |
| 250 | var toString = {}.toString; |
| 251 | |
| 252 | var classofRaw = function (it) { |
| 253 | return toString.call(it).slice(8, -1); |
| 254 | }; |
| 255 | |
| 256 | var split = ''.split; |
| 257 | |
| 258 | // fallback for non-array-like ES3 and non-enumerable old V8 strings |
| 259 | var indexedObject = fails(function () { |
| 260 | // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 |
| 261 | // eslint-disable-next-line no-prototype-builtins -- safe |
| 262 | return !Object('z').propertyIsEnumerable(0); |
| 263 | }) ? function (it) { |
| 264 | return classofRaw(it) == 'String' ? split.call(it, '') : Object(it); |
| 265 | } : Object; |
| 266 | |
| 267 | // `RequireObjectCoercible` abstract operation |
| 268 | // https://tc39.es/ecma262/#sec-requireobjectcoercible |
| 269 | var requireObjectCoercible = function (it) { |
| 270 | if (it == undefined) throw TypeError("Can't call method on " + it); |
| 271 | return it; |
| 272 | }; |
| 273 | |
| 274 | // toObject with fallback for non-array-like ES3 strings |
| 275 | |
| 276 | |
| 277 | |
| 278 | var toIndexedObject = function (it) { |
| 279 | return indexedObject(requireObjectCoercible(it)); |
| 280 | }; |
| 281 | |
| 282 | var isObject = function (it) { |
| 283 | return typeof it === 'object' ? it !== null : typeof it === 'function'; |
| 284 | }; |
| 285 | |
| 286 | var aFunction$1 = function (variable) { |
| 287 | return typeof variable == 'function' ? variable : undefined; |
| 288 | }; |
| 289 | |
| 290 | var getBuiltIn = function (namespace, method) { |
| 291 | return arguments.length < 2 ? aFunction$1(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; |
| 292 | }; |
| 293 | |
| 294 | var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; |
| 295 | |
| 296 | var process = global_1.process; |
| 297 | var Deno = global_1.Deno; |
| 298 | var versions = process && process.versions || Deno && Deno.version; |
| 299 | var v8 = versions && versions.v8; |
| 300 | var match, version$1; |
| 301 | |
| 302 | if (v8) { |
| 303 | match = v8.split('.'); |
| 304 | version$1 = match[0] < 4 ? 1 : match[0] + match[1]; |
| 305 | } else if (engineUserAgent) { |
| 306 | match = engineUserAgent.match(/Edge\/(\d+)/); |
| 307 | if (!match || match[1] >= 74) { |
| 308 | match = engineUserAgent.match(/Chrome\/(\d+)/); |
| 309 | if (match) version$1 = match[1]; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | var engineV8Version = version$1 && +version$1; |
| 314 | |
| 315 | /* eslint-disable es/no-symbol -- required for testing */ |
| 316 | |
| 317 | |
| 318 | |
| 319 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing |
| 320 | var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { |
| 321 | var symbol = Symbol(); |
| 322 | // Chrome 38 Symbol has incorrect toString conversion |
| 323 | // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances |
| 324 | return !String(symbol) || !(Object(symbol) instanceof Symbol) || |
| 325 | // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances |
| 326 | !Symbol.sham && engineV8Version && engineV8Version < 41; |
| 327 | }); |
| 328 | |
| 329 | /* eslint-disable es/no-symbol -- required for testing */ |
| 330 | |
| 331 | |
| 332 | var useSymbolAsUid = nativeSymbol |
| 333 | && !Symbol.sham |
| 334 | && typeof Symbol.iterator == 'symbol'; |
| 335 | |
| 336 | var isSymbol = useSymbolAsUid ? function (it) { |
| 337 | return typeof it == 'symbol'; |
| 338 | } : function (it) { |
| 339 | var $Symbol = getBuiltIn('Symbol'); |
| 340 | return typeof $Symbol == 'function' && Object(it) instanceof $Symbol; |
| 341 | }; |
| 342 | |
| 343 | // `OrdinaryToPrimitive` abstract operation |
| 344 | // https://tc39.es/ecma262/#sec-ordinarytoprimitive |
| 345 | var ordinaryToPrimitive = function (input, pref) { |
| 346 | var fn, val; |
| 347 | if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; |
| 348 | if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val; |
| 349 | if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; |
| 350 | throw TypeError("Can't convert object to primitive value"); |
| 351 | }; |
| 352 | |
| 353 | var setGlobal = function (key, value) { |
| 354 | try { |
| 355 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 356 | Object.defineProperty(global_1, key, { value: value, configurable: true, writable: true }); |
| 357 | } catch (error) { |
| 358 | global_1[key] = value; |
| 359 | } return value; |
| 360 | }; |
| 361 | |
| 362 | var SHARED = '__core-js_shared__'; |
| 363 | var store$1 = global_1[SHARED] || setGlobal(SHARED, {}); |
| 364 | |
| 365 | var sharedStore = store$1; |
| 366 | |
| 367 | var shared = createCommonjsModule(function (module) { |
| 368 | (module.exports = function (key, value) { |
| 369 | return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); |
| 370 | })('versions', []).push({ |
| 371 | version: '3.16.1', |
| 372 | mode: 'global', |
| 373 | copyright: '© 2021 Denis Pushkarev (zloirock.ru)' |
| 374 | }); |
| 375 | }); |
| 376 | |
| 377 | // `ToObject` abstract operation |
| 378 | // https://tc39.es/ecma262/#sec-toobject |
| 379 | var toObject = function (argument) { |
| 380 | return Object(requireObjectCoercible(argument)); |
| 381 | }; |
| 382 | |
| 383 | var hasOwnProperty = {}.hasOwnProperty; |
| 384 | |
| 385 | var has$1 = Object.hasOwn || function hasOwn(it, key) { |
| 386 | return hasOwnProperty.call(toObject(it), key); |
| 387 | }; |
| 388 | |
| 389 | var id = 0; |
| 390 | var postfix = Math.random(); |
| 391 | |
| 392 | var uid = function (key) { |
| 393 | return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36); |
| 394 | }; |
| 395 | |
| 396 | var WellKnownSymbolsStore = shared('wks'); |
| 397 | var Symbol$1 = global_1.Symbol; |
| 398 | var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; |
| 399 | |
| 400 | var wellKnownSymbol = function (name) { |
| 401 | if (!has$1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { |
| 402 | if (nativeSymbol && has$1(Symbol$1, name)) { |
| 403 | WellKnownSymbolsStore[name] = Symbol$1[name]; |
| 404 | } else { |
| 405 | WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name); |
| 406 | } |
| 407 | } return WellKnownSymbolsStore[name]; |
| 408 | }; |
| 409 | |
| 410 | var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); |
| 411 | |
| 412 | // `ToPrimitive` abstract operation |
| 413 | // https://tc39.es/ecma262/#sec-toprimitive |
| 414 | var toPrimitive = function (input, pref) { |
| 415 | if (!isObject(input) || isSymbol(input)) return input; |
| 416 | var exoticToPrim = input[TO_PRIMITIVE]; |
| 417 | var result; |
| 418 | if (exoticToPrim !== undefined) { |
| 419 | if (pref === undefined) pref = 'default'; |
| 420 | result = exoticToPrim.call(input, pref); |
| 421 | if (!isObject(result) || isSymbol(result)) return result; |
| 422 | throw TypeError("Can't convert object to primitive value"); |
| 423 | } |
| 424 | if (pref === undefined) pref = 'number'; |
| 425 | return ordinaryToPrimitive(input, pref); |
| 426 | }; |
| 427 | |
| 428 | // `ToPropertyKey` abstract operation |
| 429 | // https://tc39.es/ecma262/#sec-topropertykey |
| 430 | var toPropertyKey = function (argument) { |
| 431 | var key = toPrimitive(argument, 'string'); |
| 432 | return isSymbol(key) ? key : String(key); |
| 433 | }; |
| 434 | |
| 435 | var document$1 = global_1.document; |
| 436 | // typeof document.createElement is 'object' in old IE |
| 437 | var EXISTS = isObject(document$1) && isObject(document$1.createElement); |
| 438 | |
| 439 | var documentCreateElement = function (it) { |
| 440 | return EXISTS ? document$1.createElement(it) : {}; |
| 441 | }; |
| 442 | |
| 443 | // Thank's IE8 for his funny defineProperty |
| 444 | var ie8DomDefine = !descriptors && !fails(function () { |
| 445 | // eslint-disable-next-line es/no-object-defineproperty -- requied for testing |
| 446 | return Object.defineProperty(documentCreateElement('div'), 'a', { |
| 447 | get: function () { return 7; } |
| 448 | }).a != 7; |
| 449 | }); |
| 450 | |
| 451 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 452 | var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 453 | |
| 454 | // `Object.getOwnPropertyDescriptor` method |
| 455 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor |
| 456 | var f$3 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { |
| 457 | O = toIndexedObject(O); |
| 458 | P = toPropertyKey(P); |
| 459 | if (ie8DomDefine) try { |
| 460 | return $getOwnPropertyDescriptor(O, P); |
| 461 | } catch (error) { /* empty */ } |
| 462 | if (has$1(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]); |
| 463 | }; |
| 464 | |
| 465 | var objectGetOwnPropertyDescriptor = { |
| 466 | f: f$3 |
| 467 | }; |
| 468 | |
| 469 | var anObject = function (it) { |
| 470 | if (!isObject(it)) { |
| 471 | throw TypeError(String(it) + ' is not an object'); |
| 472 | } return it; |
| 473 | }; |
| 474 | |
| 475 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 476 | var $defineProperty = Object.defineProperty; |
| 477 | |
| 478 | // `Object.defineProperty` method |
| 479 | // https://tc39.es/ecma262/#sec-object.defineproperty |
| 480 | var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { |
| 481 | anObject(O); |
| 482 | P = toPropertyKey(P); |
| 483 | anObject(Attributes); |
| 484 | if (ie8DomDefine) try { |
| 485 | return $defineProperty(O, P, Attributes); |
| 486 | } catch (error) { /* empty */ } |
| 487 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); |
| 488 | if ('value' in Attributes) O[P] = Attributes.value; |
| 489 | return O; |
| 490 | }; |
| 491 | |
| 492 | var objectDefineProperty = { |
| 493 | f: f$2 |
| 494 | }; |
| 495 | |
| 496 | var createNonEnumerableProperty = descriptors ? function (object, key, value) { |
| 497 | return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); |
| 498 | } : function (object, key, value) { |
| 499 | object[key] = value; |
| 500 | return object; |
| 501 | }; |
| 502 | |
| 503 | var functionToString = Function.toString; |
| 504 | |
| 505 | // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper |
| 506 | if (typeof sharedStore.inspectSource != 'function') { |
| 507 | sharedStore.inspectSource = function (it) { |
| 508 | return functionToString.call(it); |
| 509 | }; |
| 510 | } |
| 511 | |
| 512 | var inspectSource = sharedStore.inspectSource; |
| 513 | |
| 514 | var WeakMap$1 = global_1.WeakMap; |
| 515 | |
| 516 | var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1)); |
| 517 | |
| 518 | var keys = shared('keys'); |
| 519 | |
| 520 | var sharedKey = function (key) { |
| 521 | return keys[key] || (keys[key] = uid(key)); |
| 522 | }; |
| 523 | |
| 524 | var hiddenKeys$1 = {}; |
| 525 | |
| 526 | var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; |
| 527 | var WeakMap = global_1.WeakMap; |
| 528 | var set, get, has; |
| 529 | |
| 530 | var enforce = function (it) { |
| 531 | return has(it) ? get(it) : set(it, {}); |
| 532 | }; |
| 533 | |
| 534 | var getterFor = function (TYPE) { |
| 535 | return function (it) { |
| 536 | var state; |
| 537 | if (!isObject(it) || (state = get(it)).type !== TYPE) { |
| 538 | throw TypeError('Incompatible receiver, ' + TYPE + ' required'); |
| 539 | } return state; |
| 540 | }; |
| 541 | }; |
| 542 | |
| 543 | if (nativeWeakMap || sharedStore.state) { |
| 544 | var store = sharedStore.state || (sharedStore.state = new WeakMap()); |
| 545 | var wmget = store.get; |
| 546 | var wmhas = store.has; |
| 547 | var wmset = store.set; |
| 548 | set = function (it, metadata) { |
| 549 | if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); |
| 550 | metadata.facade = it; |
| 551 | wmset.call(store, it, metadata); |
| 552 | return metadata; |
| 553 | }; |
| 554 | get = function (it) { |
| 555 | return wmget.call(store, it) || {}; |
| 556 | }; |
| 557 | has = function (it) { |
| 558 | return wmhas.call(store, it); |
| 559 | }; |
| 560 | } else { |
| 561 | var STATE = sharedKey('state'); |
| 562 | hiddenKeys$1[STATE] = true; |
| 563 | set = function (it, metadata) { |
| 564 | if (has$1(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); |
| 565 | metadata.facade = it; |
| 566 | createNonEnumerableProperty(it, STATE, metadata); |
| 567 | return metadata; |
| 568 | }; |
| 569 | get = function (it) { |
| 570 | return has$1(it, STATE) ? it[STATE] : {}; |
| 571 | }; |
| 572 | has = function (it) { |
| 573 | return has$1(it, STATE); |
| 574 | }; |
| 575 | } |
| 576 | |
| 577 | var internalState = { |
| 578 | set: set, |
| 579 | get: get, |
| 580 | has: has, |
| 581 | enforce: enforce, |
| 582 | getterFor: getterFor |
| 583 | }; |
| 584 | |
| 585 | var redefine = createCommonjsModule(function (module) { |
| 586 | var getInternalState = internalState.get; |
| 587 | var enforceInternalState = internalState.enforce; |
| 588 | var TEMPLATE = String(String).split('String'); |
| 589 | |
| 590 | (module.exports = function (O, key, value, options) { |
| 591 | var unsafe = options ? !!options.unsafe : false; |
| 592 | var simple = options ? !!options.enumerable : false; |
| 593 | var noTargetGet = options ? !!options.noTargetGet : false; |
| 594 | var state; |
| 595 | if (typeof value == 'function') { |
| 596 | if (typeof key == 'string' && !has$1(value, 'name')) { |
| 597 | createNonEnumerableProperty(value, 'name', key); |
| 598 | } |
| 599 | state = enforceInternalState(value); |
| 600 | if (!state.source) { |
| 601 | state.source = TEMPLATE.join(typeof key == 'string' ? key : ''); |
| 602 | } |
| 603 | } |
| 604 | if (O === global_1) { |
| 605 | if (simple) O[key] = value; |
| 606 | else setGlobal(key, value); |
| 607 | return; |
| 608 | } else if (!unsafe) { |
| 609 | delete O[key]; |
| 610 | } else if (!noTargetGet && O[key]) { |
| 611 | simple = true; |
| 612 | } |
| 613 | if (simple) O[key] = value; |
| 614 | else createNonEnumerableProperty(O, key, value); |
| 615 | // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative |
| 616 | })(Function.prototype, 'toString', function toString() { |
| 617 | return typeof this == 'function' && getInternalState(this).source || inspectSource(this); |
| 618 | }); |
| 619 | }); |
| 620 | |
| 621 | var ceil = Math.ceil; |
| 622 | var floor$2 = Math.floor; |
| 623 | |
| 624 | // `ToInteger` abstract operation |
| 625 | // https://tc39.es/ecma262/#sec-tointeger |
| 626 | var toInteger = function (argument) { |
| 627 | return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$2 : ceil)(argument); |
| 628 | }; |
| 629 | |
| 630 | var min$4 = Math.min; |
| 631 | |
| 632 | // `ToLength` abstract operation |
| 633 | // https://tc39.es/ecma262/#sec-tolength |
| 634 | var toLength = function (argument) { |
| 635 | return argument > 0 ? min$4(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 |
| 636 | }; |
| 637 | |
| 638 | var max$3 = Math.max; |
| 639 | var min$3 = Math.min; |
| 640 | |
| 641 | // Helper for a popular repeating case of the spec: |
| 642 | // Let integer be ? ToInteger(index). |
| 643 | // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). |
| 644 | var toAbsoluteIndex = function (index, length) { |
| 645 | var integer = toInteger(index); |
| 646 | return integer < 0 ? max$3(integer + length, 0) : min$3(integer, length); |
| 647 | }; |
| 648 | |
| 649 | // `Array.prototype.{ indexOf, includes }` methods implementation |
| 650 | var createMethod$2 = function (IS_INCLUDES) { |
| 651 | return function ($this, el, fromIndex) { |
| 652 | var O = toIndexedObject($this); |
| 653 | var length = toLength(O.length); |
| 654 | var index = toAbsoluteIndex(fromIndex, length); |
| 655 | var value; |
| 656 | // Array#includes uses SameValueZero equality algorithm |
| 657 | // eslint-disable-next-line no-self-compare -- NaN check |
| 658 | if (IS_INCLUDES && el != el) while (length > index) { |
| 659 | value = O[index++]; |
| 660 | // eslint-disable-next-line no-self-compare -- NaN check |
| 661 | if (value != value) return true; |
| 662 | // Array#indexOf ignores holes, Array#includes - not |
| 663 | } else for (;length > index; index++) { |
| 664 | if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; |
| 665 | } return !IS_INCLUDES && -1; |
| 666 | }; |
| 667 | }; |
| 668 | |
| 669 | var arrayIncludes = { |
| 670 | // `Array.prototype.includes` method |
| 671 | // https://tc39.es/ecma262/#sec-array.prototype.includes |
| 672 | includes: createMethod$2(true), |
| 673 | // `Array.prototype.indexOf` method |
| 674 | // https://tc39.es/ecma262/#sec-array.prototype.indexof |
| 675 | indexOf: createMethod$2(false) |
| 676 | }; |
| 677 | |
| 678 | var indexOf = arrayIncludes.indexOf; |
| 679 | |
| 680 | |
| 681 | var objectKeysInternal = function (object, names) { |
| 682 | var O = toIndexedObject(object); |
| 683 | var i = 0; |
| 684 | var result = []; |
| 685 | var key; |
| 686 | for (key in O) !has$1(hiddenKeys$1, key) && has$1(O, key) && result.push(key); |
| 687 | // Don't enum bug & hidden keys |
| 688 | while (names.length > i) if (has$1(O, key = names[i++])) { |
| 689 | ~indexOf(result, key) || result.push(key); |
| 690 | } |
| 691 | return result; |
| 692 | }; |
| 693 | |
| 694 | // IE8- don't enum bug keys |
| 695 | var enumBugKeys = [ |
| 696 | 'constructor', |
| 697 | 'hasOwnProperty', |
| 698 | 'isPrototypeOf', |
| 699 | 'propertyIsEnumerable', |
| 700 | 'toLocaleString', |
| 701 | 'toString', |
| 702 | 'valueOf' |
| 703 | ]; |
| 704 | |
| 705 | var hiddenKeys = enumBugKeys.concat('length', 'prototype'); |
| 706 | |
| 707 | // `Object.getOwnPropertyNames` method |
| 708 | // https://tc39.es/ecma262/#sec-object.getownpropertynames |
| 709 | // eslint-disable-next-line es/no-object-getownpropertynames -- safe |
| 710 | var f$1 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { |
| 711 | return objectKeysInternal(O, hiddenKeys); |
| 712 | }; |
| 713 | |
| 714 | var objectGetOwnPropertyNames = { |
| 715 | f: f$1 |
| 716 | }; |
| 717 | |
| 718 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe |
| 719 | var f = Object.getOwnPropertySymbols; |
| 720 | |
| 721 | var objectGetOwnPropertySymbols = { |
| 722 | f: f |
| 723 | }; |
| 724 | |
| 725 | // all object keys, includes non-enumerable and symbols |
| 726 | var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { |
| 727 | var keys = objectGetOwnPropertyNames.f(anObject(it)); |
| 728 | var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; |
| 729 | return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys; |
| 730 | }; |
| 731 | |
| 732 | var copyConstructorProperties = function (target, source) { |
| 733 | var keys = ownKeys(source); |
| 734 | var defineProperty = objectDefineProperty.f; |
| 735 | var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; |
| 736 | for (var i = 0; i < keys.length; i++) { |
| 737 | var key = keys[i]; |
| 738 | if (!has$1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); |
| 739 | } |
| 740 | }; |
| 741 | |
| 742 | var replacement = /#|\.prototype\./; |
| 743 | |
| 744 | var isForced = function (feature, detection) { |
| 745 | var value = data[normalize(feature)]; |
| 746 | return value == POLYFILL ? true |
| 747 | : value == NATIVE ? false |
| 748 | : typeof detection == 'function' ? fails(detection) |
| 749 | : !!detection; |
| 750 | }; |
| 751 | |
| 752 | var normalize = isForced.normalize = function (string) { |
| 753 | return String(string).replace(replacement, '.').toLowerCase(); |
| 754 | }; |
| 755 | |
| 756 | var data = isForced.data = {}; |
| 757 | var NATIVE = isForced.NATIVE = 'N'; |
| 758 | var POLYFILL = isForced.POLYFILL = 'P'; |
| 759 | |
| 760 | var isForced_1 = isForced; |
| 761 | |
| 762 | var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | /* |
| 770 | options.target - name of the target object |
| 771 | options.global - target is the global object |
| 772 | options.stat - export as static methods of target |
| 773 | options.proto - export as prototype methods of target |
| 774 | options.real - real prototype method for the `pure` version |
| 775 | options.forced - export even if the native feature is available |
| 776 | options.bind - bind methods to the target, required for the `pure` version |
| 777 | options.wrap - wrap constructors to preventing global pollution, required for the `pure` version |
| 778 | options.unsafe - use the simple assignment of property instead of delete + defineProperty |
| 779 | options.sham - add a flag to not completely full polyfills |
| 780 | options.enumerable - export as enumerable property |
| 781 | options.noTargetGet - prevent calling a getter on target |
| 782 | */ |
| 783 | var _export = function (options, source) { |
| 784 | var TARGET = options.target; |
| 785 | var GLOBAL = options.global; |
| 786 | var STATIC = options.stat; |
| 787 | var FORCED, target, key, targetProperty, sourceProperty, descriptor; |
| 788 | if (GLOBAL) { |
| 789 | target = global_1; |
| 790 | } else if (STATIC) { |
| 791 | target = global_1[TARGET] || setGlobal(TARGET, {}); |
| 792 | } else { |
| 793 | target = (global_1[TARGET] || {}).prototype; |
| 794 | } |
| 795 | if (target) for (key in source) { |
| 796 | sourceProperty = source[key]; |
| 797 | if (options.noTargetGet) { |
| 798 | descriptor = getOwnPropertyDescriptor(target, key); |
| 799 | targetProperty = descriptor && descriptor.value; |
| 800 | } else targetProperty = target[key]; |
| 801 | FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); |
| 802 | // contained in target |
| 803 | if (!FORCED && targetProperty !== undefined) { |
| 804 | if (typeof sourceProperty === typeof targetProperty) continue; |
| 805 | copyConstructorProperties(sourceProperty, targetProperty); |
| 806 | } |
| 807 | // add a flag to not completely full polyfills |
| 808 | if (options.sham || (targetProperty && targetProperty.sham)) { |
| 809 | createNonEnumerableProperty(sourceProperty, 'sham', true); |
| 810 | } |
| 811 | // extend global |
| 812 | redefine(target, key, sourceProperty, options); |
| 813 | } |
| 814 | }; |
| 815 | |
| 816 | var toString_1 = function (argument) { |
| 817 | if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a string'); |
| 818 | return String(argument); |
| 819 | }; |
| 820 | |
| 821 | // `RegExp.prototype.flags` getter implementation |
| 822 | // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags |
| 823 | var regexpFlags = function () { |
| 824 | var that = anObject(this); |
| 825 | var result = ''; |
| 826 | if (that.global) result += 'g'; |
| 827 | if (that.ignoreCase) result += 'i'; |
| 828 | if (that.multiline) result += 'm'; |
| 829 | if (that.dotAll) result += 's'; |
| 830 | if (that.unicode) result += 'u'; |
| 831 | if (that.sticky) result += 'y'; |
| 832 | return result; |
| 833 | }; |
| 834 | |
| 835 | // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError, |
| 836 | var RE = function (s, f) { |
| 837 | return RegExp(s, f); |
| 838 | }; |
| 839 | |
| 840 | var UNSUPPORTED_Y$2 = fails(function () { |
| 841 | var re = RE('a', 'y'); |
| 842 | re.lastIndex = 2; |
| 843 | return re.exec('abcd') != null; |
| 844 | }); |
| 845 | |
| 846 | var BROKEN_CARET = fails(function () { |
| 847 | // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 |
| 848 | var re = RE('^r', 'gy'); |
| 849 | re.lastIndex = 2; |
| 850 | return re.exec('str') != null; |
| 851 | }); |
| 852 | |
| 853 | var regexpStickyHelpers = { |
| 854 | UNSUPPORTED_Y: UNSUPPORTED_Y$2, |
| 855 | BROKEN_CARET: BROKEN_CARET |
| 856 | }; |
| 857 | |
| 858 | // `Object.keys` method |
| 859 | // https://tc39.es/ecma262/#sec-object.keys |
| 860 | // eslint-disable-next-line es/no-object-keys -- safe |
| 861 | var objectKeys = Object.keys || function keys(O) { |
| 862 | return objectKeysInternal(O, enumBugKeys); |
| 863 | }; |
| 864 | |
| 865 | // `Object.defineProperties` method |
| 866 | // https://tc39.es/ecma262/#sec-object.defineproperties |
| 867 | // eslint-disable-next-line es/no-object-defineproperties -- safe |
| 868 | var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { |
| 869 | anObject(O); |
| 870 | var keys = objectKeys(Properties); |
| 871 | var length = keys.length; |
| 872 | var index = 0; |
| 873 | var key; |
| 874 | while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]); |
| 875 | return O; |
| 876 | }; |
| 877 | |
| 878 | var html = getBuiltIn('document', 'documentElement'); |
| 879 | |
| 880 | /* global ActiveXObject -- old IE, WSH */ |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | var GT = '>'; |
| 890 | var LT = '<'; |
| 891 | var PROTOTYPE = 'prototype'; |
| 892 | var SCRIPT = 'script'; |
| 893 | var IE_PROTO = sharedKey('IE_PROTO'); |
| 894 | |
| 895 | var EmptyConstructor = function () { /* empty */ }; |
| 896 | |
| 897 | var scriptTag = function (content) { |
| 898 | return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; |
| 899 | }; |
| 900 | |
| 901 | // Create object with fake `null` prototype: use ActiveX Object with cleared prototype |
| 902 | var NullProtoObjectViaActiveX = function (activeXDocument) { |
| 903 | activeXDocument.write(scriptTag('')); |
| 904 | activeXDocument.close(); |
| 905 | var temp = activeXDocument.parentWindow.Object; |
| 906 | activeXDocument = null; // avoid memory leak |
| 907 | return temp; |
| 908 | }; |
| 909 | |
| 910 | // Create object with fake `null` prototype: use iframe Object with cleared prototype |
| 911 | var NullProtoObjectViaIFrame = function () { |
| 912 | // Thrash, waste and sodomy: IE GC bug |
| 913 | var iframe = documentCreateElement('iframe'); |
| 914 | var JS = 'java' + SCRIPT + ':'; |
| 915 | var iframeDocument; |
| 916 | if (iframe.style) { |
| 917 | iframe.style.display = 'none'; |
| 918 | html.appendChild(iframe); |
| 919 | // https://github.com/zloirock/core-js/issues/475 |
| 920 | iframe.src = String(JS); |
| 921 | iframeDocument = iframe.contentWindow.document; |
| 922 | iframeDocument.open(); |
| 923 | iframeDocument.write(scriptTag('document.F=Object')); |
| 924 | iframeDocument.close(); |
| 925 | return iframeDocument.F; |
| 926 | } |
| 927 | }; |
| 928 | |
| 929 | // Check for document.domain and active x support |
| 930 | // No need to use active x approach when document.domain is not set |
| 931 | // see https://github.com/es-shims/es5-shim/issues/150 |
| 932 | // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 |
| 933 | // avoid IE GC bug |
| 934 | var activeXDocument; |
| 935 | var NullProtoObject = function () { |
| 936 | try { |
| 937 | activeXDocument = new ActiveXObject('htmlfile'); |
| 938 | } catch (error) { /* ignore */ } |
| 939 | NullProtoObject = document.domain && activeXDocument ? |
| 940 | NullProtoObjectViaActiveX(activeXDocument) : // old IE |
| 941 | NullProtoObjectViaIFrame() || |
| 942 | NullProtoObjectViaActiveX(activeXDocument); // WSH |
| 943 | var length = enumBugKeys.length; |
| 944 | while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; |
| 945 | return NullProtoObject(); |
| 946 | }; |
| 947 | |
| 948 | hiddenKeys$1[IE_PROTO] = true; |
| 949 | |
| 950 | // `Object.create` method |
| 951 | // https://tc39.es/ecma262/#sec-object.create |
| 952 | var objectCreate = Object.create || function create(O, Properties) { |
| 953 | var result; |
| 954 | if (O !== null) { |
| 955 | EmptyConstructor[PROTOTYPE] = anObject(O); |
| 956 | result = new EmptyConstructor(); |
| 957 | EmptyConstructor[PROTOTYPE] = null; |
| 958 | // add "__proto__" for Object.getPrototypeOf polyfill |
| 959 | result[IE_PROTO] = O; |
| 960 | } else result = NullProtoObject(); |
| 961 | return Properties === undefined ? result : objectDefineProperties(result, Properties); |
| 962 | }; |
| 963 | |
| 964 | var regexpUnsupportedDotAll = fails(function () { |
| 965 | // babel-minify transpiles RegExp('.', 's') -> /./s and it causes SyntaxError |
| 966 | var re = RegExp('.', (typeof '').charAt(0)); |
| 967 | return !(re.dotAll && re.exec('\n') && re.flags === 's'); |
| 968 | }); |
| 969 | |
| 970 | var regexpUnsupportedNcg = fails(function () { |
| 971 | // babel-minify transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError |
| 972 | var re = RegExp('(?<a>b)', (typeof '').charAt(5)); |
| 973 | return re.exec('b').groups.a !== 'b' || |
| 974 | 'b'.replace(re, '$<a>c') !== 'bc'; |
| 975 | }); |
| 976 | |
| 977 | /* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ |
| 978 | /* eslint-disable regexp/no-useless-quantifier -- testing */ |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | var getInternalState = internalState.get; |
| 985 | |
| 986 | |
| 987 | |
| 988 | var nativeExec = RegExp.prototype.exec; |
| 989 | var nativeReplace = shared('native-string-replace', String.prototype.replace); |
| 990 | |
| 991 | var patchedExec = nativeExec; |
| 992 | |
| 993 | var UPDATES_LAST_INDEX_WRONG = (function () { |
| 994 | var re1 = /a/; |
| 995 | var re2 = /b*/g; |
| 996 | nativeExec.call(re1, 'a'); |
| 997 | nativeExec.call(re2, 'a'); |
| 998 | return re1.lastIndex !== 0 || re2.lastIndex !== 0; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 999 | })(); |
| 1000 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1001 | var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET; |
| 1002 | |
| 1003 | // nonparticipating capturing group, copied from es5-shim's String#split patch. |
| 1004 | var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; |
| 1005 | |
| 1006 | var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; |
| 1007 | |
| 1008 | if (PATCH) { |
| 1009 | // eslint-disable-next-line max-statements -- TODO |
| 1010 | patchedExec = function exec(string) { |
| 1011 | var re = this; |
| 1012 | var state = getInternalState(re); |
| 1013 | var str = toString_1(string); |
| 1014 | var raw = state.raw; |
| 1015 | var result, reCopy, lastIndex, match, i, object, group; |
| 1016 | |
| 1017 | if (raw) { |
| 1018 | raw.lastIndex = re.lastIndex; |
| 1019 | result = patchedExec.call(raw, str); |
| 1020 | re.lastIndex = raw.lastIndex; |
| 1021 | return result; |
| 1022 | } |
| 1023 | |
| 1024 | var groups = state.groups; |
| 1025 | var sticky = UNSUPPORTED_Y$1 && re.sticky; |
| 1026 | var flags = regexpFlags.call(re); |
| 1027 | var source = re.source; |
| 1028 | var charsAdded = 0; |
| 1029 | var strCopy = str; |
| 1030 | |
| 1031 | if (sticky) { |
| 1032 | flags = flags.replace('y', ''); |
| 1033 | if (flags.indexOf('g') === -1) { |
| 1034 | flags += 'g'; |
| 1035 | } |
| 1036 | |
| 1037 | strCopy = str.slice(re.lastIndex); |
| 1038 | // Support anchored sticky behavior. |
| 1039 | if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\n')) { |
| 1040 | source = '(?: ' + source + ')'; |
| 1041 | strCopy = ' ' + strCopy; |
| 1042 | charsAdded++; |
| 1043 | } |
| 1044 | // ^(? + rx + ) is needed, in combination with some str slicing, to |
| 1045 | // simulate the 'y' flag. |
| 1046 | reCopy = new RegExp('^(?:' + source + ')', flags); |
| 1047 | } |
| 1048 | |
| 1049 | if (NPCG_INCLUDED) { |
| 1050 | reCopy = new RegExp('^' + source + '$(?!\\s)', flags); |
| 1051 | } |
| 1052 | if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; |
| 1053 | |
| 1054 | match = nativeExec.call(sticky ? reCopy : re, strCopy); |
| 1055 | |
| 1056 | if (sticky) { |
| 1057 | if (match) { |
| 1058 | match.input = match.input.slice(charsAdded); |
| 1059 | match[0] = match[0].slice(charsAdded); |
| 1060 | match.index = re.lastIndex; |
| 1061 | re.lastIndex += match[0].length; |
| 1062 | } else re.lastIndex = 0; |
| 1063 | } else if (UPDATES_LAST_INDEX_WRONG && match) { |
| 1064 | re.lastIndex = re.global ? match.index + match[0].length : lastIndex; |
| 1065 | } |
| 1066 | if (NPCG_INCLUDED && match && match.length > 1) { |
| 1067 | // Fix browsers whose `exec` methods don't consistently return `undefined` |
| 1068 | // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ |
| 1069 | nativeReplace.call(match[0], reCopy, function () { |
| 1070 | for (i = 1; i < arguments.length - 2; i++) { |
| 1071 | if (arguments[i] === undefined) match[i] = undefined; |
| 1072 | } |
| 1073 | }); |
| 1074 | } |
| 1075 | |
| 1076 | if (match && groups) { |
| 1077 | match.groups = object = objectCreate(null); |
| 1078 | for (i = 0; i < groups.length; i++) { |
| 1079 | group = groups[i]; |
| 1080 | object[group[0]] = match[group[1]]; |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | return match; |
| 1085 | }; |
| 1086 | } |
| 1087 | |
| 1088 | var regexpExec = patchedExec; |
| 1089 | |
| 1090 | // `RegExp.prototype.exec` method |
| 1091 | // https://tc39.es/ecma262/#sec-regexp.prototype.exec |
| 1092 | _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, { |
| 1093 | exec: regexpExec |
| 1094 | }); |
| 1095 | |
| 1096 | // TODO: Remove from `core-js@4` since it's moved to entry points |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | var SPECIES$4 = wellKnownSymbol('species'); |
| 1105 | var RegExpPrototype$1 = RegExp.prototype; |
| 1106 | |
| 1107 | var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { |
| 1108 | var SYMBOL = wellKnownSymbol(KEY); |
| 1109 | |
| 1110 | var DELEGATES_TO_SYMBOL = !fails(function () { |
| 1111 | // String methods call symbol-named RegEp methods |
| 1112 | var O = {}; |
| 1113 | O[SYMBOL] = function () { return 7; }; |
| 1114 | return ''[KEY](O) != 7; |
| 1115 | }); |
| 1116 | |
| 1117 | var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () { |
| 1118 | // Symbol-named RegExp methods call .exec |
| 1119 | var execCalled = false; |
| 1120 | var re = /a/; |
| 1121 | |
| 1122 | if (KEY === 'split') { |
| 1123 | // We can't use real regex here since it causes deoptimization |
| 1124 | // and serious performance degradation in V8 |
| 1125 | // https://github.com/zloirock/core-js/issues/306 |
| 1126 | re = {}; |
| 1127 | // RegExp[@@split] doesn't call the regex's exec method, but first creates |
| 1128 | // a new one. We need to return the patched regex when creating the new one. |
| 1129 | re.constructor = {}; |
| 1130 | re.constructor[SPECIES$4] = function () { return re; }; |
| 1131 | re.flags = ''; |
| 1132 | re[SYMBOL] = /./[SYMBOL]; |
| 1133 | } |
| 1134 | |
| 1135 | re.exec = function () { execCalled = true; return null; }; |
| 1136 | |
| 1137 | re[SYMBOL](''); |
| 1138 | return !execCalled; |
| 1139 | }); |
| 1140 | |
| 1141 | if ( |
| 1142 | !DELEGATES_TO_SYMBOL || |
| 1143 | !DELEGATES_TO_EXEC || |
| 1144 | FORCED |
| 1145 | ) { |
| 1146 | var nativeRegExpMethod = /./[SYMBOL]; |
| 1147 | var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { |
| 1148 | var $exec = regexp.exec; |
| 1149 | if ($exec === regexpExec || $exec === RegExpPrototype$1.exec) { |
| 1150 | if (DELEGATES_TO_SYMBOL && !forceStringMethod) { |
| 1151 | // The native String method already delegates to @@method (this |
| 1152 | // polyfilled function), leasing to infinite recursion. |
| 1153 | // We avoid it by directly calling the native @@method method. |
| 1154 | return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; |
| 1155 | } |
| 1156 | return { done: true, value: nativeMethod.call(str, regexp, arg2) }; |
| 1157 | } |
| 1158 | return { done: false }; |
| 1159 | }); |
| 1160 | |
| 1161 | redefine(String.prototype, KEY, methods[0]); |
| 1162 | redefine(RegExpPrototype$1, SYMBOL, methods[1]); |
| 1163 | } |
| 1164 | |
| 1165 | if (SHAM) createNonEnumerableProperty(RegExpPrototype$1[SYMBOL], 'sham', true); |
| 1166 | }; |
| 1167 | |
| 1168 | // `String.prototype.codePointAt` methods implementation |
| 1169 | var createMethod$1 = function (CONVERT_TO_STRING) { |
| 1170 | return function ($this, pos) { |
| 1171 | var S = toString_1(requireObjectCoercible($this)); |
| 1172 | var position = toInteger(pos); |
| 1173 | var size = S.length; |
| 1174 | var first, second; |
| 1175 | if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; |
| 1176 | first = S.charCodeAt(position); |
| 1177 | return first < 0xD800 || first > 0xDBFF || position + 1 === size |
| 1178 | || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF |
| 1179 | ? CONVERT_TO_STRING ? S.charAt(position) : first |
| 1180 | : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; |
| 1181 | }; |
| 1182 | }; |
| 1183 | |
| 1184 | var stringMultibyte = { |
| 1185 | // `String.prototype.codePointAt` method |
| 1186 | // https://tc39.es/ecma262/#sec-string.prototype.codepointat |
| 1187 | codeAt: createMethod$1(false), |
| 1188 | // `String.prototype.at` method |
| 1189 | // https://github.com/mathiasbynens/String.prototype.at |
| 1190 | charAt: createMethod$1(true) |
| 1191 | }; |
| 1192 | |
| 1193 | var charAt = stringMultibyte.charAt; |
| 1194 | |
| 1195 | // `AdvanceStringIndex` abstract operation |
| 1196 | // https://tc39.es/ecma262/#sec-advancestringindex |
| 1197 | var advanceStringIndex = function (S, index, unicode) { |
| 1198 | return index + (unicode ? charAt(S, index).length : 1); |
| 1199 | }; |
| 1200 | |
| 1201 | // `RegExpExec` abstract operation |
| 1202 | // https://tc39.es/ecma262/#sec-regexpexec |
| 1203 | var regexpExecAbstract = function (R, S) { |
| 1204 | var exec = R.exec; |
| 1205 | if (typeof exec === 'function') { |
| 1206 | var result = exec.call(R, S); |
| 1207 | if (typeof result !== 'object') { |
| 1208 | throw TypeError('RegExp exec method returned something other than an Object or null'); |
| 1209 | } |
| 1210 | return result; |
| 1211 | } |
| 1212 | |
| 1213 | if (classofRaw(R) !== 'RegExp') { |
| 1214 | throw TypeError('RegExp#exec called on incompatible receiver'); |
| 1215 | } |
| 1216 | |
| 1217 | return regexpExec.call(R, S); |
| 1218 | }; |
| 1219 | |
| 1220 | // @@match logic |
| 1221 | fixRegexpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) { |
| 1222 | return [ |
| 1223 | // `String.prototype.match` method |
| 1224 | // https://tc39.es/ecma262/#sec-string.prototype.match |
| 1225 | function match(regexp) { |
| 1226 | var O = requireObjectCoercible(this); |
| 1227 | var matcher = regexp == undefined ? undefined : regexp[MATCH]; |
| 1228 | return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString_1(O)); |
| 1229 | }, |
| 1230 | // `RegExp.prototype[@@match]` method |
| 1231 | // https://tc39.es/ecma262/#sec-regexp.prototype-@@match |
| 1232 | function (string) { |
| 1233 | var rx = anObject(this); |
| 1234 | var S = toString_1(string); |
| 1235 | var res = maybeCallNative(nativeMatch, rx, S); |
| 1236 | |
| 1237 | if (res.done) return res.value; |
| 1238 | |
| 1239 | if (!rx.global) return regexpExecAbstract(rx, S); |
| 1240 | |
| 1241 | var fullUnicode = rx.unicode; |
| 1242 | rx.lastIndex = 0; |
| 1243 | var A = []; |
| 1244 | var n = 0; |
| 1245 | var result; |
| 1246 | while ((result = regexpExecAbstract(rx, S)) !== null) { |
| 1247 | var matchStr = toString_1(result[0]); |
| 1248 | A[n] = matchStr; |
| 1249 | if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); |
| 1250 | n++; |
| 1251 | } |
| 1252 | return n === 0 ? null : A; |
| 1253 | } |
| 1254 | ]; |
| 1255 | }); |
| 1256 | |
| 1257 | // `IsArray` abstract operation |
| 1258 | // https://tc39.es/ecma262/#sec-isarray |
| 1259 | // eslint-disable-next-line es/no-array-isarray -- safe |
| 1260 | var isArray = Array.isArray || function isArray(arg) { |
| 1261 | return classofRaw(arg) == 'Array'; |
| 1262 | }; |
| 1263 | |
| 1264 | var createProperty = function (object, key, value) { |
| 1265 | var propertyKey = toPropertyKey(key); |
| 1266 | if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value)); |
| 1267 | else object[propertyKey] = value; |
| 1268 | }; |
| 1269 | |
| 1270 | var SPECIES$3 = wellKnownSymbol('species'); |
| 1271 | |
| 1272 | // a part of `ArraySpeciesCreate` abstract operation |
| 1273 | // https://tc39.es/ecma262/#sec-arrayspeciescreate |
| 1274 | var arraySpeciesConstructor = function (originalArray) { |
| 1275 | var C; |
| 1276 | if (isArray(originalArray)) { |
| 1277 | C = originalArray.constructor; |
| 1278 | // cross-realm fallback |
| 1279 | if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; |
| 1280 | else if (isObject(C)) { |
| 1281 | C = C[SPECIES$3]; |
| 1282 | if (C === null) C = undefined; |
| 1283 | } |
| 1284 | } return C === undefined ? Array : C; |
| 1285 | }; |
| 1286 | |
| 1287 | // `ArraySpeciesCreate` abstract operation |
| 1288 | // https://tc39.es/ecma262/#sec-arrayspeciescreate |
| 1289 | var arraySpeciesCreate = function (originalArray, length) { |
| 1290 | return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); |
| 1291 | }; |
| 1292 | |
| 1293 | var SPECIES$2 = wellKnownSymbol('species'); |
| 1294 | |
| 1295 | var arrayMethodHasSpeciesSupport = function (METHOD_NAME) { |
| 1296 | // We can't use this feature detection in V8 since it causes |
| 1297 | // deoptimization and serious performance degradation |
| 1298 | // https://github.com/zloirock/core-js/issues/677 |
| 1299 | return engineV8Version >= 51 || !fails(function () { |
| 1300 | var array = []; |
| 1301 | var constructor = array.constructor = {}; |
| 1302 | constructor[SPECIES$2] = function () { |
| 1303 | return { foo: 1 }; |
| 1304 | }; |
| 1305 | return array[METHOD_NAME](Boolean).foo !== 1; |
| 1306 | }); |
| 1307 | }; |
| 1308 | |
| 1309 | var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable'); |
| 1310 | var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF; |
| 1311 | var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; |
| 1312 | |
| 1313 | // We can't use this feature detection in V8 since it causes |
| 1314 | // deoptimization and serious performance degradation |
| 1315 | // https://github.com/zloirock/core-js/issues/679 |
| 1316 | var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () { |
| 1317 | var array = []; |
| 1318 | array[IS_CONCAT_SPREADABLE] = false; |
| 1319 | return array.concat()[0] !== array; |
| 1320 | }); |
| 1321 | |
| 1322 | var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat'); |
| 1323 | |
| 1324 | var isConcatSpreadable = function (O) { |
| 1325 | if (!isObject(O)) return false; |
| 1326 | var spreadable = O[IS_CONCAT_SPREADABLE]; |
| 1327 | return spreadable !== undefined ? !!spreadable : isArray(O); |
| 1328 | }; |
| 1329 | |
| 1330 | var FORCED$1 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; |
| 1331 | |
| 1332 | // `Array.prototype.concat` method |
| 1333 | // https://tc39.es/ecma262/#sec-array.prototype.concat |
| 1334 | // with adding support of @@isConcatSpreadable and @@species |
| 1335 | _export({ target: 'Array', proto: true, forced: FORCED$1 }, { |
| 1336 | // eslint-disable-next-line no-unused-vars -- required for `.length` |
| 1337 | concat: function concat(arg) { |
| 1338 | var O = toObject(this); |
| 1339 | var A = arraySpeciesCreate(O, 0); |
| 1340 | var n = 0; |
| 1341 | var i, k, length, len, E; |
| 1342 | for (i = -1, length = arguments.length; i < length; i++) { |
| 1343 | E = i === -1 ? O : arguments[i]; |
| 1344 | if (isConcatSpreadable(E)) { |
| 1345 | len = toLength(E.length); |
| 1346 | if (n + len > MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); |
| 1347 | for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]); |
| 1348 | } else { |
| 1349 | if (n >= MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); |
| 1350 | createProperty(A, n++, E); |
| 1351 | } |
| 1352 | } |
| 1353 | A.length = n; |
| 1354 | return A; |
| 1355 | } |
| 1356 | }); |
| 1357 | |
| 1358 | var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); |
| 1359 | var test$1 = {}; |
| 1360 | |
| 1361 | test$1[TO_STRING_TAG$1] = 'z'; |
| 1362 | |
| 1363 | var toStringTagSupport = String(test$1) === '[object z]'; |
| 1364 | |
| 1365 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); |
| 1366 | // ES3 wrong here |
| 1367 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; |
| 1368 | |
| 1369 | // fallback for IE11 Script Access Denied error |
| 1370 | var tryGet = function (it, key) { |
| 1371 | try { |
| 1372 | return it[key]; |
| 1373 | } catch (error) { /* empty */ } |
| 1374 | }; |
| 1375 | |
| 1376 | // getting tag from ES6+ `Object.prototype.toString` |
| 1377 | var classof = toStringTagSupport ? classofRaw : function (it) { |
| 1378 | var O, tag, result; |
| 1379 | return it === undefined ? 'Undefined' : it === null ? 'Null' |
| 1380 | // @@toStringTag case |
| 1381 | : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag |
| 1382 | // builtinTag case |
| 1383 | : CORRECT_ARGUMENTS ? classofRaw(O) |
| 1384 | // ES3 arguments fallback |
| 1385 | : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result; |
| 1386 | }; |
| 1387 | |
| 1388 | // `Object.prototype.toString` method implementation |
| 1389 | // https://tc39.es/ecma262/#sec-object.prototype.tostring |
| 1390 | var objectToString = toStringTagSupport ? {}.toString : function toString() { |
| 1391 | return '[object ' + classof(this) + ']'; |
| 1392 | }; |
| 1393 | |
| 1394 | // `Object.prototype.toString` method |
| 1395 | // https://tc39.es/ecma262/#sec-object.prototype.tostring |
| 1396 | if (!toStringTagSupport) { |
| 1397 | redefine(Object.prototype, 'toString', objectToString, { unsafe: true }); |
| 1398 | } |
| 1399 | |
| 1400 | var TO_STRING = 'toString'; |
| 1401 | var RegExpPrototype = RegExp.prototype; |
| 1402 | var nativeToString = RegExpPrototype[TO_STRING]; |
| 1403 | |
| 1404 | var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; }); |
| 1405 | // FF44- RegExp#toString has a wrong name |
| 1406 | var INCORRECT_NAME = nativeToString.name != TO_STRING; |
| 1407 | |
| 1408 | // `RegExp.prototype.toString` method |
| 1409 | // https://tc39.es/ecma262/#sec-regexp.prototype.tostring |
| 1410 | if (NOT_GENERIC || INCORRECT_NAME) { |
| 1411 | redefine(RegExp.prototype, TO_STRING, function toString() { |
| 1412 | var R = anObject(this); |
| 1413 | var p = toString_1(R.source); |
| 1414 | var rf = R.flags; |
| 1415 | var f = toString_1(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf); |
| 1416 | return '/' + p + '/' + f; |
| 1417 | }, { unsafe: true }); |
| 1418 | } |
| 1419 | |
| 1420 | var MATCH$1 = wellKnownSymbol('match'); |
| 1421 | |
| 1422 | // `IsRegExp` abstract operation |
| 1423 | // https://tc39.es/ecma262/#sec-isregexp |
| 1424 | var isRegexp = function (it) { |
| 1425 | var isRegExp; |
| 1426 | return isObject(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); |
| 1427 | }; |
| 1428 | |
| 1429 | var aFunction = function (it) { |
| 1430 | if (typeof it != 'function') { |
| 1431 | throw TypeError(String(it) + ' is not a function'); |
| 1432 | } return it; |
| 1433 | }; |
| 1434 | |
| 1435 | var SPECIES$1 = wellKnownSymbol('species'); |
| 1436 | |
| 1437 | // `SpeciesConstructor` abstract operation |
| 1438 | // https://tc39.es/ecma262/#sec-speciesconstructor |
| 1439 | var speciesConstructor = function (O, defaultConstructor) { |
| 1440 | var C = anObject(O).constructor; |
| 1441 | var S; |
| 1442 | return C === undefined || (S = anObject(C)[SPECIES$1]) == undefined ? defaultConstructor : aFunction(S); |
| 1443 | }; |
| 1444 | |
| 1445 | var UNSUPPORTED_Y = regexpStickyHelpers.UNSUPPORTED_Y; |
| 1446 | var arrayPush = [].push; |
| 1447 | var min$2 = Math.min; |
| 1448 | var MAX_UINT32 = 0xFFFFFFFF; |
| 1449 | |
| 1450 | // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec |
| 1451 | // Weex JS has frozen built-in prototypes, so use try / catch wrapper |
| 1452 | var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () { |
| 1453 | // eslint-disable-next-line regexp/no-empty-group -- required for testing |
| 1454 | var re = /(?:)/; |
| 1455 | var originalExec = re.exec; |
| 1456 | re.exec = function () { return originalExec.apply(this, arguments); }; |
| 1457 | var result = 'ab'.split(re); |
| 1458 | return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; |
| 1459 | }); |
| 1460 | |
| 1461 | // @@split logic |
| 1462 | fixRegexpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) { |
| 1463 | var internalSplit; |
| 1464 | if ( |
| 1465 | 'abbc'.split(/(b)*/)[1] == 'c' || |
| 1466 | // eslint-disable-next-line regexp/no-empty-group -- required for testing |
| 1467 | 'test'.split(/(?:)/, -1).length != 4 || |
| 1468 | 'ab'.split(/(?:ab)*/).length != 2 || |
| 1469 | '.'.split(/(.?)(.?)/).length != 4 || |
| 1470 | // eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group -- required for testing |
| 1471 | '.'.split(/()()/).length > 1 || |
| 1472 | ''.split(/.?/).length |
| 1473 | ) { |
| 1474 | // based on es5-shim implementation, need to rework it |
| 1475 | internalSplit = function (separator, limit) { |
| 1476 | var string = toString_1(requireObjectCoercible(this)); |
| 1477 | var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; |
| 1478 | if (lim === 0) return []; |
| 1479 | if (separator === undefined) return [string]; |
| 1480 | // If `separator` is not a regex, use native split |
| 1481 | if (!isRegexp(separator)) { |
| 1482 | return nativeSplit.call(string, separator, lim); |
| 1483 | } |
| 1484 | var output = []; |
| 1485 | var flags = (separator.ignoreCase ? 'i' : '') + |
| 1486 | (separator.multiline ? 'm' : '') + |
| 1487 | (separator.unicode ? 'u' : '') + |
| 1488 | (separator.sticky ? 'y' : ''); |
| 1489 | var lastLastIndex = 0; |
| 1490 | // Make `global` and avoid `lastIndex` issues by working with a copy |
| 1491 | var separatorCopy = new RegExp(separator.source, flags + 'g'); |
| 1492 | var match, lastIndex, lastLength; |
| 1493 | while (match = regexpExec.call(separatorCopy, string)) { |
| 1494 | lastIndex = separatorCopy.lastIndex; |
| 1495 | if (lastIndex > lastLastIndex) { |
| 1496 | output.push(string.slice(lastLastIndex, match.index)); |
| 1497 | if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1)); |
| 1498 | lastLength = match[0].length; |
| 1499 | lastLastIndex = lastIndex; |
| 1500 | if (output.length >= lim) break; |
| 1501 | } |
| 1502 | if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop |
| 1503 | } |
| 1504 | if (lastLastIndex === string.length) { |
| 1505 | if (lastLength || !separatorCopy.test('')) output.push(''); |
| 1506 | } else output.push(string.slice(lastLastIndex)); |
| 1507 | return output.length > lim ? output.slice(0, lim) : output; |
| 1508 | }; |
| 1509 | // Chakra, V8 |
| 1510 | } else if ('0'.split(undefined, 0).length) { |
| 1511 | internalSplit = function (separator, limit) { |
| 1512 | return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit); |
| 1513 | }; |
| 1514 | } else internalSplit = nativeSplit; |
| 1515 | |
| 1516 | return [ |
| 1517 | // `String.prototype.split` method |
| 1518 | // https://tc39.es/ecma262/#sec-string.prototype.split |
| 1519 | function split(separator, limit) { |
| 1520 | var O = requireObjectCoercible(this); |
| 1521 | var splitter = separator == undefined ? undefined : separator[SPLIT]; |
| 1522 | return splitter !== undefined |
| 1523 | ? splitter.call(separator, O, limit) |
| 1524 | : internalSplit.call(toString_1(O), separator, limit); |
| 1525 | }, |
| 1526 | // `RegExp.prototype[@@split]` method |
| 1527 | // https://tc39.es/ecma262/#sec-regexp.prototype-@@split |
| 1528 | // |
| 1529 | // NOTE: This cannot be properly polyfilled in engines that don't support |
| 1530 | // the 'y' flag. |
| 1531 | function (string, limit) { |
| 1532 | var rx = anObject(this); |
| 1533 | var S = toString_1(string); |
| 1534 | var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit); |
| 1535 | |
| 1536 | if (res.done) return res.value; |
| 1537 | |
| 1538 | var C = speciesConstructor(rx, RegExp); |
| 1539 | |
| 1540 | var unicodeMatching = rx.unicode; |
| 1541 | var flags = (rx.ignoreCase ? 'i' : '') + |
| 1542 | (rx.multiline ? 'm' : '') + |
| 1543 | (rx.unicode ? 'u' : '') + |
| 1544 | (UNSUPPORTED_Y ? 'g' : 'y'); |
| 1545 | |
| 1546 | // ^(? + rx + ) is needed, in combination with some S slicing, to |
| 1547 | // simulate the 'y' flag. |
| 1548 | var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags); |
| 1549 | var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; |
| 1550 | if (lim === 0) return []; |
| 1551 | if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : []; |
| 1552 | var p = 0; |
| 1553 | var q = 0; |
| 1554 | var A = []; |
| 1555 | while (q < S.length) { |
| 1556 | splitter.lastIndex = UNSUPPORTED_Y ? 0 : q; |
| 1557 | var z = regexpExecAbstract(splitter, UNSUPPORTED_Y ? S.slice(q) : S); |
| 1558 | var e; |
| 1559 | if ( |
| 1560 | z === null || |
| 1561 | (e = min$2(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p |
| 1562 | ) { |
| 1563 | q = advanceStringIndex(S, q, unicodeMatching); |
| 1564 | } else { |
| 1565 | A.push(S.slice(p, q)); |
| 1566 | if (A.length === lim) return A; |
| 1567 | for (var i = 1; i <= z.length - 1; i++) { |
| 1568 | A.push(z[i]); |
| 1569 | if (A.length === lim) return A; |
| 1570 | } |
| 1571 | q = p = e; |
| 1572 | } |
| 1573 | } |
| 1574 | A.push(S.slice(p)); |
| 1575 | return A; |
| 1576 | } |
| 1577 | ]; |
| 1578 | }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y); |
| 1579 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1580 | /** |
| 1581 | * Append a class to an element |
| 1582 | * |
| 1583 | * @api private |
| 1584 | * @method _addClass |
| 1585 | * @param {Object} element |
| 1586 | * @param {String} className |
| 1587 | * @returns null |
| 1588 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1589 | |
| 1590 | function addClass(element, className) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1591 | if (element instanceof SVGElement) { |
| 1592 | // svg |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1593 | var pre = element.getAttribute("class") || ""; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1594 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1595 | if (!pre.match(className)) { |
| 1596 | // check if element doesn't already have className |
| 1597 | element.setAttribute("class", "".concat(pre, " ").concat(className)); |
| 1598 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1599 | } else { |
| 1600 | if (element.classList !== undefined) { |
| 1601 | // check for modern classList property |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1602 | var classes = className.split(" "); |
| 1603 | forEach(classes, function (cls) { |
| 1604 | element.classList.add(cls); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1605 | }); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1606 | } else if (!element.className.match(className)) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1607 | // check if element doesn't already have className |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1608 | element.className += " ".concat(className); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | /** |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1614 | * Get an element CSS property on the page |
| 1615 | * Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml |
| 1616 | * |
| 1617 | * @api private |
| 1618 | * @method _getPropValue |
| 1619 | * @param {Object} element |
| 1620 | * @param {String} propName |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1621 | * @returns string property value |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1622 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1623 | function getPropValue(element, propName) { |
| 1624 | var propValue = ""; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1625 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1626 | if (element.currentStyle) { |
| 1627 | //IE |
| 1628 | propValue = element.currentStyle[propName]; |
| 1629 | } else if (document.defaultView && document.defaultView.getComputedStyle) { |
| 1630 | //Others |
| 1631 | propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName); |
| 1632 | } //Prevent exception in IE |
| 1633 | |
| 1634 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1635 | if (propValue && propValue.toLowerCase) { |
| 1636 | return propValue.toLowerCase(); |
| 1637 | } else { |
| 1638 | return propValue; |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1643 | * To set the show element |
| 1644 | * This function set a relative (in most cases) position and changes the z-index |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1645 | * |
| 1646 | * @api private |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1647 | * @method _setShowElement |
| 1648 | * @param {Object} targetElement |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1649 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1650 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1651 | function setShowElement(_ref) { |
| 1652 | var element = _ref.element; |
| 1653 | addClass(element, "introjs-showElement"); |
| 1654 | var currentElementPosition = getPropValue(element, "position"); |
| 1655 | |
| 1656 | if (currentElementPosition !== "absolute" && currentElementPosition !== "relative" && currentElementPosition !== "sticky" && currentElementPosition !== "fixed") { |
| 1657 | //change to new intro item |
| 1658 | addClass(element, "introjs-relativePosition"); |
| 1659 | } |
| 1660 | } |
| 1661 | |
| 1662 | /** |
| 1663 | * Find the nearest scrollable parent |
| 1664 | * copied from https://stackoverflow.com/questions/35939886/find-first-scrollable-parent |
| 1665 | * |
| 1666 | * @param Element element |
| 1667 | * @return Element |
| 1668 | */ |
| 1669 | function getScrollParent(element) { |
| 1670 | var style = window.getComputedStyle(element); |
| 1671 | var excludeStaticParent = style.position === "absolute"; |
| 1672 | var overflowRegex = /(auto|scroll)/; |
| 1673 | if (style.position === "fixed") return document.body; |
| 1674 | |
| 1675 | for (var parent = element; parent = parent.parentElement;) { |
| 1676 | style = window.getComputedStyle(parent); |
| 1677 | |
| 1678 | if (excludeStaticParent && style.position === "static") { |
| 1679 | continue; |
| 1680 | } |
| 1681 | |
| 1682 | if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1683 | } |
| 1684 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1685 | return document.body; |
| 1686 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1687 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1688 | /** |
| 1689 | * scroll a scrollable element to a child element |
| 1690 | * |
| 1691 | * @param {Object} targetElement |
| 1692 | */ |
| 1693 | |
| 1694 | function scrollParentToElement(targetElement) { |
| 1695 | var element = targetElement.element; |
| 1696 | if (!this._options.scrollToElement) return; |
| 1697 | var parent = getScrollParent(element); |
| 1698 | if (parent === document.body) return; |
| 1699 | parent.scrollTop = element.offsetTop - parent.offsetTop; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | /** |
| 1703 | * Provides a cross-browser way to get the screen dimensions |
| 1704 | * via: http://stackoverflow.com/questions/5864467/internet-explorer-innerheight |
| 1705 | * |
| 1706 | * @api private |
| 1707 | * @method _getWinSize |
| 1708 | * @returns {Object} width and height attributes |
| 1709 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1710 | function getWinSize() { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1711 | if (window.innerWidth !== undefined) { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1712 | return { |
| 1713 | width: window.innerWidth, |
| 1714 | height: window.innerHeight |
| 1715 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1716 | } else { |
| 1717 | var D = document.documentElement; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1718 | return { |
| 1719 | width: D.clientWidth, |
| 1720 | height: D.clientHeight |
| 1721 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | /** |
| 1726 | * Check to see if the element is in the viewport or not |
| 1727 | * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport |
| 1728 | * |
| 1729 | * @api private |
| 1730 | * @method _elementInViewport |
| 1731 | * @param {Object} el |
| 1732 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1733 | function elementInViewport(el) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1734 | var rect = el.getBoundingClientRect(); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1735 | return rect.top >= 0 && rect.left >= 0 && rect.bottom + 80 <= window.innerHeight && // add 80 to get the text right |
| 1736 | rect.right <= window.innerWidth; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1740 | * To change the scroll of `window` after highlighting an element |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1741 | * |
| 1742 | * @api private |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1743 | * @param {String} scrollTo |
| 1744 | * @param {Object} targetElement |
| 1745 | * @param {Object} tooltipLayer |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1746 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1747 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1748 | function scrollTo(scrollTo, _ref, tooltipLayer) { |
| 1749 | var element = _ref.element; |
| 1750 | if (scrollTo === "off") return; |
| 1751 | var rect; |
| 1752 | if (!this._options.scrollToElement) return; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1753 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1754 | if (scrollTo === "tooltip") { |
| 1755 | rect = tooltipLayer.getBoundingClientRect(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1756 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1757 | rect = element.getBoundingClientRect(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1758 | } |
| 1759 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1760 | if (!elementInViewport(element)) { |
| 1761 | var winHeight = getWinSize().height; |
| 1762 | var top = rect.bottom - (rect.bottom - rect.top); // TODO (afshinm): do we need scroll padding now? |
| 1763 | // I have changed the scroll option and now it scrolls the window to |
| 1764 | // the center of the target element or tooltip. |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1765 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1766 | if (top < 0 || element.clientHeight > winHeight) { |
| 1767 | window.scrollBy(0, rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding); // 30px padding from edge to look nice |
| 1768 | //Scroll down |
| 1769 | } else { |
| 1770 | window.scrollBy(0, rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding); // 30px padding from edge to look nice |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1771 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1772 | } |
| 1773 | } |
| 1774 | |
| 1775 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1776 | * Setting anchors to behave like buttons |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1777 | * |
| 1778 | * @api private |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1779 | * @method _setAnchorAsButton |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1780 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1781 | function setAnchorAsButton(anchor) { |
| 1782 | anchor.setAttribute("role", "button"); |
| 1783 | anchor.tabIndex = 0; |
| 1784 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1785 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1786 | // eslint-disable-next-line es/no-object-assign -- safe |
| 1787 | var $assign = Object.assign; |
| 1788 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing |
| 1789 | var defineProperty = Object.defineProperty; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1790 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1791 | // `Object.assign` method |
| 1792 | // https://tc39.es/ecma262/#sec-object.assign |
| 1793 | var objectAssign = !$assign || fails(function () { |
| 1794 | // should have correct order of operations (Edge bug) |
| 1795 | if (descriptors && $assign({ b: 1 }, $assign(defineProperty({}, 'a', { |
| 1796 | enumerable: true, |
| 1797 | get: function () { |
| 1798 | defineProperty(this, 'b', { |
| 1799 | value: 3, |
| 1800 | enumerable: false |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1801 | }); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1802 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1803 | }), { b: 2 })).b !== 1) return true; |
| 1804 | // should work with symbols and should have deterministic property order (V8 bug) |
| 1805 | var A = {}; |
| 1806 | var B = {}; |
| 1807 | // eslint-disable-next-line es/no-symbol -- safe |
| 1808 | var symbol = Symbol(); |
| 1809 | var alphabet = 'abcdefghijklmnopqrst'; |
| 1810 | A[symbol] = 7; |
| 1811 | alphabet.split('').forEach(function (chr) { B[chr] = chr; }); |
| 1812 | return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet; |
| 1813 | }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length` |
| 1814 | var T = toObject(target); |
| 1815 | var argumentsLength = arguments.length; |
| 1816 | var index = 1; |
| 1817 | var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; |
| 1818 | var propertyIsEnumerable = objectPropertyIsEnumerable.f; |
| 1819 | while (argumentsLength > index) { |
| 1820 | var S = indexedObject(arguments[index++]); |
| 1821 | var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S); |
| 1822 | var length = keys.length; |
| 1823 | var j = 0; |
| 1824 | var key; |
| 1825 | while (length > j) { |
| 1826 | key = keys[j++]; |
| 1827 | if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key]; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1828 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1829 | } return T; |
| 1830 | } : $assign; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1831 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1832 | // `Object.assign` method |
| 1833 | // https://tc39.es/ecma262/#sec-object.assign |
| 1834 | // eslint-disable-next-line es/no-object-assign -- required for testing |
| 1835 | _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { |
| 1836 | assign: objectAssign |
| 1837 | }); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1838 | |
| 1839 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1840 | * Checks to see if target element (or parents) position is fixed or not |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1841 | * |
| 1842 | * @api private |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1843 | * @method _isFixed |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1844 | * @param {Object} element |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1845 | * @returns Boolean |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1846 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1847 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1848 | function isFixed(element) { |
| 1849 | var p = element.parentNode; |
| 1850 | |
| 1851 | if (!p || p.nodeName === "HTML") { |
| 1852 | return false; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1853 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1854 | |
| 1855 | if (getPropValue(element, "position") === "fixed") { |
| 1856 | return true; |
| 1857 | } |
| 1858 | |
| 1859 | return isFixed(p); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1860 | } |
| 1861 | |
| 1862 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1863 | * Get an element position on the page relative to another element (or body) |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1864 | * Thanks to `meouw`: http://stackoverflow.com/a/442474/375966 |
| 1865 | * |
| 1866 | * @api private |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1867 | * @method getOffset |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1868 | * @param {Object} element |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1869 | * @param {Object} relativeEl |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1870 | * @returns Element's position info |
| 1871 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1872 | |
| 1873 | function getOffset(element, relativeEl) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1874 | var body = document.body; |
| 1875 | var docEl = document.documentElement; |
| 1876 | var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop; |
| 1877 | var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1878 | relativeEl = relativeEl || body; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1879 | var x = element.getBoundingClientRect(); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1880 | var xr = relativeEl.getBoundingClientRect(); |
| 1881 | var relativeElPosition = getPropValue(relativeEl, "position"); |
| 1882 | var obj = { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1883 | width: x.width, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1884 | height: x.height |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1885 | }; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 1886 | |
| 1887 | if (relativeEl.tagName.toLowerCase() !== "body" && relativeElPosition === "relative" || relativeElPosition === "sticky") { |
| 1888 | // when the container of our target element is _not_ body and has either "relative" or "sticky" position, we should not |
| 1889 | // consider the scroll position but we need to include the relative x/y of the container element |
| 1890 | return Object.assign(obj, { |
| 1891 | top: x.top - xr.top, |
| 1892 | left: x.left - xr.left |
| 1893 | }); |
| 1894 | } else { |
| 1895 | if (isFixed(element)) { |
| 1896 | return Object.assign(obj, { |
| 1897 | top: x.top, |
| 1898 | left: x.left |
| 1899 | }); |
| 1900 | } else { |
| 1901 | return Object.assign(obj, { |
| 1902 | top: x.top + scrollTop, |
| 1903 | left: x.left + scrollLeft |
| 1904 | }); |
| 1905 | } |
| 1906 | } |
| 1907 | } |
| 1908 | |
| 1909 | var floor$1 = Math.floor; |
| 1910 | var replace = ''.replace; |
| 1911 | var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; |
| 1912 | var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; |
| 1913 | |
| 1914 | // `GetSubstitution` abstract operation |
| 1915 | // https://tc39.es/ecma262/#sec-getsubstitution |
| 1916 | var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { |
| 1917 | var tailPos = position + matched.length; |
| 1918 | var m = captures.length; |
| 1919 | var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; |
| 1920 | if (namedCaptures !== undefined) { |
| 1921 | namedCaptures = toObject(namedCaptures); |
| 1922 | symbols = SUBSTITUTION_SYMBOLS; |
| 1923 | } |
| 1924 | return replace.call(replacement, symbols, function (match, ch) { |
| 1925 | var capture; |
| 1926 | switch (ch.charAt(0)) { |
| 1927 | case '$': return '$'; |
| 1928 | case '&': return matched; |
| 1929 | case '`': return str.slice(0, position); |
| 1930 | case "'": return str.slice(tailPos); |
| 1931 | case '<': |
| 1932 | capture = namedCaptures[ch.slice(1, -1)]; |
| 1933 | break; |
| 1934 | default: // \d\d? |
| 1935 | var n = +ch; |
| 1936 | if (n === 0) return match; |
| 1937 | if (n > m) { |
| 1938 | var f = floor$1(n / 10); |
| 1939 | if (f === 0) return match; |
| 1940 | if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); |
| 1941 | return match; |
| 1942 | } |
| 1943 | capture = captures[n - 1]; |
| 1944 | } |
| 1945 | return capture === undefined ? '' : capture; |
| 1946 | }); |
| 1947 | }; |
| 1948 | |
| 1949 | var REPLACE = wellKnownSymbol('replace'); |
| 1950 | var max$2 = Math.max; |
| 1951 | var min$1 = Math.min; |
| 1952 | |
| 1953 | var maybeToString = function (it) { |
| 1954 | return it === undefined ? it : String(it); |
| 1955 | }; |
| 1956 | |
| 1957 | // IE <= 11 replaces $0 with the whole match, as if it was $& |
| 1958 | // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 |
| 1959 | var REPLACE_KEEPS_$0 = (function () { |
| 1960 | // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing |
| 1961 | return 'a'.replace(/./, '$0') === '$0'; |
| 1962 | })(); |
| 1963 | |
| 1964 | // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string |
| 1965 | var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { |
| 1966 | if (/./[REPLACE]) { |
| 1967 | return /./[REPLACE]('a', '$0') === ''; |
| 1968 | } |
| 1969 | return false; |
| 1970 | })(); |
| 1971 | |
| 1972 | var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () { |
| 1973 | var re = /./; |
| 1974 | re.exec = function () { |
| 1975 | var result = []; |
| 1976 | result.groups = { a: '7' }; |
| 1977 | return result; |
| 1978 | }; |
| 1979 | return ''.replace(re, '$<a>') !== '7'; |
| 1980 | }); |
| 1981 | |
| 1982 | // @@replace logic |
| 1983 | fixRegexpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) { |
| 1984 | var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; |
| 1985 | |
| 1986 | return [ |
| 1987 | // `String.prototype.replace` method |
| 1988 | // https://tc39.es/ecma262/#sec-string.prototype.replace |
| 1989 | function replace(searchValue, replaceValue) { |
| 1990 | var O = requireObjectCoercible(this); |
| 1991 | var replacer = searchValue == undefined ? undefined : searchValue[REPLACE]; |
| 1992 | return replacer !== undefined |
| 1993 | ? replacer.call(searchValue, O, replaceValue) |
| 1994 | : nativeReplace.call(toString_1(O), searchValue, replaceValue); |
| 1995 | }, |
| 1996 | // `RegExp.prototype[@@replace]` method |
| 1997 | // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace |
| 1998 | function (string, replaceValue) { |
| 1999 | var rx = anObject(this); |
| 2000 | var S = toString_1(string); |
| 2001 | |
| 2002 | if ( |
| 2003 | typeof replaceValue === 'string' && |
| 2004 | replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 && |
| 2005 | replaceValue.indexOf('$<') === -1 |
| 2006 | ) { |
| 2007 | var res = maybeCallNative(nativeReplace, rx, S, replaceValue); |
| 2008 | if (res.done) return res.value; |
| 2009 | } |
| 2010 | |
| 2011 | var functionalReplace = typeof replaceValue === 'function'; |
| 2012 | if (!functionalReplace) replaceValue = toString_1(replaceValue); |
| 2013 | |
| 2014 | var global = rx.global; |
| 2015 | if (global) { |
| 2016 | var fullUnicode = rx.unicode; |
| 2017 | rx.lastIndex = 0; |
| 2018 | } |
| 2019 | var results = []; |
| 2020 | while (true) { |
| 2021 | var result = regexpExecAbstract(rx, S); |
| 2022 | if (result === null) break; |
| 2023 | |
| 2024 | results.push(result); |
| 2025 | if (!global) break; |
| 2026 | |
| 2027 | var matchStr = toString_1(result[0]); |
| 2028 | if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); |
| 2029 | } |
| 2030 | |
| 2031 | var accumulatedResult = ''; |
| 2032 | var nextSourcePosition = 0; |
| 2033 | for (var i = 0; i < results.length; i++) { |
| 2034 | result = results[i]; |
| 2035 | |
| 2036 | var matched = toString_1(result[0]); |
| 2037 | var position = max$2(min$1(toInteger(result.index), S.length), 0); |
| 2038 | var captures = []; |
| 2039 | // NOTE: This is equivalent to |
| 2040 | // captures = result.slice(1).map(maybeToString) |
| 2041 | // but for some reason `nativeSlice.call(result, 1, result.length)` (called in |
| 2042 | // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and |
| 2043 | // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. |
| 2044 | for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); |
| 2045 | var namedCaptures = result.groups; |
| 2046 | if (functionalReplace) { |
| 2047 | var replacerArgs = [matched].concat(captures, position, S); |
| 2048 | if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); |
| 2049 | var replacement = toString_1(replaceValue.apply(undefined, replacerArgs)); |
| 2050 | } else { |
| 2051 | replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); |
| 2052 | } |
| 2053 | if (position >= nextSourcePosition) { |
| 2054 | accumulatedResult += S.slice(nextSourcePosition, position) + replacement; |
| 2055 | nextSourcePosition = position + matched.length; |
| 2056 | } |
| 2057 | } |
| 2058 | return accumulatedResult + S.slice(nextSourcePosition); |
| 2059 | } |
| 2060 | ]; |
| 2061 | }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); |
| 2062 | |
| 2063 | /** |
| 2064 | * Remove a class from an element |
| 2065 | * |
| 2066 | * @api private |
| 2067 | * @method _removeClass |
| 2068 | * @param {Object} element |
| 2069 | * @param {RegExp|String} classNameRegex can be regex or string |
| 2070 | * @returns null |
| 2071 | */ |
| 2072 | function removeClass(element, classNameRegex) { |
| 2073 | if (element instanceof SVGElement) { |
| 2074 | var pre = element.getAttribute("class") || ""; |
| 2075 | element.setAttribute("class", pre.replace(classNameRegex, "").replace(/^\s+|\s+$/g, "")); |
| 2076 | } else { |
| 2077 | element.className = element.className.replace(classNameRegex, "").replace(/^\s+|\s+$/g, ""); |
| 2078 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2079 | } |
| 2080 | |
| 2081 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2082 | * Sets the style of an DOM element |
| 2083 | * |
| 2084 | * @param {Object} element |
| 2085 | * @param {Object|string} style |
| 2086 | * @return null |
| 2087 | */ |
| 2088 | function setStyle(element, style) { |
| 2089 | var cssText = ""; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2090 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2091 | if (element.style.cssText) { |
| 2092 | cssText += element.style.cssText; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2093 | } |
| 2094 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2095 | if (typeof style === "string") { |
| 2096 | cssText += style; |
| 2097 | } else { |
| 2098 | for (var rule in style) { |
| 2099 | cssText += "".concat(rule, ":").concat(style[rule], ";"); |
| 2100 | } |
| 2101 | } |
| 2102 | |
| 2103 | element.style.cssText = cssText; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2104 | } |
| 2105 | |
| 2106 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2107 | * Update the position of the helper layer on the screen |
| 2108 | * |
| 2109 | * @api private |
| 2110 | * @method _setHelperLayerPosition |
| 2111 | * @param {Object} helperLayer |
| 2112 | */ |
| 2113 | |
| 2114 | function setHelperLayerPosition(helperLayer) { |
| 2115 | if (helperLayer) { |
| 2116 | //prevent error when `this._currentStep` in undefined |
| 2117 | if (!this._introItems[this._currentStep]) return; |
| 2118 | var currentElement = this._introItems[this._currentStep]; |
| 2119 | var elementPosition = getOffset(currentElement.element, this._targetElement); |
| 2120 | var widthHeightPadding = this._options.helperElementPadding; // If the target element is fixed, the tooltip should be fixed as well. |
| 2121 | // Otherwise, remove a fixed class that may be left over from the previous |
| 2122 | // step. |
| 2123 | |
| 2124 | if (isFixed(currentElement.element)) { |
| 2125 | addClass(helperLayer, "introjs-fixedTooltip"); |
| 2126 | } else { |
| 2127 | removeClass(helperLayer, "introjs-fixedTooltip"); |
| 2128 | } |
| 2129 | |
| 2130 | if (currentElement.position === "floating") { |
| 2131 | widthHeightPadding = 0; |
| 2132 | } //set new position to helper layer |
| 2133 | |
| 2134 | |
| 2135 | setStyle(helperLayer, { |
| 2136 | width: "".concat(elementPosition.width + widthHeightPadding, "px"), |
| 2137 | height: "".concat(elementPosition.height + widthHeightPadding, "px"), |
| 2138 | top: "".concat(elementPosition.top - widthHeightPadding / 2, "px"), |
| 2139 | left: "".concat(elementPosition.left - widthHeightPadding / 2, "px") |
| 2140 | }); |
| 2141 | } |
| 2142 | } |
| 2143 | |
| 2144 | var UNSCOPABLES = wellKnownSymbol('unscopables'); |
| 2145 | var ArrayPrototype = Array.prototype; |
| 2146 | |
| 2147 | // Array.prototype[@@unscopables] |
| 2148 | // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables |
| 2149 | if (ArrayPrototype[UNSCOPABLES] == undefined) { |
| 2150 | objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, { |
| 2151 | configurable: true, |
| 2152 | value: objectCreate(null) |
| 2153 | }); |
| 2154 | } |
| 2155 | |
| 2156 | // add a key to Array.prototype[@@unscopables] |
| 2157 | var addToUnscopables = function (key) { |
| 2158 | ArrayPrototype[UNSCOPABLES][key] = true; |
| 2159 | }; |
| 2160 | |
| 2161 | var $includes = arrayIncludes.includes; |
| 2162 | |
| 2163 | |
| 2164 | // `Array.prototype.includes` method |
| 2165 | // https://tc39.es/ecma262/#sec-array.prototype.includes |
| 2166 | _export({ target: 'Array', proto: true }, { |
| 2167 | includes: function includes(el /* , fromIndex = 0 */) { |
| 2168 | return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); |
| 2169 | } |
| 2170 | }); |
| 2171 | |
| 2172 | // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables |
| 2173 | addToUnscopables('includes'); |
| 2174 | |
| 2175 | var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('slice'); |
| 2176 | |
| 2177 | var SPECIES = wellKnownSymbol('species'); |
| 2178 | var nativeSlice = [].slice; |
| 2179 | var max$1 = Math.max; |
| 2180 | |
| 2181 | // `Array.prototype.slice` method |
| 2182 | // https://tc39.es/ecma262/#sec-array.prototype.slice |
| 2183 | // fallback for not array-like ES3 strings and DOM objects |
| 2184 | _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, { |
| 2185 | slice: function slice(start, end) { |
| 2186 | var O = toIndexedObject(this); |
| 2187 | var length = toLength(O.length); |
| 2188 | var k = toAbsoluteIndex(start, length); |
| 2189 | var fin = toAbsoluteIndex(end === undefined ? length : end, length); |
| 2190 | // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible |
| 2191 | var Constructor, result, n; |
| 2192 | if (isArray(O)) { |
| 2193 | Constructor = O.constructor; |
| 2194 | // cross-realm fallback |
| 2195 | if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) { |
| 2196 | Constructor = undefined; |
| 2197 | } else if (isObject(Constructor)) { |
| 2198 | Constructor = Constructor[SPECIES]; |
| 2199 | if (Constructor === null) Constructor = undefined; |
| 2200 | } |
| 2201 | if (Constructor === Array || Constructor === undefined) { |
| 2202 | return nativeSlice.call(O, k, fin); |
| 2203 | } |
| 2204 | } |
| 2205 | result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0)); |
| 2206 | for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]); |
| 2207 | result.length = n; |
| 2208 | return result; |
| 2209 | } |
| 2210 | }); |
| 2211 | |
| 2212 | var notARegexp = function (it) { |
| 2213 | if (isRegexp(it)) { |
| 2214 | throw TypeError("The method doesn't accept regular expressions"); |
| 2215 | } return it; |
| 2216 | }; |
| 2217 | |
| 2218 | var MATCH = wellKnownSymbol('match'); |
| 2219 | |
| 2220 | var correctIsRegexpLogic = function (METHOD_NAME) { |
| 2221 | var regexp = /./; |
| 2222 | try { |
| 2223 | '/./'[METHOD_NAME](regexp); |
| 2224 | } catch (error1) { |
| 2225 | try { |
| 2226 | regexp[MATCH] = false; |
| 2227 | return '/./'[METHOD_NAME](regexp); |
| 2228 | } catch (error2) { /* empty */ } |
| 2229 | } return false; |
| 2230 | }; |
| 2231 | |
| 2232 | // `String.prototype.includes` method |
| 2233 | // https://tc39.es/ecma262/#sec-string.prototype.includes |
| 2234 | _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, { |
| 2235 | includes: function includes(searchString /* , position = 0 */) { |
| 2236 | return !!~toString_1(requireObjectCoercible(this)) |
| 2237 | .indexOf(toString_1(notARegexp(searchString)), arguments.length > 1 ? arguments[1] : undefined); |
| 2238 | } |
| 2239 | }); |
| 2240 | |
| 2241 | var arrayMethodIsStrict = function (METHOD_NAME, argument) { |
| 2242 | var method = [][METHOD_NAME]; |
| 2243 | return !!method && fails(function () { |
| 2244 | // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing |
| 2245 | method.call(null, argument || function () { throw 1; }, 1); |
| 2246 | }); |
| 2247 | }; |
| 2248 | |
| 2249 | var nativeJoin = [].join; |
| 2250 | |
| 2251 | var ES3_STRINGS = indexedObject != Object; |
| 2252 | var STRICT_METHOD$1 = arrayMethodIsStrict('join', ','); |
| 2253 | |
| 2254 | // `Array.prototype.join` method |
| 2255 | // https://tc39.es/ecma262/#sec-array.prototype.join |
| 2256 | _export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$1 }, { |
| 2257 | join: function join(separator) { |
| 2258 | return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator); |
| 2259 | } |
| 2260 | }); |
| 2261 | |
| 2262 | // optional / simple context binding |
| 2263 | var functionBindContext = function (fn, that, length) { |
| 2264 | aFunction(fn); |
| 2265 | if (that === undefined) return fn; |
| 2266 | switch (length) { |
| 2267 | case 0: return function () { |
| 2268 | return fn.call(that); |
| 2269 | }; |
| 2270 | case 1: return function (a) { |
| 2271 | return fn.call(that, a); |
| 2272 | }; |
| 2273 | case 2: return function (a, b) { |
| 2274 | return fn.call(that, a, b); |
| 2275 | }; |
| 2276 | case 3: return function (a, b, c) { |
| 2277 | return fn.call(that, a, b, c); |
| 2278 | }; |
| 2279 | } |
| 2280 | return function (/* ...args */) { |
| 2281 | return fn.apply(that, arguments); |
| 2282 | }; |
| 2283 | }; |
| 2284 | |
| 2285 | var push = [].push; |
| 2286 | |
| 2287 | // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation |
| 2288 | var createMethod = function (TYPE) { |
| 2289 | var IS_MAP = TYPE == 1; |
| 2290 | var IS_FILTER = TYPE == 2; |
| 2291 | var IS_SOME = TYPE == 3; |
| 2292 | var IS_EVERY = TYPE == 4; |
| 2293 | var IS_FIND_INDEX = TYPE == 6; |
| 2294 | var IS_FILTER_REJECT = TYPE == 7; |
| 2295 | var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; |
| 2296 | return function ($this, callbackfn, that, specificCreate) { |
| 2297 | var O = toObject($this); |
| 2298 | var self = indexedObject(O); |
| 2299 | var boundFunction = functionBindContext(callbackfn, that, 3); |
| 2300 | var length = toLength(self.length); |
| 2301 | var index = 0; |
| 2302 | var create = specificCreate || arraySpeciesCreate; |
| 2303 | var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; |
| 2304 | var value, result; |
| 2305 | for (;length > index; index++) if (NO_HOLES || index in self) { |
| 2306 | value = self[index]; |
| 2307 | result = boundFunction(value, index, O); |
| 2308 | if (TYPE) { |
| 2309 | if (IS_MAP) target[index] = result; // map |
| 2310 | else if (result) switch (TYPE) { |
| 2311 | case 3: return true; // some |
| 2312 | case 5: return value; // find |
| 2313 | case 6: return index; // findIndex |
| 2314 | case 2: push.call(target, value); // filter |
| 2315 | } else switch (TYPE) { |
| 2316 | case 4: return false; // every |
| 2317 | case 7: push.call(target, value); // filterReject |
| 2318 | } |
| 2319 | } |
| 2320 | } |
| 2321 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; |
| 2322 | }; |
| 2323 | }; |
| 2324 | |
| 2325 | var arrayIteration = { |
| 2326 | // `Array.prototype.forEach` method |
| 2327 | // https://tc39.es/ecma262/#sec-array.prototype.foreach |
| 2328 | forEach: createMethod(0), |
| 2329 | // `Array.prototype.map` method |
| 2330 | // https://tc39.es/ecma262/#sec-array.prototype.map |
| 2331 | map: createMethod(1), |
| 2332 | // `Array.prototype.filter` method |
| 2333 | // https://tc39.es/ecma262/#sec-array.prototype.filter |
| 2334 | filter: createMethod(2), |
| 2335 | // `Array.prototype.some` method |
| 2336 | // https://tc39.es/ecma262/#sec-array.prototype.some |
| 2337 | some: createMethod(3), |
| 2338 | // `Array.prototype.every` method |
| 2339 | // https://tc39.es/ecma262/#sec-array.prototype.every |
| 2340 | every: createMethod(4), |
| 2341 | // `Array.prototype.find` method |
| 2342 | // https://tc39.es/ecma262/#sec-array.prototype.find |
| 2343 | find: createMethod(5), |
| 2344 | // `Array.prototype.findIndex` method |
| 2345 | // https://tc39.es/ecma262/#sec-array.prototype.findIndex |
| 2346 | findIndex: createMethod(6), |
| 2347 | // `Array.prototype.filterReject` method |
| 2348 | // https://github.com/tc39/proposal-array-filtering |
| 2349 | filterReject: createMethod(7) |
| 2350 | }; |
| 2351 | |
| 2352 | var $filter = arrayIteration.filter; |
| 2353 | |
| 2354 | |
| 2355 | var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter'); |
| 2356 | |
| 2357 | // `Array.prototype.filter` method |
| 2358 | // https://tc39.es/ecma262/#sec-array.prototype.filter |
| 2359 | // with adding support of @@species |
| 2360 | _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, { |
| 2361 | filter: function filter(callbackfn /* , thisArg */) { |
| 2362 | return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); |
| 2363 | } |
| 2364 | }); |
| 2365 | |
| 2366 | /** |
| 2367 | * Set tooltip left so it doesn't go off the right side of the window |
| 2368 | * |
| 2369 | * @return boolean true, if tooltipLayerStyleLeft is ok. false, otherwise. |
| 2370 | */ |
| 2371 | function checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) { |
| 2372 | if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) { |
| 2373 | // off the right side of the window |
| 2374 | tooltipLayer.style.left = "".concat(windowSize.width - tooltipOffset.width - targetOffset.left, "px"); |
| 2375 | return false; |
| 2376 | } |
| 2377 | |
| 2378 | tooltipLayer.style.left = "".concat(tooltipLayerStyleLeft, "px"); |
| 2379 | return true; |
| 2380 | } |
| 2381 | |
| 2382 | /** |
| 2383 | * Set tooltip right so it doesn't go off the left side of the window |
| 2384 | * |
| 2385 | * @return boolean true, if tooltipLayerStyleRight is ok. false, otherwise. |
| 2386 | */ |
| 2387 | function checkLeft(targetOffset, tooltipLayerStyleRight, tooltipOffset, tooltipLayer) { |
| 2388 | if (targetOffset.left + targetOffset.width - tooltipLayerStyleRight - tooltipOffset.width < 0) { |
| 2389 | // off the left side of the window |
| 2390 | tooltipLayer.style.left = "".concat(-targetOffset.left, "px"); |
| 2391 | return false; |
| 2392 | } |
| 2393 | |
| 2394 | tooltipLayer.style.right = "".concat(tooltipLayerStyleRight, "px"); |
| 2395 | return true; |
| 2396 | } |
| 2397 | |
| 2398 | var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); |
| 2399 | |
| 2400 | var max = Math.max; |
| 2401 | var min = Math.min; |
| 2402 | var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; |
| 2403 | var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; |
| 2404 | |
| 2405 | // `Array.prototype.splice` method |
| 2406 | // https://tc39.es/ecma262/#sec-array.prototype.splice |
| 2407 | // with adding support of @@species |
| 2408 | _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { |
| 2409 | splice: function splice(start, deleteCount /* , ...items */) { |
| 2410 | var O = toObject(this); |
| 2411 | var len = toLength(O.length); |
| 2412 | var actualStart = toAbsoluteIndex(start, len); |
| 2413 | var argumentsLength = arguments.length; |
| 2414 | var insertCount, actualDeleteCount, A, k, from, to; |
| 2415 | if (argumentsLength === 0) { |
| 2416 | insertCount = actualDeleteCount = 0; |
| 2417 | } else if (argumentsLength === 1) { |
| 2418 | insertCount = 0; |
| 2419 | actualDeleteCount = len - actualStart; |
| 2420 | } else { |
| 2421 | insertCount = argumentsLength - 2; |
| 2422 | actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart); |
| 2423 | } |
| 2424 | if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) { |
| 2425 | throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED); |
| 2426 | } |
| 2427 | A = arraySpeciesCreate(O, actualDeleteCount); |
| 2428 | for (k = 0; k < actualDeleteCount; k++) { |
| 2429 | from = actualStart + k; |
| 2430 | if (from in O) createProperty(A, k, O[from]); |
| 2431 | } |
| 2432 | A.length = actualDeleteCount; |
| 2433 | if (insertCount < actualDeleteCount) { |
| 2434 | for (k = actualStart; k < len - actualDeleteCount; k++) { |
| 2435 | from = k + actualDeleteCount; |
| 2436 | to = k + insertCount; |
| 2437 | if (from in O) O[to] = O[from]; |
| 2438 | else delete O[to]; |
| 2439 | } |
| 2440 | for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1]; |
| 2441 | } else if (insertCount > actualDeleteCount) { |
| 2442 | for (k = len - actualDeleteCount; k > actualStart; k--) { |
| 2443 | from = k + actualDeleteCount - 1; |
| 2444 | to = k + insertCount - 1; |
| 2445 | if (from in O) O[to] = O[from]; |
| 2446 | else delete O[to]; |
| 2447 | } |
| 2448 | } |
| 2449 | for (k = 0; k < insertCount; k++) { |
| 2450 | O[k + actualStart] = arguments[k + 2]; |
| 2451 | } |
| 2452 | O.length = len - actualDeleteCount + insertCount; |
| 2453 | return A; |
| 2454 | } |
| 2455 | }); |
| 2456 | |
| 2457 | /** |
| 2458 | * Remove an entry from a string array if it's there, does nothing if it isn't there. |
| 2459 | * |
| 2460 | * @param {Array} stringArray |
| 2461 | * @param {String} stringToRemove |
| 2462 | */ |
| 2463 | function removeEntry(stringArray, stringToRemove) { |
| 2464 | if (stringArray.includes(stringToRemove)) { |
| 2465 | stringArray.splice(stringArray.indexOf(stringToRemove), 1); |
| 2466 | } |
| 2467 | } |
| 2468 | |
| 2469 | /** |
| 2470 | * auto-determine alignment |
| 2471 | * @param {Integer} offsetLeft |
| 2472 | * @param {Integer} tooltipWidth |
| 2473 | * @param {Object} windowSize |
| 2474 | * @param {String} desiredAlignment |
| 2475 | * @return {String} calculatedAlignment |
| 2476 | */ |
| 2477 | |
| 2478 | function _determineAutoAlignment(offsetLeft, tooltipWidth, _ref, desiredAlignment) { |
| 2479 | var width = _ref.width; |
| 2480 | var halfTooltipWidth = tooltipWidth / 2; |
| 2481 | var winWidth = Math.min(width, window.screen.width); |
| 2482 | var possibleAlignments = ["-left-aligned", "-middle-aligned", "-right-aligned"]; |
| 2483 | var calculatedAlignment = ""; // valid left must be at least a tooltipWidth |
| 2484 | // away from right side |
| 2485 | |
| 2486 | if (winWidth - offsetLeft < tooltipWidth) { |
| 2487 | removeEntry(possibleAlignments, "-left-aligned"); |
| 2488 | } // valid middle must be at least half |
| 2489 | // width away from both sides |
| 2490 | |
| 2491 | |
| 2492 | if (offsetLeft < halfTooltipWidth || winWidth - offsetLeft < halfTooltipWidth) { |
| 2493 | removeEntry(possibleAlignments, "-middle-aligned"); |
| 2494 | } // valid right must be at least a tooltipWidth |
| 2495 | // width away from left side |
| 2496 | |
| 2497 | |
| 2498 | if (offsetLeft < tooltipWidth) { |
| 2499 | removeEntry(possibleAlignments, "-right-aligned"); |
| 2500 | } |
| 2501 | |
| 2502 | if (possibleAlignments.length) { |
| 2503 | if (possibleAlignments.includes(desiredAlignment)) { |
| 2504 | // the desired alignment is valid |
| 2505 | calculatedAlignment = desiredAlignment; |
| 2506 | } else { |
| 2507 | // pick the first valid position, in order |
| 2508 | calculatedAlignment = possibleAlignments[0]; |
| 2509 | } |
| 2510 | } else { |
| 2511 | // if screen width is too small |
| 2512 | // for ANY alignment, middle is |
| 2513 | // probably the best for visibility |
| 2514 | calculatedAlignment = "-middle-aligned"; |
| 2515 | } |
| 2516 | |
| 2517 | return calculatedAlignment; |
| 2518 | } |
| 2519 | /** |
| 2520 | * Determines the position of the tooltip based on the position precedence and availability |
| 2521 | * of screen space. |
| 2522 | * |
| 2523 | * @param {Object} targetElement |
| 2524 | * @param {Object} tooltipLayer |
| 2525 | * @param {String} desiredTooltipPosition |
| 2526 | * @return {String} calculatedPosition |
| 2527 | */ |
| 2528 | |
| 2529 | |
| 2530 | function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) { |
| 2531 | // Take a clone of position precedence. These will be the available |
| 2532 | var possiblePositions = this._options.positionPrecedence.slice(); |
| 2533 | |
| 2534 | var windowSize = getWinSize(); |
| 2535 | var tooltipHeight = getOffset(tooltipLayer).height + 10; |
| 2536 | var tooltipWidth = getOffset(tooltipLayer).width + 20; |
| 2537 | var targetElementRect = targetElement.getBoundingClientRect(); // If we check all the possible areas, and there are no valid places for the tooltip, the element |
| 2538 | // must take up most of the screen real estate. Show the tooltip floating in the middle of the screen. |
| 2539 | |
| 2540 | var calculatedPosition = "floating"; |
| 2541 | /* |
| 2542 | * auto determine position |
| 2543 | */ |
| 2544 | // Check for space below |
| 2545 | |
| 2546 | if (targetElementRect.bottom + tooltipHeight > windowSize.height) { |
| 2547 | removeEntry(possiblePositions, "bottom"); |
| 2548 | } // Check for space above |
| 2549 | |
| 2550 | |
| 2551 | if (targetElementRect.top - tooltipHeight < 0) { |
| 2552 | removeEntry(possiblePositions, "top"); |
| 2553 | } // Check for space to the right |
| 2554 | |
| 2555 | |
| 2556 | if (targetElementRect.right + tooltipWidth > windowSize.width) { |
| 2557 | removeEntry(possiblePositions, "right"); |
| 2558 | } // Check for space to the left |
| 2559 | |
| 2560 | |
| 2561 | if (targetElementRect.left - tooltipWidth < 0) { |
| 2562 | removeEntry(possiblePositions, "left"); |
| 2563 | } // @var {String} ex: 'right-aligned' |
| 2564 | |
| 2565 | |
| 2566 | var desiredAlignment = function (pos) { |
| 2567 | var hyphenIndex = pos.indexOf("-"); |
| 2568 | |
| 2569 | if (hyphenIndex !== -1) { |
| 2570 | // has alignment |
| 2571 | return pos.substr(hyphenIndex); |
| 2572 | } |
| 2573 | |
| 2574 | return ""; |
| 2575 | }(desiredTooltipPosition || ""); // strip alignment from position |
| 2576 | |
| 2577 | |
| 2578 | if (desiredTooltipPosition) { |
| 2579 | // ex: "bottom-right-aligned" |
| 2580 | // should return 'bottom' |
| 2581 | desiredTooltipPosition = desiredTooltipPosition.split("-")[0]; |
| 2582 | } |
| 2583 | |
| 2584 | if (possiblePositions.length) { |
| 2585 | if (possiblePositions.includes(desiredTooltipPosition)) { |
| 2586 | // If the requested position is in the list, choose that |
| 2587 | calculatedPosition = desiredTooltipPosition; |
| 2588 | } else { |
| 2589 | // Pick the first valid position, in order |
| 2590 | calculatedPosition = possiblePositions[0]; |
| 2591 | } |
| 2592 | } // only top and bottom positions have optional alignments |
| 2593 | |
| 2594 | |
| 2595 | if (["top", "bottom"].includes(calculatedPosition)) { |
| 2596 | calculatedPosition += _determineAutoAlignment(targetElementRect.left, tooltipWidth, windowSize, desiredAlignment); |
| 2597 | } |
| 2598 | |
| 2599 | return calculatedPosition; |
| 2600 | } |
| 2601 | /** |
| 2602 | * Render tooltip box in the page |
| 2603 | * |
| 2604 | * @api private |
| 2605 | * @method placeTooltip |
| 2606 | * @param {HTMLElement} targetElement |
| 2607 | * @param {HTMLElement} tooltipLayer |
| 2608 | * @param {HTMLElement} arrowLayer |
| 2609 | * @param {Boolean} hintMode |
| 2610 | */ |
| 2611 | |
| 2612 | |
| 2613 | function placeTooltip(targetElement, tooltipLayer, arrowLayer, hintMode) { |
| 2614 | var tooltipCssClass = ""; |
| 2615 | var currentStepObj; |
| 2616 | var tooltipOffset; |
| 2617 | var targetOffset; |
| 2618 | var windowSize; |
| 2619 | var currentTooltipPosition; |
| 2620 | hintMode = hintMode || false; //reset the old style |
| 2621 | |
| 2622 | tooltipLayer.style.top = null; |
| 2623 | tooltipLayer.style.right = null; |
| 2624 | tooltipLayer.style.bottom = null; |
| 2625 | tooltipLayer.style.left = null; |
| 2626 | tooltipLayer.style.marginLeft = null; |
| 2627 | tooltipLayer.style.marginTop = null; |
| 2628 | arrowLayer.style.display = "inherit"; //prevent error when `this._currentStep` is undefined |
| 2629 | |
| 2630 | if (!this._introItems[this._currentStep]) return; //if we have a custom css class for each step |
| 2631 | |
| 2632 | currentStepObj = this._introItems[this._currentStep]; |
| 2633 | |
| 2634 | if (typeof currentStepObj.tooltipClass === "string") { |
| 2635 | tooltipCssClass = currentStepObj.tooltipClass; |
| 2636 | } else { |
| 2637 | tooltipCssClass = this._options.tooltipClass; |
| 2638 | } |
| 2639 | |
| 2640 | tooltipLayer.className = ["introjs-tooltip", tooltipCssClass].filter(Boolean).join(" "); |
| 2641 | tooltipLayer.setAttribute("role", "dialog"); |
| 2642 | currentTooltipPosition = this._introItems[this._currentStep].position; // Floating is always valid, no point in calculating |
| 2643 | |
| 2644 | if (currentTooltipPosition !== "floating" && this._options.autoPosition) { |
| 2645 | currentTooltipPosition = _determineAutoPosition.call(this, targetElement, tooltipLayer, currentTooltipPosition); |
| 2646 | } |
| 2647 | |
| 2648 | var tooltipLayerStyleLeft; |
| 2649 | targetOffset = getOffset(targetElement); |
| 2650 | tooltipOffset = getOffset(tooltipLayer); |
| 2651 | windowSize = getWinSize(); |
| 2652 | addClass(tooltipLayer, "introjs-".concat(currentTooltipPosition)); |
| 2653 | |
| 2654 | switch (currentTooltipPosition) { |
| 2655 | case "top-right-aligned": |
| 2656 | arrowLayer.className = "introjs-arrow bottom-right"; |
| 2657 | var tooltipLayerStyleRight = 0; |
| 2658 | checkLeft(targetOffset, tooltipLayerStyleRight, tooltipOffset, tooltipLayer); |
| 2659 | tooltipLayer.style.bottom = "".concat(targetOffset.height + 20, "px"); |
| 2660 | break; |
| 2661 | |
| 2662 | case "top-middle-aligned": |
| 2663 | arrowLayer.className = "introjs-arrow bottom-middle"; |
| 2664 | var tooltipLayerStyleLeftRight = targetOffset.width / 2 - tooltipOffset.width / 2; // a fix for middle aligned hints |
| 2665 | |
| 2666 | if (hintMode) { |
| 2667 | tooltipLayerStyleLeftRight += 5; |
| 2668 | } |
| 2669 | |
| 2670 | if (checkLeft(targetOffset, tooltipLayerStyleLeftRight, tooltipOffset, tooltipLayer)) { |
| 2671 | tooltipLayer.style.right = null; |
| 2672 | checkRight(targetOffset, tooltipLayerStyleLeftRight, tooltipOffset, windowSize, tooltipLayer); |
| 2673 | } |
| 2674 | |
| 2675 | tooltipLayer.style.bottom = "".concat(targetOffset.height + 20, "px"); |
| 2676 | break; |
| 2677 | |
| 2678 | case "top-left-aligned": // top-left-aligned is the same as the default top |
| 2679 | |
| 2680 | case "top": |
| 2681 | arrowLayer.className = "introjs-arrow bottom"; |
| 2682 | tooltipLayerStyleLeft = hintMode ? 0 : 15; |
| 2683 | checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer); |
| 2684 | tooltipLayer.style.bottom = "".concat(targetOffset.height + 20, "px"); |
| 2685 | break; |
| 2686 | |
| 2687 | case "right": |
| 2688 | tooltipLayer.style.left = "".concat(targetOffset.width + 20, "px"); |
| 2689 | |
| 2690 | if (targetOffset.top + tooltipOffset.height > windowSize.height) { |
| 2691 | // In this case, right would have fallen below the bottom of the screen. |
| 2692 | // Modify so that the bottom of the tooltip connects with the target |
| 2693 | arrowLayer.className = "introjs-arrow left-bottom"; |
| 2694 | tooltipLayer.style.top = "-".concat(tooltipOffset.height - targetOffset.height - 20, "px"); |
| 2695 | } else { |
| 2696 | arrowLayer.className = "introjs-arrow left"; |
| 2697 | } |
| 2698 | |
| 2699 | break; |
| 2700 | |
| 2701 | case "left": |
| 2702 | if (!hintMode && this._options.showStepNumbers === true) { |
| 2703 | tooltipLayer.style.top = "15px"; |
| 2704 | } |
| 2705 | |
| 2706 | if (targetOffset.top + tooltipOffset.height > windowSize.height) { |
| 2707 | // In this case, left would have fallen below the bottom of the screen. |
| 2708 | // Modify so that the bottom of the tooltip connects with the target |
| 2709 | tooltipLayer.style.top = "-".concat(tooltipOffset.height - targetOffset.height - 20, "px"); |
| 2710 | arrowLayer.className = "introjs-arrow right-bottom"; |
| 2711 | } else { |
| 2712 | arrowLayer.className = "introjs-arrow right"; |
| 2713 | } |
| 2714 | |
| 2715 | tooltipLayer.style.right = "".concat(targetOffset.width + 20, "px"); |
| 2716 | break; |
| 2717 | |
| 2718 | case "floating": |
| 2719 | arrowLayer.style.display = "none"; //we have to adjust the top and left of layer manually for intro items without element |
| 2720 | |
| 2721 | tooltipLayer.style.left = "50%"; |
| 2722 | tooltipLayer.style.top = "50%"; |
| 2723 | tooltipLayer.style.marginLeft = "-".concat(tooltipOffset.width / 2, "px"); |
| 2724 | tooltipLayer.style.marginTop = "-".concat(tooltipOffset.height / 2, "px"); |
| 2725 | break; |
| 2726 | |
| 2727 | case "bottom-right-aligned": |
| 2728 | arrowLayer.className = "introjs-arrow top-right"; |
| 2729 | tooltipLayerStyleRight = 0; |
| 2730 | checkLeft(targetOffset, tooltipLayerStyleRight, tooltipOffset, tooltipLayer); |
| 2731 | tooltipLayer.style.top = "".concat(targetOffset.height + 20, "px"); |
| 2732 | break; |
| 2733 | |
| 2734 | case "bottom-middle-aligned": |
| 2735 | arrowLayer.className = "introjs-arrow top-middle"; |
| 2736 | tooltipLayerStyleLeftRight = targetOffset.width / 2 - tooltipOffset.width / 2; // a fix for middle aligned hints |
| 2737 | |
| 2738 | if (hintMode) { |
| 2739 | tooltipLayerStyleLeftRight += 5; |
| 2740 | } |
| 2741 | |
| 2742 | if (checkLeft(targetOffset, tooltipLayerStyleLeftRight, tooltipOffset, tooltipLayer)) { |
| 2743 | tooltipLayer.style.right = null; |
| 2744 | checkRight(targetOffset, tooltipLayerStyleLeftRight, tooltipOffset, windowSize, tooltipLayer); |
| 2745 | } |
| 2746 | |
| 2747 | tooltipLayer.style.top = "".concat(targetOffset.height + 20, "px"); |
| 2748 | break; |
| 2749 | // case 'bottom-left-aligned': |
| 2750 | // Bottom-left-aligned is the same as the default bottom |
| 2751 | // case 'bottom': |
| 2752 | // Bottom going to follow the default behavior |
| 2753 | |
| 2754 | default: |
| 2755 | arrowLayer.className = "introjs-arrow top"; |
| 2756 | tooltipLayerStyleLeft = 0; |
| 2757 | checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer); |
| 2758 | tooltipLayer.style.top = "".concat(targetOffset.height + 20, "px"); |
| 2759 | } |
| 2760 | } |
| 2761 | |
| 2762 | /** |
| 2763 | * To remove all show element(s) |
| 2764 | * |
| 2765 | * @api private |
| 2766 | * @method _removeShowElement |
| 2767 | */ |
| 2768 | |
| 2769 | function removeShowElement() { |
| 2770 | var elms = document.querySelectorAll(".introjs-showElement"); |
| 2771 | forEach(elms, function (elm) { |
| 2772 | removeClass(elm, /introjs-[a-zA-Z]+/g); |
| 2773 | }); |
| 2774 | } |
| 2775 | |
| 2776 | function _createElement(tagname, attrs) { |
| 2777 | var element = document.createElement(tagname); |
| 2778 | attrs = attrs || {}; // regex for matching attributes that need to be set with setAttribute |
| 2779 | |
| 2780 | var setAttRegex = /^(?:role|data-|aria-)/; |
| 2781 | |
| 2782 | for (var k in attrs) { |
| 2783 | var v = attrs[k]; |
| 2784 | |
| 2785 | if (k === "style") { |
| 2786 | setStyle(element, v); |
| 2787 | } else if (k.match(setAttRegex)) { |
| 2788 | element.setAttribute(k, v); |
| 2789 | } else { |
| 2790 | element[k] = v; |
| 2791 | } |
| 2792 | } |
| 2793 | |
| 2794 | return element; |
| 2795 | } |
| 2796 | |
| 2797 | /** |
| 2798 | * Appends `element` to `parentElement` |
| 2799 | * |
| 2800 | * @param {Element} parentElement |
| 2801 | * @param {Element} element |
| 2802 | * @param {Boolean} [animate=false] |
| 2803 | */ |
| 2804 | |
| 2805 | function appendChild(parentElement, element, animate) { |
| 2806 | if (animate) { |
| 2807 | var existingOpacity = element.style.opacity || "1"; |
| 2808 | setStyle(element, { |
| 2809 | opacity: "0" |
| 2810 | }); |
| 2811 | window.setTimeout(function () { |
| 2812 | setStyle(element, { |
| 2813 | opacity: existingOpacity |
| 2814 | }); |
| 2815 | }, 10); |
| 2816 | } |
| 2817 | |
| 2818 | parentElement.appendChild(element); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2819 | } |
| 2820 | |
| 2821 | /** |
| 2822 | * Gets the current progress percentage |
| 2823 | * |
| 2824 | * @api private |
| 2825 | * @method _getProgress |
| 2826 | * @returns current progress percentage |
| 2827 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2828 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 2829 | function _getProgress() { |
| 2830 | // Steps are 0 indexed |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 2831 | var currentStep = parseInt(this._currentStep + 1, 10); |
| 2832 | return currentStep / this._introItems.length * 100; |
| 2833 | } |
| 2834 | /** |
| 2835 | * Add disableinteraction layer and adjust the size and position of the layer |
| 2836 | * |
| 2837 | * @api private |
| 2838 | * @method _disableInteraction |
| 2839 | */ |
| 2840 | |
| 2841 | |
| 2842 | function _disableInteraction() { |
| 2843 | var disableInteractionLayer = document.querySelector(".introjs-disableInteraction"); |
| 2844 | |
| 2845 | if (disableInteractionLayer === null) { |
| 2846 | disableInteractionLayer = _createElement("div", { |
| 2847 | className: "introjs-disableInteraction" |
| 2848 | }); |
| 2849 | |
| 2850 | this._targetElement.appendChild(disableInteractionLayer); |
| 2851 | } |
| 2852 | |
| 2853 | setHelperLayerPosition.call(this, disableInteractionLayer); |
| 2854 | } |
| 2855 | /** |
| 2856 | * Creates the bullets layer |
| 2857 | * @returns HTMLElement |
| 2858 | * @private |
| 2859 | */ |
| 2860 | |
| 2861 | |
| 2862 | function _createBullets(targetElement) { |
| 2863 | var self = this; |
| 2864 | var bulletsLayer = _createElement("div", { |
| 2865 | className: "introjs-bullets" |
| 2866 | }); |
| 2867 | |
| 2868 | if (this._options.showBullets === false) { |
| 2869 | bulletsLayer.style.display = "none"; |
| 2870 | } |
| 2871 | |
| 2872 | var ulContainer = _createElement("ul"); |
| 2873 | ulContainer.setAttribute("role", "tablist"); |
| 2874 | |
| 2875 | var anchorClick = function anchorClick() { |
| 2876 | self.goToStep(this.getAttribute("data-stepnumber")); |
| 2877 | }; |
| 2878 | |
| 2879 | forEach(this._introItems, function (_ref, i) { |
| 2880 | var step = _ref.step; |
| 2881 | var innerLi = _createElement("li"); |
| 2882 | var anchorLink = _createElement("a"); |
| 2883 | innerLi.setAttribute("role", "presentation"); |
| 2884 | anchorLink.setAttribute("role", "tab"); |
| 2885 | anchorLink.onclick = anchorClick; |
| 2886 | |
| 2887 | if (i === targetElement.step - 1) { |
| 2888 | anchorLink.className = "active"; |
| 2889 | } |
| 2890 | |
| 2891 | setAnchorAsButton(anchorLink); |
| 2892 | anchorLink.innerHTML = " "; |
| 2893 | anchorLink.setAttribute("data-stepnumber", step); |
| 2894 | innerLi.appendChild(anchorLink); |
| 2895 | ulContainer.appendChild(innerLi); |
| 2896 | }); |
| 2897 | bulletsLayer.appendChild(ulContainer); |
| 2898 | return bulletsLayer; |
| 2899 | } |
| 2900 | /** |
| 2901 | * Deletes and recreates the bullets layer |
| 2902 | * @param oldReferenceLayer |
| 2903 | * @param targetElement |
| 2904 | * @private |
| 2905 | */ |
| 2906 | |
| 2907 | |
| 2908 | function _recreateBullets(oldReferenceLayer, targetElement) { |
| 2909 | if (this._options.showBullets) { |
| 2910 | var existing = document.querySelector(".introjs-bullets"); |
| 2911 | existing.parentNode.replaceChild(_createBullets.call(this, targetElement), existing); |
| 2912 | } |
| 2913 | } |
| 2914 | /** |
| 2915 | * Updates the bullets |
| 2916 | * |
| 2917 | * @param oldReferenceLayer |
| 2918 | * @param targetElement |
| 2919 | */ |
| 2920 | |
| 2921 | function _updateBullets(oldReferenceLayer, targetElement) { |
| 2922 | if (this._options.showBullets) { |
| 2923 | oldReferenceLayer.querySelector(".introjs-bullets li > a.active").className = ""; |
| 2924 | oldReferenceLayer.querySelector(".introjs-bullets li > a[data-stepnumber=\"".concat(targetElement.step, "\"]")).className = "active"; |
| 2925 | } |
| 2926 | } |
| 2927 | /** |
| 2928 | * Creates the progress-bar layer and elements |
| 2929 | * @returns {*} |
| 2930 | * @private |
| 2931 | */ |
| 2932 | |
| 2933 | |
| 2934 | function _createProgressBar() { |
| 2935 | var progressLayer = _createElement("div"); |
| 2936 | progressLayer.className = "introjs-progress"; |
| 2937 | |
| 2938 | if (this._options.showProgress === false) { |
| 2939 | progressLayer.style.display = "none"; |
| 2940 | } |
| 2941 | |
| 2942 | var progressBar = _createElement("div", { |
| 2943 | className: "introjs-progressbar" |
| 2944 | }); |
| 2945 | |
| 2946 | if (this._options.progressBarAdditionalClass) { |
| 2947 | progressBar.className += " " + this._options.progressBarAdditionalClass; |
| 2948 | } |
| 2949 | |
| 2950 | progressBar.setAttribute("role", "progress"); |
| 2951 | progressBar.setAttribute("aria-valuemin", 0); |
| 2952 | progressBar.setAttribute("aria-valuemax", 100); |
| 2953 | progressBar.setAttribute("aria-valuenow", _getProgress.call(this)); |
| 2954 | progressBar.style.cssText = "width:".concat(_getProgress.call(this), "%;"); |
| 2955 | progressLayer.appendChild(progressBar); |
| 2956 | return progressLayer; |
| 2957 | } |
| 2958 | /** |
| 2959 | * Updates an existing progress bar variables |
| 2960 | * @param oldReferenceLayer |
| 2961 | * @private |
| 2962 | */ |
| 2963 | |
| 2964 | |
| 2965 | function _updateProgressBar(oldReferenceLayer) { |
| 2966 | oldReferenceLayer.querySelector(".introjs-progress .introjs-progressbar").style.cssText = "width:".concat(_getProgress.call(this), "%;"); |
| 2967 | oldReferenceLayer.querySelector(".introjs-progress .introjs-progressbar").setAttribute("aria-valuenow", _getProgress.call(this)); |
| 2968 | } |
| 2969 | /** |
| 2970 | * Show an element on the page |
| 2971 | * |
| 2972 | * @api private |
| 2973 | * @method _showElement |
| 2974 | * @param {Object} targetElement |
| 2975 | */ |
| 2976 | |
| 2977 | function _showElement(targetElement) { |
| 2978 | var _this = this; |
| 2979 | |
| 2980 | if (typeof this._introChangeCallback !== "undefined") { |
| 2981 | this._introChangeCallback.call(this, targetElement.element); |
| 2982 | } |
| 2983 | |
| 2984 | var self = this; |
| 2985 | var oldHelperLayer = document.querySelector(".introjs-helperLayer"); |
| 2986 | var oldReferenceLayer = document.querySelector(".introjs-tooltipReferenceLayer"); |
| 2987 | var highlightClass = "introjs-helperLayer"; |
| 2988 | var nextTooltipButton; |
| 2989 | var prevTooltipButton; |
| 2990 | var skipTooltipButton; //check for a current step highlight class |
| 2991 | |
| 2992 | if (typeof targetElement.highlightClass === "string") { |
| 2993 | highlightClass += " ".concat(targetElement.highlightClass); |
| 2994 | } //check for options highlight class |
| 2995 | |
| 2996 | |
| 2997 | if (typeof this._options.highlightClass === "string") { |
| 2998 | highlightClass += " ".concat(this._options.highlightClass); |
| 2999 | } |
| 3000 | |
| 3001 | if (oldHelperLayer !== null && oldReferenceLayer !== null) { |
| 3002 | var oldHelperNumberLayer = oldReferenceLayer.querySelector(".introjs-helperNumberLayer"); |
| 3003 | var oldtooltipLayer = oldReferenceLayer.querySelector(".introjs-tooltiptext"); |
| 3004 | var oldTooltipTitleLayer = oldReferenceLayer.querySelector(".introjs-tooltip-title"); |
| 3005 | var oldArrowLayer = oldReferenceLayer.querySelector(".introjs-arrow"); |
| 3006 | var oldtooltipContainer = oldReferenceLayer.querySelector(".introjs-tooltip"); |
| 3007 | skipTooltipButton = oldReferenceLayer.querySelector(".introjs-skipbutton"); |
| 3008 | prevTooltipButton = oldReferenceLayer.querySelector(".introjs-prevbutton"); |
| 3009 | nextTooltipButton = oldReferenceLayer.querySelector(".introjs-nextbutton"); //update or reset the helper highlight class |
| 3010 | |
| 3011 | oldHelperLayer.className = highlightClass; //hide the tooltip |
| 3012 | |
| 3013 | oldtooltipContainer.style.opacity = 0; |
| 3014 | oldtooltipContainer.style.display = "none"; // if the target element is within a scrollable element |
| 3015 | |
| 3016 | scrollParentToElement.call(self, targetElement); // set new position to helper layer |
| 3017 | |
| 3018 | setHelperLayerPosition.call(self, oldHelperLayer); |
| 3019 | setHelperLayerPosition.call(self, oldReferenceLayer); //remove old classes if the element still exist |
| 3020 | |
| 3021 | removeShowElement(); //we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation |
| 3022 | |
| 3023 | if (self._lastShowElementTimer) { |
| 3024 | window.clearTimeout(self._lastShowElementTimer); |
| 3025 | } |
| 3026 | |
| 3027 | self._lastShowElementTimer = window.setTimeout(function () { |
| 3028 | // set current step to the label |
| 3029 | if (oldHelperNumberLayer !== null) { |
| 3030 | oldHelperNumberLayer.innerHTML = "".concat(targetElement.step, " of ").concat(_this._introItems.length); |
| 3031 | } // set current tooltip text |
| 3032 | |
| 3033 | |
| 3034 | oldtooltipLayer.innerHTML = targetElement.intro; // set current tooltip title |
| 3035 | |
| 3036 | oldTooltipTitleLayer.innerHTML = targetElement.title; //set the tooltip position |
| 3037 | |
| 3038 | oldtooltipContainer.style.display = "block"; |
| 3039 | placeTooltip.call(self, targetElement.element, oldtooltipContainer, oldArrowLayer); //change active bullet |
| 3040 | |
| 3041 | _updateBullets.call(self, oldReferenceLayer, targetElement); |
| 3042 | |
| 3043 | _updateProgressBar.call(self, oldReferenceLayer); //show the tooltip |
| 3044 | |
| 3045 | |
| 3046 | oldtooltipContainer.style.opacity = 1; //reset button focus |
| 3047 | |
| 3048 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null && /introjs-donebutton/gi.test(nextTooltipButton.className)) { |
| 3049 | // skip button is now "done" button |
| 3050 | nextTooltipButton.focus(); |
| 3051 | } else if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3052 | //still in the tour, focus on next |
| 3053 | nextTooltipButton.focus(); |
| 3054 | } // change the scroll of the window, if needed |
| 3055 | |
| 3056 | |
| 3057 | scrollTo.call(self, targetElement.scrollTo, targetElement, oldtooltipLayer); |
| 3058 | }, 350); // end of old element if-else condition |
| 3059 | } else { |
| 3060 | var helperLayer = _createElement("div", { |
| 3061 | className: highlightClass |
| 3062 | }); |
| 3063 | var referenceLayer = _createElement("div", { |
| 3064 | className: "introjs-tooltipReferenceLayer" |
| 3065 | }); |
| 3066 | var arrowLayer = _createElement("div", { |
| 3067 | className: "introjs-arrow" |
| 3068 | }); |
| 3069 | var tooltipLayer = _createElement("div", { |
| 3070 | className: "introjs-tooltip" |
| 3071 | }); |
| 3072 | var tooltipTextLayer = _createElement("div", { |
| 3073 | className: "introjs-tooltiptext" |
| 3074 | }); |
| 3075 | var tooltipHeaderLayer = _createElement("div", { |
| 3076 | className: "introjs-tooltip-header" |
| 3077 | }); |
| 3078 | var tooltipTitleLayer = _createElement("h1", { |
| 3079 | className: "introjs-tooltip-title" |
| 3080 | }); |
| 3081 | var buttonsLayer = _createElement("div"); |
| 3082 | setStyle(helperLayer, { |
| 3083 | "box-shadow": "0 0 1px 2px rgba(33, 33, 33, 0.8), rgba(33, 33, 33, ".concat(self._options.overlayOpacity.toString(), ") 0 0 0 5000px") |
| 3084 | }); // target is within a scrollable element |
| 3085 | |
| 3086 | scrollParentToElement.call(self, targetElement); //set new position to helper layer |
| 3087 | |
| 3088 | setHelperLayerPosition.call(self, helperLayer); |
| 3089 | setHelperLayerPosition.call(self, referenceLayer); //add helper layer to target element |
| 3090 | |
| 3091 | appendChild(this._targetElement, helperLayer, true); |
| 3092 | appendChild(this._targetElement, referenceLayer); |
| 3093 | tooltipTextLayer.innerHTML = targetElement.intro; |
| 3094 | tooltipTitleLayer.innerHTML = targetElement.title; |
| 3095 | buttonsLayer.className = "introjs-tooltipbuttons"; |
| 3096 | |
| 3097 | if (this._options.showButtons === false) { |
| 3098 | buttonsLayer.style.display = "none"; |
| 3099 | } |
| 3100 | |
| 3101 | tooltipHeaderLayer.appendChild(tooltipTitleLayer); |
| 3102 | tooltipLayer.appendChild(tooltipHeaderLayer); |
| 3103 | tooltipLayer.appendChild(tooltipTextLayer); |
| 3104 | tooltipLayer.appendChild(_createBullets.call(this, targetElement)); |
| 3105 | tooltipLayer.appendChild(_createProgressBar.call(this)); // add helper layer number |
| 3106 | |
| 3107 | var helperNumberLayer = _createElement("div"); |
| 3108 | |
| 3109 | if (this._options.showStepNumbers === true) { |
| 3110 | helperNumberLayer.className = "introjs-helperNumberLayer"; |
| 3111 | helperNumberLayer.innerHTML = "".concat(targetElement.step, " of ").concat(this._introItems.length); |
| 3112 | tooltipLayer.appendChild(helperNumberLayer); |
| 3113 | } |
| 3114 | |
| 3115 | tooltipLayer.appendChild(arrowLayer); |
| 3116 | referenceLayer.appendChild(tooltipLayer); //next button |
| 3117 | |
| 3118 | nextTooltipButton = _createElement("a"); |
| 3119 | |
| 3120 | nextTooltipButton.onclick = function () { |
| 3121 | if (self._introItems.length - 1 !== self._currentStep) { |
| 3122 | nextStep.call(self); |
| 3123 | } else if (/introjs-donebutton/gi.test(nextTooltipButton.className)) { |
| 3124 | if (typeof self._introCompleteCallback === "function") { |
| 3125 | self._introCompleteCallback.call(self); |
| 3126 | } |
| 3127 | |
| 3128 | exitIntro.call(self, self._targetElement); |
| 3129 | } |
| 3130 | }; |
| 3131 | |
| 3132 | setAnchorAsButton(nextTooltipButton); |
| 3133 | nextTooltipButton.innerHTML = this._options.nextLabel; //previous button |
| 3134 | |
| 3135 | prevTooltipButton = _createElement("a"); |
| 3136 | |
| 3137 | prevTooltipButton.onclick = function () { |
| 3138 | if (self._currentStep !== 0) { |
| 3139 | previousStep.call(self); |
| 3140 | } |
| 3141 | }; |
| 3142 | |
| 3143 | setAnchorAsButton(prevTooltipButton); |
| 3144 | prevTooltipButton.innerHTML = this._options.prevLabel; //skip button |
| 3145 | |
| 3146 | skipTooltipButton = _createElement("a", { |
| 3147 | className: "introjs-skipbutton" |
| 3148 | }); |
| 3149 | setAnchorAsButton(skipTooltipButton); |
| 3150 | skipTooltipButton.innerHTML = this._options.skipLabel; |
| 3151 | |
| 3152 | skipTooltipButton.onclick = function () { |
| 3153 | if (self._introItems.length - 1 === self._currentStep && typeof self._introCompleteCallback === "function") { |
| 3154 | self._introCompleteCallback.call(self); |
| 3155 | } |
| 3156 | |
| 3157 | if (typeof self._introSkipCallback === "function") { |
| 3158 | self._introSkipCallback.call(self); |
| 3159 | } |
| 3160 | |
| 3161 | exitIntro.call(self, self._targetElement); |
| 3162 | }; |
| 3163 | |
| 3164 | tooltipHeaderLayer.appendChild(skipTooltipButton); //in order to prevent displaying previous button always |
| 3165 | |
| 3166 | if (this._introItems.length > 1) { |
| 3167 | buttonsLayer.appendChild(prevTooltipButton); |
| 3168 | } // we always need the next button because this |
| 3169 | // button changes to "Done" in the last step of the tour |
| 3170 | |
| 3171 | |
| 3172 | buttonsLayer.appendChild(nextTooltipButton); |
| 3173 | tooltipLayer.appendChild(buttonsLayer); //set proper position |
| 3174 | |
| 3175 | placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer); // change the scroll of the window, if needed |
| 3176 | |
| 3177 | scrollTo.call(this, targetElement.scrollTo, targetElement, tooltipLayer); //end of new element if-else condition |
| 3178 | } // removing previous disable interaction layer |
| 3179 | |
| 3180 | |
| 3181 | var disableInteractionLayer = self._targetElement.querySelector(".introjs-disableInteraction"); |
| 3182 | |
| 3183 | if (disableInteractionLayer) { |
| 3184 | disableInteractionLayer.parentNode.removeChild(disableInteractionLayer); |
| 3185 | } //disable interaction |
| 3186 | |
| 3187 | |
| 3188 | if (targetElement.disableInteraction) { |
| 3189 | _disableInteraction.call(self); |
| 3190 | } // when it's the first step of tour |
| 3191 | |
| 3192 | |
| 3193 | if (this._currentStep === 0 && this._introItems.length > 1) { |
| 3194 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3195 | nextTooltipButton.className = "".concat(this._options.buttonClass, " introjs-nextbutton"); |
| 3196 | nextTooltipButton.innerHTML = this._options.nextLabel; |
| 3197 | } |
| 3198 | |
| 3199 | if (this._options.hidePrev === true) { |
| 3200 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3201 | prevTooltipButton.className = "".concat(this._options.buttonClass, " introjs-prevbutton introjs-hidden"); |
| 3202 | } |
| 3203 | |
| 3204 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3205 | addClass(nextTooltipButton, "introjs-fullbutton"); |
| 3206 | } |
| 3207 | } else { |
| 3208 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3209 | prevTooltipButton.className = "".concat(this._options.buttonClass, " introjs-prevbutton introjs-disabled"); |
| 3210 | } |
| 3211 | } |
| 3212 | } else if (this._introItems.length - 1 === this._currentStep || this._introItems.length === 1) { |
| 3213 | // last step of tour |
| 3214 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3215 | prevTooltipButton.className = "".concat(this._options.buttonClass, " introjs-prevbutton"); |
| 3216 | } |
| 3217 | |
| 3218 | if (this._options.hideNext === true) { |
| 3219 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3220 | nextTooltipButton.className = "".concat(this._options.buttonClass, " introjs-nextbutton introjs-hidden"); |
| 3221 | } |
| 3222 | |
| 3223 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3224 | addClass(prevTooltipButton, "introjs-fullbutton"); |
| 3225 | } |
| 3226 | } else { |
| 3227 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3228 | if (this._options.nextToDone === true) { |
| 3229 | nextTooltipButton.innerHTML = this._options.doneLabel; |
| 3230 | addClass(nextTooltipButton, "".concat(this._options.buttonClass, " introjs-nextbutton introjs-donebutton")); |
| 3231 | } else { |
| 3232 | nextTooltipButton.className = "".concat(this._options.buttonClass, " introjs-nextbutton introjs-disabled"); |
| 3233 | } |
| 3234 | } |
| 3235 | } |
| 3236 | } else { |
| 3237 | // steps between start and end |
| 3238 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3239 | prevTooltipButton.className = "".concat(this._options.buttonClass, " introjs-prevbutton"); |
| 3240 | } |
| 3241 | |
| 3242 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3243 | nextTooltipButton.className = "".concat(this._options.buttonClass, " introjs-nextbutton"); |
| 3244 | nextTooltipButton.innerHTML = this._options.nextLabel; |
| 3245 | } |
| 3246 | } |
| 3247 | |
| 3248 | if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) { |
| 3249 | prevTooltipButton.setAttribute("role", "button"); |
| 3250 | } |
| 3251 | |
| 3252 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3253 | nextTooltipButton.setAttribute("role", "button"); |
| 3254 | } |
| 3255 | |
| 3256 | if (typeof skipTooltipButton !== "undefined" && skipTooltipButton !== null) { |
| 3257 | skipTooltipButton.setAttribute("role", "button"); |
| 3258 | } //Set focus on "next" button, so that hitting Enter always moves you onto the next step |
| 3259 | |
| 3260 | |
| 3261 | if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) { |
| 3262 | nextTooltipButton.focus(); |
| 3263 | } |
| 3264 | |
| 3265 | setShowElement(targetElement); |
| 3266 | |
| 3267 | if (typeof this._introAfterChangeCallback !== "undefined") { |
| 3268 | this._introAfterChangeCallback.call(this, targetElement.element); |
| 3269 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 3270 | } |
| 3271 | |
| 3272 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 3273 | * Go to specific step of introduction |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 3274 | * |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 3275 | * @api private |
| 3276 | * @method _goToStep |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 3277 | */ |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 3278 | |
| 3279 | function goToStep(step) { |
| 3280 | //because steps starts with zero |
| 3281 | this._currentStep = step - 2; |
| 3282 | |
| 3283 | if (typeof this._introItems !== "undefined") { |
| 3284 | nextStep.call(this); |
| 3285 | } |
| 3286 | } |
| 3287 | /** |
| 3288 | * Go to the specific step of introduction with the explicit [data-step] number |
| 3289 | * |
| 3290 | * @api private |
| 3291 | * @method _goToStepNumber |
| 3292 | */ |
| 3293 | |
| 3294 | function goToStepNumber(step) { |
| 3295 | this._currentStepNumber = step; |
| 3296 | |
| 3297 | if (typeof this._introItems !== "undefined") { |
| 3298 | nextStep.call(this); |
| 3299 | } |
| 3300 | } |
| 3301 | /** |
| 3302 | * Go to next step on intro |
| 3303 | * |
| 3304 | * @api private |
| 3305 | * @method _nextStep |
| 3306 | */ |
| 3307 | |
| 3308 | function nextStep() { |
| 3309 | var _this = this; |
| 3310 | |
| 3311 | this._direction = "forward"; |
| 3312 | |
| 3313 | if (typeof this._currentStepNumber !== "undefined") { |
| 3314 | forEach(this._introItems, function (_ref, i) { |
| 3315 | var step = _ref.step; |
| 3316 | |
| 3317 | if (step === _this._currentStepNumber) { |
| 3318 | _this._currentStep = i - 1; |
| 3319 | _this._currentStepNumber = undefined; |
| 3320 | } |
| 3321 | }); |
| 3322 | } |
| 3323 | |
| 3324 | if (typeof this._currentStep === "undefined") { |
| 3325 | this._currentStep = 0; |
| 3326 | } else { |
| 3327 | ++this._currentStep; |
| 3328 | } |
| 3329 | |
| 3330 | var nextStep = this._introItems[this._currentStep]; |
| 3331 | var continueStep = true; |
| 3332 | |
| 3333 | if (typeof this._introBeforeChangeCallback !== "undefined") { |
| 3334 | continueStep = this._introBeforeChangeCallback.call(this, nextStep && nextStep.element); |
| 3335 | } // if `onbeforechange` returned `false`, stop displaying the element |
| 3336 | |
| 3337 | |
| 3338 | if (continueStep === false) { |
| 3339 | --this._currentStep; |
| 3340 | return false; |
| 3341 | } |
| 3342 | |
| 3343 | if (this._introItems.length <= this._currentStep) { |
| 3344 | //end of the intro |
| 3345 | //check if any callback is defined |
| 3346 | if (typeof this._introCompleteCallback === "function") { |
| 3347 | this._introCompleteCallback.call(this); |
| 3348 | } |
| 3349 | |
| 3350 | exitIntro.call(this, this._targetElement); |
| 3351 | return; |
| 3352 | } |
| 3353 | |
| 3354 | _showElement.call(this, nextStep); |
| 3355 | } |
| 3356 | /** |
| 3357 | * Go to previous step on intro |
| 3358 | * |
| 3359 | * @api private |
| 3360 | * @method _previousStep |
| 3361 | */ |
| 3362 | |
| 3363 | function previousStep() { |
| 3364 | this._direction = "backward"; |
| 3365 | |
| 3366 | if (this._currentStep === 0) { |
| 3367 | return false; |
| 3368 | } |
| 3369 | |
| 3370 | --this._currentStep; |
| 3371 | var nextStep = this._introItems[this._currentStep]; |
| 3372 | var continueStep = true; |
| 3373 | |
| 3374 | if (typeof this._introBeforeChangeCallback !== "undefined") { |
| 3375 | continueStep = this._introBeforeChangeCallback.call(this, nextStep && nextStep.element); |
| 3376 | } // if `onbeforechange` returned `false`, stop displaying the element |
| 3377 | |
| 3378 | |
| 3379 | if (continueStep === false) { |
| 3380 | ++this._currentStep; |
| 3381 | return false; |
| 3382 | } |
| 3383 | |
| 3384 | _showElement.call(this, nextStep); |
| 3385 | } |
| 3386 | /** |
| 3387 | * Returns the current step of the intro |
| 3388 | * |
| 3389 | * @returns {number | boolean} |
| 3390 | */ |
| 3391 | |
| 3392 | function currentStep() { |
| 3393 | return this._currentStep; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 3394 | } |
| 3395 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 3396 | /** |
| 3397 | * on keyCode: |
| 3398 | * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode |
| 3399 | * This feature has been removed from the Web standards. |
| 3400 | * Though some browsers may still support it, it is in |
| 3401 | * the process of being dropped. |
| 3402 | * Instead, you should use KeyboardEvent.code, |
| 3403 | * if it's implemented. |
| 3404 | * |
| 3405 | * jQuery's approach is to test for |
| 3406 | * (1) e.which, then |
| 3407 | * (2) e.charCode, then |
| 3408 | * (3) e.keyCode |
| 3409 | * https://github.com/jquery/jquery/blob/a6b0705294d336ae2f63f7276de0da1195495363/src/event.js#L638 |
| 3410 | * |
| 3411 | * @param type var |
| 3412 | * @return type |
| 3413 | */ |
| 3414 | |
| 3415 | function onKeyDown(e) { |
| 3416 | var code = e.code === undefined ? e.which : e.code; // if e.which is null |
| 3417 | |
| 3418 | if (code === null) { |
| 3419 | code = e.charCode === null ? e.keyCode : e.charCode; |
| 3420 | } |
| 3421 | |
| 3422 | if ((code === "Escape" || code === 27) && this._options.exitOnEsc === true) { |
| 3423 | //escape key pressed, exit the intro |
| 3424 | //check if exit callback is defined |
| 3425 | exitIntro.call(this, this._targetElement); |
| 3426 | } else if (code === "ArrowLeft" || code === 37) { |
| 3427 | //left arrow |
| 3428 | previousStep.call(this); |
| 3429 | } else if (code === "ArrowRight" || code === 39) { |
| 3430 | //right arrow |
| 3431 | nextStep.call(this); |
| 3432 | } else if (code === "Enter" || code === "NumpadEnter" || code === 13) { |
| 3433 | //srcElement === ie |
| 3434 | var target = e.target || e.srcElement; |
| 3435 | |
| 3436 | if (target && target.className.match("introjs-prevbutton")) { |
| 3437 | //user hit enter while focusing on previous button |
| 3438 | previousStep.call(this); |
| 3439 | } else if (target && target.className.match("introjs-skipbutton")) { |
| 3440 | //user hit enter while focusing on skip button |
| 3441 | if (this._introItems.length - 1 === this._currentStep && typeof this._introCompleteCallback === "function") { |
| 3442 | this._introCompleteCallback.call(this); |
| 3443 | } |
| 3444 | |
| 3445 | exitIntro.call(this, this._targetElement); |
| 3446 | } else if (target && target.getAttribute("data-stepnumber")) { |
| 3447 | // user hit enter while focusing on step bullet |
| 3448 | target.click(); |
| 3449 | } else { |
| 3450 | //default behavior for responding to enter |
| 3451 | nextStep.call(this); |
| 3452 | } //prevent default behaviour on hitting Enter, to prevent steps being skipped in some browsers |
| 3453 | |
| 3454 | |
| 3455 | if (e.preventDefault) { |
| 3456 | e.preventDefault(); |
| 3457 | } else { |
| 3458 | e.returnValue = false; |
| 3459 | } |
| 3460 | } |
| 3461 | } |
| 3462 | |
| 3463 | /* |
| 3464 | * makes a copy of the object |
| 3465 | * @api private |
| 3466 | * @method _cloneObject |
| 3467 | */ |
| 3468 | function cloneObject(object) { |
| 3469 | if (object === null || _typeof(object) !== "object" || typeof object.nodeType !== "undefined") { |
| 3470 | return object; |
| 3471 | } |
| 3472 | |
| 3473 | var temp = {}; |
| 3474 | |
| 3475 | for (var key in object) { |
| 3476 | if (typeof window.jQuery !== "undefined" && object[key] instanceof window.jQuery) { |
| 3477 | temp[key] = object[key]; |
| 3478 | } else { |
| 3479 | temp[key] = cloneObject(object[key]); |
| 3480 | } |
| 3481 | } |
| 3482 | |
| 3483 | return temp; |
| 3484 | } |
| 3485 | |
| 3486 | /** |
| 3487 | * Get a queryselector within the hint wrapper |
| 3488 | * |
| 3489 | * @param {String} selector |
| 3490 | * @return {NodeList|Array} |
| 3491 | */ |
| 3492 | |
| 3493 | function hintQuerySelectorAll(selector) { |
| 3494 | var hintsWrapper = document.querySelector(".introjs-hints"); |
| 3495 | return hintsWrapper ? hintsWrapper.querySelectorAll(selector) : []; |
| 3496 | } |
| 3497 | /** |
| 3498 | * Hide a hint |
| 3499 | * |
| 3500 | * @api private |
| 3501 | * @method hideHint |
| 3502 | */ |
| 3503 | |
| 3504 | function hideHint(stepId) { |
| 3505 | var hint = hintQuerySelectorAll(".introjs-hint[data-step=\"".concat(stepId, "\"]"))[0]; |
| 3506 | removeHintTooltip.call(this); |
| 3507 | |
| 3508 | if (hint) { |
| 3509 | addClass(hint, "introjs-hidehint"); |
| 3510 | } // call the callback function (if any) |
| 3511 | |
| 3512 | |
| 3513 | if (typeof this._hintCloseCallback !== "undefined") { |
| 3514 | this._hintCloseCallback.call(this, stepId); |
| 3515 | } |
| 3516 | } |
| 3517 | /** |
| 3518 | * Hide all hints |
| 3519 | * |
| 3520 | * @api private |
| 3521 | * @method hideHints |
| 3522 | */ |
| 3523 | |
| 3524 | function hideHints() { |
| 3525 | var _this = this; |
| 3526 | |
| 3527 | var hints = hintQuerySelectorAll(".introjs-hint"); |
| 3528 | forEach(hints, function (hint) { |
| 3529 | hideHint.call(_this, hint.getAttribute("data-step")); |
| 3530 | }); |
| 3531 | } |
| 3532 | /** |
| 3533 | * Show all hints |
| 3534 | * |
| 3535 | * @api private |
| 3536 | * @method _showHints |
| 3537 | */ |
| 3538 | |
| 3539 | function showHints() { |
| 3540 | var _this2 = this; |
| 3541 | |
| 3542 | var hints = hintQuerySelectorAll(".introjs-hint"); |
| 3543 | |
| 3544 | if (hints && hints.length) { |
| 3545 | forEach(hints, function (hint) { |
| 3546 | showHint.call(_this2, hint.getAttribute("data-step")); |
| 3547 | }); |
| 3548 | } else { |
| 3549 | populateHints.call(this, this._targetElement); |
| 3550 | } |
| 3551 | } |
| 3552 | /** |
| 3553 | * Show a hint |
| 3554 | * |
| 3555 | * @api private |
| 3556 | * @method showHint |
| 3557 | */ |
| 3558 | |
| 3559 | function showHint(stepId) { |
| 3560 | var hint = hintQuerySelectorAll(".introjs-hint[data-step=\"".concat(stepId, "\"]"))[0]; |
| 3561 | |
| 3562 | if (hint) { |
| 3563 | removeClass(hint, /introjs-hidehint/g); |
| 3564 | } |
| 3565 | } |
| 3566 | /** |
| 3567 | * Removes all hint elements on the page |
| 3568 | * Useful when you want to destroy the elements and add them again (e.g. a modal or popup) |
| 3569 | * |
| 3570 | * @api private |
| 3571 | * @method removeHints |
| 3572 | */ |
| 3573 | |
| 3574 | function removeHints() { |
| 3575 | var _this3 = this; |
| 3576 | |
| 3577 | var hints = hintQuerySelectorAll(".introjs-hint"); |
| 3578 | forEach(hints, function (hint) { |
| 3579 | removeHint.call(_this3, hint.getAttribute("data-step")); |
| 3580 | }); |
| 3581 | } |
| 3582 | /** |
| 3583 | * Remove one single hint element from the page |
| 3584 | * Useful when you want to destroy the element and add them again (e.g. a modal or popup) |
| 3585 | * Use removeHints if you want to remove all elements. |
| 3586 | * |
| 3587 | * @api private |
| 3588 | * @method removeHint |
| 3589 | */ |
| 3590 | |
| 3591 | function removeHint(stepId) { |
| 3592 | var hint = hintQuerySelectorAll(".introjs-hint[data-step=\"".concat(stepId, "\"]"))[0]; |
| 3593 | |
| 3594 | if (hint) { |
| 3595 | hint.parentNode.removeChild(hint); |
| 3596 | } |
| 3597 | } |
| 3598 | /** |
| 3599 | * Add all available hints to the page |
| 3600 | * |
| 3601 | * @api private |
| 3602 | * @method addHints |
| 3603 | */ |
| 3604 | |
| 3605 | function addHints() { |
| 3606 | var _this4 = this; |
| 3607 | |
| 3608 | var self = this; |
| 3609 | var hintsWrapper = document.querySelector(".introjs-hints"); |
| 3610 | |
| 3611 | if (hintsWrapper === null) { |
| 3612 | hintsWrapper = _createElement("div", { |
| 3613 | className: "introjs-hints" |
| 3614 | }); |
| 3615 | } |
| 3616 | /** |
| 3617 | * Returns an event handler unique to the hint iteration |
| 3618 | * |
| 3619 | * @param {Integer} i |
| 3620 | * @return {Function} |
| 3621 | */ |
| 3622 | |
| 3623 | |
| 3624 | var getHintClick = function getHintClick(i) { |
| 3625 | return function (e) { |
| 3626 | var evt = e ? e : window.event; |
| 3627 | |
| 3628 | if (evt.stopPropagation) { |
| 3629 | evt.stopPropagation(); |
| 3630 | } |
| 3631 | |
| 3632 | if (evt.cancelBubble !== null) { |
| 3633 | evt.cancelBubble = true; |
| 3634 | } |
| 3635 | |
| 3636 | showHintDialog.call(self, i); |
| 3637 | }; |
| 3638 | }; |
| 3639 | |
| 3640 | forEach(this._introItems, function (item, i) { |
| 3641 | // avoid append a hint twice |
| 3642 | if (document.querySelector(".introjs-hint[data-step=\"".concat(i, "\"]"))) { |
| 3643 | return; |
| 3644 | } |
| 3645 | |
| 3646 | var hint = _createElement("a", { |
| 3647 | className: "introjs-hint" |
| 3648 | }); |
| 3649 | setAnchorAsButton(hint); |
| 3650 | hint.onclick = getHintClick(i); |
| 3651 | |
| 3652 | if (!item.hintAnimation) { |
| 3653 | addClass(hint, "introjs-hint-no-anim"); |
| 3654 | } // hint's position should be fixed if the target element's position is fixed |
| 3655 | |
| 3656 | |
| 3657 | if (isFixed(item.element)) { |
| 3658 | addClass(hint, "introjs-fixedhint"); |
| 3659 | } |
| 3660 | |
| 3661 | var hintDot = _createElement("div", { |
| 3662 | className: "introjs-hint-dot" |
| 3663 | }); |
| 3664 | var hintPulse = _createElement("div", { |
| 3665 | className: "introjs-hint-pulse" |
| 3666 | }); |
| 3667 | hint.appendChild(hintDot); |
| 3668 | hint.appendChild(hintPulse); |
| 3669 | hint.setAttribute("data-step", i); // we swap the hint element with target element |
| 3670 | // because _setHelperLayerPosition uses `element` property |
| 3671 | |
| 3672 | item.targetElement = item.element; |
| 3673 | item.element = hint; // align the hint position |
| 3674 | |
| 3675 | alignHintPosition.call(_this4, item.hintPosition, hint, item.targetElement); |
| 3676 | hintsWrapper.appendChild(hint); |
| 3677 | }); // adding the hints wrapper |
| 3678 | |
| 3679 | document.body.appendChild(hintsWrapper); // call the callback function (if any) |
| 3680 | |
| 3681 | if (typeof this._hintsAddedCallback !== "undefined") { |
| 3682 | this._hintsAddedCallback.call(this); |
| 3683 | } |
| 3684 | } |
| 3685 | /** |
| 3686 | * Aligns hint position |
| 3687 | * |
| 3688 | * @api private |
| 3689 | * @method alignHintPosition |
| 3690 | * @param {String} position |
| 3691 | * @param {Object} hint |
| 3692 | * @param {Object} element |
| 3693 | */ |
| 3694 | |
| 3695 | function alignHintPosition(position, _ref, element) { |
| 3696 | var style = _ref.style; |
| 3697 | // get/calculate offset of target element |
| 3698 | var offset = getOffset.call(this, element); |
| 3699 | var iconWidth = 20; |
| 3700 | var iconHeight = 20; // align the hint element |
| 3701 | |
| 3702 | switch (position) { |
| 3703 | default: |
| 3704 | case "top-left": |
| 3705 | style.left = "".concat(offset.left, "px"); |
| 3706 | style.top = "".concat(offset.top, "px"); |
| 3707 | break; |
| 3708 | |
| 3709 | case "top-right": |
| 3710 | style.left = "".concat(offset.left + offset.width - iconWidth, "px"); |
| 3711 | style.top = "".concat(offset.top, "px"); |
| 3712 | break; |
| 3713 | |
| 3714 | case "bottom-left": |
| 3715 | style.left = "".concat(offset.left, "px"); |
| 3716 | style.top = "".concat(offset.top + offset.height - iconHeight, "px"); |
| 3717 | break; |
| 3718 | |
| 3719 | case "bottom-right": |
| 3720 | style.left = "".concat(offset.left + offset.width - iconWidth, "px"); |
| 3721 | style.top = "".concat(offset.top + offset.height - iconHeight, "px"); |
| 3722 | break; |
| 3723 | |
| 3724 | case "middle-left": |
| 3725 | style.left = "".concat(offset.left, "px"); |
| 3726 | style.top = "".concat(offset.top + (offset.height - iconHeight) / 2, "px"); |
| 3727 | break; |
| 3728 | |
| 3729 | case "middle-right": |
| 3730 | style.left = "".concat(offset.left + offset.width - iconWidth, "px"); |
| 3731 | style.top = "".concat(offset.top + (offset.height - iconHeight) / 2, "px"); |
| 3732 | break; |
| 3733 | |
| 3734 | case "middle-middle": |
| 3735 | style.left = "".concat(offset.left + (offset.width - iconWidth) / 2, "px"); |
| 3736 | style.top = "".concat(offset.top + (offset.height - iconHeight) / 2, "px"); |
| 3737 | break; |
| 3738 | |
| 3739 | case "bottom-middle": |
| 3740 | style.left = "".concat(offset.left + (offset.width - iconWidth) / 2, "px"); |
| 3741 | style.top = "".concat(offset.top + offset.height - iconHeight, "px"); |
| 3742 | break; |
| 3743 | |
| 3744 | case "top-middle": |
| 3745 | style.left = "".concat(offset.left + (offset.width - iconWidth) / 2, "px"); |
| 3746 | style.top = "".concat(offset.top, "px"); |
| 3747 | break; |
| 3748 | } |
| 3749 | } |
| 3750 | /** |
| 3751 | * Triggers when user clicks on the hint element |
| 3752 | * |
| 3753 | * @api private |
| 3754 | * @method _showHintDialog |
| 3755 | * @param {Number} stepId |
| 3756 | */ |
| 3757 | |
| 3758 | function showHintDialog(stepId) { |
| 3759 | var hintElement = document.querySelector(".introjs-hint[data-step=\"".concat(stepId, "\"]")); |
| 3760 | var item = this._introItems[stepId]; // call the callback function (if any) |
| 3761 | |
| 3762 | if (typeof this._hintClickCallback !== "undefined") { |
| 3763 | this._hintClickCallback.call(this, hintElement, item, stepId); |
| 3764 | } // remove all open tooltips |
| 3765 | |
| 3766 | |
| 3767 | var removedStep = removeHintTooltip.call(this); // to toggle the tooltip |
| 3768 | |
| 3769 | if (parseInt(removedStep, 10) === stepId) { |
| 3770 | return; |
| 3771 | } |
| 3772 | |
| 3773 | var tooltipLayer = _createElement("div", { |
| 3774 | className: "introjs-tooltip" |
| 3775 | }); |
| 3776 | var tooltipTextLayer = _createElement("div"); |
| 3777 | var arrowLayer = _createElement("div"); |
| 3778 | var referenceLayer = _createElement("div"); |
| 3779 | |
| 3780 | tooltipLayer.onclick = function (e) { |
| 3781 | //IE9 & Other Browsers |
| 3782 | if (e.stopPropagation) { |
| 3783 | e.stopPropagation(); |
| 3784 | } //IE8 and Lower |
| 3785 | else { |
| 3786 | e.cancelBubble = true; |
| 3787 | } |
| 3788 | }; |
| 3789 | |
| 3790 | tooltipTextLayer.className = "introjs-tooltiptext"; |
| 3791 | var tooltipWrapper = _createElement("p"); |
| 3792 | tooltipWrapper.innerHTML = item.hint; |
| 3793 | var closeButton = _createElement("a"); |
| 3794 | closeButton.className = this._options.buttonClass; |
| 3795 | closeButton.setAttribute("role", "button"); |
| 3796 | closeButton.innerHTML = this._options.hintButtonLabel; |
| 3797 | closeButton.onclick = hideHint.bind(this, stepId); |
| 3798 | tooltipTextLayer.appendChild(tooltipWrapper); |
| 3799 | tooltipTextLayer.appendChild(closeButton); |
| 3800 | arrowLayer.className = "introjs-arrow"; |
| 3801 | tooltipLayer.appendChild(arrowLayer); |
| 3802 | tooltipLayer.appendChild(tooltipTextLayer); // set current step for _placeTooltip function |
| 3803 | |
| 3804 | this._currentStep = hintElement.getAttribute("data-step"); // align reference layer position |
| 3805 | |
| 3806 | referenceLayer.className = "introjs-tooltipReferenceLayer introjs-hintReference"; |
| 3807 | referenceLayer.setAttribute("data-step", hintElement.getAttribute("data-step")); |
| 3808 | setHelperLayerPosition.call(this, referenceLayer); |
| 3809 | referenceLayer.appendChild(tooltipLayer); |
| 3810 | document.body.appendChild(referenceLayer); //set proper position |
| 3811 | |
| 3812 | placeTooltip.call(this, hintElement, tooltipLayer, arrowLayer, true); |
| 3813 | } |
| 3814 | /** |
| 3815 | * Removes open hint (tooltip hint) |
| 3816 | * |
| 3817 | * @api private |
| 3818 | * @method _removeHintTooltip |
| 3819 | */ |
| 3820 | |
| 3821 | function removeHintTooltip() { |
| 3822 | var tooltip = document.querySelector(".introjs-hintReference"); |
| 3823 | |
| 3824 | if (tooltip) { |
| 3825 | var step = tooltip.getAttribute("data-step"); |
| 3826 | tooltip.parentNode.removeChild(tooltip); |
| 3827 | return step; |
| 3828 | } |
| 3829 | } |
| 3830 | /** |
| 3831 | * Start parsing hint items |
| 3832 | * |
| 3833 | * @api private |
| 3834 | * @param {Object} targetElm |
| 3835 | * @method _startHint |
| 3836 | */ |
| 3837 | |
| 3838 | function populateHints(targetElm) { |
| 3839 | var _this5 = this; |
| 3840 | |
| 3841 | this._introItems = []; |
| 3842 | |
| 3843 | if (this._options.hints) { |
| 3844 | forEach(this._options.hints, function (hint) { |
| 3845 | var currentItem = cloneObject(hint); |
| 3846 | |
| 3847 | if (typeof currentItem.element === "string") { |
| 3848 | //grab the element with given selector from the page |
| 3849 | currentItem.element = document.querySelector(currentItem.element); |
| 3850 | } |
| 3851 | |
| 3852 | currentItem.hintPosition = currentItem.hintPosition || _this5._options.hintPosition; |
| 3853 | currentItem.hintAnimation = currentItem.hintAnimation || _this5._options.hintAnimation; |
| 3854 | |
| 3855 | if (currentItem.element !== null) { |
| 3856 | _this5._introItems.push(currentItem); |
| 3857 | } |
| 3858 | }); |
| 3859 | } else { |
| 3860 | var hints = targetElm.querySelectorAll("*[data-hint]"); |
| 3861 | |
| 3862 | if (!hints || !hints.length) { |
| 3863 | return false; |
| 3864 | } //first add intro items with data-step |
| 3865 | |
| 3866 | |
| 3867 | forEach(hints, function (currentElement) { |
| 3868 | // hint animation |
| 3869 | var hintAnimation = currentElement.getAttribute("data-hintanimation"); |
| 3870 | |
| 3871 | if (hintAnimation) { |
| 3872 | hintAnimation = hintAnimation === "true"; |
| 3873 | } else { |
| 3874 | hintAnimation = _this5._options.hintAnimation; |
| 3875 | } |
| 3876 | |
| 3877 | _this5._introItems.push({ |
| 3878 | element: currentElement, |
| 3879 | hint: currentElement.getAttribute("data-hint"), |
| 3880 | hintPosition: currentElement.getAttribute("data-hintposition") || _this5._options.hintPosition, |
| 3881 | hintAnimation: hintAnimation, |
| 3882 | tooltipClass: currentElement.getAttribute("data-tooltipclass"), |
| 3883 | position: currentElement.getAttribute("data-position") || _this5._options.tooltipPosition |
| 3884 | }); |
| 3885 | }); |
| 3886 | } |
| 3887 | |
| 3888 | addHints.call(this); |
| 3889 | /* |
| 3890 | todo: |
| 3891 | these events should be removed at some point |
| 3892 | */ |
| 3893 | |
| 3894 | DOMEvent.on(document, "click", removeHintTooltip, this, false); |
| 3895 | DOMEvent.on(window, "resize", reAlignHints, this, true); |
| 3896 | } |
| 3897 | /** |
| 3898 | * Re-aligns all hint elements |
| 3899 | * |
| 3900 | * @api private |
| 3901 | * @method _reAlignHints |
| 3902 | */ |
| 3903 | |
| 3904 | function reAlignHints() { |
| 3905 | var _this6 = this; |
| 3906 | |
| 3907 | forEach(this._introItems, function (_ref2) { |
| 3908 | var targetElement = _ref2.targetElement, |
| 3909 | hintPosition = _ref2.hintPosition, |
| 3910 | element = _ref2.element; |
| 3911 | |
| 3912 | if (typeof targetElement === "undefined") { |
| 3913 | return; |
| 3914 | } |
| 3915 | |
| 3916 | alignHintPosition.call(_this6, hintPosition, element, targetElement); |
| 3917 | }); |
| 3918 | } |
| 3919 | |
| 3920 | // TODO: use something more complex like timsort? |
| 3921 | var floor = Math.floor; |
| 3922 | |
| 3923 | var mergeSort = function (array, comparefn) { |
| 3924 | var length = array.length; |
| 3925 | var middle = floor(length / 2); |
| 3926 | return length < 8 ? insertionSort(array, comparefn) : merge( |
| 3927 | mergeSort(array.slice(0, middle), comparefn), |
| 3928 | mergeSort(array.slice(middle), comparefn), |
| 3929 | comparefn |
| 3930 | ); |
| 3931 | }; |
| 3932 | |
| 3933 | var insertionSort = function (array, comparefn) { |
| 3934 | var length = array.length; |
| 3935 | var i = 1; |
| 3936 | var element, j; |
| 3937 | |
| 3938 | while (i < length) { |
| 3939 | j = i; |
| 3940 | element = array[i]; |
| 3941 | while (j && comparefn(array[j - 1], element) > 0) { |
| 3942 | array[j] = array[--j]; |
| 3943 | } |
| 3944 | if (j !== i++) array[j] = element; |
| 3945 | } return array; |
| 3946 | }; |
| 3947 | |
| 3948 | var merge = function (left, right, comparefn) { |
| 3949 | var llength = left.length; |
| 3950 | var rlength = right.length; |
| 3951 | var lindex = 0; |
| 3952 | var rindex = 0; |
| 3953 | var result = []; |
| 3954 | |
| 3955 | while (lindex < llength || rindex < rlength) { |
| 3956 | if (lindex < llength && rindex < rlength) { |
| 3957 | result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]); |
| 3958 | } else { |
| 3959 | result.push(lindex < llength ? left[lindex++] : right[rindex++]); |
| 3960 | } |
| 3961 | } return result; |
| 3962 | }; |
| 3963 | |
| 3964 | var arraySort = mergeSort; |
| 3965 | |
| 3966 | var firefox = engineUserAgent.match(/firefox\/(\d+)/i); |
| 3967 | |
| 3968 | var engineFfVersion = !!firefox && +firefox[1]; |
| 3969 | |
| 3970 | var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); |
| 3971 | |
| 3972 | var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); |
| 3973 | |
| 3974 | var engineWebkitVersion = !!webkit && +webkit[1]; |
| 3975 | |
| 3976 | var test = []; |
| 3977 | var nativeSort = test.sort; |
| 3978 | |
| 3979 | // IE8- |
| 3980 | var FAILS_ON_UNDEFINED = fails(function () { |
| 3981 | test.sort(undefined); |
| 3982 | }); |
| 3983 | // V8 bug |
| 3984 | var FAILS_ON_NULL = fails(function () { |
| 3985 | test.sort(null); |
| 3986 | }); |
| 3987 | // Old WebKit |
| 3988 | var STRICT_METHOD = arrayMethodIsStrict('sort'); |
| 3989 | |
| 3990 | var STABLE_SORT = !fails(function () { |
| 3991 | // feature detection can be too slow, so check engines versions |
| 3992 | if (engineV8Version) return engineV8Version < 70; |
| 3993 | if (engineFfVersion && engineFfVersion > 3) return; |
| 3994 | if (engineIsIeOrEdge) return true; |
| 3995 | if (engineWebkitVersion) return engineWebkitVersion < 603; |
| 3996 | |
| 3997 | var result = ''; |
| 3998 | var code, chr, value, index; |
| 3999 | |
| 4000 | // generate an array with more 512 elements (Chakra and old V8 fails only in this case) |
| 4001 | for (code = 65; code < 76; code++) { |
| 4002 | chr = String.fromCharCode(code); |
| 4003 | |
| 4004 | switch (code) { |
| 4005 | case 66: case 69: case 70: case 72: value = 3; break; |
| 4006 | case 68: case 71: value = 4; break; |
| 4007 | default: value = 2; |
| 4008 | } |
| 4009 | |
| 4010 | for (index = 0; index < 47; index++) { |
| 4011 | test.push({ k: chr + index, v: value }); |
| 4012 | } |
| 4013 | } |
| 4014 | |
| 4015 | test.sort(function (a, b) { return b.v - a.v; }); |
| 4016 | |
| 4017 | for (index = 0; index < test.length; index++) { |
| 4018 | chr = test[index].k.charAt(0); |
| 4019 | if (result.charAt(result.length - 1) !== chr) result += chr; |
| 4020 | } |
| 4021 | |
| 4022 | return result !== 'DGBEFHACIJK'; |
| 4023 | }); |
| 4024 | |
| 4025 | var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT; |
| 4026 | |
| 4027 | var getSortCompare = function (comparefn) { |
| 4028 | return function (x, y) { |
| 4029 | if (y === undefined) return -1; |
| 4030 | if (x === undefined) return 1; |
| 4031 | if (comparefn !== undefined) return +comparefn(x, y) || 0; |
| 4032 | return toString_1(x) > toString_1(y) ? 1 : -1; |
| 4033 | }; |
| 4034 | }; |
| 4035 | |
| 4036 | // `Array.prototype.sort` method |
| 4037 | // https://tc39.es/ecma262/#sec-array.prototype.sort |
| 4038 | _export({ target: 'Array', proto: true, forced: FORCED }, { |
| 4039 | sort: function sort(comparefn) { |
| 4040 | if (comparefn !== undefined) aFunction(comparefn); |
| 4041 | |
| 4042 | var array = toObject(this); |
| 4043 | |
| 4044 | if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn); |
| 4045 | |
| 4046 | var items = []; |
| 4047 | var arrayLength = toLength(array.length); |
| 4048 | var itemsLength, index; |
| 4049 | |
| 4050 | for (index = 0; index < arrayLength; index++) { |
| 4051 | if (index in array) items.push(array[index]); |
| 4052 | } |
| 4053 | |
| 4054 | items = arraySort(items, getSortCompare(comparefn)); |
| 4055 | itemsLength = items.length; |
| 4056 | index = 0; |
| 4057 | |
| 4058 | while (index < itemsLength) array[index] = items[index++]; |
| 4059 | while (index < arrayLength) delete array[index++]; |
| 4060 | |
| 4061 | return array; |
| 4062 | } |
| 4063 | }); |
| 4064 | |
| 4065 | /** |
| 4066 | * Finds all Intro steps from the data-* attributes and the options.steps array |
| 4067 | * |
| 4068 | * @api private |
| 4069 | * @param targetElm |
| 4070 | * @returns {[]} |
| 4071 | */ |
| 4072 | |
| 4073 | function fetchIntroSteps(targetElm) { |
| 4074 | var _this = this; |
| 4075 | |
| 4076 | var allIntroSteps = targetElm.querySelectorAll("*[data-intro]"); |
| 4077 | var introItems = []; |
| 4078 | |
| 4079 | if (this._options.steps) { |
| 4080 | //use steps passed programmatically |
| 4081 | forEach(this._options.steps, function (step) { |
| 4082 | var currentItem = cloneObject(step); //set the step |
| 4083 | |
| 4084 | currentItem.step = introItems.length + 1; |
| 4085 | currentItem.title = currentItem.title || ""; //use querySelector function only when developer used CSS selector |
| 4086 | |
| 4087 | if (typeof currentItem.element === "string") { |
| 4088 | //grab the element with given selector from the page |
| 4089 | currentItem.element = document.querySelector(currentItem.element); |
| 4090 | } //intro without element |
| 4091 | |
| 4092 | |
| 4093 | if (typeof currentItem.element === "undefined" || currentItem.element === null) { |
| 4094 | var floatingElementQuery = document.querySelector(".introjsFloatingElement"); |
| 4095 | |
| 4096 | if (floatingElementQuery === null) { |
| 4097 | floatingElementQuery = _createElement("div", { |
| 4098 | className: "introjsFloatingElement" |
| 4099 | }); |
| 4100 | document.body.appendChild(floatingElementQuery); |
| 4101 | } |
| 4102 | |
| 4103 | currentItem.element = floatingElementQuery; |
| 4104 | currentItem.position = "floating"; |
| 4105 | } |
| 4106 | |
| 4107 | currentItem.position = currentItem.position || _this._options.tooltipPosition; |
| 4108 | currentItem.scrollTo = currentItem.scrollTo || _this._options.scrollTo; |
| 4109 | |
| 4110 | if (typeof currentItem.disableInteraction === "undefined") { |
| 4111 | currentItem.disableInteraction = _this._options.disableInteraction; |
| 4112 | } |
| 4113 | |
| 4114 | if (currentItem.element !== null) { |
| 4115 | introItems.push(currentItem); |
| 4116 | } |
| 4117 | }); |
| 4118 | } else { |
| 4119 | //use steps from data-* annotations |
| 4120 | var elmsLength = allIntroSteps.length; |
| 4121 | var disableInteraction; //if there's no element to intro |
| 4122 | |
| 4123 | if (elmsLength < 1) { |
| 4124 | return []; |
| 4125 | } |
| 4126 | |
| 4127 | forEach(allIntroSteps, function (currentElement) { |
| 4128 | // start intro for groups of elements |
| 4129 | if (_this._options.group && currentElement.getAttribute("data-intro-group") !== _this._options.group) { |
| 4130 | return; |
| 4131 | } // skip hidden elements |
| 4132 | |
| 4133 | |
| 4134 | if (currentElement.style.display === "none") { |
| 4135 | return; |
| 4136 | } |
| 4137 | |
| 4138 | var step = parseInt(currentElement.getAttribute("data-step"), 10); |
| 4139 | |
| 4140 | if (currentElement.hasAttribute("data-disable-interaction")) { |
| 4141 | disableInteraction = !!currentElement.getAttribute("data-disable-interaction"); |
| 4142 | } else { |
| 4143 | disableInteraction = _this._options.disableInteraction; |
| 4144 | } |
| 4145 | |
| 4146 | if (step > 0) { |
| 4147 | introItems[step - 1] = { |
| 4148 | element: currentElement, |
| 4149 | title: currentElement.getAttribute("data-title") || "", |
| 4150 | intro: currentElement.getAttribute("data-intro"), |
| 4151 | step: parseInt(currentElement.getAttribute("data-step"), 10), |
| 4152 | tooltipClass: currentElement.getAttribute("data-tooltipclass"), |
| 4153 | highlightClass: currentElement.getAttribute("data-highlightclass"), |
| 4154 | position: currentElement.getAttribute("data-position") || _this._options.tooltipPosition, |
| 4155 | scrollTo: currentElement.getAttribute("data-scrollto") || _this._options.scrollTo, |
| 4156 | disableInteraction: disableInteraction |
| 4157 | }; |
| 4158 | } |
| 4159 | }); //next add intro items without data-step |
| 4160 | //todo: we need a cleanup here, two loops are redundant |
| 4161 | |
| 4162 | var nextStep = 0; |
| 4163 | forEach(allIntroSteps, function (currentElement) { |
| 4164 | // start intro for groups of elements |
| 4165 | if (_this._options.group && currentElement.getAttribute("data-intro-group") !== _this._options.group) { |
| 4166 | return; |
| 4167 | } |
| 4168 | |
| 4169 | if (currentElement.getAttribute("data-step") === null) { |
| 4170 | while (true) { |
| 4171 | if (typeof introItems[nextStep] === "undefined") { |
| 4172 | break; |
| 4173 | } else { |
| 4174 | nextStep++; |
| 4175 | } |
| 4176 | } |
| 4177 | |
| 4178 | if (currentElement.hasAttribute("data-disable-interaction")) { |
| 4179 | disableInteraction = !!currentElement.getAttribute("data-disable-interaction"); |
| 4180 | } else { |
| 4181 | disableInteraction = _this._options.disableInteraction; |
| 4182 | } |
| 4183 | |
| 4184 | introItems[nextStep] = { |
| 4185 | element: currentElement, |
| 4186 | title: currentElement.getAttribute("data-title") || "", |
| 4187 | intro: currentElement.getAttribute("data-intro"), |
| 4188 | step: nextStep + 1, |
| 4189 | tooltipClass: currentElement.getAttribute("data-tooltipclass"), |
| 4190 | highlightClass: currentElement.getAttribute("data-highlightclass"), |
| 4191 | position: currentElement.getAttribute("data-position") || _this._options.tooltipPosition, |
| 4192 | scrollTo: currentElement.getAttribute("data-scrollto") || _this._options.scrollTo, |
| 4193 | disableInteraction: disableInteraction |
| 4194 | }; |
| 4195 | } |
| 4196 | }); |
| 4197 | } //removing undefined/null elements |
| 4198 | |
| 4199 | |
| 4200 | var tempIntroItems = []; |
| 4201 | |
| 4202 | for (var z = 0; z < introItems.length; z++) { |
| 4203 | if (introItems[z]) { |
| 4204 | // copy non-falsy values to the end of the array |
| 4205 | tempIntroItems.push(introItems[z]); |
| 4206 | } |
| 4207 | } |
| 4208 | |
| 4209 | introItems = tempIntroItems; //Ok, sort all items with given steps |
| 4210 | |
| 4211 | introItems.sort(function (a, b) { |
| 4212 | return a.step - b.step; |
| 4213 | }); |
| 4214 | return introItems; |
| 4215 | } |
| 4216 | |
| 4217 | /** |
| 4218 | * Update placement of the intro objects on the screen |
| 4219 | * @api private |
| 4220 | * @param {boolean} refreshSteps to refresh the intro steps as well |
| 4221 | */ |
| 4222 | |
| 4223 | function refresh(refreshSteps) { |
| 4224 | var referenceLayer = document.querySelector(".introjs-tooltipReferenceLayer"); |
| 4225 | var helperLayer = document.querySelector(".introjs-helperLayer"); |
| 4226 | var disableInteractionLayer = document.querySelector(".introjs-disableInteraction"); // re-align intros |
| 4227 | |
| 4228 | setHelperLayerPosition.call(this, helperLayer); |
| 4229 | setHelperLayerPosition.call(this, referenceLayer); |
| 4230 | setHelperLayerPosition.call(this, disableInteractionLayer); |
| 4231 | |
| 4232 | if (refreshSteps) { |
| 4233 | this._introItems = fetchIntroSteps.call(this, this._targetElement); |
| 4234 | |
| 4235 | _recreateBullets.call(this, referenceLayer, this._introItems[this._currentStep]); |
| 4236 | |
| 4237 | _updateProgressBar.call(this, referenceLayer); |
| 4238 | } // re-align tooltip |
| 4239 | |
| 4240 | |
| 4241 | if (this._currentStep !== undefined && this._currentStep !== null) { |
| 4242 | var oldArrowLayer = document.querySelector(".introjs-arrow"); |
| 4243 | var oldtooltipContainer = document.querySelector(".introjs-tooltip"); |
| 4244 | placeTooltip.call(this, this._introItems[this._currentStep].element, oldtooltipContainer, oldArrowLayer); |
| 4245 | } //re-align hints |
| 4246 | |
| 4247 | |
| 4248 | reAlignHints.call(this); |
| 4249 | return this; |
| 4250 | } |
| 4251 | |
| 4252 | function onResize() { |
| 4253 | refresh.call(this); |
| 4254 | } |
| 4255 | |
| 4256 | /** |
| 4257 | * Removes `element` from `parentElement` |
| 4258 | * |
| 4259 | * @param {Element} element |
| 4260 | * @param {Boolean} [animate=false] |
| 4261 | */ |
| 4262 | |
| 4263 | function removeChild(element, animate) { |
| 4264 | if (!element || !element.parentElement) return; |
| 4265 | var parentElement = element.parentElement; |
| 4266 | |
| 4267 | if (animate) { |
| 4268 | setStyle(element, { |
| 4269 | opacity: "0" |
| 4270 | }); |
| 4271 | window.setTimeout(function () { |
| 4272 | try { |
| 4273 | // removeChild(..) throws an exception if the child has already been removed (https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild) |
| 4274 | // this try-catch is added to make sure this function doesn't throw an exception if the child has been removed |
| 4275 | // this scenario can happen when start()/exit() is called multiple times and the helperLayer is removed by the |
| 4276 | // previous exit() call (note: this is a timeout) |
| 4277 | parentElement.removeChild(element); |
| 4278 | } catch (e) {} |
| 4279 | }, 500); |
| 4280 | } else { |
| 4281 | parentElement.removeChild(element); |
| 4282 | } |
| 4283 | } |
| 4284 | |
| 4285 | /** |
| 4286 | * Exit from intro |
| 4287 | * |
| 4288 | * @api private |
| 4289 | * @method _exitIntro |
| 4290 | * @param {Object} targetElement |
| 4291 | * @param {Boolean} force - Setting to `true` will skip the result of beforeExit callback |
| 4292 | */ |
| 4293 | |
| 4294 | function exitIntro(targetElement, force) { |
| 4295 | var continueExit = true; // calling onbeforeexit callback |
| 4296 | // |
| 4297 | // If this callback return `false`, it would halt the process |
| 4298 | |
| 4299 | if (this._introBeforeExitCallback !== undefined) { |
| 4300 | continueExit = this._introBeforeExitCallback.call(this); |
| 4301 | } // skip this check if `force` parameter is `true` |
| 4302 | // otherwise, if `onbeforeexit` returned `false`, don't exit the intro |
| 4303 | |
| 4304 | |
| 4305 | if (!force && continueExit === false) return; // remove overlay layers from the page |
| 4306 | |
| 4307 | var overlayLayers = targetElement.querySelectorAll(".introjs-overlay"); |
| 4308 | |
| 4309 | if (overlayLayers && overlayLayers.length) { |
| 4310 | forEach(overlayLayers, function (overlayLayer) { |
| 4311 | return removeChild(overlayLayer); |
| 4312 | }); |
| 4313 | } //remove all helper layers |
| 4314 | |
| 4315 | |
| 4316 | var helperLayer = targetElement.querySelector(".introjs-helperLayer"); |
| 4317 | removeChild(helperLayer, true); |
| 4318 | var referenceLayer = targetElement.querySelector(".introjs-tooltipReferenceLayer"); |
| 4319 | removeChild(referenceLayer); //remove disableInteractionLayer |
| 4320 | |
| 4321 | var disableInteractionLayer = targetElement.querySelector(".introjs-disableInteraction"); |
| 4322 | removeChild(disableInteractionLayer); //remove intro floating element |
| 4323 | |
| 4324 | var floatingElement = document.querySelector(".introjsFloatingElement"); |
| 4325 | removeChild(floatingElement); |
| 4326 | removeShowElement(); //clean listeners |
| 4327 | |
| 4328 | DOMEvent.off(window, "keydown", onKeyDown, this, true); |
| 4329 | DOMEvent.off(window, "resize", onResize, this, true); //check if any callback is defined |
| 4330 | |
| 4331 | if (this._introExitCallback !== undefined) { |
| 4332 | this._introExitCallback.call(this); |
| 4333 | } //set the step to zero |
| 4334 | |
| 4335 | |
| 4336 | this._currentStep = undefined; |
| 4337 | } |
| 4338 | |
| 4339 | /** |
| 4340 | * Add overlay layer to the page |
| 4341 | * |
| 4342 | * @api private |
| 4343 | * @method _addOverlayLayer |
| 4344 | * @param {Object} targetElm |
| 4345 | */ |
| 4346 | |
| 4347 | function addOverlayLayer(targetElm) { |
| 4348 | var _this = this; |
| 4349 | |
| 4350 | var overlayLayer = _createElement("div", { |
| 4351 | className: "introjs-overlay" |
| 4352 | }); |
| 4353 | setStyle(overlayLayer, { |
| 4354 | top: 0, |
| 4355 | bottom: 0, |
| 4356 | left: 0, |
| 4357 | right: 0, |
| 4358 | position: "fixed" |
| 4359 | }); |
| 4360 | targetElm.appendChild(overlayLayer); |
| 4361 | |
| 4362 | if (this._options.exitOnOverlayClick === true) { |
| 4363 | setStyle(overlayLayer, { |
| 4364 | cursor: "pointer" |
| 4365 | }); |
| 4366 | |
| 4367 | overlayLayer.onclick = function () { |
| 4368 | exitIntro.call(_this, targetElm); |
| 4369 | }; |
| 4370 | } |
| 4371 | |
| 4372 | return true; |
| 4373 | } |
| 4374 | |
| 4375 | /** |
| 4376 | * Initiate a new introduction/guide from an element in the page |
| 4377 | * |
| 4378 | * @api private |
| 4379 | * @method introForElement |
| 4380 | * @param {Object} targetElm |
| 4381 | * @returns {Boolean} Success or not? |
| 4382 | */ |
| 4383 | |
| 4384 | function introForElement(targetElm) { |
| 4385 | //set it to the introJs object |
| 4386 | var steps = fetchIntroSteps.call(this, targetElm); |
| 4387 | |
| 4388 | if (steps.length === 0) { |
| 4389 | return false; |
| 4390 | } |
| 4391 | |
| 4392 | this._introItems = steps; //add overlay layer to the page |
| 4393 | |
| 4394 | if (addOverlayLayer.call(this, targetElm)) { |
| 4395 | //then, start the show |
| 4396 | nextStep.call(this); |
| 4397 | |
| 4398 | if (this._options.keyboardNavigation) { |
| 4399 | DOMEvent.on(window, "keydown", onKeyDown, this, true); |
| 4400 | } //for window resize |
| 4401 | |
| 4402 | |
| 4403 | DOMEvent.on(window, "resize", onResize, this, true); |
| 4404 | } |
| 4405 | |
| 4406 | return false; |
| 4407 | } |
| 4408 | |
| 4409 | var version = "4.2.2"; |
| 4410 | |
| 4411 | /** |
| 4412 | * IntroJs main class |
| 4413 | * |
| 4414 | * @class IntroJs |
| 4415 | */ |
| 4416 | |
| 4417 | function IntroJs(obj) { |
| 4418 | this._targetElement = obj; |
| 4419 | this._introItems = []; |
| 4420 | this._options = { |
| 4421 | /* Next button label in tooltip box */ |
| 4422 | nextLabel: "Next", |
| 4423 | |
| 4424 | /* Previous button label in tooltip box */ |
| 4425 | prevLabel: "Back", |
| 4426 | |
| 4427 | /* Skip button label in tooltip box */ |
| 4428 | skipLabel: "×", |
| 4429 | |
| 4430 | /* Done button label in tooltip box */ |
| 4431 | doneLabel: "Done", |
| 4432 | |
| 4433 | /* Hide previous button in the first step? Otherwise, it will be disabled button. */ |
| 4434 | hidePrev: false, |
| 4435 | |
| 4436 | /* Hide next button in the last step? Otherwise, it will be disabled button (note: this will also hide the "Done" button) */ |
| 4437 | hideNext: false, |
| 4438 | |
| 4439 | /* Change the Next button to Done in the last step of the intro? otherwise, it will render a disabled button */ |
| 4440 | nextToDone: true, |
| 4441 | |
| 4442 | /* Default tooltip box position */ |
| 4443 | tooltipPosition: "bottom", |
| 4444 | |
| 4445 | /* Next CSS class for tooltip boxes */ |
| 4446 | tooltipClass: "", |
| 4447 | |
| 4448 | /* Start intro for a group of elements */ |
| 4449 | group: "", |
| 4450 | |
| 4451 | /* CSS class that is added to the helperLayer */ |
| 4452 | highlightClass: "", |
| 4453 | |
| 4454 | /* Close introduction when pressing Escape button? */ |
| 4455 | exitOnEsc: true, |
| 4456 | |
| 4457 | /* Close introduction when clicking on overlay layer? */ |
| 4458 | exitOnOverlayClick: true, |
| 4459 | |
| 4460 | /* Show step numbers in introduction? */ |
| 4461 | showStepNumbers: false, |
| 4462 | |
| 4463 | /* Let user use keyboard to navigate the tour? */ |
| 4464 | keyboardNavigation: true, |
| 4465 | |
| 4466 | /* Show tour control buttons? */ |
| 4467 | showButtons: true, |
| 4468 | |
| 4469 | /* Show tour bullets? */ |
| 4470 | showBullets: true, |
| 4471 | |
| 4472 | /* Show tour progress? */ |
| 4473 | showProgress: false, |
| 4474 | |
| 4475 | /* Scroll to highlighted element? */ |
| 4476 | scrollToElement: true, |
| 4477 | |
| 4478 | /* |
| 4479 | * Should we scroll the tooltip or target element? |
| 4480 | * |
| 4481 | * Options are: 'element' or 'tooltip' |
| 4482 | */ |
| 4483 | scrollTo: "element", |
| 4484 | |
| 4485 | /* Padding to add after scrolling when element is not in the viewport (in pixels) */ |
| 4486 | scrollPadding: 30, |
| 4487 | |
| 4488 | /* Set the overlay opacity */ |
| 4489 | overlayOpacity: 0.5, |
| 4490 | |
| 4491 | /* To determine the tooltip position automatically based on the window.width/height */ |
| 4492 | autoPosition: true, |
| 4493 | |
| 4494 | /* Precedence of positions, when auto is enabled */ |
| 4495 | positionPrecedence: ["bottom", "top", "right", "left"], |
| 4496 | |
| 4497 | /* Disable an interaction with element? */ |
| 4498 | disableInteraction: false, |
| 4499 | |
| 4500 | /* Set how much padding to be used around helper element */ |
| 4501 | helperElementPadding: 10, |
| 4502 | |
| 4503 | /* Default hint position */ |
| 4504 | hintPosition: "top-middle", |
| 4505 | |
| 4506 | /* Hint button label */ |
| 4507 | hintButtonLabel: "Got it", |
| 4508 | |
| 4509 | /* Adding animation to hints? */ |
| 4510 | hintAnimation: true, |
| 4511 | |
| 4512 | /* additional classes to put on the buttons */ |
| 4513 | buttonClass: "introjs-button", |
| 4514 | |
| 4515 | /* additional classes to put on progress bar */ |
| 4516 | progressBarAdditionalClass: false |
| 4517 | }; |
| 4518 | } |
| 4519 | |
| 4520 | var introJs = function introJs(targetElm) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4521 | var instance; |
| 4522 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4523 | if (_typeof(targetElm) === "object") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4524 | //Ok, create a new instance |
| 4525 | instance = new IntroJs(targetElm); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4526 | } else if (typeof targetElm === "string") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4527 | //select the target element with query selector |
| 4528 | var targetElement = document.querySelector(targetElm); |
| 4529 | |
| 4530 | if (targetElement) { |
| 4531 | instance = new IntroJs(targetElement); |
| 4532 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4533 | throw new Error("There is no element with given selector."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4534 | } |
| 4535 | } else { |
| 4536 | instance = new IntroJs(document.body); |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4537 | } // add instance to list of _instances |
| 4538 | // passing group to stamp to increment |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4539 | // from 0 onward somewhat reliably |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4540 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4541 | |
| 4542 | introJs.instances[stamp(instance, "introjs-instance")] = instance; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4543 | return instance; |
| 4544 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4545 | /** |
| 4546 | * Current IntroJs version |
| 4547 | * |
| 4548 | * @property version |
| 4549 | * @type String |
| 4550 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4551 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4552 | |
| 4553 | introJs.version = version; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4554 | /** |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4555 | * key-val object helper for introJs instances |
| 4556 | * |
| 4557 | * @property instances |
| 4558 | * @type Object |
| 4559 | */ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4560 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4561 | introJs.instances = {}; //Prototype |
| 4562 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4563 | introJs.fn = IntroJs.prototype = { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4564 | clone: function clone() { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4565 | return new IntroJs(this); |
| 4566 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4567 | setOption: function setOption(option, value) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4568 | this._options[option] = value; |
| 4569 | return this; |
| 4570 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4571 | setOptions: function setOptions(options) { |
| 4572 | this._options = mergeOptions(this._options, options); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4573 | return this; |
| 4574 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4575 | start: function start() { |
| 4576 | introForElement.call(this, this._targetElement); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4577 | return this; |
| 4578 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4579 | goToStep: function goToStep$1(step) { |
| 4580 | goToStep.call(this, step); |
| 4581 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4582 | return this; |
| 4583 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4584 | addStep: function addStep(options) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4585 | if (!this._options.steps) { |
| 4586 | this._options.steps = []; |
| 4587 | } |
| 4588 | |
| 4589 | this._options.steps.push(options); |
| 4590 | |
| 4591 | return this; |
| 4592 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4593 | addSteps: function addSteps(steps) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4594 | if (!steps.length) return; |
| 4595 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4596 | for (var index = 0; index < steps.length; index++) { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4597 | this.addStep(steps[index]); |
| 4598 | } |
| 4599 | |
| 4600 | return this; |
| 4601 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4602 | goToStepNumber: function goToStepNumber$1(step) { |
| 4603 | goToStepNumber.call(this, step); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4604 | |
| 4605 | return this; |
| 4606 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4607 | nextStep: function nextStep$1() { |
| 4608 | nextStep.call(this); |
| 4609 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4610 | return this; |
| 4611 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4612 | previousStep: function previousStep$1() { |
| 4613 | previousStep.call(this); |
| 4614 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4615 | return this; |
| 4616 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4617 | currentStep: function currentStep$1() { |
| 4618 | return currentStep.call(this); |
| 4619 | }, |
| 4620 | exit: function exit(force) { |
| 4621 | exitIntro.call(this, this._targetElement, force); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4622 | return this; |
| 4623 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4624 | refresh: function refresh$1(refreshSteps) { |
| 4625 | refresh.call(this, refreshSteps); |
| 4626 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4627 | return this; |
| 4628 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4629 | onbeforechange: function onbeforechange(providedCallback) { |
| 4630 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4631 | this._introBeforeChangeCallback = providedCallback; |
| 4632 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4633 | throw new Error("Provided callback for onbeforechange was not a function"); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4634 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4635 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4636 | return this; |
| 4637 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4638 | onchange: function onchange(providedCallback) { |
| 4639 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4640 | this._introChangeCallback = providedCallback; |
| 4641 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4642 | throw new Error("Provided callback for onchange was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4643 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4644 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4645 | return this; |
| 4646 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4647 | onafterchange: function onafterchange(providedCallback) { |
| 4648 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4649 | this._introAfterChangeCallback = providedCallback; |
| 4650 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4651 | throw new Error("Provided callback for onafterchange was not a function"); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4652 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4653 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4654 | return this; |
| 4655 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4656 | oncomplete: function oncomplete(providedCallback) { |
| 4657 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4658 | this._introCompleteCallback = providedCallback; |
| 4659 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4660 | throw new Error("Provided callback for oncomplete was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4661 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4662 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4663 | return this; |
| 4664 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4665 | onhintsadded: function onhintsadded(providedCallback) { |
| 4666 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4667 | this._hintsAddedCallback = providedCallback; |
| 4668 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4669 | throw new Error("Provided callback for onhintsadded was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4670 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4671 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4672 | return this; |
| 4673 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4674 | onhintclick: function onhintclick(providedCallback) { |
| 4675 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4676 | this._hintClickCallback = providedCallback; |
| 4677 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4678 | throw new Error("Provided callback for onhintclick was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4679 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4680 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4681 | return this; |
| 4682 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4683 | onhintclose: function onhintclose(providedCallback) { |
| 4684 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4685 | this._hintCloseCallback = providedCallback; |
| 4686 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4687 | throw new Error("Provided callback for onhintclose was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4688 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4689 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4690 | return this; |
| 4691 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4692 | onexit: function onexit(providedCallback) { |
| 4693 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4694 | this._introExitCallback = providedCallback; |
| 4695 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4696 | throw new Error("Provided callback for onexit was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4697 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4698 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4699 | return this; |
| 4700 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4701 | onskip: function onskip(providedCallback) { |
| 4702 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4703 | this._introSkipCallback = providedCallback; |
| 4704 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4705 | throw new Error("Provided callback for onskip was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4706 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4707 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4708 | return this; |
| 4709 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4710 | onbeforeexit: function onbeforeexit(providedCallback) { |
| 4711 | if (typeof providedCallback === "function") { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4712 | this._introBeforeExitCallback = providedCallback; |
| 4713 | } else { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4714 | throw new Error("Provided callback for onbeforeexit was not a function."); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4715 | } |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4716 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4717 | return this; |
| 4718 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4719 | addHints: function addHints() { |
| 4720 | populateHints.call(this, this._targetElement); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4721 | return this; |
| 4722 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4723 | hideHint: function hideHint$1(stepId) { |
| 4724 | hideHint.call(this, stepId); |
| 4725 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4726 | return this; |
| 4727 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4728 | hideHints: function hideHints$1() { |
| 4729 | hideHints.call(this); |
| 4730 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4731 | return this; |
| 4732 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4733 | showHint: function showHint$1(stepId) { |
| 4734 | showHint.call(this, stepId); |
| 4735 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4736 | return this; |
| 4737 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4738 | showHints: function showHints$1() { |
| 4739 | showHints.call(this); |
| 4740 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4741 | return this; |
| 4742 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4743 | removeHints: function removeHints$1() { |
| 4744 | removeHints.call(this); |
| 4745 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4746 | return this; |
| 4747 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4748 | removeHint: function removeHint$1(stepId) { |
| 4749 | removeHint().call(this, stepId); |
| 4750 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4751 | return this; |
| 4752 | }, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4753 | showHintDialog: function showHintDialog$1(stepId) { |
| 4754 | showHintDialog.call(this, stepId); |
| 4755 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 4756 | return this; |
| 4757 | } |
| 4758 | }; |
| 4759 | |
| 4760 | return introJs; |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 4761 | |
| 4762 | }))); |