|
|
/*! * Angular Material Design * https://github.com/angular/material
* @license MIT * v1.1.0-master-2b98560 */ !function(e,t,n){"use strict";function r(e,r,o,i,a,l,s,d){var u,c,m=a.prefixer(),f=this;this.nestLevel=parseInt(r.mdNestLevel,10)||0,this.init=function(n,r){r=r||{},u=n,c=o[0].querySelector(m.buildSelector(["ng-click","ng-mouseenter"])),c.setAttribute("aria-expanded","false"),this.isInMenuBar=r.isInMenuBar,this.nestedMenus=a.nodesToArray(u[0].querySelectorAll(".md-nested-menu")),u.on("$mdInterimElementRemove",function(){f.isOpen=!1,a.nextTick(function(){f.onIsOpenChanged(f.isOpen)})}),a.nextTick(function(){f.onIsOpenChanged(f.isOpen)});var l="menu_container_"+a.nextUid();u.attr("id",l),t.element(c).attr({"aria-owns":l,"aria-haspopup":"true"}),i.$on("$destroy",t.bind(this,function(){this.disableHoverListener(),e.destroy()})),u.on("$destroy",function(){e.destroy()})};var p,h,g=[];this.enableHoverListener=function(){g.push(s.$on("$mdMenuOpen",function(e,t){u[0].contains(t[0])&&(f.currentlyOpenMenu=t.controller("mdMenu"),f.isAlreadyOpening=!1,f.currentlyOpenMenu.registerContainerProxy(f.triggerContainerProxy.bind(f)))})),g.push(s.$on("$mdMenuClose",function(e,t){u[0].contains(t[0])&&(f.currentlyOpenMenu=n)})),h=t.element(a.nodesToArray(u[0].children[0].children)),h.on("mouseenter",f.handleMenuItemHover),h.on("mouseleave",f.handleMenuItemMouseLeave)},this.disableHoverListener=function(){for(;g.length;)g.shift()();h&&h.off("mouseenter",f.handleMenuItemHover),h&&h.off("mouseleave",f.handleMenuItemMouseLeave)},this.handleMenuItemHover=function(e){if(!f.isAlreadyOpening){var n=e.target.querySelector("md-menu")||a.getClosest(e.target,"MD-MENU");p=l(function(){if(n&&(n=t.element(n).controller("mdMenu")),f.currentlyOpenMenu&&f.currentlyOpenMenu!=n){var e=f.nestLevel+1;f.currentlyOpenMenu.close(!0,{closeTo:e}),f.isAlreadyOpening=!!n,n&&n.open()}else n&&!n.isOpen&&n.open&&(f.isAlreadyOpening=!!n,n&&n.open())},n?100:250);var r=e.currentTarget.querySelector(".md-button:not([disabled])");r&&r.focus()}},this.handleMenuItemMouseLeave=function(){p&&(l.cancel(p),p=n)},this.open=function(t){t&&t.stopPropagation(),t&&t.preventDefault(),f.isOpen||(f.enableHoverListener(),f.isOpen=!0,a.nextTick(function(){f.onIsOpenChanged(f.isOpen)}),c=c||(t?t.target:o[0]),c.setAttribute("aria-expanded","true"),i.$emit("$mdMenuOpen",o),e.show({scope:i,mdMenuCtrl:f,nestLevel:f.nestLevel,element:u,target:c,preserveElement:!0,parent:"body"})["finally"](function(){c.setAttribute("aria-expanded","false"),f.disableHoverListener()}))},i.$mdOpenMenu=this.open,this.onIsOpenChanged=function(e){e?(u.attr("aria-hidden","false"),o[0].classList.add("md-open"),t.forEach(f.nestedMenus,function(e){e.classList.remove("md-open")})):(u.attr("aria-hidden","true"),o[0].classList.remove("md-open")),i.$mdMenuIsOpen=f.isOpen},this.focusMenuContainer=function(){var e=u[0].querySelector(m.buildSelector(["md-menu-focus-target","md-autofocus"]));e||(e=u[0].querySelector(".md-button")),e.focus()},this.registerContainerProxy=function(e){this.containerProxy=e},this.triggerContainerProxy=function(e){this.containerProxy&&this.containerProxy(e)},this.destroy=function(){return f.isOpen?e.destroy():d.when(!1)},this.close=function(n,r){if(f.isOpen){f.isOpen=!1,a.nextTick(function(){f.onIsOpenChanged(f.isOpen)});var l=t.extend({},r,{skipFocus:n});if(i.$emit("$mdMenuClose",o,l),e.hide(null,r),!n){var s=f.restoreFocusTo||o.find("button")[0];s instanceof t.element&&(s=s[0]),s&&s.focus()}}},this.positionMode=function(){var e=(r.mdPositionMode||"target").split(" ");return 1==e.length&&e.push(e[0]),{left:e[0],top:e[1]}},this.offsets=function(){var e=(r.mdOffset||"0 0").split(" ").map(parseFloat);if(2==e.length)return{left:e[0],top:e[1]};if(1==e.length)return{top:e[0],left:e[0]};throw Error("Invalid offsets specified. Please follow format <x, y> or <n>")}}function o(e){function r(n){n.addClass("md-menu");var r=n.children()[0],a=e.prefixer();if(a.hasAttribute(r,"ng-click")||(r=r.querySelector(a.buildSelector(["ng-click","ng-mouseenter"]))||r),!r||"MD-BUTTON"!=r.nodeName&&"BUTTON"!=r.nodeName||r.hasAttribute("type")||r.setAttribute("type","button"),2!=n.children().length)throw Error(i+"Expected two children elements.");r&&r.setAttribute("aria-haspopup","true");var l=n[0].querySelectorAll("md-menu"),s=parseInt(n[0].getAttribute("md-nest-level"),10)||0;return l&&t.forEach(e.nodesToArray(l),function(e){e.hasAttribute("md-position-mode")||e.setAttribute("md-position-mode","cascade"),e.classList.add("_md-nested-menu"),e.setAttribute("md-nest-level",s+1)}),o}function o(e,r,o,i){var a=i[0],l=i[1]!=n,s=t.element('<div class="_md md-open-menu-container md-whiteframe-z2"></div>'),d=r.children()[1];r.addClass("_md"),d.hasAttribute("role")||d.setAttribute("role","menu"),s.append(d),r.on("$destroy",function(){s.remove()}),r.append(s),s[0].style.display="none",a.init(s,{isInMenuBar:l})}var i="Invalid HTML for md-menu: ";return{restrict:"E",require:["mdMenu","?^mdMenuBar"],controller:"mdMenuCtrl",scope:!0,compile:r}}function i(e){function r(e,r,a,l,s,d,u,c,m){function f(n,r,o){return o.nestLevel?t.noop:(o.disableParentScroll&&!e.getClosest(o.target,"MD-DIALOG")?o.restoreScroll=e.disableScrollAround(o.element,o.parent):o.disableParentScroll=!1,o.hasBackdrop&&(o.backdrop=e.createBackdrop(n,"md-menu-backdrop md-click-catcher"),m.enter(o.backdrop,l[0].body)),function(){o.backdrop&&o.backdrop.remove(),o.disableParentScroll&&o.restoreScroll()})}function p(e,t,n){function r(){return c(t,{addClass:"md-leave"}).start()}function o(){t.removeClass("md-active"),b(t,n),n.alreadyOpen=!1}return n.cleanupInteraction&&n.cleanupInteraction(),n.cleanupResizing(),n.hideBackdrop(),n.$destroy===!0?o():r().then(o)}function h(n,o,i){function l(){return i.parent.append(o),o[0].style.display="",d(function(e){var t=y(o,i);o.removeClass("md-leave"),c(o,{addClass:"md-active",from:C.toCss(t),to:C.toCss({transform:""})}).start().then(e)})}function m(){if(!i.target)throw Error("$mdMenu.show() expected a target to animate from in options.target");t.extend(i,{alreadyOpen:!1,isRemoved:!1,target:t.element(i.target),parent:t.element(i.parent),menuContentEl:t.element(o[0].querySelector("md-menu-content"))})}function p(){var e=function(e,t){return u.throttle(function(){if(!i.isRemoved){var n=y(e,t);e.css(C.toCss(n))}})}(o,i);return s.addEventListener("resize",e),s.addEventListener("orientationchange",e),function(){s.removeEventListener("resize",e),s.removeEventListener("orientationchange",e)}}function h(){function t(t){var n;switch(t.keyCode){case a.KEY_CODE.ESCAPE:i.mdMenuCtrl.close(!1,{closeAll:!0}),n=!0;break;case a.KEY_CODE.UP_ARROW:g(t,i.menuContentEl,i,-1)||i.nestLevel||i.mdMenuCtrl.triggerContainerProxy(t),n=!0;break;case a.KEY_CODE.DOWN_ARROW:g(t,i.menuContentEl,i,1)||i.nestLevel||i.mdMenuCtrl.triggerContainerProxy(t),n=!0;break;case a.KEY_CODE.LEFT_ARROW:i.nestLevel?i.mdMenuCtrl.close():i.mdMenuCtrl.triggerContainerProxy(t),n=!0;break;case a.KEY_CODE.RIGHT_ARROW:var r=e.getClosest(t.target,"MD-MENU");r&&r!=i.parent[0]?t.target.click():i.mdMenuCtrl.triggerContainerProxy(t),n=!0}n&&(t.preventDefault(),t.stopImmediatePropagation())}function r(e){e.preventDefault(),e.stopPropagation(),n.$apply(function(){i.mdMenuCtrl.close(!0,{closeAll:!0})})}function l(t){function r(){n.$apply(function(){i.mdMenuCtrl.close(!0,{closeAll:!0})})}function o(e,t){if(!e)return!1;for(var n,r=0;n=t[r];++r)if(M.hasAttribute(e,n))return!0;return!1}var a=t.target;do{if(a==i.menuContentEl[0])return;if((o(a,["ng-click","ng-href","ui-sref"])||"BUTTON"==a.nodeName||"MD-BUTTON"==a.nodeName)&&!o(a,["md-prevent-menu-close"])){var l=e.getClosest(a,"MD-MENU");a.hasAttribute("disabled")||l&&l!=i.parent[0]||r();break}}while(a=a.parentNode)}o.addClass("md-clickable"),i.backdrop&&i.backdrop.on("click",r),i.menuContentEl.on("keydown",t),i.menuContentEl[0].addEventListener("click",l,!0);var s=i.menuContentEl[0].querySelector(M.buildSelector(["md-menu-focus-target","md-autofocus"]));if(!s){var d=i.menuContentEl[0].firstElementChild;s=d&&(d.querySelector(".md-button:not([disabled])")||d.firstElementChild)}return s&&s.focus(),function(){o.removeClass("md-clickable"),i.backdrop&&i.backdrop.off("click",r),i.menuContentEl.off("keydown",t),i.menuContentEl[0].removeEventListener("click",l,!0)}}return m(i),r.inherit(i.menuContentEl,i.target),i.cleanupResizing=p(),i.hideBackdrop=f(n,o,i),l().then(function(e){return i.alreadyOpen=!0,i.cleanupInteraction=h(),e})}function g(t,n,r,o){for(var i,a=e.getClosest(t.target,"MD-MENU-ITEM"),l=e.nodesToArray(n[0].children),s=l.indexOf(a),d=s+o;d>=0&&d<l.length;d+=o){var u=l[d].querySelector(".md-button");if(i=v(u))break}return i}function v(e){if(e&&e.getAttribute("tabindex")!=-1)return e.focus(),l[0].activeElement==e}function b(e,t){t.preserveElement?o(e).style.display="none":o(e).parentNode===o(t.parent)&&o(t.parent).removeChild(o(e))}function y(t,r){function o(e){e.top=Math.max(Math.min(e.top,b.bottom-u.offsetHeight),b.top),e.left=Math.max(Math.min(e.left,b.right-u.offsetWidth),b.left)}function a(){for(var e=0;e<c.children.length;++e)if("none"!=s.getComputedStyle(c.children[e]).display)return c.children[e]}var d,u=t[0],c=t[0].firstElementChild,m=c.getBoundingClientRect(),f=l[0].body,p=f.getBoundingClientRect(),h=s.getComputedStyle(c),g=r.target[0].querySelector(M.buildSelector("md-menu-origin"))||r.target[0],v=g.getBoundingClientRect(),b={left:p.left+i,top:Math.max(p.top,0)+i,bottom:Math.max(p.bottom,Math.max(p.top,0)+p.height)-i,right:p.right-i},y={top:0,left:0,right:0,bottom:0},C={top:0,left:0,right:0,bottom:0},E=r.mdMenuCtrl.positionMode();"target"!=E.top&&"target"!=E.left&&"target-right"!=E.left||(d=a(),d&&(d=d.firstElementChild||d,d=d.querySelector(M.buildSelector("md-menu-align-target"))||d,y=d.getBoundingClientRect(),C={top:parseFloat(u.style.top||0),left:parseFloat(u.style.left||0)}));var O={},k="top ";switch(E.top){case"target":O.top=C.top+v.top-y.top;break;case"cascade":O.top=v.top-parseFloat(h.paddingTop)-g.style.top;break;case"bottom":O.top=v.top+v.height;break;default:throw new Error('Invalid target mode "'+E.top+'" specified for md-menu on Y axis.')}var $="rtl"==e.bidi();switch(E.left){case"target":O.left=C.left+v.left-y.left,k+=$?"right":"left";break;case"target-left":O.left=v.left,k+="left";break;case"target-right":O.left=v.right-m.width+(m.right-y.right),k+="right";break;case"cascade":var A=$?v.left-m.width<b.left:v.right+m.width<b.right;O.left=A?v.right-g.style.left:v.left-g.style.left-m.width,k+=A?"left":"right";break;case"right":$?(O.left=v.right-v.width,k+="left"):(O.left=v.right-m.width,k+="right");break;case"left":$?(O.left=v.right-m.width,k+="right"):(O.left=v.left,k+="left");break;default:throw new Error('Invalid target mode "'+E.left+'" specified for md-menu on X axis.')}var x=r.mdMenuCtrl.offsets();O.top+=x.top,O.left+=x.left,o(O);var w=Math.round(100*Math.min(v.width/u.offsetWidth,1))/100,S=Math.round(100*Math.min(v.height/u.offsetHeight,1))/100;return{top:Math.round(O.top),left:Math.round(O.left),transform:r.alreadyOpen?n:e.supplant("scale({0},{1})",[w,S]),transformOrigin:k}}var M=e.prefixer(),C=e.dom.animator;return{parent:"body",onShow:h,onRemove:p,hasBackdrop:!0,disableParentScroll:!0,skipCompile:!0,preserveScope:!0,skipHide:!0,themable:!0}}function o(e){return e instanceof t.element&&(e=e[0]),e}r.$inject=["$mdUtil","$mdTheming","$mdConstant","$document","$window","$q","$$rAF","$animateCss","$animate"];var i=8;return e("$mdMenu").setDefaults({methods:["target"],options:r})}t.module("material.components.menu",["material.core","material.components.backdrop"]),r.$inject=["$mdMenu","$attrs","$element","$scope","$mdUtil","$timeout","$rootScope","$q"],t.module("material.components.menu").controller("mdMenuCtrl",r),o.$inject=["$mdUtil"],t.module("material.components.menu").directive("mdMenu",o),i.$inject=["$$interimElementProvider"],t.module("material.components.menu").provider("$mdMenu",i)}(window,window.angular);
|