<commit_before>/*
 * Paper.js
 *
 * This file is part of Paper.js, a JavaScript Vector Graphics Library,
 * based on Scriptographer.org and designed to be largely API compatible.
 * http://paperjs.org/
 * http://scriptographer.org/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * Copyright (c) 2011, <NAME> & <NAME>
 * http://lehni.org/ & http://jonathanpuckey.com/
 *
 * All rights reserved.
 */

var Tool = this.Tool = ToolHandler.extend(new function() {
	function viewToArtwork(event, document) {
		var point = Event.getOffset(event);
		// TODO: always the active view?
		return document.activeView.viewToArtwork(point);
	};

	return {
		beans: true,

		initialize: function(handlers, doc) {
			this.base(handlers);
			// Create events once, so they can be removed easily too.
			var that = this, curPoint;
			var dragging = false;
			this.events = {
				mousedown: function(event) {
					curPoint = viewToArtwork(event, that._document);
					that.onHandleEvent('mouse-down', curPoint, event);
					if (that.onMouseDown)
						that._document.redraw();
					if (that.eventInterval != null) {
						this.timer = setInterval(that.events.mousemove,
								that.eventInterval);
					}
					dragging = true;
				},

				mousemove: function(event) {
					// If the event was triggered by a touch screen device,
					// prevent the default behaviour, as it will otherwise
					// scroll the page:
					if (event.targetTouches)
						event.preventDefault();
					var point = event && viewToArtwork(event, that._document);
					// If there is only an onMouseMove handler, call it when
					// the user is dragging
					var onlyMove = !!(!that.onMouseDrag && that.onMouseMove);
					if (dragging && !onlyMove) {
						curPoint = point || curPoint;
						if (curPoint)
							that.onHandleEvent('mouse-drag', curPoint, event);
					} else if (!dragging || onlyMove) {
						that.onHandleEvent('mouse-move', point, event);
					}
					if (that.onMouseMove || that.onMouseDrag)
						that._document.redraw();
				},

				mouseup: function(event) {
					if (dragging) {
						curPoint = null;<commit_msg>Tool: check for event first, before checking for event.targetTouches.<commit_after>/*
 * Paper.js
 *
 * This file is part of Paper.js, a JavaScript Vector Graphics Library,
 * based on Scriptographer.org and designed to be largely API compatible.
 * http://paperjs.org/
 * http://scriptographer.org/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * Copyright (c) 2011, <NAME> & <NAME>
 * http://lehni.org/ & http://jonathanpuckey.com/
 *
 * All rights reserved.
 */

var Tool = this.Tool = ToolHandler.extend(new function() {
	function viewToArtwork(event, document) {
		var point = Event.getOffset(event);
		// TODO: always the active view?
		return document.activeView.viewToArtwork(point);
	};

	return {
		beans: true,

		initialize: function(handlers, doc) {
			this.base(handlers);
			// Create events once, so they can be removed easily too.
			var that = this, curPoint;
			var dragging = false;
			this.events = {
				mousedown: function(event) {
					curPoint = viewToArtwork(event, that._document);
					that.onHandleEvent('mouse-down', curPoint, event);
					if (that.onMouseDown)
						that._document.redraw();
					if (that.eventInterval != null) {
						this.timer = setInterval(that.events.mousemove,
								that.eventInterval);
					}
					dragging = true;
				},

				mousemove: function(event) {
					// If the event was triggered by a touch screen device,
					// prevent the default behaviour, as it will otherwise
					// scroll the page:
					if (event && event.targetTouches)
						event.preventDefault();
					var point = event && viewToArtwork(event, that._document);
					// If there is only an onMouseMove handler, call it when
					// the user is dragging
					var onlyMove = !!(!that.onMouseDrag && that.onMouseMove);
					if (dragging && !onlyMove) {
						curPoint = point || curPoint;
						if (curPoint)
							that.onHandleEvent('mouse-drag', curPoint, event);
					} else if (!dragging || onlyMove) {
						that.onHandleEvent('mouse-move', point, event);
					}
					if (that.onMouseMove || that.onMouseDrag)
						that._document.redraw();
				},

				mouseup: function(event) {
					if (dragging) {
						curPoint = null;
{'fraction_non_alphanumeric': 0.12253423067997216, 'fraction_numerical': 0.0018565792527268509, 'mean_word_length': 2.9432753888380603, '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': '7344269', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1288, 'n_words': 376}