浏览代码

grids use opt method

Adam Shaw 8 年之前
父节点
当前提交
c8cd31a9d8

+ 2 - 2
src/agenda/AgendaView.js

@@ -478,8 +478,8 @@ var agendaTimeGridMethods = {
 		var view = this.view;
 		var weekText;
 
-		if (view.opt('weekNumbers')) {
-			weekText = this.start.format(view.opt('smallWeekFormat'));
+		if (this.opt('weekNumbers')) {
+			weekText = this.start.format(this.opt('smallWeekFormat'));
 
 			return '' +
 				'<th class="fc-axis fc-week-number ' + view.widgetHeaderClass + '" ' + view.axisStyleAttr() + '>' +

+ 1 - 1
src/basic/BasicView.js

@@ -369,7 +369,7 @@ var basicDayGridMethods = {
 			return '' +
 				'<th class="fc-week-number ' + view.widgetHeaderClass + '" ' + view.weekNumberStyleAttr() + '>' +
 					'<span>' + // needed for matchCellWidths
-						htmlEscape(view.opt('weekNumberTitle')) +
+						htmlEscape(this.opt('weekNumberTitle')) +
 					'</span>' +
 				'</th>';
 		}

+ 1 - 1
src/common/DayGrid.js

@@ -203,7 +203,7 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 
 	// Computes a default event time formatting string if `timeFormat` is not explicitly defined
 	computeEventTimeFormat: function() {
-		return this.view.opt('extraSmallTimeFormat'); // like "6p" or "6:30p"
+		return this.opt('extraSmallTimeFormat'); // like "6p" or "6:30p"
 	},
 
 

+ 6 - 6
src/common/DayGrid.limit.js

@@ -192,7 +192,7 @@ DayGrid.mixin({
 				this.getMoreLinkText(hiddenSegs.length)
 			)
 			.on('click', function(ev) {
-				var clickOption = view.opt('eventLimitClick');
+				var clickOption = _this.opt('eventLimitClick');
 				var date = _this.getCellDate(row, col);
 				var moreEl = $(this);
 				var dayEl = _this.getCellEl(row, col);
@@ -241,10 +241,10 @@ DayGrid.mixin({
 		options = {
 			className: 'fc-more-popover',
 			content: this.renderSegPopoverContent(row, col, segs),
-			parentEl: this.view.el, // attach to root of view. guarantees outside of scrollbars.
+			parentEl: view.el, // attach to root of view. guarantees outside of scrollbars.
 			top: topEl.offset().top,
 			autoHide: true, // when the user clicks elsewhere, hide the popover
-			viewportConstrain: view.opt('popoverViewportConstrain'),
+			viewportConstrain: this.opt('popoverViewportConstrain'),
 			hide: function() {
 				// kill everything when the popover is hidden
 				// notify events to be removed
@@ -282,8 +282,8 @@ DayGrid.mixin({
 	// Builds the inner DOM contents of the segment popover
 	renderSegPopoverContent: function(row, col, segs) {
 		var view = this.view;
-		var isTheme = view.opt('theme');
-		var title = this.getCellDate(row, col).format(view.opt('dayPopoverFormat'));
+		var isTheme = this.opt('theme');
+		var title = this.getCellDate(row, col).format(this.opt('dayPopoverFormat'));
 		var content = $(
 			'<div class="fc-header ' + view.widgetHeaderClass + '">' +
 				'<span class="fc-close ' +
@@ -350,7 +350,7 @@ DayGrid.mixin({
 
 	// Generates the text that should be inside a "more" link, given the number of events it represents
 	getMoreLinkText: function(num) {
-		var opt = this.view.opt('eventLimitText');
+		var opt = this.opt('eventLimitText');
 
 		if (typeof opt === 'function') {
 			return opt(num);

+ 2 - 2
src/common/DayTableMixin.js

@@ -64,7 +64,7 @@ var DayTableMixin = FC.DayTableMixin = {
 	// Computes and assigned the colCnt property and updates any options that may be computed from it
 	updateDayTableCols: function() {
 		this.colCnt = this.computeColCnt();
-		this.colHeadFormat = this.view.opt('columnFormat') || this.computeColHeadFormat();
+		this.colHeadFormat = this.opt('columnFormat') || this.computeColHeadFormat();
 	},
 
 
@@ -142,7 +142,7 @@ var DayTableMixin = FC.DayTableMixin = {
 		}
 		// multiple days, so full single date string WON'T be in title text
 		else if (this.colCnt > 1) {
-			return this.view.opt('dayOfMonthFormat'); // "Sat 12/10"
+			return this.opt('dayOfMonthFormat'); // "Sat 12/10"
 		}
 		// single day, so full single date string will probably be in title text
 		else {

+ 14 - 15
src/common/Grid.events.js

@@ -333,9 +333,9 @@ Grid.mixin({
 
 		if (!isResizing && (isDraggable || isResizable)) { // allowed to be selected?
 
-			eventLongPressDelay = view.opt('eventLongPressDelay');
+			eventLongPressDelay = this.opt('eventLongPressDelay');
 			if (eventLongPressDelay == null) {
-				eventLongPressDelay = view.opt('longPressDelay'); // fallback
+				eventLongPressDelay = this.opt('longPressDelay'); // fallback
 			}
 
 			dragListener = isDraggable ?
@@ -386,7 +386,7 @@ Grid.mixin({
 		// Tracks mouse movement over the *view's* coordinate map. Allows dragging and dropping between subcomponents
 		// of the view.
 		var dragListener = this.segDragListener = new HitDragListener(view, {
-			scroll: view.opt('dragScroll'),
+			scroll: this.opt('dragScroll'),
 			subjectEl: el,
 			subjectCenter: true,
 			interactionStart: function(ev) {
@@ -395,8 +395,8 @@ Grid.mixin({
 				mouseFollower = new MouseFollower(seg.el, {
 					additionalClass: 'fc-dragging',
 					parentEl: view.el,
-					opacity: dragListener.isTouch ? null : view.opt('dragOpacity'),
-					revertDuration: view.opt('dragRevertDuration'),
+					opacity: dragListener.isTouch ? null : _this.opt('dragOpacity'),
+					revertDuration: _this.opt('dragRevertDuration'),
 					zIndex: 2 // one above the .fc-view
 				});
 				mouseFollower.hide(); // don't show until we know this is a real drag
@@ -583,7 +583,7 @@ Grid.mixin({
 
 	// Utility for apply dragOpacity to a jQuery set
 	applyDragOpacity: function(els) {
-		var opacity = this.view.opt('dragOpacity');
+		var opacity = this.opt('dragOpacity');
 
 		if (opacity != null) {
 			els.css('opacity', opacity);
@@ -597,16 +597,15 @@ Grid.mixin({
 
 	// Called when a jQuery UI drag is initiated anywhere in the DOM
 	externalDragStart: function(ev, ui) {
-		var view = this.view;
 		var el;
 		var accept;
 
-		if (view.opt('droppable')) { // only listen if this setting is on
+		if (this.opt('droppable')) { // only listen if this setting is on
 			el = $((ui ? ui.item : null) || ev.target);
 
 			// Test that the dragged element passes the dropAccept selector or filter function.
 			// FYI, the default is "*" (matches all)
-			accept = view.opt('dropAccept');
+			accept = this.opt('dropAccept');
 			if ($.isFunction(accept) ? accept.call(el[0], el) : el.is(accept)) {
 				if (!this.isDraggingExternal) { // prevent double-listening if fired twice
 					this.listenToExternalDrag(el, ev, ui);
@@ -732,7 +731,7 @@ Grid.mixin({
 
 		// Tracks mouse movement over the *grid's* coordinate map
 		var dragListener = this.segResizeListener = new HitDragListener(this, {
-			scroll: view.opt('dragScroll'),
+			scroll: this.opt('dragScroll'),
 			subjectEl: el,
 			interactionStart: function() {
 				isDragging = false;
@@ -981,8 +980,8 @@ Grid.mixin({
 
 		return source.backgroundColor ||
 			source.color ||
-			this.view.opt('eventBackgroundColor') ||
-			this.view.opt('eventColor');
+			this.opt('eventBackgroundColor') ||
+			this.opt('eventColor');
 	},
 
 
@@ -999,8 +998,8 @@ Grid.mixin({
 
 		return source.borderColor ||
 			source.color ||
-			this.view.opt('eventBorderColor') ||
-			this.view.opt('eventColor');
+			this.opt('eventBorderColor') ||
+			this.opt('eventColor');
 	},
 
 
@@ -1015,7 +1014,7 @@ Grid.mixin({
 		var source = seg.event.source || {};
 
 		return source.textColor ||
-			this.view.opt('eventTextColor');
+			this.opt('eventTextColor');
 	},
 
 

+ 15 - 19
src/common/Grid.js

@@ -56,7 +56,7 @@ var Grid = FC.Grid = ChronoComponent.extend({
 
 	// Generates the format string used for event time text, if not explicitly defined by 'timeFormat'
 	computeEventTimeFormat: function() {
-		return this.view.opt('smallTimeFormat');
+		return this.opt('smallTimeFormat');
 	},
 
 
@@ -95,21 +95,20 @@ var Grid = FC.Grid = ChronoComponent.extend({
 
 	// Updates values that rely on options and also relate to range
 	processRangeOptions: function() {
-		var view = this.view;
 		var displayEventTime;
 		var displayEventEnd;
 
 		this.eventTimeFormat =
-			view.opt('eventTimeFormat') ||
-			view.opt('timeFormat') || // deprecated
+			this.opt('eventTimeFormat') ||
+			this.opt('timeFormat') || // deprecated
 			this.computeEventTimeFormat();
 
-		displayEventTime = view.opt('displayEventTime');
+		displayEventTime = this.opt('displayEventTime');
 		if (displayEventTime == null) {
 			displayEventTime = this.computeDisplayEventTime(); // might be based off of range
 		}
 
-		displayEventEnd = view.opt('displayEventEnd');
+		displayEventEnd = this.opt('displayEventEnd');
 		if (displayEventEnd == null) {
 			displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
 		}
@@ -274,7 +273,6 @@ var Grid = FC.Grid = ChronoComponent.extend({
 
 	// Process a mousedown on an element that represents a day. For day clicking and selecting.
 	dayMousedown: function(ev) {
-		var view = this.view;
 
 		// HACK
 		// This will still work even though bindDayHandler doesn't use GlobalEmitter.
@@ -284,9 +282,9 @@ var Grid = FC.Grid = ChronoComponent.extend({
 
 		this.dayClickListener.startInteraction(ev);
 
-		if (view.opt('selectable')) {
+		if (this.opt('selectable')) {
 			this.daySelectListener.startInteraction(ev, {
-				distance: view.opt('selectMinDistance')
+				distance: this.opt('selectMinDistance')
 			});
 		}
 	},
@@ -304,14 +302,14 @@ var Grid = FC.Grid = ChronoComponent.extend({
 			return;
 		}
 
-		selectLongPressDelay = view.opt('selectLongPressDelay');
+		selectLongPressDelay = this.opt('selectLongPressDelay');
 		if (selectLongPressDelay == null) {
-			selectLongPressDelay = view.opt('longPressDelay'); // fallback
+			selectLongPressDelay = this.opt('longPressDelay'); // fallback
 		}
 
 		this.dayClickListener.startInteraction(ev);
 
-		if (view.opt('selectable')) {
+		if (this.opt('selectable')) {
 			this.daySelectListener.startInteraction(ev, {
 				delay: selectLongPressDelay
 			});
@@ -322,11 +320,10 @@ var Grid = FC.Grid = ChronoComponent.extend({
 	// Creates a listener that tracks the user's drag across day elements, for day clicking.
 	buildDayClickListener: function() {
 		var _this = this;
-		var view = this.view;
 		var dayClickHit; // null if invalid dayClick
 
 		var dragListener = new HitDragListener(this, {
-			scroll: view.opt('dragScroll'),
+			scroll: this.opt('dragScroll'),
 			interactionStart: function() {
 				dayClickHit = dragListener.origHit;
 			},
@@ -346,7 +343,7 @@ var Grid = FC.Grid = ChronoComponent.extend({
 					hitSpan = _this.getSafeHitSpan(dayClickHit);
 
 					if (hitSpan) {
-						view.triggerDayClick(hitSpan, _this.getHitEl(dayClickHit), ev);
+						_this.view.triggerDayClick(hitSpan, _this.getHitEl(dayClickHit), ev);
 					}
 				}
 			}
@@ -365,16 +362,15 @@ var Grid = FC.Grid = ChronoComponent.extend({
 	// Creates a listener that tracks the user's drag across day elements, for day selecting.
 	buildDaySelectListener: function() {
 		var _this = this;
-		var view = this.view;
 		var selectionSpan; // null if invalid selection
 
 		var dragListener = new HitDragListener(this, {
-			scroll: view.opt('dragScroll'),
+			scroll: this.opt('dragScroll'),
 			interactionStart: function() {
 				selectionSpan = null;
 			},
 			dragStart: function() {
-				view.unselect(); // since we could be rendering a new selection, we want to clear any old one
+				_this.view.unselect(); // since we could be rendering a new selection, we want to clear any old one
 			},
 			hitOver: function(hit, isOrig, origHit) {
 				var origHitSpan;
@@ -410,7 +406,7 @@ var Grid = FC.Grid = ChronoComponent.extend({
 			interactionEnd: function(ev, isCancelled) {
 				if (!isCancelled && selectionSpan) {
 					// the selection will already have been rendered. just report it
-					view.reportSelection(selectionSpan, ev);
+					_this.view.reportSelection(selectionSpan, ev);
 				}
 			}
 		});

+ 1 - 1
src/common/TimeGrid.events.js

@@ -482,7 +482,7 @@ TimeGrid.mixin({
 	// Generates an object with CSS properties/values that should be applied to an event segment element.
 	// Contains important positioning-related properties that should be applied to any event element, customized or not.
 	generateFgSegHorizontalCss: function(seg) {
-		var shouldOverlap = this.view.opt('slotEventOverlap');
+		var shouldOverlap = this.opt('slotEventOverlap');
 		var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
 		var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
 		var props = this.generateSegVerticalCss(seg); // get top/bottom first

+ 8 - 10
src/common/TimeGrid.js

@@ -111,9 +111,8 @@ var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
 
 	// Parses various options into properties of this object
 	processOptions: function() {
-		var view = this.view;
-		var slotDuration = view.opt('slotDuration');
-		var snapDuration = view.opt('snapDuration');
+		var slotDuration = this.opt('slotDuration');
+		var snapDuration = this.opt('snapDuration');
 		var input;
 
 		slotDuration = moment.duration(slotDuration);
@@ -127,16 +126,15 @@ var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
 
 		// might be an array value (for TimelineView).
 		// if so, getting the most granular entry (the last one probably).
-		input = view.opt('slotLabelFormat');
+		input = this.opt('slotLabelFormat');
 		if ($.isArray(input)) {
 			input = input[input.length - 1];
 		}
 
-		this.labelFormat =
-			input ||
-			view.opt('smallTimeFormat'); // the computed default
+		this.labelFormat = input ||
+			this.opt('smallTimeFormat'); // the computed default
 
-		input = view.opt('slotLabelInterval');
+		input = this.opt('slotLabelInterval');
 		this.labelInterval = input ?
 			moment.duration(input) :
 			this.computeLabelInterval(slotDuration);
@@ -164,7 +162,7 @@ var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
 
 	// Computes a default event time formatting string if `timeFormat` is not explicitly defined
 	computeEventTimeFormat: function() {
-		return this.view.opt('noMeridiemTimeFormat'); // like "6:30" (no AM/PM)
+		return this.opt('noMeridiemTimeFormat'); // like "6:30" (no AM/PM)
 	},
 
 
@@ -485,7 +483,7 @@ var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
 
 	// Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
 	renderSelection: function(span) {
-		if (this.view.opt('selectHelper')) { // this setting signals that a mock helper event should be rendered
+		if (this.opt('selectHelper')) { // this setting signals that a mock helper event should be rendered
 
 			// normally acceps an eventLocation, span has a start/end, which is good enough
 			this.renderEventLocationHelper(span);

+ 4 - 4
src/list/ListView.js

@@ -111,7 +111,7 @@ var ListViewGrid = Grid.extend({
 
 	// like "4:00am"
 	computeEventTimeFormat: function() {
-		return this.view.opt('mediumTimeFormat');
+		return this.opt('mediumTimeFormat');
 	},
 
 	// for events with a url, the whole <tr> should be clickable,
@@ -149,7 +149,7 @@ var ListViewGrid = Grid.extend({
 			'<div class="fc-list-empty-wrap2">' + // TODO: try less wraps
 			'<div class="fc-list-empty-wrap1">' +
 			'<div class="fc-list-empty">' +
-				htmlEscape(this.view.opt('noEventsMessage')) +
+				htmlEscape(this.opt('noEventsMessage')) +
 			'</div>' +
 			'</div>' +
 			'</div>'
@@ -202,8 +202,8 @@ var ListViewGrid = Grid.extend({
 	// generates the HTML for the day headers that live amongst the event rows
 	dayHeaderHtml: function(dayDate) {
 		var view = this.view;
-		var mainFormat = view.opt('listDayFormat');
-		var altFormat = view.opt('listDayAltFormat');
+		var mainFormat = this.opt('listDayFormat');
+		var altFormat = this.opt('listDayAltFormat');
 
 		return '<tr class="fc-list-heading" data-date="' + dayDate.format('YYYY-MM-DD') + '">' +
 			'<td class="' + view.widgetHeaderClass + '" colspan="3">' +