2016-03-31 15:39:38 +02:00
|
|
|
|
var gadjo_js = gadjo_js || {};
|
2015-06-15 17:47:30 +02:00
|
|
|
|
(function () {
|
2016-03-31 15:39:38 +02:00
|
|
|
|
if (gadjo_js.loaded) return
|
|
|
|
|
gadjo_js.loaded = true;
|
2015-06-15 17:47:30 +02:00
|
|
|
|
var $ = jQuery;
|
2017-06-01 17:13:11 +02:00
|
|
|
|
var popup_script_loaded = {};
|
|
|
|
|
var deferred_timeout = function (duration) {
|
|
|
|
|
var dfd = $.Deferred();
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
dfd.resolve();
|
|
|
|
|
}, duration);
|
|
|
|
|
return dfd.promise();
|
|
|
|
|
}
|
2015-06-15 17:47:30 +02:00
|
|
|
|
window.displayPopup = function(event)
|
|
|
|
|
{
|
|
|
|
|
/* Opens the target link into a dialog box
|
|
|
|
|
*
|
|
|
|
|
* The target link is extracted from the @href attribute for anchors or
|
|
|
|
|
* from the @data-url attribute for other tags.
|
|
|
|
|
*
|
|
|
|
|
* The dialog title is extracted from "#appbar h2" (this selector can be
|
|
|
|
|
* changed with a @data-title-selector attribute on the anchor tag).
|
|
|
|
|
*
|
|
|
|
|
* The dialog content is extracted from "form" (this selector can be
|
|
|
|
|
* changed with a @data-selector attribute).
|
|
|
|
|
*
|
|
|
|
|
* Buttons (both <button> and <a>) are extracted from the content and
|
|
|
|
|
* converted into proper dialog buttons. A button with "cancel" as its
|
|
|
|
|
* class will have its action changed to simply close the dialog, without
|
|
|
|
|
* server processing.
|
|
|
|
|
*
|
|
|
|
|
* After loading the dialog content, a gadjo:dialog-loaded event is
|
|
|
|
|
* triggered on the anchor with the dialog content as argument.
|
|
|
|
|
*
|
|
|
|
|
* Alternatively the server may notice the ajax request and answer with
|
|
|
|
|
* an appropriate JSON response. In that case it should have a 'content'
|
|
|
|
|
* attribute with the HTML content, or a 'location' attribute in case of
|
|
|
|
|
* a redirect.
|
|
|
|
|
*
|
|
|
|
|
* In case of such a redirect, a gadjo:dialog-done event is triggered on
|
|
|
|
|
* the anchor and can be cancelled to prevent the default redirect
|
|
|
|
|
* behaviour.
|
|
|
|
|
*
|
|
|
|
|
* The JSON support depends on the presence of the jQuery Form plugin.
|
2015-09-28 10:38:18 +02:00
|
|
|
|
*
|
|
|
|
|
* Submit is done in place if the $anchor has a data-inplace-submit="true"
|
|
|
|
|
* attribute, a gadjo:dialog-done event is triggered on success, a
|
|
|
|
|
* gadjo:dialog-submit-error event is triggered on failure.
|
2016-04-12 13:42:20 +02:00
|
|
|
|
*
|
2019-10-29 09:47:44 +01:00
|
|
|
|
* Set data-autoclose-dialog="true" to close the dialog box after the
|
|
|
|
|
* submit.
|
|
|
|
|
*
|
2016-04-12 13:42:20 +02:00
|
|
|
|
* Dialog is modal by default, set data-modal="false" for non-modal
|
|
|
|
|
* dialogs.
|
2015-06-15 17:47:30 +02:00
|
|
|
|
*/
|
|
|
|
|
var $anchor = $(this);
|
|
|
|
|
var url = $anchor.attr('href') || $anchor.data('url');
|
|
|
|
|
var selector = $anchor.data('selector') || 'form:not(.gadjo-popup-ignore)';
|
|
|
|
|
var title_selector = $anchor.data('title-selector') || '#appbar h2';
|
2015-09-28 10:38:18 +02:00
|
|
|
|
var inplace_submit = $anchor.data('inplace-submit');
|
2019-10-29 09:47:44 +01:00
|
|
|
|
var autoclose_dialog = $anchor.data('autoclose-dialog');
|
2016-04-12 13:42:20 +02:00
|
|
|
|
var modal = $anchor.data('modal');
|
2017-08-27 11:58:35 +02:00
|
|
|
|
if (url == '#') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-04-12 13:42:20 +02:00
|
|
|
|
if (modal === undefined) {
|
|
|
|
|
modal = true;
|
|
|
|
|
}
|
2015-06-15 17:47:30 +02:00
|
|
|
|
|
|
|
|
|
function show_error(message) {
|
|
|
|
|
/* Add a div to body to show an error message and fade it out after 3
|
|
|
|
|
* seconds */
|
|
|
|
|
$('<div id="gadjo-ajax-error"></div>')
|
|
|
|
|
.text(message)
|
|
|
|
|
.appendTo('body')
|
|
|
|
|
.delay(3000)
|
|
|
|
|
.fadeOut(400, function () {
|
|
|
|
|
$(this).remove();
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-06-10 14:26:06 +02:00
|
|
|
|
|
2015-06-15 17:47:30 +02:00
|
|
|
|
function ajaxform_submit(data, status, xhr, form) {
|
|
|
|
|
if ('location' in data) {
|
|
|
|
|
var e = $.Event('gadjo:dialog-done');
|
2018-12-11 14:25:42 +01:00
|
|
|
|
if (document.body.contains($anchor[0])) {
|
2015-11-16 14:36:06 +01:00
|
|
|
|
$anchor.trigger(e, data);
|
2015-06-15 17:47:30 +02:00
|
|
|
|
} else {
|
2015-11-16 14:36:06 +01:00
|
|
|
|
$(document).trigger(e, data);
|
2015-06-15 17:47:30 +02:00
|
|
|
|
}
|
|
|
|
|
/* check if the event action has been prevented, and don't do
|
|
|
|
|
* anything in that case. */
|
|
|
|
|
if (! e.isDefaultPrevented()) {
|
|
|
|
|
if (data.location.split('#')[0] == window.location.href.split('#')[0]) {
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
}
|
|
|
|
|
window.location = data.location;
|
2014-07-21 13:54:20 +02:00
|
|
|
|
}
|
2014-08-13 11:07:47 +02:00
|
|
|
|
} else {
|
2015-06-15 17:47:30 +02:00
|
|
|
|
var $form = $(form);
|
|
|
|
|
$form.empty().append($(data.content).find(selector).children());
|
|
|
|
|
$form.find('.buttons').hide();
|
2018-12-11 14:25:42 +01:00
|
|
|
|
if (document.body.contains($anchor[0])) {
|
2015-06-15 17:47:30 +02:00
|
|
|
|
$anchor.trigger('gadjo:dialog-loaded', $form);
|
|
|
|
|
} else {
|
|
|
|
|
$(document).trigger('gadjo:dialog-loaded', $form);
|
|
|
|
|
}
|
2014-08-13 11:07:47 +02:00
|
|
|
|
}
|
2014-07-18 17:35:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 17:47:30 +02:00
|
|
|
|
/* Close existing dialog boxes */
|
|
|
|
|
$(".ui-dialog-content").dialog("destroy");
|
2015-05-05 11:12:22 +02:00
|
|
|
|
|
2015-06-15 17:47:30 +02:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
success: function(html) {
|
|
|
|
|
var is_json = typeof html != 'string';
|
|
|
|
|
if (is_json) {
|
|
|
|
|
/* get html out of json */
|
|
|
|
|
var html = html.content;
|
|
|
|
|
} else {
|
|
|
|
|
var html = html;
|
|
|
|
|
}
|
|
|
|
|
var $html = $(html);
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* load additional scripts from popup */
|
|
|
|
|
var $script = $html.filter('script[src]');
|
|
|
|
|
var loading = [];
|
|
|
|
|
for (var i = 0; i < $script.length; i++) {
|
|
|
|
|
var script = $script[i];
|
|
|
|
|
var src = script.attributes.src.value;
|
|
|
|
|
if ($('script[src="' + src + '"]').length) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (popup_script_loaded[src]) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
popup_script_loaded[src] = true;
|
|
|
|
|
loading.push($.ajax({
|
|
|
|
|
url: src,
|
|
|
|
|
dataType: 'script',
|
|
|
|
|
cache: true,
|
|
|
|
|
success: function () {},
|
|
|
|
|
}));
|
2015-06-15 17:47:30 +02:00
|
|
|
|
}
|
2018-08-02 17:34:34 +02:00
|
|
|
|
/* load additional stylesheets from popup */
|
|
|
|
|
var $stylesheet = $html.filter('link[rel="stylesheet"]');
|
|
|
|
|
for (var i = 0; i < $stylesheet.length; i++) {
|
|
|
|
|
var stylesheet = $stylesheet[i];
|
|
|
|
|
var href = stylesheet.attributes.href.value;
|
|
|
|
|
if ($('link[rel="stylesheet"][href="' + href + '"]').length) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$(stylesheet).appendTo($('head'));
|
|
|
|
|
}
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* add millisecond timeout to let additional scripts load */
|
|
|
|
|
$.when(loading, deferred_timeout(100)).always(function () {
|
|
|
|
|
/* get content and form (if different) ouf of html */
|
|
|
|
|
var $content = $html.find(selector);
|
|
|
|
|
if ($content.is('form')) {
|
|
|
|
|
var $form = $content;
|
|
|
|
|
} else {
|
|
|
|
|
var $form = $content.find('form');
|
|
|
|
|
}
|
2014-07-21 13:54:20 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* get title out of html */
|
|
|
|
|
var title = $html.find(title_selector).text();
|
2014-07-18 17:35:45 +02:00
|
|
|
|
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$content.dialog({
|
2017-06-01 17:13:11 +02:00
|
|
|
|
modal: modal,
|
|
|
|
|
'title': title,
|
|
|
|
|
width: 'auto',
|
|
|
|
|
close: function (ev, ui) {
|
|
|
|
|
$(this).dialog('destroy');
|
|
|
|
|
},
|
|
|
|
|
});
|
2014-07-18 17:35:45 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* if the form doesn't have an @action attribute, set it to URL */
|
|
|
|
|
if (! $form.attr('action')) {
|
|
|
|
|
$form.attr('action', url);
|
|
|
|
|
}
|
2014-07-18 17:35:45 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* hide buttons from content and convert buttons (<button> and <a>)
|
|
|
|
|
* into proper dialog buttons */
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$content.find('.buttons').hide();
|
2015-06-15 17:47:30 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
var buttons = Array();
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$content.find('.buttons button, .buttons a').each(function(idx, elem) {
|
2017-06-01 17:13:11 +02:00
|
|
|
|
var $elem = $(elem);
|
|
|
|
|
var button = Object();
|
2015-06-15 17:47:30 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
button.text = $elem.text();
|
|
|
|
|
if ($elem.prop('disabled')) {
|
|
|
|
|
button.disabled = 'disabled';
|
|
|
|
|
}
|
|
|
|
|
if ($elem.hasClass('cancel')) {
|
|
|
|
|
/* special behaviour for the cancel button: do not send
|
|
|
|
|
* anything to server, just close the dialog */
|
2017-09-22 10:48:37 +02:00
|
|
|
|
button.click = function() { $content.dialog('destroy'); return false; };
|
2017-06-01 17:13:11 +02:00
|
|
|
|
} else {
|
|
|
|
|
button.click = function() {
|
|
|
|
|
if (inplace_submit) {
|
|
|
|
|
var action_url = $form.attr('action');
|
|
|
|
|
if ($form[0].checkValidity() === false) {
|
|
|
|
|
/* if HTML5 validation fails, we trigger a
|
|
|
|
|
* click to get the errors displayed */
|
|
|
|
|
$form.find('button').click();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$('.ui-dialog-buttonpane button').button('disable');
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: action_url,
|
|
|
|
|
data: $form.serialize(),
|
|
|
|
|
}).success(function(data) {
|
|
|
|
|
$anchor.trigger('gadjo:dialog-done', data);
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$content.dialog('destroy');
|
2017-06-01 17:13:11 +02:00
|
|
|
|
}).fail(function() { $anchor.trigger('gadjo:dialog-submit-error');
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2017-09-22 11:01:40 +02:00
|
|
|
|
if ($elem.is('a')) {
|
|
|
|
|
window.location = $elem.attr('href');
|
|
|
|
|
} else {
|
|
|
|
|
$elem.click();
|
|
|
|
|
}
|
2019-10-29 09:47:44 +01:00
|
|
|
|
var validated = true;
|
|
|
|
|
$form.find('input, textarea').each(function() {
|
|
|
|
|
if ($(this)[0].checkValidity != undefined) {
|
|
|
|
|
validated &= $(this)[0].checkValidity();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (autoclose_dialog & validated) {
|
|
|
|
|
$content.dialog('destroy');
|
|
|
|
|
}
|
2015-12-29 18:16:44 +01:00
|
|
|
|
}
|
2017-06-01 17:13:11 +02:00
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-06-15 17:47:30 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* add custom classes to some buttons */
|
|
|
|
|
if ($elem.hasClass('submit-button')) {
|
|
|
|
|
button.class = 'submit-button';
|
|
|
|
|
} else if ($elem.hasClass('cancel') || $elem.hasClass('cancel-button')) {
|
|
|
|
|
button.class = 'cancel-button';
|
|
|
|
|
} else if ($elem.hasClass('delete-button')) {
|
|
|
|
|
button.class = 'delete-button';
|
|
|
|
|
}
|
|
|
|
|
buttons.push(button);
|
|
|
|
|
});
|
2014-07-18 17:35:45 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
buttons.reverse();
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$content.dialog('option', 'buttons', buttons);
|
2014-07-18 17:35:45 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* focus initial input field */
|
|
|
|
|
if ($form.find('input:visible').length) {
|
|
|
|
|
$form.find('input:visible')[0].focus();
|
|
|
|
|
}
|
2014-07-21 13:54:20 +02:00
|
|
|
|
|
2017-06-01 17:13:11 +02:00
|
|
|
|
/* if received content was in json, apply jQuery Form plugin on it */
|
|
|
|
|
if (is_json && $.fn.ajaxForm != undefined) {
|
|
|
|
|
$form.ajaxForm({
|
|
|
|
|
success: ajaxform_submit,
|
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
|
show_error("Dialog box submit failed: " + textStatus + " " + errorThrown);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-09-22 10:48:37 +02:00
|
|
|
|
$anchor.trigger('gadjo:dialog-loaded', $content);
|
2017-06-01 17:13:11 +02:00
|
|
|
|
});
|
2015-06-15 17:47:30 +02:00
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
|
show_error("Dialog box loading failed: " + textStatus + " " + errorThrown);
|
2014-07-18 17:35:45 +02:00
|
|
|
|
}
|
2015-06-15 17:47:30 +02:00
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-07-21 13:54:20 +02:00
|
|
|
|
|
2022-03-26 17:30:03 +01:00
|
|
|
|
// Tabs
|
|
|
|
|
// adapted from https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role
|
|
|
|
|
gadjo_js.Tabs = function(tabs_el) {
|
|
|
|
|
this.parent = tabs_el;
|
|
|
|
|
this.tabList = this.parent.querySelector('[role="tablist"]');
|
|
|
|
|
this.tabs = this.tabList.querySelectorAll('[role="tab"]');
|
|
|
|
|
this.tabpanels = this.parent.querySelectorAll('[role="tabpanel"]');
|
|
|
|
|
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gadjo_js.Tabs.prototype = {
|
|
|
|
|
init : function() {
|
|
|
|
|
const _self = this;
|
|
|
|
|
|
|
|
|
|
// Add a click event handler to each tab
|
|
|
|
|
this.tabs.forEach(function(tab) {
|
|
|
|
|
tab.addEventListener('click', function(e) {_self.selectTab.call(_self, e)});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Enable arrow navigation between tabs in the tab list
|
|
|
|
|
let tabFocus = 0;
|
|
|
|
|
|
|
|
|
|
this.tabList.addEventListener('keydown', function(e) {
|
|
|
|
|
// Move up & down
|
|
|
|
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
_self.tabs[tabFocus].setAttribute('tabindex', -1);
|
|
|
|
|
if (e.key === "ArrowDown") {
|
|
|
|
|
tabFocus++;
|
|
|
|
|
// If we're at the end, go to the start
|
|
|
|
|
if (tabFocus >= _self.tabs.length) {
|
|
|
|
|
tabFocus = 0;
|
|
|
|
|
}
|
|
|
|
|
} else if (e.key === "ArrowUp") {
|
|
|
|
|
tabFocus--;
|
|
|
|
|
// If we're at the start, move to the end
|
|
|
|
|
if (tabFocus < 0) {
|
|
|
|
|
tabFocus = _self.tabs.length - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_self.tabs[tabFocus].setAttribute('tabindex', 0);
|
|
|
|
|
_self.tabs[tabFocus].focus();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
selectTab: function(e) {
|
|
|
|
|
const btn = e.target && e.target || e;
|
|
|
|
|
|
|
|
|
|
// Remove all current selected tabs
|
|
|
|
|
this.tabList
|
|
|
|
|
.querySelectorAll('[aria-selected="true"]')
|
|
|
|
|
.forEach(function(t) { t.setAttribute('aria-selected', false); });
|
|
|
|
|
|
|
|
|
|
// Set this tab as selected
|
|
|
|
|
btn.setAttribute('aria-selected', true);
|
|
|
|
|
|
|
|
|
|
// Hide all tab panels
|
|
|
|
|
this.tabpanels.forEach(function(p) { p.hidden = true });
|
|
|
|
|
|
|
|
|
|
// Show the selected panel
|
|
|
|
|
this.parent
|
|
|
|
|
.querySelector('#' + btn.getAttribute('aria-controls'))
|
|
|
|
|
.hidden = false;
|
|
|
|
|
|
2022-04-12 08:53:49 +02:00
|
|
|
|
// Trigger gadjo:tab-selected event on panel
|
|
|
|
|
$(this.parent.querySelector('#' + btn.getAttribute('aria-controls'))).trigger('gadjo:tab-selected');
|
2022-03-26 17:30:03 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
$(document.querySelectorAll('.pk-tabs')).each(function(i, el) {
|
|
|
|
|
el.tabs = new gadjo_js.Tabs(el);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-11-06 09:21:20 +01:00
|
|
|
|
var storage = undefined;
|
|
|
|
|
try {
|
|
|
|
|
window.localStorage._gadgo_test = true;
|
|
|
|
|
window.localStorage.removeItem('_gadjo_test');
|
|
|
|
|
storage = window.localStorage;
|
|
|
|
|
} catch(e) {
|
|
|
|
|
try {
|
|
|
|
|
window.sessionStorage._gadjo_test = true;
|
|
|
|
|
window.sessionStorage.removeItem('_gadjo_test');
|
|
|
|
|
storage = window.sessionStorage;
|
|
|
|
|
} catch(e) {
|
|
|
|
|
storage = Object();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 17:47:30 +02:00
|
|
|
|
$(function() {
|
2016-07-17 14:49:03 +02:00
|
|
|
|
var cookie_domain = window.location.hostname.split('.').slice(1).join('.');
|
|
|
|
|
|
|
|
|
|
function readCookie(name) { /* http://www.quirksmode.org/js/cookies.html */
|
|
|
|
|
var nameEQ = name + "=";
|
|
|
|
|
var ca = document.cookie.split(';');
|
|
|
|
|
for(var i=0;i < ca.length;i++) {
|
|
|
|
|
var c = ca[i];
|
|
|
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
|
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function set_sidepage_status(sidepage_status) {
|
|
|
|
|
storage.sidepage_status = sidepage_status;
|
|
|
|
|
if (cookie_domain) {
|
|
|
|
|
var date = new Date();
|
|
|
|
|
date.setTime(date.getTime() + (10 * 86400 * 1000)); /* a long week */
|
|
|
|
|
document.cookie = 'gadjo_sidepage_status=' + sidepage_status +
|
|
|
|
|
'; expires=' + date.toGMTString() +
|
2020-08-17 22:23:48 +02:00
|
|
|
|
(window.location.protocol == "https:" && "; Secure" || "") +
|
|
|
|
|
'; sameSite=Strict' +
|
2016-07-17 14:49:03 +02:00
|
|
|
|
'; domain=.' + cookie_domain +
|
|
|
|
|
'; path=/';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function get_sidepage_status() {
|
|
|
|
|
if (window.location.protocol == 'file:') {
|
|
|
|
|
/* don't open sidepage when loading from a file:// */
|
|
|
|
|
return 'collapsed';
|
|
|
|
|
}
|
|
|
|
|
var sidepage_status = null;
|
|
|
|
|
if (cookie_domain) {
|
|
|
|
|
sidepage_status = readCookie('gadjo_sidepage_status');
|
|
|
|
|
} else {
|
|
|
|
|
sidepage_status = storage.sidepage_status;
|
|
|
|
|
}
|
|
|
|
|
if (!sidepage_status &&
|
|
|
|
|
typeof(GADJO_DEFAULT_SIDEPAGE_STATUS) !== "undefined") {
|
|
|
|
|
return GADJO_DEFAULT_SIDEPAGE_STATUS;
|
|
|
|
|
}
|
|
|
|
|
return sidepage_status;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-16 16:16:45 +02:00
|
|
|
|
$(document).on('click.gadjo', 'a[rel=popup], a[data-popup]', displayPopup);
|
2015-09-12 10:24:17 +02:00
|
|
|
|
if ($('#sidepage').length) {
|
|
|
|
|
var sidepage_button = $('#sidepage #applabel');
|
|
|
|
|
sidepage_button.on('click', function() {
|
2018-03-10 14:55:52 +01:00
|
|
|
|
$('body').addClass('enable-transitions');
|
|
|
|
|
$('body').toggleClass('sidepage-expanded');
|
|
|
|
|
if ($('body').hasClass('sidepage-expanded')) {
|
2016-07-17 14:49:03 +02:00
|
|
|
|
set_sidepage_status('expanded');
|
2015-09-12 10:24:17 +02:00
|
|
|
|
} else {
|
2016-07-17 14:49:03 +02:00
|
|
|
|
set_sidepage_status('collasped');
|
2015-09-12 10:24:17 +02:00
|
|
|
|
}
|
2019-05-28 09:29:02 +02:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
// delay to get the CSS transition to run
|
|
|
|
|
$(window).trigger('gadjo:sidepage-toggled');
|
|
|
|
|
}, 500);
|
2015-09-12 10:24:17 +02:00
|
|
|
|
});
|
2017-09-05 23:07:30 +02:00
|
|
|
|
if ($(window).width() > 760) {
|
|
|
|
|
if (get_sidepage_status() == 'expanded') {
|
2018-03-10 14:55:52 +01:00
|
|
|
|
$('body').toggleClass('sidepage-expanded');
|
2017-09-05 23:07:30 +02:00
|
|
|
|
}
|
2014-07-11 13:10:51 +02:00
|
|
|
|
}
|
2015-06-15 17:47:30 +02:00
|
|
|
|
}
|
2014-07-11 13:10:51 +02:00
|
|
|
|
});
|
2018-02-11 17:46:51 +01:00
|
|
|
|
$(function () { /* foldable elements with memory */
|
2016-01-27 15:59:56 +01:00
|
|
|
|
function gadjo_unfold_saved() {
|
|
|
|
|
$('.gadjo-folded').each(function (idx, elem) {
|
|
|
|
|
if (elem.id && sessionStorage['gadjo-foldable-id-' + elem.id + '-' + window.location.pathname] == "true") {
|
|
|
|
|
$(elem).removeClass('gadjo-folded');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
gadjo_unfold_saved()
|
|
|
|
|
$(document).on('gadjo:content-update', gadjo_unfold_saved);
|
|
|
|
|
$('body').on('click', '.gadjo-foldable-widget', function (event) {
|
|
|
|
|
var $parent = $(event.target).closest('.gadjo-foldable');
|
|
|
|
|
$parent.toggleClass('gadjo-folded');
|
|
|
|
|
if ($parent[0].id) {
|
|
|
|
|
sessionStorage['gadjo-foldable-id-' + $parent[0].id + '-' + window.location.pathname] = ! $parent.is('.gadjo-folded');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-02-11 17:46:51 +01:00
|
|
|
|
$(function () { /* foldable sections */
|
|
|
|
|
$('.section.foldable > h2, .section.foldable > h3').on('click', function() {
|
|
|
|
|
$(this).parent().toggleClass('folded');
|
|
|
|
|
});
|
|
|
|
|
});
|
2016-07-09 08:53:18 +02:00
|
|
|
|
$(function () {
|
2016-08-20 11:33:32 +02:00
|
|
|
|
if ($('body').data('gadjo')) {
|
|
|
|
|
if ($('#sidepage').length == 1) {
|
2018-03-11 11:05:28 +01:00
|
|
|
|
$('body').attr('data-has-sidepage', 'true');
|
2016-08-20 11:33:32 +02:00
|
|
|
|
}
|
2017-05-28 20:12:38 +02:00
|
|
|
|
/* add × to close notification messages */
|
|
|
|
|
$('.messages > li').each(function(idx, elem) {
|
|
|
|
|
var elem = $('<a aria-hidden="true" class="close">×</a>');
|
|
|
|
|
$(elem).on('click', function() {
|
|
|
|
|
$(this).parent('li').fadeOut('slow');
|
|
|
|
|
});
|
|
|
|
|
$(this).prepend(elem);
|
2017-01-16 09:37:50 +01:00
|
|
|
|
});
|
2017-05-28 20:12:38 +02:00
|
|
|
|
}
|
2016-07-09 08:53:18 +02:00
|
|
|
|
});
|
2017-01-31 11:42:16 +01:00
|
|
|
|
$(function() {
|
2019-07-16 08:42:10 +02:00
|
|
|
|
$('#main-content').on('click', 'a.extra-actions-menu-opener', function() {
|
2017-01-31 11:42:16 +01:00
|
|
|
|
$(this).toggleClass('open');
|
|
|
|
|
$('.extra-actions-menu').toggleClass('open');
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-12-17 18:31:11 +01:00
|
|
|
|
$(function() {
|
2022-01-07 10:22:17 +01:00
|
|
|
|
$(document).on('click auxclick', '.clickable-rows tr', function(event) {
|
2021-12-17 18:31:11 +01:00
|
|
|
|
var $target = $(event.target);
|
|
|
|
|
if ($target.is('input, button, a')) {
|
2022-01-05 17:49:34 +01:00
|
|
|
|
return true;
|
2021-12-17 18:31:11 +01:00
|
|
|
|
}
|
2022-01-30 13:40:54 +01:00
|
|
|
|
if (window.getSelection().toString()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-01-28 23:10:07 +01:00
|
|
|
|
var href = $(this).find('a[href]').prop('href');
|
|
|
|
|
if (href) {
|
2021-12-17 18:31:11 +01:00
|
|
|
|
if (event.which == 2 || event.ctrlKey) {
|
2022-01-28 23:10:07 +01:00
|
|
|
|
window.open(href, '_blank');
|
2021-12-17 18:31:11 +01:00
|
|
|
|
} else {
|
2022-01-28 23:10:07 +01:00
|
|
|
|
window.location = href;
|
2021-12-17 18:31:11 +01:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-07-17 12:52:42 +02:00
|
|
|
|
$(function() {
|
|
|
|
|
$('.varname').on('click', function() {
|
|
|
|
|
var doc = window.document, sel, range;
|
|
|
|
|
if (window.getSelection && doc.createRange) {
|
|
|
|
|
sel = window.getSelection();
|
|
|
|
|
range = doc.createRange();
|
|
|
|
|
range.selectNodeContents(this);
|
|
|
|
|
sel.removeAllRanges();
|
|
|
|
|
sel.addRange(range);
|
|
|
|
|
} else if (doc.body.createTextRange) {
|
|
|
|
|
range = doc.body.createTextRange();
|
|
|
|
|
range.moveToElementText(this);
|
|
|
|
|
range.select();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-06-15 17:47:30 +02:00
|
|
|
|
})();
|