UNPKG

w-ui

Version:

A Vue.js 2.0 UI Toolkit for mobile

1 lines 12.4 kB
module.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=301)}({1:function(e,t,n){"use strict";function r(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var i=o(r);return[n].concat(r.sources.map(function(e){return"/*# sourceURL="+r.sourceRoot+e+" */"})).concat([i]).join("\n")}return[n].join("\n")}function o(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=r(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var i=this[o][0];"number"==typeof i&&(r[i]=!0)}for(o=0;o<e.length;o++){var a=e[o];"number"==typeof a[0]&&r[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),t.push(a))}},t}},2:function(e,t,n){function r(e){for(var t=0;t<e.length;t++){var n=e[t],r=l[n.id];if(r){r.refs++;for(var o=0;o<r.parts.length;o++)r.parts[o](n.parts[o]);for(;o<n.parts.length;o++)r.parts.push(i(n.parts[o]));r.parts.length>n.parts.length&&(r.parts.length=n.parts.length)}else{for(var a=[],o=0;o<n.parts.length;o++)a.push(i(n.parts[o]));l[n.id]={id:n.id,refs:1,parts:a}}}}function o(){var e=document.createElement("style");return e.type="text/css",f.appendChild(e),e}function i(e){var t,n,r=document.querySelector("style["+g+'~="'+e.id+'"]');if(r){if(p)return h;r.parentNode.removeChild(r)}if(w){var i=m++;r=d||(d=o()),t=a.bind(null,r,i,!1),n=a.bind(null,r,i,!0)}else r=o(),t=u.bind(null,r),n=function(){r.parentNode.removeChild(r)};return t(e),function(r){if(r){if(r.css===e.css&&r.media===e.media&&r.sourceMap===e.sourceMap)return;t(e=r)}else n()}}function a(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=y(t,o);else{var i=document.createTextNode(o),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(i,a[t]):e.appendChild(i)}}function u(e,t){var n=t.css,r=t.media,o=t.sourceMap;if(r&&e.setAttribute("media",r),v.ssrId&&e.setAttribute(g,t.id),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var s="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!s)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var c=n(3),l={},f=s&&(document.head||document.getElementsByTagName("head")[0]),d=null,m=0,p=!1,h=function(){},v=null,g="data-vue-ssr-id",w="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,n,o){p=n,v=o||{};var i=c(e,t);return r(i),function(t){for(var n=[],o=0;o<i.length;o++){var a=i[o],u=l[a.id];u.refs--,n.push(u)}t?(i=c(e,t),r(i)):i=[];for(var o=0;o<n.length;o++){var u=n[o];if(0===u.refs){for(var s=0;s<u.parts.length;s++)u.parts[s]();delete l[u.id]}}}};var y=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},3:function(e,t,n){"use strict";e.exports=function(e,t){for(var n=[],r={},o=0;o<t.length;o++){var i=t[o],a=i[0],u=i[1],s=i[2],c=i[3],l={id:e+":"+o,css:u,media:s,sourceMap:c};r[a]?r[a].parts.push(l):n.push(r[a]={id:a,parts:[l]})}return n}},301:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Waterfall=void 0;var r=n(302),o=function(e){return e&&e.__esModule?e:{default:e}}(r);t.Waterfall=o.default},302:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n(303);var o=n(5);t.default={name:"w-waterfall",props:{items:{type:Array},columns:{default:2,type:Number},enterClass:{type:String}},data:function(){for(var e=[],t=0;t<this.columns;t++)e.push([]);return{columnData:e,currentIndex:0,currentColumn:0,pageIndex:0,columnHeight:e.slice(0),columnMap:{},screenHeight:window.innerHeight,loadedAll:!1}},created:function(){},mounted:function(){var e,t=this,n=this.getRandomName(),r=this.getRandomName(),o=this.getRandomName(),i=!1;window[n]=function(t){e&&clearTimeout(e),i=!0,e=setTimeout(window[r],100)},window[o]=function(t){e&&clearTimeout(e),i=!0,e=setTimeout(window[r],100)},window[r]=function(e){i&&(i=!1,t.checkPage())},document.removeEventListener("touchmove",window[n]),document.removeEventListener("touchend",window[r]),document.addEventListener("touchmove",window[n],!1),document.addEventListener("touchend",window[r],!1),window.addEventListener("scroll",window[n],!1),this.nextPage()},watch:{currentIndex:function(e,t){var n=this;!function(){n.$nextTick(function(){var t=n.$slots.default[e-1];(0,o.addClass)(t.elm,n.enterClass+"-before");var r=t.elm.querySelectorAll("img");r&&r.length>0?(r=Array.prototype.slice.call(r,0),Promise.all(r.map(function(e){return new Promise(function(r,i){var a=setTimeout(function(){r(20)},1e3);e.onload=function(){clearTimeout(a),r(e.height),(0,o.removeClass)(t.elm,n.enterClass+"-before"),(0,o.addClass)(t.elm,n.enterClass+"-after")},e.onerror=function(){clearTimeout(a),r(20)}})})).then(function(t){n.computeHeight(e-1)})):n.computeHeight(e-1)})}()}},render:function(e){var t=this;return e("div",{class:"wui-waterfall"},[e("div",{class:"waterfall-content"},[this.columnData.map(function(n,r){return e("div",{class:"wui-waterfall-column",key:"column-"+r},[n.map(function(e){return t.$slots.default[e]})])})]),this.loadedAll?e("div",{class:"no-more"},["- 没有更多了 -"]):""])},methods:{computeHeight:function(e){var t=this.columnMap[e],n=this.$slots.default[e],o=n.elm.offsetHeight;this.columnHeight[t]=parseInt(this.columnHeight[t])+parseInt(o);var i=this.getColumn(),a=r(i,2),u=a[0],s=a[1];this.currentColumn=s,u>this.pageIndex*this.screenHeight||this.next()},getRandomName:function(){return"func_"+(1e6*Math.random()).toString(32)+"_"+Date.now().toString(32)},getColumn:function(){for(var e=this.columnHeight[0],t=0,n=0;n<this.columnHeight.length;n++)this.columnHeight[n]<e&&(e=this.columnHeight[n],t=n);return[e,t]},next:function(){!this.loadedAll&&this.currentIndex<this.$slots.default.length?(this.columnData[this.currentColumn].push(this.currentIndex),this.columnMap[this.currentIndex]=this.currentColumn,this.currentIndex++):this.loadedAll=!0},nextPage:function(){this.pageIndex++,this.next()},checkPage:function(){(document.documentElement.scrollTop||document.body.scrollTop)-50>(this.pageIndex-1)*this.screenHeight&&this.nextPage()}}}},303:function(e,t,n){var r=n(304);"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);n(2)("393c39a8",r,!1,{})},304:function(e,t,n){t=e.exports=n(1)(!1),t.push([e.i,".wui-waterfall {\n position: relative;\n}\n.wui-waterfall .waterfall-content {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n width: 100%;\n max-width: 100%;\n}\n.wui-waterfall .waterfall-content .wui-waterfall-column img {\n width: 100%;\n}\n.wui-waterfall .no-more {\n text-align: center;\n color: #ccc;\n}\n",""])},4:function(e,t){e.exports=require("vue")},5:function(e,t,n){"use strict";function r(e,t){if(!e||!t)return!1;if(-1!==t.indexOf(" "))throw new Error("className should not contain space.");return e.classList?e.classList.contains(t):(" "+e.className+" ").indexOf(" "+t+" ")>-1}function o(e,t){if(e){for(var n=e.className,o=(t||"").split(" "),i=0,a=o.length;i<a;i++){var u=o[i];u&&(e.classList?e.classList.add(u):r(e,u)||(n+=" "+u))}e.classList||(e.className=n)}}function i(e,t){if(e&&t){for(var n=t.split(" "),o=" "+e.className+" ",i=0,a=n.length;i<a;i++){var u=n[i];u&&(e.classList?e.classList.remove(u):r(e,u)&&(o=o.replace(" "+u+" "," ")))}e.classList||(e.className=y(o))}}function a(e,t,n){if(e&&t)if("object"===(void 0===t?"undefined":f(t)))for(var r in t)t.hasOwnProperty(r)&&a(e,r,t[r]);else t=b(t),"opacity"===t&&g<9?e.style.filter=isNaN(n)?"":"alpha(opacity="+100*n+")":e.style[t]=n}function u(e){for(var t=e;t&&"HTML"!==t.tagName&&"BODY"!==t.tagName&&1===t.nodeType;){var n=document.defaultView.getComputedStyle(t).overflowY;if("scroll"===n||"auto"===n)return t;t=t.parentNode}return window}function s(e,t){var n=e==window?document.body.offsetHeight:e.offsetHeight,r=e===window?0:e.getBoundingClientRect().top,o=t.getBoundingClientRect().top-r,i=o+t.offsetHeight;return o>=0&&o<n||i>0&&i<=n}function c(e){function t(n,r,o){if(n!==r){var i=n+o>r?r:n+o;n>r&&(i=n-o<r?r:n-o),e===window?window.scrollTo(i,i):e.scrollTop=i,window.requestAnimationFrame(function(){return t(i,r,o)})}}var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:500;window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)});var i=Math.abs(n-r);t(n,r,Math.ceil(i/o*50))}function l(){return++w}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=t.isArray=t.isDate=t.isFunction=t.isNumber=t.isString=t.isBoolean=t.pageScroll=t.isIOS=t.getStyle=t.once=t.off=t.on=void 0;var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.hasClass=r,t.addClass=o,t.removeClass=i,t.setStyle=a,t.getScrollview=u,t.checkInview=s,t.scrollTop=c,t.getZIndex=l;var d=n(4),m=function(e){return e&&e.__esModule?e:{default:e}}(d),p=m.default.prototype.$isServer,h=/([\:\-\_]+(.))/g,v=/^moz([A-Z])/,g=p?0:Number(document.documentMode),w=1e4,y=function(e){return(e||"").replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")},b=function(e){return e.replace(h,function(e,t,n,r){return r?n.toUpperCase():n}).replace(v,"Moz$1")},x=t.on=function(){return!p&&document.addEventListener?function(e,t,n){e&&t&&n&&e.addEventListener(t,n,!1)}:function(e,t,n){e&&t&&n&&e.attachEvent("on"+t,n)}}(),S=t.off=function(){return!p&&document.removeEventListener?function(e,t,n){e&&t&&e.removeEventListener(t,n,!1)}:function(e,t,n){e&&t&&e.detachEvent("on"+t,n)}}();t.once=function(e,t,n){x(e,t,function r(){n&&n.apply(this,arguments),S(e,t,r)})},t.getStyle=g<9?function(e,t){if(!p){if(!e||!t)return null;t=b(t),"float"===t&&(t="styleFloat");try{switch(t){case"opacity":try{return e.filters.item("alpha").opacity/100}catch(e){return 1}default:return e.style[t]||e.currentStyle?e.currentStyle[t]:null}}catch(n){return e.style[t]}}}:function(e,t){if(!p){if(!e||!t)return null;t=b(t),"float"===t&&(t="cssFloat");try{var n=document.defaultView.getComputedStyle(e,"");return e.style[t]||n?n[t]:null}catch(n){return e.style[t]}}},t.isIOS=!!(window.navigator&&window.navigator.userAgent||"").match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),t.pageScroll=function(){var e=function(e){e.preventDefault(),e.stopPropagation()},t=!1;return{lock:function(n){t||(t=!0,(n||document).addEventListener("touchmove",e))},unlock:function(n){t=!1,(n||document).removeEventListener("touchmove",e)}}}(),t.isBoolean=function(e){return"boolean"==typeof e},t.isString=function(e){return"string"==typeof e},t.isNumber=function(e){return"number"==typeof e},t.isFunction=function(e){return"function"==typeof e},t.isDate=function(e){return"date"===Object.prototype.toString.call(e).match(/^(\[object )(\w+)\]$/i)[2].toLowerCase()},t.isArray=Array.isArray,t.isObject=function(e){return"object"===(void 0===e?"undefined":f(e))}}});