-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular.panels.min.js
1 lines (1 loc) · 1.51 KB
/
angular.panels.min.js
1
!function(e){"use strict";var n=e.module("angular.panels",[]);n.constant("panelList",{}),n.provider("panels",["panelList",function(n){this.add=function(e){return e&&e.id&&(n[e.id]=e),this},this.$get=["$parse",function(t){var o=e.element(document.body),s={opened:void 0,open:function(e){if(o.addClass("overflow-hidden"),s.opened&&s.close(s.opened),e&&n[e]){var i=n[e],l=i.element,a=l.scope(),c=t(i.openCallbackFunction)(a);l.attr("style",s.style(i,!0)),"function"==typeof c&&c()}s.opened=e},close:function(){if(o.removeClass("overflow-hidden"),s.opened&&n[s.opened]){var e=n[s.opened],i=e.element,l=i.scope(),a=t(e.closeCallbackFunction)(l);i.attr("style",s.style(e,!1)),"function"==typeof a&&a()}s.opened=void 0},style:function(e,n){switch(e.position){case"top":case"bottom":return e.position+":"+(n?"0;":"-"+e.size+";")+"height:"+e.size;case"left":case"right":return e.position+":"+(n?"0;":"-"+e.size+";")+"width:"+e.size}}};return s}]}]),n.directive("panels",["$http","$compile","panels","panelList",function(n,t,o,s){return{restrict:"A",scope:{},controller:["$scope",function(e){e.panels=o}],link:function(i,l,a){e.forEach(s,function(a,c){n.get(a.templateUrl).success(function(n){var n='<div style="'+o.style(a)+'" class="panels panel-'+a.position+'" data-ng-class="{open : panels.opened==\''+a.id+'\'}" data-ng-controller="'+a.controller+'">'+n+"</div>",p=t(n)(i);l.append(p),s[c].element=e.element(p)})}),l.append(t('<div class="dimming" data-ng-class="{open : panels.opened}" data-ng-click="panels.close();"></div>')(i))}}}])}(angular);