<commit_before>/**
 * navigator.js
 *
 * requirements:
 *	 tools.js
 *	 ui.js
 *	 slider.js
 *   stack.js
 */

/**
 */

/**
 * Navigator tool.  Moves the stack around 
 */
function Navigator()
{
	var self = this;
	this.stack = null;

	if ( !ui ) ui = new UI();

	var sliders_box = document.getElementById( "sliders_box" );
	this.input_x = document.getElementById( "x" );		//!< x_input
	this.input_y = document.getElementById( "y" );		//!< y_input

  // Last mouse position for proper zoom with + and -
  var lastX = 0,
      lastY = 0;
	
	/* remove all existing dimension sliders */
	while ( sliders_box.firstChild )
		sliders_box.removeChild( sliders_box.firstChild );
	
	this.slider_z = new Slider(
			SLIDER_HORIZONTAL,
			true,
			1,
			388,
			388,
			1,
			function( val ){ statusBar.replaceLast( "z: " + val ); return; } );
	
	this.slider_s = new Slider(
			SLIDER_HORIZONTAL,
			true,
			undefined,
			undefined,
			new Array(
				0,
				1,
				2,
				4,
				8 ),
			8,
			function( val ){ statusBar.replaceLast( "s: " + val ); } );
	
	var slider_z_box = document.createElement( "div" );
	slider_z_box.className = "box";
	slider_z_box.id = "slider_z_box";
	var slider_z_box_label = document.createElement( "p" );
	slider_z_box_label.appendChild( document.createTextNode( "z-index&nbsp;&nbsp;" ) );
	slider_z_box.appendChild( self.slider_z.getView() );
	slider_z_box.appendChild( self.slider_z.getInputView() );
	
	sliders_box.appendChild( slider_z_box );
	
	var slider_s_view = self.slider_s.getView();
	slider_s_view.id = "slider_s";
	document.getElementById( "slider_s" ).parentNode.replaceChild(
			slider_s_view,
			document.getElementById( "slider_s" ) );
	document.getElementById( "slider_s" ).parentNode.replaceChild(
			self.slider_s.getInputView(),
			slider_s_view.nextSibling );
			
	//! mouse catcher
	this.mouseCatcher = document.createElement( "div" );
	self.mouseCatcher.className = "sliceMouseCatcher";

    this.setMouseCatcher = function( mc )
    {
        self.mouseCatcher = mc;
    }
	
	this.updateControls = function()
	{
		self.slider_s.setByValue( self.stack.s, true );
		self.slider_z.setByValue( self.stack.z, true );

		self.input_x.value = self.stack.x;
		self.input_y.value = self.stack.y;
		
		return;
	}
	
	this.resize = function( width, height )
	{
		self.mouseCatcher.style.width = width + "px";
		self.mouseCatcher.style.height = height + "px";
		return;
	}
	
	this.redraw = function()
	{
		self.updateControls();
	}
	
	var onmousemove = function( e )
	{
		self.lastX = self.stack.x + ui.diffX; // TODO - or + ?
		self.lastY = self.stack.y + ui.diffY;
		self.stack.moveToPixel( self.stack.z,
														self.stack.y - ui.diffY / self.stack.scale,
														self.stack.x - ui.diffX / self.stack.scale,
														self.stack.s );
		self.updateControls();
		return true;
	};
	
	var onmouseup = function( e )
	{
		ui.releaseEvents(); 
		ui.removeEvent( "onmousemove", onmousemove );
		ui.removeEvent( "onmouseup", onmouseup );
		return false;
	};
	
	var onmousedown = function( e )
	{
		ui.registerEvent( "onmousemove", onmousemove );
		ui.registerEvent( "onmouseup", onmouseup );
		ui.catchEvents( "move" );
		ui.onmousedown( e );
		
		ui.catchFocus();
		
		return false;
	};<commit_msg>removed unnecessary updateControls call, the method is already called via Project.moveTo->Tool.redraw<commit_after>/**
 * navigator.js
 *
 * requirements:
 *	 tools.js
 *	 ui.js
 *	 slider.js
 *   stack.js
 */

/**
 */

/**
 * Navigator tool.  Moves the stack around 
 */
function Navigator()
{
	var self = this;
	this.stack = null;

	if ( !ui ) ui = new UI();

	var sliders_box = document.getElementById( "sliders_box" );
	this.input_x = document.getElementById( "x" );		//!< x_input
	this.input_y = document.getElementById( "y" );		//!< y_input

  // Last mouse position for proper zoom with + and -
  var lastX = 0,
      lastY = 0;
	
	/* remove all existing dimension sliders */
	while ( sliders_box.firstChild )
		sliders_box.removeChild( sliders_box.firstChild );
	
	this.slider_z = new Slider(
			SLIDER_HORIZONTAL,
			true,
			1,
			388,
			388,
			1,
			function( val ){ statusBar.replaceLast( "z: " + val ); return; } );
	
	this.slider_s = new Slider(
			SLIDER_HORIZONTAL,
			true,
			undefined,
			undefined,
			new Array(
				0,
				1,
				2,
				4,
				8 ),
			8,
			function( val ){ statusBar.replaceLast( "s: " + val ); } );
	
	var slider_z_box = document.createElement( "div" );
	slider_z_box.className = "box";
	slider_z_box.id = "slider_z_box";
	var slider_z_box_label = document.createElement( "p" );
	slider_z_box_label.appendChild( document.createTextNode( "z-index&nbsp;&nbsp;" ) );
	slider_z_box.appendChild( self.slider_z.getView() );
	slider_z_box.appendChild( self.slider_z.getInputView() );
	
	sliders_box.appendChild( slider_z_box );
	
	var slider_s_view = self.slider_s.getView();
	slider_s_view.id = "slider_s";
	document.getElementById( "slider_s" ).parentNode.replaceChild(
			slider_s_view,
			document.getElementById( "slider_s" ) );
	document.getElementById( "slider_s" ).parentNode.replaceChild(
			self.slider_s.getInputView(),
			slider_s_view.nextSibling );
			
	//! mouse catcher
	this.mouseCatcher = document.createElement( "div" );
	self.mouseCatcher.className = "sliceMouseCatcher";

    this.setMouseCatcher = function( mc )
    {
        self.mouseCatcher = mc;
    }
	
	this.updateControls = function()
	{
		self.slider_s.setByValue( self.stack.s, true );
		self.slider_z.setByValue( self.stack.z, true );

		self.input_x.value = self.stack.x;
		self.input_y.value = self.stack.y;
		
		return;
	}
	
	this.resize = function( width, height )
	{
		self.mouseCatcher.style.width = width + "px";
		self.mouseCatcher.style.height = height + "px";
		return;
	}
	
	this.redraw = function()
	{
		self.updateControls();
	}
	
	var onmousemove = function( e )
	{
		self.lastX = self.stack.x + ui.diffX; // TODO - or + ?
		self.lastY = self.stack.y + ui.diffY;
		self.stack.moveToPixel(
			self.stack.z,
			self.stack.y - ui.diffY / self.stack.scale,
			self.stack.x - ui.diffX / self.stack.scale,
			self.stack.s );
		return true;
	};
	
	var onmouseup = function( e )
	{
		ui.releaseEvents(); 
		ui.removeEvent( "onmousemove", onmousemove );
		ui.removeEvent( "onmouseup", onmouseup );
		return false;
	};
	
	var onmousedown = function( e )
	{
		ui.registerEvent( "onmousemove", onmousemove );
		ui.registerEvent( "onmouseup", onmouseup );
		ui.catchEvents( "move" );
		ui.onmousedown( e );
		
		ui.catchFocus();
		
		return false;
	};
{'fraction_non_alphanumeric': 0.14276932534193945, 'fraction_numerical': 0.0049177808513908095, 'mean_word_length': 3.1825192802056557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '6472327', 'n_tokens_mistral': 2684, 'n_tokens_neox': 2363, 'n_words': 457}