<commit_before>var angular = require('angular');
var boxModule = angular.module('ui.box');
require('./transclude-replace');

var _makeDirective = function(direction) {
	var _modeHorizontal = direction==='horizontal';
	return {
		restrict: 'E',
		replace: true,
		transclude: true,
		template: '<div class="splitbox"><div class="splitter"><div> </div></div><div ui-transclude-replace/></div>',
		link:  function(scope, element, attr) {
	var _isDragging = false;

	var splitter = element.children().eq(0);
	var splitterSize = attr.splitterSize || 1;
	var oneMinSize = attr.oneMinSize || 1;
	var twoMinSize = attr.twoMinSize || 1;

	var one = element.children().eq(1);
	var two = element.children().eq(2);
	element.addClass(_modeHorizontal ? 'horizontal' : 'vertical');
	splitter.addClass(_modeHorizontal ? 'horizontal' : 'vertical');
	one.addClass('splitboxbox');
	two.addClass('splitboxbox');
	
	element.bind('mousemove', function(event) {
		if(!_isDragging) {
			return;
		} else {
			var bounds = element[0].getBoundingClientRect();


			if(_modeHorizontal) {
				_tick(event.clientY);
			}
			else {
				_tick(event.clientX);
			}
		}
	});

	splitter.bind('mousedown', function(event) {
		event.preventDefault();
		_isDragging = true;
	});
	angular.element(document).bind('mouseup', function(event) {
		_isDragging = false;
	});

	function _tick(mousePos) {
		var pct = 0;
		var bounds = element[0].getBoundingClientRect();

		if(_modeHorizontal){
		    var height = bounds.bottom - bounds.top;
		    var pos = mousePos - bounds.top;
            if (pos < oneMinSize) return;
		    if (height - pos < twoMinSize) return;

			pct = pos/height*100;
	    	splitter.css('top',pct + '%');
	    	one.css('height', pct + '%');
		    two.css('top', pct + '%');			
		} else {
		    var width = bounds.right - bounds.left;
		    var pos = mousePos - bounds.left;
            if (pos < oneMinSize) return;
		    if (width - pos < twoMinSize) return;

			pct = pos/width*100;
		   splitter.css('left',pct + '%');
		    one.css('width', pct + '%');
	    	two.css('left', pct + '%');			

		}
	}

//			var firstBounds = one.getBoundingClientRect();
	var _init = function() {
		var bounds = element[0].getBoundingClientRect();		
		if(_modeHorizontal) {
			_tick((bounds.bottom - bounds.top)/2);
		} else{
			_tick((bounds.right - bounds.top)/2);
		}
	}
	_init();
}

	}
}

boxModule.directive('hbox', function() {
	return _makeDirective('horizontal');
});

boxModule.directive('vbox', function() {
	return _makeDirective('vertical');
});<commit_msg>added refresh event<commit_after>var angular = require('angular');
var boxModule = angular.module('ui.box');
require('./transclude-replace');

var _makeDirective = function(direction, $rootScope) {
	var _modeHorizontal = direction==='horizontal';
	return {
		restrict: 'E',
		replace: true,
		transclude: true,
		template: '<div class="splitbox"><div class="splitter"><div> </div></div><div ui-transclude-replace/></div>',
		link:  function(scope, element, attr) {
	var _isDragging = false;

	var splitter = element.children().eq(0);
	var splitterSize = attr.splitterSize || 1;
	var oneMinSize = attr.oneMinSize || 1;
	var twoMinSize = attr.twoMinSize || 1;

	var one = element.children().eq(1);
	var two = element.children().eq(2);
	element.addClass(_modeHorizontal ? 'horizontal' : 'vertical');
	splitter.addClass(_modeHorizontal ? 'horizontal' : 'vertical');
	
	element.bind('mousemove', function(event) {
		if(!_isDragging) {
			return;
		} else {
			var bounds = element[0].getBoundingClientRect();


			if(_modeHorizontal) {
				_tick(event.clientY);
			}
			else {
				_tick(event.clientX);
			}
		}
	});

	splitter.bind('mousedown', function(event) {
		event.preventDefault();
		_isDragging = true;
	});
	angular.element(document).bind('mouseup', function(event) {
		_isDragging = false;
	});

	$rootScope.$on('ui.box.redraw', function() {
		_init();
	});

	function _tick(mousePos) {
		element.children().eq(1).addClass('splitboxbox');
		element.children().eq(2).addClass('splitboxbox');

		var pct = 0;
		var bounds = element[0].getBoundingClientRect();

		if(_modeHorizontal){
		    var height = bounds.bottom - bounds.top;
		    var pos = mousePos - bounds.top;
            if (pos < oneMinSize) return;
		    if (height - pos < twoMinSize) return;

			pct = pos/height*100;
	    	splitter.css('top',pct + '%');
	    	element.children().eq(1).css('height', pct + '%');
		    element.children().eq(2).css('top', pct + '%');		
		    element.children().css('width','100%');
		    element.children().css('left','0%');
		} else {
		    var width = bounds.right - bounds.left;
		    var pos = mousePos - bounds.left;
            if (pos < oneMinSize) return;
		    if (width - pos < twoMinSize) return;

			pct = pos/width*100;
		   splitter.css('left',pct + '%');
		    element.children().eq(1).css('width', pct + '%');
	    	element.children().eq(2).css('left', pct + '%');			
		    element.children().css('height','100%');
		    element.children().css('top','0%');

		}
	}

//			var firstBounds = one.getBoundingClientRect();
	function _init() {
		var bounds = element[0].getBoundingClientRect();		
		if(_modeHorizontal) {
			_tick((bounds.bottom - bounds.top)/2);
		} else{
			_tick((bounds.right - bounds.top)/2);
		}
	}
	_init();
}

	}
}

boxModule.directive('hbox', function($rootScope) {
	return _makeDirective('horizontal', $rootScope);
});

boxModule.directive('vbox', function($rootScope) {
	return _makeDirective('vertical', $rootScope);
});
{'fraction_non_alphanumeric': 0.1796832332058984, 'fraction_numerical': 0.009102494083378846, 'mean_word_length': 3.707797772065124, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3126728', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1844, 'n_words': 341}