Commit c56f56b1 authored by bbaer's avatar bbaer

added fullcalendar.js basis implementation

parent 612fc161
Pipeline #3134 passed with stages
in 1 minute and 58 seconds
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
/* global console */
/* global FullCalendar */
/* global $ */
/**
* Qfq Namespace
*
* @namespace QfqNS
*/
var QfqNS = QfqNS || {};
/**
* Qfq Helper Namespace
*
* @namespace QfqNS.Helper
*/
QfqNS.Helper = QfqNS.Helper || {};
(function (n) {
'use strict';
/**
* Initializes fullcalendar.js.
*
* The Full Calendar configuration has to be provided in the `data-config` attribute as JSON. E.g.
*
* <div class="qfq-calendar" data-config='{ "plugins": [ 'dayGrid' ] }'></textarea>
*
* @function
*/
var fullCalendar = function () {
if (typeof FullCalendar === 'undefined') {
QfqNS.log.error("FullCalendar Plugin wasn't loaded correctly.");
return;
}
$("div.qfq-calendar").each(
function () {
var config = {};
var $this = $(this);
var element = document.getElementById($this.attr('id'));
var configData = $this.data('config');
if (configData) {
if (configData instanceof Object) {
// jQuery takes care of decoding data-config to JavaScript object.
config = configData;
} else {
QfqNS.Log.warning("'data-config' is invalid: " + configData);
}
}
var calendar = new FullCalendar.Calendar(element, configData);
calendar.render();
calendar.on('change', (function ($form, $textArea) {
return function (instance, changeObj) {
$textArea.val(instance.getValue());
$form.change();
};
})($(this).closest('form'), $this));
}
);
};
n.calendar = fullCalendar;
})(QfqNS.Helper);
\ No newline at end of file
......@@ -153,6 +153,7 @@ var QfqNS = QfqNS || {};
//n.Helper.jqxEditor();
n.Helper.tinyMce();
n.Helper.codemirror();
n.Helper.calendar();
this.form.on('form.submit.before', n.Helper.tinyMce.prepareSave);
this.form.on('form.validation.before', n.Helper.tinyMce.prepareSave);
this.form.on('form.validation.failed', this.validationError);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment