You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
26 KiB

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