| 1 |
- !function(){var t={},e={},i={},n={};t=function(t){function e(){}function i(t,i){var n;return Object.create?n=Object.create(t):(e.prototype=t,n=new e),n.constructor=i,n}function n(t,e){if(t){if(t.nodeType)return[t];var e=e&&e.nodeType?e:document;return t&&"string"==typeof t?e.querySelectorAll(t):void 0}}for(var r=/\\?\{([^{}]+)\}/g,s="",l=/^[\s\xa0]+|[\s\xa0]+$/g,o=String.prototype.trim,a=o?function(t){return null==t?s:o.call(t)}:function(t){return null==t?s:(t+"").replace(l,s)},c=0,u=function(t){var e=t.offsetTop;return null!=t.offsetParent&&(e+=u(t.offsetParent)),e},f=function(t){var e=t.offsetLeft;return null!=t.offsetParent&&(e+=f(t.offsetParent)),e},d=({isObject:function(t){return t===Object(t)},isArray:Array.isArray||function(t){return"[object Array]"==toString.call(t)},isEmpty:function(t){if(null==t)return!0;if(this.isArray(t)||this.isString(t))return 0===t.length;for(var e in t)if(this.has(t,e))return!1;return!0},mix:function(t,e,i){for(var n in e)t[n]=e[n];return t},extend:function(t,e,n,r){if(!e||!t)return t;var s,l=e.prototype;return s=i(l,t),t.prototype=this.mix(s,t.prototype),t.superclass=i(l,e),n&&this.mix(s,n),r&&this.mix(t,r),t},startsWith:function(t,e){return 0===t.lastIndexOf(e,0)},endsWith:function(t,e){var i=t.length-e.length;return i>=0&&t.indexOf(e,i)===i},trim:a,substitute:function(t,e,i){return"string"==typeof t&&e?t.replace(i||r,function(t,i){return"\\"===t.charAt(0)?t.slice(1):void 0===e[i]?s:e[i]}):t},vendor:function(){for(var t,e=document.createElement("div").style,i=["t","webkitT","MozT","msT","OT"],n=0,r=i.length;n<r;n++)if(t=i[n]+"ransform",t in e)return i[n].substr(0,i[n].length-1);return!1}(),prefixStyle:function(t){return this.vendor!==!1&&(""===this.vendor?t:this.vendor+t.charAt(0).toUpperCase()+t.substr(1))},hasClass:function(t,e){return t&&t.className&&e&&t.className.indexOf(e)!=-1},addClass:function(t,e){t&&e&&!this.hasClass(t,e)&&(t.className+=" "+e)},removeClass:function(t,e){t&&t.className&&e&&(t.className=t.className.replace(e,""))},remove:function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},getOffsetTop:u,getOffsetLeft:f,findParentEl:function(t,e,i){var n=null,r=null,s=/^#/.test(e)?"id":/^\./.test(e)?"class":"tag",l=e.replace(/\.|#/g,"");if(i&&"string"==typeof i&&(i=document.querySelector(i)),i=i||document.body,t&&e){if("class"==s&&t.className&&t.className.match(l))return t;if("id"==s&&t.id&&a(t.id)==l)return t;if("tag"==s&&t.tagName.toLowerCase()==l)return t;for(;!n&&r!=i&&(r=t.parentNode);){if("class"==s&&r.className&&r.className.match(l)||"id"==s&&r.id&&a(r.id)==l||"tag"==s&&r.tagName&&r.tagName.toLowerCase()==l)return n=r;t=r}return null}},guid:function(t){var e=++c+"";return t?t+e:e},isAndroid:function(){return/Android /.test(window.navigator.appVersion)},isBadAndroid:function(){return/Android /.test(window.navigator.appVersion)&&!/Chrome\/\d/.test(window.navigator.appVersion)},px2Num:function(t){return Number(t.replace(/px/,""))},getNodes:n,getNode:function(t,e){var i=n(t,e);return i&&i[0]},stringifyStyle:function(t){var e="";for(var i in t)e+=[i,":",t[i],";"].join("");return e}}),h=["Arguments","Function","String","Number","Date","RegExp"],p=0;p<h.length;p++)d["is"+h[p]]=function(t){return toString.call(t)=="[object "+h[p]+"]"};return"object"==typeof module&&module.exports?t=d:d}(t),e=function(e){var i=t,n=function(t){var e,i=!1;return function(){return i?e:(i=!0,e=t.apply(this,arguments),t=null,e)}},r={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var n=this._events[t]||(this._events[t]=[]);return n.push({callback:e,context:i,ctx:i||this}),this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this,s=n(function(){r.off(t,s),e.apply(this,arguments)});return s._callback=e,this.on(t,s,i)},off:function(t,e,i){if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i)return this._events=void 0,this;for(var n=t?[t]:Object.keys(this._events),r=0,s=n.length;r<s;r++){t=n[r];var o=this._events[t];if(o)if(e||i){for(var a=[],c=0,u=o.length;c<u;c++){var f=o[c];(e&&e!==f.callback&&e!==f.callback._callback||i&&i!==f.context)&&a.push(f)}a.length?this._events[t]=a:delete this._events[t]}else delete this._events[t]}return this},trigger:function(t){if(!this._events)return this;var e=Array.prototype.slice.call(arguments,1);if(!l(this,"trigger",t,e))return this;var i=this._events[t],n=this._events.all;return i&&o(i,e),n&&o(n,arguments),this},listenTo:function(t,e,n){var r=this._listeningTo||(this._listeningTo={}),s=t._listenId||(t._listenId=i.guid("l"));return r[s]=t,n||"object"!=typeof e||(n=this),t.on(e,n,this),this},listenToOnce:function(t,e,i){if("object"==typeof e){for(var r in e)this.listenToOnce(t,r,e[r]);return this}var s=n(function(){this.stopListening(t,e,s),i.apply(this,arguments)});return s._callback=i,this.listenTo(t,e,s)},stopListening:function(t,e,n){var r=this._listeningTo;if(!r)return this;var s=!e&&!n;n||"object"!=typeof e||(n=this),t&&((r={})[t._listenId]=t);for(var l in r)t=r[l],t.off(e,n,this),(s||i.isEmpty(t._events))&&delete this._listeningTo[l];return this}},s=/\s+/,l=function(t,e,i,n){if(!i)return!0;if("object"==typeof i){for(var r in i)t[e].apply(t,[r,i[r]].concat(n));return!1}if(s.test(i)){for(var l=i.split(s),o=0,a=l.length;o<a;o++)t[e].apply(t,[l[o]].concat(n));return!1}return!0},o=function(t,e){var i,n=-1,r=t.length,s=e[0],l=e[1],o=e[2];switch(e.length){case 0:for(;++n<r;)(i=t[n]).callback.call(i.ctx);return;case 1:for(;++n<r;)(i=t[n]).callback.call(i.ctx,s);return;case 2:for(;++n<r;)(i=t[n]).callback.call(i.ctx,s,l);return;case 3:for(;++n<r;)(i=t[n]).callback.call(i.ctx,s,l,o);return;default:for(;++n<r;)(i=t[n]).callback.apply(i.ctx,e);return}};return r.bind=r.on,r.unbind=r.off,"object"==typeof module&&module.exports?e=r:r}(e),i=function(i){var n=t,r=e,s=function(){};return n.mix(s.prototype,r),n.mix(s.prototype,{plug:function(t){var e=this;if(t&&t.pluginId){e.__plugins||(e.__plugins=[]);var i=e.getPlugin(t.pluginId);return i&&e.unplug(t.pluginId),t.pluginInitializer(e),e.__plugins.push(t),e}},unplug:function(t){var e=this;if(t&&e.__plugins){var i="string"==typeof t?e.getPlugin(t):t;i.pluginDestructor(e);for(var n=0,r=e.__plugins.length;n<r;n++)if(e.__plugins[n]==i)return e.__plugins.splice(n,1)}},getPlugin:function(t){var e=this,i=[];if(e.__plugins){for(var n=0,r=e.__plugins.length;n<r;n++)e.__plugins[n]&&e.__plugins[n].pluginId==t&&i.push(e.__plugins[n]);return i.length>1?i:i[0]||null}}}),"object"==typeof module&&module.exports?i=s:s}(i),n=function(e){var n=t,r=i,s=n.prefixStyle("transform"),l=n.prefixStyle("transition"),o=function(t){o.superclass.constructor.call(this,t),this.userConfig=n.mix({transition:"all 0.5s ease"},t)};if(n.extend(o,r,{pluginId:"infinite",visibleElements:{},sections:{},pluginInitializer:function(t){var e=this;return e.xscroll=t,e.isY=!("y"!=t.userConfig.zoomType),e._={_top:e.isY?"_top":"_left",_height:e.isY?"_height":"_width",top:e.isY?"top":"left",height:e.isY?"height":"width",width:e.isY?"width":"height",y:e.isY?"y":"x",translate:e.isY?"translateY":"translateX",containerHeight:e.isY?"containerHeight":"containerWidth",scrollTop:e.isY?"scrollTop":"scrollLeft"},e._initInfinite(),t.on("afterrender",function(){e.render(),e._bindEvt()}),e},pluginDestructor:function(){for(var t=this,e=t._,i=0;i<t.infiniteLength;i++)t.infiniteElements[i].style[e.top]="auto",t.infiniteElements[i].style[s]="none",t.infiniteElements[i].style.visibility="hidden";return t.xscroll&&t.xscroll.off("scroll",t._updateByScroll,t),t.xscroll&&t.xscroll.off("tap panstart pan panend",t._cellEventsHandler,t),t},_initInfinite:function(){var t=this,e=t.xscroll,i=t._;return t.sections={},t.infiniteElements=e.renderTo.querySelectorAll(t.userConfig.infiniteElements),t.infiniteLength=t.infiniteElements.length,t.infiniteElementsCache=function(){for(var e=[],r=0;r<t.infiniteLength;r++)e.push({}),t.infiniteElements[r].style.position="absolute",t.infiniteElements[r].style[i.top]=0,t.infiniteElements[r].style.visibility="hidden",t.infiniteElements[r].style.display="block",n.addClass(t.infiniteElements[r],"_xs_infinite_elements_");return e}(),t.elementsPos={},t},_renderUnRecycledEl:function(){var t=this,e=t._,i=t.userConfig.gpuAcceleration?" translateZ(0) ":"";for(var r in t.__serializedData){var l=t.__serializedData[r];if(t.__serializedData[r].recycled===!1){var o=l.id&&document.getElementById(l.id.replace("#",""))||document.createElement("div"),a=n.guid("xs-row-");o.id=l.id||a,l.id=o.id,t.xscroll.content.appendChild(o);for(var c in l.style)c!=e.height&&"display"!=c&&"position"!=c&&(o.style[c]=l.style[c]);o.style[e.top]=0,o.style.position="absolute",o.style.display="block",o.style[e.height]=l[e._height]+"px",o.style[s]=e.translate+"("+l[e._top]+"px) "+i,n.addClass(o,l.className),t.userConfig.renderHook.call(t,o,l)}}},render:function(){var t=this,e=t._,i=t.xscroll,n=t.isY?i.getScrollTop():i.getScrollLeft();t.visibleElements=t.getVisibleElements(n),t.__serializedData=t._computeDomPositions(),i.sticky&&i.sticky.render(!0),i.fixed&&i.fixed.render();var r=i[e.height],s=t._containerSize;return s<r&&(s=r),i[e.containerHeight]=s,i.container.style[e.height]=s+"px",i.content.style[e.height]=s+"px",t._renderUnRecycledEl(),t._updateByScroll(),t._updateByRender(n),t.xscroll.boundryCheck(),t},_getChangedRows:function(t){var e=this,i={};for(var n in e.elementsPos)t.hasOwnProperty(n)||(i[n]="delete");for(var n in t)t[n].recycled&&!e.elementsPos.hasOwnProperty(n)&&(i[n]="add");return e.elementsPos=t,i},_updateByScroll:function(t){var e=this,i=e.xscroll,n=e._,r=t&&t[n.scrollTop],s=void 0===r?e.isY?i.getScrollTop():i.getScrollLeft():r,l=e.getVisibleElements(s),o=e.changedRows=e._getChangedRows(l);try{for(var a in o)if("delete"==o[a]&&e._pushEl(a),"add"==o[a]){var c=e._popEl(l[a][e.guid]),u=c.index,f=c.el;f&&(e.infiniteElementsCache[u].guid=l[a].guid,e.__serializedData[l[a].guid].__infiniteIndex=u,e._renderData(f,l[a]),e._renderStyle(f,l[a]))}}catch(t){console.warn("Not enough infiniteElements setted!")}return e},_updateByRender:function(t){var e,i,n=this,r=n._,s=n.xscroll,t=void 0===t?n.isY?s.getScrollTop():s.getScrollLeft():t,l=n.visibleElements,o=n.getVisibleElements(t);for(var a in o){i=o[a];for(var c in l)if(e=l[c],e.guid===i.guid)i.style==e.style&&i[r._top]==e[r._top]&&i[r._height]==e[r._height]||n._renderStyle(n.infiniteElements[i.__infiniteIndex],i,!0),JSON.stringify(i.data)!=JSON.stringify(e.data)&&n._renderData(n.infiniteElements[i.__infiniteIndex],i);else if(n.__serializedData[i.guid].recycled&&void 0===n.__serializedData[i.guid].__infiniteIndex){var u=n._popEl();n.__serializedData[i.guid].__infiniteIndex=u.index,n._renderData(u.el,i),n._renderStyle(u.el,i)}}n.visibleElements=o},_computeDomPositions:function(){var t,e=this,i=e._,r=0,s=0,l=e.sections,o=[],a={};for(var c in l)for(var u=0,f=l[c].length;u<f;u++)t=l[c][u],t.sectionId=c,t.index=u,o.push(t);e.userConfig.maxSpeed=3;for(var c=0,d=o.length;c<d;c++){var h=o[c];s=h.style&&h.style[i.height]>=0&&"fixed"!=h.style.position?h.style[i.height]:0,h.guid=h.guid||n.guid(),h[i._top]=r,h[i._height]=s,h.recycled=h.recycled!==!1,r+=s,a[h.guid]=h}return e._containerSize=r,a},getVisibleElements:function(t){var e,i=this,n=i.xscroll,r=i._,t=void 0===t?i.isY?n.getScrollTop():n.getScrollLeft():t,s=i.userConfig.threshold>=0?i.userConfig.threshold:n[r.height]/3,l={},o=i.__serializedData;for(var a in o)e=o[a],e[r._top]>=t-s&&e[r._top]<=t+n[r.height]+s&&(l[e.guid]=e);return JSON.parse(JSON.stringify(l))},_popEl:function(){for(var t=this,e=0;e<t.infiniteLength;e++)if(!t.infiniteElementsCache[e]._visible)return t.infiniteElementsCache[e]._visible=!0,{index:e,el:t.infiniteElements[e]}},_pushEl:function(t){for(var e=this,i=0;i<e.infiniteLength;i++)e.infiniteElementsCache[i].guid==t&&(e.infiniteElementsCache[i]._visible=!1,e.infiniteElements[i].style.visibility="hidden",e.infiniteElementsCache[i].guid=null)},_renderData:function(t,e){var i=this;t&&e&&"fixed"!=e.style.position&&i.userConfig.renderHook.call(i,t,e)},_renderStyle:function(t,e,i){var n=this,r=n._;if(t){var o=n.xscroll.userConfig.gpuAcceleration?" translateZ(0) ":"";for(var a in e.style)a!=r.height&&"display"!=a&&"position"!=a&&(t.style[a]=e.style[a]);t.setAttribute("xs-index",e.index),t.setAttribute("xs-sectionid",e.sectionId),t.setAttribute("xs-guid",e.guid),t.style.visibility="visible",t.style[r.height]=e[r._height]+"px",t.style[s]=r.translate+"("+e[r._top]+"px) "+o,t.style[l]=i?n.userConfig.transition:"none"}},getCell:function(t){var e=this,i=n.findParentEl(t.target,"._xs_infinite_elements_",e.xscroll.renderTo);i||(i=n.findParentEl(t.target,".xs-sticky-handler",e.xscroll.renderTo));var r=i&&i.getAttribute("xs-guid");if(void 0!==r)return{data:e.__serializedData[r],el:i}},_bindEvt:function(){var t=this;if(!t._isEvtBinded)return t._isEvtBinded=!0,t.xscroll.renderTo.addEventListener("webkitTransitionEnd",function(t){t.target.className.match(/xs-row/)&&(t.target.style.webkitTransition="")}),t.xscroll.on("scroll",t._updateByScroll,t),t.xscroll.on("tap panstart pan panend",t._cellEventsHandler,t),t},_cellEventsHandler:function(t){var e=this,i=e.getCell(t);t.cell=i.data,t.cellEl=i.el,t.cell&&e[t.type].call(e,t)},tap:function(t){return this.trigger("tap",t),this},panstart:function(t){return this.trigger("panstart",t),this},pan:function(t){return this.trigger("pan",t),this},panend:function(t){return this.trigger("panend",t),this},insertBefore:function(t,e,i){var n=this;return void 0===t||void 0===e||void 0===i?n:(n.sections[t]||(n.sections[t]=[]),n.sections[t].splice(e,0,i),n)},insertAfter:function(t,e,i){var n=this;return void 0===t||void 0===e||void 0===i?n:(n.sections[t]||(n.sections[t]=[]),n.sections[t].splice(Number(e)+1,0,i),n)},append:function(t,e){var i=this;return i.sections[t]||(i.sections[t]=[]),i.sections[t]=i.sections[t].concat(e),i},remove:function(t,e,i){var n=this,i=i||1;return void 0!==t&&n.sections[t]?void 0===e?(n.sections[t]=null,n):n.sections[t]&&n.sections[t][e]?(n.sections[t].splice(e,i),n):n:n},replace:function(t,e,i){var n=this;return void 0!==t&&n.sections[t]?(n.sections[t][e]=i,n):n},get:function(t,e){if(void 0!==t)return void 0===e?this.sections[t]:this.sections[t][e]}}),"object"==typeof module&&module.exports)e=o;else if(window.XScroll&&window.XScroll.Plugins)return XScroll.Plugins.Infinite=o;return e}(n)}();
|