1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.panel.js

1 line
8.7 KiB
JavaScript
Raw Normal View History

2017-01-27 22:16:59 -05:00
define(["jqmwidget"],function(){!function($,undefined){var props={animation:{},transition:{}},testElement=document.createElement("a"),vendorPrefixes=["","webkit-","moz-","o-"];$.each(["animation","transition"],function(i,test){var testName=0===i?test+"-name":test;$.each(vendorPrefixes,function(j,prefix){if(testElement.style[$.camelCase(prefix+testName)]!==undefined)return props[test].prefix=prefix,!1}),props[test].duration=$.camelCase(props[test].prefix+test+"-duration"),props[test].event=$.camelCase(props[test].prefix+test+"-end"),""===props[test].prefix&&(props[test].event=props[test].event.toLowerCase())}),$(testElement).remove(),$.fn.animationComplete=function(callback,type,fallbackTime){var timer,duration,that=this,eventBinding=function(){clearTimeout(timer),callback.apply(this,arguments)},animationType=type&&"animation"!==type?"transition":"animation";return fallbackTime===undefined&&($(this).context!==document&&(duration=3e3*parseFloat($(this).css(props[animationType].duration))),(0===duration||duration===undefined||isNaN(duration))&&(duration=$.fn.animationComplete.defaultDuration)),timer=setTimeout(function(){$(that).off(props[animationType].event,eventBinding),callback.apply(that)},duration),$(this).one(props[animationType].event,eventBinding)},$.fn.animationComplete.defaultDuration=1e3}(jQuery),function($,undefined){$.widget("mobile.panel",{options:{animate:!0,theme:null,position:"left",dismissible:!0,display:"overlay",swipeClose:!0,positionFixed:!0},_parentPage:null,_page:null,_modal:null,_panelInner:null,_wrapper:null,_create:function(){var el=this.element,parentPage=el.closest(".ui-page, [data-role='page']");$.extend(this,{_parentPage:parentPage.length>0&&parentPage,_openedPage:null,_page:this._getPage,_panelInner:this._getPanelInner()}),"overlay"!==this.options.display&&this._getWrapper(),this._addPanelClasses(),this.options.animate&&this.element.addClass("ui-panel-animate"),this._bindUpdateLayout(),this._bindCloseEvents(),this._bindLinkListeners(),this._bindPageEvents(),this.options.dismissible&&this._createModal(),this._bindSwipeEvents()},_getPanelInner:function(){var panelInner=this.element[0].querySelector(".ui-panel-inner");return panelInner=panelInner?$(panelInner):this.element.children().wrapAll("<div class='ui-panel-inner' />").parent()},_createModal:function(){var self=this,target=self._parentPage?self._parentPage.parent():self.element.parent();self._modal=$("<div class='ui-panel-dismiss'></div>").on("mousedown",function(){self.close()}).appendTo(target)},_getPage:function(){var page=this._openedPage||this._parentPage||$(".ui-page-active");return page},_getWrapper:function(){var wrapper=this._page().find(".ui-panel-wrapper");0===wrapper.length&&(wrapper=this._page().children(".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)").wrapAll("<div class='ui-panel-wrapper'></div>").parent()),this._wrapper=wrapper},_getPosDisplayClasses:function(prefix){return prefix+"-position-right "+prefix+"-display-"+this.options.display},_getPanelClasses:function(){var panelClasses="ui-panel "+this._getPosDisplayClasses("ui-panel")+" ui-panel-closed ui-body-"+(this.options.theme?this.options.theme:"inherit");return this.options.positionFixed&&(panelClasses+=" ui-panel-fixed"),panelClasses},_addPanelClasses:function(){this.element.addClass(this._getPanelClasses())},_handleCloseClick:function(event){event.isDefaultPrevented()||this.close()},_bindCloseEvents:function(){},_positionPanel:function(scrollToTop){var self=this,panelInnerHeight=self._panelInner.outerHeight(),expand=panelInnerHeight>(window.innerHeight||$(window).height());expand||!self.options.positionFixed?(expand&&self._unfixPanel(),scrollToTop&&this.window[0].scrollTo(0,$.mobile.defaultHomeScroll)):self._fixPanel()},_bindFixListener:function(){this._on($(window),{resize:"_positionPanel"})},_unbindFixListener:function(){this._off($(window),"resize")},_unfixPanel:function(){this.options.positionFixed&&this.element.removeClass("ui-panel-fixed")},_fixPanel:function(){this.options.positionFixed&&this.element.addClass(