angular-material
Version:
**[Support for legacy AngularJS ended on January 1st, 2022](https://goo.gle/angularjs-end-of-life). [See `@angular/core` for the actively supported Angular](https://npmjs.com/@angular/core).**
7 lines • 25.6 kB
JavaScript
/*!
* AngularJS Material Design
* https://github.com/angular/material
* @license MIT
* v1.2.4-master-bfc8ae7
*/
!function(t,p,n){"use strict";h.$inject=["presets","$rootElement","$rootScope","$injector","$window"],p.module("material.components.panel",["material.core","material.components.backdrop"]).provider("$mdPanel",function(){return{definePreset:e,getAllPresets:a,clearPresets:l,$get:["$rootElement","$rootScope","$injector","$window",function(t,e,n,o){return new h(i,t,e,n,o)}]}});var o,s=80,r="_md-panel-hidden",i={};function e(t,e){if(!t||!e)throw new Error("mdPanelProvider: The panel preset definition is malformed. The name and preset object are required.");if(i.hasOwnProperty(t))throw new Error("mdPanelProvider: The panel preset you have requested has already been defined.");delete e.id,delete e.position,delete e.animation,i[t]=e}function a(){return p.copy(i)}function l(){i={}}function c(t){return p.isString(t)&&(t=[t]),t}function h(t,e,n,o,i){this._defaultConfigOptions={bindToController:!0,clickOutsideToClose:!1,disableParentScroll:!1,escapeToClose:!1,focusOnOpen:!0,fullscreen:!1,hasBackdrop:!1,propagateContainerEvents:!1,transformTemplate:p.bind(this,this._wrapTemplate),trapFocus:!1,zIndex:s},this._config={},this._presets=t,this._$rootElement=e,this._$rootScope=n,this._$injector=o,this._$window=i,this._$mdUtil=this._$injector.get("$mdUtil"),this._trackedPanels={},this._groups=Object.create(null),this.animation=f.animation,this.xPosition=_.xPosition,this.yPosition=_.yPosition,this.interceptorTypes=u.interceptorTypes,this.closeReasons=u.closeReasons,this.absPosition=_.absPosition}function u(t,e){this._$q=e.get("$q"),this._$mdCompiler=e.get("$mdCompiler"),this._$mdConstant=e.get("$mdConstant"),this._$mdUtil=e.get("$mdUtil"),this._$mdTheming=e.get("$mdTheming"),this._$rootScope=e.get("$rootScope"),this._$animate=e.get("$animate"),this._$mdPanel=e.get("$mdPanel"),this._$log=e.get("$log"),this._$window=e.get("$window"),this._$$rAF=e.get("$$rAF"),this.id=t.id,this.config=t,this.panelContainer=n,this.panelEl=n,this.innerWrapper=n,this.isAttached=!1,this._removeListeners=[],this._topFocusTrap=n,this._bottomFocusTrap=n,this._backdropRef=n,this._restoreScroll=null,this._interceptors=Object.create(null),this._compilerCleanup=null,this._restoreCache={styles:"",classes:""}}function _(t){this._$window=t.get("$window"),this._isRTL=t.get("$mdUtil").isRtl(),this._$mdConstant=t.get("$mdConstant"),this._absolute=!1,this._relativeToEl=n,this._top="",this._bottom="",this._left="",this._right="",this._translateX=[],this._translateY=[],this._positions=[],this._actualPosition=n}function f(t){this._$mdUtil=t.get("$mdUtil"),this._openFrom,this._closeTo,this._animationClass="",this._openDuration,this._closeDuration,this._rawDuration}function d(t){var e=p.isString(t)?document.querySelector(t):t;return p.element(e)}function m(t,e){if(null!==e&&!p.isUndefined(e)){for(var n,o=Object.keys(t),i=[],s=0;n=o[s];s++){var r=t[n];if(i.push(r),r===e)return}throw new Error("Panel position only accepts the following values:\n"+i.join(" | "))}}function g(t){return p.isNumber(t)?t+"px":t}h.prototype.create=function(t,e){if("string"==typeof t?t=this._getPresetByName(t):"object"!=typeof t||!p.isUndefined(e)&&e||(e=t,t={}),t=t||{},e=e||{},p.isDefined(e.id)&&this._trackedPanels[e.id]){var n=this._trackedPanels[e.id];return p.extend(n.config,e),n}this._config=p.extend({id:e.id||"panel_"+this._$mdUtil.nextUid(),scope:this._$rootScope.$new(!0),attachTo:this._$rootElement},this._defaultConfigOptions,e,t);var o=new u(this._config,this._$injector);return this._trackedPanels[this._config.id]=o,this._config.groupName&&(this._config.groupName=c(this._config.groupName),p.forEach(this._config.groupName,function(t){o.addToGroup(t)})),this._config.scope.$on("$destroy",p.bind(o,o.detach)),o},h.prototype.open=function(t,e){var n=this.create(t,e);return n.open().then(function(){return n})},h.prototype._getPresetByName=function(t){if(!this._presets[t])throw new Error("mdPanel: The panel preset configuration that you requested does not exist. Use the $mdPanelProvider to create a preset before requesting one.");return this._presets[t]},h.prototype.newPanelPosition=function(){return new _(this._$injector)},h.prototype.newPanelAnimation=function(){return new f(this._$injector)},h.prototype.newPanelGroup=function(t,e){return this._groups[t]||(e=e||{},this._groups[t]={panels:[],openPanels:[],maxOpen:0<e.maxOpen?e.maxOpen:1/0}),this._groups[t]},h.prototype.setGroupMaxOpen=function(t,e){if(!this._groups[t])throw new Error("mdPanel: Group does not exist yet. Call newPanelGroup().");this._groups[t].maxOpen=e},h.prototype._openCountExceedsMaxOpen=function(t){if(this._groups[t]){var e=this._groups[t];return 0<e.maxOpen&&e.openPanels.length>e.maxOpen}return!1},h.prototype._closeFirstOpenedPanel=function(t){var e=this._groups[t];e&&e.openPanels.length&&e.openPanels[0].close()},h.prototype._wrapTemplate=function(t){return'<div class="md-panel-outer-wrapper"><div class="md-panel-inner-wrapper _md-panel-offscreen"><div class="md-panel _md-panel-offscreen">'+(t||"")+"</div></div></div>"},h.prototype._wrapContentElement=function(t){var e=p.element('<div class="md-panel-outer-wrapper"><div class="md-panel-inner-wrapper _md-panel-offscreen"></div></div>');return t.addClass("md-panel _md-panel-offscreen"),e.children().eq(0).append(t),e},u.interceptorTypes={CLOSE:"onClose"},u.prototype.open=function(){var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i._simpleBind(i.show,i);i.attach().then(o).then(function(){i.config.groupName&&(i.config.groupName=c(i.config.groupName),p.forEach(i.config.groupName,function(t){i._$mdPanel._openCountExceedsMaxOpen(t)&&i._$mdPanel._closeFirstOpenedPanel(t)}))}).then(n).catch(e)})},u.prototype.close=function(s){var r=this;return this._$q(function(o,i){r._callInterceptors(u.interceptorTypes.CLOSE).then(function(){var t=r._done(o,r),e=r._simpleBind(r.detach,r),n=r.config.onCloseSuccess||p.noop;n=p.bind(r,n,r,s),r.hide().then(e).then(t).then(n).catch(i)},i)})},u.prototype.attach=function(){if(this.isAttached&&this.panelEl)return this._$q.when(this);var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i.config.onDomAdded||p.noop;i._$q.all([i._createBackdrop(),i._createPanel().then(function(t){return i.isAttached=!0,i._addEventListeners(),t}).catch(e)]).then(o).then(n).catch(e)})},u.prototype.detach=function(){if(!this.isAttached)return this._$q.when(this);var o=this,i=o.config.onDomRemoved||p.noop;return this._restoreScroll&&(this._restoreScroll(),this._restoreScroll=null),this._$q(function(t,e){var n=o._done(t,o);o._$q.all([(o._removeEventListeners(),o._topFocusTrap&&o._topFocusTrap.parentNode&&o._topFocusTrap.parentNode.removeChild(o._topFocusTrap),o._bottomFocusTrap&&o._bottomFocusTrap.parentNode&&o._bottomFocusTrap.parentNode.removeChild(o._bottomFocusTrap),o._restoreCache.classes&&(o.panelEl[0].className=o._restoreCache.classes),o.panelEl[0].style.cssText=o._restoreCache.styles||"",o._compilerCleanup(),o.panelContainer.remove(),o.isAttached=!1,o._$q.when(o)),!o._backdropRef||o._backdropRef.detach()]).then(i).then(n).catch(e)})},u.prototype.destroy=function(){var e=this;this.config.groupName&&(this.config.groupName=c(this.config.groupName),p.forEach(this.config.groupName,function(t){e.removeFromGroup(t)})),this.config.scope.$destroy(),this.config.locals=null,this.config.onDomAdded=null,this.config.onDomRemoved=null,this.config.onRemoving=null,this.config.onOpenComplete=null,this._interceptors=n},u.prototype.show=function(){if(!this.panelContainer)return this._$q(function(t,e){e("mdPanel: Panel does not exist yet. Call open() or attach().")});if(!this.panelContainer.hasClass(r))return this._$q.when(this);var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i.config.onOpenComplete||p.noop;i._$q.all([i._backdropRef?i._backdropRef.show():i,(i.panelContainer.removeClass(r),i._animateOpen()).then(function(){i._focusOnOpen()},e)]).then(o).then(function(){i.config.groupName&&(i.config.groupName=c(i.config.groupName),p.forEach(i.config.groupName,function(t){(t=i._$mdPanel._groups[t])&&t.openPanels.push(i)}))}).then(n).catch(e)})},u.prototype.hide=function(){if(!this.panelContainer)return this._$q(function(t,e){e("mdPanel: Panel does not exist yet. Call open() or attach().")});if(this.panelContainer.hasClass(r))return this._$q.when(this);var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i.config.onRemoving||p.noop;i._$q.all([i._backdropRef?i._backdropRef.hide():i,i._animateClose().then(o).then(function(){i.panelContainer.addClass(r)}).then(function(){var e;i.config.groupName&&(i.config.groupName=c(i.config.groupName),p.forEach(i.config.groupName,function(t){t=i._$mdPanel._groups[t],-1<(e=t.openPanels.indexOf(i))&&t.openPanels.splice(e,1)}))}).then(function(){var t=i.config.origin;t&&d(t).focus()}).catch(e)]).then(n,e)})},u.prototype._compile=function(){var o=this;return o._$mdCompiler.compile(o.config).then(function(t){var e=o.config;if(e.contentElement){var n=t.element;o._restoreCache.styles=n[0].style.cssText,o._restoreCache.classes=n[0].className,o.panelContainer=o._$mdPanel._wrapContentElement(n),o.panelEl=n}else o.panelContainer=t.link(e.scope),o.panelEl=p.element(o.panelContainer[0].querySelector(".md-panel"));return o.innerWrapper=p.element(o.panelContainer[0].querySelector(".md-panel-inner-wrapper")),o._compilerCleanup=t.cleanup,d(o.config.attachTo).append(o.panelContainer),o})},u.prototype._createPanel=function(){var n=this;return this._$q(function(t,e){n.config.locals||(n.config.locals={}),(n.config.locals.mdPanelRef=n)._compile().then(function(){n.config.disableParentScroll&&(n._restoreScroll=n._$mdUtil.disableScrollAround(null,n.panelContainer,{disableScrollMask:!0})),n.config.panelClass&&n.panelEl.addClass(n.config.panelClass),n.config.propagateContainerEvents&&(n.panelContainer.css("pointer-events","none"),n.panelEl.css("pointer-events","all")),n._$animate.pin&&n._$animate.pin(n.panelContainer,d(n.config.attachTo)),n._configureTrapFocus(),n._addStyles().then(function(){t(n)},e)},e)})},u.prototype._addStyles=function(){var n=this;return this._$q(function(t){n.panelContainer.css("z-index",n.config.zIndex),n.innerWrapper.css("z-index",n.config.zIndex+1);function e(){n._setTheming(),n.panelEl.removeClass("_md-panel-offscreen"),n.innerWrapper.removeClass("_md-panel-offscreen"),n.panelContainer.addClass(r),t(n)}if(n.config.fullscreen)return n.panelEl.addClass("_md-panel-fullscreen"),void e();n.config.position?n._$rootScope.$$postDigest(function(){n._updatePosition(!0),n._setTheming(),t(n)}):e()})},u.prototype._setTheming=function(){this._$mdTheming(this.panelEl),this._$mdTheming(this.panelContainer)},u.prototype.updatePosition=function(t){if(!this.panelContainer)throw new Error("mdPanel: Panel does not exist yet. Call open() or attach().");this.config.position=t,this._updatePosition()},u.prototype._updatePosition=function(t){var e=this.config.position;e&&(e._setPanelPosition(this.innerWrapper),t&&(this.panelEl.removeClass("_md-panel-offscreen"),this.innerWrapper.removeClass("_md-panel-offscreen"),this.panelContainer.addClass(r)),this.innerWrapper.css(_.absPosition.TOP,e.getTop()),this.innerWrapper.css(_.absPosition.BOTTOM,e.getBottom()),this.innerWrapper.css(_.absPosition.LEFT,e.getLeft()),this.innerWrapper.css(_.absPosition.RIGHT,e.getRight()))},u.prototype._focusOnOpen=function(){if(this.config.focusOnOpen){var t=this;this._$rootScope.$$postDigest(function(){(t._$mdUtil.findFocusTarget(t.panelEl)||t.panelEl).focus()})}},u.prototype._createBackdrop=function(){if(this.config.hasBackdrop){if(!this._backdropRef){var t=this._$mdPanel.newPanelAnimation().openFrom(this.config.attachTo).withAnimation({open:"_md-opaque-enter",close:"_md-opaque-leave"});this.config.animation&&t.duration(this.config.animation._rawDuration);var e={animation:t,attachTo:this.config.attachTo,focusOnOpen:!1,panelClass:"_md-panel-backdrop",zIndex:this.config.zIndex-1};this._backdropRef=this._$mdPanel.create(e)}if(!this._backdropRef.isAttached)return this._backdropRef.attach()}},u.prototype._addEventListeners=function(){this._configureEscapeToClose(),this._configureClickOutsideToClose(),this._configureScrollListener()},u.prototype._removeEventListeners=function(){this._removeListeners&&this._removeListeners.forEach(function(t){t()}),this._removeListeners=[]},u.prototype._configureEscapeToClose=function(){if(this.config.escapeToClose){var t=d(this.config.attachTo),e=this,n=function(t){t.keyCode===e._$mdConstant.KEY_CODE.ESCAPE&&(t.stopPropagation(),t.preventDefault(),e.close(u.closeReasons.ESCAPE))};this.panelContainer.on("keydown",n),t.on("keydown",n),this._removeListeners.push(function(){e.panelContainer.off("keydown",n),t.off("keydown",n)})}},u.prototype._configureClickOutsideToClose=function(){if(this.config.clickOutsideToClose){var e,n=this.config.propagateContainerEvents?p.element(document.body):this.panelContainer,t=function(t){e=t.target},o=this,i=function(t){o.config.propagateContainerEvents?e===o.panelEl[0]||o.panelEl[0].contains(e)||o.close():e===n[0]&&t.target===n[0]&&(t.stopPropagation(),t.preventDefault(),o.close(u.closeReasons.CLICK_OUTSIDE))};n.on("mousedown",t),n.on("mouseup",i),this._removeListeners.push(function(){n.off("mousedown",t),n.off("mouseup",i)})}},u.prototype._configureScrollListener=function(){if(!this.config.disableParentScroll){var t=p.bind(this,this._updatePosition),e=this._$$rAF.throttle(t),n=this,o=function(){e()};this._$window.addEventListener("scroll",o,!0),this._removeListeners.push(function(){n._$window.removeEventListener("scroll",o,!0)})}},u.prototype._configureTrapFocus=function(){if(this.panelEl.attr("tabIndex","-1"),this.config.trapFocus){var t=this.panelEl;if(!o){var e=document.createElement("div");e.className="_md-panel-focus-trap",e.tabIndex=0,o=p.element(e)}this._topFocusTrap=o.clone()[0],this._bottomFocusTrap=o.clone()[0];var n=function(){t.focus()};this._topFocusTrap.addEventListener("focus",n),this._bottomFocusTrap.addEventListener("focus",n),this._removeListeners.push(this._simpleBind(function(){this._topFocusTrap.removeEventListener("focus",n),this._bottomFocusTrap.removeEventListener("focus",n)},this)),t[0].parentNode.insertBefore(this._topFocusTrap,t[0]),t.after(this._bottomFocusTrap)}},u.prototype.updateAnimation=function(t){this.config.animation=t,this._backdropRef&&this._backdropRef.config.animation.duration(t._rawDuration)},u.prototype._animateOpen=function(){this.panelContainer.addClass("md-panel-is-showing");var n=this.config.animation;if(!n)return this.panelContainer.addClass("_md-panel-shown"),this._$q.when(this);var o=this;return this._$q(function(t){var e=o._done(t,o);n.animateOpen(o.panelEl).then(e,function(){o._$log.warn("mdPanel: MdPanel Animations failed. Showing panel without animating."),e()})})},u.prototype._animateClose=function(){var n=this,o=this.config.animation;return o?this._$q(function(t){function e(){n.panelContainer.removeClass("md-panel-is-showing"),n.panelEl.css("transform",""),t(n)}o.animateClose(n.panelEl).then(e,function(){n._$log.warn("mdPanel: MdPanel Animations failed. Hiding panel without animating."),e()})}):(this.panelContainer.removeClass("md-panel-is-showing"),this.panelContainer.removeClass("_md-panel-shown"),this._$q.when(this))},u.prototype.registerInterceptor=function(t,e){var n=null;if(p.isString(t)?p.isFunction(e)||(n="Interceptor callback must be a function, instead got "+typeof e):n="Interceptor type must be a string, instead got "+typeof t,n)throw new Error("MdPanel: "+n);var o=this._interceptors[t]=this._interceptors[t]||[];return-1===o.indexOf(e)&&o.push(e),this},u.prototype.removeInterceptor=function(t,e){var n=this._interceptors[t]?this._interceptors[t].indexOf(e):-1;return-1<n&&this._interceptors[t].splice(n,1),this},u.prototype.removeAllInterceptors=function(t){return t?this._interceptors[t]=[]:this._interceptors=Object.create(null),this},u.prototype._callInterceptors=function(t){var o=this,i=o._$q;return(o._interceptors&&o._interceptors[t]||[]).reduceRight(function(t,e){var n=e&&p.isFunction(e.then)?e:null;return t.then(function(){if(!n)try{n=e(o)}catch(t){n=i.reject(t)}return n})},i.resolve(o))},u.prototype._simpleBind=function(e,n){return function(t){return e.apply(n,t)}},u.prototype._done=function(t,e){return function(){t(e)}},u.prototype.addToGroup=function(t){this._$mdPanel._groups[t]||this._$mdPanel.newPanelGroup(t);var e=this._$mdPanel._groups[t];e.panels.indexOf(this)<0&&e.panels.push(this)},u.prototype.removeFromGroup=function(t){if(!this._$mdPanel._groups[t])throw new Error("mdPanel: The group "+t+" does not exist.");var e=this._$mdPanel._groups[t],n=e.panels.indexOf(this);-1<n&&e.panels.splice(n,1)},u.closeReasons={CLICK_OUTSIDE:"clickOutsideToClose",ESCAPE:"escapeToClose"},_.xPosition={CENTER:"center",ALIGN_START:"align-start",ALIGN_END:"align-end",OFFSET_START:"offset-start",OFFSET_END:"offset-end"},_.yPosition={CENTER:"center",ALIGN_TOPS:"align-tops",ALIGN_BOTTOMS:"align-bottoms",ABOVE:"above",BELOW:"below"},_.absPosition={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},_.viewportMargin=8,_.prototype.absolute=function(){return this._absolute=!0,this},_.prototype._setPosition=function(t,e){if(t===_.absPosition.RIGHT||t===_.absPosition.LEFT)this._left=this._right="";else{if(t!==_.absPosition.BOTTOM&&t!==_.absPosition.TOP){var n=Object.keys(_.absPosition).join().toLowerCase();throw new Error("mdPanel: Position must be one of "+n+".")}this._top=this._bottom=""}return this["_"+t]=p.isString(e)?e:"0",this},_.prototype.top=function(t){return this._setPosition(_.absPosition.TOP,t)},_.prototype.bottom=function(t){return this._setPosition(_.absPosition.BOTTOM,t)},_.prototype.start=function(t){var e=this._isRTL?_.absPosition.RIGHT:_.absPosition.LEFT;return this._setPosition(e,t)},_.prototype.end=function(t){var e=this._isRTL?_.absPosition.LEFT:_.absPosition.RIGHT;return this._setPosition(e,t)},_.prototype.left=function(t){return this._setPosition(_.absPosition.LEFT,t)},_.prototype.right=function(t){return this._setPosition(_.absPosition.RIGHT,t)},_.prototype.centerHorizontally=function(){return this._left="50%",this._right="",this._translateX=["-50%"],this},_.prototype.centerVertically=function(){return this._top="50%",this._bottom="",this._translateY=["-50%"],this},_.prototype.center=function(){return this.centerHorizontally().centerVertically()},_.prototype.relativeTo=function(t){return this._absolute=!1,this._relativeToEl=d(t),this},_.prototype.addPanelPosition=function(t,e){if(!this._relativeToEl)throw new Error("mdPanel: addPanelPosition can only be used with relative positioning. Set relativeTo first.");return m(_.xPosition,t),m(_.yPosition,e),this._positions.push({x:t,y:e}),this},_.prototype.withOffsetX=function(t){return this._translateX.push(g(t)),this},_.prototype.withOffsetY=function(t){return this._translateY.push(g(t)),this},_.prototype.getTop=function(){return this._top},_.prototype.getBottom=function(){return this._bottom},_.prototype.getLeft=function(){return this._left},_.prototype.getRight=function(){return this._right},_.prototype.getTransform=function(){return(this._reduceTranslateValues("translateX",this._translateX)+" "+this._reduceTranslateValues("translateY",this._translateY)).trim()},_.prototype._setTransform=function(t){return t.css(this._$mdConstant.CSS.TRANSFORM,this.getTransform())},_.prototype._isOnscreen=function(t){var e=parseInt(this.getLeft()),n=parseInt(this.getTop());if(this._translateX.length||this._translateY.length){var o=function(t,e){var n=getComputedStyle(t[0]||t)[e],o=n.indexOf("("),i=n.lastIndexOf(")"),s={x:0,y:0};if(-1<o&&-1<i){var r=n.substring(o+1,i).split(", ").slice(-2);s.x=parseInt(r[0]),s.y=parseInt(r[1])}return s}(t,this._$mdConstant.CSS.TRANSFORM);e+=o.x,n+=o.y}var i=e+t[0].offsetWidth,s=n+t[0].offsetHeight;return 0<=e&&0<=n&&s<=this._$window.innerHeight&&i<=this._$window.innerWidth},_.prototype.getActualPosition=function(){return this._actualPosition},_.prototype._reduceTranslateValues=function(n,t){return t.map(function(t){var e=p.isFunction(t)?g(t(this)):t;return n+"("+e+")"},this).join(" ")},_.prototype._setPanelPosition=function(t){if(t.removeClass("_md-panel-position-adjusted"),this._absolute)this._setTransform(t);else{if(this._actualPosition)return this._calculatePanelPosition(t,this._actualPosition),this._setTransform(t),void this._constrainToViewport(t);for(var e=0;e<this._positions.length;e++)if(this._actualPosition=this._positions[e],this._calculatePanelPosition(t,this._actualPosition),this._setTransform(t),this._isOnscreen(t))return;this._constrainToViewport(t)}},_.prototype._constrainToViewport=function(t){var e=_.viewportMargin,n=this._top,o=this._left;if(this.getTop()){var i=parseInt(this.getTop()),s=t[0].offsetHeight+i,r=this._$window.innerHeight;i<e?this._top=e+"px":r<s&&(this._top=i-(s-r+e)+"px")}if(this.getLeft()){var a=parseInt(this.getLeft()),p=t[0].offsetWidth+a,l=this._$window.innerWidth;a<e?this._left=e+"px":l<p&&(this._left=a-(p-l+e)+"px")}t.toggleClass("_md-panel-position-adjusted",this._top!==n||this._left!==o)},_.prototype._reverseXPosition=function(t){if(t===_.xPosition.CENTER)return t;var e="start";return-1<t.indexOf(e)?t.replace(e,"end"):t.replace("end",e)},_.prototype._bidi=function(t){return this._isRTL?this._reverseXPosition(t):t},_.prototype._calculatePanelPosition=function(t,e){var n=t[0].getBoundingClientRect(),o=Math.max(n.width,t[0].clientWidth),i=Math.max(n.height,t[0].clientHeight),s=this._relativeToEl[0].getBoundingClientRect(),r=s.left,a=s.right,p=s.width;switch(this._bidi(e.x)){case _.xPosition.OFFSET_START:this._left=r-o+"px";break;case _.xPosition.ALIGN_END:this._left=a-o+"px";break;case _.xPosition.CENTER:var l=r+.5*p-.5*o;this._left=l+"px";break;case _.xPosition.ALIGN_START:this._left=r+"px";break;case _.xPosition.OFFSET_END:this._left=a+"px"}var c=s.top,h=s.bottom,u=s.height;switch(e.y){case _.yPosition.ABOVE:this._top=c-i+"px";break;case _.yPosition.ALIGN_BOTTOMS:this._top=h-i+"px";break;case _.yPosition.CENTER:var f=c+.5*u-.5*i;this._top=f+"px";break;case _.yPosition.ALIGN_TOPS:this._top=c+"px";break;case _.yPosition.BELOW:this._top=h+"px"}},f.animation={SLIDE:"md-panel-animate-slide",SCALE:"md-panel-animate-scale",FADE:"md-panel-animate-fade"},f.prototype.openFrom=function(t){return t=t.target?t.target:t,this._openFrom=this._getPanelAnimationTarget(t),this._closeTo||(this._closeTo=this._openFrom),this},f.prototype.closeTo=function(t){return this._closeTo=this._getPanelAnimationTarget(t),this},f.prototype.duration=function(t){return t&&(p.isNumber(t)?this._openDuration=this._closeDuration=e(t):p.isObject(t)&&(this._openDuration=e(t.open),this._closeDuration=e(t.close))),this._rawDuration=t,this;function e(t){if(p.isNumber(t))return t/1e3}},f.prototype._getPanelAnimationTarget=function(t){return p.isDefined(t.top)||p.isDefined(t.left)?{element:n,bounds:{top:t.top||0,left:t.left||0}}:this._getBoundingClientRect(d(t))},f.prototype.withAnimation=function(t){return this._animationClass=t,this},f.prototype.animateOpen=function(t){var e=this._$mdUtil.dom.animator;this._fixBounds(t);var n={},o=t[0].style.transform||"",i=e.toTransformCss(o),s=e.toTransformCss(o);switch(this._animationClass){case f.animation.SLIDE:t.css("opacity","1"),n={transitionInClass:"_md-panel-animate-enter",transitionOutClass:"_md-panel-animate-leave"};var r=e.calculateSlideToOrigin(t,this._openFrom)||"";i=e.toTransformCss(r+" "+o);break;case f.animation.SCALE:n={transitionInClass:"_md-panel-animate-enter"};var a=e.calculateZoomToOrigin(t,this._openFrom)||"";i=e.toTransformCss(o+" "+a);break;case f.animation.FADE:n={transitionInClass:"_md-panel-animate-enter"};break;default:n=p.isString(this._animationClass)?{transitionInClass:this._animationClass}:{transitionInClass:this._animationClass.open,transitionOutClass:this._animationClass.close}}return n.duration=this._openDuration,e.translate3d(t,i,s,n)},f.prototype.animateClose=function(t){var e=this._$mdUtil.dom.animator,n={},o=t[0].style.transform||"",i=e.toTransformCss(o),s=e.toTransformCss(o);switch(this._animationClass){case f.animation.SLIDE:t.css("opacity","1"),n={transitionInClass:"_md-panel-animate-leave",transitionOutClass:"_md-panel-animate-enter _md-panel-animate-leave"};var r=e.calculateSlideToOrigin(t,this._closeTo)||"";s=e.toTransformCss(r+" "+o);break;case f.animation.SCALE:n={transitionInClass:"_md-panel-animate-scale-out _md-panel-animate-leave",transitionOutClass:"_md-panel-animate-scale-out _md-panel-animate-enter _md-panel-animate-leave"};var a=e.calculateZoomToOrigin(t,this._closeTo)||"";s=e.toTransformCss(o+" "+a);break;case f.animation.FADE:n={transitionInClass:"_md-panel-animate-fade-out _md-panel-animate-leave",transitionOutClass:"_md-panel-animate-fade-out _md-panel-animate-enter _md-panel-animate-leave"};break;default:n=p.isString(this._animationClass)?{transitionOutClass:this._animationClass}:{transitionInClass:this._animationClass.close,transitionOutClass:this._animationClass.open}}return n.duration=this._closeDuration,e.translate3d(t,i,s,n)},f.prototype._fixBounds=function(t){var e=t[0].offsetWidth,n=t[0].offsetHeight;this._openFrom&&null==this._openFrom.bounds.height&&(this._openFrom.bounds.height=n),this._openFrom&&null==this._openFrom.bounds.width&&(this._openFrom.bounds.width=e),this._closeTo&&null==this._closeTo.bounds.height&&(this._closeTo.bounds.height=n),this._closeTo&&null==this._closeTo.bounds.width&&(this._closeTo.bounds.width=e)},f.prototype._getBoundingClientRect=function(t){if(t instanceof p.element)return{element:t,bounds:t[0].getBoundingClientRect()}}}(window,window.angular);