2020-05-19 11:43:42 +03:00

7 lines
26 KiB
JavaScript

/*!
* AngularJS Material Design
* https://github.com/angular/material
* @license MIT
* v1.1.18-master-97a1616
*/
!function(t,l){"use strict";p.$inject=["presets","$rootElement","$rootScope","$injector","$window"],l.module("material.components.panel",["material.core","material.components.backdrop"]).provider("$mdPanel",function(){return{definePreset:e,getAllPresets:o,clearPresets:r,$get:["$rootElement","$rootScope","$injector","$window",function(t,e,n,o){return new p(i,t,e,n,o)}]}});var s=80,a="_md-panel-hidden",n=l.element('<div class="_md-panel-focus-trap" tabindex="0"></div>'),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 o(){return l.copy(i)}function r(){i={}}function p(t,e,n,o,i){this._defaultConfigOptions={bindToController:!0,clickOutsideToClose:!1,disableParentScroll:!1,escapeToClose:!1,focusOnOpen:!0,fullscreen:!1,hasBackdrop:!1,propagateContainerEvents:!1,transformTemplate:l.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=c.animation,this.xPosition=d.xPosition,this.yPosition=d.yPosition,this.interceptorTypes=h.interceptorTypes,this.closeReasons=h.closeReasons,this.absPosition=d.absPosition}function h(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 d(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 e=l.isString(t)?document.querySelector(t):t;return l.element(e)}function f(t){return l.isNumber(t)?t+"px":t}p.prototype.create=function(t,e){if("string"==typeof t?t=this._getPresetByName(t):"object"!=typeof t||!l.isUndefined(e)&&e||(e=t,t={}),t=t||{},e=e||{},l.isDefined(e.id)&&this._trackedPanels[e.id]){var n=this._trackedPanels[e.id];return l.extend(n.config,e),n}this._config=l.extend({id:e.id||"panel_"+this._$mdUtil.nextUid(),scope:this._$rootScope.$new(!0),attachTo:this._$rootElement},this._defaultConfigOptions,e,t);var o=new h(this._config,this._$injector);return this._trackedPanels[this._config.id]=o,this._config.groupName&&(l.isString(this._config.groupName)&&(this._config.groupName=[this._config.groupName]),l.forEach(this._config.groupName,function(t){o.addToGroup(t)})),this._config.scope.$on("$destroy",l.bind(o,o.detach)),o},p.prototype.open=function(t,e){var n=this.create(t,e);return n.open().then(function(){return n})},p.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]},p.prototype.newPanelPosition=function(){return new d(this._$injector)},p.prototype.newPanelAnimation=function(){return new c(this._$injector)},p.prototype.newPanelGroup=function(t,e){if(!this._groups[t]){var n={panels:[],openPanels:[],maxOpen:0<(e=e||{}).maxOpen?e.maxOpen:1/0};this._groups[t]=n}return this._groups[t]},p.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},p.prototype._openCountExceedsMaxOpen=function(t){if(this._groups[t]){var e=this._groups[t];return 0<e.maxOpen&&e.openPanels.length>e.maxOpen}return!1},p.prototype._closeFirstOpenedPanel=function(t){this._groups[t].openPanels[0].close()},p.prototype._wrapTemplate=function(t){return'<div class="md-panel-outer-wrapper"> <div class="md-panel _md-panel-offscreen">'+(t||"")+"</div></div>"},p.prototype._wrapContentElement=function(t){var e=l.element('<div class="md-panel-outer-wrapper">');return t.addClass("md-panel _md-panel-offscreen"),e.append(t),e},h.interceptorTypes={CLOSE:"onClose"},h.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&&l.forEach(i.config.groupName,function(t){i._$mdPanel._openCountExceedsMaxOpen(t)&&i._$mdPanel._closeFirstOpenedPanel(t)})}).then(n).catch(e)})},h.prototype.close=function(s){var a=this;return this._$q(function(o,i){a._callInterceptors(h.interceptorTypes.CLOSE).then(function(){var t=a._done(o,a),e=a._simpleBind(a.detach,a),n=a.config.onCloseSuccess||l.noop;n=l.bind(a,n,a,s),a.hide().then(e).then(t).then(n).catch(i)},i)})},h.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||l.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)})},h.prototype.detach=function(){if(!this.isAttached)return this._$q.when(this);var o=this,i=o.config.onDomRemoved||l.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)})},h.prototype.destroy=function(){var e=this;this.config.groupName&&l.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=null},h.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(a))return this._$q.when(this);var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i.config.onOpenComplete||l.noop;i._$q.all([i._backdropRef?i._backdropRef.show():i,(i.panelContainer.removeClass(a),i._animateOpen()).then(function(){i._focusOnOpen()},e)]).then(o).then(function(){i.config.groupName&&l.forEach(i.config.groupName,function(t){i._$mdPanel._groups[t].openPanels.push(i)})}).then(n).catch(e)})},h.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(a))return this._$q.when(this);var i=this;return this._$q(function(t,e){var n=i._done(t,i),o=i.config.onRemoving||l.noop;i._$q.all([i._backdropRef?i._backdropRef.hide():i,i._animateClose().then(o).then(function(){i.panelContainer.addClass(a)}).then(function(){var e;i.config.groupName&&l.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&&u(t).focus()}).catch(e)]).then(n,e)})},h.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 AngularJS 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)},h.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 AngularJS 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)},h.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 AngularJS 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)},h.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=l.element(o.panelContainer[0].querySelector(".md-panel"));return o._compilerCleanup=t.cleanup,u(o.config.attachTo).append(o.panelContainer),o})},h.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,u(n.config.attachTo)),n._configureTrapFocus(),n._addStyles().then(function(){t(n)},e)},e)})},h.prototype._addStyles=function(){var n=this;return this._$q(function(t){n.panelContainer.css("z-index",n.config.zIndex),n.panelEl.css("z-index",n.config.zIndex+1);function e(){n._setTheming(),n.panelEl.removeClass("_md-panel-offscreen"),n.panelContainer.addClass(a),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()})},h.prototype._setTheming=function(){this._$mdTheming(this.panelEl),this._$mdTheming(this.panelContainer)},h.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()},h.prototype._updatePosition=function(t){var e=this.config.position;e&&(e._setPanelPosition(this.panelEl),t&&(this.panelEl.removeClass("_md-panel-offscreen"),this.panelContainer.addClass(a)),this.panelEl.css(d.absPosition.TOP,e.getTop()),this.panelEl.css(d.absPosition.BOTTOM,e.getBottom()),this.panelEl.css(d.absPosition.LEFT,e.getLeft()),this.panelEl.css(d.absPosition.RIGHT,e.getRight()))},h.prototype._focusOnOpen=function(){if(this.config.focusOnOpen){var t=this;this._$rootScope.$$postDigest(function(){(t._$mdUtil.findFocusTarget(t.panelEl)||t.panelEl).focus()})}},h.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()}},h.prototype._addEventListeners=function(){this._configureEscapeToClose(),this._configureClickOutsideToClose(),this._configureScrollListener()},h.prototype._removeEventListeners=function(){this._removeListeners&&this._removeListeners.forEach(function(t){t()}),this._removeListeners=[]},h.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(h.closeReasons.ESCAPE))};this.panelContainer.on("keydown",n),t.on("keydown",n),this._removeListeners.push(function(){e.panelContainer.off("keydown",n),t.off("keydown",n)})}},h.prototype._configureClickOutsideToClose=function(){if(this.config.clickOutsideToClose){var e,n=this.config.propagateContainerEvents?l.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(h.closeReasons.CLICK_OUTSIDE))};n.on("mousedown",t),n.on("mouseup",i),this._removeListeners.push(function(){n.off("mousedown",t),n.off("mouseup",i)})}},h.prototype._configureScrollListener=function(){if(!this.config.disableParentScroll){var t=l.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)})}},h.prototype._configureTrapFocus=function(){if(this.panelEl.attr("tabIndex","-1"),this.config.trapFocus){var t=this.panelEl;this._topFocusTrap=n.clone()[0],this._bottomFocusTrap=n.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)}},h.prototype.updateAnimation=function(t){this.config.animation=t,this._backdropRef&&this._backdropRef.config.animation.duration(t._rawDuration)},h.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()})})},h.prototype._animateClose=function(){var n=this.config.animation;if(!n)return this.panelContainer.removeClass("md-panel-is-showing"),this.panelContainer.removeClass("_md-panel-shown"),this._$q.when(this);var o=this;return this._$q(function(t){function e(){o.panelContainer.removeClass("md-panel-is-showing"),t(o)}n.animateClose(o.panelEl).then(e,function(){o._$log.warn("mdPanel: MdPanel Animations failed. Hiding panel without animating."),e()})})},h.prototype.registerInterceptor=function(t,e){var n=null;if(l.isString(t)?l.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},h.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},h.prototype.removeAllInterceptors=function(t){return t?this._interceptors[t]=[]:this._interceptors=Object.create(null),this},h.prototype._callInterceptors=function(t){var o=this,i=o._$q;return(o._interceptors&&o._interceptors[t]||[]).reduceRight(function(t,e){var n=e&&l.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))},h.prototype._simpleBind=function(e,n){return function(t){return e.apply(n,t)}},h.prototype._done=function(t,e){return function(){t(e)}},h.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)},h.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)},h.closeReasons={CLICK_OUTSIDE:"clickOutsideToClose",ESCAPE:"escapeToClose"},d.xPosition={CENTER:"center",ALIGN_START:"align-start",ALIGN_END:"align-end",OFFSET_START:"offset-start",OFFSET_END:"offset-end"},d.yPosition={CENTER:"center",ALIGN_TOPS:"align-tops",ALIGN_BOTTOMS:"align-bottoms",ABOVE:"above",BELOW:"below"},d.absPosition={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},d.viewportMargin=8,d.prototype.absolute=function(){return this._absolute=!0,this},d.prototype._setPosition=function(t,e){if(t===d.absPosition.RIGHT||t===d.absPosition.LEFT)this._left=this._right="";else{if(t!==d.absPosition.BOTTOM&&t!==d.absPosition.TOP){var n=Object.keys(d.absPosition).join().toLowerCase();throw new Error("mdPanel: Position must be one of "+n+".")}this._top=this._bottom=""}return this["_"+t]=l.isString(e)?e:"0",this},d.prototype.top=function(t){return this._setPosition(d.absPosition.TOP,t)},d.prototype.bottom=function(t){return this._setPosition(d.absPosition.BOTTOM,t)},d.prototype.start=function(t){var e=this._isRTL?d.absPosition.RIGHT:d.absPosition.LEFT;return this._setPosition(e,t)},d.prototype.end=function(t){var e=this._isRTL?d.absPosition.LEFT:d.absPosition.RIGHT;return this._setPosition(e,t)},d.prototype.left=function(t){return this._setPosition(d.absPosition.LEFT,t)},d.prototype.right=function(t){return this._setPosition(d.absPosition.RIGHT,t)},d.prototype.centerHorizontally=function(){return this._left="50%",this._right="",this._translateX=["-50%"],this},d.prototype.centerVertically=function(){return this._top="50%",this._bottom="",this._translateY=["-50%"],this},d.prototype.center=function(){return this.centerHorizontally().centerVertically()},d.prototype.relativeTo=function(t){return this._absolute=!1,this._relativeToEl=u(t),this},d.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},d.prototype._validateYPosition=function(t){if(null!=t){for(var e,n=Object.keys(d.yPosition),o=[],i=0;e=n[i];i++){var s=d.yPosition[e];if(o.push(s),s===t)return}throw new Error("mdPanel: Panel y position only accepts the following values:\n"+o.join(" | "))}},d.prototype._validateXPosition=function(t){if(null!=t){for(var e,n=Object.keys(d.xPosition),o=[],i=0;e=n[i];i++){var s=d.xPosition[e];if(o.push(s),s===t)return}throw new Error("mdPanel: Panel x Position only accepts the following values:\n"+o.join(" | "))}},d.prototype.withOffsetX=function(t){return this._translateX.push(f(t)),this},d.prototype.withOffsetY=function(t){return this._translateY.push(f(t)),this},d.prototype.getTop=function(){return this._top},d.prototype.getBottom=function(){return this._bottom},d.prototype.getLeft=function(){return this._left},d.prototype.getRight=function(){return this._right},d.prototype.getTransform=function(){return(this._reduceTranslateValues("translateX",this._translateX)+" "+this._reduceTranslateValues("translateY",this._translateY)).trim()},d.prototype._setTransform=function(t){return t.css(this._$mdConstant.CSS.TRANSFORM,this.getTransform())},d.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 a=n.substring(o+1,i).split(", ").slice(-2);s.x=parseInt(a[0]),s.y=parseInt(a[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},d.prototype.getActualPosition=function(){return this._actualPosition},d.prototype._reduceTranslateValues=function(n,t){return t.map(function(t){var e=l.isFunction(t)?f(t(this)):t;return n+"("+e+")"},this).join(" ")},d.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)}},d.prototype._constrainToViewport=function(t){var e=d.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":a<s&&(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":p<l&&(this._left=r-(l-p+e)+"px")}t.toggleClass("_md-panel-position-adjusted",this._top!==n||this._left!==o)},d.prototype._reverseXPosition=function(t){if(t===d.xPosition.CENTER)return t;var e="start";return-1<t.indexOf(e)?t.replace(e,"end"):t.replace("end",e)},d.prototype._bidi=function(t){return this._isRTL?this._reverseXPosition(t):t},d.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(),a=s.left,r=s.right,l=s.width;switch(this._bidi(e.x)){case d.xPosition.OFFSET_START:this._left=a-o+"px";break;case d.xPosition.ALIGN_END:this._left=r-o+"px";break;case d.xPosition.CENTER:var p=a+.5*l-.5*o;this._left=p+"px";break;case d.xPosition.ALIGN_START:this._left=a+"px";break;case d.xPosition.OFFSET_END:this._left=r+"px"}var h=s.top,c=s.bottom,u=s.height;switch(e.y){case d.yPosition.ABOVE:this._top=h-i+"px";break;case d.yPosition.ALIGN_BOTTOMS:this._top=c-i+"px";break;case d.yPosition.CENTER:var f=h+.5*u-.5*i;this._top=f+"px";break;case d.yPosition.ALIGN_TOPS:this._top=h+"px";break;case d.yPosition.BELOW:this._top=c+"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){return t&&(l.isNumber(t)?this._openDuration=this._closeDuration=e(t):l.isObject(t)&&(this._openDuration=e(t.open),this._closeDuration=e(t.close))),this._rawDuration=t,this;function e(t){if(l.isNumber(t))return t/1e3}},c.prototype._getPanelAnimationTarget=function(t){return l.isDefined(t.top)||l.isDefined(t.left)?{element:void 0,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 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 c.animation.SLIDE:t.css("opacity","1"),n={transitionInClass:"_md-panel-animate-enter"};var a=e.calculateSlideToOrigin(t,this._openFrom)||"";i=e.toTransformCss(a+" "+o);break;case c.animation.SCALE:n={transitionInClass:"_md-panel-animate-enter"};var r=e.calculateZoomToOrigin(t,this._openFrom)||"";i=e.toTransformCss(r+" "+o);break;case c.animation.FADE:n={transitionInClass:"_md-panel-animate-enter"};break;default:n=l.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)},c.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 c.animation.SLIDE:t.css("opacity","1"),n={transitionInClass:"_md-panel-animate-leave"};var a=e.calculateSlideToOrigin(t,this._closeTo)||"";s=e.toTransformCss(a+" "+o);break;case c.animation.SCALE:n={transitionInClass:"_md-panel-animate-scale-out _md-panel-animate-leave"};var r=e.calculateZoomToOrigin(t,this._closeTo)||"";s=e.toTransformCss(r+" "+o);break;case c.animation.FADE:n={transitionInClass:"_md-panel-animate-fade-out _md-panel-animate-leave"};break;default:n=l.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)},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 l.element)return{element:t,bounds:t[0].getBoundingClientRect()}}}(window,window.angular);