-
Notifications
You must be signed in to change notification settings - Fork 0
/
box-drag.min.js
1 lines (1 loc) · 1.91 KB
/
box-drag.min.js
1
!function(){"use strict";function e(e){function o(o,t,n){function r(e){t.css({position:"absolute"}),p=e.pageY-d,l=e.pageX-a,t.css({top:p+"px",left:l+"px"})}function i(){e.unbind("mousemove",r),e.unbind("mouseup",i),t.css({position:"fixed",top:v(t[0]).innerTop+"px"})}var a=0,d=0,l=0,p=20;t.appendTo("body"),t.css({position:"fixed",top:n.top||void 0,left:n.left||void 0,bottom:n.bottom||"20px",right:n.right||"20px",width:n.width||"400px"}),angular.element(t[0].querySelector("div.box-drag-header")).css({padding:n.paddingHeader||"7px 10px"});var u=n.bodyOverflowY||"inherit";angular.element(t[0].querySelector("div.box-drag-body")).css({height:n.bodyHeight||"310px","overflow-y":u}),angular.element(t[0].querySelector("div.box-drag-footer")).css({padding:n.paddingFooter||"7px 10px"});var g=angular.element(t[0].querySelector("div.box-drag-header")).prop("offsetHeight"),c=angular.element(t[0].querySelector("div.box-drag-header")).css("line-height"),c=parseFloat(c.replace("px","")),s=angular.element(t[0].querySelector("div.box-drag-body")).prop("offsetHeight"),f=angular.element(t[0].querySelector("div.box-drag-footer")).prop("offsetHeight");void 0===f&&(f=0),"inherit"===u&&(c=0),t.css({height:g+s+f+c+"px"});var v=function(e){var o,t={top:0,left:0},n=e&&e.ownerDocument;return o=n.documentElement,void 0!==typeof e.getBoundingClientRect&&(t=e.getBoundingClientRect()),{top:t.top+(window.pageYOffset||o.scrollTop)-(o.clientTop||0),left:t.left+(window.pageXOffset||o.scrollLeft)-(o.clientLeft||0),innerTop:t.top}},x=function(o){o.preventDefault(),l=v(t[0]).left,p=v(t[0]).top,a=o.pageX-l,d=o.pageY-p,e.on("mousemove",r),e.on("mouseup",i)};angular.element(t[0].querySelector("div.box-drag-handle")).on("mousedown",x),o.$on("$destroy",function(){angular.element(t[0].querySelector("div.box-drag-handle")).off("mousedown",x),t.remove()})}var t={link:o,restrict:"E"};return t}angular.module("boxDrag",[]).directive("boxDrag",e),e.$inject=["$document"]}();