vendor: 50,360 bytes, lines 1-1628
1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.vex = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){ 2/* 3 * classList.js: Cross-browser full element.classList implementation. 4 * 1.1.20170427 5 * 6 * By Eli Grey, http://eligrey.com 7 * License: Dedicated to the public domain. 8 * See https://github.com/eligrey/classList.js/blob/master/LICENSE.md 9 */ 10 11/*global self, document, DOMException */ 12 13/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ 14 15if ("document" in window.self) { 16 17// Full polyfill for browsers with no classList support 18// Including IE < Edge missing SVGElement.classList 19if (!("classList" in document.createElement("_")) 20 || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg","g"))) { 21 22(function (view) { 23 24"use strict"; 25 26if (!('Element' in view)) return; 27 28var 29 classListProp = "classList" 30 , protoProp = "prototype" 31 , elemCtrProto = view.Element[protoProp] 32 , objCtr = Object 33 , strTrim = String[protoProp].trim || function () { 34 return this.replace(/^\s+|\s+$/g, ""); 35 } 36 , arrIndexOf = Array[protoProp].indexOf || function (item) { 37 var 38 i = 0 39 , len = this.length 40 ; 41 for (; i < len; i++) { 42 if (i in this && this[i] === item) { 43 return i; 44 } 45 } 46 return -1; 47 } 48 // Vendors: please allow content code to instantiate DOMExceptions 49 , DOMEx = function (type, message) { 50 this.name = type; 51 this.code = DOMException[type]; 52 this.message = message; 53 } 54 , checkTokenAndGetIndex = function (classList, token) { 55 if (token === "") { 56 throw new DOMEx( 57 "SYNTAX_ERR" 58 , "An invalid or illegal string was specified" 59 ); 60 } 61 if (/\s/.test(token)) { 62 throw new DOMEx( 63 "INVALID_CHARACTER_ERR" 64 , "String contains an invalid character" 65 ); 66 } 67 return arrIndexOf.call(classList, token); 68 } 69 , ClassList = function (elem) { 70 var 71 trimmedClasses = strTrim.call(elem.getAttribute("class") || "") 72 , classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [] 73 , i = 0 74 , len = classes.length 75 ; 76 for (; i < len; i++) { 77 this.push(classes[i]); 78 } 79 this._updateClassName = function () { 80 elem.setAttribute("class", this.toString()); 81 }; 82 } 83 , classListProto = ClassList[protoProp] = [] 84 , classListGetter = function () { 85 return new ClassList(this); 86 } 87; 88// Most DOMException implementations don't allow calling DOMException's toString() 89// on non-DOMExceptions. Error's toString() is sufficient here. 90DOMEx[protoProp] = Error[protoProp]; 91classListProto.item = function (i) { 92 return this[i] || null; 93}; 94classListProto.contains = function (token) { 95 token += ""; 96 return checkTokenAndGetIndex(this, token) !== -1; 97}; 98classListProto.add = function () { 99 var 100 tokens = arguments 101 , i = 0 102 , l = tokens.length 103 , token 104 , updated = false 105 ; 106 do { 107 token = tokens[i] + ""; 108 if (checkTokenAndGetIndex(this, token) === -1) { 109 this.push(token); 110 updated = true; 111 } 112 } 113 while (++i < l); 114 115 if (updated) { 116 this._updateClassName(); 117 } 118}; 119classListProto.remove = function () { 120 var 121 tokens = arguments 122 , i = 0 123 , l = tokens.length 124 , token 125 , updated = false 126 , index 127 ; 128 do { 129 token = tokens[i] + ""; 130 index = checkTokenAndGetIndex(this, token); 131 while (index !== -1) { 132 this.splice(index, 1); 133 updated = true; 134 index = checkTokenAndGetIndex(this, token); 135 } 136 } 137 while (++i < l); 138 139 if (updated) { 140 this._updateClassName(); 141 } 142}; 143classListProto.toggle = function (token, force) { 144 token += ""; 145 146 var 147 result = this.contains(token) 148 , method = result ? 149 force !== true && "remove" 150 : 151 force !== false && "add" 152 ; 153 154 if (method) { 155 this[method](token); 156 } 157 158 if (force === true || force === false) { 159 return force; 160 } else { 161 return !result; 162 } 163}; 164classListProto.toString = function () { 165 return this.join(" "); 166}; 167 168if (objCtr.defineProperty) { 169 var classListPropDesc = { 170 get: classListGetter 171 , enumerable: true 172 , configurable: true 173 }; 174 try { 175 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); 176 } catch (ex) { // IE 8 doesn't support enumerable:true 177 // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36 178 // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected 179 if (ex.number === undefined || ex.number === -0x7FF5EC54) { 180 classListPropDesc.enumerable = false; 181 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); 182 } 183 } 184} else if (objCtr[protoProp].__defineGetter__) { 185 elemCtrProto.__defineGetter__(classListProp, classListGetter); 186} 187 188}(window.self)); 189 190} 191 192// There is full or partial native classList support, so just check if we need 193// to normalize the add/remove and toggle APIs. 194 195(function () { 196 "use strict"; 197 198 var testElement = document.createElement("_"); 199 200 testElement.classList.add("c1", "c2"); 201 202 // Polyfill for IE 10/11 and Firefox <26, where classList.add and 203 // classList.remove exist but support only one argument at a time. 204 if (!testElement.classList.contains("c2")) { 205 var createMethod = function(method) { 206 var original = DOMTokenList.prototype[method]; 207 208 DOMTokenList.prototype[method] = function(token) { 209 var i, len = arguments.length; 210 211 for (i = 0; i < len; i++) { 212 token = arguments[i]; 213 original.call(this, token); 214 } 215 }; 216 }; 217 createMethod('add'); 218 createMethod('remove'); 219 } 220 221 testElement.classList.toggle("c3", false); 222 223 // Polyfill for IE 10 and Firefox <24, where classList.toggle does not 224 // support the second argument. 225 if (testElement.classList.contains("c3")) { 226 var _toggle = DOMTokenList.prototype.toggle; 227 228 DOMTokenList.prototype.toggle = function(token, force) { 229 if (1 in arguments && !this.contains(token) === !force) { 230 return force; 231 } else { 232 return _toggle.call(this, token); 233 } 234 }; 235 236 } 237 238 testElement = null; 239}()); 240 241} 242 243},{}],2:[function(require,module,exports){ 244 245/** 246 * Expose `parse`. 247 */ 248 249module.exports = parse; 250 251/** 252 * Tests for browser support. 253 */ 254 255var innerHTMLBug = false; 256var bugTestDiv; 257if (typeof document !== 'undefined') { 258 bugTestDiv = document.createElement('div'); 259 // Setup 260 bugTestDiv.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>'; 261 // Make sure that link elements get serialized correctly by innerHTML 262 // This requires a wrapper element in IE 263 innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length; 264 bugTestDiv = undefined; 265} 266 267/** 268 * Wrap map from jquery. 269 */ 270 271var map = { 272 legend: [1, '<fieldset>', '</fieldset>'], 273 tr: [2, '<table><tbody>', '</tbody></table>'], 274 col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], 275 // for script/link/style tags to work in IE6-8, you have to wrap 276 // in a div with a non-whitespace character in front, ha! 277 _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', ''] 278}; 279 280map.td = 281map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; 282 283map.option = 284map.optgroup = [1, '<select multiple="multiple">', '</select>']; 285 286map.thead = 287map.tbody = 288map.colgroup = 289map.caption = 290map.tfoot = [1, '<table>', '</table>']; 291 292map.polyline = 293map.ellipse = 294map.polygon = 295map.circle = 296map.text = 297map.line = 298map.path = 299map.rect = 300map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; 301 302/** 303 * Parse `html` and return a DOM Node instance, which could be a TextNode, 304 * HTML DOM Node of some kind (<div> for example), or a DocumentFragment 305 * instance, depending on the contents of the `html` string. 306 * 307 * @param {String} html - HTML string to "domify" 308 * @param {Document} doc - The `document` instance to create the Node for 309 * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance 310 * @api private 311 */ 312 313function parse(html, doc) { 314 if ('string' != typeof html) throw new TypeError('String expected'); 315 316 // default to the global `document` object 317 if (!doc) doc = document; 318 319 // tag name 320 var m = /<([\w:]+)/.exec(html); 321 if (!m) return doc.createTextNode(html); 322 323 html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace 324 325 var tag = m[1]; 326 327 // body support 328 if (tag == 'body') { 329 var el = doc.createElement('html'); 330 el.innerHTML = html; 331 return el.removeChild(el.lastChild); 332 } 333 334 // wrap map 335 var wrap = map[tag] || map._default; 336 var depth = wrap[0]; 337 var prefix = wrap[1]; 338 var suffix = wrap[2]; 339 var el = doc.createElement('div'); 340 el.innerHTML = prefix + html + suffix; 341 while (depth--) el = el.lastChild; 342 343 // one element 344 if (el.firstChild == el.lastChild) { 345 return el.removeChild(el.firstChild); 346 } 347 348 // several elements 349 var fragment = doc.createDocumentFragment(); 350 while (el.firstChild) { 351 fragment.appendChild(el.removeChild(el.firstChild)); 352 } 353 354 return fragment; 355} 356 357},{}],3:[function(require,module,exports){ 358/** 359 * Code refactored from Mozilla Developer Network: 360 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign 361 */ 362 363'use strict'; 364 365function assign(target, firstSource) { 366 if (target === undefined || target === null) { 367 throw new TypeError('Cannot convert first argument to object'); 368 } 369 370 var to = Object(target); 371 for (var i = 1; i < arguments.length; i++) { 372 var nextSource = arguments[i]; 373 if (nextSource === undefined || nextSource === null) { 374 continue; 375 } 376 377 var keysArray = Object.keys(Object(nextSource)); 378 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { 379 var nextKey = keysArray[nextIndex]; 380 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 381 if (desc !== undefined && desc.enumerable) { 382 to[nextKey] = nextSource[nextKey]; 383 } 384 } 385 } 386 return to; 387} 388 389function polyfill() { 390 if (!Object.assign) { 391 Object.defineProperty(Object, 'assign', { 392 enumerable: false, 393 configurable: true, 394 writable: true, 395 value: assign 396 }); 397 } 398} 399 400module.exports = { 401 assign: assign, 402 polyfill: polyfill 403}; 404 405},{}],4:[function(require,module,exports){ 406// get successful control from form and assemble into object 407// http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 408 409// types which indicate a submit action and are not successful controls 410// these will be ignored 411var k_r_submitter = /^(?:submit|button|image|reset|file)$/i; 412 413// node names which could be successful controls 414var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i; 415 416// Matches bracket notation. 417var brackets = /(\[[^\[\]]*\])/g; 418 419// serializes form fields 420// @param form MUST be an HTMLForm element 421// @param options is an optional argument to configure the serialization. Default output 422// with no options specified is a url encoded string 423// - hash: [true | false] Configure the output type. If true, the output will 424// be a js object. 425// - serializer: [function] Optional serializer function to override the default one. 426// The function takes 3 arguments (result, key, value) and should return new result 427// hash and url encoded str serializers are provided with this module 428// - disabled: [true | false]. If true serialize disabled fields. 429// - empty: [true | false]. If true serialize empty fields 430function serialize(form, options) { 431 if (typeof options != 'object') { 432 options = { hash: !!options }; 433 } 434 else if (options.hash === undefined) { 435 options.hash = true; 436 } 437 438 var result = (options.hash) ? {} : ''; 439 var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize); 440 441 var elements = form && form.elements ? form.elements : []; 442 443 //Object store each radio and set if it's empty or not 444 var radio_store = Object.create(null); 445 446 for (var i=0 ; i<elements.length ; ++i) { 447 var element = elements[i]; 448 449 // ingore disabled fields 450 if ((!options.disabled && element.disabled) || !element.name) { 451 continue; 452 } 453 // ignore anyhting that is not considered a success field 454 if (!k_r_success_contrls.test(element.nodeName) || 455 k_r_submitter.test(element.type)) { 456 continue; 457 } 458 459 var key = element.name; 460 var val = element.value; 461 462 // we can't just use element.value for checkboxes cause some browsers lie to us 463 // they say "on" for value when the box isn't checked 464 if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) { 465 val = undefined; 466 } 467 468 // If we want empty elements 469 if (options.empty) { 470 // for checkbox 471 if (element.type === 'checkbox' && !element.checked) { 472 val = ''; 473 } 474 475 // for radio 476 if (element.type === 'radio') { 477 if (!radio_store[element.name] && !element.checked) { 478 radio_store[element.name] = false; 479 } 480 else if (element.checked) { 481 radio_store[element.name] = true; 482 } 483 } 484 485 // if options empty is true, continue only if its radio 486 if (!val && element.type == 'radio') { 487 continue; 488 } 489 } 490 else { 491 // value-less fields are ignored unless options.empty is true 492 if (!val) { 493 continue; 494 } 495 } 496 497 // multi select boxes 498 if (element.type === 'select-multiple') { 499 val = []; 500 501 var selectOptions = element.options; 502 var isSelectedOptions = false; 503 for (var j=0 ; j<selectOptions.length ; ++j) { 504 var option = selectOptions[j]; 505 var allowedEmpty = options.empty && !option.value; 506 var hasValue = (option.value || allowedEmpty); 507 if (option.selected && hasValue) { 508 isSelectedOptions = true; 509 510 // If using a hash serializer be sure to add the 511 // correct notation for an array in the multi-select 512 // context. Here the name attribute on the select element 513 // might be missing the trailing bracket pair. Both names 514 // "foo" and "foo[]" should be arrays. 515 if (options.hash && key.slice(key.length - 2) !== '[]') { 516 result = serializer(result, key + '[]', option.value); 517 } 518 else { 519 result = serializer(result, key, option.value); 520 } 521 } 522 } 523 524 // Serialize if no selected options and options.empty is true 525 if (!isSelectedOptions && options.empty) { 526 result = serializer(result, key, ''); 527 } 528 529 continue; 530 } 531 532 result = serializer(result, key, val); 533 } 534 535 // Check for all empty radio buttons and serialize them with key="" 536 if (options.empty) { 537 for (var key in radio_store) { 538 if (!radio_store[key]) { 539 result = serializer(result, key, ''); 540 } 541 } 542 } 543 544 return result; 545} 546 547function parse_keys(string) { 548 var keys = []; 549 var prefix = /^([^\[\]]*)/; 550 var children = new RegExp(brackets); 551 var match = prefix.exec(string); 552 553 if (match[1]) { 554 keys.push(match[1]); 555 } 556 557 while ((match = children.exec(string)) !== null) { 558 keys.push(match[1]); 559 } 560 561 return keys; 562} 563 564function hash_assign(result, keys, value) { 565 if (keys.length === 0) { 566 result = value; 567 return result; 568 } 569 570 var key = keys.shift(); 571 var between = key.match(/^\[(.+?)\]$/); 572 573 if (key === '[]') { 574 result = result || []; 575 576 if (Array.isArray(result)) { 577 result.push(hash_assign(null, keys, value)); 578 } 579 else { 580 // This might be the result of bad name attributes like "[][foo]", 581 // in this case the original `result` object will already be 582 // assigned to an object literal. Rather than coerce the object to 583 // an array, or cause an exception the attribute "_values" is 584 // assigned as an array. 585 result._values = result._values || []; 586 result._values.push(hash_assign(null, keys, value)); 587 } 588 589 return result; 590 } 591 592 // Key is an attribute name and can be assigned directly. 593 if (!between) { 594 result[key] = hash_assign(result[key], keys, value); 595 } 596 else { 597 var string = between[1]; 598 // +var converts the variable into a number 599 // better than parseInt because it doesn't truncate away trailing 600 // letters and actually fails if whole thing is not a number 601 var index = +string; 602 603 // If the characters between the brackets is not a number it is an 604 // attribute name and can be assigned directly. 605 if (isNaN(index)) { 606 result = result || {}; 607 result[string] = hash_assign(result[string], keys, value); 608 } 609 else { 610 result = result || []; 611 result[index] = hash_assign(result[index], keys, value); 612 } 613 } 614 615 return result; 616} 617 618// Object/hash encoding serializer. 619function hash_serializer(result, key, value) { 620 var matches = key.match(brackets); 621 622 // Has brackets? Use the recursive assignment function to walk the keys, 623 // construct any missing objects in the result tree and make the assignment 624 // at the end of the chain. 625 if (matches) { 626 var keys = parse_keys(key); 627 hash_assign(result, keys, value); 628 } 629 else { 630 // Non bracket notation can make assignments directly. 631 var existing = result[key]; 632 633 // If the value has been assigned already (for instance when a radio and 634 // a checkbox have the same name attribute) convert the previous value 635 // into an array before pushing into it. 636 // 637 // NOTE: If this requirement were removed all hash creation and 638 // assignment could go through `hash_assign`. 639 if (existing) { 640 if (!Array.isArray(existing)) { 641 result[key] = [ existing ]; 642 } 643 644 result[key].push(value); 645 } 646 else { 647 result[key] = value; 648 } 649 } 650 651 return result; 652} 653 654// urlform encoding serializer 655function str_serialize(result, key, value) { 656 // encode newlines as \r\n cause the html spec says so 657 value = value.replace(/(\r)?\n/g, '\r\n'); 658 value = encodeURIComponent(value); 659 660 // spaces should be '+' rather than '%20'. 661 value = value.replace(/%20/g, '+'); 662 return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value; 663} 664 665module.exports = serialize; 666 667},{}],5:[function(require,module,exports){ 668(function (global){ 669(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.vexDialog = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 670 671/** 672 * Expose `parse`. 673 */ 674 675module.exports = parse; 676 677/** 678 * Tests for browser support. 679 */ 680 681var innerHTMLBug = false; 682var bugTestDiv; 683if (typeof document !== 'undefined') { 684 bugTestDiv = document.createElement('div'); 685 // Setup 686 bugTestDiv.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>'; 687 // Make sure that link elements get serialized correctly by innerHTML 688 // This requires a wrapper element in IE 689 innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length; 690 bugTestDiv = undefined; 691} 692 693/** 694 * Wrap map from jquery. 695 */ 696 697var map = { 698 legend: [1, '<fieldset>', '</fieldset>'], 699 tr: [2, '<table><tbody>', '</tbody></table>'], 700 col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], 701 // for script/link/style tags to work in IE6-8, you have to wrap 702 // in a div with a non-whitespace character in front, ha! 703 _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', ''] 704}; 705 706map.td = 707map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; 708 709map.option = 710map.optgroup = [1, '<select multiple="multiple">', '</select>']; 711 712map.thead = 713map.tbody = 714map.colgroup = 715map.caption = 716map.tfoot = [1, '<table>', '</table>']; 717 718map.polyline = 719map.ellipse = 720map.polygon = 721map.circle = 722map.text = 723map.line = 724map.path = 725map.rect = 726map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; 727 728/** 729 * Parse `html` and return a DOM Node instance, which could be a TextNode, 730 * HTML DOM Node of some kind (<div> for example), or a DocumentFragment 731 * instance, depending on the contents of the `html` string. 732 * 733 * @param {String} html - HTML string to "domify" 734 * @param {Document} doc - The `document` instance to create the Node for 735 * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance 736 * @api private 737 */ 738 739function parse(html, doc) { 740 if ('string' != typeof html) throw new TypeError('String expected'); 741 742 // default to the global `document` object 743 if (!doc) doc = document; 744 745 // tag name 746 var m = /<([\w:]+)/.exec(html); 747 if (!m) return doc.createTextNode(html); 748 749 html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace 750 751 var tag = m[1]; 752 753 // body support 754 if (tag == 'body') { 755 var el = doc.createElement('html'); 756 el.innerHTML = html; 757 return el.removeChild(el.lastChild); 758 } 759 760 // wrap map 761 var wrap = map[tag] || map._default; 762 var depth = wrap[0]; 763 var prefix = wrap[1]; 764 var suffix = wrap[2]; 765 var el = doc.createElement('div'); 766 el.innerHTML = prefix + html + suffix; 767 while (depth--) el = el.lastChild; 768 769 // one element 770 if (el.firstChild == el.lastChild) { 771 return el.removeChild(el.firstChild); 772 } 773 774 // several elements 775 var fragment = doc.createDocumentFragment(); 776 while (el.firstChild) { 777 fragment.appendChild(el.removeChild(el.firstChild)); 778 } 779 780 return fragment; 781} 782 783},{}],2:[function(require,module,exports){ 784// get successful control from form and assemble into object 785// http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 786 787// types which indicate a submit action and are not successful controls 788// these will be ignored 789var k_r_submitter = /^(?:submit|button|image|reset|file)$/i; 790 791// node names which could be successful controls 792var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i; 793 794// Matches bracket notation. 795var brackets = /(\[[^\[\]]*\])/g; 796 797// serializes form fields 798// @param form MUST be an HTMLForm element 799// @param options is an optional argument to configure the serialization. Default output 800// with no options specified is a url encoded string 801// - hash: [true | false] Configure the output type. If true, the output will 802// be a js object. 803// - serializer: [function] Optional serializer function to override the default one. 804// The function takes 3 arguments (result, key, value) and should return new result 805// hash and url encoded str serializers are provided with this module 806// - disabled: [true | false]. If true serialize disabled fields. 807// - empty: [true | false]. If true serialize empty fields 808function serialize(form, options) { 809 if (typeof options != 'object') { 810 options = { hash: !!options }; 811 } 812 else if (options.hash === undefined) { 813 options.hash = true; 814 } 815 816 var result = (options.hash) ? {} : ''; 817 var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize); 818 819 var elements = form && form.elements ? form.elements : []; 820 821 //Object store each radio and set if it's empty or not 822 var radio_store = Object.create(null); 823 824 for (var i=0 ; i<elements.length ; ++i) { 825 var element = elements[i]; 826 827 // ingore disabled fields 828 if ((!options.disabled && element.disabled) || !element.name) { 829 continue; 830 } 831 // ignore anyhting that is not considered a success field 832 if (!k_r_success_contrls.test(element.nodeName) || 833 k_r_submitter.test(element.type)) { 834 continue; 835 } 836 837 var key = element.name; 838 var val = element.value; 839 840 // we can't just use element.value for checkboxes cause some browsers lie to us 841 // they say "on" for value when the box isn't checked 842 if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) { 843 val = undefined; 844 } 845 846 // If we want empty elements 847 if (options.empty) { 848 // for checkbox 849 if (element.type === 'checkbox' && !element.checked) { 850 val = ''; 851 } 852 853 // for radio 854 if (element.type === 'radio') { 855 if (!radio_store[element.name] && !element.checked) { 856 radio_store[element.name] = false; 857 } 858 else if (element.checked) { 859 radio_store[element.name] = true; 860 } 861 } 862 863 // if options empty is true, continue only if its radio 864 if (!val && element.type == 'radio') { 865 continue; 866 } 867 } 868 else { 869 // value-less fields are ignored unless options.empty is true 870 if (!val) { 871 continue; 872 } 873 } 874 875 // multi select boxes 876 if (element.type === 'select-multiple') { 877 val = []; 878 879 var selectOptions = element.options; 880 var isSelectedOptions = false; 881 for (var j=0 ; j<selectOptions.length ; ++j) { 882 var option = selectOptions[j]; 883 var allowedEmpty = options.empty && !option.value; 884 var hasValue = (option.value || allowedEmpty); 885 if (option.selected && hasValue) { 886 isSelectedOptions = true; 887 888 // If using a hash serializer be sure to add the 889 // correct notation for an array in the multi-select 890 // context. Here the name attribute on the select element 891 // might be missing the trailing bracket pair. Both names 892 // "foo" and "foo[]" should be arrays. 893 if (options.hash && key.slice(key.length - 2) !== '[]') { 894 result = serializer(result, key + '[]', option.value); 895 } 896 else { 897 result = serializer(result, key, option.value); 898 } 899 } 900 } 901 902 // Serialize if no selected options and options.empty is true 903 if (!isSelectedOptions && options.empty) { 904 result = serializer(result, key, ''); 905 } 906 907 continue; 908 } 909 910 result = serializer(result, key, val); 911 } 912 913 // Check for all empty radio buttons and serialize them with key="" 914 if (options.empty) { 915 for (var key in radio_store) { 916 if (!radio_store[key]) { 917 result = serializer(result, key, ''); 918 } 919 } 920 } 921 922 return result; 923} 924 925function parse_keys(string) { 926 var keys = []; 927 var prefix = /^([^\[\]]*)/; 928 var children = new RegExp(brackets); 929 var match = prefix.exec(string); 930 931 if (match[1]) { 932 keys.push(match[1]); 933 } 934 935 while ((match = children.exec(string)) !== null) { 936 keys.push(match[1]); 937 } 938 939 return keys; 940} 941 942function hash_assign(result, keys, value) { 943 if (keys.length === 0) { 944 result = value; 945 return result; 946 } 947 948 var key = keys.shift(); 949 var between = key.match(/^\[(.+?)\]$/); 950 951 if (key === '[]') { 952 result = result || []; 953 954 if (Array.isArray(result)) { 955 result.push(hash_assign(null, keys, value)); 956 } 957 else { 958 // This might be the result of bad name attributes like "[][foo]", 959 // in this case the original `result` object will already be 960 // assigned to an object literal. Rather than coerce the object to 961 // an array, or cause an exception the attribute "_values" is 962 // assigned as an array. 963 result._values = result._values || []; 964 result._values.push(hash_assign(null, keys, value)); 965 } 966 967 return result; 968 } 969 970 // Key is an attribute name and can be assigned directly. 971 if (!between) { 972 result[key] = hash_assign(result[key], keys, value); 973 } 974 else { 975 var string = between[1]; 976 // +var converts the variable into a number 977 // better than parseInt because it doesn't truncate away trailing 978 // letters and actually fails if whole thing is not a number 979 var index = +string; 980 981 // If the characters between the brackets is not a number it is an 982 // attribute name and can be assigned directly. 983 if (isNaN(index)) { 984 result = result || {}; 985 result[string] = hash_assign(result[string], keys, value); 986 } 987 else { 988 result = result || []; 989 result[index] = hash_assign(result[index], keys, value); 990 } 991 } 992 993 return result; 994} 995 996// Object/hash encoding serializer. 997function hash_serializer(result, key, value) { 998 var matches = key.match(brackets); 999 1000 // Has brackets? Use the recursive assignment function to walk the keys, 1001 // construct any missing objects in the result tree and make the assignment 1002 // at the end of the chain. 1003 if (matches) { 1004 var keys = parse_keys(key); 1005 hash_assign(result, keys, value); 1006 } 1007 else { 1008 // Non bracket notation can make assignments directly. 1009 var existing = result[key]; 1010 1011 // If the value has been assigned already (for instance when a radio and 1012 // a checkbox have the same name attribute) convert the previous value 1013 // into an array before pushing into it. 1014 // 1015 // NOTE: If this requirement were removed all hash creation and 1016 // assignment could go through `hash_assign`. 1017 if (existing) { 1018 if (!Array.isArray(existing)) { 1019 result[key] = [ existing ]; 1020 } 1021 1022 result[key].push(value); 1023 } 1024 else { 1025 result[key] = value; 1026 } 1027 } 1028 1029 return result; 1030} 1031 1032// urlform encoding serializer 1033function str_serialize(result, key, value) { 1034 // encode newlines as \r\n cause the html spec says so 1035 value = value.replace(/(\r)?\n/g, '\r\n'); 1036 value = encodeURIComponent(value); 1037 1038 // spaces should be '+' rather than '%20'. 1039 value = value.replace(/%20/g, '+'); 1040 return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value; 1041} 1042 1043module.exports = serialize; 1044 1045},{}],3:[function(require,module,exports){ 1046var domify = require('domify') 1047var serialize = require('form-serialize') 1048 1049// Build DOM elements for the structure of the dialog 1050var buildDialogForm = function buildDialogForm (options) { 1051 var form = document.createElement('form') 1052 form.classList.add('vex-dialog-form') 1053 1054 var message = document.createElement('div') 1055 message.classList.add('vex-dialog-message') 1056 message.appendChild(options.message instanceof window.Node ? options.message : domify(options.message)) 1057 1058 var input = document.createElement('div') 1059 input.classList.add('vex-dialog-input') 1060 input.appendChild(options.input instanceof window.Node ? options.input : domify(options.input)) 1061 1062 form.appendChild(message) 1063 form.appendChild(input) 1064 1065 return form 1066} 1067 1068// Take an array of buttons (see the default buttons below) and turn them into DOM elements 1069var buttonsToDOM = function buttonsToDOM (buttons) { 1070 var domButtons = document.createElement('div') 1071 domButtons.classList.add('vex-dialog-buttons') 1072 1073 for (var i = 0; i < buttons.length; i++) { 1074 var button = buttons[i] 1075 var domButton = document.createElement('button') 1076 domButton.type = button.type 1077 domButton.textContent = button.text 1078 domButton.className = button.className 1079 domButton.classList.add('vex-dialog-button') 1080 if (i === 0) { 1081 domButton.classList.add('vex-first') 1082 } else if (i === buttons.length - 1) { 1083 domButton.classList.add('vex-last') 1084 } 1085 // Attach click listener to button with closure 1086 (function (button) { 1087 domButton.addEventListener('click', function (e) { 1088 if (button.click) { 1089 button.click.call(this, e) 1090 } 1091 }.bind(this)) 1092 }.bind(this)(button)) 1093 1094 domButtons.appendChild(domButton) 1095 } 1096 1097 return domButtons 1098} 1099 1100var plugin = function plugin (vex) { 1101 // Define the API first 1102 var dialog = { 1103 // Plugin name 1104 name: 'dialog', 1105 1106 // Open 1107 open: function open (opts) { 1108 var options = Object.assign({}, this.defaultOptions, opts) 1109 1110 // `message` is unsafe internally, so translate 1111 // safe default: HTML-escape the message before passing it through 1112 if (options.unsafeMessage && !options.message) { 1113 options.message = options.unsafeMessage 1114 } else if (options.message) { 1115 options.message = vex._escapeHtml(options.message) 1116 } 1117 1118 // Build the form from the options 1119 var form = options.unsafeContent = buildDialogForm(options) 1120 1121 // Open the dialog 1122 var dialogInstance = vex.open(options) 1123 1124 // Quick comment - these options and appending buttons and everything 1125 // would preferably be done _before_ opening the dialog. However, since 1126 // they rely on the context of the vex instance, we have to do them 1127 // after. A potential future fix would be to differentiate between 1128 // a "created" vex instance and an "opened" vex instance, so any actions 1129 // that rely on the specific context of the instance can do their stuff 1130 // before opening the dialog on the page. 1131 1132 // Override the before close callback to also pass the value of the form 1133 var beforeClose = options.beforeClose && options.beforeClose.bind(dialogInstance) 1134 dialogInstance.options.beforeClose = function dialogBeforeClose () { 1135 // Only call the callback once - when the validation in beforeClose, if present, is true 1136 var shouldClose = beforeClose ? beforeClose() : true 1137 if (shouldClose) { 1138 options.callback(this.value || false) 1139 } 1140 // Return the result of beforeClose() to vex 1141 return shouldClose 1142 }.bind(dialogInstance) 1143 1144 // Append buttons to form with correct context 1145 form.appendChild(buttonsToDOM.call(dialogInstance, options.buttons)) 1146 1147 // Attach form to instance 1148 dialogInstance.form = form 1149 1150 // Add submit listener to form 1151 form.addEventListener('submit', options.onSubmit.bind(dialogInstance)) 1152 1153 // Optionally focus the first input in the form 1154 if (options.focusFirstInput) { 1155 var el = dialogInstance.contentEl.querySelector('button, input, select, textarea') 1156 if (el) { 1157 el.focus() 1158 } 1159 } 1160 1161 // For chaining 1162 return dialogInstance 1163 }, 1164 1165 // Alert 1166 alert: function (options) { 1167 // Allow string as message 1168 if (typeof options === 'string') { 1169 options = { 1170 message: options 1171 } 1172 } 1173 options = Object.assign({}, this.defaultOptions, this.defaultAlertOptions, options) 1174 return this.open(options) 1175 }, 1176 1177 // Confirm 1178 confirm: function (options) { 1179 if (typeof options !== 'object' || typeof options.callback !== 'function') { 1180 throw new Error('dialog.confirm(options) requires options.callback.') 1181 } 1182 options = Object.assign({}, this.defaultOptions, this.defaultConfirmOptions, options) 1183 return this.open(options) 1184 }, 1185 1186 // Prompt 1187 prompt: function (options) { 1188 if (typeof options !== 'object' || typeof options.callback !== 'function') { 1189 throw new Error('dialog.prompt(options) requires options.callback.') 1190 } 1191 var defaults = Object.assign({}, this.defaultOptions, this.defaultPromptOptions) 1192 var dynamicDefaults = { 1193 unsafeMessage: '<label for="vex">' + vex._escapeHtml(options.label || defaults.label) + '</label>', 1194 input: '<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="' + vex._escapeHtml(options.placeholder || defaults.placeholder) + '" value="' + vex._escapeHtml(options.value || defaults.value) + '" />' 1195 } 1196 options = Object.assign(defaults, dynamicDefaults, options) 1197 // Pluck the value of the "vex" input field as the return value for prompt's callback 1198 // More closely mimics "window.prompt" in that a single string is returned 1199 var callback = options.callback 1200 options.callback = function promptCallback (value) { 1201 if (typeof value === 'object') { 1202 var keys = Object.keys(value) 1203 value = keys.length ? value[keys[0]] : '' 1204 } 1205 callback(value) 1206 } 1207 return this.open(options) 1208 } 1209 } 1210 1211 // Now define any additional data that's not the direct dialog API 1212 dialog.buttons = { 1213 YES: { 1214 text: 'OK', 1215 type: 'submit', 1216 className: 'vex-dialog-button-primary', 1217 click: function yesClick () { 1218 this.value = true 1219 } 1220 }, 1221 1222 NO: { 1223 text: 'Cancel', 1224 type: 'button', 1225 className: 'vex-dialog-button-secondary', 1226 click: function noClick () { 1227 this.value = false 1228 this.close() 1229 } 1230 } 1231 } 1232 1233 dialog.defaultOptions = { 1234 callback: function () {}, 1235 afterOpen: function () {}, 1236 message: '', 1237 input: '', 1238 buttons: [ 1239 dialog.buttons.YES, 1240 dialog.buttons.NO 1241 ], 1242 showCloseButton: false, 1243 onSubmit: function onDialogSubmit (e) { 1244 e.preventDefault() 1245 if (this.options.input) { 1246 this.value = serialize(this.form, { hash: true }) 1247 } 1248 return this.close() 1249 }, 1250 focusFirstInput: true 1251 } 1252 1253 dialog.defaultAlertOptions = { 1254 buttons: [ 1255 dialog.buttons.YES 1256 ] 1257 } 1258 1259 dialog.defaultPromptOptions = { 1260 label: 'Prompt:', 1261 placeholder: '', 1262 value: '' 1263 } 1264 1265 dialog.defaultConfirmOptions = {} 1266 1267 return dialog 1268} 1269 1270module.exports = plugin 1271 1272},{"domify":1,"form-serialize":2}]},{},[3])(3) 1273}); 1274}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1275},{"domify":2,"form-serialize":4}],6:[function(require,module,exports){ 1276var vex = require('./vex') 1277vex.registerPlugin(require('vex-dialog')) 1278module.exports = vex 1279 1280},{"./vex":7,"vex-dialog":5}],7:[function(require,module,exports){ 1281// classList polyfill for old browsers 1282require('classlist-polyfill') 1283// Object.assign polyfill 1284require('es6-object-assign').polyfill() 1285 1286// String to DOM function 1287var domify = require('domify') 1288 1289// Use the DOM's HTML parsing to escape any dangerous strings 1290var escapeHtml = function escapeHtml (str) { 1291 if (typeof str !== 'undefined') { 1292 var div = document.createElement('div') 1293 div.appendChild(document.createTextNode(str)) 1294 return div.innerHTML 1295 } else { 1296 return '' 1297 } 1298} 1299 1300// Utility function to add space-delimited class strings to a DOM element's classList 1301var addClasses = function addClasses (el, classStr) { 1302 if (typeof classStr !== 'string' || classStr.length === 0) { 1303 return 1304 } 1305 var classes = classStr.split(' ') 1306 for (var i = 0; i < classes.length; i++) { 1307 var className = classes[i] 1308 if (className.length) { 1309 el.classList.add(className) 1310 } 1311 } 1312} 1313 1314// Detect CSS Animation End Support 1315// https://github.com/limonte/sweetalert2/blob/99bd539f85e15ac170f69d35001d12e092ef0054/src/utils/dom.js#L194 1316var animationEndEvent = (function detectAnimationEndEvent () { 1317 var el = document.createElement('div') 1318 var eventNames = { 1319 'animation': 'animationend', 1320 'WebkitAnimation': 'webkitAnimationEnd', 1321 'MozAnimation': 'animationend', 1322 'OAnimation': 'oanimationend', 1323 'msAnimation': 'MSAnimationEnd' 1324 } 1325 for (var i in eventNames) { 1326 if (el.style[i] !== undefined) { 1327 return eventNames[i] 1328 } 1329 } 1330 return false 1331})() 1332 1333// vex base CSS classes 1334var baseClassNames = { 1335 vex: 'vex', 1336 content: 'vex-content', 1337 overlay: 'vex-overlay', 1338 close: 'vex-close', 1339 closing: 'vex-closing', 1340 open: 'vex-open' 1341} 1342 1343// Private lookup table of all open vex objects, keyed by id 1344var vexes = {} 1345var globalId = 1 1346 1347// Private boolean to assist the escapeButtonCloses option 1348var isEscapeActive = false 1349 1350// vex itself is an object that exposes a simple API to open and close vex objects in various ways 1351var vex = { 1352 open: function open (opts) { 1353 // Check for usage of deprecated options, and log a warning 1354 var warnDeprecated = function warnDeprecated (prop) { 1355 console.warn('The "' + prop + '" property is deprecated in vex 3. Use CSS classes and the appropriate "ClassName" options, instead.') 1356 console.warn('See http://github.hubspot.com/vex/api/advanced/#options') 1357 } 1358 if (opts.css) { 1359 warnDeprecated('css') 1360 } 1361 if (opts.overlayCSS) { 1362 warnDeprecated('overlayCSS') 1363 } 1364 if (opts.contentCSS) { 1365 warnDeprecated('contentCSS') 1366 } 1367 if (opts.closeCSS) { 1368 warnDeprecated('closeCSS') 1369 } 1370 1371 // The dialog instance 1372 var vexInstance = {} 1373 1374 // Set id 1375 vexInstance.id = globalId++ 1376 1377 // Store internally 1378 vexes[vexInstance.id] = vexInstance 1379 1380 // Set state 1381 vexInstance.isOpen = true 1382 1383 // Close function on the vex instance 1384 // This is how all API functions should close individual vexes 1385 vexInstance.close = function instanceClose () { 1386 // Check state 1387 if (!this.isOpen) { 1388 return true 1389 } 1390 1391 var options = this.options 1392 1393 // escapeButtonCloses is checked first 1394 if (isEscapeActive && !options.escapeButtonCloses) { 1395 return false 1396 } 1397 1398 // Allow the user to validate any info or abort the close with the beforeClose callback 1399 var shouldClose = (function shouldClose () { 1400 // Call before close callback 1401 if (options.beforeClose) { 1402 return options.beforeClose.call(this) 1403 } 1404 // Otherwise indicate that it's ok to continue with close 1405 return true 1406 }.bind(this)()) 1407 1408 // If beforeClose() fails, abort the close 1409 if (shouldClose === false) { 1410 return false 1411 } 1412 1413 // Update state 1414 this.isOpen = false 1415 1416 // Detect if the content el has any CSS animations defined 1417 var style = window.getComputedStyle(this.contentEl) 1418 function hasAnimationPre (prefix) { 1419 return style.getPropertyValue(prefix + 'animation-name') !== 'none' && style.getPropertyValue(prefix + 'animation-duration') !== '0s' 1420 } 1421 var hasAnimation = hasAnimationPre('') || hasAnimationPre('-webkit-') || hasAnimationPre('-moz-') || hasAnimationPre('-o-') 1422 1423 // Define the function that will actually close the instance 1424 var close = function close () { 1425 if (!this.rootEl.parentNode) { 1426 return 1427 } 1428 // Run once 1429 this.rootEl.removeEventListener(animationEndEvent, close) 1430 this.overlayEl.removeEventListener(animationEndEvent, close) 1431 // Remove from lookup table (prevent memory leaks) 1432 delete vexes[this.id] 1433 // Remove the dialog from the DOM 1434 this.rootEl.parentNode.removeChild(this.rootEl) 1435 // Remove the overlay from the DOM 1436 this.bodyEl.removeChild(this.overlayEl) 1437 // Call after close callback 1438 if (options.afterClose) { 1439 options.afterClose.call(this) 1440 } 1441 // Remove styling from the body, if no more vexes are open 1442 if (Object.keys(vexes).length === 0) { 1443 document.body.classList.remove(baseClassNames.open) 1444 } 1445 }.bind(this) 1446 1447 // Close the vex 1448 if (animationEndEvent && hasAnimation) { 1449 // Setup the end event listener, to remove the el from the DOM 1450 this.rootEl.addEventListener(animationEndEvent, close) 1451 this.overlayEl.addEventListener(animationEndEvent, close) 1452 // Add the closing class to the dialog, showing the close animation 1453 this.rootEl.classList.add(baseClassNames.closing) 1454 this.overlayEl.classList.add(baseClassNames.closing) 1455 } else { 1456 close() 1457 } 1458 1459 return true 1460 } 1461 1462 // Allow strings as content 1463 if (typeof opts === 'string') { 1464 opts = { 1465 content: opts 1466 } 1467 } 1468 1469 // `content` is unsafe internally, so translate 1470 // safe default: HTML-escape the content before passing it through 1471 if (opts.unsafeContent && !opts.content) { 1472 opts.content = opts.unsafeContent 1473 } else if (opts.content) { 1474 opts.content = escapeHtml(opts.content) 1475 } 1476 1477 // Store options on instance for future reference 1478 var options = vexInstance.options = Object.assign({}, vex.defaultOptions, opts) 1479 1480 // Get Body Element 1481 var bodyEl = vexInstance.bodyEl = document.getElementsByTagName('body')[0] 1482 1483 // vex root 1484 var rootEl = vexInstance.rootEl = document.createElement('div') 1485 rootEl.classList.add(baseClassNames.vex) 1486 addClasses(rootEl, options.className) 1487 1488 // Overlay 1489 var overlayEl = vexInstance.overlayEl = document.createElement('div') 1490 overlayEl.classList.add(baseClassNames.overlay) 1491 addClasses(overlayEl, options.overlayClassName) 1492 if (options.overlayClosesOnClick) { 1493 rootEl.addEventListener('click', function overlayClickListener (e) { 1494 if (e.target === rootEl) { 1495 vexInstance.close() 1496 } 1497 }) 1498 } 1499 bodyEl.appendChild(overlayEl) 1500 1501 // Content 1502 var contentEl = vexInstance.contentEl = document.createElement('div') 1503 contentEl.classList.add(baseClassNames.content) 1504 addClasses(contentEl, options.contentClassName) 1505 contentEl.appendChild(options.content instanceof window.Node ? options.content : domify(options.content)) 1506 rootEl.appendChild(contentEl) 1507 1508 // Close button 1509 if (options.showCloseButton) { 1510 var closeEl = vexInstance.closeEl = document.createElement('div') 1511 closeEl.classList.add(baseClassNames.close) 1512 addClasses(closeEl, options.closeClassName) 1513 closeEl.addEventListener('click', vexInstance.close.bind(vexInstance)) 1514 contentEl.appendChild(closeEl) 1515 } 1516 1517 // Add to DOM 1518 document.querySelector(options.appendLocation).appendChild(rootEl) 1519 1520 // Call after open callback 1521 if (options.afterOpen) { 1522 options.afterOpen.call(vexInstance) 1523 } 1524 1525 // Apply styling to the body 1526 document.body.classList.add(baseClassNames.open) 1527 1528 // Return the created vex instance 1529 return vexInstance 1530 }, 1531 1532 // A top-level vex.close function to close dialogs by reference or id 1533 close: function close (vexOrId) { 1534 var id 1535 if (vexOrId.id) { 1536 id = vexOrId.id 1537 } else if (typeof vexOrId === 'string') { 1538 id = vexOrId 1539 } else { 1540 throw new TypeError('close requires a vex object or id string') 1541 } 1542 if (!vexes[id]) { 1543 return false 1544 } 1545 return vexes[id].close() 1546 }, 1547 1548 // Close the most recently created/opened vex 1549 closeTop: function closeTop () { 1550 var ids = Object.keys(vexes) 1551 if (!ids.length) { 1552 return false 1553 } 1554 return vexes[ids[ids.length - 1]].close() 1555 }, 1556 1557 // Close every vex! 1558 closeAll: function closeAll () { 1559 for (var id in vexes) { 1560 this.close(id) 1561 } 1562 return true 1563 }, 1564 1565 // A getter for the internal lookup table 1566 getAll: function getAll () { 1567 return vexes 1568 }, 1569 1570 // A getter for the internal lookup table 1571 getById: function getById (id) { 1572 return vexes[id] 1573 } 1574} 1575 1576// Close top vex on escape 1577window.addEventListener('keyup', function vexKeyupListener (e) { 1578 if (e.keyCode === 27) { 1579 isEscapeActive = true 1580 vex.closeTop() 1581 isEscapeActive = false 1582 } 1583}) 1584 1585// Close all vexes on history pop state (useful in single page apps) 1586window.addEventListener('popstate', function () { 1587 if (vex.defaultOptions.closeAllOnPopState) { 1588 vex.closeAll() 1589 } 1590}) 1591 1592vex.defaultOptions = { 1593 content: '', 1594 showCloseButton: true, 1595 escapeButtonCloses: true, 1596 overlayClosesOnClick: true, 1597 appendLocation: 'body', 1598 className: '', 1599 overlayClassName: '', 1600 contentClassName: '', 1601 closeClassName: '', 1602 closeAllOnPopState: true 1603} 1604 1605// TODO Loading symbols? 1606 1607// Include escapeHtml function on the library object 1608Object.defineProperty(vex, '_escapeHtml', { 1609 configurable: false, 1610 enumerable: false, 1611 writable: false, 1612 value: escapeHtml 1613}) 1614 1615// Plugin system! 1616vex.registerPlugin = function registerPlugin (pluginFn, name) { 1617 var plugin = pluginFn(vex) 1618 var pluginName = name || plugin.name 1619 if (vex[pluginName]) { 1620 throw new Error('Plugin ' + name + ' is already registered.') 1621 } 1622 vex[pluginName] = plugin 1623} 1624 1625module.exports = vex 1626 1627},{"classlist-polyfill":1,"domify":2,"es6-object-assign":3}]},{},[6])(6) 1628});
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.