|
@@ -1,12 +1,12 @@
|
|
|
|
|
|
|
|
-/* Top toolbar area with buttons and title
|
|
|
|
|
|
|
+/* Toolbar with buttons and title
|
|
|
----------------------------------------------------------------------------------------------------------------------*/
|
|
----------------------------------------------------------------------------------------------------------------------*/
|
|
|
-// TODO: rename all header-related things to "toolbar"
|
|
|
|
|
|
|
|
|
|
-function Header(calendar) {
|
|
|
|
|
|
|
+function Toolbar(calendar, options) {
|
|
|
var t = this;
|
|
var t = this;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// exports
|
|
// exports
|
|
|
|
|
+ t.setOptions = setOptions;
|
|
|
t.render = render;
|
|
t.render = render;
|
|
|
t.removeElement = removeElement;
|
|
t.removeElement = removeElement;
|
|
|
t.updateTitle = updateTitle;
|
|
t.updateTitle = updateTitle;
|
|
@@ -16,23 +16,26 @@ function Header(calendar) {
|
|
|
t.enableButton = enableButton;
|
|
t.enableButton = enableButton;
|
|
|
t.getViewsWithButtons = getViewsWithButtons;
|
|
t.getViewsWithButtons = getViewsWithButtons;
|
|
|
t.el = null; // mirrors local `el`
|
|
t.el = null; // mirrors local `el`
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// locals
|
|
// locals
|
|
|
var el;
|
|
var el;
|
|
|
var viewsWithButtons = [];
|
|
var viewsWithButtons = [];
|
|
|
var tm;
|
|
var tm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ function setOptions(newOptions) {
|
|
|
|
|
+ options = newOptions;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// can be called repeatedly and will rerender
|
|
// can be called repeatedly and will rerender
|
|
|
function render() {
|
|
function render() {
|
|
|
- var options = calendar.options;
|
|
|
|
|
- var sections = options.header;
|
|
|
|
|
|
|
+ var sections = options.layout;
|
|
|
|
|
|
|
|
tm = options.theme ? 'ui' : 'fc';
|
|
tm = options.theme ? 'ui' : 'fc';
|
|
|
|
|
|
|
|
if (sections) {
|
|
if (sections) {
|
|
|
if (!el) {
|
|
if (!el) {
|
|
|
- el = this.el = $("<div class='fc-toolbar'/>");
|
|
|
|
|
|
|
+ el = this.el = $("<div class='fc-toolbar "+ options.extraClasses + "'/>");
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
el.empty();
|
|
el.empty();
|
|
@@ -46,20 +49,19 @@ function Header(calendar) {
|
|
|
removeElement();
|
|
removeElement();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function removeElement() {
|
|
function removeElement() {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.remove();
|
|
el.remove();
|
|
|
el = t.el = null;
|
|
el = t.el = null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function renderSection(position) {
|
|
function renderSection(position) {
|
|
|
var sectionEl = $('<div class="fc-' + position + '"/>');
|
|
var sectionEl = $('<div class="fc-' + position + '"/>');
|
|
|
- var options = calendar.options;
|
|
|
|
|
- var buttonStr = options.header[position];
|
|
|
|
|
|
|
+ var buttonStr = options.layout[position];
|
|
|
|
|
|
|
|
if (buttonStr) {
|
|
if (buttonStr) {
|
|
|
$.each(buttonStr.split(' '), function(i) {
|
|
$.each(buttonStr.split(' '), function(i) {
|
|
@@ -217,31 +219,31 @@ function Header(calendar) {
|
|
|
|
|
|
|
|
return sectionEl;
|
|
return sectionEl;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function updateTitle(text) {
|
|
function updateTitle(text) {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.find('h2').text(text);
|
|
el.find('h2').text(text);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function activateButton(buttonName) {
|
|
function activateButton(buttonName) {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.find('.fc-' + buttonName + '-button')
|
|
el.find('.fc-' + buttonName + '-button')
|
|
|
.addClass(tm + '-state-active');
|
|
.addClass(tm + '-state-active');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function deactivateButton(buttonName) {
|
|
function deactivateButton(buttonName) {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.find('.fc-' + buttonName + '-button')
|
|
el.find('.fc-' + buttonName + '-button')
|
|
|
.removeClass(tm + '-state-active');
|
|
.removeClass(tm + '-state-active');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function disableButton(buttonName) {
|
|
function disableButton(buttonName) {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.find('.fc-' + buttonName + '-button')
|
|
el.find('.fc-' + buttonName + '-button')
|
|
@@ -249,8 +251,8 @@ function Header(calendar) {
|
|
|
.addClass(tm + '-state-disabled');
|
|
.addClass(tm + '-state-disabled');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function enableButton(buttonName) {
|
|
function enableButton(buttonName) {
|
|
|
if (el) {
|
|
if (el) {
|
|
|
el.find('.fc-' + buttonName + '-button')
|
|
el.find('.fc-' + buttonName + '-button')
|