UNPKG

w-ui

Version:

A Vue.js 2.0 UI Toolkit for mobile

1 lines 16 kB
module.exports=function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=243)}({243:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(244),i={name:"w-sortable"};i.install=function(t){t.directive("sortable",{inserted:function(t,e){new o(t,e.value||{})}})},e.Sortable=i},244:function(t,e,n){"use strict";var o,i,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(r){o=r,void 0!==(i="function"==typeof o?o.call(e,n,e,t):o)&&(t.exports=i)}(function(){function t(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be HTMLElement, and not "+{}.toString.call(t);this.el=t,this.options=e=y({},e),t[q]=this;var n={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(t.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0}};for(var o in n)!(o in e)&&(e[o]=n[o]);st(e);for(var i in this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&$,a(t,"mousedown",this._onTapStart),a(t,"touchstart",this._onTapStart),a(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(a(t,"dragover",this),a(t,"dragenter",this)),rt.push(this._onDragOver),e.store&&this.sort(e.store.get(this))}function e(t,e){"clone"!==t.lastPullMode&&(e=!0),E&&E.state!==e&&(c(E,"display",e?"none":""),e||E.state&&(t.options.group.revertClone?(x.insertBefore(E,N),t._animate(T,E)):x.insertBefore(E,T)),E.state=e)}function n(t,e,n){if(t){n=n||G;do{if(">*"===e&&t.parentNode===n||b(t,e))return t}while(t=o(t))}return null}function o(t){var e=t.host;return e&&e.nodeType?e:t.parentNode}function i(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.preventDefault()}function a(t,e,n){t.addEventListener(e,n,K)}function s(t,e,n){t.removeEventListener(e,n,K)}function l(t,e,n){if(t)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(W," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(W," ")}}function c(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return G.defaultView&&G.defaultView.getComputedStyle?n=G.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function u(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function d(t,e,n,o,i,r,a){t=t||e[q];var s=G.createEvent("Event"),l=t.options,c="on"+n.charAt(0).toUpperCase()+n.substr(1);s.initEvent(n,!0,!0),s.to=e,s.from=i||e,s.item=o||e,s.clone=E,s.oldIndex=r,s.newIndex=a,e.dispatchEvent(s),l[c]&&l[c].call(t,s)}function h(t,e,n,o,i,r,a){var s,l,c=t[q],u=c.options.onMove;return s=G.createEvent("Event"),s.initEvent("move",!0,!0),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||e.getBoundingClientRect(),t.dispatchEvent(s),u&&(l=u.call(c,s,a)),l}function f(t){t.draggable=!1}function p(){et=!1}function g(t,e){var n=t.lastElementChild,o=n.getBoundingClientRect();return(e.clientY-(o.top+o.height)>5||e.clientX-(o.right+o.width)>5)&&n}function v(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function m(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"===t.nodeName.toUpperCase()||">*"!==e&&!b(t,e)||n++;return n}function b(t,e){if(t){e=e.split(".");var n=e.shift().toUpperCase(),o=new RegExp("\\s("+e.join("|")+")(?=\\s)","g");return!(""!==n&&t.nodeName.toUpperCase()!=n||e.length&&((" "+t.className+" ").match(o)||[]).length!=e.length)}return!1}function _(t,e){var n,o;return function(){void 0===n&&(n=arguments,o=this,setTimeout(function(){1===n.length?t.call(o,n[0]):t.apply(o,n),n=void 0},e))}}function y(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function D(t){return Z?Z(t).clone(!0)[0]:J&&J.dom?J.dom(t).cloneNode(!0):t.cloneNode(!0)}function w(t){for(var e=t.getElementsByTagName("input"),n=e.length;n--;){var o=e[n];o.checked&&it.push(o)}}if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var T,S,C,E,x,N,k,B,O,Y,X,M,P,A,R,I,j,L,F,U,H={},W=/\s+/g,V=/left|right|inline/,q="Sortable"+(new Date).getTime(),z=window,G=z.document,Q=z.parseInt,Z=z.jQuery||z.Zepto,J=z.Polymer,K=!1,$=!!("draggable"in G.createElement("div")),tt=function(t){return!navigator.userAgent.match(/Trident.*rv[ :]?11\./)&&(t=G.createElement("x"),t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents)}(),et=!1,nt=Math.abs,ot=Math.min,it=[],rt=[],at=_(function(t,e,n){if(n&&e.scroll){var o,i,r,a,s,l,c=n[q],u=e.scrollSensitivity,d=e.scrollSpeed,h=t.clientX,f=t.clientY,p=window.innerWidth,g=window.innerHeight;if(O!==n&&(B=e.scroll,O=n,Y=e.scrollFn,!0===B)){B=n;do{if(B.offsetWidth<B.scrollWidth||B.offsetHeight<B.scrollHeight)break}while(B=B.parentNode)}B&&(o=B,i=B.getBoundingClientRect(),r=(nt(i.right-h)<=u)-(nt(i.left-h)<=u),a=(nt(i.bottom-f)<=u)-(nt(i.top-f)<=u)),r||a||(r=(p-h<=u)-(h<=u),a=(g-f<=u)-(f<=u),(r||a)&&(o=z)),H.vx===r&&H.vy===a&&H.el===o||(H.el=o,H.vx=r,H.vy=a,clearInterval(H.pid),o&&(H.pid=setInterval(function(){return l=a?a*d:0,s=r?r*d:0,"function"==typeof Y?Y.call(c,s,l,t):void(o===z?z.scrollTo(z.pageXOffset+s,z.pageYOffset+l):(o.scrollTop+=l,o.scrollLeft+=s))},24)))}},30),st=function(t){function e(t,e){return void 0!==t&&!0!==t||(t=n.name),"function"==typeof t?t:function(n,o){var i=o.options.group.name;return e?t:t&&(t.join?t.indexOf(i)>-1:i==t)}}var n={},o=t.group;o&&"object"==(void 0===o?"undefined":r(o))||(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n};t.prototype={constructor:t,_onTapStart:function(t){var e,o=this,i=this.el,r=this.options,a=r.preventOnFilter,s=t.type,l=t.touches&&t.touches[0],c=(l||t).target,u=t.target.shadowRoot&&t.path[0]||c,h=r.filter;if(w(i),!T&&!("mousedown"===s&&0!==t.button||r.disabled)&&(c=n(c,r.draggable,i))&&k!==c){if(e=m(c,r.draggable),"function"==typeof h){if(h.call(this,t,c,this))return d(o,u,"filter",c,i,e),void(a&&t.preventDefault())}else if(h&&(h=h.split(",").some(function(t){if(t=n(u,t.trim(),i))return d(o,t,"filter",c,i,e),!0})))return void(a&&t.preventDefault());r.handle&&!n(u,r.handle,i)||this._prepareDragStart(t,l,c,e)}},_prepareDragStart:function(t,e,n,o){var i,r=this,s=r.el,c=r.options,h=s.ownerDocument;n&&!T&&n.parentNode===s&&(L=t,x=s,T=n,S=T.parentNode,N=T.nextSibling,k=n,I=c.group,A=o,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,T.style["will-change"]="transform",i=function(){r._disableDelayedDrag(),T.draggable=r.nativeDraggable,l(T,c.chosenClass,!0),r._triggerDragStart(t,e),d(r,x,"choose",T,x,A)},c.ignore.split(",").forEach(function(t){u(T,t.trim(),f)}),a(h,"mouseup",r._onDrop),a(h,"touchend",r._onDrop),a(h,"touchcancel",r._onDrop),a(h,"pointercancel",r._onDrop),a(h,"selectstart",r),c.delay?(a(h,"mouseup",r._disableDelayedDrag),a(h,"touchend",r._disableDelayedDrag),a(h,"touchcancel",r._disableDelayedDrag),a(h,"mousemove",r._disableDelayedDrag),a(h,"touchmove",r._disableDelayedDrag),a(h,"pointermove",r._disableDelayedDrag),r._dragStartTimer=setTimeout(i,c.delay)):i())},_disableDelayedDrag:function(){var t=this.el.ownerDocument;clearTimeout(this._dragStartTimer),s(t,"mouseup",this._disableDelayedDrag),s(t,"touchend",this._disableDelayedDrag),s(t,"touchcancel",this._disableDelayedDrag),s(t,"mousemove",this._disableDelayedDrag),s(t,"touchmove",this._disableDelayedDrag),s(t,"pointermove",this._disableDelayedDrag)},_triggerDragStart:function(t,e){e=e||("touch"==t.pointerType?t:null),e?(L={target:T,clientX:e.clientX,clientY:e.clientY},this._onDragStart(L,"touch")):this.nativeDraggable?(a(T,"dragend",this),a(x,"dragstart",this._onDragStart)):this._onDragStart(L,!0);try{G.selection?setTimeout(function(){G.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(){if(x&&T){var e=this.options;l(T,e.ghostClass,!0),l(T,e.dragClass,!1),t.active=this,d(this,x,"start",T,x,A)}else this._nulling()},_emulateDragOver:function(){if(F){if(this._lastX===F.clientX&&this._lastY===F.clientY)return;this._lastX=F.clientX,this._lastY=F.clientY,tt||c(C,"display","none");var t=G.elementFromPoint(F.clientX,F.clientY),e=t,n=rt.length;if(e)do{if(e[q]){for(;n--;)rt[n]({clientX:F.clientX,clientY:F.clientY,target:t,rootEl:e});break}t=e}while(e=e.parentNode);tt||c(C,"display","")}},_onTouchMove:function(e){if(L){var n=this.options,o=n.fallbackTolerance,i=n.fallbackOffset,r=e.touches?e.touches[0]:e,a=r.clientX-L.clientX+i.x,s=r.clientY-L.clientY+i.y,l=e.touches?"translate3d("+a+"px,"+s+"px,0)":"translate("+a+"px,"+s+"px)";if(!t.active){if(o&&ot(nt(r.clientX-this._lastX),nt(r.clientY-this._lastY))<o)return;this._dragStarted()}this._appendGhost(),U=!0,F=r,c(C,"webkitTransform",l),c(C,"mozTransform",l),c(C,"msTransform",l),c(C,"transform",l),e.preventDefault()}},_appendGhost:function(){if(!C){var t,e=T.getBoundingClientRect(),n=c(T),o=this.options;C=T.cloneNode(!0),l(C,o.ghostClass,!1),l(C,o.fallbackClass,!0),l(C,o.dragClass,!0),c(C,"top",e.top-Q(n.marginTop,10)),c(C,"left",e.left-Q(n.marginLeft,10)),c(C,"width",e.width),c(C,"height",e.height),c(C,"opacity","0.8"),c(C,"position","fixed"),c(C,"zIndex","100000"),c(C,"pointerEvents","none"),o.fallbackOnBody&&G.body.appendChild(C)||x.appendChild(C),t=C.getBoundingClientRect(),c(C,"width",2*e.width-t.width),c(C,"height",2*e.height-t.height)}},_onDragStart:function(t,e){var n=t.dataTransfer,o=this.options;this._offUpEvents(),I.checkPull(this,this,T,t)&&(E=D(T),E.draggable=!1,E.style["will-change"]="",c(E,"display","none"),l(E,this.options.chosenClass,!1),x.insertBefore(E,T),d(this,x,"clone",T)),l(T,o.dragClass,!0),e?("touch"===e?(a(G,"touchmove",this._onTouchMove),a(G,"touchend",this._onDrop),a(G,"touchcancel",this._onDrop),a(G,"pointermove",this._onTouchMove),a(G,"pointerup",this._onDrop)):(a(G,"mousemove",this._onTouchMove),a(G,"mouseup",this._onDrop)),this._loopId=setInterval(this._emulateDragOver,50)):(n&&(n.effectAllowed="move",o.setData&&o.setData.call(this,n,T)),a(G,"drop",this),setTimeout(this._dragStarted,0))},_onDragOver:function(o){var i,r,a,s,l=this.el,u=this.options,d=u.group,f=t.active,v=I===d,m=!1,b=u.sort;if(void 0!==o.preventDefault&&(o.preventDefault(),!u.dragoverBubble&&o.stopPropagation()),!T.animated&&(U=!0,f&&!u.disabled&&(v?b||(s=!x.contains(T)):j===this||(f.lastPullMode=I.checkPull(this,f,T,o))&&d.checkPut(this,f,T,o))&&(void 0===o.rootEl||o.rootEl===this.el))){if(at(o,u,this.el),et)return;if(i=n(o.target,u.draggable,l),r=T.getBoundingClientRect(),j!==this&&(j=this,m=!0),s)return e(f,!0),S=x,void(E||N?x.insertBefore(T,E||N):b||x.appendChild(T));if(0===l.children.length||l.children[0]===C||l===o.target&&(i=g(l,o))){if(i){if(i.animated)return;a=i.getBoundingClientRect()}e(f,v),!1!==h(x,l,T,r,i,a,o)&&(T.contains(l)||(l.appendChild(T),S=l),this._animate(r,T),i&&this._animate(a,i))}else if(i&&!i.animated&&i!==T&&void 0!==i.parentNode[q]){X!==i&&(X=i,M=c(i),P=c(i.parentNode)),a=i.getBoundingClientRect();var _=a.right-a.left,y=a.bottom-a.top,D=V.test(M.cssFloat+M.display)||"flex"==P.display&&0===P["flex-direction"].indexOf("row"),w=i.offsetWidth>T.offsetWidth,k=i.offsetHeight>T.offsetHeight,B=(D?(o.clientX-a.left)/_:(o.clientY-a.top)/y)>.5,O=i.nextElementSibling,Y=h(x,l,T,r,i,a,o),A=!1;if(!1!==Y){if(et=!0,setTimeout(p,30),e(f,v),1===Y||-1===Y)A=1===Y;else if(D){var R=T.offsetTop,L=i.offsetTop;A=R===L?i.previousElementSibling===T&&!w||B&&w:i.previousElementSibling===T||T.previousElementSibling===i?(o.clientY-a.top)/y>.5:L>R}else m||(A=O!==T&&!k||B&&k);T.contains(l)||(A&&!O?l.appendChild(T):i.parentNode.insertBefore(T,A?O:i)),S=T.parentNode,this._animate(r,T),this._animate(a,i)}}}},_animate:function(t,e){var n=this.options.animation;if(n){var o=e.getBoundingClientRect();1===t.nodeType&&(t=t.getBoundingClientRect()),c(e,"transition","none"),c(e,"transform","translate3d("+(t.left-o.left)+"px,"+(t.top-o.top)+"px,0)"),e.offsetWidth,c(e,"transition","all "+n+"ms"),c(e,"transform","translate3d(0,0,0)"),clearTimeout(e.animated),e.animated=setTimeout(function(){c(e,"transition",""),c(e,"transform",""),e.animated=!1},n)}},_offUpEvents:function(){var t=this.el.ownerDocument;s(G,"touchmove",this._onTouchMove),s(G,"pointermove",this._onTouchMove),s(t,"mouseup",this._onDrop),s(t,"touchend",this._onDrop),s(t,"pointerup",this._onDrop),s(t,"touchcancel",this._onDrop),s(t,"selectstart",this)},_onDrop:function(e){var n=this.el,o=this.options;clearInterval(this._loopId),clearInterval(H.pid),clearTimeout(this._dragStartTimer),s(G,"mousemove",this._onTouchMove),this.nativeDraggable&&(s(G,"drop",this),s(n,"dragstart",this._onDragStart)),this._offUpEvents(),e&&(U&&(e.preventDefault(),!o.dropBubble&&e.stopPropagation()),C&&C.parentNode.removeChild(C),x!==S&&"clone"===t.active.lastPullMode||E&&E.parentNode.removeChild(E),T&&(this.nativeDraggable&&s(T,"dragend",this),f(T),T.style["will-change"]="",l(T,this.options.ghostClass,!1),l(T,this.options.chosenClass,!1),x!==S?(R=m(T,o.draggable))>=0&&(d(null,S,"add",T,x,A,R),d(this,x,"remove",T,x,A,R),d(null,S,"sort",T,x,A,R),d(this,x,"sort",T,x,A,R)):T.nextSibling!==N&&(R=m(T,o.draggable))>=0&&(d(this,x,"update",T,x,A,R),d(this,x,"sort",T,x,A,R)),t.active&&(null!=R&&-1!==R||(R=A),d(this,x,"end",T,x,A,R),this.save()))),this._nulling()},_nulling:function(){x=T=S=C=N=E=k=B=O=L=F=U=R=X=M=j=I=t.active=null,it.forEach(function(t){t.checked=!0}),it.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragover":case"dragenter":T&&(this._onDragOver(t),i(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],o=this.el.children,i=0,r=o.length,a=this.options;i<r;i++)t=o[i],n(t,a.draggable,this.el)&&e.push(t.getAttribute(a.dataIdAttr)||v(t));return e},sort:function(t){var e={},o=this.el;this.toArray().forEach(function(t,i){var r=o.children[i];n(r,this.options.draggable,o)&&(e[t]=r)},this),t.forEach(function(t){e[t]&&(o.removeChild(e[t]),o.appendChild(e[t]))})},save:function(){var t=this.options.store;t&&t.set(this)},closest:function(t,e){return n(t,e||this.options.draggable,this.el)},option:function(t,e){var n=this.options;return void 0===e?n[t]:(n[t]=e,void("group"===t&&st(n)))},destroy:function(){var t=this.el;t[q]=null,s(t,"mousedown",this._onTapStart),s(t,"touchstart",this._onTapStart),s(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(s(t,"dragover",this),s(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),rt.splice(rt.indexOf(this._onDragOver),1),this._onDrop(),this.el=t=null}},a(G,"touchmove",function(e){t.active&&e.preventDefault()});try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){K={capture:!1,passive:!1}}}))}catch(t){}return t.utils={on:a,off:s,css:c,find:u,is:function(t,e){return!!n(t,e,t)},extend:y,throttle:_,closest:n,toggleClass:l,clone:D,index:m},t.create=function(e,n){return new t(e,n)},t.version="1.5.1",t})}});