Skip to content

Commit

Permalink
no more Calendar and EventManager access options as local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jul 10, 2016
1 parent 42951c5 commit b766b77
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
44 changes: 22 additions & 22 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,16 @@ function Calendar_constructor(element, overrides) {
// -----------------------------------------------------------------------------------


t.defaultAllDayEventDuration = moment.duration(options.defaultAllDayEventDuration);
t.defaultTimedEventDuration = moment.duration(options.defaultTimedEventDuration);
t.defaultAllDayEventDuration = moment.duration(t.options.defaultAllDayEventDuration);
t.defaultTimedEventDuration = moment.duration(t.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') {
if (t.options.timezone === 'local') {
mom = FC.moment.apply(null, arguments);

// Force the moment to be local, because FC.moment doesn't guarantee it.
Expand Down Expand Up @@ -381,7 +381,7 @@ function Calendar_constructor(element, overrides) {
// 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';
return t.options.timezone !== 'local' && t.options.timezone !== 'UTC';
};


Expand Down Expand Up @@ -410,7 +410,7 @@ function Calendar_constructor(element, overrides) {
// Returns a moment for the current date, as defined by the client's computer or from the `now` option.
// Will return an moment with an ambiguous timezone.
t.getNow = function() {
var now = options.now;
var now = t.options.now;
if (typeof now === 'function') {
now = now();
}
Expand Down Expand Up @@ -452,7 +452,7 @@ function Calendar_constructor(element, overrides) {
// Produces a human-readable string for the given duration.
// Side-effect: changes the locale of the given duration.
t.humanizeDuration = function(duration) {
return (duration.locale || duration.lang).call(duration, options.lang) // works moment-pre-2.8
return (duration.locale || duration.lang).call(duration, t.options.lang) // works moment-pre-2.8
.humanize();
};

Expand All @@ -462,7 +462,7 @@ function Calendar_constructor(element, overrides) {
// -----------------------------------------------------------------------------------


EventManager.call(t, options);
EventManager.call(t);
var isFetchNeeded = t.isFetchNeeded;
var fetchEvents = t.fetchEvents;
var fetchEventSources = t.fetchEventSources;
Expand Down Expand Up @@ -492,8 +492,8 @@ function Calendar_constructor(element, overrides) {


// compute the initial ambig-timezone date
if (options.defaultDate != null) {
date = t.moment(options.defaultDate).stripZone();
if (t.options.defaultDate != null) {
date = t.moment(t.options.defaultDate).stripZone();
}
else {
date = t.getNow(); // getNow already returns unzoned
Expand Down Expand Up @@ -535,10 +535,10 @@ function Calendar_constructor(element, overrides) {
header = t.header = new Header(t);
renderHeader();

renderView(options.defaultView);
renderView(t.options.defaultView);

if (options.handleWindowResize) {
windowResizeProxy = debounce(windowResize, options.windowResizeDelay); // prevents rapid calls
if (t.options.handleWindowResize) {
windowResizeProxy = debounce(windowResize, t.options.windowResizeDelay); // prevents rapid calls
$(window).resize(windowResizeProxy);
}
}
Expand Down Expand Up @@ -675,7 +675,7 @@ function Calendar_constructor(element, overrides) {


t.isHeightAuto = function() {
return options.contentHeight === 'auto' || options.height === 'auto';
return t.options.contentHeight === 'auto' || t.options.height === 'auto';
};


Expand Down Expand Up @@ -703,14 +703,14 @@ function Calendar_constructor(element, overrides) {


function _calcSize() { // assumes elementVisible
if (typeof options.contentHeight === 'number') { // exists and not 'auto'
suggestedViewHeight = options.contentHeight;
if (typeof t.options.contentHeight === 'number') { // exists and not 'auto'
suggestedViewHeight = t.options.contentHeight;
}
else if (typeof options.height === 'number') { // exists and not 'auto'
suggestedViewHeight = options.height - (header.el ? header.el.outerHeight(true) : 0);
else if (typeof t.options.height === 'number') { // exists and not 'auto'
suggestedViewHeight = t.options.height - (header.el ? header.el.outerHeight(true) : 0);
}
else {
suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
suggestedViewHeight = Math.round(content.width() / Math.max(t.options.aspectRatio, .5));
}
}

Expand Down Expand Up @@ -755,7 +755,7 @@ function Calendar_constructor(element, overrides) {


function getAndRenderEvents() {
if (!options.lazyFetching || isFetchNeeded(currentView.start, currentView.end)) {
if (!t.options.lazyFetching || isFetchNeeded(currentView.start, currentView.end)) {
fetchAndRenderEvents();
}
else {
Expand Down Expand Up @@ -937,7 +937,7 @@ function Calendar_constructor(element, overrides) {

// getter
if (value === undefined) {
return options[name];
return t.options[name];
}

// setter
Expand Down Expand Up @@ -971,8 +971,8 @@ function Calendar_constructor(element, overrides) {
thisObj = thisObj || _element;
this.triggerWith(name, thisObj, args); // Emitter's method

if (options[name]) {
return options[name].apply(thisObj, args);
if (t.options[name]) {
return t.options[name].apply(thisObj, args);
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/EventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var ajaxDefaults = {
var eventGUID = 1;


function EventManager(options) { // assumed to be a calendar
function EventManager() { // assumed to be a calendar
var t = this;


Expand Down Expand Up @@ -47,7 +47,7 @@ function EventManager(options) { // assumed to be a calendar


$.each(
(options.events ? [ options.events ] : []).concat(options.eventSources || []),
(t.options.events ? [ t.options.events ] : []).concat(t.options.eventSources || []),
function(i, sourceInput) {
var source = buildEventSource(sourceInput);
if (source) {
Expand Down Expand Up @@ -181,7 +181,7 @@ function EventManager(options) { // assumed to be a calendar
source,
rangeStart.clone(),
rangeEnd.clone(),
options.timezone,
t.options.timezone,
callback
);

Expand All @@ -204,7 +204,7 @@ function EventManager(options) { // assumed to be a calendar
t, // this, the Calendar object
rangeStart.clone(),
rangeEnd.clone(),
options.timezone,
t.options.timezone,
function(events) {
callback(events);
t.popLoading();
Expand Down Expand Up @@ -239,18 +239,18 @@ function EventManager(options) { // assumed to be a calendar
// and not affect the passed-in object.
var data = $.extend({}, customData || {});

var startParam = firstDefined(source.startParam, options.startParam);
var endParam = firstDefined(source.endParam, options.endParam);
var timezoneParam = firstDefined(source.timezoneParam, options.timezoneParam);
var startParam = firstDefined(source.startParam, t.options.startParam);
var endParam = firstDefined(source.endParam, t.options.endParam);
var timezoneParam = firstDefined(source.timezoneParam, t.options.timezoneParam);

if (startParam) {
data[startParam] = rangeStart.format();
}
if (endParam) {
data[endParam] = rangeEnd.format();
}
if (options.timezone && options.timezone != 'local') {
data[timezoneParam] = options.timezone;
if (t.options.timezone && t.options.timezone != 'local') {
data[timezoneParam] = t.options.timezone;
}

t.pushLoading();
Expand Down Expand Up @@ -612,8 +612,8 @@ function EventManager(options) { // assumed to be a calendar
var start, end;
var allDay;

if (options.eventDataTransform) {
input = options.eventDataTransform(input);
if (t.options.eventDataTransform) {
input = t.options.eventDataTransform(input);
}
if (source && source.eventDataTransform) {
input = source.eventDataTransform(input);
Expand Down Expand Up @@ -679,7 +679,7 @@ function EventManager(options) { // assumed to be a calendar
if (allDay === undefined) { // still undefined? fallback to default
allDay = firstDefined(
source ? source.allDayDefault : undefined,
options.allDayDefault
t.options.allDayDefault
);
// still undefined? normalizeEventDates will calculate it
}
Expand Down Expand Up @@ -715,7 +715,7 @@ function EventManager(options) { // assumed to be a calendar
}

if (!eventProps.end) {
if (options.forceEventDuration) {
if (t.options.forceEventDuration) {
eventProps.end = t.getDefaultEventEnd(eventProps.allDay, eventProps.start);
}
else {
Expand Down Expand Up @@ -1016,7 +1016,7 @@ function EventManager(options) { // assumed to be a calendar
// Returns an array of events as to when the business hours occur in the given view.
// Abuse of our event system :(
function getBusinessHoursEvents(wholeDay) {
var optionVal = options.businessHours;
var optionVal = t.options.businessHours;
var defaultVal = {
className: 'fc-nonbusiness',
start: '09:00',
Expand Down Expand Up @@ -1068,12 +1068,12 @@ function EventManager(options) { // assumed to be a calendar
var constraint = firstDefined(
event.constraint,
source.constraint,
options.eventConstraint
t.options.eventConstraint
);
var overlap = firstDefined(
event.overlap,
source.overlap,
options.eventOverlap
t.options.eventOverlap
);
return isSpanAllowed(span, constraint, overlap, event);
}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ function EventManager(options) { // assumed to be a calendar

// Determines the given span (unzoned start/end with other misc data) can be selected.
function isSelectionSpanAllowed(span) {
return isSpanAllowed(span, options.selectConstraint, options.selectOverlap);
return isSpanAllowed(span, t.options.selectConstraint, t.options.selectOverlap);
}


Expand Down

0 comments on commit b766b77

Please sign in to comment.