diff --git a/js/ngPopover.min.js b/js/ngPopover.min.js new file mode 100644 index 0000000..ba13c70 --- /dev/null +++ b/js/ngPopover.min.js @@ -0,0 +1 @@ +var module=angular.module("ngPopover",[]);module.provider("ngPopover",function(){var o,t=!1,e=500,n=0,r=15,p=[];$(document).on("click",function(e){if(t){var n=p.some(function(o){return 0!=$(o).has(e.target).length});if(!$("#ng-popover").is(e.target)&&0==$("#ng-popover").has(e.target).length&&!n){var r=200,i=$(e.target);(i.attr("ng-popover")||i.parents(["ng-popover"]))&&(r=0),$("#ng-popover").fadeOut(r,function(){$(this).remove(),t=!1,o!=e.target&&(i.attr("ng-popover")||i.parents(["ng-popover"]))&&i.trigger("click")})}}});var i=function(o,t,p,i,a,l){var v=$(o).offset(),f=$(o).outerWidth(),c=$(o).outerHeight(),s=$("#ng-popover").outerWidth(),g=$("#ng-popover").outerHeight(),d=$(window).width();l&&($("#ng-popover").css({maxWidth:+l}),s=$("#ng-popover").outerWidth()),i&&(s=f,$("#ng-popover").css({width:s}));var h=$(window),u={top:h.scrollTop(),left:h.scrollLeft()};u.right=u.left+h.width(),u.bottom=u.top+h.height();var m;if("left"===t&&(m={left:v.left-s,top:v.top+c/2-g/2}),"right"===t&&(m={left:v.left+f,top:v.top+c/2-g/2}),"bottom"===t&&(m={left:v.left+f/2-s/2,top:v.top+c}),"top"===t&&(m={left:v.left-s/2,top:v.top-g}),"left"===t||"right"===t){var w=0;(m.top+g>u.bottom||m.topu.right&&(b=Math.min(m.left,m.left+s-u.right),m.left-=b+r,$("#ng-popover .arrow").css({left:b+r+s/2}))}if(a){var y=$(o).find(a);anchorPosition=y.offset(),anchorWidth=y.outerWidth(),$("#ng-popover .arrow").css({left:anchorPosition.left-v.left+anchorWidth/2-1})}if(e>d&&p){var k=s-$("#ng-popover").width();$("#ng-popover").width(d-k-2*n),m.left=n,("bottom"===t||"top"===t)&&$("#ng-popover .arrow").css({left:v.left+f/2-n})}else $("#ng-popover").width(s);return m};$("body").on("keyup",function(o){27===o.keyCode&&$("#ng-popover").fadeOut(200,function(){$(this).remove(),t=!1})}),this.$get=["$rootScope","$templateCache","$compile",function(r,a,l){return{setup:function(o){e=o.smallScreenBreakpoint||500,n=o.maximizeMargin||0,p=o.overlayClasses||[]},close:function(o){r.$broadcast("ng-popover-hide",o)},open:function(e,n,p){var v=a.get(p.template||p.ngPopover);v||(v=p.template||p.ngPopover);var f=p.placement||"bottom",c=p.maximize||!1,s=p.title||"",g=p.useparentwidth||!1,d=p.anchorselector||"",h=p.maxwidth||null;p.data&&(n=n.$new(),n.rrData=p.data);var u=function(){$("body").append(""),l($("#ng-popover").contents())(n),n.$apply();var o=i(e,f,c,g,d,h);$(".close-pop").on("click",function(){$("#ng-popover").fadeOut(200,function(){$(this).remove(),t=!1})});var r=f;"bottom"===f&&""===s&&(r="bottom-no-title"),$("#ng-popover").css({left:o.left,top:o.top}).toggleClass(r).fadeIn(100,function(){t=!0})};$(e).on("click",function(e){if(!t)if(o=e.target,r.$broadcast("ng-popover-show",n),p.init){var i=n.$eval(p.init);"object"==typeof i?i.then(function(){setTimeout(u,0)}):u()}else u()}),n.$on("ng-popover-hide",function(){$("#ng-popover").fadeOut(100,function(){$(this).remove(),t=!1})})}}}]}),module.directive("ngPopover",["ngPopover",function(o){return{restrict:"A",link:function(t,e,n){o.open(e,t,n)}}}]); \ No newline at end of file