1/*! 2 * Button visually impaired - v1.0.0 https://bvi.isvek.ru 3 * Copyright 2014-2021 Oleg Korotenko <[email protected]>. 4 * Licensed MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md) 5 */ 6(function (global, factory) { 7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 8 typeof define === 'function' && define.amd ? define(factory) : 9 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.isvek = factory()); 10}(this, (function () { 'use strict'; 11 12 function ownKeys(object, enumerableOnly) { 13 var keys = Object.keys(object); 14 15 if (Object.getOwnPropertySymbols) { 16 var symbols = Object.getOwnPropertySymbols(object); 17 18 if (enumerableOnly) { 19 symbols = symbols.filter(function (sym) { 20 return Object.getOwnPropertyDescriptor(object, sym).enumerable; 21 }); 22 } 23 24 keys.push.apply(keys, symbols); 25 } 26 27 return keys; 28 } 29 30 function _objectSpread2(target) { 31 for (var i = 1; i < arguments.length; i++) { 32 var source = arguments[i] != null ? arguments[i] : {}; 33 34 if (i % 2) { 35 ownKeys(Object(source), true).forEach(function (key) { 36 _defineProperty(target, key, source[key]); 37 }); 38 } else if (Object.getOwnPropertyDescriptors) { 39 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); 40 } else { 41 ownKeys(Object(source)).forEach(function (key) { 42 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); 43 }); 44 } 45 } 46 47 return target; 48 } 49 50 function _typeof(obj) { 51 "@babel/helpers - typeof"; 52 53 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 54 _typeof = function (obj) { 55 return typeof obj; 56 }; 57 } else { 58 _typeof = function (obj) { 59 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 60 }; 61 } 62 63 return _typeof(obj); 64 } 65 66 function _classCallCheck(instance, Constructor) { 67 if (!(instance instanceof Constructor)) { 68 throw new TypeError("Cannot call a class as a function"); 69 } 70 } 71 72 function _defineProperties(target, props) { 73 for (var i = 0; i < props.length; i++) { 74 var descriptor = props[i]; 75 descriptor.enumerable = descriptor.enumerable || false; 76 descriptor.configurable = true; 77 if ("value" in descriptor) descriptor.writable = true; 78 Object.defineProperty(target, descriptor.key, descriptor); 79 } 80 } 81 82 function _createClass(Constructor, protoProps, staticProps) { 83 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 84 if (staticProps) _defineProperties(Constructor, staticProps); 85 return Constructor; 86 } 87 88 function _defineProperty(obj, key, value) { 89 if (key in obj) { 90 Object.defineProperty(obj, key, { 91 value: value, 92 enumerable: true, 93 configurable: true, 94 writable: true 95 }); 96 } else { 97 obj[key] = value; 98 } 99 100 return obj; 101 } 102 103 function _unsupportedIterableToArray(o, minLen) { 104 if (!o) return; 105 if (typeof o === "string") return _arrayLikeToArray(o, minLen); 106 var n = Object.prototype.toString.call(o).slice(8, -1); 107 if (n === "Object" && o.constructor) n = o.constructor.name; 108 if (n === "Map" || n === "Set") return Array.from(o); 109 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); 110 } 111 112 function _arrayLikeToArray(arr, len) { 113 if (len == null || len > arr.length) len = arr.length; 114 115 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; 116 117 return arr2; 118 } 119 120 function _createForOfIteratorHelper(o, allowArrayLike) { 121 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; 122 123 if (!it) { 124 if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { 125 if (it) o = it; 126 var i = 0; 127 128 var F = function () {}; 129 130 return { 131 s: F, 132 n: function () { 133 if (i >= o.length) return { 134 done: true 135 }; 136 return { 137 done: false, 138 value: o[i++] 139 }; 140 }, 141 e: function (e) { 142 throw e; 143 }, 144 f: F 145 }; 146 } 147 148 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 149 } 150 151 var normalCompletion = true, 152 didErr = false, 153 err; 154 return { 155 s: function () { 156 it = it.call(o); 157 }, 158 n: function () { 159 var step = it.next(); 160 normalCompletion = step.done; 161 return step; 162 }, 163 e: function (e) { 164 didErr = true; 165 err = e; 166 }, 167 f: function () { 168 try { 169 if (!normalCompletion && it.return != null) it.return(); 170 } finally { 171 if (didErr) throw err; 172 } 173 } 174 }; 175 } 176 177 var runtime = {exports: {}}; 178
vendor: 5,181 bytes, lines 179-297
179 (function (module) { 180 var runtime = function (exports) { 181 182 var Op = Object.prototype; 183 var hasOwn = Op.hasOwnProperty; 184 var undefined$1; // More compressible than void 0. 185 186 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 187 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 188 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 189 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 190 191 function define(obj, key, value) { 192 Object.defineProperty(obj, key, { 193 value: value, 194 enumerable: true, 195 configurable: true, 196 writable: true 197 }); 198 return obj[key]; 199 } 200 201 try { 202 // IE 8 has a broken Object.defineProperty that only works on DOM objects. 203 define({}, ""); 204 } catch (err) { 205 define = function define(obj, key, value) { 206 return obj[key] = value; 207 }; 208 } 209 210 function wrap(innerFn, outerFn, self, tryLocsList) { 211 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 212 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 213 var generator = Object.create(protoGenerator.prototype); 214 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, 215 // .throw, and .return methods. 216 217 generator._invoke = makeInvokeMethod(innerFn, self, context); 218 return generator; 219 } 220 221 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion 222 // record like context.tryEntries[i].completion. This interface could 223 // have been (and was previously) designed to take a closure to be 224 // invoked without arguments, but in all the cases we care about we 225 // already have an existing method we want to call, so there's no need 226 // to create a new function object. We can even get away with assuming 227 // the method takes exactly one argument, since that happens to be true 228 // in every case, so we don't have to touch the arguments object. The 229 // only additional allocation required is the completion record, which 230 // has a stable shape and so hopefully should be cheap to allocate. 231 232 function tryCatch(fn, obj, arg) { 233 try { 234 return { 235 type: "normal", 236 arg: fn.call(obj, arg) 237 }; 238 } catch (err) { 239 return { 240 type: "throw", 241 arg: err 242 }; 243 } 244 } 245 246 var GenStateSuspendedStart = "suspendedStart"; 247 var GenStateSuspendedYield = "suspendedYield"; 248 var GenStateExecuting = "executing"; 249 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as 250 // breaking out of the dispatch switch statement. 251 252 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and 253 // .constructor.prototype properties for functions that return Generator 254 // objects. For full spec compliance, you may wish to configure your 255 // minifier not to mangle the names of these two functions. 256 257 function Generator() {} 258 259 function GeneratorFunction() {} 260 261 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that 262 // don't natively support it. 263 264 265 var IteratorPrototype = {}; 266 define(IteratorPrototype, iteratorSymbol, function () { 267 return this; 268 }); 269 var getProto = Object.getPrototypeOf; 270 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 271 272 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 273 // This environment has a native %IteratorPrototype%; use it instead 274 // of the polyfill. 275 IteratorPrototype = NativeIteratorPrototype; 276 } 277 278 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); 279 GeneratorFunction.prototype = GeneratorFunctionPrototype; 280 define(Gp, "constructor", GeneratorFunctionPrototype); 281 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); 282 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the 283 // Iterator interface in terms of a single ._invoke method. 284 285 function defineIteratorMethods(prototype) { 286 ["next", "throw", "return"].forEach(function (method) { 287 define(prototype, method, function (arg) { 288 return this._invoke(method, arg); 289 }); 290 }); 291 } 292 293 exports.isGeneratorFunction = function (genFun) { 294 var ctor = typeof genFun === "function" && genFun.constructor; 295 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can 296 // do is to check its .name property. 297 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
vendor: 8,280 bytes, lines 298-499
298 }; 299 300 exports.mark = function (genFun) { 301 if (Object.setPrototypeOf) { 302 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 303 } else { 304 genFun.__proto__ = GeneratorFunctionPrototype; 305 define(genFun, toStringTagSymbol, "GeneratorFunction"); 306 } 307 308 genFun.prototype = Object.create(Gp); 309 return genFun; 310 }; // Within the body of any async function, `await x` is transformed to 311 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 312 // `hasOwn.call(value, "__await")` to determine if the yielded value is 313 // meant to be awaited. 314 315 316 exports.awrap = function (arg) { 317 return { 318 __await: arg 319 }; 320 }; 321 322 function AsyncIterator(generator, PromiseImpl) { 323 function invoke(method, arg, resolve, reject) { 324 var record = tryCatch(generator[method], generator, arg); 325 326 if (record.type === "throw") { 327 reject(record.arg); 328 } else { 329 var result = record.arg; 330 var value = result.value; 331 332 if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) { 333 return PromiseImpl.resolve(value.__await).then(function (value) { 334 invoke("next", value, resolve, reject); 335 }, function (err) { 336 invoke("throw", err, resolve, reject); 337 }); 338 } 339 340 return PromiseImpl.resolve(value).then(function (unwrapped) { 341 // When a yielded Promise is resolved, its final value becomes 342 // the .value of the Promise<{value,done}> result for the 343 // current iteration. 344 result.value = unwrapped; 345 resolve(result); 346 }, function (error) { 347 // If a rejected Promise was yielded, throw the rejection back 348 // into the async generator function so it can be handled there. 349 return invoke("throw", error, resolve, reject); 350 }); 351 } 352 } 353 354 var previousPromise; 355 356 function enqueue(method, arg) { 357 function callInvokeWithMethodAndArg() { 358 return new PromiseImpl(function (resolve, reject) { 359 invoke(method, arg, resolve, reject); 360 }); 361 } 362 363 return previousPromise = // If enqueue has been called before, then we want to wait until 364 // all previous Promises have been resolved before calling invoke, 365 // so that results are always delivered in the correct order. If 366 // enqueue has not been called before, then it is important to 367 // call invoke immediately, without waiting on a callback to fire, 368 // so that the async generator function has the opportunity to do 369 // any necessary setup in a predictable way. This predictability 370 // is why the Promise constructor synchronously invokes its 371 // executor callback, and why async functions synchronously 372 // execute code before the first await. Since we implement simple 373 // async functions in terms of async generators, it is especially 374 // important to get this right, even though it requires care. 375 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later 376 // invocations of the iterator. 377 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); 378 } // Define the unified helper method that is used to implement .next, 379 // .throw, and .return (see defineIteratorMethods). 380 381 382 this._invoke = enqueue; 383 } 384 385 defineIteratorMethods(AsyncIterator.prototype); 386 define(AsyncIterator.prototype, asyncIteratorSymbol, function () { 387 return this; 388 }); 389 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of 390 // AsyncIterator objects; they just return a Promise for the value of 391 // the final result produced by the iterator. 392 393 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { 394 if (PromiseImpl === void 0) PromiseImpl = Promise; 395 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); 396 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. 397 : iter.next().then(function (result) { 398 return result.done ? result.value : iter.next(); 399 }); 400 }; 401 402 function makeInvokeMethod(innerFn, self, context) { 403 var state = GenStateSuspendedStart; 404 return function invoke(method, arg) { 405 if (state === GenStateExecuting) { 406 throw new Error("Generator is already running"); 407 } 408 409 if (state === GenStateCompleted) { 410 if (method === "throw") { 411 throw arg; 412 } // Be forgiving, per 25.3.3.3.3 of the spec: 413 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 414 415 416 return doneResult(); 417 } 418 419 context.method = method; 420 context.arg = arg; 421 422 while (true) { 423 var delegate = context.delegate; 424 425 if (delegate) { 426 var delegateResult = maybeInvokeDelegate(delegate, context); 427 428 if (delegateResult) { 429 if (delegateResult === ContinueSentinel) continue; 430 return delegateResult; 431 } 432 } 433 434 if (context.method === "next") { 435 // Setting context._sent for legacy support of Babel's 436 // function.sent implementation. 437 context.sent = context._sent = context.arg; 438 } else if (context.method === "throw") { 439 if (state === GenStateSuspendedStart) { 440 state = GenStateCompleted; 441 throw context.arg; 442 } 443 444 context.dispatchException(context.arg); 445 } else if (context.method === "return") { 446 context.abrupt("return", context.arg); 447 } 448 449 state = GenStateExecuting; 450 var record = tryCatch(innerFn, self, context); 451 452 if (record.type === "normal") { 453 // If an exception is thrown from innerFn, we leave state === 454 // GenStateExecuting and loop back for another invocation. 455 state = context.done ? GenStateCompleted : GenStateSuspendedYield; 456 457 if (record.arg === ContinueSentinel) { 458 continue; 459 } 460 461 return { 462 value: record.arg, 463 done: context.done 464 }; 465 } else if (record.type === "throw") { 466 state = GenStateCompleted; // Dispatch the exception by looping back around to the 467 // context.dispatchException(context.arg) call above. 468 469 context.method = "throw"; 470 context.arg = record.arg; 471 } 472 } 473 }; 474 } // Call delegate.iterator[context.method](context.arg) and handle the 475 // result, either by returning a { value, done } result from the 476 // delegate iterator, or by modifying context.method and context.arg, 477 // setting context.delegate to null, and returning the ContinueSentinel. 478 479 480 function maybeInvokeDelegate(delegate, context) { 481 var method = delegate.iterator[context.method]; 482 483 if (method === undefined$1) { 484 // A .throw or .return when the delegate iterator has no .throw 485 // method always terminates the yield* loop. 486 context.delegate = null; 487 488 if (context.method === "throw") { 489 // Note: ["return"] must be used for ES3 parsing compatibility. 490 if (delegate.iterator["return"]) { 491 // If the delegate iterator has a return method, give it a 492 // chance to clean up. 493 context.method = "return"; 494 context.arg = undefined$1; 495 maybeInvokeDelegate(delegate, context); 496 497 if (context.method === "throw") { 498 // If maybeInvokeDelegate(context) changed context.method from 499 // "return" to "throw", let that override the TypeError below.
vendor: 5,022 bytes, lines 500-654
500 return ContinueSentinel; 501 } 502 } 503 504 context.method = "throw"; 505 context.arg = new TypeError("The iterator does not provide a 'throw' method"); 506 } 507 508 return ContinueSentinel; 509 } 510 511 var record = tryCatch(method, delegate.iterator, context.arg); 512 513 if (record.type === "throw") { 514 context.method = "throw"; 515 context.arg = record.arg; 516 context.delegate = null; 517 return ContinueSentinel; 518 } 519 520 var info = record.arg; 521 522 if (!info) { 523 context.method = "throw"; 524 context.arg = new TypeError("iterator result is not an object"); 525 context.delegate = null; 526 return ContinueSentinel; 527 } 528 529 if (info.done) { 530 // Assign the result of the finished delegate to the temporary 531 // variable specified by delegate.resultName (see delegateYield). 532 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). 533 534 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the 535 // exception, let the outer generator proceed normally. If 536 // context.method was "next", forget context.arg since it has been 537 // "consumed" by the delegate iterator. If context.method was 538 // "return", allow the original .return call to continue in the 539 // outer generator. 540 541 if (context.method !== "return") { 542 context.method = "next"; 543 context.arg = undefined$1; 544 } 545 } else { 546 // Re-yield the result returned by the delegate method. 547 return info; 548 } // The delegate iterator is finished, so forget it and continue with 549 // the outer generator. 550 551 552 context.delegate = null; 553 return ContinueSentinel; 554 } // Define Generator.prototype.{next,throw,return} in terms of the 555 // unified ._invoke helper method. 556 557 558 defineIteratorMethods(Gp); 559 define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the 560 // @@iterator function is called on it. Some browsers' implementations of the 561 // iterator prototype chain incorrectly implement this, causing the Generator 562 // object to not be returned from this call. This ensures that doesn't happen. 563 // See https://github.com/facebook/regenerator/issues/274 for more details. 564 565 define(Gp, iteratorSymbol, function () { 566 return this; 567 }); 568 define(Gp, "toString", function () { 569 return "[object Generator]"; 570 }); 571 572 function pushTryEntry(locs) { 573 var entry = { 574 tryLoc: locs[0] 575 }; 576 577 if (1 in locs) { 578 entry.catchLoc = locs[1]; 579 } 580 581 if (2 in locs) { 582 entry.finallyLoc = locs[2]; 583 entry.afterLoc = locs[3]; 584 } 585 586 this.tryEntries.push(entry); 587 } 588 589 function resetTryEntry(entry) { 590 var record = entry.completion || {}; 591 record.type = "normal"; 592 delete record.arg; 593 entry.completion = record; 594 } 595 596 function Context(tryLocsList) { 597 // The root entry object (effectively a try statement without a catch 598 // or a finally block) gives us a place to store values thrown from 599 // locations where there is no enclosing try statement. 600 this.tryEntries = [{ 601 tryLoc: "root" 602 }]; 603 tryLocsList.forEach(pushTryEntry, this); 604 this.reset(true); 605 } 606 607 exports.keys = function (object) { 608 var keys = []; 609 610 for (var key in object) { 611 keys.push(key); 612 } 613 614 keys.reverse(); // Rather than returning an object with a next method, we keep 615 // things simple and return the next function itself. 616 617 return function next() { 618 while (keys.length) { 619 var key = keys.pop(); 620 621 if (key in object) { 622 next.value = key; 623 next.done = false; 624 return next; 625 } 626 } // To avoid creating an additional object, we just hang the .value 627 // and .done properties off the next function object itself. This 628 // also ensures that the minifier will not anonymize the function. 629 630 631 next.done = true; 632 return next; 633 }; 634 }; 635 636 function values(iterable) { 637 if (iterable) { 638 var iteratorMethod = iterable[iteratorSymbol]; 639 640 if (iteratorMethod) { 641 return iteratorMethod.call(iterable); 642 } 643 644 if (typeof iterable.next === "function") { 645 return iterable; 646 } 647 648 if (!isNaN(iterable.length)) { 649 var i = -1, 650 next = function next() { 651 while (++i < iterable.length) { 652 if (hasOwn.call(iterable, i)) { 653 next.value = iterable[i]; 654 next.done = false;
vendor: 4,072 bytes, lines 655-784
655 return next; 656 } 657 } 658 659 next.value = undefined$1; 660 next.done = true; 661 return next; 662 }; 663 664 return next.next = next; 665 } 666 } // Return an iterator with no values. 667 668 669 return { 670 next: doneResult 671 }; 672 } 673 674 exports.values = values; 675 676 function doneResult() { 677 return { 678 value: undefined$1, 679 done: true 680 }; 681 } 682 683 Context.prototype = { 684 constructor: Context, 685 reset: function reset(skipTempReset) { 686 this.prev = 0; 687 this.next = 0; // Resetting context._sent for legacy support of Babel's 688 // function.sent implementation. 689 690 this.sent = this._sent = undefined$1; 691 this.done = false; 692 this.delegate = null; 693 this.method = "next"; 694 this.arg = undefined$1; 695 this.tryEntries.forEach(resetTryEntry); 696 697 if (!skipTempReset) { 698 for (var name in this) { 699 // Not sure about the optimal order of these conditions: 700 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { 701 this[name] = undefined$1; 702 } 703 } 704 } 705 }, 706 stop: function stop() { 707 this.done = true; 708 var rootEntry = this.tryEntries[0]; 709 var rootRecord = rootEntry.completion; 710 711 if (rootRecord.type === "throw") { 712 throw rootRecord.arg; 713 } 714 715 return this.rval; 716 }, 717 dispatchException: function dispatchException(exception) { 718 if (this.done) { 719 throw exception; 720 } 721 722 var context = this; 723 724 function handle(loc, caught) { 725 record.type = "throw"; 726 record.arg = exception; 727 context.next = loc; 728 729 if (caught) { 730 // If the dispatched exception was caught by a catch block, 731 // then let that catch block handle the exception normally. 732 context.method = "next"; 733 context.arg = undefined$1; 734 } 735 736 return !!caught; 737 } 738 739 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 740 var entry = this.tryEntries[i]; 741 var record = entry.completion; 742 743 if (entry.tryLoc === "root") { 744 // Exception thrown outside of any try block that could handle 745 // it, so set the completion value of the entire function to 746 // throw the exception. 747 return handle("end"); 748 } 749 750 if (entry.tryLoc <= this.prev) { 751 var hasCatch = hasOwn.call(entry, "catchLoc"); 752 var hasFinally = hasOwn.call(entry, "finallyLoc"); 753 754 if (hasCatch && hasFinally) { 755 if (this.prev < entry.catchLoc) { 756 return handle(entry.catchLoc, true); 757 } else if (this.prev < entry.finallyLoc) { 758 return handle(entry.finallyLoc); 759 } 760 } else if (hasCatch) { 761 if (this.prev < entry.catchLoc) { 762 return handle(entry.catchLoc, true); 763 } 764 } else if (hasFinally) { 765 if (this.prev < entry.finallyLoc) { 766 return handle(entry.finallyLoc); 767 } 768 } else { 769 throw new Error("try statement without catch or finally"); 770 } 771 } 772 } 773 }, 774 abrupt: function abrupt(type, arg) { 775 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 776 var entry = this.tryEntries[i]; 777 778 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { 779 var finallyEntry = entry; 780 break; 781 } 782 } 783 784 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
vendor: 4,423 bytes, lines 785-899
785 // Ignore the finally entry if control is not jumping to a 786 // location outside the try/catch block. 787 finallyEntry = null; 788 } 789 790 var record = finallyEntry ? finallyEntry.completion : {}; 791 record.type = type; 792 record.arg = arg; 793 794 if (finallyEntry) { 795 this.method = "next"; 796 this.next = finallyEntry.finallyLoc; 797 return ContinueSentinel; 798 } 799 800 return this.complete(record); 801 }, 802 complete: function complete(record, afterLoc) { 803 if (record.type === "throw") { 804 throw record.arg; 805 } 806 807 if (record.type === "break" || record.type === "continue") { 808 this.next = record.arg; 809 } else if (record.type === "return") { 810 this.rval = this.arg = record.arg; 811 this.method = "return"; 812 this.next = "end"; 813 } else if (record.type === "normal" && afterLoc) { 814 this.next = afterLoc; 815 } 816 817 return ContinueSentinel; 818 }, 819 finish: function finish(finallyLoc) { 820 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 821 var entry = this.tryEntries[i]; 822 823 if (entry.finallyLoc === finallyLoc) { 824 this.complete(entry.completion, entry.afterLoc); 825 resetTryEntry(entry); 826 return ContinueSentinel; 827 } 828 } 829 }, 830 "catch": function _catch(tryLoc) { 831 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 832 var entry = this.tryEntries[i]; 833 834 if (entry.tryLoc === tryLoc) { 835 var record = entry.completion; 836 837 if (record.type === "throw") { 838 var thrown = record.arg; 839 resetTryEntry(entry); 840 } 841 842 return thrown; 843 } 844 } // The context.catch method must only be called with a location 845 // argument that corresponds to a known catch block. 846 847 848 throw new Error("illegal catch attempt"); 849 }, 850 delegateYield: function delegateYield(iterable, resultName, nextLoc) { 851 this.delegate = { 852 iterator: values(iterable), 853 resultName: resultName, 854 nextLoc: nextLoc 855 }; 856 857 if (this.method === "next") { 858 // Deliberately forget the last sent value so that we don't 859 // accidentally pass it on to the delegate. 860 this.arg = undefined$1; 861 } 862 863 return ContinueSentinel; 864 } 865 }; // Regardless of whether this script is executing as a CommonJS module 866 // or not, return the runtime object so that we can declare the variable 867 // regeneratorRuntime in the outer scope, which allows this module to be 868 // injected easily by `bin/regenerator --include-runtime script.js`. 869 870 return exports; 871 }( // If this script is executing as a CommonJS module, use module.exports 872 // as the regeneratorRuntime namespace. Otherwise create a new empty 873 // object. Either way, the resulting object will be used to initialize 874 // the regeneratorRuntime variable at the top of this file. 875 module.exports ); 876 877 try { 878 regeneratorRuntime = runtime; 879 } catch (accidentalStrictMode) { 880 // This module should not be running in strict mode, so the above 881 // assignment should always work unless something is misconfigured. Just 882 // in case runtime.js accidentally runs in strict mode, in modern engines 883 // we can explicitly access globalThis. In older engines we can escape 884 // strict mode using a global Function call. This could conceivably fail 885 // if a Content Security Policy forbids using Function, but in that case 886 // the proper solution is to fix the accidental strict mode problem. If 887 // you've misconfigured your bundler to force strict mode and applied a 888 // CSP to forbid Function, and you're not willing to fix either of those 889 // problems, please detail your unique predicament in a GitHub issue. 890 if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === "object") { 891 globalThis.regeneratorRuntime = runtime; 892 } else { 893 Function("r", "regeneratorRuntime = r")(runtime); 894 } 895 } 896 })(runtime); 897 898 /** 899 * --------------------------------------------------------------------------
900 * Button visually impaired (v1.0.0): util/index.js 901 * Licensed under MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md) 902 * -------------------------------------------------------------------------- 903 */ 904 (function (arr) { 905 arr.forEach(function (item) { 906 if (item.hasOwnProperty('prepend')) { 907 return; 908 } 909 910 Object.defineProperty(item, 'prepend', { 911 configurable: true, 912 enumerable: true, 913 writable: true, 914 value: function prepend() { 915 var argArr = Array.prototype.slice.call(arguments), 916 docFrag = document.createDocumentFragment(); 917 argArr.forEach(function (argItem) { 918 var isNode = argItem instanceof Node; 919 docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); 920 }); 921 this.insertBefore(docFrag, this.firstChild); 922 } 923 }); 924 }); 925 })([Element.prototype, Document.prototype, DocumentFragment.prototype]); 926 927 if (window.NodeList && !NodeList.prototype.forEach) { 928 NodeList.prototype.forEach = Array.prototype.forEach; 929 } 930 931 if (window.HTMLCollection && !HTMLCollection.prototype.forEach) { 932 HTMLCollection.prototype.forEach = Array.prototype.forEach; 933 } 934 935 var toType = function toType(obj) { 936 if (obj === null || obj === undefined) { 937 return "".concat(obj); 938 } 939 940 return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); 941 }; 942 943 var isElement = function isElement(obj) { 944 if (!obj || _typeof(obj) !== 'object') { 945 return false; 946 } 947 948 return typeof obj.nodeType !== 'undefined'; 949 }; 950 951 var checkConfig = function checkConfig(config, configTypes, configOptions) { 952 Object.keys(configTypes).forEach(function (key) { 953 var expectedTypes = configTypes[key]; 954 var value = config[key]; 955 var valueType = value && isElement(value) ? 'element' : toType(value); 956 957 if (!new RegExp(expectedTypes).test(valueType)) { 958 throw new TypeError("Bvi console: \u041E\u043F\u0446\u0438\u044F \"".concat(key, "\" \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043D\u044B\u0439 \u0442\u0438\u043F \"").concat(valueType, "\", \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \"").concat(expectedTypes, "\".")); 959 } 960 }); 961 Object.keys(configOptions).forEach(function (key) { 962 var expectedOptions = configOptions[key]; 963 var value = config[key]; 964 965 if (!new RegExp(expectedOptions).test(value)) { 966 throw new TypeError("Bvi console: \u041E\u043F\u0446\u0438\u044F \"".concat(key, "\" \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \"").concat(value, "\", \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \"").concat(expectedOptions, "\".")); 967 } 968 }); 969 }; 970 971 var stringToBoolean = function stringToBoolean(string) { 972 switch (string) { 973 case 'on': 974 case 'true': 975 case '1': 976 return true; 977 978 default: 979 return false; 980 } 981 }; 982 983 var wrapInner = function wrapInner(parent, wrapper, className) { 984 if (typeof wrapper === 'string') { 985 wrapper = document.createElement(wrapper); 986 } 987 988 parent.appendChild(wrapper).className = className; 989 990 while (parent.firstChild !== wrapper) { 991 wrapper.appendChild(parent.firstChild); 992 } 993 }; 994 995 var unwrap = function unwrap(wrapper) { 996 var docFrag = document.createDocumentFragment(); 997 if (!wrapper) return; 998 999 while (wrapper.firstChild) { 1000 var child = wrapper.removeChild(wrapper.firstChild); 1001 docFrag.appendChild(child); 1002 } 1003 1004 wrapper.parentNode.replaceChild(docFrag, wrapper); 1005 }; 1006 1007 var getObject = function getObject(object, callback) { 1008 Object.keys(object).forEach(function (key) { 1009 if (typeof callback === 'function') { 1010 callback(key); 1011 } 1012 }); 1013 }; 1014 1015 var getArray = function getArray(array, callback) { 1016 Array.from(array).forEach(function (key) { 1017 if (typeof callback === 'function') { 1018 callback(key); 1019 } 1020 }); 1021 }; 1022 1023 var synth = function synth() { 1024 return window.speechSynthesis; 1025 }; 1026 1027 /** 1028 * --------------------------------------------------------------------------
1029 * Button visually impaired (v1.0.0): util/cookie.js 1030 * Licensed under MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md) 1031 * -------------------------------------------------------------------------- 1032 */ 1033 var setCookie = function setCookie() { 1034 var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 1035 var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 1036 var now = new Date(); 1037 var time = now.getTime(); 1038 time += 24 * 60 * 60 * 1000; 1039 now.setTime(time); 1040 document.cookie = "bvi_".concat(name, "=").concat(value, ";path=/;expires=").concat(now.toUTCString(), ";domain=").concat(location.host); 1041 }; 1042 1043 var getCookie = function getCookie() { 1044 var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 1045 name = "bvi_".concat(name, "="); 1046 var decodedCookie = decodeURIComponent(document.cookie); 1047 var cookies = decodedCookie.split(';'); 1048 1049 for (var i = 0; i < cookies.length; i++) { 1050 var cookie = cookies[i].trim(); 1051 1052 if (cookie.indexOf(name) !== -1) { 1053 return cookie.substring(name.length, cookie.length); 1054 } 1055 } 1056 }; 1057 1058 var removeCookie = function removeCookie() { 1059 var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 1060 document.cookie = "bvi_".concat(name, "=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=").concat(location.host); 1061 }; 1062 1063 /** 1064 * -------------------------------------------------------------------------- 1065 * Button visually impaired (v1.0.0): i18n.js 1066 * Licensed under MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md) 1067 * -------------------------------------------------------------------------- 1068 */ 1069 var lang = { 1070 'ru-RU': { 1071 'text': { 1072 'fontSize': 'Ð Ð°Ð·Ð¼ÐµÑ ÑÑиÑÑа', 1073 'siteColors': 'ЦвеÑа ÑайÑа', 1074 'images': 'ÐзобÑажениÑ', 1075 'speech': 'СинÑез ÑеÑи', 1076 'settings': 'ÐаÑÑÑойки', 1077 'regularVersionOfTheSite': 'ÐбÑÑÐ½Ð°Ñ Ð²ÐµÑÑÐ¸Ñ ÑайÑа', 1078 'letterSpacing': 'ÐежбÑквенное ÑаÑÑÑоÑние', 1079 'normal': 'СÑандаÑÑнÑй', 1080 'average': 'СÑедний', 1081 'big': 'ÐолÑÑой', 1082 'lineHeight': 'ÐежÑÑÑоÑнÑй инÑеÑвал', 1083 'font': 'ШÑиÑÑ', 1084 'arial': 'Ðез заÑеÑек', 1085 'times': 'С заÑеÑками', 1086 'builtElements': 'ÐÑÑÑоеннÑе ÑлеменÑÑ (Ðидео, каÑÑÑ Ð¸ Ñд.)', 1087 'on': 'ÐклÑÑиÑÑ', 1088 'off': 'ÐÑклÑÑиÑÑ', 1089 'reset': 'СбÑоÑиÑÑ Ð½Ð°ÑÑÑойки', 1090 'plural_0': 'пикÑелÑ', 1091 'plural_1': 'пекÑелÑ', 1092 'plural_2': 'пикÑелей' 1093 }, 1094 'voice': { 1095 'fontSizePlus': 'Ð Ð°Ð·Ð¼ÐµÑ ÑÑиÑÑа ÑвелиÌÑен', 1096 'fontSizeMinus': 'Ð Ð°Ð·Ð¼ÐµÑ ÑÑиÑÑа ÑмеÌнÑÑен', 1097 'siteColorBlackOnWhite': 'Ð¦Ð²ÐµÑ ÑайÑа ÑеÑнÑм по беломÑ', 1098 'siteColorWhiteOnBlack': 'Ð¦Ð²ÐµÑ ÑайÑа белÑм по ÑеÑномÑ', 1099 'siteColorDarkBlueOnBlue': 'Ð¦Ð²ÐµÑ ÑайÑа ÑÑмно-Ñиним по голÑбомÑ', 1100 'siteColorBeigeBrown': 'Ð¦Ð²ÐµÑ ÑайÑа коÑиÌÑневÑм по беÌжевомÑ', 1101 'siteColorGreenOnDarkBrown': 'Ð¦Ð²ÐµÑ ÑайÑа зеленÑм по ÑÑмно-коÑиÑневомÑ', 1102 'imagesOn': 'ÐзобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð²ÐºÐ»ÑÑенÑ', 1103 'imagesOFF': 'ÐзобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð²ÑклÑÑенÑ', 1104 'imagesGrayscale': 'ÐзобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÑÑÑно-белÑе', 1105 'speechOn': 'СинÑез ÑеÑи вклÑÑÑн', 1106 'speechOff': 'СинÑез ÑеÑи вÑÌклÑÑен', 1107 'lineHeightNormal': 'ÐежÑÑÑоÑнÑй инÑеÑвал ÑÑандаÑÑнÑй', 1108 'lineHeightAverage': 'ÐежÑÑÑоÑнÑй инÑеÑвал ÑÑедний', 1109 'lineHeightBig': 'ÐежÑÑÑоÑнÑй инÑеÑвал болÑÑой', 1110 'LetterSpacingNormal': 'ÐнÑеÑвал Ð¼ÐµÐ¶Ð´Ñ Ð±Ñквами ÑÑандаÑÑнÑй', 1111 'LetterSpacingAverage': 'ÐнÑеÑвал Ð¼ÐµÐ¶Ð´Ñ Ð±Ñквами ÑÑедний', 1112 'LetterSpacingBig': 'ÐнÑеÑвал Ð¼ÐµÐ¶Ð´Ñ Ð±Ñквами болÑÑой', 1113 'fontArial': 'ШÑиÑÑ Ð±ÐµÐ· заÑеÑек', 1114 'fontTimes': 'ШÑиÑÑ Ñ Ð·Ð°ÑеÑками', 1115 'builtElementsOn': 'ÐÑÑÑоеннÑе ÑлеменÑÑ Ð²ÐºÐ»ÑÑенÑ', 1116 'builtElementsOFF': 'ÐÑÑÑоеннÑе ÑлеменÑÑ Ð²ÑклÑÑенÑ', 1117 'resetSettings': 'УÑÑÐ°Ð½Ð¾Ð²Ð»ÐµÐ½Ñ Ð½Ð°ÑÑÑойки по ÑмолÑаÌниÑ', 1118 'panelShow': 'ÐÐ°Ð½ÐµÐ»Ñ Ð¾ÑкÑÑÑа', 1119 'panelHide': 'ÐÐ°Ð½ÐµÐ»Ñ ÑкÑÑÑа', 1120 'panelOn': 'ÐеÑÑÐ¸Ñ ÑайÑа Ð´Ð»Ñ ÑлабовиÌдÑÑий', 1121 'panelOff': 'ÐбÑÑÐ½Ð°Ñ Ð²ÐµÑÑÐ¸Ñ ÑайÑа' 1122 } 1123 }, 1124 'en-US': { 1125 'text': { 1126 'fontSize': 'Font size', 1127 'siteColors': 'Site colors', 1128 'images': 'Images', 1129 'speech': 'Speech synthesis', 1130 'settings': 'Settings', 1131 'regularVersionOfTheSite': 'Regular version Of The site', 1132 'letterSpacing': 'Letter spacing', 1133 'normal': 'Single', 1134 'average': 'One and a half', 1135 'big': 'Double', 1136 'lineHeight': 'Line spacing', 1137 'font': 'Font',
1138 'arial': 'Sans Serif - Arial', 1139 'times': 'Serif - Times New Roman', 1140 'builtElements': 'Include inline elements (Videos, maps, etc.)', 1141 'on': 'Enable', 1142 'off': 'Disabled', 1143 'reset': 'Reset settings', 1144 'plural_0': 'pixel', 1145 'plural_1': 'pixels', 1146 'plural_2': 'pixels' 1147 }, 1148 'voice': { 1149 'fontSizePlus': 'Font size increased', 1150 'fontSizeMinus': 'Font size reduced', 1151 'siteColorBlackOnWhite': 'Site color black on white', 1152 'siteColorWhiteOnBlack': 'Site color white on black', 1153 'siteColorDarkBlueOnBlue': 'Site color dark blue on cyan', 1154 'siteColorBeigeBrown': 'SiteColorBeigeBrown', 1155 'siteColorGreenOnDarkBrown': 'Site color green on dark brown', 1156 'imagesOn': 'Images enable', 1157 'imagesOFF': 'Images disabled', 1158 'imagesGrayscale': 'Images gray scale', 1159 'speechOn': 'Synthesis speech enable', 1160 'speechOff': 'Synthesis speech disabled', 1161 'lineHeightNormal': 'Line spacing single', 1162 'lineHeightAverage': 'Line spacing one and a half', 1163 'lineHeightBig': 'Line spacing double', 1164 'LetterSpacingNormal': 'Letter spacing single', 1165 'LetterSpacingAverage': 'Letter spacing one and a half', 1166 'LetterSpacingBig': 'Letter spacing letter double', 1167 'fontArial': 'Sans Serif - Arial', 1168 'fontTimes': 'Serif - Times New Roman', 1169 'builtElementsOn': 'Include inline elements are enabled', 1170 'builtElementsOFF': 'Include inline elements are disabled', 1171 'resetSettings': 'Default settings have been set', 1172 'panelShow': 'Panel show', 1173 'panelHide': 'Panel hide', 1174 'panelOn': 'Site version for visually impaired', 1175 'panelOff': 'Regular version of the site' 1176 } 1177 } 1178 }; 1179 1180 var I18n = /*#__PURE__*/function () { 1181 function I18n(options) { 1182 _classCallCheck(this, I18n); 1183 1184 this._config = options; 1185 } 1186 1187 _createClass(I18n, [{ 1188 key: "t", 1189 value: function t(key) { 1190 return lang[this._config.lang]['text'][key]; 1191 } 1192 }, { 1193 key: "v", 1194 value: function v(key) { 1195 return lang[this._config.lang]['voice'][key]; 1196 } 1197 }]); 1198 1199 return I18n; 1200 }(); 1201 1202 /** 1203 * ------------------------------------------------------------------------ 1204 * Constants 1205 * ------------------------------------------------------------------------ 1206 */ 1207 1208 var Default = { 1209 target: '.bvi-open', 1210 fontSize: 16, 1211 theme: 'white', 1212 images: 'grayscale', 1213 letterSpacing: 'normal', 1214 lineHeight: 'normal', 1215 speech: true, 1216 fontFamily: 'arial', 1217 builtElements: false, 1218 panelFixed: true, 1219 panelHide: false, 1220 reload: false, 1221 lang: 'ru-RU' 1222 }; 1223 var DefaultType = { 1224 target: 'string', 1225 fontSize: 'number', 1226 theme: 'string', 1227 images: '(string|boolean)', 1228 letterSpacing: 'string', 1229 lineHeight: 'string', 1230 speech: 'boolean', 1231 fontFamily: 'string', 1232 builtElements: 'boolean', 1233 panelFixed: 'boolean', 1234 panelHide: 'boolean', 1235 reload: 'boolean', 1236 lang: 'string' 1237 }; 1238 var DefaultOptions = { 1239 target: '', 1240 fontSize: '(^[1-9]$|^[1-3][0-9]?$|^39$)', 1241 theme: '(white|black|blue|brown|green)', 1242 images: '(true|false|grayscale)', 1243 letterSpacing: '(normal|average|big)', 1244 lineHeight: '(normal|average|big)', 1245 speech: '(true|false)', 1246 fontFamily: '(arial|times)', 1247 builtElements: '(true|false)', 1248 panelFixed: '(true|false)', 1249 panelHide: '(true|false)', 1250 reload: '(true|false)', 1251 lang: '(ru-RU|en-US)' 1252 }; 1253 /** 1254 * ------------------------------------------------------------------------ 1255 * Class Definition 1256 * ------------------------------------------------------------------------ 1257 */ 1258 1259 var Bvi = /*#__PURE__*/function () { 1260 function Bvi(options) { 1261 _classCallCheck(this, Bvi); 1262 1263 this._config = this._getConfig(options); 1264 this._elements = document.querySelectorAll(this._config.target); 1265 this._i18n = new I18n({ 1266 lang: this._config.lang 1267 }); 1268 1269 this._addEventListeners(); 1270 1271 this._init(); 1272 1273 //console.log('Bvi console: ready Button visually impaired v1.0.0'); 1274 } // Private 1275 1276 1277 _createClass(Bvi, [{ 1278 key: "_init", 1279 value: function _init() { 1280 getObject(this._config, function (key) { 1281 if (typeof getCookie(key) === 'undefined') { 1282 removeCookie('panelActive'); 1283 } 1284 }); 1285 1286 if (stringToBoolean(getCookie('panelActive'))) { 1287 this._set(); 1288 1289 this._getPanel(); 1290
1291 this._addEventListenersPanel(); 1292 1293 this._images(); 1294 1295 this._speechPlayer(); 1296 1297 if ('speechSynthesis' in window && stringToBoolean(getCookie('speech'))) { 1298 setInterval(function () { 1299 if (synth().pending === false) { 1300 var play = document.querySelectorAll('.bvi-speech-play'); 1301 var pause = document.querySelectorAll('.bvi-speech-pause'); 1302 var resume = document.querySelectorAll('.bvi-speech-resume'); 1303 var stop = document.querySelectorAll('.bvi-speech-stop'); 1304 1305 var el = function el(elements, callback) { 1306 elements.forEach(function (element) { 1307 return callback(element); 1308 }); 1309 }; 1310 1311 el(play, function (element) { 1312 return element.classList.remove('disabled'); 1313 }); 1314 el(pause, function (element) { 1315 return element.classList.add('disabled'); 1316 }); 1317 el(resume, function (element) { 1318 return element.classList.add('disabled'); 1319 }); 1320 el(stop, function (element) { 1321 return element.classList.add('disabled'); 1322 }); 1323 } 1324 }, 1000); 1325 } 1326 } else { 1327 this._remove(); 1328 } 1329 } 1330 }, { 1331 key: "_addEventListeners", 1332 value: function _addEventListeners() { 1333 var _this = this; 1334 1335 if (!this._elements) { 1336 return false; 1337 } 1338 1339 this._elements.forEach(function (element) { 1340 element.addEventListener('click', function (event) { 1341 event.preventDefault(); 1342 getObject(_this._config, function (key) { 1343 return setCookie(key, _this._config[key]); 1344 }); 1345 setCookie('panelActive', true); 1346 1347 _this._init(); 1348 1349 _this._speech("".concat(_this._i18n.v('panelOn'))); 1350 }); 1351 }); 1352 } 1353 }, { 1354 key: "_addEventListenersPanel", 1355 value: function _addEventListenersPanel() { 1356 var _this2 = this; 1357 1358 var elements = { 1359 fontSizeMinus: document.querySelector('.bvi-fontSize-minus'), 1360 fontSizePlus: document.querySelector('.bvi-fontSize-plus'), 1361 themeWhite: document.querySelector('.bvi-theme-white'), 1362 themeBlack: document.querySelector('.bvi-theme-black'), 1363 themeBlue: document.querySelector('.bvi-theme-blue'), 1364 themeBrown: document.querySelector('.bvi-theme-brown'), 1365 themeGreen: document.querySelector('.bvi-theme-green'), 1366 imagesOn: document.querySelector('.bvi-images-on'), 1367 imagesOff: document.querySelector('.bvi-images-off'), 1368 imagesGrayscale: document.querySelector('.bvi-images-grayscale'), 1369 speechOn: document.querySelector('.bvi-speech-on'), 1370 speechOff: document.querySelector('.bvi-speech-off'), 1371 lineHeightNormal: document.querySelector('.bvi-line-height-normal'), 1372 lineHeightAverage: document.querySelector('.bvi-line-height-average'), 1373 lineHeightBig: document.querySelector('.bvi-line-height-big'), 1374 letterSpacingNormal: document.querySelector('.bvi-letter-spacing-normal'), 1375 letterSpacingAverage: document.querySelector('.bvi-letter-spacing-average'), 1376 letterSpacingBig: document.querySelector('.bvi-letter-spacing-big'), 1377 fontFamilyArial: document.querySelector('.bvi-font-family-arial'), 1378 fontFamilyTimes: document.querySelector('.bvi-font-family-times'), 1379 builtElementsOn: document.querySelector('.bvi-built-elements-on'), 1380 builtElementsOff: document.querySelector('.bvi-built-elements-off'), 1381 reset: document.querySelector('.bvi-reset'), 1382 links: document.querySelectorAll('.bvi-link'), 1383 modal: document.querySelector('.bvi-modal') 1384 }; 1385 1386 var activeLink = function activeLink(element) { 1387 var _iterator = _createForOfIteratorHelper(element.parentNode.children), 1388 _step; 1389 1390 try { 1391 for (_iterator.s();
1391 !(_step = _iterator.n()).done;) { 1392 var sibling = _step.value; 1393 sibling.classList.remove('active'); 1394 } 1395 } catch (err) { 1396 _iterator.e(err); 1397 } finally { 1398 _iterator.f(); 1399 } 1400 1401 element.classList.add('active'); 1402 }; 1403 1404 var click = function click(element, callback) { 1405 element.addEventListener('click', function (event) { 1406 event.preventDefault(); 1407 1408 if (typeof callback === 'function') { 1409 callback(event); 1410 } 1411 }); 1412 }; 1413 1414 var activeAll = function activeAll() { 1415 var links = document.querySelectorAll('.bvi-link'); 1416 links.forEach(function (link) { 1417 link.classList.remove('active'); 1418 }); 1419 getObject(_this2._config, function (key) { 1420 if (key === 'theme') { 1421 var value = getCookie(key); 1422 document.querySelector(".bvi-theme-".concat(value)).classList.add('active'); 1423 } 1424 1425 if (key === 'images') { 1426 var _value = getCookie(key) === 'grayscale' ? 'grayscale' : stringToBoolean(getCookie(key)) ? 'on' : 'off'; 1427 1428 document.querySelector(".bvi-images-".concat(_value)).classList.add('active'); 1429 } 1430 1431 if (key === 'speech') { 1432 var _value2 = stringToBoolean(getCookie(key)) ? 'on' : 'off'; 1433 1434 document.querySelector(".bvi-speech-".concat(_value2)).classList.add('active'); 1435 } 1436 1437 if (key === 'lineHeight') { 1438 var _value3 = getCookie(key); 1439 1440 document.querySelector(".bvi-line-height-".concat(_value3)).classList.add('active'); 1441 } 1442 1443 if (key === 'letterSpacing') { 1444 var _value4 = getCookie(key); 1445 1446 document.querySelector(".bvi-letter-spacing-".concat(_value4)).classList.add('active'); 1447 } 1448 1449 if (key === 'fontFamily') { 1450 var _value5 = getCookie(key); 1451 1452 document.querySelector(".bvi-font-family-".concat(_value5)).classList.add('active'); 1453 } 1454 1455 if (key === 'builtElements') { 1456 var _value6 = stringToBoolean(getCookie(key)) ? 'on' : 'off'; 1457 1458 document.querySelector(".bvi-built-elements-".concat(_value6)).classList.add('active'); 1459 } 1460 }); 1461 }; 1462 1463 activeAll(); // Font size 1464 1465 click(elements.fontSizeMinus, function () { 1466 var size = parseFloat(getCookie('fontSize')) - 1; 1467 1468 if (size !== 0) { 1469 _this2._setAttrDataBviBody('fontSize', size); 1470 1471 setCookie('fontSize', size); 1472 1473 _this2._speech("".concat(_this2._i18n.v('fontSizeMinus'))); 1474 1475 activeLink(elements.fontSizeMinus); 1476 } 1477 }); 1478 click(elements.fontSizePlus, function () { 1479 var size = parseFloat(getCookie('fontSize')) + 1; 1480 1481 if (size !== 40) { 1482 _this2._setAttrDataBviBody('fontSize', size); 1483 1484 setCookie('fontSize', size); 1485 1486 _this2._speech("".concat(_this2._i18n.v('fontSizePlus'))); 1487 1488 activeLink(elements.fontSizePlus); 1489 } 1490 }); // Theme 1491 1492 click(elements.themeWhite, function () { 1493 _this2._setAttrDataBviBody('theme', 'white'); 1494 1495 setCookie('theme', 'white'); 1496 1497 _this2._speech("".concat(_this2._i18n.v('siteColorBlackOnWhite'))); 1498 1499 activeLink(elements.themeWhite); 1500 }); 1501 click(elements.themeBlack, function () { 1502 _this2._setAttrDataBviBody('theme', 'black'); 1503 1504 setCookie('theme', 'black'); 1505 1506 _this2._speech("".concat(_this2._i18n.v('siteColorWhiteOnBlack'))); 1507 1508 activeLink(elements.themeBlack); 1509 }); 1510 click(elements.themeBlue, function () { 1511 _this2._setAttrDataBviBody('theme', 'blue'); 1512 1513 setCookie('theme', 'blue'); 1514 1515 _this2._speech("".concat(_this2._i18n.v('siteColorDarkBlueOnBlue'))); 1516 1517 activeLink(elements.themeBlue); 1518 }); 1519 click(elements.themeBrown, function () {
1520 _this2._setAttrDataBviBody('theme', 'brown'); 1521 1522 setCookie('theme', 'brown'); 1523 1524 _this2._speech("".concat(_this2._i18n.v('siteColorBeigeBrown'))); 1525 1526 activeLink(elements.themeBrown); 1527 }); 1528 click(elements.themeGreen, function () { 1529 _this2._setAttrDataBviBody('theme', 'green'); 1530 1531 setCookie('theme', 'green'); 1532 1533 _this2._speech("".concat(_this2._i18n.v('siteColorGreenOnDarkBrown'))); 1534 1535 activeLink(elements.themeGreen); 1536 }); // Images 1537 1538 click(elements.imagesOn, function () { 1539 _this2._setAttrDataBviBody('images', 'true'); 1540 1541 setCookie('images', 'true'); 1542 1543 _this2._speech("".concat(_this2._i18n.v('imagesOn'))); 1544 1545 activeLink(elements.imagesOn); 1546 }); 1547 click(elements.imagesOff, function () { 1548 _this2._setAttrDataBviBody('images', 'false'); 1549 1550 setCookie('images', 'false'); 1551 1552 _this2._speech("".concat(_this2._i18n.v('imagesOFF'))); 1553 1554 activeLink(elements.imagesOff); 1555 }); 1556 click(elements.imagesGrayscale, function () { 1557 _this2._setAttrDataBviBody('images', 'grayscale'); 1558 1559 setCookie('images', 'grayscale'); 1560 1561 _this2._speech("".concat(_this2._i18n.v('imagesGrayscale'))); 1562 1563 activeLink(elements.imagesGrayscale); 1564 }); // Speech 1565 1566 click(elements.speechOn, function () { 1567 _this2._setAttrDataBviBody('speech', 'true'); 1568 1569 setCookie('speech', 'true'); 1570 1571 _this2._speech("".concat(_this2._i18n.v('speechOn'))); 1572 1573 activeLink(elements.speechOn); 1574 1575 _this2._speechPlayer(); 1576 }); 1577 click(elements.speechOff, function () { 1578 _this2._speech("".concat(_this2._i18n.v('speechOff'))); 1579 1580 _this2._setAttrDataBviBody('speech', 'false'); 1581 1582 setCookie('speech', 'false'); 1583 activeLink(elements.speechOff); 1584 1585 _this2._speechPlayer(); 1586 }); // Line height 1587 1588 click(elements.lineHeightNormal, function () { 1589 _this2._setAttrDataBviBody('lineHeight', 'normal'); 1590 1591 setCookie('lineHeight', 'normal'); 1592 1593 _this2._speech("".concat(_this2._i18n.v('lineHeightNormal'))); 1594 1595 activeLink(elements.lineHeightNormal); 1596 }); 1597 click(elements.lineHeightAverage, function () { 1598 _this2._setAttrDataBviBody('lineHeight', 'average'); 1599 1600 setCookie('lineHeight', 'average'); 1601 1602 _this2._speech("".concat(_this2._i18n.v('lineHeightAverage'))); 1603 1604 activeLink(elements.lineHeightAverage); 1605 }); 1606 click(elements.lineHeightBig, function () { 1607 _this2._setAttrDataBviBody('lineHeight', 'big'); 1608 1609 setCookie('lineHeight', 'big'); 1610 1611 _this2._speech("".concat(_this2._i18n.v('lineHeightBig'))); 1612 1613 activeLink(elements.lineHeightBig); 1614 }); // Letter spacing 1615 1616 click(elements.letterSpacingNormal, function () { 1617 _this2._setAttrDataBviBody('letterSpacing', 'normal'); 1618 1619 setCookie('letterSpacing', 'normal'); 1620 1621 _this2._speech("".concat(_this2._i18n.v('LetterSpacingNormal'))); 1622 1623 activeLink(elements.letterSpacingNormal); 1624 }); 1625 click(elements.letterSpacingAverage, function () { 1626 _this2._setAttrDataBviBody('letterSpacing', 'average'); 1627 1628 setCookie('letterSpacing', 'average'); 1629 1630 _this2._speech("".concat(_this2._i18n.v('LetterSpacingAverage'))); 1631 1632 activeLink(elements.letterSpacingAverage); 1633 }); 1634 click(elements.letterSpacingBig, function () { 1635 _this2._setAttrDataBviBody('letterSpacing', 'big'); 1636 1637 setCookie('letterSpacing', 'big'); 1638 1639 _this2._speech("".concat(_this2._i18n.v('LetterSpacingBig'))); 1640 1641 activeLink(elements.letterSpacingBig); 1642 }); // Font family 1643 1644 click(elements.fontFamilyArial, function () { 1645 _this2._setAttrDataBviBody('fontFamily', 'arial'); 1646 1647 setCookie('fontFamily', 'arial'); 1648 1649 _this2._speech("".concat(_this2._i18n.v('fontArial'))); 1650
1651 activeLink(elements.fontFamilyArial); 1652 }); 1653 click(elements.fontFamilyTimes, function () { 1654 _this2._setAttrDataBviBody('fontFamily', 'times'); 1655 1656 setCookie('fontFamily', 'times'); 1657 1658 _this2._speech("".concat(_this2._i18n.v('fontTimes'))); 1659 1660 activeLink(elements.fontFamilyTimes); 1661 }); // Built elements 1662 1663 click(elements.builtElementsOn, function () { 1664 _this2._setAttrDataBviBody('builtElements', 'true'); 1665 1666 setCookie('builtElements', 'true'); 1667 1668 _this2._speech("".concat(_this2._i18n.v('builtElementsOn'))); 1669 1670 activeLink(elements.builtElementsOn); 1671 }); 1672 click(elements.builtElementsOff, function () { 1673 _this2._setAttrDataBviBody('builtElements', 'false'); 1674 1675 setCookie('builtElements', 'false'); 1676 1677 _this2._speech("".concat(_this2._i18n.v('builtElementsOFF'))); 1678 1679 activeLink(elements.builtElementsOff); 1680 }); // Reset 1681 1682 click(elements.reset, function () { 1683 _this2._speech("".concat(_this2._i18n.v('resetSettings'))); 1684 1685 getObject(_this2._config, function (key) { 1686 _this2._setAttrDataBviBody(key, _this2._config[key]); 1687 1688 setCookie(key, _this2._config[key]); 1689 activeAll(); 1690 }); 1691 }); 1692 getArray(elements.links, function (element) { 1693 click(element, function (event) { 1694 var target = event.target.getAttribute('data-bvi'); 1695 1696 if (target === 'close') { 1697 _this2._setAttrDataBviBody('panelActive', 'false'); 1698 1699 setCookie('panelActive', 'false'); 1700 1701 _this2._init(); 1702 } 1703 1704 if (target === 'modal') { 1705 document.body.style.overflow = 'hidden'; 1706 document.body.classList.add('bvi-noscroll'); 1707 elements.modal.classList.toggle('show'); 1708 } 1709 1710 if (target === 'modal-close') { 1711 document.body.classList.remove('bvi-noscroll'); 1712 document.body.style.overflow = ''; 1713 elements.modal.classList.remove('show'); 1714 } 1715 1716 if (target === 'panel-hide') { 1717 document.querySelector('.bvi-panel').classList.add('bvi-panel-hide'); 1718 document.querySelector('.bvi-link-fixed-top').classList.remove('bvi-hide'); 1719 document.querySelector('.bvi-link-fixed-top').classList.add('bvi-show'); 1720 setCookie('panelHide', 'true'); 1721 1722 _this2._speech("".concat(_this2._i18n.v('panelHide'))); 1723 } 1724 1725 if (target === 'panel-show') { 1726 document.querySelector('.bvi-link-fixed-top').classList.remove('bvi-show'); 1727 document.querySelector('.bvi-link-fixed-top').classList.add('bvi-hide'); 1728 document.querySelector('.bvi-panel').classList.remove('bvi-panel-hide'); 1729 setCookie('panelHide', 'false'); 1730 1731 _this2._speech("".concat(_this2._i18n.v('panelShow'))); 1732 } 1733 }); 1734 }); 1735 click(elements.modal, function (event) { 1736 if (event.target.contains(elements.modal)) { 1737 document.body.classList.remove('bvi-noscroll'); 1738 document.body.style.overflow = ''; 1739 elements.modal.classList.remove('show'); 1740 } 1741 }); 1742 } 1743 }, { 1744 key: "_getPanel", 1745 value: function _getPanel() { 1746 var scroll = function scroll() { 1747 var scroll = window.pageYOffset !== undefined ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; 1748 1749 if (stringToBoolean(getCookie('panelFixed'))) { 1750 if (scroll > 200) { 1751 document.querySelector('.bvi-panel').classList.add('bvi-fixed-top'); 1752 } else { 1753 document.querySelector('.bvi-panel').classList.remove('bvi-fixed-top'); 1754 } 1755 } 1756 }; 1757 1758 var panelHide = stringToBoolean(getCookie('panelHide')) ? ' bvi-panel-hide' : ''; 1759 var linkHide = !stringToBoolean(getCookie('panelHide')) ? ' bvi-hide' : 'bvi-show'; 1760 var html = "\n <div class='bvi-panel".concat(panelHide, "'>\n <div class=\"bvi-blocks bvi-block-center\">\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('fontSize'), "</div>\n <a class=\"bvi-link bvi-fontSize-minus\">\u0410-</a>\n <a class=\"bvi-link bvi-fontSize-plus\">\u0410+</a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('siteColors'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-theme-white\">\u0426</a>\n <a href=\"#\" class=\"bvi-link bvi-theme-black\">\u0426</a>\n <a href=\"#\" class=\"bvi-link bvi-theme-blue\">\u0426</a>\n <a href=\"#\" class=\"bvi-link bvi-theme-brown\">\u0426</a>\n <a href=\"#\" class=\"bvi-link bvi-theme-green\">\u0426</a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('images'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-images-on\">\n <i class=\"bvi-images bvi-images-image\"></i>\n </a>\n <a href=\"#\" class=\"bvi-link bvi-images-off\">\n <i class=\"bvi-images bvi-images-minus-circle\"></i>\n </a>\n <a href=\"#\" class=\"bvi-link bvi-images-grayscale\">\n <i class=\"bvi-images bvi-images-adjust\"></i>\n </a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('speech'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-speech-off\">\n <i class=\"bvi-images bvi-images-volume-off\"></i>\n </a>\n <a href=\"#\" class=\"bvi-link bvi-speech-on\">\n <i class=\"bvi-images bvi-images-volume-up\"></i>\n </a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('settings'), "</div>\n <a href=\"#\" class=\"bvi-link\" data-bvi=\"modal\">\n <i class=\"bvi-images bvi-images-cog\"></i>\n </a>\n <a href=\"#\" class=\"bvi-link\" data-bvi=\"close\">\n ").concat(this._i18n.t('regularVersionOfTheSite'), "\n </a>\n <a href=\"#\" class=\"bvi-link\" data-bvi=\"panel-hide\">\n <i class=\"bvi-images bvi-images-minus\"></i>\n </a>\n </div>\n </div>\n <div class=\"bvi-modal\">\n <div class=\"bvi-modal-dialog\">\n <div class=\"bvi-modal-content\">\n <div class=\"bvi-modal-header\">\n <div class=\"bvi-modal-title\">").concat(this._i18n.t('settings'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-modal-close\" data-bvi=\"modal-close\">\xD7</a>\n </div>\n <div class=\"bvi-modal-body\">\n <div class=\"bvi-blocks bvi-block-center\">\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('letterSpacing'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-letter-spacing-normal\">").concat(this._i18n.t('normal'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-letter-spacing-average\">").concat(this._i18n.t('average'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-letter-spacing-big\">").concat(this._i18n.t('big'), "</a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('lineHeight'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-line-height-normal\">").concat(this._i18n.t('normal'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-line-height-average\">").concat(this._i18n.t('average'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-line-height-big\">").concat(this._i18n.t('big'), "</a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('font'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-font-family-arial\">").concat(this._i18n.t('arial'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-font-family-times\">").concat(this._i18n.t('times'), "</a>\n </div>\n <div class=\"bvi-block\">\n <div class=\"bvi-block-title\">").concat(this._i18n.t('builtElements'), "</div>\n <a href=\"#\" class=\"bvi-link bvi-built-elements-on\">").concat(this._i18n.t('on'), "</a>\n <a href=\"#\" class=\"bvi-link bvi-built-elements-off\">").concat(this._i18n.t('off'), "</a>\n </div>\n </div>\n <div class=\"bvi-blocks bvi-block-center\">\n <a href=\"https://bvi.isvek.ru\" class=\"bvi-copyright\" target=\"_blank\">bvi.isvek.ru</a>\n </div>\n </div>\n <div class=\"bvi-modal-footer\">\n <a href=\"#\" class=\"bvi-link bvi-reset\">").concat(this._i18n.t('reset'), "</a>\n </div>\n </div>\n </div>\n </div>\n </div>"); 1761 var link = "<a href=\"#\" class=\"bvi-link bvi-link-fixed-top bvi-no-styles ".concat(linkHide, "\" data-bvi=\"panel-show\">") + '<i class="bvi-images bvi-images-eye bvi-images-size-32 bvi-no-styles"></i></a>'; 1762 window.addEventListener('scroll', scroll); 1763 document.querySelector('.bvi-body').insertAdjacentHTML('beforebegin', html); 1764 document.querySelector('.bvi-body').insertAdjacentHTML('afterbegin', link); 1765 scroll(); 1766 } 1767 }, {
1768 key: "_set", 1769 value: function _set() { 1770 var _this3 = this; 1771 1772 document.body.classList.add('bvi-active'); 1773 wrapInner(document.body, 'div', 'bvi-body'); 1774 getObject(this._config, function (key) { 1775 return _this3._setAttrDataBviBody(key, getCookie(key)); 1776 }); 1777 getArray(this._elements, function (element) { 1778 return element.style.display = 'none'; 1779 }); 1780 document.querySelectorAll('img').forEach(function (element) { 1781 if (element.classList.contains('bvi-img')) { 1782 element.classList.remove('bvi-img'); 1783 } 1784 }); 1785 document.querySelectorAll('body *').forEach(function (element) { 1786 if (element.classList.contains('bvi-background-image')) { 1787 element.classList.remove('bvi-background-image'); 1788 } 1789 }); 1790 } 1791 }, { 1792 key: "_remove", 1793 value: function _remove() { 1794 var bviPanel = document.querySelector('.bvi-panel'); 1795 var bviBody = document.querySelector('.bvi-body'); 1796 var bviLinkFixedTop = document.querySelector('.bvi-link-fixed-top'); 1797 1798 if (bviPanel) { 1799 bviPanel.remove(); 1800 } 1801 1802 if (bviBody) { 1803 unwrap(bviBody); 1804 } 1805 1806 if (bviLinkFixedTop) { 1807 bviLinkFixedTop.remove(); 1808 } 1809 1810 this._speech("".concat(this._i18n.v('panelOff'))); 1811 1812 document.body.classList.remove('bvi-active'); 1813 getArray(this._elements, function (element) { 1814 return element.style.display = ''; 1815 }); 1816 1817 if (stringToBoolean(getCookie('reload'))) { 1818 document.location.reload(); 1819 } 1820 1821 getObject(this._config, function (key) { 1822 removeCookie(key); 1823 }); 1824 1825 this._speechPlayer(); 1826 1827 removeCookie('panelActive'); 1828 } 1829 }, { 1830 key: "_images", 1831 value: function _images() { 1832 document.querySelectorAll('img').forEach(function (element) { 1833 if (!element.classList.contains('bvi-no-style')) { 1834 element.classList.add('bvi-img'); 1835 } 1836 }); 1837 document.querySelectorAll('.bvi-body *').forEach(function (element) { 1838 var style = getComputedStyle(element); 1839 1840 if (style.backgroundImage !== 'none' && style.background !== 'none' && !element.classList.contains('bvi-no-style')) { 1841 element.classList.add('bvi-background-image'); 1842 } 1843 }); 1844 } 1845 }, { 1846 key: "_getConfig", 1847 value: function _getConfig(config) { 1848 config = _objectSpread2(_objectSpread2({}, Default), config); 1849 var extended = {}; 1850 1851 for (var keyDefault in Default) { 1852 extended[keyDefault] = config[keyDefault]; 1853 } 1854 1855 checkConfig(extended, DefaultType, DefaultOptions); 1856 return extended; 1857 } 1858 }, { 1859 key: "_setAttrDataBviBody", 1860 value: function _setAttrDataBviBody() { 1861 var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 1862 var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 1863 document.querySelector('.bvi-body').setAttribute("data-bvi-".concat(name), value); 1864 } 1865 }, { 1866 key: "_speechPlayer", 1867 value: function _speechPlayer() { 1868 var _this4 = this; 1869 1870 var selectorSpeechText = document.querySelectorAll('.bvi-speech-text'); 1871 var selectorSpeechLink = document.querySelectorAll('.bvi-speech-link'); 1872 var selectorBviSpeech = document.querySelectorAll('.bvi-speech'); 1873 1874 if ('speechSynthesis' in window && stringToBoolean(getCookie('speech'))) { 1875 if (selectorBviSpeech) { 1876 if (selectorSpeechText) { 1877 selectorSpeechText.forEach(function (element) { 1878 return unwrap(element); 1879 }); 1880 } 1881 1882 if (selectorSpeechLink) { 1883 selectorSpeechLink.forEach(function (element) { 1884 return element.remove(); 1885 }); 1886 } 1887 1888 selectorBviSpeech.forEach(function (speechDivBlock, index) { 1889 var id = "bvi-speech-text-id-".concat(index + 1); 1890 var html = "\n <div class=\"bvi-speech-link\">\n <a href=\"#\" class=\"bvi-link bvi-speech-play\" title=\"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438\">\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438</a>\n <a href=\"#\" class=\"bvi-link bvi-speech-pause disabled\" title=\"\u041F\u0430\u0443\u0437\u0430\">\u041F\u0430\u0443\u0437\u0430</a>\n <a href=\"#\" class=\"bvi-link bvi-speech-resume disabled\" title=\"\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C\">\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C</a>\n <a href=\"#\" class=\"bvi-link bvi-speech-stop disabled\" title=\"\u0421\u0442\u043E\u043F\">\u0421\u0442\u043E\u043F</i></a>\n </div>"; 1891 wrapInner(speechDivBlock, 'div', "bvi-speech-text ".concat(id)); 1892 speechDivBlock.insertAdjacentHTML('afterbegin', html); 1893 }); 1894 var selectorPlay = document.querySelectorAll('.bvi-speech-play'); 1895 var selectorPause = document.querySelectorAll('.bvi-speech-pause'); 1896 var selectorResume = document.querySelectorAll('.bvi-speech-resume'); 1897 var selectorStop = document.querySelectorAll('.bvi-speech-stop'); 1898 1899 var el = function el(elements, callback) {
1900 elements.forEach(function (element) { 1901 element.addEventListener('click', function (event) { 1902 event.preventDefault(); 1903 1904 if (typeof callback === 'function') { 1905 return callback(element, event); 1906 } 1907 }, false); 1908 }); 1909 }; 1910 1911 el(selectorPlay, function (element, event) { 1912 var target = event.target; 1913 var text = target.parentNode.nextElementSibling; 1914 var closest = event.target.closest('.bvi-speech-link'); 1915 var play = document.querySelectorAll('.bvi-speech-play'); 1916 var pause = document.querySelectorAll('.bvi-speech-pause'); 1917 var resume = document.querySelectorAll('.bvi-speech-resume'); 1918 var stop = document.querySelectorAll('.bvi-speech-stop'); 1919 1920 _this4._speech(text.textContent, text, true); 1921 1922 play.forEach(function (element) { 1923 return element.classList.remove('disabled'); 1924 }); 1925 pause.forEach(function (element) { 1926 return element.classList.add('disabled'); 1927 }); 1928 resume.forEach(function (element) { 1929 return element.classList.add('disabled'); 1930 }); 1931 stop.forEach(function (element) { 1932 return element.classList.add('disabled'); 1933 }); 1934 target.classList.add('disabled'); 1935 closest.querySelector('.bvi-speech-pause').classList.remove('disabled'); 1936 closest.querySelector('.bvi-speech-stop').classList.remove('disabled'); 1937 }); 1938 el(selectorPause, function (element, event) { 1939 var target = event.target; 1940 var closest = event.target.closest('.bvi-speech-link'); 1941 target.classList.add('disabled'); 1942 closest.querySelector('.bvi-speech-resume').classList.remove('disabled'); 1943 synth().pause(); 1944 }); 1945 el(selectorResume, function (element, event) { 1946 var target = event.target; 1947 var closest = event.target.closest('.bvi-speech-link'); 1948 target.classList.add('disabled'); 1949 closest.querySelector('.bvi-speech-pause').classList.remove('disabled'); 1950 synth().resume(); 1951 }); 1952 el(selectorStop, function (element, event) { 1953 var target = event.target; 1954 var closest = event.target.closest('.bvi-speech-link'); 1955 target.classList.add('disabled'); 1956 closest.querySelector('.bvi-speech-pause').classList.add('disabled'); 1957 closest.querySelector('.bvi-speech-play').classList.remove('disabled'); 1958 synth().cancel(); 1959 }); 1960 } 1961 } else { 1962 if (selectorSpeechText) { 1963 selectorSpeechText.forEach(function (element) { 1964 return unwrap(element); 1965 }); 1966 } 1967 1968 if (selectorSpeechLink) { 1969 selectorSpeechLink.forEach(function (element) { 1970 return element.remove(); 1971 }); 1972 } 1973 } 1974 } 1975 }, { 1976 key: "_speech", 1977 value: function _speech(text, element) { 1978 var _this5 = this; 1979 1980 var echo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 1981 1982 if ('speechSynthesis' in window && stringToBoolean(getCookie('speech'))) { 1983 synth().cancel(); 1984 1985 var getWordAt = function getWordAt(str, pos) { 1986 str = String(str); 1987 pos = Number(pos) >>> 0; 1988 var left = str.slice(0, pos + 1).search(/\S+$/); 1989 var right = str.slice(pos).search(/\s/); 1990 1991 if (right < 0) { 1992 return str.slice(left); 1993 } 1994 1995 return str.slice(left, right + pos); 1996 }; 1997 1998 var chunkLength = 120; 1999 var patternRegex = new RegExp('^[\\s\\S]{' + Math.floor(chunkLength / 2) + ',' + chunkLength + '}[.!?,]{1}|^[\\s\\S]{1,' + chunkLength + '}$|^[\\s\\S]{1,' + chunkLength + '} '); 2000 var array = []; 2001 var $text = text; 2002 var voices = synth().getVoices(); 2003 2004 while ($text.length > 0) { 2005 array.push($text.match(patternRegex)[0]); 2006 $text = $text.substring(array[array.length - 1].length); 2007 } 2008 2009 array.forEach(function (getText) { 2010 var utter = new SpeechSynthesisUtterance(getText.trim()); 2011 utter.volume = 1; 2012 utter.rate = 1; 2013 utter.pitch = 1; 2014 utter.lang = _this5._config.lang; 2015 2016 for (var i = 0; i < voices.length; i++) { 2017 if (_this5._config.lang === 'ru-RU' && voices[i].name === 'Microsoft Pavel - Russian (Russia)') { 2018 utter.voice = voices[i]; 2019 } 2020 2021 if (_this5._config.lang === 'en-US' && voices[i].name === 'Microsoft Pavel - English (English)') { 2022 utter.voice = voices[i]; 2023 } 2024 } 2025 2026 if (echo) { 2027 utter.onboundary = function (event) { 2028 element.classList.add('bvi-highlighting'); 2029 var world = getWordAt(event.utterance.text, event.charIndex); 2030 var textContent = element.textContent; 2031 var term = world.replace(/(\s+)/, '((<[^>]+>)*$1(<[^>
2031]+>)*)'); 2032 var pattern = new RegExp('(' + term + ')', 'gi'); 2033 textContent = textContent.replace(pattern, '<mark>$1</mark>'); 2034 textContent = textContent.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, '$1</mark>$2<mark>$4'); 2035 element.innerHTML = textContent; 2036 }; 2037 2038 utter.onend = function (event) { 2039 element.classList.remove('bvi-highlighting'); 2040 var textContent = element.textContent; 2041 textContent = textContent.replace(/(<mark>$1<\/mark>)/, '$1'); 2042 element.innerHTML = textContent; 2043 }; 2044 } 2045 2046 synth().speak(utter); 2047 }); 2048 } 2049 } 2050 }]); 2051 2052 return Bvi; 2053 }(); 2054 2055 /** 2056 * -------------------------------------------------------------------------- 2057 * Button visually impaired (v1.0.0): index.umd.js 2058 * Licensed under MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md) 2059 * -------------------------------------------------------------------------- 2060 */ 2061 var index_umd = { 2062 Bvi: Bvi 2063 }; 2064 2065 return index_umd; 2066 2067}))); 2068//# sourceMappingURL=bvi.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.