framework7
Version:
Full featured mobile HTML framework for building iOS & Android apps
1 lines • 3.96 kB
JavaScript
(function framework7ComponentLoader(e,t){void 0===t&&(t=!0);var o=document,V=(window,e.$),a=(e.Template7,e.utils),s=(e.device,e.support,e.Class,e.Modal,e.ConstructorMethods,e.ModalMethods,{init:function(){var d,p,b,u,v,f,h,c,g,m,x,w,a,C,T,M,I,L,y,E,s=this;var e=!!s.support.passiveListener&&{passive:!1,capture:!1};V(o).on(s.touchEvents.start,".list.sortable .sortable-handler",function(e){d=!(p=!1),b="touchstart"===e.type?e.targetTouches[0].pageY:e.pageY,v=V(this).parent("li"),a=v.index(),h=v.parents(".sortable");var t=v.parents(".list-group");t.length&&t.parents(h).length&&(h=t),f=h.children("ul").children("li"),s.panel&&(s.panel.allowOpen=!1),s.swipeout&&(s.swipeout.allow=!1)},e),s.on("touchmove:active",function(e){if(d&&v){var t="touchmove"===e.type?e.targetTouches[0].pageY:e.pageY;if(!p){C=v.parents(".page"),T=v.parents(".page-content");var a=parseInt(T.css("padding-top"),10),s=parseInt(T.css("padding-bottom"),10);E=T[0].scrollTop,I=C.offset().top+a,M=C.height()-a-s,v.addClass("sorting"),h.addClass("sortable-sorting"),L=v[0].offsetTop,g=v[0].offsetTop,m=v.parent().height()-L-v.height(),c=v[0].offsetHeight,y=v.offset().top}p=!0,e.preventDefault(),e.f7PreventSwipePanel=!0,u=t-b;var o=T[0].scrollTop-E,r=Math.min(Math.max(u+o,-g),m);v.transform("translate3d(0,"+r+"px,0)");var i,n=44,l=!0;u+o+n<-g&&(l=!1),m<u+o-n&&(l=!1),x=w=void 0,l&&(I+M<y+u+c+n&&(i=y+u+c+n-(I+M)),y+u<I+n&&(i=y+u-I-n),i&&(T[0].scrollTop+=i)),f.each(function(e,t){var a=V(t);if(a[0]!==v[0]){var s=a[0].offsetTop,o=a.height(),i=L+r;s-o/2<=i&&v.index()<a.index()?(a.transform("translate3d(0, "+-c+"px,0)"),x=a,w=void 0):i<=s+o/2&&v.index()>a.index()?(a.transform("translate3d(0, "+c+"px,0)"),x=void 0,w||(w=a)):a.transform("translate3d(0, 0%,0)")}})}}),s.on("touchend:passive",function(){if(!d||!p)return p=d=!1,void(d&&!p&&(s.panel&&(s.panel.allowOpen=!0),s.swipeout&&(s.swipeout.allow=!0)));var e;if(s.panel&&(s.panel.allowOpen=!0),s.swipeout&&(s.swipeout.allow=!0),f.transform(""),v.removeClass("sorting"),h.removeClass("sortable-sorting"),x?e=x.index():w&&(e=w.index()),s.params.sortable.moveElements&&(x&&v.insertAfter(x),w&&v.insertBefore(w)),(x||w)&&h.hasClass("virtual-list")){void 0===(a=v[0].f7VirtualListIndex)&&(a=v.attr("data-virtual-list-index")),w?void 0===(e=w[0].f7VirtualListIndex)&&(e=w.attr("data-virtual-list-index")):void 0===(e=x[0].f7VirtualListIndex)&&(e=x.attr("data-virtual-list-index")),e=null!==e?parseInt(e,10):void 0;var t=h[0].f7VirtualList;t&&t.moveItem(a,e)}void 0===e||Number.isNaN(e)||e===a||(v.trigger("sortable:sort",{from:a,to:e}),s.emit("sortableSort",v[0],{from:a,to:e})),x=w=void 0,p=d=!1})},enable:function(e){void 0===e&&(e=".list.sortable");var t=V(e);0!==t.length&&(t.addClass("sortable-enabled"),t.trigger("sortable:enable"),this.emit("sortableEnable",t[0]))},disable:function(e){void 0===e&&(e=".list.sortable");var t=V(e);0!==t.length&&(t.removeClass("sortable-enabled"),t.trigger("sortable:disable"),this.emit("sortableDisable",t[0]))},toggle:function(e){void 0===e&&(e=".list.sortable");var t=V(e);0!==t.length&&(t.hasClass("sortable-enabled")?this.sortable.disable(t):this.sortable.enable(t))}}),i={name:"sortable",params:{sortable:{moveElements:!0}},create:function(){var e=this;a.extend(e,{sortable:{init:s.init.bind(e),enable:s.enable.bind(e),disable:s.disable.bind(e),toggle:s.toggle.bind(e)}})},on:{init:function(){this.params.sortable&&this.sortable.init()}},clicks:{".sortable-enable":function(e,t){void 0===t&&(t={});this.sortable.enable(t.sortable)},".sortable-disable":function(e,t){void 0===t&&(t={});this.sortable.disable(t.sortable)},".sortable-toggle":function(e,t){void 0===t&&(t={});this.sortable.toggle(t.sortable)}}};if(t){if(e.prototype.modules&&e.prototype.modules[i.name])return;e.use(i),e.instance&&(e.instance.useModuleParams(i,e.instance.params),e.instance.useModule(i))}return i}(Framework7, typeof Framework7AutoInstallComponent === 'undefined' ? undefined : Framework7AutoInstallComponent))