/
fullcalendar.js
executable file
·8391 lines (6501 loc) · 231 KB
/
fullcalendar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* FullCalendar v2.1.1
* Docs & License: http://arshaw.com/fullcalendar/
* (c) 2013 Adam Shaw
*/
(function(factory) {
if (typeof define === 'function' && define.amd) {
define([ 'jquery', 'moment' ], factory);
}
else {
factory(jQuery, moment);
}
})(function($, moment) {
;;
var defaults = {
lang: 'en',
defaultTimedEventDuration: '02:00:00',
defaultAllDayEventDuration: { days: 1 },
forceEventDuration: false,
nextDayThreshold: '09:00:00', // 9am
// display
defaultView: 'month',
aspectRatio: 1.35,
header: {
left: 'title',
center: '',
right: 'today prev,next'
},
weekends: true,
weekNumbers: false,
weekNumberTitle: 'W',
weekNumberCalculation: 'local',
//editable: false,
// event ajax
lazyFetching: true,
startParam: 'start',
endParam: 'end',
timezoneParam: 'timezone',
timezone: false,
//allDayDefault: undefined,
// time formats
titleFormat: {
month: 'MMMM YYYY', // like "September 1986". each language will override this
week: 'll', // like "Sep 4 1986"
day: 'LL' // like "September 4 1986"
},
columnFormat: {
month: 'ddd', // like "Sat"
week: generateWeekColumnFormat,
day: 'dddd' // like "Saturday"
},
timeFormat: { // for event elements
'default': generateShortTimeFormat
},
displayEventEnd: {
month: false,
basicWeek: false,
'default': true
},
// locale
isRTL: false,
defaultButtonText: {
prev: "prev",
next: "next",
prevYear: "prev year",
nextYear: "next year",
today: 'today',
month: 'month',
week: 'week',
day: 'day'
},
buttonIcons: {
prev: 'left-single-arrow',
next: 'right-single-arrow',
prevYear: 'left-double-arrow',
nextYear: 'right-double-arrow'
},
// jquery-ui theming
theme: false,
themeButtonIcons: {
prev: 'circle-triangle-w',
next: 'circle-triangle-e',
prevYear: 'seek-prev',
nextYear: 'seek-next'
},
dragOpacity: .75,
dragRevertDuration: 500,
dragScroll: true,
//selectable: false,
unselectAuto: true,
dropAccept: '*',
eventLimit: false,
eventLimitText: 'more',
eventLimitClick: 'popover',
dayPopoverFormat: 'LL',
handleWindowResize: true,
windowResizeDelay: 200 // milliseconds before a rerender happens
};
function generateShortTimeFormat(options, langData) {
return langData.longDateFormat('LT')
.replace(':mm', '(:mm)')
.replace(/(\Wmm)$/, '($1)') // like above, but for foreign langs
.replace(/\s*a$/i, 't'); // convert to AM/PM/am/pm to lowercase one-letter. remove any spaces beforehand
}
function generateWeekColumnFormat(options, langData) {
var format = langData.longDateFormat('L'); // for the format like "MM/DD/YYYY"
format = format.replace(/^Y+[^\w\s]*|[^\w\s]*Y+$/g, ''); // strip the year off the edge, as well as other misc non-whitespace chars
if (options.isRTL) {
format += ' ddd'; // for RTL, add day-of-week to end
}
else {
format = 'ddd ' + format; // for LTR, add day-of-week to beginning
}
return format;
}
var langOptionHash = {
en: {
columnFormat: {
week: 'ddd M/D' // override for english. different from the generated default, which is MM/DD
},
dayPopoverFormat: 'dddd, MMMM D'
}
};
// right-to-left defaults
var rtlDefaults = {
header: {
left: 'next,prev today',
center: '',
right: 'title'
},
buttonIcons: {
prev: 'right-single-arrow',
next: 'left-single-arrow',
prevYear: 'right-double-arrow',
nextYear: 'left-double-arrow'
},
themeButtonIcons: {
prev: 'circle-triangle-e',
next: 'circle-triangle-w',
nextYear: 'seek-prev',
prevYear: 'seek-next'
}
};
;;
var fc = $.fullCalendar = { version: "2.1.1" };
var fcViews = fc.views = {};
$.fn.fullCalendar = function(options) {
var args = Array.prototype.slice.call(arguments, 1); // for a possible method call
var res = this; // what this function will return (this jQuery object by default)
this.each(function(i, _element) { // loop each DOM element involved
var element = $(_element);
var calendar = element.data('fullCalendar'); // get the existing calendar object (if any)
var singleRes; // the returned value of this single method call
// a method call
if (typeof options === 'string') {
if (calendar && $.isFunction(calendar[options])) {
singleRes = calendar[options].apply(calendar, args);
if (!i) {
res = singleRes; // record the first method call result
}
if (options === 'destroy') { // for the destroy method, must remove Calendar object data
element.removeData('fullCalendar');
}
}
}
// a new calendar initialization
else if (!calendar) { // don't initialize twice
calendar = new Calendar(element, options);
element.data('fullCalendar', calendar);
calendar.render();
}
});
return res;
};
// function for adding/overriding defaults
function setDefaults(d) {
mergeOptions(defaults, d);
}
// Recursively combines option hash-objects.
// Better than `$.extend(true, ...)` because arrays are not traversed/copied.
//
// called like:
// mergeOptions(target, obj1, obj2, ...)
//
function mergeOptions(target) {
function mergeIntoTarget(name, value) {
if ($.isPlainObject(value) && $.isPlainObject(target[name]) && !isForcedAtomicOption(name)) {
// merge into a new object to avoid destruction
target[name] = mergeOptions({}, target[name], value); // combine. `value` object takes precedence
}
else if (value !== undefined) { // only use values that are set and not undefined
target[name] = value;
}
}
for (var i=1; i<arguments.length; i++) {
$.each(arguments[i], mergeIntoTarget);
}
return target;
}
// overcome sucky view-option-hash and option-merging behavior messing with options it shouldn't
function isForcedAtomicOption(name) {
// Any option that ends in "Time" or "Duration" is probably a Duration,
// and these will commonly be specified as plain objects, which we don't want to mess up.
return /(Time|Duration)$/.test(name);
}
// FIX: find a different solution for view-option-hashes and have a whitelist
// for options that can be recursively merged.
;;
//var langOptionHash = {}; // initialized in defaults.js
fc.langs = langOptionHash; // expose
// Initialize jQuery UI Datepicker translations while using some of the translations
// for our own purposes. Will set this as the default language for datepicker.
// Called from a translation file.
fc.datepickerLang = function(langCode, datepickerLangCode, options) {
var langOptions = langOptionHash[langCode];
// initialize FullCalendar's lang hash for this language
if (!langOptions) {
langOptions = langOptionHash[langCode] = {};
}
// merge certain Datepicker options into FullCalendar's options
mergeOptions(langOptions, {
isRTL: options.isRTL,
weekNumberTitle: options.weekHeader,
titleFormat: {
month: options.showMonthAfterYear ?
'YYYY[' + options.yearSuffix + '] MMMM' :
'MMMM YYYY[' + options.yearSuffix + ']'
},
defaultButtonText: {
// the translations sometimes wrongly contain HTML entities
prev: stripHtmlEntities(options.prevText),
next: stripHtmlEntities(options.nextText),
today: stripHtmlEntities(options.currentText)
}
});
// is jQuery UI Datepicker is on the page?
if ($.datepicker) {
// Register the language data.
// FullCalendar and MomentJS use language codes like "pt-br" but Datepicker
// does it like "pt-BR" or if it doesn't have the language, maybe just "pt".
// Make an alias so the language can be referenced either way.
$.datepicker.regional[datepickerLangCode] =
$.datepicker.regional[langCode] = // alias
options;
// Alias 'en' to the default language data. Do this every time.
$.datepicker.regional.en = $.datepicker.regional[''];
// Set as Datepicker's global defaults.
$.datepicker.setDefaults(options);
}
};
// Sets FullCalendar-specific translations. Also sets the language as the global default.
// Called from a translation file.
fc.lang = function(langCode, options) {
var langOptions;
if (options) {
langOptions = langOptionHash[langCode];
// initialize the hash for this language
if (!langOptions) {
langOptions = langOptionHash[langCode] = {};
}
mergeOptions(langOptions, options || {});
}
// set it as the default language for FullCalendar
defaults.lang = langCode;
};
;;
function Calendar(element, instanceOptions) {
var t = this;
// Build options object
// -----------------------------------------------------------------------------------
// Precedence (lowest to highest): defaults, rtlDefaults, langOptions, instanceOptions
instanceOptions = instanceOptions || {};
var options = mergeOptions({}, defaults, instanceOptions);
var langOptions;
// determine language options
if (options.lang in langOptionHash) {
langOptions = langOptionHash[options.lang];
}
else {
langOptions = langOptionHash[defaults.lang];
}
if (langOptions) { // if language options exist, rebuild...
options = mergeOptions({}, defaults, langOptions, instanceOptions);
}
if (options.isRTL) { // is isRTL, rebuild...
options = mergeOptions({}, defaults, rtlDefaults, langOptions || {}, instanceOptions);
}
// Exports
// -----------------------------------------------------------------------------------
t.options = options;
t.render = render;
t.destroy = destroy;
t.refetchEvents = refetchEvents;
t.reportEvents = reportEvents;
t.reportEventChange = reportEventChange;
t.rerenderEvents = renderEvents; // `renderEvents` serves as a rerender. an API method
t.changeView = changeView;
t.select = select;
t.unselect = unselect;
t.prev = prev;
t.next = next;
t.prevYear = prevYear;
t.nextYear = nextYear;
t.today = today;
t.gotoDate = gotoDate;
t.incrementDate = incrementDate;
t.zoomTo = zoomTo;
t.getDate = getDate;
t.getCalendar = getCalendar;
t.getView = getView;
t.option = option;
t.trigger = trigger;
// Language-data Internals
// -----------------------------------------------------------------------------------
// Apply overrides to the current language's data
// Returns moment's internal locale data. If doesn't exist, returns English.
// Works with moment-pre-2.8
function getLocaleData(langCode) {
var f = moment.localeData || moment.langData;
return f.call(moment, langCode) ||
f.call(moment, 'en'); // the newer localData could return null, so fall back to en
}
var localeData = createObject(getLocaleData(options.lang)); // make a cheap copy
if (options.monthNames) {
localeData._months = options.monthNames;
}
if (options.monthNamesShort) {
localeData._monthsShort = options.monthNamesShort;
}
if (options.dayNames) {
localeData._weekdays = options.dayNames;
}
if (options.dayNamesShort) {
localeData._weekdaysShort = options.dayNamesShort;
}
if (options.firstDay != null) {
var _week = createObject(localeData._week); // _week: { dow: # }
_week.dow = options.firstDay;
localeData._week = _week;
}
// Calendar-specific Date Utilities
// -----------------------------------------------------------------------------------
t.defaultAllDayEventDuration = moment.duration(options.defaultAllDayEventDuration);
t.defaultTimedEventDuration = moment.duration(options.defaultTimedEventDuration);
// Builds a moment using the settings of the current calendar: timezone and language.
// Accepts anything the vanilla moment() constructor accepts.
t.moment = function() {
var mom;
if (options.timezone === 'local') {
mom = fc.moment.apply(null, arguments);
// Force the moment to be local, because fc.moment doesn't guarantee it.
if (mom.hasTime()) { // don't give ambiguously-timed moments a local zone
mom.local();
}
}
else if (options.timezone === 'UTC') {
mom = fc.moment.utc.apply(null, arguments); // process as UTC
}
else {
mom = fc.moment.parseZone.apply(null, arguments); // let the input decide the zone
}
if ('_locale' in mom) { // moment 2.8 and above
mom._locale = localeData;
}
else { // pre-moment-2.8
mom._lang = localeData;
}
return mom;
};
// Returns a boolean about whether or not the calendar knows how to calculate
// the timezone offset of arbitrary dates in the current timezone.
t.getIsAmbigTimezone = function() {
return options.timezone !== 'local' && options.timezone !== 'UTC';
};
// Returns a copy of the given date in the current timezone of it is ambiguously zoned.
// This will also give the date an unambiguous time.
t.rezoneDate = function(date) {
return t.moment(date.toArray());
};
// Returns a moment for the current date, as defined by the client's computer,
// or overridden by the `now` option.
t.getNow = function() {
var now = options.now;
if (typeof now === 'function') {
now = now();
}
return t.moment(now);
};
// Calculates the week number for a moment according to the calendar's
// `weekNumberCalculation` setting.
t.calculateWeekNumber = function(mom) {
var calc = options.weekNumberCalculation;
if (typeof calc === 'function') {
return calc(mom);
}
else if (calc === 'local') {
return mom.week();
}
else if (calc.toUpperCase() === 'ISO') {
return mom.isoWeek();
}
};
// Get an event's normalized end date. If not present, calculate it from the defaults.
t.getEventEnd = function(event) {
if (event.end) {
return event.end.clone();
}
else {
return t.getDefaultEventEnd(event.allDay, event.start);
}
};
// Given an event's allDay status and start date, return swhat its fallback end date should be.
t.getDefaultEventEnd = function(allDay, start) { // TODO: rename to computeDefaultEventEnd
var end = start.clone();
if (allDay) {
end.stripTime().add(t.defaultAllDayEventDuration);
}
else {
end.add(t.defaultTimedEventDuration);
}
if (t.getIsAmbigTimezone()) {
end.stripZone(); // we don't know what the tzo should be
}
return end;
};
// Date-formatting Utilities
// -----------------------------------------------------------------------------------
// Like the vanilla formatRange, but with calendar-specific settings applied.
t.formatRange = function(m1, m2, formatStr) {
// a function that returns a formatStr // TODO: in future, precompute this
if (typeof formatStr === 'function') {
formatStr = formatStr.call(t, options, localeData);
}
return formatRange(m1, m2, formatStr, null, options.isRTL);
};
// Like the vanilla formatDate, but with calendar-specific settings applied.
t.formatDate = function(mom, formatStr) {
// a function that returns a formatStr // TODO: in future, precompute this
if (typeof formatStr === 'function') {
formatStr = formatStr.call(t, options, localeData);
}
return formatDate(mom, formatStr);
};
// Imports
// -----------------------------------------------------------------------------------
EventManager.call(t, options);
var isFetchNeeded = t.isFetchNeeded;
var fetchEvents = t.fetchEvents;
// Locals
// -----------------------------------------------------------------------------------
var _element = element[0];
var header;
var headerElement;
var content;
var tm; // for making theme classes
var currentView;
var suggestedViewHeight;
var windowResizeProxy; // wraps the windowResize function
var ignoreWindowResize = 0;
var date;
var events = [];
// Main Rendering
// -----------------------------------------------------------------------------------
if (options.defaultDate != null) {
date = t.moment(options.defaultDate);
}
else {
date = t.getNow();
}
function render(inc) {
if (!content) {
initialRender();
}
else if (elementVisible()) {
// mainly for the public API
calcSize();
renderView(inc);
}
}
function initialRender() {
tm = options.theme ? 'ui' : 'fc';
element.addClass('fc');
if (options.isRTL) {
element.addClass('fc-rtl');
}
else {
element.addClass('fc-ltr');
}
if (options.theme) {
element.addClass('ui-widget');
}
else {
element.addClass('fc-unthemed');
}
content = $("<div class='fc-view-container'/>").prependTo(element);
header = new Header(t, options);
headerElement = header.render();
if (headerElement) {
element.prepend(headerElement);
}
changeView(options.defaultView);
if (options.handleWindowResize) {
windowResizeProxy = debounce(windowResize, options.windowResizeDelay); // prevents rapid calls
$(window).resize(windowResizeProxy);
}
}
function destroy() {
if (currentView) {
currentView.destroy();
}
header.destroy();
content.remove();
element.removeClass('fc fc-ltr fc-rtl fc-unthemed ui-widget');
$(window).unbind('resize', windowResizeProxy);
}
function elementVisible() {
return element.is(':visible');
}
// View Rendering
// -----------------------------------------------------------------------------------
function changeView(viewName) {
renderView(0, viewName);
}
// Renders a view because of a date change, view-type change, or for the first time
function renderView(delta, viewName) {
ignoreWindowResize++;
// if viewName is changing, destroy the old view
if (currentView && viewName && currentView.name !== viewName) {
header.deactivateButton(currentView.name);
freezeContentHeight(); // prevent a scroll jump when view element is removed
if (currentView.start) { // rendered before?
currentView.destroy();
}
currentView.el.remove();
currentView = null;
}
// if viewName changed, or the view was never created, create a fresh view
if (!currentView && viewName) {
currentView = new fcViews[viewName](t);
currentView.el = $("<div class='fc-view fc-" + viewName + "-view' />").appendTo(content);
header.activateButton(viewName);
}
if (currentView) {
// let the view determine what the delta means
if (delta) {
date = currentView.incrementDate(date, delta);
}
// render or rerender the view
if (
!currentView.start || // never rendered before
delta || // explicit date window change
!date.isWithin(currentView.intervalStart, currentView.intervalEnd) // implicit date window change
) {
if (elementVisible()) {
freezeContentHeight();
if (currentView.start) { // rendered before?
currentView.destroy();
}
currentView.render(date);
unfreezeContentHeight();
// need to do this after View::render, so dates are calculated
updateTitle();
updateTodayButton();
getAndRenderEvents();
}
}
}
unfreezeContentHeight(); // undo any lone freezeContentHeight calls
ignoreWindowResize--;
}
// Resizing
// -----------------------------------------------------------------------------------
t.getSuggestedViewHeight = function() {
if (suggestedViewHeight === undefined) {
calcSize();
}
return suggestedViewHeight;
};
t.isHeightAuto = function() {
return options.contentHeight === 'auto' || options.height === 'auto';
};
function updateSize(shouldRecalc) {
if (elementVisible()) {
if (shouldRecalc) {
_calcSize();
}
ignoreWindowResize++;
currentView.updateSize(true); // isResize=true. will poll getSuggestedViewHeight() and isHeightAuto()
ignoreWindowResize--;
return true; // signal success
}
}
function calcSize() {
if (elementVisible()) {
_calcSize();
}
}
function _calcSize() { // assumes elementVisible
if (typeof options.contentHeight === 'number') { // exists and not 'auto'
suggestedViewHeight = options.contentHeight;
}
else if (typeof options.height === 'number') { // exists and not 'auto'
suggestedViewHeight = options.height - (headerElement ? headerElement.outerHeight(true) : 0);
}
else {
suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
}
}
function windowResize(ev) {
if (
!ignoreWindowResize &&
ev.target === window && // so we don't process jqui "resize" events that have bubbled up
currentView.start // view has already been rendered
) {
if (updateSize(true)) {
currentView.trigger('windowResize', _element);
}
}
}
/* Event Fetching/Rendering
-----------------------------------------------------------------------------*/
// TODO: going forward, most of this stuff should be directly handled by the view
function refetchEvents() { // can be called as an API method
destroyEvents(); // so that events are cleared before user starts waiting for AJAX
fetchAndRenderEvents();
}
function renderEvents() { // destroys old events if previously rendered
if (elementVisible()) {
freezeContentHeight();
currentView.destroyEvents(); // no performance cost if never rendered
currentView.renderEvents(events);
unfreezeContentHeight();
}
}
function destroyEvents() {
freezeContentHeight();
currentView.destroyEvents();
unfreezeContentHeight();
}
function getAndRenderEvents() {
if (!options.lazyFetching || isFetchNeeded(currentView.start, currentView.end)) {
fetchAndRenderEvents();
}
else {
renderEvents();
}
}
function fetchAndRenderEvents() {
fetchEvents(currentView.start, currentView.end);
// ... will call reportEvents
// ... which will call renderEvents
}
// called when event data arrives
function reportEvents(_events) {
events = _events;
renderEvents();
}
// called when a single event's data has been changed
function reportEventChange() {
renderEvents();
}
/* Header Updating
-----------------------------------------------------------------------------*/
function updateTitle() {
header.updateTitle(currentView.title);
}
function updateTodayButton() {
var now = t.getNow();
if (now.isWithin(currentView.intervalStart, currentView.intervalEnd)) {
header.disableButton('today');
}
else {
header.enableButton('today');
}
}
/* Selection
-----------------------------------------------------------------------------*/
function select(start, end) {
start = t.moment(start);
if (end) {
end = t.moment(end);
}
else if (start.hasTime()) {
end = start.clone().add(t.defaultTimedEventDuration);
}
else {
end = start.clone().add(t.defaultAllDayEventDuration);
}
currentView.select(start, end);
}
function unselect() { // safe to be called before renderView
if (currentView) {
currentView.unselect();
}
}
/* Date
-----------------------------------------------------------------------------*/
function prev() {
renderView(-1);
}
function next() {
renderView(1);
}
function prevYear() {
date.add(-1, 'years');
renderView();
}
function nextYear() {
date.add(1, 'years');
renderView();
}
function today() {
date = t.getNow();
renderView();
}
function gotoDate(dateInput) {
date = t.moment(dateInput);
renderView();
}
function incrementDate(delta) {
date.add(moment.duration(delta));
renderView();
}
// Forces navigation to a view for the given date.
// `viewName` can be a specific view name or a generic one like "week" or "day".
function zoomTo(newDate, viewName) {
var viewStr;
var match;
if (!viewName || fcViews[viewName] === undefined) { // a general view name, or "auto"
viewName = viewName || 'day';
viewStr = header.getViewsWithButtons().join(' '); // space-separated string of all the views in the header
// try to match a general view name, like "week", against a specific one, like "agendaWeek"
match = viewStr.match(new RegExp('\\w+' + capitaliseFirstLetter(viewName)));
// fall back to the day view being used in the header
if (!match) {
match = viewStr.match(/\w+Day/);
}
viewName = match ? match[0] : 'agendaDay'; // fall back to agendaDay
}
date = newDate;
changeView(viewName);
}
function getDate() {
return date.clone();
}
/* Height "Freezing"
-----------------------------------------------------------------------------*/
function freezeContentHeight() {