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