<commit_before>/* Copyright 2015-2016 Teeming Society. Licensed under the Apache License, Version 2.0 (the "License"); DreemGL is a collaboration between Teeming Society & Samsung Electronics, sponsored by Samsung and others.
   You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
   either express or implied. See the License for the specific language governing permissions and limitations under the License.*/

define.class('$ui/label', function (require, $ui$, view, label) {

	this.text = ''
	this.bgcolor = vec4(1, 1, 1, 0.01)
	this.pickalpha = 0
	this.height = 28

	this.attributes = {
		data: Config({type: Array,  value: wire('this.parent.data')}),
		zoom: Config({type: Number, value: wire('this.parent.zoom')}),
		scroll: wire('this.parent.scroll')
		// hoverid: -1
	}

	this.pointermove = function(event) {
		var eventghost = this.find('eventghost')
		var timeline = this.parent
		eventghost.title = ''
		eventghost.start = timeline.getRangeStart() + timeline.getRange() * (event.min[0] / this.layout.width)
		eventghost.end = timeline.getRangeStart() + timeline.getRange() * (event.max[0] / this.layout.width)
		this.redraw()
	}

	this.pointerend = function(event) {
		var eventghost = this.find('eventghost')
		var timeline = this.parent
		if (abs(event.delta.x) > 2) {
			var eventdata = {
				title: 'New Event',
				date: eventghost.start,
				enddate: eventghost.end,
				metadata: {
					location: {
						name: 'New Location',
						lattitude: 0,
						longitute: 0
					}
				}
			}
			timeline.makeEvent(eventdata)
		}
		eventghost.start = 0
		eventghost.end = 0
	}

	// this.onpointertap = function(event){
	// 	this.hoverid = this.last_pick_id
	// 	var eventData = this.data[this.hoverid]
	// }
	//
	// this.ondata = function (data) {
	// 	this.pickrange = this.data.length
	// }

	define.class(this, 'event', view, function(){

		this.bgcolor = '#999999'
		this.position = 'absolute'
		this.flexdirection = 'row'
		this.cursor = 'move'
		this.justifycontent = "center"
		this.borderradius = 6

		var RESIZE_HANDLE_WIDTH = 10

		this.attributes = {
			title: '',
			id: null,
			zoom: Config({type: Number, value: wire('this.parent.zoom')}),
			scroll: wire('this.parent.scroll'),
			duration: 1,
			offset: 0,
			start: 0,
			end: 0
		}

		var editmode = ''

		var initPointer = function (event) {
			this.cursor = 'move'
			editmode = 'move'

			var localstart = this.globalToLocal(event.position)
			var localstartx = localstart[0] - this.offset * this.layout.width
			var pxduration = this.duration * this.layout.width

			if (localstartx < min(RESIZE_HANDLE_WIDTH, pxduration / 2)) {
				this.cursor = 'ew-resize'
				editmode = 'setstart'
			} else if (pxduration - localstartx < min(RESIZE_HANDLE_WIDTH, pxduration / 2)) {
				this.cursor = 'ew-resize'
				editmode = 'setend'
			}
		}

		this.pointerhover = initPointer
		this.pointerstart = initPointer

		this.pointermove = function(event) {
			var eventghost = this.parent.find('eventghost')
			var timeline = this.parent.parent<commit_msg>Event resize fix.<commit_after>/* Copyright 2015-2016 Teeming Society. Licensed under the Apache License, Version 2.0 (the "License"); DreemGL is a collaboration between Teeming Society & Samsung Electronics, sponsored by Samsung and others.
   You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
   either express or implied. See the License for the specific language governing permissions and limitations under the License.*/

define.class('$ui/label', function (require, $ui$, view, label) {

	this.text = ''
	this.bgcolor = vec4(1, 1, 1, 0.01)
	this.pickalpha = 0
	this.height = 28

	this.attributes = {
		data: Config({type: Array,  value: wire('this.parent.data')}),
		zoom: Config({type: Number, value: wire('this.parent.zoom')}),
		scroll: wire('this.parent.scroll')
		// hoverid: -1
	}

	this.pointermove = function(event) {
		var eventghost = this.find('eventghost')
		var timeline = this.parent
		eventghost.title = ''
		eventghost.start = timeline.getRangeStart() + timeline.getRange() * (event.min[0] / this.layout.width)
		eventghost.end = timeline.getRangeStart() + timeline.getRange() * (event.max[0] / this.layout.width)
		this.redraw()
	}

	this.pointerend = function(event) {
		var eventghost = this.find('eventghost')
		var timeline = this.parent
		if (abs(event.delta.x) > 2) {
			var eventdata = {
				title: 'New Event',
				date: eventghost.start,
				enddate: eventghost.end,
				metadata: {
					location: {
						name: 'New Location',
						lattitude: 0,
						longitute: 0
					}
				}
			}
			timeline.makeEvent(eventdata)
		}
		eventghost.start = 0
		eventghost.end = 0
	}

	// this.onpointertap = function(event){
	// 	this.hoverid = this.last_pick_id
	// 	var eventData = this.data[this.hoverid]
	// }
	//
	// this.ondata = function (data) {
	// 	this.pickrange = this.data.length
	// }

	define.class(this, 'event', view, function(){

		this.bgcolor = '#999999'
		this.position = 'absolute'
		this.flexdirection = 'row'
		this.cursor = 'move'
		this.justifycontent = "center"
		this.borderradius = 6

		var RESIZE_HANDLE_WIDTH = 10

		this.attributes = {
			title: '',
			id: null,
			zoom: Config({type: Number, value: wire('this.parent.zoom')}),
			scroll: wire('this.parent.scroll'),
			duration: 1,
			offset: 0,
			start: 0,
			end: 0
		}

		var editmode = ''

		this.pointerhover = this.pointerstart = function (event) {
			this.cursor = 'move'
			editmode = 'move'

			var localstart = this.globalToLocal(event.position)
			var localstartx = localstart[0] - this.offset * this.layout.width
			var pxduration = this.duration * this.layout.width

			if (localstartx < min(RESIZE_HANDLE_WIDTH, pxduration / 2)) {
				this.cursor = 'ew-resize'
				editmode = 'setstart'
			} else if (pxduration - localstartx < min(RESIZE_HANDLE_WIDTH, pxduration / 2)) {
				this.cursor = 'ew-resize'
				editmode = 'setend'
			}
		}

		this.pointermove = function(event) {
			var eventghost = this.parent.find('eventghost')
			var timeline = this.parent.parent
{'fraction_non_alphanumeric': 0.12981868048148712, 'fraction_numerical': 0.014017979582508, 'mean_word_length': 3.4053691275167783, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5033797', 'n_tokens_mistral': 2499, 'n_tokens_neox': 2140, 'n_words': 569}