3 lines
18 KiB
JavaScript
3 lines
18 KiB
JavaScript
/*! vex.combined.js: vex 4.1.0, vex-dialog 1.0.7 */
|
|
|
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).vex=e()}}(function(){return function e(t,n,o){function i(a,s){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(r)return r(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return i(n||e)},u,u.exports,e,t,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(e,t,n){"document"in window.self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||function(e){"use strict";if("Element"in e){var t="classList",n="prototype",o=e.Element[n],i=Object,r=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array[n].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},s=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},l=function(e,t){if(""===t)throw new s("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new s("INVALID_CHARACTER_ERR","String contains an invalid character");return a.call(e,t)},c=function(e){for(var t=r.call(e.getAttribute("class")||""),n=t?t.split(/\s+/):[],o=0,i=n.length;o<i;o++)this.push(n[o]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},u=c[n]=[],d=function(){return new c(this)};if(s[n]=Error[n],u.item=function(e){return this[e]||null},u.contains=function(e){return-1!==l(this,e+="")},u.add=function(){for(var e,t=arguments,n=0,o=t.length,i=!1;e=t[n]+"",-1===l(this,e)&&(this.push(e),i=!0),++n<o;);i&&this._updateClassName()},u.remove=function(){var e,t,n=arguments,o=0,i=n.length,r=!1;do{for(e=n[o]+"",t=l(this,e);-1!==t;)this.splice(t,1),r=!0,t=l(this,e)}while(++o<i);r&&this._updateClassName()},u.toggle=function(e,t){e+="";var n=this.contains(e),o=n?!0!==t&&"remove":!1!==t&&"add";return o&&this[o](e),!0===t||!1===t?t:!n},u.toString=function(){return this.join(" ")},i.defineProperty){var f={get:d,enumerable:!0,configurable:!0};try{i.defineProperty(o,t,f)}catch(e){void 0!==e.number&&-2146823252!==e.number||(f.enumerable=!1,i.defineProperty(o,t,f))}}else i[n].__defineGetter__&&o.__defineGetter__(t,d)}}(window.self),function(){"use strict";var e=document.createElement("_");if(e.classList.add("c1","c2"),!e.classList.contains("c2")){var t=function(e){var t=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){var n,o=arguments.length;for(n=0;n<o;n++)e=arguments[n],t.call(this,e)}};t("add"),t("remove")}if(e.classList.toggle("c3",!1),e.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:n.call(this,e)}}e=null}())},{}],2:[function(e,t,n){t.exports=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var o=n[1];if("body"==o){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var a=r[o]||r._default,s=a[0],l=a[1],c=a[2];(i=t.createElement("div")).innerHTML=l+e+c;for(;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);var u=t.createDocumentFragment();for(;i.firstChild;)u.appendChild(i.removeChild(i.firstChild));return u};var o,i=!1;"undefined"!=typeof document&&((o=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',i=!o.getElementsByTagName("link").length,o=void 0);var r={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:i?[1,"X<div>","</div>"]:[0,"",""]};r.td=r.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],r.option=r.optgroup=[1,'<select multiple="multiple">',"</select>"],r.thead=r.tbody=r.colgroup=r.caption=r.tfoot=[1,"<table>","</table>"],r.polyline=r.ellipse=r.polygon=r.circle=r.text=r.line=r.path=r.rect=r.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],3:[function(e,t,n){"use strict";function o(e,t){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=arguments[o];if(null!=i)for(var r=Object.keys(Object(i)),a=0,s=r.length;a<s;a++){var l=r[a],c=Object.getOwnPropertyDescriptor(i,l);void 0!==c&&c.enumerable&&(n[l]=i[l])}}return n}t.exports={assign:o,polyfill:function(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:o})}}},{}],4:[function(e,t,n){var o=/^(?:submit|button|image|reset|file)$/i,i=/^(?:input|select|textarea|keygen)/i,r=/(\[[^\[\]]*\])/g;function a(e,t,n){if(t.match(r)){!function e(t,n,o){if(0===n.length)return t=o;var i=n.shift(),r=i.match(/^\[(.+?)\]$/);if("[]"===i)return t=t||[],Array.isArray(t)?t.push(e(null,n,o)):(t._values=t._values||[],t._values.push(e(null,n,o))),t;if(r){var a=r[1],s=+a;isNaN(s)?(t=t||{})[a]=e(t[a],n,o):(t=t||[])[s]=e(t[s],n,o)}else t[i]=e(t[i],n,o);return t}(e,function(e){var t=[],n=new RegExp(r),o=/^([^\[\]]*)/.exec(e);for(o[1]&&t.push(o[1]);null!==(o=n.exec(e));)t.push(o[1]);return t}(t),n)}else{var o=e[t];o?(Array.isArray(o)||(e[t]=[o]),e[t].push(n)):e[t]=n}return e}function s(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=(n=encodeURIComponent(n)).replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}t.exports=function(e,t){"object"!=typeof t?t={hash:!!t}:void 0===t.hash&&(t.hash=!0);for(var n=t.hash?{}:"",r=t.serializer||(t.hash?a:s),l=e&&e.elements?e.elements:[],c=Object.create(null),u=0;u<l.length;++u){var d=l[u];if((t.disabled||!d.disabled)&&d.name&&i.test(d.nodeName)&&!o.test(d.type)){var f=d.name,p=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(p=void 0),t.empty){if("checkbox"!==d.type||d.checked||(p=""),"radio"===d.type&&(c[d.name]||d.checked?d.checked&&(c[d.name]=!0):c[d.name]=!1),!p&&"radio"==d.type)continue}else if(!p)continue;if("select-multiple"!==d.type)n=r(n,f,p);else{p=[];for(var h=d.options,v=!1,m=0;m<h.length;++m){var g=h[m],b=t.empty&&!g.value,y=g.value||b;g.selected&&y&&(v=!0,n=t.hash&&"[]"!==f.slice(f.length-2)?r(n,f+"[]",g.value):r(n,f,g.value))}!v&&t.empty&&(n=r(n,f,""))}}}if(t.empty)for(var f in c)c[f]||(n=r(n,f,""));return n}},{}],5:[function(e,t,n){(function(o){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:this).vexDialog=e()}(function(){return function t(n,o,i){function r(s,l){if(!o[s]){if(!n[s]){var c="function"==typeof e&&e;if(!l&&c)return c(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=o[s]={exports:{}};n[s][0].call(d.exports,function(e){var t=n[s][1][e];return r(t||e)},d,d.exports,t,n,o,i)}return o[s].exports}for(var a="function"==typeof e&&e,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(e,t,n){t.exports=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var o=n[1];if("body"==o){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var a=r[o]||r._default,s=a[0],l=a[1],c=a[2];(i=t.createElement("div")).innerHTML=l+e+c;for(;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);var u=t.createDocumentFragment();for(;i.firstChild;)u.appendChild(i.removeChild(i.firstChild));return u};var o,i=!1;"undefined"!=typeof document&&((o=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',i=!o.getElementsByTagName("link").length,o=void 0);var r={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:i?[1,"X<div>","</div>"]:[0,"",""]};r.td=r.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],r.option=r.optgroup=[1,'<select multiple="multiple">',"</select>"],r.thead=r.tbody=r.colgroup=r.caption=r.tfoot=[1,"<table>","</table>"],r.polyline=r.ellipse=r.polygon=r.circle=r.text=r.line=r.path=r.rect=r.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],2:[function(e,t,n){var o=/^(?:submit|button|image|reset|file)$/i,i=/^(?:input|select|textarea|keygen)/i,r=/(\[[^\[\]]*\])/g;function a(e,t,n){if(t.match(r)){!function e(t,n,o){if(0===n.length)return t=o;var i=n.shift(),r=i.match(/^\[(.+?)\]$/);if("[]"===i)return t=t||[],Array.isArray(t)?t.push(e(null,n,o)):(t._values=t._values||[],t._values.push(e(null,n,o))),t;if(r){var a=r[1],s=+a;isNaN(s)?(t=t||{})[a]=e(t[a],n,o):(t=t||[])[s]=e(t[s],n,o)}else t[i]=e(t[i],n,o);return t}(e,function(e){var t=[],n=new RegExp(r),o=/^([^\[\]]*)/.exec(e);for(o[1]&&t.push(o[1]);null!==(o=n.exec(e));)t.push(o[1]);return t}(t),n)}else{var o=e[t];o?(Array.isArray(o)||(e[t]=[o]),e[t].push(n)):e[t]=n}return e}function s(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=(n=encodeURIComponent(n)).replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}t.exports=function(e,t){"object"!=typeof t?t={hash:!!t}:void 0===t.hash&&(t.hash=!0);for(var n=t.hash?{}:"",r=t.serializer||(t.hash?a:s),l=e&&e.elements?e.elements:[],c=Object.create(null),u=0;u<l.length;++u){var d=l[u];if((t.disabled||!d.disabled)&&d.name&&i.test(d.nodeName)&&!o.test(d.type)){var f=d.name,p=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(p=void 0),t.empty){if("checkbox"!==d.type||d.checked||(p=""),"radio"===d.type&&(c[d.name]||d.checked?d.checked&&(c[d.name]=!0):c[d.name]=!1),!p&&"radio"==d.type)continue}else if(!p)continue;if("select-multiple"!==d.type)n=r(n,f,p);else{p=[];for(var h=d.options,v=!1,m=0;m<h.length;++m){var g=h[m],b=t.empty&&!g.value,y=g.value||b;g.selected&&y&&(v=!0,n=t.hash&&"[]"!==f.slice(f.length-2)?r(n,f+"[]",g.value):r(n,f,g.value))}!v&&t.empty&&(n=r(n,f,""))}}}if(t.empty)for(var f in c)c[f]||(n=r(n,f,""));return n}},{}],3:[function(e,t,n){var o=e("domify"),i=e("form-serialize");t.exports=function(e){var t={name:"dialog",open:function(t){var n=Object.assign({},this.defaultOptions,t);n.unsafeMessage&&!n.message?n.message=n.unsafeMessage:n.message&&(n.message=e._escapeHtml(n.message));var i=n.unsafeContent=function(e){var t=document.createElement("form");t.classList.add("vex-dialog-form");var n=document.createElement("div");n.classList.add("vex-dialog-message"),n.appendChild(e.message instanceof window.Node?e.message:o(e.message));var i=document.createElement("div");return i.classList.add("vex-dialog-input"),i.appendChild(e.input instanceof window.Node?e.input:o(e.input)),t.appendChild(n),t.appendChild(i),t}(n),r=e.open(n),a=n.beforeClose&&n.beforeClose.bind(r);if(r.options.beforeClose=function(){var e=!a||a();return e&&n.callback(this.value||!1),e}.bind(r),i.appendChild(function(e){var t=document.createElement("div");t.classList.add("vex-dialog-buttons");for(var n=0;n<e.length;n++){var o=e[n],i=document.createElement("button");i.type=o.type,i.textContent=o.text,i.className=o.className,i.classList.add("vex-dialog-button"),0===n?i.classList.add("vex-first"):n===e.length-1&&i.classList.add("vex-last"),function(e){i.addEventListener("click",function(t){e.click&&e.click.call(this,t)}.bind(this))}.bind(this)(o),t.appendChild(i)}return t}.call(r,n.buttons)),r.form=i,i.addEventListener("submit",n.onSubmit.bind(r)),n.focusFirstInput){var s=r.contentEl.querySelector("button, input, select, textarea");s&&s.focus()}return r},alert:function(e){return"string"==typeof e&&(e={message:e}),e=Object.assign({},this.defaultOptions,this.defaultAlertOptions,e),this.open(e)},confirm:function(e){if("object"!=typeof e||"function"!=typeof e.callback)throw new Error("dialog.confirm(options) requires options.callback.");return e=Object.assign({},this.defaultOptions,this.defaultConfirmOptions,e),this.open(e)},prompt:function(t){if("object"!=typeof t||"function"!=typeof t.callback)throw new Error("dialog.prompt(options) requires options.callback.");var n=Object.assign({},this.defaultOptions,this.defaultPromptOptions),o={unsafeMessage:'<label for="vex">'+e._escapeHtml(t.label||n.label)+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+e._escapeHtml(t.placeholder||n.placeholder)+'" value="'+e._escapeHtml(t.value||n.value)+'" />'},i=(t=Object.assign(n,o,t)).callback;return t.callback=function(e){if("object"==typeof e){var t=Object.keys(e);e=t.length?e[t[0]]:""}i(e)},this.open(t)},buttons:{YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary",click:function(){this.value=!0}},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(){this.value=!1,this.close()}}}};return t.defaultOptions={callback:function(){},afterOpen:function(){},message:"",input:"",buttons:[t.buttons.YES,t.buttons.NO],showCloseButton:!1,onSubmit:function(e){return e.preventDefault(),this.options.input&&(this.value=i(this.form,{hash:!0})),this.close()},focusFirstInput:!0},t.defaultAlertOptions={buttons:[t.buttons.YES]},t.defaultPromptOptions={label:"Prompt:",placeholder:"",value:""},t.defaultConfirmOptions={},t}},{domify:1,"form-serialize":2}]},{},[3])(3)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{domify:2,"form-serialize":4}],6:[function(e,t,n){var o=e("./vex");o.registerPlugin(e("vex-dialog")),t.exports=o},{"./vex":7,"vex-dialog":5}],7:[function(e,t,n){e("classlist-polyfill"),e("es6-object-assign").polyfill();var o=e("domify"),i=function(e){if(void 0!==e){var t=document.createElement("div");return t.appendChild(document.createTextNode(e)),t.innerHTML}return""},r=function(e,t){if("string"==typeof t&&0!==t.length)for(var n=t.split(" "),o=0;o<n.length;o++){var i=n[o];i.length&&e.classList.add(i)}},a=function(){var e=document.createElement("div"),t={animation:"animationend",WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oanimationend",msAnimation:"MSAnimationEnd"};for(var n in t)if(void 0!==e.style[n])return t[n];return!1}(),s="vex",l="vex-content",c="vex-overlay",u="vex-close",d="vex-closing",f="vex-open",p={},h=1,v=!1,m={open:function(e){var t=function(e){console.warn('The "'+e+'" property is deprecated in vex 3. Use CSS classes and the appropriate "ClassName" options, instead.'),console.warn("See http://github.hubspot.com/vex/api/advanced/#options")};e.css&&t("css"),e.overlayCSS&&t("overlayCSS"),e.contentCSS&&t("contentCSS"),e.closeCSS&&t("closeCSS");var n={};n.id=h++,p[n.id]=n,n.isOpen=!0,n.close=function(){if(!this.isOpen)return!0;var e=this.options;if(v&&!e.escapeButtonCloses)return!1;if(!1===function(){return!e.beforeClose||e.beforeClose.call(this)}.bind(this)())return!1;this.isOpen=!1;var t=window.getComputedStyle(this.contentEl);function n(e){return"none"!==t.getPropertyValue(e+"animation-name")&&"0s"!==t.getPropertyValue(e+"animation-duration")}var o=n("")||n("-webkit-")||n("-moz-")||n("-o-"),i=function t(){this.rootEl.parentNode&&(this.rootEl.removeEventListener(a,t),this.overlayEl.removeEventListener(a,t),delete p[this.id],this.rootEl.parentNode.removeChild(this.rootEl),this.bodyEl.removeChild(this.overlayEl),e.afterClose&&e.afterClose.call(this),0===Object.keys(p).length&&document.body.classList.remove(f))}.bind(this);return a&&o?(this.rootEl.addEventListener(a,i),this.overlayEl.addEventListener(a,i),this.rootEl.classList.add(d),this.overlayEl.classList.add(d)):i(),!0},"string"==typeof e&&(e={content:e}),e.unsafeContent&&!e.content?e.content=e.unsafeContent:e.content&&(e.content=i(e.content));var g=n.options=Object.assign({},m.defaultOptions,e),b=n.bodyEl=document.getElementsByTagName("body")[0],y=n.rootEl=document.createElement("div");y.classList.add(s),r(y,g.className);var C=n.overlayEl=document.createElement("div");C.classList.add(c),r(C,g.overlayClassName),g.overlayClosesOnClick&&y.addEventListener("click",function(e){e.target===y&&n.close()}),b.appendChild(C);var w=n.contentEl=document.createElement("div");if(w.classList.add(l),r(w,g.contentClassName),w.appendChild(g.content instanceof window.Node?g.content:o(g.content)),y.appendChild(w),g.showCloseButton){var x=n.closeEl=document.createElement("div");x.classList.add(u),r(x,g.closeClassName),x.addEventListener("click",n.close.bind(n)),w.appendChild(x)}return document.querySelector(g.appendLocation).appendChild(y),g.afterOpen&&g.afterOpen.call(n),document.body.classList.add(f),n},close:function(e){var t;if(e.id)t=e.id;else{if("string"!=typeof e)throw new TypeError("close requires a vex object or id string");t=e}return!!p[t]&&p[t].close()},closeTop:function(){var e=Object.keys(p);return!!e.length&&p[e[e.length-1]].close()},closeAll:function(){for(var e in p)this.close(e);return!0},getAll:function(){return p},getById:function(e){return p[e]}};window.addEventListener("keyup",function(e){27===e.keyCode&&(v=!0,m.closeTop(),v=!1)}),window.addEventListener("popstate",function(){m.defaultOptions.closeAllOnPopState&&m.closeAll()}),m.defaultOptions={content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",overlayClassName:"",contentClassName:"",closeClassName:"",closeAllOnPopState:!0},Object.defineProperty(m,"_escapeHtml",{configurable:!1,enumerable:!1,writable:!1,value:i}),m.registerPlugin=function(e,t){var n=e(m),o=t||n.name;if(m[o])throw new Error("Plugin "+t+" is already registered.");m[o]=n},t.exports=m},{"classlist-polyfill":1,domify:2,"es6-object-assign":3}]},{},[6])(6)}); |