web/data/fullcalendar.js
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 17 Feb 2014 14:10:53 +0100
changeset 9552 1358f8ef1b5b
parent 9417 60322cb8636c
permissions -rw-r--r--
[web/basecomponents] remove EtypeRestrictionComponent Closes #3119951
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9417
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
/*!
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
 * FullCalendar v1.6.4
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
 * Docs & License: http://arshaw.com/fullcalendar/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
 * (c) 2013 Adam Shaw
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
 */
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
/*
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
 * Use fullcalendar.css for basic styling.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
 * For event drag & drop, requires jQuery UI draggable.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
 * For event resizing, requires jQuery UI resizable.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
 */
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
(function($, undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    14
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    15
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    16
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    17
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    18
var defaults = {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
	// display
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
	defaultView: 'month',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
	aspectRatio: 1.35,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
	header: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
		left: 'title',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
		center: '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
		right: 'today prev,next'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
	weekends: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
	weekNumbers: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
	weekNumberCalculation: 'iso',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
	weekNumberTitle: 'W',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
	// editing
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
	//editable: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    35
	//disableDragging: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    36
	//disableResizing: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
	allDayDefault: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
	ignoreTimezone: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    40
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
	// event ajax
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
	lazyFetching: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
	startParam: 'start',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
	endParam: 'end',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
	// time formats
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
	titleFormat: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
		month: 'MMMM yyyy',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
		week: "MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
		day: 'dddd, MMM d, yyyy'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
	columnFormat: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
		month: 'ddd',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
		week: 'ddd M/d',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    55
		day: 'dddd M/d'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
	timeFormat: { // for event elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    58
		'': 'h(:mm)t' // default
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    59
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
	// locale
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    62
	isRTL: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    63
	firstDay: 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
	monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
	monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
	dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
	dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    68
	buttonText: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    69
		prev: "<span class='fc-text-arrow'>&lsaquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    70
		next: "<span class='fc-text-arrow'>&rsaquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    71
		prevYear: "<span class='fc-text-arrow'>&laquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    72
		nextYear: "<span class='fc-text-arrow'>&raquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    73
		today: 'today',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    74
		month: 'month',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    75
		week: 'week',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    76
		day: 'day'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    77
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    78
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    79
	// jquery-ui theming
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    80
	theme: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    81
	buttonIcons: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    82
		prev: 'circle-triangle-w',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    83
		next: 'circle-triangle-e'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    84
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    85
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    86
	//selectable: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    87
	unselectAuto: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    88
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    89
	dropAccept: '*',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    90
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    91
	handleWindowResize: true
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    92
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    93
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    94
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    95
// right-to-left defaults
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    96
var rtlDefaults = {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    97
	header: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    98
		left: 'next,prev today',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    99
		center: '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   100
		right: 'title'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   101
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   102
	buttonText: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   103
		prev: "<span class='fc-text-arrow'>&rsaquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   104
		next: "<span class='fc-text-arrow'>&lsaquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   105
		prevYear: "<span class='fc-text-arrow'>&raquo;</span>",
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   106
		nextYear: "<span class='fc-text-arrow'>&laquo;</span>"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   107
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   108
	buttonIcons: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   109
		prev: 'circle-triangle-e',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   110
		next: 'circle-triangle-w'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   111
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   112
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   113
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   114
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   115
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   116
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   117
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   118
var fc = $.fullCalendar = { version: "1.6.4" };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   119
var fcViews = fc.views = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   120
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   121
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   122
$.fn.fullCalendar = function(options) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   123
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   124
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   125
	// method calling
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   126
	if (typeof options == 'string') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   127
		var args = Array.prototype.slice.call(arguments, 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   128
		var res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   129
		this.each(function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   130
			var calendar = $.data(this, 'fullCalendar');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   131
			if (calendar && $.isFunction(calendar[options])) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   132
				var r = calendar[options].apply(calendar, args);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   133
				if (res === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   134
					res = r;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   135
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   136
				if (options == 'destroy') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   137
					$.removeData(this, 'fullCalendar');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   138
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   139
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   140
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   141
		if (res !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   142
			return res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   143
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   144
		return this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   145
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   146
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   147
	options = options || {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   148
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   149
	// would like to have this logic in EventManager, but needs to happen before options are recursively extended
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   150
	var eventSources = options.eventSources || [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   151
	delete options.eventSources;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   152
	if (options.events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   153
		eventSources.push(options.events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   154
		delete options.events;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   155
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   156
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   157
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   158
	options = $.extend(true, {},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   159
		defaults,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   160
		(options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   161
		options
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   162
	);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   163
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   164
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   165
	this.each(function(i, _element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   166
		var element = $(_element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   167
		var calendar = new Calendar(element, options, eventSources);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   168
		element.data('fullCalendar', calendar); // TODO: look into memory leak implications
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   169
		calendar.render();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   170
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   171
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   172
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   173
	return this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   174
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   175
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   176
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   177
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   178
// function for adding/overriding defaults
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   179
function setDefaults(d) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   180
	$.extend(true, defaults, d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   181
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   182
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   183
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   184
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   185
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   186
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   187
 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   188
function Calendar(element, options, eventSources) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   189
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   190
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   191
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   192
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   193
	t.options = options;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   194
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   195
	t.destroy = destroy;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   196
	t.refetchEvents = refetchEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   197
	t.reportEvents = reportEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   198
	t.reportEventChange = reportEventChange;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   199
	t.rerenderEvents = rerenderEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   200
	t.changeView = changeView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   201
	t.select = select;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   202
	t.unselect = unselect;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   203
	t.prev = prev;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   204
	t.next = next;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   205
	t.prevYear = prevYear;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   206
	t.nextYear = nextYear;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   207
	t.today = today;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   208
	t.gotoDate = gotoDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   209
	t.incrementDate = incrementDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   210
	t.formatDate = function(format, date) { return formatDate(format, date, options) };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   211
	t.formatDates = function(format, date1, date2) { return formatDates(format, date1, date2, options) };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   212
	t.getDate = getDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   213
	t.getView = getView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   214
	t.option = option;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   215
	t.trigger = trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   216
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   217
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   218
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   219
	EventManager.call(t, options, eventSources);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   220
	var isFetchNeeded = t.isFetchNeeded;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   221
	var fetchEvents = t.fetchEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   222
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   223
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   224
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   225
	var _element = element[0];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   226
	var header;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   227
	var headerElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   228
	var content;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   229
	var tm; // for making theme classes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   230
	var currentView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   231
	var elementOuterWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   232
	var suggestedViewHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   233
	var resizeUID = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   234
	var ignoreWindowResize = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   235
	var date = new Date();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   236
	var events = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   237
	var _dragElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   238
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   239
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   240
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   241
	/* Main Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   242
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   243
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   244
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   245
	setYMD(date, options.year, options.month, options.date);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   246
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   247
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   248
	function render(inc) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   249
		if (!content) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   250
			initialRender();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   251
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   252
		else if (elementVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   253
			// mainly for the public API
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   254
			calcSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   255
			_renderView(inc);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   256
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   257
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   258
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   259
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   260
	function initialRender() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   261
		tm = options.theme ? 'ui' : 'fc';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   262
		element.addClass('fc');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   263
		if (options.isRTL) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   264
			element.addClass('fc-rtl');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   265
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   266
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   267
			element.addClass('fc-ltr');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   268
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   269
		if (options.theme) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   270
			element.addClass('ui-widget');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   271
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   272
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   273
		content = $("<div class='fc-content' style='position:relative'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   274
			.prependTo(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   275
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   276
		header = new Header(t, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   277
		headerElement = header.render();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   278
		if (headerElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   279
			element.prepend(headerElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   280
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   281
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   282
		changeView(options.defaultView);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   283
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   284
		if (options.handleWindowResize) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   285
			$(window).resize(windowResize);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   286
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   287
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   288
		// needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   289
		if (!bodyVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   290
			lateRender();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   291
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   292
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   293
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   294
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   295
	// called when we know the calendar couldn't be rendered when it was initialized,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   296
	// but we think it's ready now
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   297
	function lateRender() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   298
		setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   299
			if (!currentView.start && bodyVisible()) { // !currentView.start makes sure this never happens more than once
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   300
				renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   301
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   302
		},0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   303
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   304
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   305
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   306
	function destroy() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   307
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   308
		if (currentView) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   309
			trigger('viewDestroy', currentView, currentView, currentView.element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   310
			currentView.triggerEventDestroy();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   311
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   312
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   313
		$(window).unbind('resize', windowResize);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   314
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   315
		header.destroy();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   316
		content.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   317
		element.removeClass('fc fc-rtl ui-widget');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   318
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   319
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   320
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   321
	function elementVisible() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   322
		return element.is(':visible');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   323
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   324
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   325
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   326
	function bodyVisible() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   327
		return $('body').is(':visible');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   328
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   329
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   330
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   331
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   332
	/* View Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   333
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   334
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   335
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   336
	function changeView(newViewName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   337
		if (!currentView || newViewName != currentView.name) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   338
			_changeView(newViewName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   339
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   340
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   341
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   342
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   343
	function _changeView(newViewName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   344
		ignoreWindowResize++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   345
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   346
		if (currentView) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   347
			trigger('viewDestroy', currentView, currentView, currentView.element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   348
			unselect();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   349
			currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   350
			freezeContentHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   351
			currentView.element.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   352
			header.deactivateButton(currentView.name);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   353
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   354
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   355
		header.activateButton(newViewName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   356
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   357
		currentView = new fcViews[newViewName](
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   358
			$("<div class='fc-view fc-view-" + newViewName + "' style='position:relative'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   359
				.appendTo(content),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   360
			t // the calendar object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   361
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   362
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   363
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   364
		unfreezeContentHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   365
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   366
		ignoreWindowResize--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   367
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   368
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   369
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   370
	function renderView(inc) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   371
		if (
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   372
			!currentView.start || // never rendered before
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   373
			inc || date < currentView.start || date >= currentView.end // or new date range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   374
		) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   375
			if (elementVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   376
				_renderView(inc);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   377
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   378
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   379
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   380
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   381
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   382
	function _renderView(inc) { // assumes elementVisible
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   383
		ignoreWindowResize++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   384
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   385
		if (currentView.start) { // already been rendered?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   386
			trigger('viewDestroy', currentView, currentView, currentView.element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   387
			unselect();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   388
			clearEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   389
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   390
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   391
		freezeContentHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   392
		currentView.render(date, inc || 0); // the view's render method ONLY renders the skeleton, nothing else
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   393
		setSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   394
		unfreezeContentHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   395
		(currentView.afterRender || noop)();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   396
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   397
		updateTitle();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   398
		updateTodayButton();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   399
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   400
		trigger('viewRender', currentView, currentView, currentView.element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   401
		currentView.trigger('viewDisplay', _element); // deprecated
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   402
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   403
		ignoreWindowResize--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   404
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   405
		getAndRenderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   406
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   407
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   408
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   409
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   410
	/* Resizing
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   411
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   412
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   413
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   414
	function updateSize() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   415
		if (elementVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   416
			unselect();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   417
			clearEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   418
			calcSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   419
			setSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   420
			renderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   421
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   422
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   423
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   424
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   425
	function calcSize() { // assumes elementVisible
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   426
		if (options.contentHeight) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   427
			suggestedViewHeight = options.contentHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   428
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   429
		else if (options.height) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   430
			suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   431
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   432
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   433
			suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   434
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   435
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   436
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   437
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   438
	function setSize() { // assumes elementVisible
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   439
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   440
		if (suggestedViewHeight === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   441
			calcSize(); // for first time
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   442
				// NOTE: we don't want to recalculate on every renderView because
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   443
				// it could result in oscillating heights due to scrollbars.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   444
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   445
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   446
		ignoreWindowResize++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   447
		currentView.setHeight(suggestedViewHeight);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   448
		currentView.setWidth(content.width());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   449
		ignoreWindowResize--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   450
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   451
		elementOuterWidth = element.outerWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   452
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   453
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   454
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   455
	function windowResize() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   456
		if (!ignoreWindowResize) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   457
			if (currentView.start) { // view has already been rendered
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   458
				var uid = ++resizeUID;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   459
				setTimeout(function() { // add a delay
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   460
					if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   461
						if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   462
							ignoreWindowResize++; // in case the windowResize callback changes the height
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   463
							updateSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   464
							currentView.trigger('windowResize', _element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   465
							ignoreWindowResize--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   466
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   467
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   468
				}, 200);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   469
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   470
				// calendar must have been initialized in a 0x0 iframe that has just been resized
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   471
				lateRender();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   472
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   473
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   474
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   475
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   476
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   477
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   478
	/* Event Fetching/Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   479
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   480
	// TODO: going forward, most of this stuff should be directly handled by the view
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   481
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   482
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   483
	function refetchEvents() { // can be called as an API method
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   484
		clearEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   485
		fetchAndRenderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   486
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   487
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   488
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   489
	function rerenderEvents(modifiedEventID) { // can be called as an API method
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   490
		clearEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   491
		renderEvents(modifiedEventID);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   492
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   493
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   494
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   495
	function renderEvents(modifiedEventID) { // TODO: remove modifiedEventID hack
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   496
		if (elementVisible()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   497
			currentView.setEventData(events); // for View.js, TODO: unify with renderEvents
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   498
			currentView.renderEvents(events, modifiedEventID); // actually render the DOM elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   499
			currentView.trigger('eventAfterAllRender');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   500
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   501
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   502
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   503
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   504
	function clearEvents() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   505
		currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   506
		currentView.clearEvents(); // actually remove the DOM elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   507
		currentView.clearEventData(); // for View.js, TODO: unify with clearEvents
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   508
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   509
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   510
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   511
	function getAndRenderEvents() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   512
		if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   513
			fetchAndRenderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   514
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   515
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   516
			renderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   517
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   518
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   519
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   520
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   521
	function fetchAndRenderEvents() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   522
		fetchEvents(currentView.visStart, currentView.visEnd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   523
			// ... will call reportEvents
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   524
			// ... which will call renderEvents
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   525
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   526
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   527
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   528
	// called when event data arrives
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   529
	function reportEvents(_events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   530
		events = _events;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   531
		renderEvents();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   532
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   533
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   534
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   535
	// called when a single event's data has been changed
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   536
	function reportEventChange(eventID) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   537
		rerenderEvents(eventID);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   538
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   539
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   540
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   541
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   542
	/* Header Updating
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   543
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   544
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   545
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   546
	function updateTitle() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   547
		header.updateTitle(currentView.title);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   548
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   549
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   550
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   551
	function updateTodayButton() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   552
		var today = new Date();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   553
		if (today >= currentView.start && today < currentView.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   554
			header.disableButton('today');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   555
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   556
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   557
			header.enableButton('today');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   558
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   559
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   560
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   561
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   562
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   563
	/* Selection
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   564
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   565
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   566
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   567
	function select(start, end, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   568
		currentView.select(start, end, allDay===undefined ? true : allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   569
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   570
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   571
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   572
	function unselect() { // safe to be called before renderView
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   573
		if (currentView) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   574
			currentView.unselect();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   575
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   576
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   577
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   578
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   579
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   580
	/* Date
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   581
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   582
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   583
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   584
	function prev() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   585
		renderView(-1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   586
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   587
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   588
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   589
	function next() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   590
		renderView(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   591
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   592
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   593
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   594
	function prevYear() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   595
		addYears(date, -1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   596
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   597
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   598
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   599
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   600
	function nextYear() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   601
		addYears(date, 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   602
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   603
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   604
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   605
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   606
	function today() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   607
		date = new Date();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   608
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   609
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   610
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   611
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   612
	function gotoDate(year, month, dateOfMonth) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   613
		if (year instanceof Date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   614
			date = cloneDate(year); // provided 1 argument, a Date
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   615
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   616
			setYMD(date, year, month, dateOfMonth);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   617
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   618
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   619
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   620
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   621
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   622
	function incrementDate(years, months, days) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   623
		if (years !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   624
			addYears(date, years);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   625
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   626
		if (months !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   627
			addMonths(date, months);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   628
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   629
		if (days !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   630
			addDays(date, days);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   631
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   632
		renderView();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   633
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   634
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   635
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   636
	function getDate() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   637
		return cloneDate(date);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   638
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   639
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   640
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   641
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   642
	/* Height "Freezing"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   643
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   644
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   645
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   646
	function freezeContentHeight() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   647
		content.css({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   648
			width: '100%',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   649
			height: content.height(),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   650
			overflow: 'hidden'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   651
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   652
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   653
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   654
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   655
	function unfreezeContentHeight() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   656
		content.css({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   657
			width: '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   658
			height: '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   659
			overflow: ''
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   660
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   661
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   662
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   663
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   664
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   665
	/* Misc
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   666
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   667
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   668
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   669
	function getView() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   670
		return currentView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   671
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   672
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   673
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   674
	function option(name, value) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   675
		if (value === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   676
			return options[name];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   677
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   678
		if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   679
			options[name] = value;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   680
			updateSize();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   681
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   682
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   683
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   684
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   685
	function trigger(name, thisObj) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   686
		if (options[name]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   687
			return options[name].apply(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   688
				thisObj || _element,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   689
				Array.prototype.slice.call(arguments, 2)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   690
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   691
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   692
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   693
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   694
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   695
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   696
	/* External Dragging
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   697
	------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   698
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   699
	if (options.droppable) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   700
		$(document)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   701
			.bind('dragstart', function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   702
				var _e = ev.target;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   703
				var e = $(_e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   704
				if (!e.parents('.fc').length) { // not already inside a calendar
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   705
					var accept = options.dropAccept;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   706
					if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   707
						_dragElement = _e;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   708
						currentView.dragStart(_dragElement, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   709
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   710
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   711
			})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   712
			.bind('dragstop', function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   713
				if (_dragElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   714
					currentView.dragStop(_dragElement, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   715
					_dragElement = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   716
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   717
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   718
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   719
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   720
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   721
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   722
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   723
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   724
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   725
function Header(calendar, options) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   726
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   727
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   728
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   729
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   730
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   731
	t.destroy = destroy;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   732
	t.updateTitle = updateTitle;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   733
	t.activateButton = activateButton;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   734
	t.deactivateButton = deactivateButton;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   735
	t.disableButton = disableButton;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   736
	t.enableButton = enableButton;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   737
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   738
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   739
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   740
	var element = $([]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   741
	var tm;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   742
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   743
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   744
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   745
	function render() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   746
		tm = options.theme ? 'ui' : 'fc';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   747
		var sections = options.header;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   748
		if (sections) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   749
			element = $("<table class='fc-header' style='width:100%'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   750
				.append(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   751
					$("<tr/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   752
						.append(renderSection('left'))
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   753
						.append(renderSection('center'))
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   754
						.append(renderSection('right'))
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   755
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   756
			return element;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   757
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   758
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   759
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   760
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   761
	function destroy() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   762
		element.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   763
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   764
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   765
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   766
	function renderSection(position) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   767
		var e = $("<td class='fc-header-" + position + "'/>");
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   768
		var buttonStr = options.header[position];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   769
		if (buttonStr) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   770
			$.each(buttonStr.split(' '), function(i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   771
				if (i > 0) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   772
					e.append("<span class='fc-header-space'/>");
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   773
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   774
				var prevButton;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   775
				$.each(this.split(','), function(j, buttonName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   776
					if (buttonName == 'title') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   777
						e.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   778
						if (prevButton) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   779
							prevButton.addClass(tm + '-corner-right');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   780
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   781
						prevButton = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   782
					}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   783
						var buttonClick;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   784
						if (calendar[buttonName]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   785
							buttonClick = calendar[buttonName]; // calendar method
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   786
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   787
						else if (fcViews[buttonName]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   788
							buttonClick = function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   789
								button.removeClass(tm + '-state-hover'); // forget why
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   790
								calendar.changeView(buttonName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   791
							};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   792
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   793
						if (buttonClick) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   794
							var icon = options.theme ? smartProperty(options.buttonIcons, buttonName) : null; // why are we using smartProperty here?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   795
							var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   796
							var button = $(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   797
								"<span class='fc-button fc-button-" + buttonName + " " + tm + "-state-default'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   798
									(icon ?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   799
										"<span class='fc-icon-wrap'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   800
											"<span class='ui-icon ui-icon-" + icon + "'/>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   801
										"</span>" :
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   802
										text
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   803
										) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   804
								"</span>"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   805
								)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   806
								.click(function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   807
									if (!button.hasClass(tm + '-state-disabled')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   808
										buttonClick();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   809
									}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   810
								})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   811
								.mousedown(function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   812
									button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   813
										.not('.' + tm + '-state-active')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   814
										.not('.' + tm + '-state-disabled')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   815
										.addClass(tm + '-state-down');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   816
								})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   817
								.mouseup(function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   818
									button.removeClass(tm + '-state-down');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   819
								})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   820
								.hover(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   821
									function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   822
										button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   823
											.not('.' + tm + '-state-active')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   824
											.not('.' + tm + '-state-disabled')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   825
											.addClass(tm + '-state-hover');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   826
									},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   827
									function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   828
										button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   829
											.removeClass(tm + '-state-hover')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   830
											.removeClass(tm + '-state-down');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   831
									}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   832
								)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   833
								.appendTo(e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   834
							disableTextSelection(button);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   835
							if (!prevButton) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   836
								button.addClass(tm + '-corner-left');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   837
							}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   838
							prevButton = button;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   839
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   840
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   841
				});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   842
				if (prevButton) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   843
					prevButton.addClass(tm + '-corner-right');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   844
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   845
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   846
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   847
		return e;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   848
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   849
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   850
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   851
	function updateTitle(html) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   852
		element.find('h2')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   853
			.html(html);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   854
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   855
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   856
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   857
	function activateButton(buttonName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   858
		element.find('span.fc-button-' + buttonName)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   859
			.addClass(tm + '-state-active');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   860
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   861
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   862
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   863
	function deactivateButton(buttonName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   864
		element.find('span.fc-button-' + buttonName)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   865
			.removeClass(tm + '-state-active');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   866
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   867
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   868
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   869
	function disableButton(buttonName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   870
		element.find('span.fc-button-' + buttonName)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   871
			.addClass(tm + '-state-disabled');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   872
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   873
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   874
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   875
	function enableButton(buttonName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   876
		element.find('span.fc-button-' + buttonName)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   877
			.removeClass(tm + '-state-disabled');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   878
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   879
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   880
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   881
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   882
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   883
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   884
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   885
fc.sourceNormalizers = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   886
fc.sourceFetchers = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   887
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   888
var ajaxDefaults = {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   889
	dataType: 'json',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   890
	cache: false
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   891
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   892
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   893
var eventGUID = 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   894
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   895
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   896
function EventManager(options, _sources) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   897
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   898
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   899
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   900
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   901
	t.isFetchNeeded = isFetchNeeded;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   902
	t.fetchEvents = fetchEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   903
	t.addEventSource = addEventSource;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   904
	t.removeEventSource = removeEventSource;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   905
	t.updateEvent = updateEvent;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   906
	t.renderEvent = renderEvent;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   907
	t.removeEvents = removeEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   908
	t.clientEvents = clientEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   909
	t.normalizeEvent = normalizeEvent;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   910
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   911
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   912
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   913
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   914
	var getView = t.getView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   915
	var reportEvents = t.reportEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   916
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   917
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   918
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   919
	var stickySource = { events: [] };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   920
	var sources = [ stickySource ];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   921
	var rangeStart, rangeEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   922
	var currentFetchID = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   923
	var pendingSourceCnt = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   924
	var loadingLevel = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   925
	var cache = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   926
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   927
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   928
	for (var i=0; i<_sources.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   929
		_addEventSource(_sources[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   930
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   931
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   932
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   933
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   934
	/* Fetching
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   935
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   936
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   937
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   938
	function isFetchNeeded(start, end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   939
		return !rangeStart || start < rangeStart || end > rangeEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   940
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   941
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   942
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   943
	function fetchEvents(start, end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   944
		rangeStart = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   945
		rangeEnd = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   946
		cache = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   947
		var fetchID = ++currentFetchID;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   948
		var len = sources.length;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   949
		pendingSourceCnt = len;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   950
		for (var i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   951
			fetchEventSource(sources[i], fetchID);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   952
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   953
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   954
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   955
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   956
	function fetchEventSource(source, fetchID) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   957
		_fetchEventSource(source, function(events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   958
			if (fetchID == currentFetchID) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   959
				if (events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   960
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   961
					if (options.eventDataTransform) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   962
						events = $.map(events, options.eventDataTransform);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   963
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   964
					if (source.eventDataTransform) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   965
						events = $.map(events, source.eventDataTransform);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   966
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   967
					// TODO: this technique is not ideal for static array event sources.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   968
					//  For arrays, we'll want to process all events right in the beginning, then never again.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   969
				
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   970
					for (var i=0; i<events.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   971
						events[i].source = source;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   972
						normalizeEvent(events[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   973
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   974
					cache = cache.concat(events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   975
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   976
				pendingSourceCnt--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   977
				if (!pendingSourceCnt) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   978
					reportEvents(cache);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   979
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   980
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   981
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   982
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   983
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   984
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   985
	function _fetchEventSource(source, callback) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   986
		var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   987
		var fetchers = fc.sourceFetchers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   988
		var res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   989
		for (i=0; i<fetchers.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   990
			res = fetchers[i](source, rangeStart, rangeEnd, callback);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   991
			if (res === true) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   992
				// the fetcher is in charge. made its own async request
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   993
				return;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   994
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   995
			else if (typeof res == 'object') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   996
				// the fetcher returned a new source. process it
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   997
				_fetchEventSource(res, callback);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   998
				return;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   999
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1000
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1001
		var events = source.events;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1002
		if (events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1003
			if ($.isFunction(events)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1004
				pushLoading();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1005
				events(cloneDate(rangeStart), cloneDate(rangeEnd), function(events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1006
					callback(events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1007
					popLoading();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1008
				});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1009
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1010
			else if ($.isArray(events)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1011
				callback(events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1012
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1013
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1014
				callback();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1015
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1016
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1017
			var url = source.url;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1018
			if (url) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1019
				var success = source.success;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1020
				var error = source.error;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1021
				var complete = source.complete;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1022
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1023
				// retrieve any outbound GET/POST $.ajax data from the options
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1024
				var customData;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1025
				if ($.isFunction(source.data)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1026
					// supplied as a function that returns a key/value object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1027
					customData = source.data();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1028
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1029
				else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1030
					// supplied as a straight key/value object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1031
					customData = source.data;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1032
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1033
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1034
				// use a copy of the custom data so we can modify the parameters
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1035
				// and not affect the passed-in object.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1036
				var data = $.extend({}, customData || {});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1037
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1038
				var startParam = firstDefined(source.startParam, options.startParam);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1039
				var endParam = firstDefined(source.endParam, options.endParam);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1040
				if (startParam) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1041
					data[startParam] = Math.round(+rangeStart / 1000);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1042
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1043
				if (endParam) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1044
					data[endParam] = Math.round(+rangeEnd / 1000);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1045
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1046
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1047
				pushLoading();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1048
				$.ajax($.extend({}, ajaxDefaults, source, {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1049
					data: data,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1050
					success: function(events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1051
						events = events || [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1052
						var res = applyAll(success, this, arguments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1053
						if ($.isArray(res)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1054
							events = res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1055
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1056
						callback(events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1057
					},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1058
					error: function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1059
						applyAll(error, this, arguments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1060
						callback();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1061
					},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1062
					complete: function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1063
						applyAll(complete, this, arguments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1064
						popLoading();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1065
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1066
				}));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1067
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1068
				callback();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1069
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1070
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1071
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1072
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1073
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1074
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1075
	/* Sources
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1076
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1077
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1078
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1079
	function addEventSource(source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1080
		source = _addEventSource(source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1081
		if (source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1082
			pendingSourceCnt++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1083
			fetchEventSource(source, currentFetchID); // will eventually call reportEvents
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1084
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1085
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1086
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1087
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1088
	function _addEventSource(source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1089
		if ($.isFunction(source) || $.isArray(source)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1090
			source = { events: source };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1091
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1092
		else if (typeof source == 'string') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1093
			source = { url: source };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1094
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1095
		if (typeof source == 'object') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1096
			normalizeSource(source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1097
			sources.push(source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1098
			return source;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1099
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1100
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1101
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1102
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1103
	function removeEventSource(source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1104
		sources = $.grep(sources, function(src) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1105
			return !isSourcesEqual(src, source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1106
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1107
		// remove all client events from that source
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1108
		cache = $.grep(cache, function(e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1109
			return !isSourcesEqual(e.source, source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1110
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1111
		reportEvents(cache);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1112
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1113
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1114
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1115
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1116
	/* Manipulation
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1117
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1118
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1119
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1120
	function updateEvent(event) { // update an existing event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1121
		var i, len = cache.length, e,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1122
			defaultEventEnd = getView().defaultEventEnd, // getView???
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1123
			startDelta = event.start - event._start,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1124
			endDelta = event.end ?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1125
				(event.end - (event._end || defaultEventEnd(event))) // event._end would be null if event.end
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1126
				: 0;                                                      // was null and event was just resized
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1127
		for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1128
			e = cache[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1129
			if (e._id == event._id && e != event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1130
				e.start = new Date(+e.start + startDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1131
				if (event.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1132
					if (e.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1133
						e.end = new Date(+e.end + endDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1134
					}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1135
						e.end = new Date(+defaultEventEnd(e) + endDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1136
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1137
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1138
					e.end = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1139
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1140
				e.title = event.title;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1141
				e.url = event.url;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1142
				e.allDay = event.allDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1143
				e.className = event.className;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1144
				e.editable = event.editable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1145
				e.color = event.color;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1146
				e.backgroundColor = event.backgroundColor;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1147
				e.borderColor = event.borderColor;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1148
				e.textColor = event.textColor;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1149
				normalizeEvent(e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1150
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1151
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1152
		normalizeEvent(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1153
		reportEvents(cache);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1154
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1155
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1156
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1157
	function renderEvent(event, stick) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1158
		normalizeEvent(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1159
		if (!event.source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1160
			if (stick) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1161
				stickySource.events.push(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1162
				event.source = stickySource;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1163
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1164
			cache.push(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1165
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1166
		reportEvents(cache);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1167
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1168
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1169
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1170
	function removeEvents(filter) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1171
		if (!filter) { // remove all
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1172
			cache = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1173
			// clear all array sources
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1174
			for (var i=0; i<sources.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1175
				if ($.isArray(sources[i].events)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1176
					sources[i].events = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1177
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1178
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1179
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1180
			if (!$.isFunction(filter)) { // an event ID
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1181
				var id = filter + '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1182
				filter = function(e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1183
					return e._id == id;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1184
				};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1185
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1186
			cache = $.grep(cache, filter, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1187
			// remove events from array sources
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1188
			for (var i=0; i<sources.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1189
				if ($.isArray(sources[i].events)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1190
					sources[i].events = $.grep(sources[i].events, filter, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1191
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1192
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1193
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1194
		reportEvents(cache);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1195
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1196
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1197
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1198
	function clientEvents(filter) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1199
		if ($.isFunction(filter)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1200
			return $.grep(cache, filter);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1201
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1202
		else if (filter) { // an event ID
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1203
			filter += '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1204
			return $.grep(cache, function(e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1205
				return e._id == filter;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1206
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1207
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1208
		return cache; // else, return all
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1209
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1210
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1211
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1212
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1213
	/* Loading State
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1214
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1215
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1216
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1217
	function pushLoading() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1218
		if (!loadingLevel++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1219
			trigger('loading', null, true, getView());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1220
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1221
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1222
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1223
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1224
	function popLoading() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1225
		if (!--loadingLevel) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1226
			trigger('loading', null, false, getView());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1227
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1228
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1229
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1230
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1231
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1232
	/* Event Normalization
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1233
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1234
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1235
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1236
	function normalizeEvent(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1237
		var source = event.source || {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1238
		var ignoreTimezone = firstDefined(source.ignoreTimezone, options.ignoreTimezone);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1239
		event._id = event._id || (event.id === undefined ? '_fc' + eventGUID++ : event.id + '');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1240
		if (event.date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1241
			if (!event.start) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1242
				event.start = event.date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1243
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1244
			delete event.date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1245
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1246
		event._start = cloneDate(event.start = parseDate(event.start, ignoreTimezone));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1247
		event.end = parseDate(event.end, ignoreTimezone);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1248
		if (event.end && event.end <= event.start) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1249
			event.end = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1250
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1251
		event._end = event.end ? cloneDate(event.end) : null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1252
		if (event.allDay === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1253
			event.allDay = firstDefined(source.allDayDefault, options.allDayDefault);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1254
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1255
		if (event.className) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1256
			if (typeof event.className == 'string') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1257
				event.className = event.className.split(/\s+/);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1258
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1259
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1260
			event.className = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1261
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1262
		// TODO: if there is no start date, return false to indicate an invalid event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1263
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1264
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1265
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1266
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1267
	/* Utils
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1268
	------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1269
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1270
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1271
	function normalizeSource(source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1272
		if (source.className) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1273
			// TODO: repeat code, same code for event classNames
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1274
			if (typeof source.className == 'string') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1275
				source.className = source.className.split(/\s+/);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1276
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1277
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1278
			source.className = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1279
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1280
		var normalizers = fc.sourceNormalizers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1281
		for (var i=0; i<normalizers.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1282
			normalizers[i](source);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1283
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1284
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1285
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1286
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1287
	function isSourcesEqual(source1, source2) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1288
		return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1289
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1290
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1291
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1292
	function getSourcePrimitive(source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1293
		return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1294
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1295
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1296
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1297
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1298
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1299
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1300
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1301
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1302
fc.addDays = addDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1303
fc.cloneDate = cloneDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1304
fc.parseDate = parseDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1305
fc.parseISO8601 = parseISO8601;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1306
fc.parseTime = parseTime;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1307
fc.formatDate = formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1308
fc.formatDates = formatDates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1309
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1310
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1311
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1312
/* Date Math
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1313
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1314
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1315
var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1316
	DAY_MS = 86400000,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1317
	HOUR_MS = 3600000,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1318
	MINUTE_MS = 60000;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1319
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1320
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1321
function addYears(d, n, keepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1322
	d.setFullYear(d.getFullYear() + n);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1323
	if (!keepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1324
		clearTime(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1325
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1326
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1327
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1328
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1329
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1330
function addMonths(d, n, keepTime) { // prevents day overflow/underflow
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1331
	if (+d) { // prevent infinite looping on invalid dates
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1332
		var m = d.getMonth() + n,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1333
			check = cloneDate(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1334
		check.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1335
		check.setMonth(m);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1336
		d.setMonth(m);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1337
		if (!keepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1338
			clearTime(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1339
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1340
		while (d.getMonth() != check.getMonth()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1341
			d.setDate(d.getDate() + (d < check ? 1 : -1));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1342
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1343
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1344
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1345
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1346
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1347
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1348
function addDays(d, n, keepTime) { // deals with daylight savings
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1349
	if (+d) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1350
		var dd = d.getDate() + n,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1351
			check = cloneDate(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1352
		check.setHours(9); // set to middle of day
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1353
		check.setDate(dd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1354
		d.setDate(dd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1355
		if (!keepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1356
			clearTime(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1357
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1358
		fixDate(d, check);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1359
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1360
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1361
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1362
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1363
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1364
function fixDate(d, check) { // force d to be on check's YMD, for daylight savings purposes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1365
	if (+d) { // prevent infinite looping on invalid dates
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1366
		while (d.getDate() != check.getDate()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1367
			d.setTime(+d + (d < check ? 1 : -1) * HOUR_MS);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1368
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1369
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1370
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1371
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1372
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1373
function addMinutes(d, n) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1374
	d.setMinutes(d.getMinutes() + n);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1375
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1376
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1377
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1378
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1379
function clearTime(d) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1380
	d.setHours(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1381
	d.setMinutes(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1382
	d.setSeconds(0); 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1383
	d.setMilliseconds(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1384
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1385
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1386
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1387
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1388
function cloneDate(d, dontKeepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1389
	if (dontKeepTime) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1390
		return clearTime(new Date(+d));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1391
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1392
	return new Date(+d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1393
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1394
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1395
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1396
function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1397
	var i=0, d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1398
	do {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1399
		d = new Date(1970, i++, 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1400
	} while (d.getHours()); // != 0
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1401
	return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1402
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1403
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1404
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1405
function dayDiff(d1, d2) { // d1 - d2
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1406
	return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1407
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1408
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1409
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1410
function setYMD(date, y, m, d) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1411
	if (y !== undefined && y != date.getFullYear()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1412
		date.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1413
		date.setMonth(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1414
		date.setFullYear(y);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1415
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1416
	if (m !== undefined && m != date.getMonth()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1417
		date.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1418
		date.setMonth(m);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1419
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1420
	if (d !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1421
		date.setDate(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1422
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1423
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1424
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1425
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1426
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1427
/* Date Parsing
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1428
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1429
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1430
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1431
function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1432
	if (typeof s == 'object') { // already a Date object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1433
		return s;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1434
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1435
	if (typeof s == 'number') { // a UNIX timestamp
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1436
		return new Date(s * 1000);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1437
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1438
	if (typeof s == 'string') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1439
		if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1440
			return new Date(parseFloat(s) * 1000);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1441
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1442
		if (ignoreTimezone === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1443
			ignoreTimezone = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1444
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1445
		return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1446
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1447
	// TODO: never return invalid dates (like from new Date(<string>)), return null instead
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1448
	return null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1449
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1450
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1451
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1452
function parseISO8601(s, ignoreTimezone) { // ignoreTimezone defaults to false
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1453
	// derived from http://delete.me.uk/2005/03/iso8601.html
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1454
	// TODO: for a know glitch/feature, read tests/issue_206_parseDate_dst.html
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1455
	var m = s.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1456
	if (!m) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1457
		return null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1458
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1459
	var date = new Date(m[1], 0, 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1460
	if (ignoreTimezone || !m[13]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1461
		var check = new Date(m[1], 0, 1, 9, 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1462
		if (m[3]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1463
			date.setMonth(m[3] - 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1464
			check.setMonth(m[3] - 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1465
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1466
		if (m[5]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1467
			date.setDate(m[5]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1468
			check.setDate(m[5]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1469
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1470
		fixDate(date, check);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1471
		if (m[7]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1472
			date.setHours(m[7]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1473
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1474
		if (m[8]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1475
			date.setMinutes(m[8]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1476
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1477
		if (m[10]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1478
			date.setSeconds(m[10]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1479
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1480
		if (m[12]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1481
			date.setMilliseconds(Number("0." + m[12]) * 1000);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1482
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1483
		fixDate(date, check);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1484
	}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1485
		date.setUTCFullYear(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1486
			m[1],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1487
			m[3] ? m[3] - 1 : 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1488
			m[5] || 1
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1489
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1490
		date.setUTCHours(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1491
			m[7] || 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1492
			m[8] || 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1493
			m[10] || 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1494
			m[12] ? Number("0." + m[12]) * 1000 : 0
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1495
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1496
		if (m[14]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1497
			var offset = Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1498
			offset *= m[15] == '-' ? 1 : -1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1499
			date = new Date(+date + (offset * 60 * 1000));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1500
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1501
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1502
	return date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1503
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1504
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1505
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1506
function parseTime(s) { // returns minutes since start of day
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1507
	if (typeof s == 'number') { // an hour
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1508
		return s * 60;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1509
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1510
	if (typeof s == 'object') { // a Date object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1511
		return s.getHours() * 60 + s.getMinutes();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1512
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1513
	var m = s.match(/(\d+)(?::(\d+))?\s*(\w+)?/);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1514
	if (m) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1515
		var h = parseInt(m[1], 10);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1516
		if (m[3]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1517
			h %= 12;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1518
			if (m[3].toLowerCase().charAt(0) == 'p') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1519
				h += 12;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1520
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1521
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1522
		return h * 60 + (m[2] ? parseInt(m[2], 10) : 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1523
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1524
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1525
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1526
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1527
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1528
/* Date Formatting
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1529
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1530
// TODO: use same function formatDate(date, [date2], format, [options])
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1531
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1532
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1533
function formatDate(date, format, options) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1534
	return formatDates(date, null, format, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1535
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1536
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1537
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1538
function formatDates(date1, date2, format, options) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1539
	options = options || defaults;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1540
	var date = date1,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1541
		otherDate = date2,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1542
		i, len = format.length, c,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1543
		i2, formatter,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1544
		res = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1545
	for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1546
		c = format.charAt(i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1547
		if (c == "'") {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1548
			for (i2=i+1; i2<len; i2++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1549
				if (format.charAt(i2) == "'") {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1550
					if (date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1551
						if (i2 == i+1) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1552
							res += "'";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1553
						}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1554
							res += format.substring(i+1, i2);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1555
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1556
						i = i2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1557
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1558
					break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1559
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1560
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1561
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1562
		else if (c == '(') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1563
			for (i2=i+1; i2<len; i2++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1564
				if (format.charAt(i2) == ')') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1565
					var subres = formatDate(date, format.substring(i+1, i2), options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1566
					if (parseInt(subres.replace(/\D/, ''), 10)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1567
						res += subres;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1568
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1569
					i = i2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1570
					break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1571
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1572
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1573
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1574
		else if (c == '[') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1575
			for (i2=i+1; i2<len; i2++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1576
				if (format.charAt(i2) == ']') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1577
					var subformat = format.substring(i+1, i2);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1578
					var subres = formatDate(date, subformat, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1579
					if (subres != formatDate(otherDate, subformat, options)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1580
						res += subres;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1581
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1582
					i = i2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1583
					break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1584
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1585
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1586
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1587
		else if (c == '{') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1588
			date = date2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1589
			otherDate = date1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1590
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1591
		else if (c == '}') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1592
			date = date1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1593
			otherDate = date2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1594
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1595
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1596
			for (i2=len; i2>i; i2--) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1597
				if (formatter = dateFormatters[format.substring(i, i2)]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1598
					if (date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1599
						res += formatter(date, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1600
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1601
					i = i2 - 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1602
					break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1603
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1604
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1605
			if (i2 == i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1606
				if (date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1607
					res += c;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1608
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1609
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1610
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1611
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1612
	return res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1613
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1614
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1615
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1616
var dateFormatters = {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1617
	s	: function(d)	{ return d.getSeconds() },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1618
	ss	: function(d)	{ return zeroPad(d.getSeconds()) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1619
	m	: function(d)	{ return d.getMinutes() },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1620
	mm	: function(d)	{ return zeroPad(d.getMinutes()) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1621
	h	: function(d)	{ return d.getHours() % 12 || 12 },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1622
	hh	: function(d)	{ return zeroPad(d.getHours() % 12 || 12) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1623
	H	: function(d)	{ return d.getHours() },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1624
	HH	: function(d)	{ return zeroPad(d.getHours()) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1625
	d	: function(d)	{ return d.getDate() },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1626
	dd	: function(d)	{ return zeroPad(d.getDate()) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1627
	ddd	: function(d,o)	{ return o.dayNamesShort[d.getDay()] },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1628
	dddd: function(d,o)	{ return o.dayNames[d.getDay()] },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1629
	M	: function(d)	{ return d.getMonth() + 1 },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1630
	MM	: function(d)	{ return zeroPad(d.getMonth() + 1) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1631
	MMM	: function(d,o)	{ return o.monthNamesShort[d.getMonth()] },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1632
	MMMM: function(d,o)	{ return o.monthNames[d.getMonth()] },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1633
	yy	: function(d)	{ return (d.getFullYear()+'').substring(2) },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1634
	yyyy: function(d)	{ return d.getFullYear() },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1635
	t	: function(d)	{ return d.getHours() < 12 ? 'a' : 'p' },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1636
	tt	: function(d)	{ return d.getHours() < 12 ? 'am' : 'pm' },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1637
	T	: function(d)	{ return d.getHours() < 12 ? 'A' : 'P' },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1638
	TT	: function(d)	{ return d.getHours() < 12 ? 'AM' : 'PM' },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1639
	u	: function(d)	{ return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") },
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1640
	S	: function(d)	{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1641
		var date = d.getDate();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1642
		if (date > 10 && date < 20) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1643
			return 'th';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1644
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1645
		return ['st', 'nd', 'rd'][date%10-1] || 'th';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1646
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1647
	w   : function(d, o) { // local
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1648
		return o.weekNumberCalculation(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1649
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1650
	W   : function(d) { // ISO
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1651
		return iso8601Week(d);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1652
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1653
};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1654
fc.dateFormatters = dateFormatters;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1655
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1656
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1657
/* thanks jQuery UI (https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1658
 * 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1659
 * Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1660
 * `date` - the date to get the week for
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1661
 * `number` - the number of the week within the year that contains this date
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1662
 */
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1663
function iso8601Week(date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1664
	var time;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1665
	var checkDate = new Date(date.getTime());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1666
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1667
	// Find Thursday of this week starting on Monday
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1668
	checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1669
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1670
	time = checkDate.getTime();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1671
	checkDate.setMonth(0); // Compare with Jan 1
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1672
	checkDate.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1673
	return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1674
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1675
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1676
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1677
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1678
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1679
fc.applyAll = applyAll;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1680
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1681
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1682
/* Event Date Math
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1683
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1684
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1685
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1686
function exclEndDay(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1687
	if (event.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1688
		return _exclEndDay(event.end, event.allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1689
	}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1690
		return addDays(cloneDate(event.start), 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1691
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1692
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1693
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1694
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1695
function _exclEndDay(end, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1696
	end = cloneDate(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1697
	return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1698
	// why don't we check for seconds/ms too?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1699
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1700
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1701
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1702
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1703
/* Event Element Binding
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1704
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1705
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1706
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1707
function lazySegBind(container, segs, bindHandlers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1708
	container.unbind('mouseover').mouseover(function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1709
		var parent=ev.target, e,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1710
			i, seg;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1711
		while (parent != this) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1712
			e = parent;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1713
			parent = parent.parentNode;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1714
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1715
		if ((i = e._fci) !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1716
			e._fci = undefined;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1717
			seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1718
			bindHandlers(seg.event, seg.element, seg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1719
			$(ev.target).trigger(ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1720
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1721
		ev.stopPropagation();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1722
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1723
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1724
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1725
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1726
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1727
/* Element Dimensions
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1728
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1729
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1730
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1731
function setOuterWidth(element, width, includeMargins) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1732
	for (var i=0, e; i<element.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1733
		e = $(element[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1734
		e.width(Math.max(0, width - hsides(e, includeMargins)));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1735
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1736
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1737
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1738
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1739
function setOuterHeight(element, height, includeMargins) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1740
	for (var i=0, e; i<element.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1741
		e = $(element[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1742
		e.height(Math.max(0, height - vsides(e, includeMargins)));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1743
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1744
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1745
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1746
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1747
function hsides(element, includeMargins) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1748
	return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1749
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1750
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1751
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1752
function hpadding(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1753
	return (parseFloat($.css(element[0], 'paddingLeft', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1754
	       (parseFloat($.css(element[0], 'paddingRight', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1755
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1756
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1757
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1758
function hmargins(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1759
	return (parseFloat($.css(element[0], 'marginLeft', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1760
	       (parseFloat($.css(element[0], 'marginRight', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1761
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1762
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1763
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1764
function hborders(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1765
	return (parseFloat($.css(element[0], 'borderLeftWidth', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1766
	       (parseFloat($.css(element[0], 'borderRightWidth', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1767
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1768
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1769
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1770
function vsides(element, includeMargins) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1771
	return vpadding(element) +  vborders(element) + (includeMargins ? vmargins(element) : 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1772
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1773
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1774
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1775
function vpadding(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1776
	return (parseFloat($.css(element[0], 'paddingTop', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1777
	       (parseFloat($.css(element[0], 'paddingBottom', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1778
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1779
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1780
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1781
function vmargins(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1782
	return (parseFloat($.css(element[0], 'marginTop', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1783
	       (parseFloat($.css(element[0], 'marginBottom', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1784
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1785
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1786
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1787
function vborders(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1788
	return (parseFloat($.css(element[0], 'borderTopWidth', true)) || 0) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1789
	       (parseFloat($.css(element[0], 'borderBottomWidth', true)) || 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1790
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1791
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1792
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1793
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1794
/* Misc Utils
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1795
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1796
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1797
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1798
//TODO: arraySlice
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1799
//TODO: isFunction, grep ?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1800
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1801
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1802
function noop() { }
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1803
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1804
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1805
function dateCompare(a, b) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1806
	return a - b;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1807
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1808
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1809
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1810
function arrayMax(a) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1811
	return Math.max.apply(Math, a);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1812
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1813
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1814
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1815
function zeroPad(n) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1816
	return (n < 10 ? '0' : '') + n;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1817
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1818
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1819
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1820
function smartProperty(obj, name) { // get a camel-cased/namespaced property of an object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1821
	if (obj[name] !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1822
		return obj[name];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1823
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1824
	var parts = name.split(/(?=[A-Z])/),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1825
		i=parts.length-1, res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1826
	for (; i>=0; i--) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1827
		res = obj[parts[i].toLowerCase()];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1828
		if (res !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1829
			return res;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1830
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1831
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1832
	return obj[''];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1833
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1834
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1835
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1836
function htmlEscape(s) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1837
	return s.replace(/&/g, '&amp;')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1838
		.replace(/</g, '&lt;')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1839
		.replace(/>/g, '&gt;')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1840
		.replace(/'/g, '&#039;')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1841
		.replace(/"/g, '&quot;')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1842
		.replace(/\n/g, '<br />');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1843
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1844
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1845
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1846
function disableTextSelection(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1847
	element
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1848
		.attr('unselectable', 'on')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1849
		.css('MozUserSelect', 'none')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1850
		.bind('selectstart.ui', function() { return false; });
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1851
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1852
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1853
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1854
/*
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1855
function enableTextSelection(element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1856
	element
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1857
		.attr('unselectable', 'off')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1858
		.css('MozUserSelect', '')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1859
		.unbind('selectstart.ui');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1860
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1861
*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1862
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1863
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1864
function markFirstLast(e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1865
	e.children()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1866
		.removeClass('fc-first fc-last')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1867
		.filter(':first-child')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1868
			.addClass('fc-first')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1869
		.end()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1870
		.filter(':last-child')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1871
			.addClass('fc-last');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1872
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1873
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1874
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1875
function setDayID(cell, date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1876
	cell.each(function(i, _cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1877
		_cell.className = _cell.className.replace(/^fc-\w*/, 'fc-' + dayIDs[date.getDay()]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1878
		// TODO: make a way that doesn't rely on order of classes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1879
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1880
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1881
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1882
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1883
function getSkinCss(event, opt) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1884
	var source = event.source || {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1885
	var eventColor = event.color;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1886
	var sourceColor = source.color;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1887
	var optionColor = opt('eventColor');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1888
	var backgroundColor =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1889
		event.backgroundColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1890
		eventColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1891
		source.backgroundColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1892
		sourceColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1893
		opt('eventBackgroundColor') ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1894
		optionColor;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1895
	var borderColor =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1896
		event.borderColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1897
		eventColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1898
		source.borderColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1899
		sourceColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1900
		opt('eventBorderColor') ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1901
		optionColor;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1902
	var textColor =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1903
		event.textColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1904
		source.textColor ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1905
		opt('eventTextColor');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1906
	var statements = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1907
	if (backgroundColor) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1908
		statements.push('background-color:' + backgroundColor);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1909
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1910
	if (borderColor) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1911
		statements.push('border-color:' + borderColor);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1912
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1913
	if (textColor) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1914
		statements.push('color:' + textColor);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1915
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1916
	return statements.join(';');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1917
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1918
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1919
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1920
function applyAll(functions, thisObj, args) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1921
	if ($.isFunction(functions)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1922
		functions = [ functions ];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1923
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1924
	if (functions) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1925
		var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1926
		var ret;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1927
		for (i=0; i<functions.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1928
			ret = functions[i].apply(thisObj, args) || ret;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1929
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1930
		return ret;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1931
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1932
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1933
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1934
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1935
function firstDefined() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1936
	for (var i=0; i<arguments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1937
		if (arguments[i] !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1938
			return arguments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1939
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1940
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1941
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1942
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1943
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1944
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1945
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1946
fcViews.month = MonthView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1947
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1948
function MonthView(element, calendar) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1949
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1950
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1951
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1952
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1953
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1954
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1955
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1956
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1957
	BasicView.call(t, element, calendar, 'month');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1958
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1959
	var renderBasic = t.renderBasic;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1960
	var skipHiddenDays = t.skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1961
	var getCellsPerWeek = t.getCellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1962
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1963
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1964
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1965
	function render(date, delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1966
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1967
		if (delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1968
			addMonths(date, delta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1969
			date.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1970
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1971
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1972
		var firstDay = opt('firstDay');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1973
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1974
		var start = cloneDate(date, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1975
		start.setDate(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1976
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1977
		var end = addMonths(cloneDate(start), 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1978
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1979
		var visStart = cloneDate(start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1980
		addDays(visStart, -((visStart.getDay() - firstDay + 7) % 7));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1981
		skipHiddenDays(visStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1982
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1983
		var visEnd = cloneDate(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1984
		addDays(visEnd, (7 - visEnd.getDay() + firstDay) % 7);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1985
		skipHiddenDays(visEnd, -1, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1986
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1987
		var colCnt = getCellsPerWeek();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1988
		var rowCnt = Math.round(dayDiff(visEnd, visStart) / 7); // should be no need for Math.round
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1989
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1990
		if (opt('weekMode') == 'fixed') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1991
			addDays(visEnd, (6 - rowCnt) * 7); // add weeks to make up for it
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1992
			rowCnt = 6;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1993
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1994
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1995
		t.title = formatDate(start, opt('titleFormat'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1996
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1997
		t.start = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1998
		t.end = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  1999
		t.visStart = visStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2000
		t.visEnd = visEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2001
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2002
		renderBasic(rowCnt, colCnt, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2003
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2004
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2005
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2006
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2007
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2008
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2009
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2010
fcViews.basicWeek = BasicWeekView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2011
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2012
function BasicWeekView(element, calendar) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2013
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2014
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2015
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2016
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2017
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2018
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2019
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2020
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2021
	BasicView.call(t, element, calendar, 'basicWeek');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2022
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2023
	var renderBasic = t.renderBasic;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2024
	var skipHiddenDays = t.skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2025
	var getCellsPerWeek = t.getCellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2026
	var formatDates = calendar.formatDates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2027
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2028
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2029
	function render(date, delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2030
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2031
		if (delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2032
			addDays(date, delta * 7);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2033
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2034
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2035
		var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2036
		var end = addDays(cloneDate(start), 7);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2037
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2038
		var visStart = cloneDate(start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2039
		skipHiddenDays(visStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2040
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2041
		var visEnd = cloneDate(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2042
		skipHiddenDays(visEnd, -1, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2043
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2044
		var colCnt = getCellsPerWeek();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2045
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2046
		t.start = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2047
		t.end = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2048
		t.visStart = visStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2049
		t.visEnd = visEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2050
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2051
		t.title = formatDates(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2052
			visStart,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2053
			addDays(cloneDate(visEnd), -1),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2054
			opt('titleFormat')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2055
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2056
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2057
		renderBasic(1, colCnt, false);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2058
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2059
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2060
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2061
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2062
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2063
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2064
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2065
fcViews.basicDay = BasicDayView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2066
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2067
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2068
function BasicDayView(element, calendar) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2069
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2070
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2071
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2072
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2073
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2074
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2075
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2076
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2077
	BasicView.call(t, element, calendar, 'basicDay');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2078
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2079
	var renderBasic = t.renderBasic;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2080
	var skipHiddenDays = t.skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2081
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2082
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2083
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2084
	function render(date, delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2085
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2086
		if (delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2087
			addDays(date, delta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2088
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2089
		skipHiddenDays(date, delta < 0 ? -1 : 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2090
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2091
		var start = cloneDate(date, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2092
		var end = addDays(cloneDate(start), 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2093
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2094
		t.title = formatDate(date, opt('titleFormat'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2095
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2096
		t.start = t.visStart = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2097
		t.end = t.visEnd = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2098
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2099
		renderBasic(1, 1, false);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2100
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2101
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2102
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2103
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2104
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2105
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2106
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2107
setDefaults({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2108
	weekMode: 'fixed'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2109
});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2110
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2111
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2112
function BasicView(element, calendar, viewName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2113
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2114
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2115
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2116
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2117
	t.renderBasic = renderBasic;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2118
	t.setHeight = setHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2119
	t.setWidth = setWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2120
	t.renderDayOverlay = renderDayOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2121
	t.defaultSelectionEnd = defaultSelectionEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2122
	t.renderSelection = renderSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2123
	t.clearSelection = clearSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2124
	t.reportDayClick = reportDayClick; // for selection (kinda hacky)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2125
	t.dragStart = dragStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2126
	t.dragStop = dragStop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2127
	t.defaultEventEnd = defaultEventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2128
	t.getHoverListener = function() { return hoverListener };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2129
	t.colLeft = colLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2130
	t.colRight = colRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2131
	t.colContentLeft = colContentLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2132
	t.colContentRight = colContentRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2133
	t.getIsCellAllDay = function() { return true };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2134
	t.allDayRow = allDayRow;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2135
	t.getRowCnt = function() { return rowCnt };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2136
	t.getColCnt = function() { return colCnt };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2137
	t.getColWidth = function() { return colWidth };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2138
	t.getDaySegmentContainer = function() { return daySegmentContainer };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2139
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2140
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2141
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2142
	View.call(t, element, calendar, viewName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2143
	OverlayManager.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2144
	SelectionManager.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2145
	BasicEventRenderer.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2146
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2147
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2148
	var renderOverlay = t.renderOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2149
	var clearOverlays = t.clearOverlays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2150
	var daySelectionMousedown = t.daySelectionMousedown;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2151
	var cellToDate = t.cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2152
	var dateToCell = t.dateToCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2153
	var rangeToSegments = t.rangeToSegments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2154
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2155
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2156
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2157
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2158
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2159
	var table;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2160
	var head;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2161
	var headCells;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2162
	var body;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2163
	var bodyRows;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2164
	var bodyCells;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2165
	var bodyFirstCells;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2166
	var firstRowCellInners;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2167
	var firstRowCellContentInners;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2168
	var daySegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2169
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2170
	var viewWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2171
	var viewHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2172
	var colWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2173
	var weekNumberWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2174
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2175
	var rowCnt, colCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2176
	var showNumbers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2177
	var coordinateGrid;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2178
	var hoverListener;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2179
	var colPositions;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2180
	var colContentPositions;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2181
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2182
	var tm;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2183
	var colFormat;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2184
	var showWeekNumbers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2185
	var weekNumberTitle;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2186
	var weekNumberFormat;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2187
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2188
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2189
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2190
	/* Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2191
	------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2192
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2193
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2194
	disableTextSelection(element.addClass('fc-grid'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2195
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2196
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2197
	function renderBasic(_rowCnt, _colCnt, _showNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2198
		rowCnt = _rowCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2199
		colCnt = _colCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2200
		showNumbers = _showNumbers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2201
		updateOptions();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2202
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2203
		if (!body) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2204
			buildEventContainer();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2205
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2206
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2207
		buildTable();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2208
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2209
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2210
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2211
	function updateOptions() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2212
		tm = opt('theme') ? 'ui' : 'fc';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2213
		colFormat = opt('columnFormat');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2214
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2215
		// week # options. (TODO: bad, logic also in other views)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2216
		showWeekNumbers = opt('weekNumbers');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2217
		weekNumberTitle = opt('weekNumberTitle');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2218
		if (opt('weekNumberCalculation') != 'iso') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2219
			weekNumberFormat = "w";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2220
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2221
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2222
			weekNumberFormat = "W";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2223
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2224
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2225
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2226
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2227
	function buildEventContainer() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2228
		daySegmentContainer =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2229
			$("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2230
				.appendTo(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2231
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2232
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2233
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2234
	function buildTable() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2235
		var html = buildTableHTML();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2236
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2237
		if (table) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2238
			table.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2239
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2240
		table = $(html).appendTo(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2241
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2242
		head = table.find('thead');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2243
		headCells = head.find('.fc-day-header');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2244
		body = table.find('tbody');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2245
		bodyRows = body.find('tr');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2246
		bodyCells = body.find('.fc-day');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2247
		bodyFirstCells = bodyRows.find('td:first-child');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2248
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2249
		firstRowCellInners = bodyRows.eq(0).find('.fc-day > div');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2250
		firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2251
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2252
		markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2253
		markFirstLast(bodyRows); // marks first+last td's
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2254
		bodyRows.eq(0).addClass('fc-first');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2255
		bodyRows.filter(':last').addClass('fc-last');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2256
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2257
		bodyCells.each(function(i, _cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2258
			var date = cellToDate(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2259
				Math.floor(i / colCnt),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2260
				i % colCnt
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2261
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2262
			trigger('dayRender', t, date, $(_cell));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2263
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2264
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2265
		dayBind(bodyCells);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2266
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2267
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2268
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2269
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2270
	/* HTML Building
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2271
	-----------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2272
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2273
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2274
	function buildTableHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2275
		var html =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2276
			"<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2277
			buildHeadHTML() +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2278
			buildBodyHTML() +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2279
			"</table>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2280
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2281
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2282
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2283
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2284
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2285
	function buildHeadHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2286
		var headerClass = tm + "-widget-header";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2287
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2288
		var col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2289
		var date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2290
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2291
		html += "<thead><tr>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2292
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2293
		if (showWeekNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2294
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2295
				"<th class='fc-week-number " + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2296
				htmlEscape(weekNumberTitle) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2297
				"</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2298
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2299
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2300
		for (col=0; col<colCnt; col++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2301
			date = cellToDate(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2302
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2303
				"<th class='fc-day-header fc-" + dayIDs[date.getDay()] + " " + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2304
				htmlEscape(formatDate(date, colFormat)) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2305
				"</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2306
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2307
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2308
		html += "</tr></thead>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2309
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2310
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2311
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2312
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2313
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2314
	function buildBodyHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2315
		var contentClass = tm + "-widget-content";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2316
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2317
		var row;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2318
		var col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2319
		var date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2320
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2321
		html += "<tbody>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2322
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2323
		for (row=0; row<rowCnt; row++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2324
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2325
			html += "<tr class='fc-week'>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2326
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2327
			if (showWeekNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2328
				date = cellToDate(row, 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2329
				html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2330
					"<td class='fc-week-number " + contentClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2331
					"<div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2332
					htmlEscape(formatDate(date, weekNumberFormat)) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2333
					"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2334
					"</td>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2335
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2336
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2337
			for (col=0; col<colCnt; col++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2338
				date = cellToDate(row, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2339
				html += buildCellHTML(date);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2340
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2341
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2342
			html += "</tr>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2343
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2344
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2345
		html += "</tbody>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2346
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2347
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2348
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2349
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2350
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2351
	function buildCellHTML(date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2352
		var contentClass = tm + "-widget-content";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2353
		var month = t.start.getMonth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2354
		var today = clearTime(new Date());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2355
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2356
		var classNames = [
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2357
			'fc-day',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2358
			'fc-' + dayIDs[date.getDay()],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2359
			contentClass
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2360
		];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2361
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2362
		if (date.getMonth() != month) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2363
			classNames.push('fc-other-month');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2364
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2365
		if (+date == +today) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2366
			classNames.push(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2367
				'fc-today',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2368
				tm + '-state-highlight'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2369
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2370
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2371
		else if (date < today) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2372
			classNames.push('fc-past');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2373
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2374
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2375
			classNames.push('fc-future');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2376
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2377
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2378
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2379
			"<td" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2380
			" class='" + classNames.join(' ') + "'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2381
			" data-date='" + formatDate(date, 'yyyy-MM-dd') + "'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2382
			">" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2383
			"<div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2384
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2385
		if (showNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2386
			html += "<div class='fc-day-number'>" + date.getDate() + "</div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2387
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2388
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2389
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2390
			"<div class='fc-day-content'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2391
			"<div style='position:relative'>&nbsp;</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2392
			"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2393
			"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2394
			"</td>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2395
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2396
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2397
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2398
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2399
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2400
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2401
	/* Dimensions
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2402
	-----------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2403
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2404
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2405
	function setHeight(height) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2406
		viewHeight = height;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2407
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2408
		var bodyHeight = viewHeight - head.height();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2409
		var rowHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2410
		var rowHeightLast;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2411
		var cell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2412
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2413
		if (opt('weekMode') == 'variable') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2414
			rowHeight = rowHeightLast = Math.floor(bodyHeight / (rowCnt==1 ? 2 : 6));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2415
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2416
			rowHeight = Math.floor(bodyHeight / rowCnt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2417
			rowHeightLast = bodyHeight - rowHeight * (rowCnt-1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2418
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2419
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2420
		bodyFirstCells.each(function(i, _cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2421
			if (i < rowCnt) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2422
				cell = $(_cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2423
				cell.find('> div').css(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2424
					'min-height',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2425
					(i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2426
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2427
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2428
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2429
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2430
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2431
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2432
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2433
	function setWidth(width) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2434
		viewWidth = width;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2435
		colPositions.clear();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2436
		colContentPositions.clear();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2437
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2438
		weekNumberWidth = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2439
		if (showWeekNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2440
			weekNumberWidth = head.find('th.fc-week-number').outerWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2441
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2442
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2443
		colWidth = Math.floor((viewWidth - weekNumberWidth) / colCnt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2444
		setOuterWidth(headCells.slice(0, -1), colWidth);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2445
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2446
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2447
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2448
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2449
	/* Day clicking and binding
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2450
	-----------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2451
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2452
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2453
	function dayBind(days) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2454
		days.click(dayClick)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2455
			.mousedown(daySelectionMousedown);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2456
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2457
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2458
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2459
	function dayClick(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2460
		if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2461
			var date = parseISO8601($(this).data('date'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2462
			trigger('dayClick', this, date, true, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2463
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2464
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2465
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2466
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2467
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2468
	/* Semi-transparent Overlay Helpers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2469
	------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2470
	// TODO: should be consolidated with AgendaView's methods
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2471
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2472
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2473
	function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2474
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2475
		if (refreshCoordinateGrid) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2476
			coordinateGrid.build();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2477
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2478
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2479
		var segments = rangeToSegments(overlayStart, overlayEnd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2480
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2481
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2482
			var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2483
			dayBind(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2484
				renderCellOverlay(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2485
					segment.row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2486
					segment.leftCol,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2487
					segment.row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2488
					segment.rightCol
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2489
				)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2490
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2491
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2492
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2493
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2494
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2495
	function renderCellOverlay(row0, col0, row1, col1) { // row1,col1 is inclusive
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2496
		var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2497
		return renderOverlay(rect, element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2498
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2499
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2500
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2501
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2502
	/* Selection
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2503
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2504
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2505
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2506
	function defaultSelectionEnd(startDate, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2507
		return cloneDate(startDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2508
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2509
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2510
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2511
	function renderSelection(startDate, endDate, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2512
		renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true); // rebuild every time???
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2513
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2514
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2515
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2516
	function clearSelection() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2517
		clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2518
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2519
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2520
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2521
	function reportDayClick(date, allDay, ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2522
		var cell = dateToCell(date);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2523
		var _element = bodyCells[cell.row*colCnt + cell.col];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2524
		trigger('dayClick', _element, date, allDay, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2525
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2526
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2527
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2528
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2529
	/* External Dragging
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2530
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2531
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2532
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2533
	function dragStart(_dragElement, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2534
		hoverListener.start(function(cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2535
			clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2536
			if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2537
				renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2538
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2539
		}, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2540
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2541
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2542
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2543
	function dragStop(_dragElement, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2544
		var cell = hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2545
		clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2546
		if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2547
			var d = cellToDate(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2548
			trigger('drop', _dragElement, d, true, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2549
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2550
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2551
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2552
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2553
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2554
	/* Utilities
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2555
	--------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2556
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2557
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2558
	function defaultEventEnd(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2559
		return cloneDate(event.start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2560
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2561
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2562
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2563
	coordinateGrid = new CoordinateGrid(function(rows, cols) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2564
		var e, n, p;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2565
		headCells.each(function(i, _e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2566
			e = $(_e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2567
			n = e.offset().left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2568
			if (i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2569
				p[1] = n;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2570
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2571
			p = [n];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2572
			cols[i] = p;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2573
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2574
		p[1] = n + e.outerWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2575
		bodyRows.each(function(i, _e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2576
			if (i < rowCnt) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2577
				e = $(_e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2578
				n = e.offset().top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2579
				if (i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2580
					p[1] = n;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2581
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2582
				p = [n];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2583
				rows[i] = p;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2584
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2585
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2586
		p[1] = n + e.outerHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2587
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2588
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2589
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2590
	hoverListener = new HoverListener(coordinateGrid);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2591
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2592
	colPositions = new HorizontalPositionCache(function(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2593
		return firstRowCellInners.eq(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2594
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2595
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2596
	colContentPositions = new HorizontalPositionCache(function(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2597
		return firstRowCellContentInners.eq(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2598
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2599
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2600
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2601
	function colLeft(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2602
		return colPositions.left(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2603
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2604
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2605
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2606
	function colRight(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2607
		return colPositions.right(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2608
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2609
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2610
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2611
	function colContentLeft(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2612
		return colContentPositions.left(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2613
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2614
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2615
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2616
	function colContentRight(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2617
		return colContentPositions.right(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2618
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2619
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2620
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2621
	function allDayRow(i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2622
		return bodyRows.eq(i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2623
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2624
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2625
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2626
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2627
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2628
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2629
function BasicEventRenderer() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2630
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2631
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2632
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2633
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2634
	t.renderEvents = renderEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2635
	t.clearEvents = clearEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2636
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2637
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2638
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2639
	DayEventRenderer.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2640
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2641
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2642
	function renderEvents(events, modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2643
		t.renderDayEvents(events, modifiedEventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2644
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2645
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2646
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2647
	function clearEvents() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2648
		t.getDaySegmentContainer().empty();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2649
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2650
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2651
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2652
	// TODO: have this class (and AgendaEventRenderer) be responsible for creating the event container div
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2653
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2654
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2655
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2656
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2657
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2658
fcViews.agendaWeek = AgendaWeekView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2659
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2660
function AgendaWeekView(element, calendar) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2661
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2662
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2663
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2664
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2665
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2666
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2667
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2668
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2669
	AgendaView.call(t, element, calendar, 'agendaWeek');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2670
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2671
	var renderAgenda = t.renderAgenda;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2672
	var skipHiddenDays = t.skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2673
	var getCellsPerWeek = t.getCellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2674
	var formatDates = calendar.formatDates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2675
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2676
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2677
	function render(date, delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2678
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2679
		if (delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2680
			addDays(date, delta * 7);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2681
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2682
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2683
		var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2684
		var end = addDays(cloneDate(start), 7);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2685
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2686
		var visStart = cloneDate(start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2687
		skipHiddenDays(visStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2688
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2689
		var visEnd = cloneDate(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2690
		skipHiddenDays(visEnd, -1, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2691
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2692
		var colCnt = getCellsPerWeek();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2693
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2694
		t.title = formatDates(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2695
			visStart,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2696
			addDays(cloneDate(visEnd), -1),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2697
			opt('titleFormat')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2698
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2699
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2700
		t.start = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2701
		t.end = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2702
		t.visStart = visStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2703
		t.visEnd = visEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2704
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2705
		renderAgenda(colCnt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2706
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2707
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2708
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2709
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2710
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2711
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2712
fcViews.agendaDay = AgendaDayView;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2713
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2714
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2715
function AgendaDayView(element, calendar) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2716
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2717
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2718
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2719
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2720
	t.render = render;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2721
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2722
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2723
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2724
	AgendaView.call(t, element, calendar, 'agendaDay');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2725
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2726
	var renderAgenda = t.renderAgenda;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2727
	var skipHiddenDays = t.skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2728
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2729
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2730
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2731
	function render(date, delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2732
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2733
		if (delta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2734
			addDays(date, delta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2735
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2736
		skipHiddenDays(date, delta < 0 ? -1 : 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2737
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2738
		var start = cloneDate(date, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2739
		var end = addDays(cloneDate(start), 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2740
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2741
		t.title = formatDate(date, opt('titleFormat'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2742
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2743
		t.start = t.visStart = start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2744
		t.end = t.visEnd = end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2745
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2746
		renderAgenda(1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2747
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2748
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2749
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2750
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2751
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2752
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2753
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2754
setDefaults({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2755
	allDaySlot: true,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2756
	allDayText: 'all-day',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2757
	firstHour: 6,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2758
	slotMinutes: 30,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2759
	defaultEventMinutes: 120,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2760
	axisFormat: 'h(:mm)tt',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2761
	timeFormat: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2762
		agenda: 'h:mm{ - h:mm}'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2763
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2764
	dragOpacity: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2765
		agenda: .5
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2766
	},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2767
	minTime: 0,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2768
	maxTime: 24,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2769
	slotEventOverlap: true
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2770
});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2771
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2772
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2773
// TODO: make it work in quirks mode (event corners, all-day height)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2774
// TODO: test liquid width, especially in IE6
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2775
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2776
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2777
function AgendaView(element, calendar, viewName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2778
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2779
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2780
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2781
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2782
	t.renderAgenda = renderAgenda;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2783
	t.setWidth = setWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2784
	t.setHeight = setHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2785
	t.afterRender = afterRender;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2786
	t.defaultEventEnd = defaultEventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2787
	t.timePosition = timePosition;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2788
	t.getIsCellAllDay = getIsCellAllDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2789
	t.allDayRow = getAllDayRow;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2790
	t.getCoordinateGrid = function() { return coordinateGrid }; // specifically for AgendaEventRenderer
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2791
	t.getHoverListener = function() { return hoverListener };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2792
	t.colLeft = colLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2793
	t.colRight = colRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2794
	t.colContentLeft = colContentLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2795
	t.colContentRight = colContentRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2796
	t.getDaySegmentContainer = function() { return daySegmentContainer };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2797
	t.getSlotSegmentContainer = function() { return slotSegmentContainer };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2798
	t.getMinMinute = function() { return minMinute };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2799
	t.getMaxMinute = function() { return maxMinute };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2800
	t.getSlotContainer = function() { return slotContainer };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2801
	t.getRowCnt = function() { return 1 };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2802
	t.getColCnt = function() { return colCnt };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2803
	t.getColWidth = function() { return colWidth };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2804
	t.getSnapHeight = function() { return snapHeight };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2805
	t.getSnapMinutes = function() { return snapMinutes };
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2806
	t.defaultSelectionEnd = defaultSelectionEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2807
	t.renderDayOverlay = renderDayOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2808
	t.renderSelection = renderSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2809
	t.clearSelection = clearSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2810
	t.reportDayClick = reportDayClick; // selection mousedown hack
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2811
	t.dragStart = dragStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2812
	t.dragStop = dragStop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2813
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2814
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2815
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2816
	View.call(t, element, calendar, viewName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2817
	OverlayManager.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2818
	SelectionManager.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2819
	AgendaEventRenderer.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2820
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2821
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2822
	var renderOverlay = t.renderOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2823
	var clearOverlays = t.clearOverlays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2824
	var reportSelection = t.reportSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2825
	var unselect = t.unselect;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2826
	var daySelectionMousedown = t.daySelectionMousedown;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2827
	var slotSegHtml = t.slotSegHtml;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2828
	var cellToDate = t.cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2829
	var dateToCell = t.dateToCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2830
	var rangeToSegments = t.rangeToSegments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2831
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2832
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2833
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2834
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2835
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2836
	var dayTable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2837
	var dayHead;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2838
	var dayHeadCells;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2839
	var dayBody;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2840
	var dayBodyCells;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2841
	var dayBodyCellInners;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2842
	var dayBodyCellContentInners;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2843
	var dayBodyFirstCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2844
	var dayBodyFirstCellStretcher;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2845
	var slotLayer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2846
	var daySegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2847
	var allDayTable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2848
	var allDayRow;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2849
	var slotScroller;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2850
	var slotContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2851
	var slotSegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2852
	var slotTable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2853
	var selectionHelper;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2854
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2855
	var viewWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2856
	var viewHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2857
	var axisWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2858
	var colWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2859
	var gutterWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2860
	var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2861
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2862
	var snapMinutes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2863
	var snapRatio; // ratio of number of "selection" slots to normal slots. (ex: 1, 2, 4)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2864
	var snapHeight; // holds the pixel hight of a "selection" slot
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2865
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2866
	var colCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2867
	var slotCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2868
	var coordinateGrid;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2869
	var hoverListener;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2870
	var colPositions;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2871
	var colContentPositions;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2872
	var slotTopCache = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2873
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2874
	var tm;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2875
	var rtl;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2876
	var minMinute, maxMinute;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2877
	var colFormat;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2878
	var showWeekNumbers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2879
	var weekNumberTitle;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2880
	var weekNumberFormat;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2881
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2882
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2883
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2884
	/* Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2885
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2886
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2887
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2888
	disableTextSelection(element.addClass('fc-agenda'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2889
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2890
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2891
	function renderAgenda(c) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2892
		colCnt = c;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2893
		updateOptions();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2894
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2895
		if (!dayTable) { // first time rendering?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2896
			buildSkeleton(); // builds day table, slot area, events containers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2897
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2898
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2899
			buildDayTable(); // rebuilds day table
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2900
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2901
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2902
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2903
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2904
	function updateOptions() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2905
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2906
		tm = opt('theme') ? 'ui' : 'fc';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2907
		rtl = opt('isRTL')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2908
		minMinute = parseTime(opt('minTime'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2909
		maxMinute = parseTime(opt('maxTime'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2910
		colFormat = opt('columnFormat');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2911
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2912
		// week # options. (TODO: bad, logic also in other views)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2913
		showWeekNumbers = opt('weekNumbers');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2914
		weekNumberTitle = opt('weekNumberTitle');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2915
		if (opt('weekNumberCalculation') != 'iso') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2916
			weekNumberFormat = "w";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2917
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2918
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2919
			weekNumberFormat = "W";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2920
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2921
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2922
		snapMinutes = opt('snapMinutes') || opt('slotMinutes');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2923
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2924
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2925
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2926
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2927
	/* Build DOM
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2928
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2929
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2930
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2931
	function buildSkeleton() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2932
		var headerClass = tm + "-widget-header";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2933
		var contentClass = tm + "-widget-content";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2934
		var s;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2935
		var d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2936
		var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2937
		var maxd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2938
		var minutes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2939
		var slotNormal = opt('slotMinutes') % 15 == 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2940
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2941
		buildDayTable();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2942
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2943
		slotLayer =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2944
			$("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2945
				.appendTo(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2946
				
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2947
		if (opt('allDaySlot')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2948
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2949
			daySegmentContainer =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2950
				$("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2951
					.appendTo(slotLayer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2952
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2953
			s =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2954
				"<table style='width:100%' class='fc-agenda-allday' cellspacing='0'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2955
				"<tr>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2956
				"<th class='" + headerClass + " fc-agenda-axis'>" + opt('allDayText') + "</th>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2957
				"<td>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2958
				"<div class='fc-day-content'><div style='position:relative'/></div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2959
				"</td>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2960
				"<th class='" + headerClass + " fc-agenda-gutter'>&nbsp;</th>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2961
				"</tr>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2962
				"</table>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2963
			allDayTable = $(s).appendTo(slotLayer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2964
			allDayRow = allDayTable.find('tr');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2965
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2966
			dayBind(allDayRow.find('td'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2967
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2968
			slotLayer.append(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2969
				"<div class='fc-agenda-divider " + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2970
				"<div class='fc-agenda-divider-inner'/>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2971
				"</div>"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2972
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2973
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2974
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2975
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2976
			daySegmentContainer = $([]); // in jQuery 1.4, we can just do $()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2977
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2978
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2979
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2980
		slotScroller =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2981
			$("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2982
				.appendTo(slotLayer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2983
				
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2984
		slotContainer =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2985
			$("<div style='position:relative;width:100%;overflow:hidden'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2986
				.appendTo(slotScroller);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2987
				
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2988
		slotSegmentContainer =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2989
			$("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2990
				.appendTo(slotContainer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2991
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2992
		s =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2993
			"<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2994
			"<tbody>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2995
		d = zeroDate();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2996
		maxd = addMinutes(cloneDate(d), maxMinute);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2997
		addMinutes(d, minMinute);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2998
		slotCnt = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  2999
		for (i=0; d < maxd; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3000
			minutes = d.getMinutes();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3001
			s +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3002
				"<tr class='fc-slot" + i + ' ' + (!minutes ? '' : 'fc-minor') + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3003
				"<th class='fc-agenda-axis " + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3004
				((!slotNormal || !minutes) ? formatDate(d, opt('axisFormat')) : '&nbsp;') +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3005
				"</th>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3006
				"<td class='" + contentClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3007
				"<div style='position:relative'>&nbsp;</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3008
				"</td>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3009
				"</tr>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3010
			addMinutes(d, opt('slotMinutes'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3011
			slotCnt++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3012
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3013
		s +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3014
			"</tbody>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3015
			"</table>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3016
		slotTable = $(s).appendTo(slotContainer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3017
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3018
		slotBind(slotTable.find('td'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3019
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3020
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3021
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3022
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3023
	/* Build Day Table
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3024
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3025
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3026
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3027
	function buildDayTable() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3028
		var html = buildDayTableHTML();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3029
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3030
		if (dayTable) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3031
			dayTable.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3032
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3033
		dayTable = $(html).appendTo(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3034
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3035
		dayHead = dayTable.find('thead');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3036
		dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3037
		dayBody = dayTable.find('tbody');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3038
		dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3039
		dayBodyCellInners = dayBodyCells.find('> div');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3040
		dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3041
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3042
		dayBodyFirstCell = dayBodyCells.eq(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3043
		dayBodyFirstCellStretcher = dayBodyCellInners.eq(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3044
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3045
		markFirstLast(dayHead.add(dayHead.find('tr')));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3046
		markFirstLast(dayBody.add(dayBody.find('tr')));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3047
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3048
		// TODO: now that we rebuild the cells every time, we should call dayRender
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3049
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3050
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3051
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3052
	function buildDayTableHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3053
		var html =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3054
			"<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3055
			buildDayTableHeadHTML() +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3056
			buildDayTableBodyHTML() +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3057
			"</table>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3058
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3059
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3060
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3061
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3062
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3063
	function buildDayTableHeadHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3064
		var headerClass = tm + "-widget-header";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3065
		var date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3066
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3067
		var weekText;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3068
		var col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3069
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3070
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3071
			"<thead>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3072
			"<tr>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3073
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3074
		if (showWeekNumbers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3075
			date = cellToDate(0, 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3076
			weekText = formatDate(date, weekNumberFormat);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3077
			if (rtl) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3078
				weekText += weekNumberTitle;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3079
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3080
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3081
				weekText = weekNumberTitle + weekText;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3082
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3083
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3084
				"<th class='fc-agenda-axis fc-week-number " + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3085
				htmlEscape(weekText) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3086
				"</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3087
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3088
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3089
			html += "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3090
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3091
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3092
		for (col=0; col<colCnt; col++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3093
			date = cellToDate(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3094
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3095
				"<th class='fc-" + dayIDs[date.getDay()] + " fc-col" + col + ' ' + headerClass + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3096
				htmlEscape(formatDate(date, colFormat)) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3097
				"</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3098
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3099
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3100
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3101
			"<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3102
			"</tr>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3103
			"</thead>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3104
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3105
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3106
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3107
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3108
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3109
	function buildDayTableBodyHTML() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3110
		var headerClass = tm + "-widget-header"; // TODO: make these when updateOptions() called
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3111
		var contentClass = tm + "-widget-content";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3112
		var date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3113
		var today = clearTime(new Date());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3114
		var col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3115
		var cellsHTML;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3116
		var cellHTML;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3117
		var classNames;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3118
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3119
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3120
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3121
			"<tbody>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3122
			"<tr>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3123
			"<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3124
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3125
		cellsHTML = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3126
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3127
		for (col=0; col<colCnt; col++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3128
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3129
			date = cellToDate(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3130
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3131
			classNames = [
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3132
				'fc-col' + col,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3133
				'fc-' + dayIDs[date.getDay()],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3134
				contentClass
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3135
			];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3136
			if (+date == +today) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3137
				classNames.push(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3138
					tm + '-state-highlight',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3139
					'fc-today'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3140
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3141
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3142
			else if (date < today) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3143
				classNames.push('fc-past');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3144
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3145
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3146
				classNames.push('fc-future');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3147
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3148
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3149
			cellHTML =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3150
				"<td class='" + classNames.join(' ') + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3151
				"<div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3152
				"<div class='fc-day-content'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3153
				"<div style='position:relative'>&nbsp;</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3154
				"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3155
				"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3156
				"</td>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3157
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3158
			cellsHTML += cellHTML;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3159
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3160
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3161
		html += cellsHTML;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3162
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3163
			"<td class='fc-agenda-gutter " + contentClass + "'>&nbsp;</td>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3164
			"</tr>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3165
			"</tbody>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3166
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3167
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3168
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3169
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3170
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3171
	// TODO: data-date on the cells
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3172
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3173
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3174
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3175
	/* Dimensions
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3176
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3177
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3178
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3179
	function setHeight(height) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3180
		if (height === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3181
			height = viewHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3182
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3183
		viewHeight = height;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3184
		slotTopCache = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3185
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3186
		var headHeight = dayBody.position().top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3187
		var allDayHeight = slotScroller.position().top; // including divider
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3188
		var bodyHeight = Math.min( // total body height, including borders
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3189
			height - headHeight,   // when scrollbars
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3190
			slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3191
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3192
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3193
		dayBodyFirstCellStretcher
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3194
			.height(bodyHeight - vsides(dayBodyFirstCell));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3195
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3196
		slotLayer.css('top', headHeight);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3197
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3198
		slotScroller.height(bodyHeight - allDayHeight - 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3199
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3200
		// the stylesheet guarantees that the first row has no border.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3201
		// this allows .height() to work well cross-browser.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3202
		slotHeight = slotTable.find('tr:first').height() + 1; // +1 for bottom border
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3203
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3204
		snapRatio = opt('slotMinutes') / snapMinutes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3205
		snapHeight = slotHeight / snapRatio;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3206
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3207
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3208
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3209
	function setWidth(width) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3210
		viewWidth = width;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3211
		colPositions.clear();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3212
		colContentPositions.clear();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3213
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3214
		var axisFirstCells = dayHead.find('th:first');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3215
		if (allDayTable) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3216
			axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3217
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3218
		axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3219
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3220
		axisWidth = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3221
		setOuterWidth(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3222
			axisFirstCells
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3223
				.width('')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3224
				.each(function(i, _cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3225
					axisWidth = Math.max(axisWidth, $(_cell).outerWidth());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3226
				}),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3227
			axisWidth
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3228
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3229
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3230
		var gutterCells = dayTable.find('.fc-agenda-gutter');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3231
		if (allDayTable) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3232
			gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3233
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3234
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3235
		var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3236
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3237
		gutterWidth = slotScroller.width() - slotTableWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3238
		if (gutterWidth) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3239
			setOuterWidth(gutterCells, gutterWidth);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3240
			gutterCells
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3241
				.show()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3242
				.prev()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3243
				.removeClass('fc-last');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3244
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3245
			gutterCells
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3246
				.hide()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3247
				.prev()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3248
				.addClass('fc-last');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3249
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3250
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3251
		colWidth = Math.floor((slotTableWidth - axisWidth) / colCnt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3252
		setOuterWidth(dayHeadCells.slice(0, -1), colWidth);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3253
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3254
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3255
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3256
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3257
	/* Scrolling
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3258
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3259
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3260
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3261
	function resetScroll() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3262
		var d0 = zeroDate();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3263
		var scrollDate = cloneDate(d0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3264
		scrollDate.setHours(opt('firstHour'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3265
		var top = timePosition(d0, scrollDate) + 1; // +1 for the border
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3266
		function scroll() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3267
			slotScroller.scrollTop(top);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3268
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3269
		scroll();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3270
		setTimeout(scroll, 0); // overrides any previous scroll state made by the browser
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3271
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3272
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3273
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3274
	function afterRender() { // after the view has been freshly rendered and sized
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3275
		resetScroll();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3276
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3277
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3278
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3279
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3280
	/* Slot/Day clicking and binding
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3281
	-----------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3282
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3283
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3284
	function dayBind(cells) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3285
		cells.click(slotClick)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3286
			.mousedown(daySelectionMousedown);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3287
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3288
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3289
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3290
	function slotBind(cells) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3291
		cells.click(slotClick)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3292
			.mousedown(slotSelectionMousedown);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3293
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3294
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3295
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3296
	function slotClick(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3297
		if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3298
			var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3299
			var date = cellToDate(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3300
			var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3301
			if (rowMatch) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3302
				var mins = parseInt(rowMatch[1]) * opt('slotMinutes');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3303
				var hours = Math.floor(mins/60);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3304
				date.setHours(hours);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3305
				date.setMinutes(mins%60 + minMinute);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3306
				trigger('dayClick', dayBodyCells[col], date, false, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3307
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3308
				trigger('dayClick', dayBodyCells[col], date, true, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3309
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3310
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3311
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3312
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3313
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3314
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3315
	/* Semi-transparent Overlay Helpers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3316
	-----------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3317
	// TODO: should be consolidated with BasicView's methods
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3318
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3319
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3320
	function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3321
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3322
		if (refreshCoordinateGrid) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3323
			coordinateGrid.build();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3324
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3325
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3326
		var segments = rangeToSegments(overlayStart, overlayEnd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3327
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3328
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3329
			var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3330
			dayBind(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3331
				renderCellOverlay(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3332
					segment.row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3333
					segment.leftCol,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3334
					segment.row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3335
					segment.rightCol
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3336
				)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3337
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3338
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3339
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3340
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3341
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3342
	function renderCellOverlay(row0, col0, row1, col1) { // only for all-day?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3343
		var rect = coordinateGrid.rect(row0, col0, row1, col1, slotLayer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3344
		return renderOverlay(rect, slotLayer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3345
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3346
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3347
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3348
	function renderSlotOverlay(overlayStart, overlayEnd) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3349
		for (var i=0; i<colCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3350
			var dayStart = cellToDate(0, i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3351
			var dayEnd = addDays(cloneDate(dayStart), 1);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3352
			var stretchStart = new Date(Math.max(dayStart, overlayStart));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3353
			var stretchEnd = new Date(Math.min(dayEnd, overlayEnd));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3354
			if (stretchStart < stretchEnd) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3355
				var rect = coordinateGrid.rect(0, i, 0, i, slotContainer); // only use it for horizontal coords
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3356
				var top = timePosition(dayStart, stretchStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3357
				var bottom = timePosition(dayStart, stretchEnd);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3358
				rect.top = top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3359
				rect.height = bottom - top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3360
				slotBind(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3361
					renderOverlay(rect, slotContainer)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3362
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3363
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3364
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3365
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3366
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3367
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3368
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3369
	/* Coordinate Utilities
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3370
	-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3371
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3372
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3373
	coordinateGrid = new CoordinateGrid(function(rows, cols) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3374
		var e, n, p;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3375
		dayHeadCells.each(function(i, _e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3376
			e = $(_e);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3377
			n = e.offset().left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3378
			if (i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3379
				p[1] = n;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3380
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3381
			p = [n];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3382
			cols[i] = p;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3383
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3384
		p[1] = n + e.outerWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3385
		if (opt('allDaySlot')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3386
			e = allDayRow;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3387
			n = e.offset().top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3388
			rows[0] = [n, n+e.outerHeight()];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3389
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3390
		var slotTableTop = slotContainer.offset().top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3391
		var slotScrollerTop = slotScroller.offset().top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3392
		var slotScrollerBottom = slotScrollerTop + slotScroller.outerHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3393
		function constrain(n) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3394
			return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3395
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3396
		for (var i=0; i<slotCnt*snapRatio; i++) { // adapt slot count to increased/decreased selection slot count
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3397
			rows.push([
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3398
				constrain(slotTableTop + snapHeight*i),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3399
				constrain(slotTableTop + snapHeight*(i+1))
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3400
			]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3401
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3402
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3403
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3404
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3405
	hoverListener = new HoverListener(coordinateGrid);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3406
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3407
	colPositions = new HorizontalPositionCache(function(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3408
		return dayBodyCellInners.eq(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3409
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3410
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3411
	colContentPositions = new HorizontalPositionCache(function(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3412
		return dayBodyCellContentInners.eq(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3413
	});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3414
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3415
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3416
	function colLeft(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3417
		return colPositions.left(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3418
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3419
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3420
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3421
	function colContentLeft(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3422
		return colContentPositions.left(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3423
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3424
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3425
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3426
	function colRight(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3427
		return colPositions.right(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3428
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3429
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3430
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3431
	function colContentRight(col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3432
		return colContentPositions.right(col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3433
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3434
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3435
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3436
	function getIsCellAllDay(cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3437
		return opt('allDaySlot') && !cell.row;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3438
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3439
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3440
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3441
	function realCellToDate(cell) { // ugh "real" ... but blame it on our abuse of the "cell" system
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3442
		var d = cellToDate(0, cell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3443
		var slotIndex = cell.row;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3444
		if (opt('allDaySlot')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3445
			slotIndex--;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3446
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3447
		if (slotIndex >= 0) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3448
			addMinutes(d, minMinute + slotIndex * snapMinutes);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3449
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3450
		return d;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3451
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3452
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3453
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3454
	// get the Y coordinate of the given time on the given day (both Date objects)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3455
	function timePosition(day, time) { // both date objects. day holds 00:00 of current day
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3456
		day = cloneDate(day, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3457
		if (time < addMinutes(cloneDate(day), minMinute)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3458
			return 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3459
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3460
		if (time >= addMinutes(cloneDate(day), maxMinute)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3461
			return slotTable.height();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3462
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3463
		var slotMinutes = opt('slotMinutes'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3464
			minutes = time.getHours()*60 + time.getMinutes() - minMinute,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3465
			slotI = Math.floor(minutes / slotMinutes),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3466
			slotTop = slotTopCache[slotI];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3467
		if (slotTop === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3468
			slotTop = slotTopCache[slotI] =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3469
				slotTable.find('tr').eq(slotI).find('td div')[0].offsetTop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3470
				// .eq() is faster than ":eq()" selector
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3471
				// [0].offsetTop is faster than .position().top (do we really need this optimization?)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3472
				// a better optimization would be to cache all these divs
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3473
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3474
		return Math.max(0, Math.round(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3475
			slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3476
		));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3477
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3478
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3479
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3480
	function getAllDayRow(index) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3481
		return allDayRow;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3482
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3483
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3484
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3485
	function defaultEventEnd(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3486
		var start = cloneDate(event.start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3487
		if (event.allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3488
			return start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3489
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3490
		return addMinutes(start, opt('defaultEventMinutes'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3491
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3492
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3493
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3494
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3495
	/* Selection
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3496
	---------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3497
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3498
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3499
	function defaultSelectionEnd(startDate, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3500
		if (allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3501
			return cloneDate(startDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3502
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3503
		return addMinutes(cloneDate(startDate), opt('slotMinutes'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3504
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3505
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3506
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3507
	function renderSelection(startDate, endDate, allDay) { // only for all-day
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3508
		if (allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3509
			if (opt('allDaySlot')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3510
				renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3511
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3512
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3513
			renderSlotSelection(startDate, endDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3514
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3515
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3516
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3517
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3518
	function renderSlotSelection(startDate, endDate) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3519
		var helperOption = opt('selectHelper');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3520
		coordinateGrid.build();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3521
		if (helperOption) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3522
			var col = dateToCell(startDate).col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3523
			if (col >= 0 && col < colCnt) { // only works when times are on same day
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3524
				var rect = coordinateGrid.rect(0, col, 0, col, slotContainer); // only for horizontal coords
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3525
				var top = timePosition(startDate, startDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3526
				var bottom = timePosition(startDate, endDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3527
				if (bottom > top) { // protect against selections that are entirely before or after visible range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3528
					rect.top = top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3529
					rect.height = bottom - top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3530
					rect.left += 2;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3531
					rect.width -= 5;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3532
					if ($.isFunction(helperOption)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3533
						var helperRes = helperOption(startDate, endDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3534
						if (helperRes) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3535
							rect.position = 'absolute';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3536
							selectionHelper = $(helperRes)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3537
								.css(rect)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3538
								.appendTo(slotContainer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3539
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3540
					}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3541
						rect.isStart = true; // conside rect a "seg" now
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3542
						rect.isEnd = true;   //
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3543
						selectionHelper = $(slotSegHtml(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3544
							{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3545
								title: '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3546
								start: startDate,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3547
								end: endDate,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3548
								className: ['fc-select-helper'],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3549
								editable: false
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3550
							},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3551
							rect
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3552
						));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3553
						selectionHelper.css('opacity', opt('dragOpacity'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3554
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3555
					if (selectionHelper) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3556
						slotBind(selectionHelper);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3557
						slotContainer.append(selectionHelper);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3558
						setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3559
						setOuterHeight(selectionHelper, rect.height, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3560
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3561
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3562
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3563
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3564
			renderSlotOverlay(startDate, endDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3565
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3566
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3567
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3568
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3569
	function clearSelection() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3570
		clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3571
		if (selectionHelper) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3572
			selectionHelper.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3573
			selectionHelper = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3574
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3575
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3576
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3577
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3578
	function slotSelectionMousedown(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3579
		if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3580
			unselect(ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3581
			var dates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3582
			hoverListener.start(function(cell, origCell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3583
				clearSelection();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3584
				if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3585
					var d1 = realCellToDate(origCell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3586
					var d2 = realCellToDate(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3587
					dates = [
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3588
						d1,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3589
						addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3590
						d2,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3591
						addMinutes(cloneDate(d2), snapMinutes)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3592
					].sort(dateCompare);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3593
					renderSlotSelection(dates[0], dates[3]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3594
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3595
					dates = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3596
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3597
			}, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3598
			$(document).one('mouseup', function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3599
				hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3600
				if (dates) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3601
					if (+dates[0] == +dates[1]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3602
						reportDayClick(dates[0], false, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3603
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3604
					reportSelection(dates[0], dates[3], false, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3605
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3606
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3607
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3608
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3609
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3610
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3611
	function reportDayClick(date, allDay, ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3612
		trigger('dayClick', dayBodyCells[dateToCell(date).col], date, allDay, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3613
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3614
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3615
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3616
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3617
	/* External Dragging
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3618
	--------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3619
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3620
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3621
	function dragStart(_dragElement, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3622
		hoverListener.start(function(cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3623
			clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3624
			if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3625
				if (getIsCellAllDay(cell)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3626
					renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3627
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3628
					var d1 = realCellToDate(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3629
					var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3630
					renderSlotOverlay(d1, d2);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3631
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3632
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3633
		}, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3634
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3635
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3636
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3637
	function dragStop(_dragElement, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3638
		var cell = hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3639
		clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3640
		if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3641
			trigger('drop', _dragElement, realCellToDate(cell), getIsCellAllDay(cell), ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3642
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3643
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3644
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3645
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3646
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3647
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3648
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3649
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3650
function AgendaEventRenderer() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3651
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3652
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3653
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3654
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3655
	t.renderEvents = renderEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3656
	t.clearEvents = clearEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3657
	t.slotSegHtml = slotSegHtml;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3658
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3659
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3660
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3661
	DayEventRenderer.call(t);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3662
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3663
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3664
	var isEventDraggable = t.isEventDraggable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3665
	var isEventResizable = t.isEventResizable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3666
	var eventEnd = t.eventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3667
	var eventElementHandlers = t.eventElementHandlers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3668
	var setHeight = t.setHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3669
	var getDaySegmentContainer = t.getDaySegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3670
	var getSlotSegmentContainer = t.getSlotSegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3671
	var getHoverListener = t.getHoverListener;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3672
	var getMaxMinute = t.getMaxMinute;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3673
	var getMinMinute = t.getMinMinute;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3674
	var timePosition = t.timePosition;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3675
	var getIsCellAllDay = t.getIsCellAllDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3676
	var colContentLeft = t.colContentLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3677
	var colContentRight = t.colContentRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3678
	var cellToDate = t.cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3679
	var getColCnt = t.getColCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3680
	var getColWidth = t.getColWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3681
	var getSnapHeight = t.getSnapHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3682
	var getSnapMinutes = t.getSnapMinutes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3683
	var getSlotContainer = t.getSlotContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3684
	var reportEventElement = t.reportEventElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3685
	var showEvents = t.showEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3686
	var hideEvents = t.hideEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3687
	var eventDrop = t.eventDrop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3688
	var eventResize = t.eventResize;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3689
	var renderDayOverlay = t.renderDayOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3690
	var clearOverlays = t.clearOverlays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3691
	var renderDayEvents = t.renderDayEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3692
	var calendar = t.calendar;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3693
	var formatDate = calendar.formatDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3694
	var formatDates = calendar.formatDates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3695
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3696
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3697
	// overrides
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3698
	t.draggableDayEvent = draggableDayEvent;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3699
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3700
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3701
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3702
	/* Rendering
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3703
	----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3704
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3705
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3706
	function renderEvents(events, modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3707
		var i, len=events.length,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3708
			dayEvents=[],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3709
			slotEvents=[];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3710
		for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3711
			if (events[i].allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3712
				dayEvents.push(events[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3713
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3714
				slotEvents.push(events[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3715
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3716
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3717
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3718
		if (opt('allDaySlot')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3719
			renderDayEvents(dayEvents, modifiedEventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3720
			setHeight(); // no params means set to viewHeight
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3721
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3722
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3723
		renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3724
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3725
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3726
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3727
	function clearEvents() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3728
		getDaySegmentContainer().empty();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3729
		getSlotSegmentContainer().empty();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3730
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3731
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3732
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3733
	function compileSlotSegs(events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3734
		var colCnt = getColCnt(),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3735
			minMinute = getMinMinute(),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3736
			maxMinute = getMaxMinute(),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3737
			d,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3738
			visEventEnds = $.map(events, slotEventEnd),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3739
			i,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3740
			j, seg,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3741
			colSegs,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3742
			segs = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3743
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3744
		for (i=0; i<colCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3745
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3746
			d = cellToDate(0, i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3747
			addMinutes(d, minMinute);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3748
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3749
			colSegs = sliceSegs(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3750
				events,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3751
				visEventEnds,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3752
				d,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3753
				addMinutes(cloneDate(d), maxMinute-minMinute)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3754
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3755
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3756
			colSegs = placeSlotSegs(colSegs); // returns a new order
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3757
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3758
			for (j=0; j<colSegs.length; j++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3759
				seg = colSegs[j];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3760
				seg.col = i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3761
				segs.push(seg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3762
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3763
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3764
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3765
		return segs;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3766
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3767
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3768
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3769
	function sliceSegs(events, visEventEnds, start, end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3770
		var segs = [],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3771
			i, len=events.length, event,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3772
			eventStart, eventEnd,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3773
			segStart, segEnd,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3774
			isStart, isEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3775
		for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3776
			event = events[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3777
			eventStart = event.start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3778
			eventEnd = visEventEnds[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3779
			if (eventEnd > start && eventStart < end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3780
				if (eventStart < start) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3781
					segStart = cloneDate(start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3782
					isStart = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3783
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3784
					segStart = eventStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3785
					isStart = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3786
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3787
				if (eventEnd > end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3788
					segEnd = cloneDate(end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3789
					isEnd = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3790
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3791
					segEnd = eventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3792
					isEnd = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3793
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3794
				segs.push({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3795
					event: event,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3796
					start: segStart,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3797
					end: segEnd,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3798
					isStart: isStart,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3799
					isEnd: isEnd
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3800
				});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3801
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3802
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3803
		return segs.sort(compareSlotSegs);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3804
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3805
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3806
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3807
	function slotEventEnd(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3808
		if (event.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3809
			return cloneDate(event.end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3810
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3811
			return addMinutes(cloneDate(event.start), opt('defaultEventMinutes'));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3812
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3813
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3814
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3815
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3816
	// renders events in the 'time slots' at the bottom
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3817
	// TODO: when we refactor this, when user returns `false` eventRender, don't have empty space
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3818
	// TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3819
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3820
	function renderSlotSegs(segs, modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3821
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3822
		var i, segCnt=segs.length, seg,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3823
			event,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3824
			top,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3825
			bottom,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3826
			columnLeft,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3827
			columnRight,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3828
			columnWidth,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3829
			width,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3830
			left,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3831
			right,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3832
			html = '',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3833
			eventElements,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3834
			eventElement,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3835
			triggerRes,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3836
			titleElement,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3837
			height,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3838
			slotSegmentContainer = getSlotSegmentContainer(),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3839
			isRTL = opt('isRTL');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3840
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3841
		// calculate position/dimensions, create html
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3842
		for (i=0; i<segCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3843
			seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3844
			event = seg.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3845
			top = timePosition(seg.start, seg.start);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3846
			bottom = timePosition(seg.start, seg.end);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3847
			columnLeft = colContentLeft(seg.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3848
			columnRight = colContentRight(seg.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3849
			columnWidth = columnRight - columnLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3850
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3851
			// shave off space on right near scrollbars (2.5%)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3852
			// TODO: move this to CSS somehow
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3853
			columnRight -= columnWidth * .025;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3854
			columnWidth = columnRight - columnLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3855
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3856
			width = columnWidth * (seg.forwardCoord - seg.backwardCoord);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3857
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3858
			if (opt('slotEventOverlap')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3859
				// double the width while making sure resize handle is visible
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3860
				// (assumed to be 20px wide)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3861
				width = Math.max(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3862
					(width - (20/2)) * 2,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3863
					width // narrow columns will want to make the segment smaller than
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3864
						// the natural width. don't allow it
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3865
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3866
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3867
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3868
			if (isRTL) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3869
				right = columnRight - seg.backwardCoord * columnWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3870
				left = right - width;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3871
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3872
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3873
				left = columnLeft + seg.backwardCoord * columnWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3874
				right = left + width;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3875
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3876
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3877
			// make sure horizontal coordinates are in bounds
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3878
			left = Math.max(left, columnLeft);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3879
			right = Math.min(right, columnRight);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3880
			width = right - left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3881
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3882
			seg.top = top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3883
			seg.left = left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3884
			seg.outerWidth = width;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3885
			seg.outerHeight = bottom - top;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3886
			html += slotSegHtml(event, seg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3887
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3888
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3889
		slotSegmentContainer[0].innerHTML = html; // faster than html()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3890
		eventElements = slotSegmentContainer.children();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3891
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3892
		// retrieve elements, run through eventRender callback, bind event handlers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3893
		for (i=0; i<segCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3894
			seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3895
			event = seg.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3896
			eventElement = $(eventElements[i]); // faster than eq()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3897
			triggerRes = trigger('eventRender', event, event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3898
			if (triggerRes === false) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3899
				eventElement.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3900
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3901
				if (triggerRes && triggerRes !== true) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3902
					eventElement.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3903
					eventElement = $(triggerRes)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3904
						.css({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3905
							position: 'absolute',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3906
							top: seg.top,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3907
							left: seg.left
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3908
						})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3909
						.appendTo(slotSegmentContainer);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3910
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3911
				seg.element = eventElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3912
				if (event._id === modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3913
					bindSlotSeg(event, eventElement, seg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3914
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3915
					eventElement[0]._fci = i; // for lazySegBind
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3916
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3917
				reportEventElement(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3918
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3919
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3920
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3921
		lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3922
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3923
		// record event sides and title positions
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3924
		for (i=0; i<segCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3925
			seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3926
			if (eventElement = seg.element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3927
				seg.vsides = vsides(eventElement, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3928
				seg.hsides = hsides(eventElement, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3929
				titleElement = eventElement.find('.fc-event-title');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3930
				if (titleElement.length) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3931
					seg.contentTop = titleElement[0].offsetTop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3932
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3933
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3934
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3935
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3936
		// set all positions/dimensions at once
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3937
		for (i=0; i<segCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3938
			seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3939
			if (eventElement = seg.element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3940
				eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3941
				height = Math.max(0, seg.outerHeight - seg.vsides);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3942
				eventElement[0].style.height = height + 'px';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3943
				event = seg.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3944
				if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3945
					// not enough room for title, put it in the time (TODO: maybe make both display:inline instead)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3946
					eventElement.find('div.fc-event-time')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3947
						.text(formatDate(event.start, opt('timeFormat')) + ' - ' + event.title);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3948
					eventElement.find('div.fc-event-title')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3949
						.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3950
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3951
				trigger('eventAfterRender', event, event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3952
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3953
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3954
					
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3955
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3956
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3957
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3958
	function slotSegHtml(event, seg) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3959
		var html = "<";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3960
		var url = event.url;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3961
		var skinCss = getSkinCss(event, opt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3962
		var classes = ['fc-event', 'fc-event-vert'];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3963
		if (isEventDraggable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3964
			classes.push('fc-event-draggable');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3965
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3966
		if (seg.isStart) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3967
			classes.push('fc-event-start');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3968
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3969
		if (seg.isEnd) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3970
			classes.push('fc-event-end');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3971
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3972
		classes = classes.concat(event.className);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3973
		if (event.source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3974
			classes = classes.concat(event.source.className || []);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3975
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3976
		if (url) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3977
			html += "a href='" + htmlEscape(event.url) + "'";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3978
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3979
			html += "div";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3980
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3981
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3982
			" class='" + classes.join(' ') + "'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3983
			" style=" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3984
				"'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3985
				"position:absolute;" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3986
				"top:" + seg.top + "px;" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3987
				"left:" + seg.left + "px;" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3988
				skinCss +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3989
				"'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3990
			">" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3991
			"<div class='fc-event-inner'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3992
			"<div class='fc-event-time'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3993
			htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3994
			"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3995
			"<div class='fc-event-title'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3996
			htmlEscape(event.title || '') +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3997
			"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3998
			"</div>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  3999
			"<div class='fc-event-bg'></div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4000
		if (seg.isEnd && isEventResizable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4001
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4002
				"<div class='ui-resizable-handle ui-resizable-s'>=</div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4003
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4004
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4005
			"</" + (url ? "a" : "div") + ">";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4006
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4007
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4008
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4009
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4010
	function bindSlotSeg(event, eventElement, seg) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4011
		var timeElement = eventElement.find('div.fc-event-time');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4012
		if (isEventDraggable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4013
			draggableSlotEvent(event, eventElement, timeElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4014
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4015
		if (seg.isEnd && isEventResizable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4016
			resizableSlotEvent(event, eventElement, timeElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4017
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4018
		eventElementHandlers(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4019
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4020
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4021
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4022
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4023
	/* Dragging
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4024
	-----------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4025
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4026
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4027
	// when event starts out FULL-DAY
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4028
	// overrides DayEventRenderer's version because it needs to account for dragging elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4029
	// to and from the slot area.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4030
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4031
	function draggableDayEvent(event, eventElement, seg) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4032
		var isStart = seg.isStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4033
		var origWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4034
		var revert;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4035
		var allDay = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4036
		var dayDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4037
		var hoverListener = getHoverListener();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4038
		var colWidth = getColWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4039
		var snapHeight = getSnapHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4040
		var snapMinutes = getSnapMinutes();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4041
		var minMinute = getMinMinute();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4042
		eventElement.draggable({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4043
			opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4044
			revertDuration: opt('dragRevertDuration'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4045
			start: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4046
				trigger('eventDragStart', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4047
				hideEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4048
				origWidth = eventElement.width();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4049
				hoverListener.start(function(cell, origCell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4050
					clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4051
					if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4052
						revert = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4053
						var origDate = cellToDate(0, origCell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4054
						var date = cellToDate(0, cell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4055
						dayDelta = dayDiff(date, origDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4056
						if (!cell.row) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4057
							// on full-days
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4058
							renderDayOverlay(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4059
								addDays(cloneDate(event.start), dayDelta),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4060
								addDays(exclEndDay(event), dayDelta)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4061
							);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4062
							resetElement();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4063
						}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4064
							// mouse is over bottom slots
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4065
							if (isStart) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4066
								if (allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4067
									// convert event to temporary slot-event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4068
									eventElement.width(colWidth - 10); // don't use entire width
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4069
									setOuterHeight(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4070
										eventElement,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4071
										snapHeight * Math.round(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4072
											(event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) /
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4073
												snapMinutes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4074
										)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4075
									);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4076
									eventElement.draggable('option', 'grid', [colWidth, 1]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4077
									allDay = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4078
								}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4079
							}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4080
								revert = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4081
							}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4082
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4083
						revert = revert || (allDay && !dayDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4084
					}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4085
						resetElement();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4086
						revert = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4087
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4088
					eventElement.draggable('option', 'revert', revert);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4089
				}, ev, 'drag');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4090
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4091
			stop: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4092
				hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4093
				clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4094
				trigger('eventDragStop', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4095
				if (revert) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4096
					// hasn't moved or is out of bounds (draggable has already reverted)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4097
					resetElement();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4098
					eventElement.css('filter', ''); // clear IE opacity side-effects
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4099
					showEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4100
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4101
					// changed!
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4102
					var minuteDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4103
					if (!allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4104
						minuteDelta = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4105
							* snapMinutes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4106
							+ minMinute
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4107
							- (event.start.getHours() * 60 + event.start.getMinutes());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4108
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4109
					eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4110
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4111
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4112
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4113
		function resetElement() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4114
			if (!allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4115
				eventElement
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4116
					.width(origWidth)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4117
					.height('')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4118
					.draggable('option', 'grid', null);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4119
				allDay = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4120
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4121
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4122
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4123
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4124
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4125
	// when event starts out IN TIMESLOTS
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4126
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4127
	function draggableSlotEvent(event, eventElement, timeElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4128
		var coordinateGrid = t.getCoordinateGrid();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4129
		var colCnt = getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4130
		var colWidth = getColWidth();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4131
		var snapHeight = getSnapHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4132
		var snapMinutes = getSnapMinutes();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4133
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4134
		// states
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4135
		var origPosition; // original position of the element, not the mouse
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4136
		var origCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4137
		var isInBounds, prevIsInBounds;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4138
		var isAllDay, prevIsAllDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4139
		var colDelta, prevColDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4140
		var dayDelta; // derived from colDelta
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4141
		var minuteDelta, prevMinuteDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4142
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4143
		eventElement.draggable({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4144
			scroll: false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4145
			grid: [ colWidth, snapHeight ],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4146
			axis: colCnt==1 ? 'y' : false,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4147
			opacity: opt('dragOpacity'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4148
			revertDuration: opt('dragRevertDuration'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4149
			start: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4150
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4151
				trigger('eventDragStart', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4152
				hideEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4153
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4154
				coordinateGrid.build();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4155
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4156
				// initialize states
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4157
				origPosition = eventElement.position();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4158
				origCell = coordinateGrid.cell(ev.pageX, ev.pageY);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4159
				isInBounds = prevIsInBounds = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4160
				isAllDay = prevIsAllDay = getIsCellAllDay(origCell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4161
				colDelta = prevColDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4162
				dayDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4163
				minuteDelta = prevMinuteDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4164
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4165
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4166
			drag: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4167
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4168
				// NOTE: this `cell` value is only useful for determining in-bounds and all-day.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4169
				// Bad for anything else due to the discrepancy between the mouse position and the
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4170
				// element position while snapping. (problem revealed in PR #55)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4171
				//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4172
				// PS- the problem exists for draggableDayEvent() when dragging an all-day event to a slot event.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4173
				// We should overhaul the dragging system and stop relying on jQuery UI.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4174
				var cell = coordinateGrid.cell(ev.pageX, ev.pageY);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4175
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4176
				// update states
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4177
				isInBounds = !!cell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4178
				if (isInBounds) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4179
					isAllDay = getIsCellAllDay(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4180
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4181
					// calculate column delta
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4182
					colDelta = Math.round((ui.position.left - origPosition.left) / colWidth);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4183
					if (colDelta != prevColDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4184
						// calculate the day delta based off of the original clicked column and the column delta
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4185
						var origDate = cellToDate(0, origCell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4186
						var col = origCell.col + colDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4187
						col = Math.max(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4188
						col = Math.min(colCnt-1, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4189
						var date = cellToDate(0, col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4190
						dayDelta = dayDiff(date, origDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4191
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4192
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4193
					// calculate minute delta (only if over slots)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4194
					if (!isAllDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4195
						minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4196
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4197
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4198
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4199
				// any state changes?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4200
				if (
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4201
					isInBounds != prevIsInBounds ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4202
					isAllDay != prevIsAllDay ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4203
					colDelta != prevColDelta ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4204
					minuteDelta != prevMinuteDelta
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4205
				) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4206
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4207
					updateUI();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4208
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4209
					// update previous states for next time
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4210
					prevIsInBounds = isInBounds;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4211
					prevIsAllDay = isAllDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4212
					prevColDelta = colDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4213
					prevMinuteDelta = minuteDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4214
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4215
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4216
				// if out-of-bounds, revert when done, and vice versa.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4217
				eventElement.draggable('option', 'revert', !isInBounds);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4218
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4219
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4220
			stop: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4221
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4222
				clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4223
				trigger('eventDragStop', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4224
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4225
				if (isInBounds && (isAllDay || dayDelta || minuteDelta)) { // changed!
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4226
					eventDrop(this, event, dayDelta, isAllDay ? 0 : minuteDelta, isAllDay, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4227
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4228
				else { // either no change or out-of-bounds (draggable has already reverted)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4229
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4230
					// reset states for next time, and for updateUI()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4231
					isInBounds = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4232
					isAllDay = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4233
					colDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4234
					dayDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4235
					minuteDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4236
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4237
					updateUI();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4238
					eventElement.css('filter', ''); // clear IE opacity side-effects
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4239
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4240
					// sometimes fast drags make event revert to wrong position, so reset.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4241
					// also, if we dragged the element out of the area because of snapping,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4242
					// but the *mouse* is still in bounds, we need to reset the position.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4243
					eventElement.css(origPosition);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4244
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4245
					showEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4246
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4247
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4248
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4249
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4250
		function updateUI() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4251
			clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4252
			if (isInBounds) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4253
				if (isAllDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4254
					timeElement.hide();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4255
					eventElement.draggable('option', 'grid', null); // disable grid snapping
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4256
					renderDayOverlay(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4257
						addDays(cloneDate(event.start), dayDelta),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4258
						addDays(exclEndDay(event), dayDelta)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4259
					);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4260
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4261
				else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4262
					updateTimeText(minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4263
					timeElement.css('display', ''); // show() was causing display=inline
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4264
					eventElement.draggable('option', 'grid', [colWidth, snapHeight]); // re-enable grid snapping
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4265
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4266
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4267
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4268
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4269
		function updateTimeText(minuteDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4270
			var newStart = addMinutes(cloneDate(event.start), minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4271
			var newEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4272
			if (event.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4273
				newEnd = addMinutes(cloneDate(event.end), minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4274
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4275
			timeElement.text(formatDates(newStart, newEnd, opt('timeFormat')));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4276
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4277
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4278
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4279
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4280
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4281
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4282
	/* Resizing
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4283
	--------------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4284
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4285
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4286
	function resizableSlotEvent(event, eventElement, timeElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4287
		var snapDelta, prevSnapDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4288
		var snapHeight = getSnapHeight();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4289
		var snapMinutes = getSnapMinutes();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4290
		eventElement.resizable({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4291
			handles: {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4292
				s: '.ui-resizable-handle'
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4293
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4294
			grid: snapHeight,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4295
			start: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4296
				snapDelta = prevSnapDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4297
				hideEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4298
				trigger('eventResizeStart', this, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4299
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4300
			resize: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4301
				// don't rely on ui.size.height, doesn't take grid into account
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4302
				snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4303
				if (snapDelta != prevSnapDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4304
					timeElement.text(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4305
						formatDates(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4306
							event.start,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4307
							(!snapDelta && !event.end) ? null : // no change, so don't display time range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4308
								addMinutes(eventEnd(event), snapMinutes*snapDelta),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4309
							opt('timeFormat')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4310
						)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4311
					);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4312
					prevSnapDelta = snapDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4313
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4314
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4315
			stop: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4316
				trigger('eventResizeStop', this, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4317
				if (snapDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4318
					eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4319
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4320
					showEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4321
					// BUG: if event was really short, need to put title back in span
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4322
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4323
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4324
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4325
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4326
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4327
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4328
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4329
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4330
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4331
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4332
/* Agenda Event Segment Utilities
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4333
-----------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4334
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4335
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4336
// Sets the seg.backwardCoord and seg.forwardCoord on each segment and returns a new
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4337
// list in the order they should be placed into the DOM (an implicit z-index).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4338
function placeSlotSegs(segs) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4339
	var levels = buildSlotSegLevels(segs);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4340
	var level0 = levels[0];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4341
	var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4342
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4343
	computeForwardSlotSegs(levels);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4344
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4345
	if (level0) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4346
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4347
		for (i=0; i<level0.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4348
			computeSlotSegPressures(level0[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4349
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4350
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4351
		for (i=0; i<level0.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4352
			computeSlotSegCoords(level0[i], 0, 0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4353
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4354
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4355
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4356
	return flattenSlotSegLevels(levels);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4357
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4358
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4359
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4360
// Builds an array of segments "levels". The first level will be the leftmost tier of segments
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4361
// if the calendar is left-to-right, or the rightmost if the calendar is right-to-left.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4362
function buildSlotSegLevels(segs) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4363
	var levels = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4364
	var i, seg;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4365
	var j;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4366
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4367
	for (i=0; i<segs.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4368
		seg = segs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4369
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4370
		// go through all the levels and stop on the first level where there are no collisions
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4371
		for (j=0; j<levels.length; j++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4372
			if (!computeSlotSegCollisions(seg, levels[j]).length) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4373
				break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4374
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4375
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4376
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4377
		(levels[j] || (levels[j] = [])).push(seg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4378
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4379
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4380
	return levels;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4381
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4382
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4383
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4384
// For every segment, figure out the other segments that are in subsequent
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4385
// levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4386
function computeForwardSlotSegs(levels) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4387
	var i, level;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4388
	var j, seg;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4389
	var k;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4390
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4391
	for (i=0; i<levels.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4392
		level = levels[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4393
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4394
		for (j=0; j<level.length; j++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4395
			seg = level[j];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4396
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4397
			seg.forwardSegs = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4398
			for (k=i+1; k<levels.length; k++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4399
				computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4400
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4401
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4402
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4403
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4404
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4405
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4406
// Figure out which path forward (via seg.forwardSegs) results in the longest path until
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4407
// the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4408
function computeSlotSegPressures(seg) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4409
	var forwardSegs = seg.forwardSegs;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4410
	var forwardPressure = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4411
	var i, forwardSeg;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4412
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4413
	if (seg.forwardPressure === undefined) { // not already computed
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4414
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4415
		for (i=0; i<forwardSegs.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4416
			forwardSeg = forwardSegs[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4417
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4418
			// figure out the child's maximum forward path
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4419
			computeSlotSegPressures(forwardSeg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4420
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4421
			// either use the existing maximum, or use the child's forward pressure
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4422
			// plus one (for the forwardSeg itself)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4423
			forwardPressure = Math.max(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4424
				forwardPressure,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4425
				1 + forwardSeg.forwardPressure
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4426
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4427
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4428
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4429
		seg.forwardPressure = forwardPressure;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4430
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4431
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4432
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4433
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4434
// Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4435
// from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4436
// seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4437
//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4438
// The segment might be part of a "series", which means consecutive segments with the same pressure
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4439
// who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4440
// segments behind this one in the current series, and `seriesBackwardCoord` is the starting
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4441
// coordinate of the first segment in the series.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4442
function computeSlotSegCoords(seg, seriesBackwardPressure, seriesBackwardCoord) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4443
	var forwardSegs = seg.forwardSegs;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4444
	var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4445
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4446
	if (seg.forwardCoord === undefined) { // not already computed
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4447
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4448
		if (!forwardSegs.length) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4449
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4450
			// if there are no forward segments, this segment should butt up against the edge
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4451
			seg.forwardCoord = 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4452
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4453
		else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4454
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4455
			// sort highest pressure first
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4456
			forwardSegs.sort(compareForwardSlotSegs);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4457
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4458
			// this segment's forwardCoord will be calculated from the backwardCoord of the
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4459
			// highest-pressure forward segment.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4460
			computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4461
			seg.forwardCoord = forwardSegs[0].backwardCoord;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4462
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4463
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4464
		// calculate the backwardCoord from the forwardCoord. consider the series
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4465
		seg.backwardCoord = seg.forwardCoord -
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4466
			(seg.forwardCoord - seriesBackwardCoord) / // available width for series
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4467
			(seriesBackwardPressure + 1); // # of segments in the series
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4468
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4469
		// use this segment's coordinates to computed the coordinates of the less-pressurized
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4470
		// forward segments
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4471
		for (i=0; i<forwardSegs.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4472
			computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4473
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4474
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4475
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4476
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4477
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4478
// Outputs a flat array of segments, from lowest to highest level
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4479
function flattenSlotSegLevels(levels) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4480
	var segs = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4481
	var i, level;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4482
	var j;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4483
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4484
	for (i=0; i<levels.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4485
		level = levels[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4486
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4487
		for (j=0; j<level.length; j++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4488
			segs.push(level[j]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4489
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4490
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4491
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4492
	return segs;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4493
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4494
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4495
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4496
// Find all the segments in `otherSegs` that vertically collide with `seg`.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4497
// Append into an optionally-supplied `results` array and return.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4498
function computeSlotSegCollisions(seg, otherSegs, results) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4499
	results = results || [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4500
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4501
	for (var i=0; i<otherSegs.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4502
		if (isSlotSegCollision(seg, otherSegs[i])) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4503
			results.push(otherSegs[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4504
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4505
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4506
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4507
	return results;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4508
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4509
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4510
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4511
// Do these segments occupy the same vertical space?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4512
function isSlotSegCollision(seg1, seg2) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4513
	return seg1.end > seg2.start && seg1.start < seg2.end;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4514
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4515
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4516
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4517
// A cmp function for determining which forward segment to rely on more when computing coordinates.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4518
function compareForwardSlotSegs(seg1, seg2) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4519
	// put higher-pressure first
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4520
	return seg2.forwardPressure - seg1.forwardPressure ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4521
		// put segments that are closer to initial edge first (and favor ones with no coords yet)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4522
		(seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4523
		// do normal sorting...
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4524
		compareSlotSegs(seg1, seg2);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4525
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4526
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4527
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4528
// A cmp function for determining which segment should be closer to the initial edge
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4529
// (the left edge on a left-to-right calendar).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4530
function compareSlotSegs(seg1, seg2) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4531
	return seg1.start - seg2.start || // earlier start time goes first
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4532
		(seg2.end - seg2.start) - (seg1.end - seg1.start) || // tie? longer-duration goes first
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4533
		(seg1.event.title || '').localeCompare(seg2.event.title); // tie? alphabetically by title
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4534
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4535
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4536
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4537
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4538
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4539
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4540
function View(element, calendar, viewName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4541
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4542
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4543
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4544
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4545
	t.element = element;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4546
	t.calendar = calendar;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4547
	t.name = viewName;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4548
	t.opt = opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4549
	t.trigger = trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4550
	t.isEventDraggable = isEventDraggable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4551
	t.isEventResizable = isEventResizable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4552
	t.setEventData = setEventData;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4553
	t.clearEventData = clearEventData;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4554
	t.eventEnd = eventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4555
	t.reportEventElement = reportEventElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4556
	t.triggerEventDestroy = triggerEventDestroy;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4557
	t.eventElementHandlers = eventElementHandlers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4558
	t.showEvents = showEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4559
	t.hideEvents = hideEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4560
	t.eventDrop = eventDrop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4561
	t.eventResize = eventResize;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4562
	// t.title
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4563
	// t.start, t.end
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4564
	// t.visStart, t.visEnd
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4565
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4566
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4567
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4568
	var defaultEventEnd = t.defaultEventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4569
	var normalizeEvent = calendar.normalizeEvent; // in EventManager
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4570
	var reportEventChange = calendar.reportEventChange;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4571
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4572
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4573
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4574
	var eventsByID = {}; // eventID mapped to array of events (there can be multiple b/c of repeating events)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4575
	var eventElementsByID = {}; // eventID mapped to array of jQuery elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4576
	var eventElementCouples = []; // array of objects, { event, element } // TODO: unify with segment system
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4577
	var options = calendar.options;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4578
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4579
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4580
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4581
	function opt(name, viewNameOverride) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4582
		var v = options[name];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4583
		if ($.isPlainObject(v)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4584
			return smartProperty(v, viewNameOverride || viewName);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4585
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4586
		return v;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4587
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4588
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4589
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4590
	function trigger(name, thisObj) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4591
		return calendar.trigger.apply(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4592
			calendar,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4593
			[name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4594
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4595
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4596
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4597
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4598
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4599
	/* Event Editable Boolean Calculations
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4600
	------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4601
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4602
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4603
	function isEventDraggable(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4604
		var source = event.source || {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4605
		return firstDefined(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4606
				event.startEditable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4607
				source.startEditable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4608
				opt('eventStartEditable'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4609
				event.editable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4610
				source.editable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4611
				opt('editable')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4612
			)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4613
			&& !opt('disableDragging'); // deprecated
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4614
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4615
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4616
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4617
	function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4618
		var source = event.source || {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4619
		return firstDefined(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4620
				event.durationEditable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4621
				source.durationEditable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4622
				opt('eventDurationEditable'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4623
				event.editable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4624
				source.editable,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4625
				opt('editable')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4626
			)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4627
			&& !opt('disableResizing'); // deprecated
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4628
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4629
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4630
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4631
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4632
	/* Event Data
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4633
	------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4634
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4635
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4636
	function setEventData(events) { // events are already normalized at this point
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4637
		eventsByID = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4638
		var i, len=events.length, event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4639
		for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4640
			event = events[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4641
			if (eventsByID[event._id]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4642
				eventsByID[event._id].push(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4643
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4644
				eventsByID[event._id] = [event];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4645
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4646
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4647
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4648
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4649
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4650
	function clearEventData() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4651
		eventsByID = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4652
		eventElementsByID = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4653
		eventElementCouples = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4654
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4655
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4656
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4657
	// returns a Date object for an event's end
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4658
	function eventEnd(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4659
		return event.end ? cloneDate(event.end) : defaultEventEnd(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4660
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4661
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4662
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4663
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4664
	/* Event Elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4665
	------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4666
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4667
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4668
	// report when view creates an element for an event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4669
	function reportEventElement(event, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4670
		eventElementCouples.push({ event: event, element: element });
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4671
		if (eventElementsByID[event._id]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4672
			eventElementsByID[event._id].push(element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4673
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4674
			eventElementsByID[event._id] = [element];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4675
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4676
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4677
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4678
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4679
	function triggerEventDestroy() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4680
		$.each(eventElementCouples, function(i, couple) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4681
			t.trigger('eventDestroy', couple.event, couple.event, couple.element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4682
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4683
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4684
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4685
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4686
	// attaches eventClick, eventMouseover, eventMouseout
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4687
	function eventElementHandlers(event, eventElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4688
		eventElement
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4689
			.click(function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4690
				if (!eventElement.hasClass('ui-draggable-dragging') &&
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4691
					!eventElement.hasClass('ui-resizable-resizing')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4692
						return trigger('eventClick', this, event, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4693
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4694
			})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4695
			.hover(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4696
				function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4697
					trigger('eventMouseover', this, event, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4698
				},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4699
				function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4700
					trigger('eventMouseout', this, event, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4701
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4702
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4703
		// TODO: don't fire eventMouseover/eventMouseout *while* dragging is occuring (on subject element)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4704
		// TODO: same for resizing
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4705
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4706
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4707
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4708
	function showEvents(event, exceptElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4709
		eachEventElement(event, exceptElement, 'show');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4710
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4711
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4712
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4713
	function hideEvents(event, exceptElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4714
		eachEventElement(event, exceptElement, 'hide');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4715
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4716
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4717
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4718
	function eachEventElement(event, exceptElement, funcName) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4719
		// NOTE: there may be multiple events per ID (repeating events)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4720
		// and multiple segments per event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4721
		var elements = eventElementsByID[event._id],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4722
			i, len = elements.length;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4723
		for (i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4724
			if (!exceptElement || elements[i][0] != exceptElement[0]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4725
				elements[i][funcName]();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4726
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4727
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4728
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4729
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4730
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4731
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4732
	/* Event Modification Reporting
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4733
	---------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4734
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4735
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4736
	function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4737
		var oldAllDay = event.allDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4738
		var eventId = event._id;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4739
		moveEvents(eventsByID[eventId], dayDelta, minuteDelta, allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4740
		trigger(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4741
			'eventDrop',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4742
			e,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4743
			event,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4744
			dayDelta,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4745
			minuteDelta,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4746
			allDay,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4747
			function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4748
				// TODO: investigate cases where this inverse technique might not work
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4749
				moveEvents(eventsByID[eventId], -dayDelta, -minuteDelta, oldAllDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4750
				reportEventChange(eventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4751
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4752
			ev,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4753
			ui
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4754
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4755
		reportEventChange(eventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4756
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4757
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4758
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4759
	function eventResize(e, event, dayDelta, minuteDelta, ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4760
		var eventId = event._id;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4761
		elongateEvents(eventsByID[eventId], dayDelta, minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4762
		trigger(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4763
			'eventResize',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4764
			e,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4765
			event,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4766
			dayDelta,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4767
			minuteDelta,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4768
			function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4769
				// TODO: investigate cases where this inverse technique might not work
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4770
				elongateEvents(eventsByID[eventId], -dayDelta, -minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4771
				reportEventChange(eventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4772
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4773
			ev,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4774
			ui
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4775
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4776
		reportEventChange(eventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4777
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4778
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4779
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4780
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4781
	/* Event Modification Math
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4782
	---------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4783
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4784
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4785
	function moveEvents(events, dayDelta, minuteDelta, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4786
		minuteDelta = minuteDelta || 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4787
		for (var e, len=events.length, i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4788
			e = events[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4789
			if (allDay !== undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4790
				e.allDay = allDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4791
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4792
			addMinutes(addDays(e.start, dayDelta, true), minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4793
			if (e.end) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4794
				e.end = addMinutes(addDays(e.end, dayDelta, true), minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4795
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4796
			normalizeEvent(e, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4797
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4798
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4799
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4800
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4801
	function elongateEvents(events, dayDelta, minuteDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4802
		minuteDelta = minuteDelta || 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4803
		for (var e, len=events.length, i=0; i<len; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4804
			e = events[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4805
			e.end = addMinutes(addDays(eventEnd(e), dayDelta, true), minuteDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4806
			normalizeEvent(e, options);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4807
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4808
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4809
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4810
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4811
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4812
	// ====================================================================================================
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4813
	// Utilities for day "cells"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4814
	// ====================================================================================================
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4815
	// The "basic" views are completely made up of day cells.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4816
	// The "agenda" views have day cells at the top "all day" slot.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4817
	// This was the obvious common place to put these utilities, but they should be abstracted out into
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4818
	// a more meaningful class (like DayEventRenderer).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4819
	// ====================================================================================================
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4820
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4821
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4822
	// For determining how a given "cell" translates into a "date":
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4823
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4824
	// 1. Convert the "cell" (row and column) into a "cell offset" (the # of the cell, cronologically from the first).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4825
	//    Keep in mind that column indices are inverted with isRTL. This is taken into account.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4826
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4827
	// 2. Convert the "cell offset" to a "day offset" (the # of days since the first visible day in the view).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4828
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4829
	// 3. Convert the "day offset" into a "date" (a JavaScript Date object).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4830
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4831
	// The reverse transformation happens when transforming a date into a cell.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4832
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4833
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4834
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4835
	t.isHiddenDay = isHiddenDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4836
	t.skipHiddenDays = skipHiddenDays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4837
	t.getCellsPerWeek = getCellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4838
	t.dateToCell = dateToCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4839
	t.dateToDayOffset = dateToDayOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4840
	t.dayOffsetToCellOffset = dayOffsetToCellOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4841
	t.cellOffsetToCell = cellOffsetToCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4842
	t.cellToDate = cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4843
	t.cellToCellOffset = cellToCellOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4844
	t.cellOffsetToDayOffset = cellOffsetToDayOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4845
	t.dayOffsetToDate = dayOffsetToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4846
	t.rangeToSegments = rangeToSegments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4847
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4848
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4849
	// internals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4850
	var hiddenDays = opt('hiddenDays') || []; // array of day-of-week indices that are hidden
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4851
	var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4852
	var cellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4853
	var dayToCellMap = []; // hash from dayIndex -> cellIndex, for one week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4854
	var cellToDayMap = []; // hash from cellIndex -> dayIndex, for one week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4855
	var isRTL = opt('isRTL');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4856
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4857
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4858
	// initialize important internal variables
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4859
	(function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4860
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4861
		if (opt('weekends') === false) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4862
			hiddenDays.push(0, 6); // 0=sunday, 6=saturday
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4863
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4864
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4865
		// Loop through a hypothetical week and determine which
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4866
		// days-of-week are hidden. Record in both hashes (one is the reverse of the other).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4867
		for (var dayIndex=0, cellIndex=0; dayIndex<7; dayIndex++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4868
			dayToCellMap[dayIndex] = cellIndex;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4869
			isHiddenDayHash[dayIndex] = $.inArray(dayIndex, hiddenDays) != -1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4870
			if (!isHiddenDayHash[dayIndex]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4871
				cellToDayMap[cellIndex] = dayIndex;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4872
				cellIndex++;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4873
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4874
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4875
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4876
		cellsPerWeek = cellIndex;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4877
		if (!cellsPerWeek) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4878
			throw 'invalid hiddenDays'; // all days were hidden? bad.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4879
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4880
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4881
	})();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4882
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4883
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4884
	// Is the current day hidden?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4885
	// `day` is a day-of-week index (0-6), or a Date object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4886
	function isHiddenDay(day) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4887
		if (typeof day == 'object') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4888
			day = day.getDay();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4889
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4890
		return isHiddenDayHash[day];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4891
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4892
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4893
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4894
	function getCellsPerWeek() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4895
		return cellsPerWeek;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4896
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4897
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4898
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4899
	// Keep incrementing the current day until it is no longer a hidden day.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4900
	// If the initial value of `date` is not a hidden day, don't do anything.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4901
	// Pass `isExclusive` as `true` if you are dealing with an end date.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4902
	// `inc` defaults to `1` (increment one day forward each time)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4903
	function skipHiddenDays(date, inc, isExclusive) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4904
		inc = inc || 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4905
		while (
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4906
			isHiddenDayHash[ ( date.getDay() + (isExclusive ? inc : 0) + 7 ) % 7 ]
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4907
		) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4908
			addDays(date, inc);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4909
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4910
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4911
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4912
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4913
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4914
	// TRANSFORMATIONS: cell -> cell offset -> day offset -> date
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4915
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4916
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4917
	// cell -> date (combines all transformations)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4918
	// Possible arguments:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4919
	// - row, col
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4920
	// - { row:#, col: # }
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4921
	function cellToDate() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4922
		var cellOffset = cellToCellOffset.apply(null, arguments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4923
		var dayOffset = cellOffsetToDayOffset(cellOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4924
		var date = dayOffsetToDate(dayOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4925
		return date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4926
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4927
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4928
	// cell -> cell offset
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4929
	// Possible arguments:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4930
	// - row, col
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4931
	// - { row:#, col:# }
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4932
	function cellToCellOffset(row, col) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4933
		var colCnt = t.getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4934
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4935
		// rtl variables. wish we could pre-populate these. but where?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4936
		var dis = isRTL ? -1 : 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4937
		var dit = isRTL ? colCnt - 1 : 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4938
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4939
		if (typeof row == 'object') {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4940
			col = row.col;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4941
			row = row.row;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4942
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4943
		var cellOffset = row * colCnt + (col * dis + dit); // column, adjusted for RTL (dis & dit)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4944
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4945
		return cellOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4946
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4947
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4948
	// cell offset -> day offset
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4949
	function cellOffsetToDayOffset(cellOffset) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4950
		var day0 = t.visStart.getDay(); // first date's day of week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4951
		cellOffset += dayToCellMap[day0]; // normlize cellOffset to beginning-of-week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4952
		return Math.floor(cellOffset / cellsPerWeek) * 7 // # of days from full weeks
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4953
			+ cellToDayMap[ // # of days from partial last week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4954
				(cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek // crazy math to handle negative cellOffsets
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4955
			]
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4956
			- day0; // adjustment for beginning-of-week normalization
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4957
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4958
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4959
	// day offset -> date (JavaScript Date object)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4960
	function dayOffsetToDate(dayOffset) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4961
		var date = cloneDate(t.visStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4962
		addDays(date, dayOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4963
		return date;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4964
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4965
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4966
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4967
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4968
	// TRANSFORMATIONS: date -> day offset -> cell offset -> cell
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4969
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4970
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4971
	// date -> cell (combines all transformations)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4972
	function dateToCell(date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4973
		var dayOffset = dateToDayOffset(date);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4974
		var cellOffset = dayOffsetToCellOffset(dayOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4975
		var cell = cellOffsetToCell(cellOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4976
		return cell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4977
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4978
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4979
	// date -> day offset
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4980
	function dateToDayOffset(date) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4981
		return dayDiff(date, t.visStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4982
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4983
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4984
	// day offset -> cell offset
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4985
	function dayOffsetToCellOffset(dayOffset) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4986
		var day0 = t.visStart.getDay(); // first date's day of week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4987
		dayOffset += day0; // normalize dayOffset to beginning-of-week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4988
		return Math.floor(dayOffset / 7) * cellsPerWeek // # of cells from full weeks
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4989
			+ dayToCellMap[ // # of cells from partial last week
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4990
				(dayOffset % 7 + 7) % 7 // crazy math to handle negative dayOffsets
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4991
			]
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4992
			- dayToCellMap[day0]; // adjustment for beginning-of-week normalization
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4993
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4994
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4995
	// cell offset -> cell (object with row & col keys)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4996
	function cellOffsetToCell(cellOffset) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4997
		var colCnt = t.getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4998
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  4999
		// rtl variables. wish we could pre-populate these. but where?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5000
		var dis = isRTL ? -1 : 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5001
		var dit = isRTL ? colCnt - 1 : 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5002
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5003
		var row = Math.floor(cellOffset / colCnt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5004
		var col = ((cellOffset % colCnt + colCnt) % colCnt) * dis + dit; // column, adjusted for RTL (dis & dit)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5005
		return {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5006
			row: row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5007
			col: col
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5008
		};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5009
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5010
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5011
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5012
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5013
	// Converts a date range into an array of segment objects.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5014
	// "Segments" are horizontal stretches of time, sliced up by row.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5015
	// A segment object has the following properties:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5016
	// - row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5017
	// - cols
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5018
	// - isStart
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5019
	// - isEnd
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5020
	//
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5021
	function rangeToSegments(startDate, endDate) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5022
		var rowCnt = t.getRowCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5023
		var colCnt = t.getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5024
		var segments = []; // array of segments to return
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5025
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5026
		// day offset for given date range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5027
		var rangeDayOffsetStart = dateToDayOffset(startDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5028
		var rangeDayOffsetEnd = dateToDayOffset(endDate); // exclusive
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5029
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5030
		// first and last cell offset for the given date range
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5031
		// "last" implies inclusivity
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5032
		var rangeCellOffsetFirst = dayOffsetToCellOffset(rangeDayOffsetStart);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5033
		var rangeCellOffsetLast = dayOffsetToCellOffset(rangeDayOffsetEnd) - 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5034
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5035
		// loop through all the rows in the view
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5036
		for (var row=0; row<rowCnt; row++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5037
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5038
			// first and last cell offset for the row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5039
			var rowCellOffsetFirst = row * colCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5040
			var rowCellOffsetLast = rowCellOffsetFirst + colCnt - 1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5041
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5042
			// get the segment's cell offsets by constraining the range's cell offsets to the bounds of the row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5043
			var segmentCellOffsetFirst = Math.max(rangeCellOffsetFirst, rowCellOffsetFirst);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5044
			var segmentCellOffsetLast = Math.min(rangeCellOffsetLast, rowCellOffsetLast);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5045
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5046
			// make sure segment's offsets are valid and in view
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5047
			if (segmentCellOffsetFirst <= segmentCellOffsetLast) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5048
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5049
				// translate to cells
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5050
				var segmentCellFirst = cellOffsetToCell(segmentCellOffsetFirst);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5051
				var segmentCellLast = cellOffsetToCell(segmentCellOffsetLast);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5052
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5053
				// view might be RTL, so order by leftmost column
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5054
				var cols = [ segmentCellFirst.col, segmentCellLast.col ].sort();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5055
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5056
				// Determine if segment's first/last cell is the beginning/end of the date range.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5057
				// We need to compare "day offset" because "cell offsets" are often ambiguous and
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5058
				// can translate to multiple days, and an edge case reveals itself when we the
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5059
				// range's first cell is hidden (we don't want isStart to be true).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5060
				var isStart = cellOffsetToDayOffset(segmentCellOffsetFirst) == rangeDayOffsetStart;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5061
				var isEnd = cellOffsetToDayOffset(segmentCellOffsetLast) + 1 == rangeDayOffsetEnd; // +1 for comparing exclusively
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5062
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5063
				segments.push({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5064
					row: row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5065
					leftCol: cols[0],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5066
					rightCol: cols[1],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5067
					isStart: isStart,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5068
					isEnd: isEnd
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5069
				});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5070
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5071
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5072
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5073
		return segments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5074
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5075
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5076
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5077
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5078
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5079
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5080
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5081
function DayEventRenderer() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5082
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5083
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5084
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5085
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5086
	t.renderDayEvents = renderDayEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5087
	t.draggableDayEvent = draggableDayEvent; // made public so that subclasses can override
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5088
	t.resizableDayEvent = resizableDayEvent; // "
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5089
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5090
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5091
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5092
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5093
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5094
	var isEventDraggable = t.isEventDraggable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5095
	var isEventResizable = t.isEventResizable;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5096
	var eventEnd = t.eventEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5097
	var reportEventElement = t.reportEventElement;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5098
	var eventElementHandlers = t.eventElementHandlers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5099
	var showEvents = t.showEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5100
	var hideEvents = t.hideEvents;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5101
	var eventDrop = t.eventDrop;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5102
	var eventResize = t.eventResize;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5103
	var getRowCnt = t.getRowCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5104
	var getColCnt = t.getColCnt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5105
	var getColWidth = t.getColWidth;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5106
	var allDayRow = t.allDayRow; // TODO: rename
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5107
	var colLeft = t.colLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5108
	var colRight = t.colRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5109
	var colContentLeft = t.colContentLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5110
	var colContentRight = t.colContentRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5111
	var dateToCell = t.dateToCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5112
	var getDaySegmentContainer = t.getDaySegmentContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5113
	var formatDates = t.calendar.formatDates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5114
	var renderDayOverlay = t.renderDayOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5115
	var clearOverlays = t.clearOverlays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5116
	var clearSelection = t.clearSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5117
	var getHoverListener = t.getHoverListener;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5118
	var rangeToSegments = t.rangeToSegments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5119
	var cellToDate = t.cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5120
	var cellToCellOffset = t.cellToCellOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5121
	var cellOffsetToDayOffset = t.cellOffsetToDayOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5122
	var dateToDayOffset = t.dateToDayOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5123
	var dayOffsetToCellOffset = t.dayOffsetToCellOffset;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5124
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5125
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5126
	// Render `events` onto the calendar, attach mouse event handlers, and call the `eventAfterRender` callback for each.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5127
	// Mouse event will be lazily applied, except if the event has an ID of `modifiedEventId`.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5128
	// Can only be called when the event container is empty (because it wipes out all innerHTML).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5129
	function renderDayEvents(events, modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5130
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5131
		// do the actual rendering. Receive the intermediate "segment" data structures.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5132
		var segments = _renderDayEvents(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5133
			events,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5134
			false, // don't append event elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5135
			true // set the heights of the rows
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5136
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5137
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5138
		// report the elements to the View, for general drag/resize utilities
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5139
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5140
			reportEventElement(segment.event, element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5141
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5142
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5143
		// attach mouse handlers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5144
		attachHandlers(segments, modifiedEventId);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5145
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5146
		// call `eventAfterRender` callback for each event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5147
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5148
			trigger('eventAfterRender', segment.event, segment.event, element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5149
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5150
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5151
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5152
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5153
	// Render an event on the calendar, but don't report them anywhere, and don't attach mouse handlers.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5154
	// Append this event element to the event container, which might already be populated with events.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5155
	// If an event's segment will have row equal to `adjustRow`, then explicitly set its top coordinate to `adjustTop`.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5156
	// This hack is used to maintain continuity when user is manually resizing an event.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5157
	// Returns an array of DOM elements for the event.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5158
	function renderTempDayEvent(event, adjustRow, adjustTop) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5159
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5160
		// actually render the event. `true` for appending element to container.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5161
		// Recieve the intermediate "segment" data structures.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5162
		var segments = _renderDayEvents(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5163
			[ event ],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5164
			true, // append event elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5165
			false // don't set the heights of the rows
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5166
		);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5167
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5168
		var elements = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5169
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5170
		// Adjust certain elements' top coordinates
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5171
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5172
			if (segment.row === adjustRow) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5173
				element.css('top', adjustTop);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5174
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5175
			elements.push(element[0]); // accumulate DOM nodes
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5176
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5177
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5178
		return elements;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5179
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5180
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5181
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5182
	// Render events onto the calendar. Only responsible for the VISUAL aspect.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5183
	// Not responsible for attaching handlers or calling callbacks.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5184
	// Set `doAppend` to `true` for rendering elements without clearing the existing container.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5185
	// Set `doRowHeights` to allow setting the height of each row, to compensate for vertical event overflow.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5186
	function _renderDayEvents(events, doAppend, doRowHeights) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5187
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5188
		// where the DOM nodes will eventually end up
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5189
		var finalContainer = getDaySegmentContainer();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5190
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5191
		// the container where the initial HTML will be rendered.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5192
		// If `doAppend`==true, uses a temporary container.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5193
		var renderContainer = doAppend ? $("<div/>") : finalContainer;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5194
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5195
		var segments = buildSegments(events);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5196
		var html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5197
		var elements;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5198
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5199
		// calculate the desired `left` and `width` properties on each segment object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5200
		calculateHorizontals(segments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5201
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5202
		// build the HTML string. relies on `left` property
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5203
		html = buildHTML(segments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5204
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5205
		// render the HTML. innerHTML is considerably faster than jQuery's .html()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5206
		renderContainer[0].innerHTML = html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5207
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5208
		// retrieve the individual elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5209
		elements = renderContainer.children();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5210
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5211
		// if we were appending, and thus using a temporary container,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5212
		// re-attach elements to the real container.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5213
		if (doAppend) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5214
			finalContainer.append(elements);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5215
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5216
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5217
		// assigns each element to `segment.event`, after filtering them through user callbacks
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5218
		resolveElements(segments, elements);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5219
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5220
		// Calculate the left and right padding+margin for each element.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5221
		// We need this for setting each element's desired outer width, because of the W3C box model.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5222
		// It's important we do this in a separate pass from acually setting the width on the DOM elements
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5223
		// because alternating reading/writing dimensions causes reflow for every iteration.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5224
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5225
			segment.hsides = hsides(element, true); // include margins = `true`
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5226
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5227
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5228
		// Set the width of each element
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5229
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5230
			element.width(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5231
				Math.max(0, segment.outerWidth - segment.hsides)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5232
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5233
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5234
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5235
		// Grab each element's outerHeight (setVerticals uses this).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5236
		// To get an accurate reading, it's important to have each element's width explicitly set already.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5237
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5238
			segment.outerHeight = element.outerHeight(true); // include margins = `true`
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5239
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5240
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5241
		// Set the top coordinate on each element (requires segment.outerHeight)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5242
		setVerticals(segments, doRowHeights);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5243
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5244
		return segments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5245
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5246
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5247
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5248
	// Generate an array of "segments" for all events.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5249
	function buildSegments(events) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5250
		var segments = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5251
		for (var i=0; i<events.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5252
			var eventSegments = buildSegmentsForEvent(events[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5253
			segments.push.apply(segments, eventSegments); // append an array to an array
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5254
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5255
		return segments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5256
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5257
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5258
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5259
	// Generate an array of segments for a single event.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5260
	// A "segment" is the same data structure that View.rangeToSegments produces,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5261
	// with the addition of the `event` property being set to reference the original event.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5262
	function buildSegmentsForEvent(event) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5263
		var startDate = event.start;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5264
		var endDate = exclEndDay(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5265
		var segments = rangeToSegments(startDate, endDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5266
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5267
			segments[i].event = event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5268
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5269
		return segments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5270
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5271
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5272
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5273
	// Sets the `left` and `outerWidth` property of each segment.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5274
	// These values are the desired dimensions for the eventual DOM elements.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5275
	function calculateHorizontals(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5276
		var isRTL = opt('isRTL');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5277
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5278
			var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5279
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5280
			// Determine functions used for calulating the elements left/right coordinates,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5281
			// depending on whether the view is RTL or not.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5282
			// NOTE:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5283
			// colLeft/colRight returns the coordinate butting up the edge of the cell.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5284
			// colContentLeft/colContentRight is indented a little bit from the edge.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5285
			var leftFunc = (isRTL ? segment.isEnd : segment.isStart) ? colContentLeft : colLeft;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5286
			var rightFunc = (isRTL ? segment.isStart : segment.isEnd) ? colContentRight : colRight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5287
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5288
			var left = leftFunc(segment.leftCol);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5289
			var right = rightFunc(segment.rightCol);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5290
			segment.left = left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5291
			segment.outerWidth = right - left;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5292
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5293
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5294
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5295
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5296
	// Build a concatenated HTML string for an array of segments
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5297
	function buildHTML(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5298
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5299
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5300
			html += buildHTMLForSegment(segments[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5301
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5302
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5303
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5304
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5305
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5306
	// Build an HTML string for a single segment.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5307
	// Relies on the following properties:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5308
	// - `segment.event` (from `buildSegmentsForEvent`)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5309
	// - `segment.left` (from `calculateHorizontals`)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5310
	function buildHTMLForSegment(segment) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5311
		var html = '';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5312
		var isRTL = opt('isRTL');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5313
		var event = segment.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5314
		var url = event.url;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5315
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5316
		// generate the list of CSS classNames
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5317
		var classNames = [ 'fc-event', 'fc-event-hori' ];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5318
		if (isEventDraggable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5319
			classNames.push('fc-event-draggable');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5320
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5321
		if (segment.isStart) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5322
			classNames.push('fc-event-start');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5323
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5324
		if (segment.isEnd) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5325
			classNames.push('fc-event-end');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5326
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5327
		// use the event's configured classNames
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5328
		// guaranteed to be an array via `normalizeEvent`
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5329
		classNames = classNames.concat(event.className);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5330
		if (event.source) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5331
			// use the event's source's classNames, if specified
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5332
			classNames = classNames.concat(event.source.className || []);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5333
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5334
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5335
		// generate a semicolon delimited CSS string for any of the "skin" properties
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5336
		// of the event object (`backgroundColor`, `borderColor` and such)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5337
		var skinCss = getSkinCss(event, opt);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5338
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5339
		if (url) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5340
			html += "<a href='" + htmlEscape(url) + "'";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5341
		}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5342
			html += "<div";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5343
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5344
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5345
			" class='" + classNames.join(' ') + "'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5346
			" style=" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5347
				"'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5348
				"position:absolute;" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5349
				"left:" + segment.left + "px;" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5350
				skinCss +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5351
				"'" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5352
			">" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5353
			"<div class='fc-event-inner'>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5354
		if (!event.allDay && segment.isStart) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5355
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5356
				"<span class='fc-event-time'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5357
				htmlEscape(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5358
					formatDates(event.start, event.end, opt('timeFormat'))
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5359
				) +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5360
				"</span>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5361
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5362
		html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5363
			"<span class='fc-event-title'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5364
			htmlEscape(event.title || '') +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5365
			"</span>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5366
			"</div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5367
		if (segment.isEnd && isEventResizable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5368
			html +=
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5369
				"<div class='ui-resizable-handle ui-resizable-" + (isRTL ? 'w' : 'e') + "'>" +
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5370
				"&nbsp;&nbsp;&nbsp;" + // makes hit area a lot better for IE6/7
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5371
				"</div>";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5372
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5373
		html += "</" + (url ? "a" : "div") + ">";
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5374
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5375
		// TODO:
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5376
		// When these elements are initially rendered, they will be briefly visibile on the screen,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5377
		// even though their widths/heights are not set.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5378
		// SOLUTION: initially set them as visibility:hidden ?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5379
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5380
		return html;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5381
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5382
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5383
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5384
	// Associate each segment (an object) with an element (a jQuery object),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5385
	// by setting each `segment.element`.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5386
	// Run each element through the `eventRender` filter, which allows developers to
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5387
	// modify an existing element, supply a new one, or cancel rendering.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5388
	function resolveElements(segments, elements) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5389
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5390
			var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5391
			var event = segment.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5392
			var element = elements.eq(i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5393
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5394
			// call the trigger with the original element
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5395
			var triggerRes = trigger('eventRender', event, event, element);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5396
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5397
			if (triggerRes === false) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5398
				// if `false`, remove the event from the DOM and don't assign it to `segment.event`
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5399
				element.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5400
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5401
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5402
				if (triggerRes && triggerRes !== true) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5403
					// the trigger returned a new element, but not `true` (which means keep the existing element)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5404
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5405
					// re-assign the important CSS dimension properties that were already assigned in `buildHTMLForSegment`
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5406
					triggerRes = $(triggerRes)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5407
						.css({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5408
							position: 'absolute',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5409
							left: segment.left
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5410
						});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5411
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5412
					element.replaceWith(triggerRes);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5413
					element = triggerRes;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5414
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5415
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5416
				segment.element = element;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5417
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5418
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5419
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5420
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5421
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5422
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5423
	/* Top-coordinate Methods
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5424
	-------------------------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5425
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5426
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5427
	// Sets the "top" CSS property for each element.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5428
	// If `doRowHeights` is `true`, also sets each row's first cell to an explicit height,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5429
	// so that if elements vertically overflow, the cell expands vertically to compensate.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5430
	function setVerticals(segments, doRowHeights) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5431
		var rowContentHeights = calculateVerticals(segments); // also sets segment.top
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5432
		var rowContentElements = getRowContentElements(); // returns 1 inner div per row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5433
		var rowContentTops = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5434
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5435
		// Set each row's height by setting height of first inner div
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5436
		if (doRowHeights) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5437
			for (var i=0; i<rowContentElements.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5438
				rowContentElements[i].height(rowContentHeights[i]);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5439
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5440
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5441
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5442
		// Get each row's top, relative to the views's origin.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5443
		// Important to do this after setting each row's height.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5444
		for (var i=0; i<rowContentElements.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5445
			rowContentTops.push(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5446
				rowContentElements[i].position().top
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5447
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5448
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5449
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5450
		// Set each segment element's CSS "top" property.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5451
		// Each segment object has a "top" property, which is relative to the row's top, but...
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5452
		segmentElementEach(segments, function(segment, element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5453
			element.css(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5454
				'top',
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5455
				rowContentTops[segment.row] + segment.top // ...now, relative to views's origin
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5456
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5457
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5458
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5459
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5460
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5461
	// Calculate the "top" coordinate for each segment, relative to the "top" of the row.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5462
	// Also, return an array that contains the "content" height for each row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5463
	// (the height displaced by the vertically stacked events in the row).
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5464
	// Requires segments to have their `outerHeight` property already set.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5465
	function calculateVerticals(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5466
		var rowCnt = getRowCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5467
		var colCnt = getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5468
		var rowContentHeights = []; // content height for each row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5469
		var segmentRows = buildSegmentRows(segments); // an array of segment arrays, one for each row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5470
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5471
		for (var rowI=0; rowI<rowCnt; rowI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5472
			var segmentRow = segmentRows[rowI];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5473
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5474
			// an array of running total heights for each column.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5475
			// initialize with all zeros.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5476
			var colHeights = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5477
			for (var colI=0; colI<colCnt; colI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5478
				colHeights.push(0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5479
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5480
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5481
			// loop through every segment
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5482
			for (var segmentI=0; segmentI<segmentRow.length; segmentI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5483
				var segment = segmentRow[segmentI];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5484
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5485
				// find the segment's top coordinate by looking at the max height
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5486
				// of all the columns the segment will be in.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5487
				segment.top = arrayMax(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5488
					colHeights.slice(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5489
						segment.leftCol,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5490
						segment.rightCol + 1 // make exclusive for slice
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5491
					)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5492
				);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5493
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5494
				// adjust the columns to account for the segment's height
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5495
				for (var colI=segment.leftCol; colI<=segment.rightCol; colI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5496
					colHeights[colI] = segment.top + segment.outerHeight;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5497
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5498
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5499
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5500
			// the tallest column in the row should be the "content height"
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5501
			rowContentHeights.push(arrayMax(colHeights));
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5502
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5503
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5504
		return rowContentHeights;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5505
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5506
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5507
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5508
	// Build an array of segment arrays, each representing the segments that will
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5509
	// be in a row of the grid, sorted by which event should be closest to the top.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5510
	function buildSegmentRows(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5511
		var rowCnt = getRowCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5512
		var segmentRows = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5513
		var segmentI;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5514
		var segment;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5515
		var rowI;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5516
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5517
		// group segments by row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5518
		for (segmentI=0; segmentI<segments.length; segmentI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5519
			segment = segments[segmentI];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5520
			rowI = segment.row;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5521
			if (segment.element) { // was rendered?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5522
				if (segmentRows[rowI]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5523
					// already other segments. append to array
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5524
					segmentRows[rowI].push(segment);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5525
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5526
				else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5527
					// first segment in row. create new array
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5528
					segmentRows[rowI] = [ segment ];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5529
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5530
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5531
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5532
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5533
		// sort each row
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5534
		for (rowI=0; rowI<rowCnt; rowI++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5535
			segmentRows[rowI] = sortSegmentRow(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5536
				segmentRows[rowI] || [] // guarantee an array, even if no segments
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5537
			);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5538
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5539
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5540
		return segmentRows;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5541
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5542
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5543
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5544
	// Sort an array of segments according to which segment should appear closest to the top
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5545
	function sortSegmentRow(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5546
		var sortedSegments = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5547
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5548
		// build the subrow array
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5549
		var subrows = buildSegmentSubrows(segments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5550
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5551
		// flatten it
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5552
		for (var i=0; i<subrows.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5553
			sortedSegments.push.apply(sortedSegments, subrows[i]); // append an array to an array
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5554
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5555
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5556
		return sortedSegments;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5557
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5558
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5559
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5560
	// Take an array of segments, which are all assumed to be in the same row,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5561
	// and sort into subrows.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5562
	function buildSegmentSubrows(segments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5563
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5564
		// Give preference to elements with certain criteria, so they have
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5565
		// a chance to be closer to the top.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5566
		segments.sort(compareDaySegments);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5567
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5568
		var subrows = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5569
		for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5570
			var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5571
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5572
			// loop through subrows, starting with the topmost, until the segment
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5573
			// doesn't collide with other segments.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5574
			for (var j=0; j<subrows.length; j++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5575
				if (!isDaySegmentCollision(segment, subrows[j])) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5576
					break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5577
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5578
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5579
			// `j` now holds the desired subrow index
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5580
			if (subrows[j]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5581
				subrows[j].push(segment);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5582
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5583
			else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5584
				subrows[j] = [ segment ];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5585
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5586
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5587
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5588
		return subrows;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5589
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5590
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5591
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5592
	// Return an array of jQuery objects for the placeholder content containers of each row.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5593
	// The content containers don't actually contain anything, but their dimensions should match
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5594
	// the events that are overlaid on top.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5595
	function getRowContentElements() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5596
		var i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5597
		var rowCnt = getRowCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5598
		var rowDivs = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5599
		for (i=0; i<rowCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5600
			rowDivs[i] = allDayRow(i)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5601
				.find('div.fc-day-content > div');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5602
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5603
		return rowDivs;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5604
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5605
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5606
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5607
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5608
	/* Mouse Handlers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5609
	---------------------------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5610
	// TODO: better documentation!
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5611
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5612
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5613
	function attachHandlers(segments, modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5614
		var segmentContainer = getDaySegmentContainer();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5615
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5616
		segmentElementEach(segments, function(segment, element, i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5617
			var event = segment.event;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5618
			if (event._id === modifiedEventId) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5619
				bindDaySeg(event, element, segment);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5620
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5621
				element[0]._fci = i; // for lazySegBind
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5622
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5623
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5624
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5625
		lazySegBind(segmentContainer, segments, bindDaySeg);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5626
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5627
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5628
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5629
	function bindDaySeg(event, eventElement, segment) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5630
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5631
		if (isEventDraggable(event)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5632
			t.draggableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5633
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5634
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5635
		if (
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5636
			segment.isEnd && // only allow resizing on the final segment for an event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5637
			isEventResizable(event)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5638
		) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5639
			t.resizableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5640
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5641
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5642
		// attach all other handlers.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5643
		// needs to be after, because resizableDayEvent might stopImmediatePropagation on click
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5644
		eventElementHandlers(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5645
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5646
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5647
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5648
	function draggableDayEvent(event, eventElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5649
		var hoverListener = getHoverListener();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5650
		var dayDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5651
		eventElement.draggable({
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5652
			delay: 50,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5653
			opacity: opt('dragOpacity'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5654
			revertDuration: opt('dragRevertDuration'),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5655
			start: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5656
				trigger('eventDragStart', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5657
				hideEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5658
				hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5659
					eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5660
					clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5661
					if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5662
						var origDate = cellToDate(origCell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5663
						var date = cellToDate(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5664
						dayDelta = dayDiff(date, origDate);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5665
						renderDayOverlay(
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5666
							addDays(cloneDate(event.start), dayDelta),
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5667
							addDays(exclEndDay(event), dayDelta)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5668
						);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5669
					}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5670
						dayDelta = 0;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5671
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5672
				}, ev, 'drag');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5673
			},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5674
			stop: function(ev, ui) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5675
				hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5676
				clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5677
				trigger('eventDragStop', eventElement, event, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5678
				if (dayDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5679
					eventDrop(this, event, dayDelta, 0, event.allDay, ev, ui);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5680
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5681
					eventElement.css('filter', ''); // clear IE opacity side-effects
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5682
					showEvents(event, eventElement);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5683
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5684
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5685
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5686
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5687
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5688
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5689
	function resizableDayEvent(event, element, segment) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5690
		var isRTL = opt('isRTL');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5691
		var direction = isRTL ? 'w' : 'e';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5692
		var handle = element.find('.ui-resizable-' + direction); // TODO: stop using this class because we aren't using jqui for this
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5693
		var isResizing = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5694
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5695
		// TODO: look into using jquery-ui mouse widget for this stuff
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5696
		disableTextSelection(element); // prevent native <a> selection for IE
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5697
		element
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5698
			.mousedown(function(ev) { // prevent native <a> selection for others
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5699
				ev.preventDefault();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5700
			})
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5701
			.click(function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5702
				if (isResizing) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5703
					ev.preventDefault(); // prevent link from being visited (only method that worked in IE6)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5704
					ev.stopImmediatePropagation(); // prevent fullcalendar eventClick handler from being called
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5705
					                               // (eventElementHandlers needs to be bound after resizableDayEvent)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5706
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5707
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5708
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5709
		handle.mousedown(function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5710
			if (ev.which != 1) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5711
				return; // needs to be left mouse button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5712
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5713
			isResizing = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5714
			var hoverListener = getHoverListener();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5715
			var rowCnt = getRowCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5716
			var colCnt = getColCnt();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5717
			var elementTop = element.css('top');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5718
			var dayDelta;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5719
			var helpers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5720
			var eventCopy = $.extend({}, event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5721
			var minCellOffset = dayOffsetToCellOffset( dateToDayOffset(event.start) );
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5722
			clearSelection();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5723
			$('body')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5724
				.css('cursor', direction + '-resize')
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5725
				.one('mouseup', mouseup);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5726
			trigger('eventResizeStart', this, event, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5727
			hoverListener.start(function(cell, origCell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5728
				if (cell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5729
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5730
					var origCellOffset = cellToCellOffset(origCell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5731
					var cellOffset = cellToCellOffset(cell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5732
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5733
					// don't let resizing move earlier than start date cell
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5734
					cellOffset = Math.max(cellOffset, minCellOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5735
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5736
					dayDelta =
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5737
						cellOffsetToDayOffset(cellOffset) -
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5738
						cellOffsetToDayOffset(origCellOffset);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5739
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5740
					if (dayDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5741
						eventCopy.end = addDays(eventEnd(event), dayDelta, true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5742
						var oldHelpers = helpers;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5743
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5744
						helpers = renderTempDayEvent(eventCopy, segment.row, elementTop);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5745
						helpers = $(helpers); // turn array into a jQuery object
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5746
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5747
						helpers.find('*').css('cursor', direction + '-resize');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5748
						if (oldHelpers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5749
							oldHelpers.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5750
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5751
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5752
						hideEvents(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5753
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5754
					else {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5755
						if (helpers) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5756
							showEvents(event);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5757
							helpers.remove();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5758
							helpers = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5759
						}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5760
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5761
					clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5762
					renderDayOverlay( // coordinate grid already rebuilt with hoverListener.start()
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5763
						event.start,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5764
						addDays( exclEndDay(event), dayDelta )
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5765
						// TODO: instead of calling renderDayOverlay() with dates,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5766
						// call _renderDayOverlay (or whatever) with cell offsets.
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5767
					);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5768
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5769
			}, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5770
			
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5771
			function mouseup(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5772
				trigger('eventResizeStop', this, event, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5773
				$('body').css('cursor', '');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5774
				hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5775
				clearOverlays();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5776
				if (dayDelta) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5777
					eventResize(this, event, dayDelta, 0, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5778
					// event redraw will clear helpers
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5779
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5780
				// otherwise, the drag handler already restored the old events
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5781
				
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5782
				setTimeout(function() { // make this happen after the element's click event
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5783
					isResizing = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5784
				},0);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5785
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5786
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5787
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5788
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5789
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5790
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5791
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5792
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5793
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5794
/* Generalized Segment Utilities
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5795
-------------------------------------------------------------------------------------------------*/
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5796
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5797
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5798
function isDaySegmentCollision(segment, otherSegments) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5799
	for (var i=0; i<otherSegments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5800
		var otherSegment = otherSegments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5801
		if (
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5802
			otherSegment.leftCol <= segment.rightCol &&
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5803
			otherSegment.rightCol >= segment.leftCol
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5804
		) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5805
			return true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5806
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5807
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5808
	return false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5809
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5810
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5811
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5812
function segmentElementEach(segments, callback) { // TODO: use in AgendaView?
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5813
	for (var i=0; i<segments.length; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5814
		var segment = segments[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5815
		var element = segment.element;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5816
		if (element) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5817
			callback(segment, element, i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5818
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5819
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5820
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5821
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5822
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5823
// A cmp function for determining which segments should appear higher up
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5824
function compareDaySegments(a, b) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5825
	return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) || // put wider events first
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5826
		b.event.allDay - a.event.allDay || // if tie, put all-day events first (booleans cast to 0/1)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5827
		a.event.start - b.event.start || // if a tie, sort by event start date
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5828
		(a.event.title || '').localeCompare(b.event.title) // if a tie, sort by event title
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5829
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5830
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5831
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5832
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5833
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5834
//BUG: unselect needs to be triggered when events are dragged+dropped
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5835
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5836
function SelectionManager() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5837
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5838
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5839
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5840
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5841
	t.select = select;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5842
	t.unselect = unselect;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5843
	t.reportSelection = reportSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5844
	t.daySelectionMousedown = daySelectionMousedown;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5845
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5846
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5847
	// imports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5848
	var opt = t.opt;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5849
	var trigger = t.trigger;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5850
	var defaultSelectionEnd = t.defaultSelectionEnd;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5851
	var renderSelection = t.renderSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5852
	var clearSelection = t.clearSelection;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5853
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5854
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5855
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5856
	var selected = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5857
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5858
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5859
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5860
	// unselectAuto
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5861
	if (opt('selectable') && opt('unselectAuto')) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5862
		$(document).mousedown(function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5863
			var ignore = opt('unselectCancel');
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5864
			if (ignore) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5865
				if ($(ev.target).parents(ignore).length) { // could be optimized to stop after first match
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5866
					return;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5867
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5868
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5869
			unselect(ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5870
		});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5871
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5872
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5873
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5874
	function select(startDate, endDate, allDay) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5875
		unselect();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5876
		if (!endDate) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5877
			endDate = defaultSelectionEnd(startDate, allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5878
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5879
		renderSelection(startDate, endDate, allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5880
		reportSelection(startDate, endDate, allDay);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5881
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5882
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5883
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5884
	function unselect(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5885
		if (selected) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5886
			selected = false;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5887
			clearSelection();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5888
			trigger('unselect', null, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5889
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5890
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5891
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5892
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5893
	function reportSelection(startDate, endDate, allDay, ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5894
		selected = true;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5895
		trigger('select', null, startDate, endDate, allDay, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5896
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5897
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5898
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5899
	function daySelectionMousedown(ev) { // not really a generic manager method, oh well
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5900
		var cellToDate = t.cellToDate;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5901
		var getIsCellAllDay = t.getIsCellAllDay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5902
		var hoverListener = t.getHoverListener();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5903
		var reportDayClick = t.reportDayClick; // this is hacky and sort of weird
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5904
		if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5905
			unselect(ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5906
			var _mousedownElement = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5907
			var dates;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5908
			hoverListener.start(function(cell, origCell) { // TODO: maybe put cellToDate/getIsCellAllDay info in cell
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5909
				clearSelection();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5910
				if (cell && getIsCellAllDay(cell)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5911
					dates = [ cellToDate(origCell), cellToDate(cell) ].sort(dateCompare);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5912
					renderSelection(dates[0], dates[1], true);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5913
				}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5914
					dates = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5915
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5916
			}, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5917
			$(document).one('mouseup', function(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5918
				hoverListener.stop();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5919
				if (dates) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5920
					if (+dates[0] == +dates[1]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5921
						reportDayClick(dates[0], true, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5922
					}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5923
					reportSelection(dates[0], dates[1], true, ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5924
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5925
			});
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5926
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5927
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5928
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5929
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5930
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5931
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5932
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5933
 
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5934
function OverlayManager() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5935
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5936
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5937
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5938
	// exports
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5939
	t.renderOverlay = renderOverlay;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5940
	t.clearOverlays = clearOverlays;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5941
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5942
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5943
	// locals
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5944
	var usedOverlays = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5945
	var unusedOverlays = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5946
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5947
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5948
	function renderOverlay(rect, parent) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5949
		var e = unusedOverlays.shift();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5950
		if (!e) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5951
			e = $("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>");
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5952
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5953
		if (e[0].parentNode != parent[0]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5954
			e.appendTo(parent);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5955
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5956
		usedOverlays.push(e.css(rect).show());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5957
		return e;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5958
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5959
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5960
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5961
	function clearOverlays() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5962
		var e;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5963
		while (e = usedOverlays.shift()) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5964
			unusedOverlays.push(e.hide().unbind());
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5965
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5966
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5967
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5968
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5969
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5970
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5971
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5972
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5973
function CoordinateGrid(buildFunc) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5974
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5975
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5976
	var rows;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5977
	var cols;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5978
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5979
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5980
	t.build = function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5981
		rows = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5982
		cols = [];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5983
		buildFunc(rows, cols);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5984
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5985
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5986
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5987
	t.cell = function(x, y) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5988
		var rowCnt = rows.length;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5989
		var colCnt = cols.length;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5990
		var i, r=-1, c=-1;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5991
		for (i=0; i<rowCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5992
			if (y >= rows[i][0] && y < rows[i][1]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5993
				r = i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5994
				break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5995
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5996
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5997
		for (i=0; i<colCnt; i++) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5998
			if (x >= cols[i][0] && x < cols[i][1]) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  5999
				c = i;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6000
				break;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6001
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6002
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6003
		return (r>=0 && c>=0) ? { row:r, col:c } : null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6004
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6005
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6006
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6007
	t.rect = function(row0, col0, row1, col1, originElement) { // row1,col1 is inclusive
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6008
		var origin = originElement.offset();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6009
		return {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6010
			top: rows[row0][0] - origin.top,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6011
			left: cols[col0][0] - origin.left,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6012
			width: cols[col1][1] - cols[col0][0],
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6013
			height: rows[row1][1] - rows[row0][0]
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6014
		};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6015
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6016
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6017
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6018
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6019
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6020
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6021
function HoverListener(coordinateGrid) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6022
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6023
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6024
	var t = this;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6025
	var bindType;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6026
	var change;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6027
	var firstCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6028
	var cell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6029
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6030
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6031
	t.start = function(_change, ev, _bindType) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6032
		change = _change;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6033
		firstCell = cell = null;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6034
		coordinateGrid.build();
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6035
		mouse(ev);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6036
		bindType = _bindType || 'mousemove';
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6037
		$(document).bind(bindType, mouse);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6038
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6039
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6040
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6041
	function mouse(ev) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6042
		_fixUIEvent(ev); // see below
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6043
		var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6044
		if (!newCell != !cell || newCell && (newCell.row != cell.row || newCell.col != cell.col)) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6045
			if (newCell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6046
				if (!firstCell) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6047
					firstCell = newCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6048
				}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6049
				change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6050
			}else{
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6051
				change(newCell, firstCell);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6052
			}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6053
			cell = newCell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6054
		}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6055
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6056
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6057
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6058
	t.stop = function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6059
		$(document).unbind(bindType, mouse);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6060
		return cell;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6061
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6062
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6063
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6064
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6065
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6066
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6067
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6068
// this fix was only necessary for jQuery UI 1.8.16 (and jQuery 1.7 or 1.7.1)
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6069
// upgrading to jQuery UI 1.8.17 (and using either jQuery 1.7 or 1.7.1) fixed the problem
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6070
// but keep this in here for 1.8.16 users
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6071
// and maybe remove it down the line
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6072
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6073
function _fixUIEvent(event) { // for issue 1168
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6074
	if (event.pageX === undefined) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6075
		event.pageX = event.originalEvent.pageX;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6076
		event.pageY = event.originalEvent.pageY;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6077
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6078
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6079
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6080
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6081
function HorizontalPositionCache(getElement) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6082
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6083
	var t = this,
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6084
		elements = {},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6085
		lefts = {},
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6086
		rights = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6087
		
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6088
	function e(i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6089
		return elements[i] = elements[i] || getElement(i);
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6090
	}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6091
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6092
	t.left = function(i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6093
		return lefts[i] = lefts[i] === undefined ? e(i).position().left : lefts[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6094
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6095
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6096
	t.right = function(i) {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6097
		return rights[i] = rights[i] === undefined ? t.left(i) + e(i).width() : rights[i];
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6098
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6099
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6100
	t.clear = function() {
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6101
		elements = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6102
		lefts = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6103
		rights = {};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6104
	};
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6105
	
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6106
}
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6107
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6108
;;
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6109
60322cb8636c [web/data] Update fullcalendar to version 1.6.4
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
  6110
})(jQuery);