angular.module("ionic-pullup",[]).constant("ionPullUpFooterState",{COLLAPSED:"COLLAPSED",MINIMIZED:"MINIMIZED",EXPANDED:"EXPANDED"}).constant("ionPullUpFooterBehavior",{HIDE:"HIDE",EXPAND:"EXPAND"}).directive("ionPullUpFooter",["$timeout","$rootScope","$window","$ionicPlatform",function(t,e,n,i){return{restrict:"AE",scope:{onExpand:"&",onCollapse:"&",onMinimize:"&"},controller:["$scope","$element","$attrs","ionPullUpFooterState","ionPullUpFooterBehavior",function(o,a,r,s,l){function u(){c(),a.css({transition:"300ms ease-in-out",padding:0}),P&&E&&a.css("bottom",P.offsetHeight+"px")}function c(){P=document.querySelector(".tabs"),E=document.querySelector(".tabs-bottom"),D=document.querySelector(".bar-header"),H=P?P.offsetHeight:0,x=D?D.offsetHeight:0}function p(){I.height=I.maxHeight>0?I.maxHeight:n.innerHeight-x-v-H,"ios"==e.platformOS&&(I.height-=60),"android"==e.platformOS&&(I.height-=40),a.css({height:I.height+"px"}),I.initialState==s.MINIMIZED?m():f()}function h(){t(function(){p()},300),a.css({transition:"none",padding:0})}function d(){c(),I.height=I.maxHeight>0?I.maxHeight:n.innerHeight-x-v-H,"ios"==e.platformOS&&(I.height-=60),"android"==e.platformOS&&(I.height-=40)}function g(){d(),I.lastPosY=0,a.css({height:I.height+"px","-webkit-transform":"translate3d(0, 0, 0)",transform:"translate3d(0, 0, 0)"}),a.css({transition:"300ms ease-in-out",padding:0}),o.onExpand(),I.state=s.EXPANDED}function f(){I.lastPosY=P&&E?I.height-H:I.height-I.defaultHeight,a.css({"-webkit-transform":"translate3d(0, "+I.lastPosY+"px, 0)",transform:"translate3d(0, "+I.lastPosY+"px, 0)"}),o.onCollapse(),I.state=s.COLLAPSED}function m(){I.lastPosY=I.height,a.css({"-webkit-transform":"translate3d(0, "+I.lastPosY+"px, 0)",transform:"translate3d(0, "+I.lastPosY+"px, 0)"}),o.onMinimize(),I.state=s.MINIMIZED}var P,E,D,H,x,v=0,I={height:0,posY:0,lastPosY:0,state:s.COLLAPSED,defaultHeight:a[0].offsetHeight,maxHeight:parseInt(r.maxHeight,10)||0,initialState:r.initialState?r.initialState.toUpperCase():s.COLLAPSED,defaultBehavior:r.defaultBehavior?r.defaultBehavior.toUpperCase():l.EXPAND} this.setHandleHeight=function(t){v=t,p()},this.getHeight=function(){return a[0].offsetHeight},this.getBackground=function(){return n.getComputedStyle(a[0]).background},this.onTap=function(t){t.gesture.srcEvent.preventDefault(),t.gesture.preventDefault(),I.state==s.COLLAPSED?I.defaultBehavior==l.HIDE?m():g():I.state==s.MINIMIZED?I.defaultBehavior==l.HIDE?f():g():I.initialState==s.MINIMIZED?m():f(),e.$broadcast("ionPullUp:tap",I.state)},this.onDrag=function(t){switch(t.gesture.srcEvent.preventDefault(),t.gesture.preventDefault(),t.type){case"dragstart":a.css("transition","none") break case"drag":if(I.posY=Math.round(t.gesture.deltaY)+I.lastPosY,I.posY<0||I.posY>I.height)return a.css({"-webkit-transform":"translate3d(0, "+I.posY+"px, 0)",transform:"translate3d(0, "+I.posY+"px, 0)"}) break case"dragend":a.css({transition:"300ms ease-in-out"}),I.lastPosY=I.posY}},u(),i.ready(function(){n.addEventListener("orientationchange",h),i.on("resume",h)})}],compile:function(t,e){e.defaultHeight&&t.css("height",parseInt(e.defaultHeight,10)+"px"),t.addClass("bar bar-footer")}}}]).directive("ionPullUpContent",[function(){return{restrict:"AE",require:"^ionPullUpFooter",link:function(t,e,n,i){var o=i.getHeight() e.css({display:"block","margin-top":o+"px",width:"100%"}),n.scroll&&"TRUE"==n.scroll.toUpperCase()&&e.css({"overflow-y":"scroll","overflow-x":"hidden"})}}}]).directive("ionPullUpBar",[function(){return{restrict:"AE",require:"^ionPullUpFooter",link:function(t,e,n,i){var o=i.getHeight() e.css({display:"flex",height:o+"px",position:"absolute",right:"0",left:"0"})}}}]).directive("ionPullUpTrigger",["$ionicGesture",function(t){return{restrict:"AE",require:"^ionPullUpFooter",link:function(e,n,i,o){t.on("tap",o.onTap,n),t.on("drag dragstart dragend",o.onDrag,n)}}}]).directive("ionPullUpHandle",["$ionicGesture","$ionicPlatform","$timeout","$window",function(t,e,n,i){return{restrict:"AE",require:"^ionPullUpFooter",link:function(o,a,r,s){function l(){n(function(){a.css("left",(i.innerWidth-c)/2+"px")},300)}var u=parseInt(r.height,10)||25,c=parseInt(r.width,10)||100,p=s.getBackground(),h=r.toggle s.setHandleHeight(u),a.css({display:"block",background:p,position:"absolute",top:1-u+"px",left:(i.innerWidth-c)/2+"px",height:u+"px",width:c+"px","text-align":"center"}),t.on("tap",s.onTap,a),t.on("drag dragstart dragend",s.onDrag,a),o.$on("ionPullUp:tap",function(){a.find("i").toggleClass(h)}),e.ready(function(){i.addEventListener("orientationchange",l),e.on("resume",l)})}}}])