angular.module('mc.resizer', []).directive('resizer', function($document) { return function($scope, $element, $attrs) { $element.on('mousedown', function(event) { event.preventDefault(); if($attrs.resizer == 'horizontalxx'){ if($scope.bottomW == 50){ $element.css({ bottom: 86+'%' }); $($attrs.resizerTop).css({ bottom: 86+'%' }); $($attrs.resizerBottom).css({ height: 86+'%' }); }else{ $element.css({ bottom: 50+'%' }); $($attrs.resizerTop).css({ bottom: 50+'%' }); $($attrs.resizerBottom).css({ height: 50+'%' }); } //var y = window.innerHeight - event.pageY; //alert($scope.bottomW); //$document.on('mouseup', mouseup); }else{ $document.on('mousemove', mousemove); $document.on('mouseup', mouseup); } }); function mousemove(event) { if ($attrs.resizer == 'vertical') { // Handle vertical resizer var x = event.pageX; if ($attrs.resizerMax && x > $attrs.resizerMax) { x = parseInt($attrs.resizerMax); } $element.css({ left: x + 'px' }); $($attrs.resizerLeft).css({ width: x + 'px' }); $($attrs.resizerRight).css({ left: (x + parseInt($attrs.resizerWidth)) + 'px' }); } else if($attrs.resizer == 'horizontalxx') { // Handle horizontal resizer var y = $(window).height() - event.pageY; //alert(""); $element.css({ bottom: 450 + 'px' }); $($attrs.resizerTop).css({ bottom: (450 + parseInt($attrs.resizerHeight)) + 'px' }); $($attrs.resizerBottom).css({ height: 450 + 'px' }); }else { // Handle horizontal resizer var y = $(window).height() - event.pageY; $element.css({ bottom: y + 'px' }); $($attrs.resizerTop).css({ bottom: y + parseInt($attrs.resizerHeight) + 'px' }); $($attrs.resizerBottom).css({ height: y + 'px' }); } } function mouseup() { $document.unbind('mousemove', mousemove); $document.unbind('mouseup', mouseup); } }; });