<commit_before>JQueryLens = { 

	defaultParams: function() {
		return {
			locator: "locator",
			thumbnail: "thumbnail",
			lens: "lens",
			zoom: 4
		};
	},

	init: function(params) {
		params = jQuery.extend(this.defaultParams(), params);

		this._zoom = params.zoom;
		this.locator = this.getElement(params.locator);
		this.thumbnail = this.getElement(params.thumbnail);
		this.lens = this.getElement(params.lens);
		this.image = $(this.getIdForImage());

		this.resizeLocator();
		this.resizeThumbnail();
		this.resizeImage();
	},

	getIdForImage: function() {
		return this.getElement(this.lens.attr("id") + " img");
	},

	getElement: function(id) {
		return $("#" + id);
	},

	getBorder : function(element) {
		return parseInt(element.css("border-left-width"));
	},

	moveLocatorAccordingToBorder: function() {
		this.locator.offset({
			top: this.locator.offset().top + 
				 this.getBorder(this.thumbnail),
			left: this.locator.offset().left + 
				  this.getBorder(this.thumbnail)
		});
	},

	moveImageAccordingToBorder: function() {
		this.image.offset({
			top: this.image.offset().top + 
				 this.getBorder(this.lens),
			left: this.image.offset().left + 
				  this.getBorder(this.lens)
		});
	},

	resizeImage: function() {
		this.image.width(this.thumbnail.width() * this._zoom);
		this.image.height(this.thumbnail.height() * this._zoom);
	},

	resizeLocator: function() {
		this.locator.width(this.lens.width() / this._zoom);
		this.locator.height(this.lens.height() / this._zoom);
	},

	resizeThumbnail: function() {
		var imageHeight = this.image.height();
		var imageWidth = this.image.width();
		this.thumbnail.height(this.thumbnail.width() * imageHeight / imageWidth);
	},

	refreshImageInLens: function() {
		this.image.offset({
			top: this.lens.position().top - 
				 (this.getBorder(this.thumbnail) * this._zoom) - 
				 (this.locator.position().top * this._zoom) - 
				 (this.getBorder(this.locator) * this._zoom),
			left: this.lens.position().left - 
				  (this.getBorder(this.thumbnail) * this._zoom) - 
				  (this.locator.position().left * this._zoom) - 
				  (this.getBorder(this.locator) * this._zoom)
		});
	},

	getDifference: function(innerDiv, outerDiv) {
		return {
			vertical: outerDiv.height() - innerDiv.height() - this.getBorder(innerDiv)*2,
			horizontal: outerDiv.width() - innerDiv.width() - this.getBorder(innerDiv)*2,
		};
	},

	getLimits: function(innerDiv, outerDiv) {
		var outerTop = outerDiv.position().top;
		var outerLeft = outerDiv.position().left;
		var difference = this.getDifference(innerDiv, outerDiv);
		return {
			minTop: outerTop,
			maxTop: outerTop + difference.vertical,
			minLeft: outerLeft,
			maxLeft: outerLeft + difference.horizontal
		};
	},

	locatorLimits: function() {
		return this.getLimits(this.locator, this.thumbnail);
	},

	adjust: function(position, limits) {
		if (position.top < limits.minTop)
			position.top = limits.minTop;

		if (position.top > limits.maxTop)
			position.top = limits.maxTop;

		if (position.left < limits.minLeft)
			position.left = limits.minLeft;

		if (position.left > limits.maxLeft)
			position.left = limits.maxLeft;

		return position;
	},

	adjustLocatorPosition: function() {
		var position = {
			top: this.locator.offset().top,
			left: this.locator.offset().left
		};

		var adjustedPosition = this.adjust(position, this.locatorLimits());

		this.locator.offset(adjustedPosition);<commit_msg>Round lens top and left values for eliminating firefox doubles<commit_after>JQueryLens = { 

	defaultParams: function() {
		return {
			locator: "locator",
			thumbnail: "thumbnail",
			lens: "lens",
			zoom: 4
		};
	},

	init: function(params) {
		params = jQuery.extend(this.defaultParams(), params);

		this._zoom = params.zoom;
		this.locator = this.getElement(params.locator);
		this.thumbnail = this.getElement(params.thumbnail);
		this.lens = this.getElement(params.lens);
		this.image = $(this.getIdForImage());

		this.resizeLocator();
		this.resizeThumbnail();
		this.resizeImage();
	},

	getIdForImage: function() {
		return this.getElement(this.lens.attr("id") + " img");
	},

	getElement: function(id) {
		return $("#" + id);
	},

	getBorder : function(element) {
		return parseInt(element.css("border-left-width"));
	},

	moveLocatorAccordingToBorder: function() {
		this.locator.offset({
			top: this.locator.offset().top + 
				 this.getBorder(this.thumbnail),
			left: this.locator.offset().left + 
				  this.getBorder(this.thumbnail)
		});
	},

	moveImageAccordingToBorder: function() {
		this.image.offset({
			top: this.image.offset().top + 
				 this.getBorder(this.lens),
			left: this.image.offset().left + 
				  this.getBorder(this.lens)
		});
	},

	resizeImage: function() {
		this.image.width(this.thumbnail.width() * this._zoom);
		this.image.height(this.thumbnail.height() * this._zoom);
	},

	resizeLocator: function() {
		this.locator.width(this.lens.width() / this._zoom);
		this.locator.height(this.lens.height() / this._zoom);
	},

	resizeThumbnail: function() {
		var imageHeight = this.image.height();
		var imageWidth = this.image.width();
		this.thumbnail.height(this.thumbnail.width() * imageHeight / imageWidth);
	},

	refreshImageInLens: function() {
        var lensTop = Math.ceil(this.lens.position().top);
        var lensLeft = Math.ceil(this.lens.position().left);
		this.image.offset({
			top: lensTop - 
				 (this.getBorder(this.thumbnail) * this._zoom) - 
				 (this.locator.position().top * this._zoom) - 
				 (this.getBorder(this.locator) * this._zoom),
			left: lensLeft  - 
				  (this.getBorder(this.thumbnail) * this._zoom) - 
				  (this.locator.position().left * this._zoom) - 
				  (this.getBorder(this.locator) * this._zoom)
		});
	},

	getDifference: function(innerDiv, outerDiv) {
		return {
			vertical: outerDiv.height() - innerDiv.height() - this.getBorder(innerDiv)*2,
			horizontal: outerDiv.width() - innerDiv.width() - this.getBorder(innerDiv)*2,
		};
	},

	getLimits: function(innerDiv, outerDiv) {
		var outerTop = outerDiv.position().top;
		var outerLeft = outerDiv.position().left;
		var difference = this.getDifference(innerDiv, outerDiv);
		return {
			minTop: outerTop,
			maxTop: outerTop + difference.vertical,
			minLeft: outerLeft,
			maxLeft: outerLeft + difference.horizontal
		};
	},

	locatorLimits: function() {
		return this.getLimits(this.locator, this.thumbnail);
	},

	adjust: function(position, limits) {
		if (position.top < limits.minTop)
			position.top = limits.minTop;

		if (position.top > limits.maxTop)
			position.top = limits.maxTop;

		if (position.left < limits.minLeft)
			position.left = limits.minLeft;

		if (position.left > limits.maxLeft)
			position.left = limits.maxLeft;

		return position;
	},

	adjustLocatorPosition: function() {
		var position = {
			top: Math.ceil(this.locator.offset().top),
			left: Math.ceil(this.locator.offset().left)
		};

		var adjustedPosition = this.adjust(position, this.locatorLimits());

		this.locator.offset(adjustedPosition);
{'fraction_non_alphanumeric': 0.15809033733562036, 'fraction_numerical': 0.0008576329331046312, 'mean_word_length': 3.776109215017065, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '606506', 'n_tokens_mistral': 2665, 'n_tokens_neox': 2331, 'n_words': 378}