|
|
@@ -240,6 +240,57 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
|
|
|
},
|
|
|
|
|
|
|
|
|
+ /* Navigation
|
|
|
+ ------------------------------------------------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+
|
|
|
+ // Generates HTML for an anchor to another view into the calendar.
|
|
|
+ // Will either generate an <a> tag or a non-clickable <span> tag, depending on enabled settings.
|
|
|
+ // `gotoOptions` can either be a moment input, or an object with the form:
|
|
|
+ // { date, type, forceOff }
|
|
|
+ // `type` is a view-type like "day" or "week". default value is "day".
|
|
|
+ // `attrs` and `innerHtml` are use to generate the rest of the HTML tag.
|
|
|
+ buildGotoAnchorHtml: function(gotoOptions, attrs, innerHtml) {
|
|
|
+ var date, type, forceOff;
|
|
|
+ var finalOptions;
|
|
|
+
|
|
|
+ if ($.isPlainObject(gotoOptions)) {
|
|
|
+ date = gotoOptions.date;
|
|
|
+ type = gotoOptions.type;
|
|
|
+ forceOff = gotoOptions.forceOff;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ date = gotoOptions; // a single moment input
|
|
|
+ }
|
|
|
+ date = FC.moment(date); // if a string, parse it
|
|
|
+
|
|
|
+ finalOptions = { // for serialization into the link
|
|
|
+ date: date.format('YYYY-MM-DD'),
|
|
|
+ type: type || 'day'
|
|
|
+ };
|
|
|
+
|
|
|
+ if (typeof attrs === 'string') {
|
|
|
+ innerHtml = attrs;
|
|
|
+ attrs = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space
|
|
|
+ innerHtml = innerHtml || '';
|
|
|
+
|
|
|
+ if (!forceOff && this.opt('navLinks')) {
|
|
|
+ return '<a' + attrs +
|
|
|
+ ' data-fc-goto="' + htmlEscape(JSON.stringify(finalOptions)) + '">' +
|
|
|
+ innerHtml +
|
|
|
+ '</a>';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return '<span' + attrs + '>' +
|
|
|
+ innerHtml +
|
|
|
+ '</span>';
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
/* Rendering
|
|
|
------------------------------------------------------------------------------------------------------------------*/
|
|
|
|