1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Hovering over a jquery element calls this method using 'hover':

jQuery.fn.setToolTipPositionAndContent = function() {
	var shift = rota.shifts.find_by_id($(this).data('id'));
	$('#tooltip').css({ top: $(this).offset().top + "px", left: $(this).offset().left + 20 + "px"});
	$('#tooltip div.content').html("<div class='ui-icon ui-icon-triangle-1-w'></div>" + shift.user().userName + ": " + formatTime(shift.start) + " - " + formatTime(shift.end));
	$('#tooltip div.ui-icon').show();
}

// Uses this method

Array.prototype.find_by_id = function(id) { // originally made to find shift in shifts array by id
	for (var i=0; i < this.length; i++) {
		if (this[i].id == id) {
			var found = this[i];
		}
	}
	return found;
}

/* 
But for some reason this is calling all Array.prototype methods in the order they appear in the file?
*/