diff --git a/js/src/bundle.js b/js/src/bundle.js index 91c97348..2f301163 100644 --- a/js/src/bundle.js +++ b/js/src/bundle.js @@ -5,7 +5,7 @@ import { BatchedItemsSize, BatchedItemsSearch } from './batcheditems.js'; -import {Colormode} from './colormode.js'; +import {ColorMode} from './colormode.js'; import {ColorToggler} from './colormode.js'; import {CopySupport} from './copysupport.js'; import {KeyBinder} from './keybinder.js'; @@ -39,7 +39,7 @@ export * from './utils.js'; $(function() { new KeyBinder(); - new Colormode(); + new ColorMode(); ts.ajax.register(BatchedItemsSize.initialize, true); ts.ajax.register(BatchedItemsSearch.initialize, true); diff --git a/js/src/colormode.js b/js/src/colormode.js index 529a16ff..20ba503c 100644 --- a/js/src/colormode.js +++ b/js/src/colormode.js @@ -1,16 +1,17 @@ import ts from 'treibstoff'; -export class Colormode extends ts.ChangeListener { +export class ColorMode { - static set_theme(theme, elem) { - if (theme === 'auto' && this.match_media.matches) { - elem.get(0).setAttribute('data-bs-theme', 'dark'); + static set_theme(theme) { + const elem = document.documentElement; + if (theme === 'auto' && this.query.matches) { + elem.setAttribute('data-bs-theme', 'dark'); } else { - elem.get(0).setAttribute('data-bs-theme', theme); + elem.setAttribute('data-bs-theme', theme); } } - static get match_media() { + static get query() { return window.matchMedia('(prefers-color-scheme: dark)'); } @@ -26,20 +27,19 @@ export class Colormode extends ts.ChangeListener { if (this.stored_theme) { return this.stored_theme; } - return this.match_media.matches ? 'dark' : 'light'; + return this.query.matches ? 'dark' : 'light'; } constructor() { - super({elem: $(document.documentElement)}); this.bind(); - this.constructor.set_theme(this.constructor.preferred_theme, this.elem); + this.constructor.set_theme(this.constructor.preferred_theme); } bind() { const stored_theme = this.stored_theme; - this.constructor.match_media.addEventListener('change', () => { + this.constructor.query.addEventListener('change', () => { if (stored_theme !== 'light' || stored_theme !== 'dark') { - this.constructor.set_theme(this.constructor.preferred_theme, this.elem); + this.constructor.set_theme(this.constructor.preferred_theme); } }); } @@ -58,24 +58,25 @@ export class ColorToggler extends ts.ChangeListener { constructor(elem) { super({elem: elem}); this.update(); - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { + ColorMode.query.addEventListener('change', () => { this.update(); }); } update() { - const preferred_theme = Colormode.preferred_theme; - if (preferred_theme === 'dark' && !this.elem.is(':checked')) { - this.elem.get(0).checked = true; - } else if (preferred_theme == 'light' && this.elem.is(':checked')) { - this.elem.get(0).checked = false; + const preferred_theme = ColorMode.preferred_theme; + const elem = this.elem; + const checked = elem.is(':checked'); + if (preferred_theme === 'dark' && !checked) { + elem.prop('checked', true); + } else if (preferred_theme === 'light' && checked) { + elem.prop('checked', false); } } on_change() { - const document_elem = $(document.documentElement); const theme = this.elem.is(':checked') ? 'dark' : 'light'; - Colormode.set_theme(theme, document_elem); - Colormode.stored_theme = theme; + ColorMode.set_theme(theme); + ColorMode.stored_theme = theme; } -} \ No newline at end of file +} diff --git a/js/src/scrollbar.js b/js/src/scrollbar.js index 47c6c71f..b111cc33 100644 --- a/js/src/scrollbar.js +++ b/js/src/scrollbar.js @@ -1,7 +1,7 @@ import $ from 'jquery'; import ts from 'treibstoff'; -export class Scrollbar extends ts.Events { +export class Scrollbar extends ts.Motion { static initialize(context) { $('.scrollable-x', context).each(function() { @@ -21,7 +21,6 @@ export class Scrollbar extends ts.Events { this.on_scroll = this.on_scroll.bind(this); this.on_click = this.on_click.bind(this); - this.on_drag = this.on_drag.bind(this); this.on_hover = this.on_hover.bind(this); this.on_resize = this.on_resize.bind(this); @@ -54,19 +53,18 @@ export class Scrollbar extends ts.Events { bind() { this.pointer_events = true; - this.elem.css('pointer-events', 'all'); this.elem.on('mousewheel wheel', this.on_scroll); - this.scrollbar.on('click', this.on_click); - this.thumb.on('mousedown', this.on_drag); this.elem.on('mouseenter mouseleave', this.on_hover); + this.scrollbar.on('click', this.on_click); + this.set_scope(this.thumb, $(document)); $(window).on('resize', this.on_resize); } unbind() { this.elem.off('mousewheel wheel', this.on_scroll); - this.scrollbar.off('click', this.on_click); - this.thumb.off('mousedown', this.on_drag); this.elem.off('mouseenter mouseleave', this.on_hover); + this.scrollbar.off('click', this.on_click); + $(this.thumb).off('mousedown', this._down_handle); $(window).off('resize', this.on_resize); } @@ -116,80 +114,66 @@ export class Scrollbar extends ts.Events { this.render(); } - on_hover(e) { - e.preventDefault(); - e.stopPropagation(); + on_hover(evt) { + evt.preventDefault(); + evt.stopPropagation(); const elem = this.elem; if ( - (elem.has(e.target).length > 0 || elem.is(e.target)) && + (elem.has(evt.target).length > 0 || elem.is(evt.target)) && this.contentsize > this.scrollsize ) { - if (e.type === 'mouseenter') { + if (evt.type === 'mouseenter') { this.scrollbar.stop(true, true).fadeIn(); - } else if (e.type === 'mouseleave' && e.relatedTarget !== elem.get(0)) { + } else if ( + evt.type === 'mouseleave' && + evt.relatedTarget !== elem.get(0) + ) { this.scrollbar.stop(true, true).fadeOut(); } } } - on_scroll(e) { + on_scroll(evt) { if (this.contentsize <= this.scrollsize) { return; } - let evt = e.originalEvent; - if (typeof evt.deltaY === 'number') { - // down - if(evt.deltaY > 0) { + let evt_ = evt.originalEvent; + if (typeof evt_.deltaY === 'number') { + if (evt_.deltaY > 0) { // down this.position += this.scroll_step; - } - // up - else if(evt.deltaY < 0) { + } else if (evt_.deltaY < 0) { // up this.position -= this.scroll_step; } } } - on_click(e) { - e.preventDefault(); // prevent text selection + on_click(evt) { + evt.preventDefault(); // prevent text selection this.thumb.addClass('active'); - let position = this.pos_from_evt(e), + let position = this.pos_from_evt(evt), thumb_pos = position - this.offset - this.thumbsize / 2; this.position = this.contentsize * thumb_pos / this.scrollsize; this.thumb.removeClass('active'); } - on_drag(e) { - e.preventDefault(); - var evt = $.Event('dragstart'); - $(window).trigger(evt); - - function on_move(e) { - let mouse_pos_on_move = this.pos_from_evt(e) - this.offset, - new_thumb_pos = thumb_position + mouse_pos_on_move - mouse_pos; - this.position = this.contentsize * new_thumb_pos / this.scrollsize; - } - - function on_up() { - var evt = $.Event('dragend'); - $(window).trigger(evt); - $(document) - .off('mousemove', _on_move) - .off('mouseup', _on_up); - this.thumb.removeClass('active'); - this.elem.on('mouseenter mouseleave', this.on_hover); - } - - let _on_move = on_move.bind(this), - _on_up = on_up.bind(this), - mouse_pos = this.pos_from_evt(e) - this.offset, - thumb_position = this.position / (this.contentsize / this.scrollsize); + down(evt) { + this._mouse_pos = this.pos_from_evt(evt) - this.offset; + this._thumb_pos = this.position / (this.contentsize / this.scrollsize); + this.elem.off('mouseenter mouseleave', this.on_hover); this.thumb.addClass('active'); + } - this.elem.off('mouseenter mouseleave', this.on_hover); + move(evt) { + let mouse_pos = this.pos_from_evt(evt) - this.offset, + thumb_pos = this._thumb_pos + mouse_pos - this._mouse_pos; + this.position = this.contentsize * thumb_pos / this.scrollsize; + } - $(document) - .on('mousemove', _on_move) - .on('mouseup', _on_up); + up(evt) { + delete this._mouse_pos; + delete this._thumb_pos; + this.elem.on('mouseenter mouseleave', this.on_hover); + this.thumb.removeClass('active'); } } diff --git a/src/cone/app/browser/static/cone/cone.app.js b/src/cone/app/browser/static/cone/cone.app.js index b8a77fe6..28fa84bc 100644 --- a/src/cone/app/browser/static/cone/cone.app.js +++ b/src/cone/app/browser/static/cone/cone.app.js @@ -1,4 +1,4 @@ -var cone = (function (exports, $$1, ts) { +var cone = (function (exports, $, ts) { 'use strict'; class BatchedItemsFilter { @@ -33,8 +33,8 @@ var cone = (function (exports, $$1, ts) { class BatchedItemsSize extends BatchedItemsFilter { static initialize(context, selector='.batched_items_slice_size select') { - $$1(selector, context).each(function() { - new BatchedItemsSize($$1(this)); + $(selector, context).each(function() { + new BatchedItemsSize($(this)); }); } constructor(elem) { @@ -42,7 +42,7 @@ var cone = (function (exports, $$1, ts) { elem.off('change').on('change', this.change_handle.bind(this)); } change_handle(evt) { - let option = $$1('option:selected', this.elem).first(); + let option = $('option:selected', this.elem).first(); this.set_filter(option.val()); } } @@ -50,8 +50,8 @@ var cone = (function (exports, $$1, ts) { static initialize(context, selector='.batched_items_filter input', name='term') { - $$1(selector, context).each(function() { - new BatchedItemsSearch($$1(this), name); + $(selector, context).each(function() { + new BatchedItemsSearch($(this), name); }); } constructor(elem, name) { @@ -106,15 +106,16 @@ var cone = (function (exports, $$1, ts) { BatchedItemsSearch.initialize(context, filter_selector, filter_name); } - class Colormode extends ts.ChangeListener { - static set_theme(theme, elem) { - if (theme === 'auto' && this.match_media.matches) { - elem.get(0).setAttribute('data-bs-theme', 'dark'); + class ColorMode { + static set_theme(theme) { + const elem = document.documentElement; + if (theme === 'auto' && this.query.matches) { + elem.setAttribute('data-bs-theme', 'dark'); } else { - elem.get(0).setAttribute('data-bs-theme', theme); + elem.setAttribute('data-bs-theme', theme); } } - static get match_media() { + static get query() { return window.matchMedia('(prefers-color-scheme: dark)'); } static get stored_theme() { @@ -127,18 +128,17 @@ var cone = (function (exports, $$1, ts) { if (this.stored_theme) { return this.stored_theme; } - return this.match_media.matches ? 'dark' : 'light'; + return this.query.matches ? 'dark' : 'light'; } constructor() { - super({elem: $(document.documentElement)}); this.bind(); - this.constructor.set_theme(this.constructor.preferred_theme, this.elem); + this.constructor.set_theme(this.constructor.preferred_theme); } bind() { const stored_theme = this.stored_theme; - this.constructor.match_media.addEventListener('change', () => { + this.constructor.query.addEventListener('change', () => { if (stored_theme !== 'light' || stored_theme !== 'dark') { - this.constructor.set_theme(this.constructor.preferred_theme, this.elem); + this.constructor.set_theme(this.constructor.preferred_theme); } }); } @@ -154,23 +154,24 @@ var cone = (function (exports, $$1, ts) { constructor(elem) { super({elem: elem}); this.update(); - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { + ColorMode.query.addEventListener('change', () => { this.update(); }); } update() { - const preferred_theme = Colormode.preferred_theme; - if (preferred_theme === 'dark' && !this.elem.is(':checked')) { - this.elem.get(0).checked = true; - } else if (preferred_theme == 'light' && this.elem.is(':checked')) { - this.elem.get(0).checked = false; + const preferred_theme = ColorMode.preferred_theme; + const elem = this.elem; + const checked = elem.is(':checked'); + if (preferred_theme === 'dark' && !checked) { + elem.prop('checked', true); + } else if (preferred_theme === 'light' && checked) { + elem.prop('checked', false); } } on_change() { - const document_elem = $(document.documentElement); const theme = this.elem.is(':checked') ? 'dark' : 'light'; - Colormode.set_theme(theme, document_elem); - Colormode.stored_theme = theme; + ColorMode.set_theme(theme); + ColorMode.stored_theme = theme; } } @@ -182,15 +183,15 @@ var cone = (function (exports, $$1, ts) { this.cut_cookie = 'cone.app.copysupport.cut'; this.copy_cookie = 'cone.app.copysupport.copy'; this.context = context; - this.paste_action = $$1('a#toolbaraction-paste', context); + this.paste_action = $('a#toolbaraction-paste', context); this.paste_action.off('click').on('click', this.handle_paste.bind(this)); - this.copyable = $$1('table tr.selectable.copysupportitem', context); + this.copyable = $('table tr.selectable.copysupportitem', context); if (!this.copyable.length) { return; } - this.cut_action = $$1('a#toolbaraction-cut', context); + this.cut_action = $('a#toolbaraction-cut', context); this.cut_action.off('click').on('click', this.handle_cut.bind(this)); - this.copy_action = $$1('a#toolbaraction-copy', context); + this.copy_action = $('a#toolbaraction-copy', context); this.copy_action.off('click').on('click', this.handle_copy.bind(this)); this.selectable = this.copyable.selectable({ on_firstclick: this.on_firstclick.bind(this), @@ -204,17 +205,17 @@ var cone = (function (exports, $$1, ts) { on_select(selectable) { } write_selected_to_cookie(name) { - let selected = $$1(this.selectable.selected); + let selected = $(this.selectable.selected); let ids = new Array(); selected.each(function() { - ids.push($$1(this).attr('ajax:target')); + ids.push($(this).attr('ajax:target')); }); let cookie = ids.join('::'); ts.create_cookie(name, cookie); if (cookie.length) { - $$1(this.paste_action).removeClass('disabled'); + $(this.paste_action).removeClass('disabled'); } else { - $$1(this.paste_action).addClass('disabled'); + $(this.paste_action).addClass('disabled'); } } read_selected_from_cookie(name, css) { @@ -225,8 +226,8 @@ var cone = (function (exports, $$1, ts) { let ids = cookie.split('::'); let that = this; let elem, target; - $$1('table tr.selectable', this.context).each(function() { - elem = $$1(this); + $('table tr.selectable', this.context).each(function() { + elem = $(this); target = elem.attr('ajax:target'); for (let idx in ids) { if (ids[idx] == target) { @@ -245,7 +246,7 @@ var cone = (function (exports, $$1, ts) { ts.create_cookie(this.copy_cookie, '', 0); this.write_selected_to_cookie(this.cut_cookie); this.copyable.removeClass('copysupport_cut'); - $$1(this.selectable.selected).addClass('copysupport_cut'); + $(this.selectable.selected).addClass('copysupport_cut'); } handle_copy(evt) { evt.preventDefault(); @@ -255,7 +256,7 @@ var cone = (function (exports, $$1, ts) { } handle_paste(evt) { evt.preventDefault(); - let elem = $$1(evt.currentTarget); + let elem = $(evt.currentTarget); if (elem.hasClass('disabled')) { return; } @@ -276,8 +277,8 @@ var cone = (function (exports, $$1, ts) { }; class KeyBinder { constructor() { - $$1(window).on('keydown', this.key_down.bind(this)); - $$1(window).on('keyup', this.key_up.bind(this)); + $(window).on('keydown', this.key_down.bind(this)); + $(window).on('keyup', this.key_up.bind(this)); } key_down(e) { switch (e.keyCode || e.which) { @@ -353,14 +354,14 @@ var cone = (function (exports, $$1, ts) { this.header_content = ts.query_elem('#header-content', elem); this.scrollbar = ts.query_elem('.scrollable-x', elem).data('scrollbar'); this.render = this.render.bind(this); - $$1(window).on('resize', this.render); + $(window).on('resize', this.render); this.on_sidebar_resize = this.on_sidebar_resize.bind(this); global_events.on('on_sidebar_resize', this.on_sidebar_resize); this.render(); ts.ajax.attach(this, elem); } destroy() { - $$1(window).off('resize', this.render); + $(window).off('resize', this.render); global_events.off('on_sidebar_resize', this.on_sidebar_resize); } on_sidebar_resize(inst) { @@ -368,7 +369,7 @@ var cone = (function (exports, $$1, ts) { this.scrollbar.position = this.scrollbar.position; } render() { - const window_width = $$1(window).width(); + const window_width = $(window).width(); const window_sm = window_width <= 576; const window_lg = window_width <= 992; const navbar_content = this.navbar_content; @@ -382,7 +383,7 @@ var cone = (function (exports, $$1, ts) { } } else if (in_navbar_content) { this.personal_tools.detach().prependTo(this.header_content); - $$1(".dropdown-menu.show").removeClass('show'); + $(".dropdown-menu.show").removeClass('show'); } if (window_lg) { this.disable_scrolling(); @@ -417,11 +418,11 @@ var cone = (function (exports, $$1, ts) { } let ol = ol_elem.data('overlay'), target = ol.ref_target; - $$1('a.addreference', context).each(function() { - new AddReferenceHandle($$1(this), target, ol); + $('a.addreference', context).each(function() { + new AddReferenceHandle($(this), target, ol); }); - $$1('a.removereference', context).each(function() { - new RemoveReferenceHandle($$1(this), target, ol); + $('a.removereference', context).each(function() { + new RemoveReferenceHandle($(this), target, ol); }); } constructor(elem, target, overlay) { @@ -437,7 +438,7 @@ var cone = (function (exports, $$1, ts) { return this.target_tag == 'SELECT'; } toggle_enabled(elem) { - $$1('a', elem.parent()).toggleClass('disabled'); + $('a', elem.parent()).toggleClass('disabled'); } reset_selected(elem) { let selected = new Array(); @@ -445,15 +446,15 @@ var cone = (function (exports, $$1, ts) { selected.push(elem.attr('value')); } if (this.multi_value()) { - $$1('[selected=selected]', elem).each(function() { - selected.push($$1(this).attr('value')); + $('[selected=selected]', elem).each(function() { + selected.push($(this).attr('value')); }); } this.set_selected_on_ajax_target(elem.parent(), selected); let overlay = this.overlay; let that = this; - $$1('div.referencebrowser a', overlay.elem).each(function() { - let link = $$1(this); + $('div.referencebrowser a', overlay.elem).each(function() { + let link = $(this); if (link.attr('ajax:target')) { that.set_selected_on_ajax_target(link, selected); } @@ -480,20 +481,20 @@ var cone = (function (exports, $$1, ts) { let target = this.target; let uid = elem.attr('id'); uid = uid.substring(4, uid.length); - let label = $$1('.reftitle', elem.parent()).html(); + let label = $('.reftitle', elem.parent()).html(); if (this.single_value()) { target.attr('value', label); let sel = '[name="' + target.attr('name') + '.uid"]'; - $$1(sel).attr('value', uid); + $(sel).attr('value', uid); this.set_selected_on_ajax_target(target.parent(), [uid]); this.overlay.close(); return; } if (this.multi_value()) { - if ($$1('[value="' + uid + '"]', target.parent()).length) { + if ($('[value="' + uid + '"]', target.parent()).length) { return; } - let option = $$1(''); + let option = $(''); option.val(uid).html(label).attr('selected', 'selected'); target.append(option); target.trigger('change'); @@ -516,14 +517,14 @@ var cone = (function (exports, $$1, ts) { if (this.single_value()) { target.attr('value', ''); let sel = '[name="' + target.attr('name') + '.uid"]'; - $$1(sel).attr('value', ''); + $(sel).attr('value', ''); } if (this.multi_value()) { let sel = '[value="' + uid + '"]'; - if (!$$1(sel, target.parent()).length) { + if (!$(sel, target.parent()).length) { return; } - $$1(sel, target).remove(); + $(sel, target).remove(); target.trigger('change'); } this.reset_selected(target); @@ -532,14 +533,14 @@ var cone = (function (exports, $$1, ts) { } class ReferenceBrowserLoader { static initialize(context) { - $$1('.referencebrowser_trigger', context).each(function() { - new ReferenceBrowserLoader($$1(this)); + $('.referencebrowser_trigger', context).each(function() { + new ReferenceBrowserLoader($(this)); }); } constructor(elem) { this.wrapper = elem.parent(); let sel = `[name="${elem.data('reference-name')}"]`; - this.target = $$1(sel, this.wrapper); + this.target = $(sel, this.wrapper); elem.off('click').on('click', this.load_ref_browser.bind(this)); } load_ref_browser(evt) { @@ -553,11 +554,11 @@ var cone = (function (exports, $$1, ts) { } on_complete(inst) { let target = this.target; - $$1('a.addreference', inst.elem).each(function() { - new AddReferenceHandle($$1(this), target, inst); + $('a.addreference', inst.elem).each(function() { + new AddReferenceHandle($(this), target, inst); }); - $$1('a.removereference', inst.elem).each(function() { - new RemoveReferenceHandle($$1(this), target, inst); + $('a.removereference', inst.elem).each(function() { + new RemoveReferenceHandle($(this), target, inst); }); } } @@ -565,8 +566,8 @@ var cone = (function (exports, $$1, ts) { ReferenceBrowserLoader.initialize(context); } function referencebrowser_on_array_index(inst, row, index) { - $$1('.referencebrowser_trigger', row).each(function() { - let trigger = $$1(this), + $('.referencebrowser_trigger', row).each(function() { + let trigger = $(this), ref_name = trigger.data('reference-name'), base_id = inst.base_id, base_name = base_id.replace(/\-/g, '.'); @@ -578,7 +579,7 @@ var cone = (function (exports, $$1, ts) { )); }); } - $$1(function() { + $(function() { if (window.yafowil_array === undefined) { return; } @@ -586,13 +587,13 @@ var cone = (function (exports, $$1, ts) { yafowil_array.on_array_event('on_index', referencebrowser_on_array_index); }); - class Scrollbar extends ts.Events { + class Scrollbar extends ts.Motion { static initialize(context) { - $$1('.scrollable-x', context).each(function() { - new ScrollbarX($$1(this)); + $('.scrollable-x', context).each(function() { + new ScrollbarX($(this)); }); - $$1('.scrollable-y', context).each(function() { - new ScrollbarY($$1(this)); + $('.scrollable-y', context).each(function() { + new ScrollbarY($(this)); }); } constructor(elem) { @@ -602,7 +603,6 @@ var cone = (function (exports, $$1, ts) { this.content = ts.query_elem('.scrollable-content', elem); this.on_scroll = this.on_scroll.bind(this); this.on_click = this.on_click.bind(this); - this.on_drag = this.on_drag.bind(this); this.on_hover = this.on_hover.bind(this); this.on_resize = this.on_resize.bind(this); this.compile(); @@ -628,19 +628,18 @@ var cone = (function (exports, $$1, ts) { } bind() { this.pointer_events = true; - this.elem.css('pointer-events', 'all'); this.elem.on('mousewheel wheel', this.on_scroll); - this.scrollbar.on('click', this.on_click); - this.thumb.on('mousedown', this.on_drag); this.elem.on('mouseenter mouseleave', this.on_hover); - $$1(window).on('resize', this.on_resize); + this.scrollbar.on('click', this.on_click); + this.set_scope(this.thumb, $(document)); + $(window).on('resize', this.on_resize); } unbind() { this.elem.off('mousewheel wheel', this.on_scroll); - this.scrollbar.off('click', this.on_click); - this.thumb.off('mousedown', this.on_drag); this.elem.off('mouseenter mouseleave', this.on_hover); - $$1(window).off('resize', this.on_resize); + this.scrollbar.off('click', this.on_click); + $(this.thumb).off('mousedown', this._down_handle); + $(window).off('resize', this.on_resize); } destroy() { this.unbind(); @@ -682,70 +681,61 @@ var cone = (function (exports, $$1, ts) { on_resize() { this.render(); } - on_hover(e) { - e.preventDefault(); - e.stopPropagation(); + on_hover(evt) { + evt.preventDefault(); + evt.stopPropagation(); const elem = this.elem; if ( - (elem.has(e.target).length > 0 || elem.is(e.target)) && + (elem.has(evt.target).length > 0 || elem.is(evt.target)) && this.contentsize > this.scrollsize ) { - if (e.type === 'mouseenter') { + if (evt.type === 'mouseenter') { this.scrollbar.stop(true, true).fadeIn(); - } else if (e.type === 'mouseleave' && e.relatedTarget !== elem.get(0)) { + } else if ( + evt.type === 'mouseleave' && + evt.relatedTarget !== elem.get(0) + ) { this.scrollbar.stop(true, true).fadeOut(); } } } - on_scroll(e) { + on_scroll(evt) { if (this.contentsize <= this.scrollsize) { return; } - let evt = e.originalEvent; - if (typeof evt.deltaY === 'number') { - if(evt.deltaY > 0) { + let evt_ = evt.originalEvent; + if (typeof evt_.deltaY === 'number') { + if (evt_.deltaY > 0) { this.position += this.scroll_step; - } - else if(evt.deltaY < 0) { + } else if (evt_.deltaY < 0) { this.position -= this.scroll_step; } } } - on_click(e) { - e.preventDefault(); + on_click(evt) { + evt.preventDefault(); this.thumb.addClass('active'); - let position = this.pos_from_evt(e), + let position = this.pos_from_evt(evt), thumb_pos = position - this.offset - this.thumbsize / 2; this.position = this.contentsize * thumb_pos / this.scrollsize; this.thumb.removeClass('active'); } - on_drag(e) { - e.preventDefault(); - var evt = $$1.Event('dragstart'); - $$1(window).trigger(evt); - function on_move(e) { - let mouse_pos_on_move = this.pos_from_evt(e) - this.offset, - new_thumb_pos = thumb_position + mouse_pos_on_move - mouse_pos; - this.position = this.contentsize * new_thumb_pos / this.scrollsize; - } - function on_up() { - var evt = $$1.Event('dragend'); - $$1(window).trigger(evt); - $$1(document) - .off('mousemove', _on_move) - .off('mouseup', _on_up); - this.thumb.removeClass('active'); - this.elem.on('mouseenter mouseleave', this.on_hover); - } - let _on_move = on_move.bind(this), - _on_up = on_up.bind(this), - mouse_pos = this.pos_from_evt(e) - this.offset, - thumb_position = this.position / (this.contentsize / this.scrollsize); - this.thumb.addClass('active'); + down(evt) { + this._mouse_pos = this.pos_from_evt(evt) - this.offset; + this._thumb_pos = this.position / (this.contentsize / this.scrollsize); this.elem.off('mouseenter mouseleave', this.on_hover); - $$1(document) - .on('mousemove', _on_move) - .on('mouseup', _on_up); + this.thumb.addClass('active'); + } + move(evt) { + let mouse_pos = this.pos_from_evt(evt) - this.offset, + thumb_pos = this._thumb_pos + mouse_pos - this._mouse_pos; + this.position = this.contentsize * thumb_pos / this.scrollsize; + } + up(evt) { + delete this._mouse_pos; + delete this._thumb_pos; + this.elem.on('mouseenter mouseleave', this.on_hover); + this.thumb.removeClass('active'); } } class ScrollbarX extends Scrollbar { @@ -816,12 +806,12 @@ var cone = (function (exports, $$1, ts) { new Sharing(context); } constructor(context) { - let checkboxes = $$1('input.add_remove_role_for_principal', context); + let checkboxes = $('input.add_remove_role_for_principal', context); checkboxes.off('change').on('change', this.set_principal_role); } set_principal_role(evt) { evt.preventDefault(); - let checkbox = $$1(this); + let checkbox = $(this); let action; if (this.checked) { action = 'add_principal_role'; @@ -859,7 +849,7 @@ var cone = (function (exports, $$1, ts) { const scrollable_content = ts.query_elem('.scrollable-content', elem); const pad_left = scrollable_content.css('padding-left'); const pad_right = scrollable_content.css('padding-right'); - const logo_width = $$1('#header-logo').outerWidth(true); + const logo_width = $('#header-logo').outerWidth(true); elem.css( 'min-width', `calc(${logo_width}px + ${pad_left} + ${pad_right})` @@ -868,7 +858,7 @@ var cone = (function (exports, $$1, ts) { const collapse_elem = ts.query_elem('#sidebar_collapse', elem); collapse_elem.on('click', this.on_click); const resizer_elem = ts.query_elem('#sidebar_resizer', elem); - this.set_scope(resizer_elem, $$1(document)); + this.set_scope(resizer_elem, $(document)); } get sidebar_width() { return localStorage.getItem('cone-app-sidebar-width') || 300; @@ -922,19 +912,19 @@ var cone = (function (exports, $$1, ts) { class Translation { static initialize(context) { - $$1('.translation-nav', context).each(function() { - new Translation($$1(this)); + $('.translation-nav', context).each(function() { + new Translation($(this)); }); } constructor(nav_elem) { this.nav_elem = nav_elem; this.fields_elem = nav_elem.next(); this.show_lang_handle = this.show_lang_handle.bind(this); - $$1('li > a', nav_elem).on('click', this.show_lang_handle); - if ($$1('li.error', nav_elem).length) { - $$1('li.error:first > a', nav_elem).click(); + $('li > a', nav_elem).on('click', this.show_lang_handle); + if ($('li.error', nav_elem).length) { + $('li.error:first > a', nav_elem).click(); } else { - $$1('li.active > a', nav_elem).click(); + $('li.active > a', nav_elem).click(); } this.fields_elem.show(); } @@ -942,9 +932,9 @@ var cone = (function (exports, $$1, ts) { evt.preventDefault(); this.nav_elem.children().removeClass('active'); this.fields_elem.children().hide(); - let elem = $$1(evt.currentTarget); + let elem = $(evt.currentTarget); elem.parent().addClass('active'); - $$1(elem.attr('href'), this.fields_elem).show(); + $(elem.attr('href'), this.fields_elem).show(); } } @@ -963,7 +953,7 @@ var cone = (function (exports, $$1, ts) { this.selected.push(elem); } remove(elem) { - let reduced = $$1.grep(this.selected, function(item, index) { + let reduced = $.grep(this.selected, function(item, index) { return item !== elem; }); this.selected = reduced; @@ -986,8 +976,8 @@ var cone = (function (exports, $$1, ts) { let selected = container.children('.selected'); let nearest = -1; let selected_index, selected_elem; - $$1(selected).each(function() { - selected_elem = $$1(this); + $(selected).each(function() { + selected_elem = $(this); selected_index = selected_elem.index(); if (nearest == -1) { nearest = selected_index; @@ -1039,7 +1029,7 @@ var cone = (function (exports, $$1, ts) { } handle_click(evt) { evt.preventDefault(); - let elem = $$1(evt.currentTarget); + let elem = $(evt.currentTarget); let container = elem.parent(); if (!keys.ctrl_down && !keys.shift_down) { this.select_no_key(container, elem); @@ -1063,7 +1053,7 @@ var cone = (function (exports, $$1, ts) { elem.off('click').on('click', this.handle_click.bind(this)); } } - $$1.fn.selectable = function(options) { + $.fn.selectable = function(options) { var api = new Selectable(options); api.bind(this); this.data('selectable', api); @@ -1079,9 +1069,9 @@ var cone = (function (exports, $$1, ts) { return ts.read_cookie(name); } - $$1(function() { + $(function() { new KeyBinder(); - new Colormode(); + new ColorMode(); ts.ajax.register(BatchedItemsSize.initialize, true); ts.ajax.register(BatchedItemsSearch.initialize, true); ts.ajax.register(CopySupport.initialize, true); @@ -1101,8 +1091,8 @@ var cone = (function (exports, $$1, ts) { exports.BatchedItemsFilter = BatchedItemsFilter; exports.BatchedItemsSearch = BatchedItemsSearch; exports.BatchedItemsSize = BatchedItemsSize; + exports.ColorMode = ColorMode; exports.ColorToggler = ColorToggler; - exports.Colormode = Colormode; exports.CopySupport = CopySupport; exports.GlobalEvents = GlobalEvents; exports.KeyBinder = KeyBinder; diff --git a/src/cone/app/browser/static/cone/cone.app.min.js b/src/cone/app/browser/static/cone/cone.app.min.js index b01ca96b..b398dcf3 100644 --- a/src/cone/app/browser/static/cone/cone.app.min.js +++ b/src/cone/app/browser/static/cone/cone.app.min.js @@ -1 +1 @@ -var cone=function(e,t,s){"use strict";class i{constructor(e,t){this.elem=e,this.name=t}set_filter(e){let t=this.elem,i=s.ajax.parse_target(t.attr("ajax:target")),r=t.attr("ajax:event");if(i.params[this.name]=e,t.attr("ajax:path")){let a=t.attr("ajax:path-event");a||(a=r),s.ajax.path({path:i.path+i.query+"&"+this.name+"="+e,event:a,target:i})}let a=r.split(":");s.ajax.trigger({name:a[0],selector:a[1],target:i})}}class r extends i{static initialize(e,s=".batched_items_slice_size select"){t(s,e).each((function(){new r(t(this))}))}constructor(e){super(e,"size"),e.off("change").on("change",this.change_handle.bind(this))}change_handle(e){let s=t("option:selected",this.elem).first();this.set_filter(s.val())}}class a extends i{static initialize(e,s=".batched_items_filter input",i="term"){t(s,e).each((function(){new a(t(this),i)}))}constructor(e,t){super(e,t),e.off("focus").on("focus",this.focus_handle.bind(this)),e.off("keypress").on("keypress",this.keypress_handle.bind(this)),e.off("keyup").on("keyup",this.keyup_handle.bind(this)),e.off("change").on("change",this.change_handle.bind(this))}focus_handle(e){let t=this.elem;t.hasClass("empty_filter")&&(t.val(""),t.removeClass("empty_filter"))}keypress_handle(e){13==e.keyCode&&e.preventDefault()}keyup_handle(e){13==e.keyCode&&(e.preventDefault(),this.set_filter(this.elem.val()))}change_handle(e){e.preventDefault(),this.set_filter(this.elem.val())}}class o extends s.ChangeListener{static set_theme(e,t){"auto"===e&&this.match_media.matches?t.get(0).setAttribute("data-bs-theme","dark"):t.get(0).setAttribute("data-bs-theme",e)}static get match_media(){return window.matchMedia("(prefers-color-scheme: dark)")}static get stored_theme(){return localStorage.getItem("cone-app-color-theme")}static set stored_theme(e){localStorage.setItem("cone-app-color-theme",e)}static get preferred_theme(){return this.stored_theme?this.stored_theme:this.match_media.matches?"dark":"light"}constructor(){super({elem:$(document.documentElement)}),this.bind(),this.constructor.set_theme(this.constructor.preferred_theme,this.elem)}bind(){const e=this.stored_theme;this.constructor.match_media.addEventListener("change",(()=>{"light"===e&&"dark"===e||this.constructor.set_theme(this.constructor.preferred_theme,this.elem)}))}}class n extends s.ChangeListener{static initialize(e){const t=s.query_elem("#colortoggle-switch",e);t&&new n(t)}constructor(e){super({elem:e}),this.update(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(()=>{this.update()}))}update(){const e=o.preferred_theme;"dark"!==e||this.elem.is(":checked")?"light"==e&&this.elem.is(":checked")&&(this.elem.get(0).checked=!1):this.elem.get(0).checked=!0}on_change(){const e=$(document.documentElement),t=this.elem.is(":checked")?"dark":"light";o.set_theme(t,e),o.stored_theme=t}}class l{static initialize(e){new l(e)}constructor(e){this.cut_cookie="cone.app.copysupport.cut",this.copy_cookie="cone.app.copysupport.copy",this.context=e,this.paste_action=t("a#toolbaraction-paste",e),this.paste_action.off("click").on("click",this.handle_paste.bind(this)),this.copyable=t("table tr.selectable.copysupportitem",e),this.copyable.length&&(this.cut_action=t("a#toolbaraction-cut",e),this.cut_action.off("click").on("click",this.handle_cut.bind(this)),this.copy_action=t("a#toolbaraction-copy",e),this.copy_action.off("click").on("click",this.handle_copy.bind(this)),this.selectable=this.copyable.selectable({on_firstclick:this.on_firstclick.bind(this),on_select:this.on_select.bind(this)}).data("selectable"),this.read_selected_from_cookie(this.cut_cookie,"copysupport_cut"),this.read_selected_from_cookie(this.copy_cookie,""))}on_firstclick(e,t){}on_select(e){}write_selected_to_cookie(e){let i=t(this.selectable.selected),r=new Array;i.each((function(){r.push(t(this).attr("ajax:target"))}));let a=r.join("::");s.create_cookie(e,a),a.length?t(this.paste_action).removeClass("disabled"):t(this.paste_action).addClass("disabled")}read_selected_from_cookie(e,i){let r=s.read_cookie(e);if(!r)return;let a,o,n=r.split("::"),l=this;t("table tr.selectable",this.context).each((function(){a=t(this),o=a.attr("ajax:target");for(let e in n)if(n[e]==o){a.addClass("selected"),i&&a.addClass(i),l.selectable.add(a.get(0));break}}))}handle_cut(e){e.preventDefault(),s.create_cookie(this.copy_cookie,"",0),this.write_selected_to_cookie(this.cut_cookie),this.copyable.removeClass("copysupport_cut"),t(this.selectable.selected).addClass("copysupport_cut")}handle_copy(e){e.preventDefault(),s.create_cookie(this.cut_cookie,"",0),this.write_selected_to_cookie(this.copy_cookie),this.copyable.removeClass("copysupport_cut")}handle_paste(e){e.preventDefault();let i=t(e.currentTarget);if(i.hasClass("disabled"))return;let r=s.ajax.parse_target(i.attr("ajax:target"));s.ajax.action({name:"paste",mode:"NONE",selector:"NONE",url:r.url,params:r.params})}}let c={shift_down:!1,ctrl_down:!1};class h{constructor(){t(window).on("keydown",this.key_down.bind(this)),t(window).on("keyup",this.key_up.bind(this))}key_down(e){switch(e.keyCode||e.which){case 16:c.shift_down=!0;break;case 17:c.ctrl_down=!0}}key_up(e){switch(e.keyCode||e.which){case 16:c.shift_down=!1;break;case 17:c.ctrl_down=!1}}}class d{static initialize(e,t=null){const i=s.query_elem("input#search-text",e);i&&(null===t&&(t=cone.LiveSearch),new t(i))}constructor(e){this.elem=e}on_select(e,t,i){t.target?s.ajax.trigger("contextchanged","#layout",t.target):console.log("No suggestion target defined.")}render_suggestion(e){return`${e.value}`}}class _ extends s.Events{on_sidebar_resize(e){}}const p=new _;class u extends s.Events{static initialize(e){const t=s.query_elem("#header-main",e);t&&new u(t)}constructor(e){super(),this.elem=e,this.personal_tools=s.query_elem("#personaltools",e),this.navbar_content=s.query_elem("#navbar-content",e),this.header_content=s.query_elem("#header-content",e),this.scrollbar=s.query_elem(".scrollable-x",e).data("scrollbar"),this.render=this.render.bind(this),t(window).on("resize",this.render),this.on_sidebar_resize=this.on_sidebar_resize.bind(this),p.on("on_sidebar_resize",this.on_sidebar_resize),this.render(),s.ajax.attach(this,e)}destroy(){t(window).off("resize",this.render),p.off("on_sidebar_resize",this.on_sidebar_resize)}on_sidebar_resize(e){this.scrollbar.render(),this.scrollbar.position=this.scrollbar.position}render(){const e=t(window).width(),i=e<=576,r=e<=992,a=this.navbar_content,o=null!==s.query_elem("#personaltools",a);i?o||this.personal_tools.detach().appendTo(a):o&&(this.personal_tools.detach().prependTo(this.header_content),t(".dropdown-menu.show").removeClass("show")),r?this.disable_scrolling():(a.removeClass("show"),this.enable_scrolling())}disable_scrolling(){const e=this.scrollbar;e.disabled||(e.position=0,e.disabled=!0)}enable_scrolling(){const e=this.scrollbar;e.disabled&&(e.disabled=!1)}}class m{static initialize(e){if(!e)return;let s=e.parents("div.modal");if(!s.length)return;let i=s.data("overlay"),r=i.ref_target;t("a.addreference",e).each((function(){new f(t(this),r,i)})),t("a.removereference",e).each((function(){new g(t(this),r,i)}))}constructor(e,t,s){this.elem=e,this.target=t,this.target_tag=t.get(0).tagName,this.overlay=s}single_value(){return"INPUT"==this.target_tag}multi_value(){return"SELECT"==this.target_tag}toggle_enabled(e){t("a",e.parent()).toggleClass("disabled")}reset_selected(e){let s=new Array;this.single_value()&&s.push(e.attr("value")),this.multi_value()&&t("[selected=selected]",e).each((function(){s.push(t(this).attr("value"))})),this.set_selected_on_ajax_target(e.parent(),s);let i=this.overlay,r=this;t("div.referencebrowser a",i.elem).each((function(){let e=t(this);e.attr("ajax:target")&&r.set_selected_on_ajax_target(e,s)}))}set_selected_on_ajax_target(e,t){let i=s.ajax.parse_target(e.attr("ajax:target"));i.params.selected=t.join(",");let r=new Array;for(let e in i.params)r.push(e+"="+i.params[e]);e.attr("ajax:target",i.url+"?"+r.join("&"))}}class f extends m{constructor(e,t,s){super(e,t,s),e.off("click").on("click",this.add_reference.bind(this))}add_reference(e){e.preventDefault();let s=this.elem,i=this.target,r=s.attr("id");r=r.substring(4,r.length);let a=t(".reftitle",s.parent()).html();if(this.single_value()){i.attr("value",a);let e='[name="'+i.attr("name")+'.uid"]';return t(e).attr("value",r),this.set_selected_on_ajax_target(i.parent(),[r]),void this.overlay.close()}if(this.multi_value()){if(t('[value="'+r+'"]',i.parent()).length)return;let e=t("");e.val(r).html(a).attr("selected","selected"),i.append(e),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class g extends m{constructor(e,t,s){super(e,t,s),e.off("click").on("click",this.remove_reference.bind(this))}remove_reference(e){e.preventDefault();let s=this.elem,i=this.target,r=s.attr("id");if(r=r.substring(4,r.length),this.single_value()){i.attr("value","");let e='[name="'+i.attr("name")+'.uid"]';t(e).attr("value","")}if(this.multi_value()){let e='[value="'+r+'"]';if(!t(e,i.parent()).length)return;t(e,i).remove(),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class b{static initialize(e){t(".referencebrowser_trigger",e).each((function(){new b(t(this))}))}constructor(e){this.wrapper=e.parent();let s=`[name="${e.data("reference-name")}"]`;this.target=t(s,this.wrapper),e.off("click").on("click",this.load_ref_browser.bind(this))}load_ref_browser(e){e.preventDefault(),s.ajax.overlay({action:"referencebrowser",target:this.wrapper.attr("ajax:target"),on_complete:this.on_complete.bind(this)}).ref_target=this.target}on_complete(e){let s=this.target;t("a.addreference",e.elem).each((function(){new f(t(this),s,e)})),t("a.removereference",e.elem).each((function(){new g(t(this),s,e)}))}}function v(e,t){b.initialize(t)}function w(e,s,i){t(".referencebrowser_trigger",s).each((function(){let s=t(this),r=s.data("reference-name"),a=e.base_id.replace(/\-/g,".");s.data("reference-name",e.set_value_index(r,a,i,"."))}))}t((function(){void 0!==window.yafowil_array&&(yafowil_array.on_array_event("on_add",v),yafowil_array.on_array_event("on_index",w))}));class k extends s.Events{static initialize(e){t(".scrollable-x",e).each((function(){new z(t(this))})),t(".scrollable-y",e).each((function(){new y(t(this))}))}constructor(e){super(),this.elem=e,this.elem.data("scrollbar",this),this.content=s.query_elem(".scrollable-content",e),this.on_scroll=this.on_scroll.bind(this),this.on_click=this.on_click.bind(this),this.on_drag=this.on_drag.bind(this),this.on_hover=this.on_hover.bind(this),this.on_resize=this.on_resize.bind(this),this.compile(),this.position=0,this.scroll_step=50,new s.Property(this,"disabled",!1),s.ajax.attach(this,this.elem),s.clock.schedule_frame((()=>this.render()))}get position(){return this._position||0}set position(e){this._position=this.safe_position(e),this.update(),this.trigger("on_position",this._position)}get pointer_events(){return"all"===this.elem.css("pointer-events")}set pointer_events(e){this.elem.css("pointer-events",e?"all":"none")}bind(){this.pointer_events=!0,this.elem.css("pointer-events","all"),this.elem.on("mousewheel wheel",this.on_scroll),this.scrollbar.on("click",this.on_click),this.thumb.on("mousedown",this.on_drag),this.elem.on("mouseenter mouseleave",this.on_hover),t(window).on("resize",this.on_resize)}unbind(){this.elem.off("mousewheel wheel",this.on_scroll),this.scrollbar.off("click",this.on_click),this.thumb.off("mousedown",this.on_drag),this.elem.off("mouseenter mouseleave",this.on_hover),t(window).off("resize",this.on_resize)}destroy(){this.unbind()}compile(){s.compile_template(this,'\n
\n
\n
\n
\n ',this.elem)}render(e){this.scrollbar.css(e,this.scrollsize),this.contentsize<=this.scrollsize?this.thumbsize=this.scrollsize:this.thumbsize=Math.pow(this.scrollsize,2)/this.contentsize,this.thumb.css(e,this.thumbsize),this.update()}safe_position(e){const t=this.contentsize-this.scrollsize;return e>=t?e=t:e<=0&&(e=0),e}on_disabled(e){e?this.unbind():this.bind()}on_resize(){this.render()}on_hover(e){e.preventDefault(),e.stopPropagation();const t=this.elem;(t.has(e.target).length>0||t.is(e.target))&&this.contentsize>this.scrollsize&&("mouseenter"===e.type?this.scrollbar.stop(!0,!0).fadeIn():"mouseleave"===e.type&&e.relatedTarget!==t.get(0)&&this.scrollbar.stop(!0,!0).fadeOut())}on_scroll(e){if(this.contentsize<=this.scrollsize)return;let t=e.originalEvent;"number"==typeof t.deltaY&&(t.deltaY>0?this.position+=this.scroll_step:t.deltaY<0&&(this.position-=this.scroll_step))}on_click(e){e.preventDefault(),this.thumb.addClass("active");let t=this.pos_from_evt(e)-this.offset-this.thumbsize/2;this.position=this.contentsize*t/this.scrollsize,this.thumb.removeClass("active")}on_drag(e){e.preventDefault();var s=t.Event("dragstart");t(window).trigger(s);let i=function(e){let t=this.pos_from_evt(e)-this.offset,s=o+t-a;this.position=this.contentsize*s/this.scrollsize}.bind(this),r=function(){var e=t.Event("dragend");t(window).trigger(e),t(document).off("mousemove",i).off("mouseup",r),this.thumb.removeClass("active"),this.elem.on("mouseenter mouseleave",this.on_hover)}.bind(this),a=this.pos_from_evt(e)-this.offset,o=this.position/(this.contentsize/this.scrollsize);this.thumb.addClass("active"),this.elem.off("mouseenter mouseleave",this.on_hover),t(document).on("mousemove",i).on("mouseup",r)}}class z extends k{get offset(){return this.elem.offset().left}get contentsize(){return this.content.outerWidth()}get scrollsize(){return this.elem.outerWidth()}compile(){super.compile(),this.thumb.css("height","6px"),this.scrollbar.css("height","6px").css("width",this.scrollsize),this.thumbsize=this.scrollsize/(this.contentsize/this.scrollsize),this.thumb.css("width",this.thumbsize)}render(){super.render("width")}update(){let e=this.position/(this.contentsize/this.scrollsize);this.content.css("right",this.position+"px"),this.thumb.css("left",e+"px")}pos_from_evt(e){return e.pageX}}class y extends k{get offset(){return this.elem.offset().top}get contentsize(){return this.content.outerHeight()}get scrollsize(){return this.elem.outerHeight()}compile(){super.compile(),this.thumb.css("width","6px"),this.scrollbar.css("width","6px").css("top","0px").css("height",this.scrollsize),this.thumbsize=this.scrollsize/(this.contentsize/this.scrollsize),this.thumb.css("height",this.thumbsize)}render(){super.render("height")}update(){let e=this.position/(this.contentsize/this.scrollsize);this.content.css("bottom",this.position+"px"),this.thumb.css("top",e+"px")}pos_from_evt(e){return e.pageY}}class x{static initialize(e){new x(e)}constructor(e){t("input.add_remove_role_for_principal",e).off("change").on("change",this.set_principal_role)}set_principal_role(e){e.preventDefault();let i,r=t(this);i=this.checked?"add_principal_role":"remove_principal_role";let a=r.parent().attr("ajax:target"),o={id:r.attr("name"),role:r.attr("value")};s.ajax.action({name:i,mode:"NONE",selector:"NONE",url:a,params:o})}}class C extends s.Motion{static initialize(e){const t=s.query_elem("#sidebar_left",e);t&&new C(t)}constructor(e){super(),this.elem=e,e.css("width",this.sidebar_width+"px"),this.scrollbar=s.query_elem(".scrollable-y",e).data("scrollbar");const i=s.query_elem(".scrollable-content",e),r=i.css("padding-left"),a=i.css("padding-right"),o=t("#header-logo").outerWidth(!0);e.css("min-width",`calc(${o}px + ${r} + ${a})`),this.on_click=this.on_click.bind(this);s.query_elem("#sidebar_collapse",e).on("click",this.on_click);const n=s.query_elem("#sidebar_resizer",e);this.set_scope(n,t(document))}get sidebar_width(){return localStorage.getItem("cone-app-sidebar-width")||300}set sidebar_width(e){localStorage.setItem("cone-app-sidebar-width",e)}get collapsed(){return"0px"===this.elem.css("width")}collapse(){this.elem.removeClass("expanded").addClass("collapsed"),p.trigger("on_sidebar_resize",this)}expand(){this.elem.removeClass("collapsed").addClass("expanded"),p.trigger("on_sidebar_resize",this)}on_click(e){this.collapsed?this.expand():this.collapse()}move(e){this.scrollbar.pointer_events=!1,e.pageX<=115&&(e.pageX=115),this.sidebar_width=parseInt(e.pageX),this.elem.css("width",this.sidebar_width),p.trigger("on_sidebar_resize",this)}up(){this.scrollbar.pointer_events=!0,p.trigger("on_sidebar_resize",this)}}class j{static initialize(e){r.initialize(e,".table_length select"),a.initialize(e,".table_filter input")}}class E{static initialize(e){t(".translation-nav",e).each((function(){new E(t(this))}))}constructor(e){this.nav_elem=e,this.fields_elem=e.next(),this.show_lang_handle=this.show_lang_handle.bind(this),t("li > a",e).on("click",this.show_lang_handle),t("li.error",e).length?t("li.error:first > a",e).click():t("li.active > a",e).click(),this.fields_elem.show()}show_lang_handle(e){e.preventDefault(),this.nav_elem.children().removeClass("active"),this.fields_elem.children().hide();let s=t(e.currentTarget);s.parent().addClass("active"),t(s.attr("href"),this.fields_elem).show()}}class S{constructor(e){this.options=e,this.selected=[],this.select_direction=0,this.firstclick=!0}reset(){this.selected=[]}add(e){this.remove(e),this.selected.push(e)}remove(e){let s=t.grep(this.selected,(function(t,s){return t!==e}));this.selected=s}select_no_key(e,t){e.children().removeClass("selected"),t.addClass("selected"),this.reset(),this.add(t.get(0))}select_ctrl_down(e){e.toggleClass("selected"),e.hasClass("selected")?this.add(e.get(0)):this.remove(e.get(0))}get_nearest(e,s){let i,r,a=e.children(".selected"),o=-1;return t(a).each((function(){r=t(this),i=r.index(),-1==o?o=i:s>i?this.select_direction>0?io&&(o=i):s{"light"===e&&"dark"===e||this.constructor.set_theme(this.constructor.preferred_theme)}))}}class n extends s.ChangeListener{static initialize(e){const t=s.query_elem("#colortoggle-switch",e);t&&new n(t)}constructor(e){super({elem:e}),this.update(),o.query.addEventListener("change",(()=>{this.update()}))}update(){const e=o.preferred_theme,t=this.elem,s=t.is(":checked");"dark"!==e||s?"light"===e&&s&&t.prop("checked",!1):t.prop("checked",!0)}on_change(){const e=this.elem.is(":checked")?"dark":"light";o.set_theme(e),o.stored_theme=e}}class l{static initialize(e){new l(e)}constructor(e){this.cut_cookie="cone.app.copysupport.cut",this.copy_cookie="cone.app.copysupport.copy",this.context=e,this.paste_action=t("a#toolbaraction-paste",e),this.paste_action.off("click").on("click",this.handle_paste.bind(this)),this.copyable=t("table tr.selectable.copysupportitem",e),this.copyable.length&&(this.cut_action=t("a#toolbaraction-cut",e),this.cut_action.off("click").on("click",this.handle_cut.bind(this)),this.copy_action=t("a#toolbaraction-copy",e),this.copy_action.off("click").on("click",this.handle_copy.bind(this)),this.selectable=this.copyable.selectable({on_firstclick:this.on_firstclick.bind(this),on_select:this.on_select.bind(this)}).data("selectable"),this.read_selected_from_cookie(this.cut_cookie,"copysupport_cut"),this.read_selected_from_cookie(this.copy_cookie,""))}on_firstclick(e,t){}on_select(e){}write_selected_to_cookie(e){let i=t(this.selectable.selected),r=new Array;i.each((function(){r.push(t(this).attr("ajax:target"))}));let a=r.join("::");s.create_cookie(e,a),a.length?t(this.paste_action).removeClass("disabled"):t(this.paste_action).addClass("disabled")}read_selected_from_cookie(e,i){let r=s.read_cookie(e);if(!r)return;let a,o,n=r.split("::"),l=this;t("table tr.selectable",this.context).each((function(){a=t(this),o=a.attr("ajax:target");for(let e in n)if(n[e]==o){a.addClass("selected"),i&&a.addClass(i),l.selectable.add(a.get(0));break}}))}handle_cut(e){e.preventDefault(),s.create_cookie(this.copy_cookie,"",0),this.write_selected_to_cookie(this.cut_cookie),this.copyable.removeClass("copysupport_cut"),t(this.selectable.selected).addClass("copysupport_cut")}handle_copy(e){e.preventDefault(),s.create_cookie(this.cut_cookie,"",0),this.write_selected_to_cookie(this.copy_cookie),this.copyable.removeClass("copysupport_cut")}handle_paste(e){e.preventDefault();let i=t(e.currentTarget);if(i.hasClass("disabled"))return;let r=s.ajax.parse_target(i.attr("ajax:target"));s.ajax.action({name:"paste",mode:"NONE",selector:"NONE",url:r.url,params:r.params})}}let c={shift_down:!1,ctrl_down:!1};class h{constructor(){t(window).on("keydown",this.key_down.bind(this)),t(window).on("keyup",this.key_up.bind(this))}key_down(e){switch(e.keyCode||e.which){case 16:c.shift_down=!0;break;case 17:c.ctrl_down=!0}}key_up(e){switch(e.keyCode||e.which){case 16:c.shift_down=!1;break;case 17:c.ctrl_down=!1}}}class d{static initialize(e,t=null){const i=s.query_elem("input#search-text",e);i&&(null===t&&(t=cone.LiveSearch),new t(i))}constructor(e){this.elem=e}on_select(e,t,i){t.target?s.ajax.trigger("contextchanged","#layout",t.target):console.log("No suggestion target defined.")}render_suggestion(e){return`${e.value}`}}class _ extends s.Events{on_sidebar_resize(e){}}const p=new _;class u extends s.Events{static initialize(e){const t=s.query_elem("#header-main",e);t&&new u(t)}constructor(e){super(),this.elem=e,this.personal_tools=s.query_elem("#personaltools",e),this.navbar_content=s.query_elem("#navbar-content",e),this.header_content=s.query_elem("#header-content",e),this.scrollbar=s.query_elem(".scrollable-x",e).data("scrollbar"),this.render=this.render.bind(this),t(window).on("resize",this.render),this.on_sidebar_resize=this.on_sidebar_resize.bind(this),p.on("on_sidebar_resize",this.on_sidebar_resize),this.render(),s.ajax.attach(this,e)}destroy(){t(window).off("resize",this.render),p.off("on_sidebar_resize",this.on_sidebar_resize)}on_sidebar_resize(e){this.scrollbar.render(),this.scrollbar.position=this.scrollbar.position}render(){const e=t(window).width(),i=e<=576,r=e<=992,a=this.navbar_content,o=null!==s.query_elem("#personaltools",a);i?o||this.personal_tools.detach().appendTo(a):o&&(this.personal_tools.detach().prependTo(this.header_content),t(".dropdown-menu.show").removeClass("show")),r?this.disable_scrolling():(a.removeClass("show"),this.enable_scrolling())}disable_scrolling(){const e=this.scrollbar;e.disabled||(e.position=0,e.disabled=!0)}enable_scrolling(){const e=this.scrollbar;e.disabled&&(e.disabled=!1)}}class m{static initialize(e){if(!e)return;let s=e.parents("div.modal");if(!s.length)return;let i=s.data("overlay"),r=i.ref_target;t("a.addreference",e).each((function(){new f(t(this),r,i)})),t("a.removereference",e).each((function(){new b(t(this),r,i)}))}constructor(e,t,s){this.elem=e,this.target=t,this.target_tag=t.get(0).tagName,this.overlay=s}single_value(){return"INPUT"==this.target_tag}multi_value(){return"SELECT"==this.target_tag}toggle_enabled(e){t("a",e.parent()).toggleClass("disabled")}reset_selected(e){let s=new Array;this.single_value()&&s.push(e.attr("value")),this.multi_value()&&t("[selected=selected]",e).each((function(){s.push(t(this).attr("value"))})),this.set_selected_on_ajax_target(e.parent(),s);let i=this.overlay,r=this;t("div.referencebrowser a",i.elem).each((function(){let e=t(this);e.attr("ajax:target")&&r.set_selected_on_ajax_target(e,s)}))}set_selected_on_ajax_target(e,t){let i=s.ajax.parse_target(e.attr("ajax:target"));i.params.selected=t.join(",");let r=new Array;for(let e in i.params)r.push(e+"="+i.params[e]);e.attr("ajax:target",i.url+"?"+r.join("&"))}}class f extends m{constructor(e,t,s){super(e,t,s),e.off("click").on("click",this.add_reference.bind(this))}add_reference(e){e.preventDefault();let s=this.elem,i=this.target,r=s.attr("id");r=r.substring(4,r.length);let a=t(".reftitle",s.parent()).html();if(this.single_value()){i.attr("value",a);let e='[name="'+i.attr("name")+'.uid"]';return t(e).attr("value",r),this.set_selected_on_ajax_target(i.parent(),[r]),void this.overlay.close()}if(this.multi_value()){if(t('[value="'+r+'"]',i.parent()).length)return;let e=t("");e.val(r).html(a).attr("selected","selected"),i.append(e),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class b extends m{constructor(e,t,s){super(e,t,s),e.off("click").on("click",this.remove_reference.bind(this))}remove_reference(e){e.preventDefault();let s=this.elem,i=this.target,r=s.attr("id");if(r=r.substring(4,r.length),this.single_value()){i.attr("value","");let e='[name="'+i.attr("name")+'.uid"]';t(e).attr("value","")}if(this.multi_value()){let e='[value="'+r+'"]';if(!t(e,i.parent()).length)return;t(e,i).remove(),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class g{static initialize(e){t(".referencebrowser_trigger",e).each((function(){new g(t(this))}))}constructor(e){this.wrapper=e.parent();let s=`[name="${e.data("reference-name")}"]`;this.target=t(s,this.wrapper),e.off("click").on("click",this.load_ref_browser.bind(this))}load_ref_browser(e){e.preventDefault(),s.ajax.overlay({action:"referencebrowser",target:this.wrapper.attr("ajax:target"),on_complete:this.on_complete.bind(this)}).ref_target=this.target}on_complete(e){let s=this.target;t("a.addreference",e.elem).each((function(){new f(t(this),s,e)})),t("a.removereference",e.elem).each((function(){new b(t(this),s,e)}))}}function v(e,t){g.initialize(t)}function w(e,s,i){t(".referencebrowser_trigger",s).each((function(){let s=t(this),r=s.data("reference-name"),a=e.base_id.replace(/\-/g,".");s.data("reference-name",e.set_value_index(r,a,i,"."))}))}t((function(){void 0!==window.yafowil_array&&(yafowil_array.on_array_event("on_add",v),yafowil_array.on_array_event("on_index",w))}));class k extends s.Motion{static initialize(e){t(".scrollable-x",e).each((function(){new z(t(this))})),t(".scrollable-y",e).each((function(){new y(t(this))}))}constructor(e){super(),this.elem=e,this.elem.data("scrollbar",this),this.content=s.query_elem(".scrollable-content",e),this.on_scroll=this.on_scroll.bind(this),this.on_click=this.on_click.bind(this),this.on_hover=this.on_hover.bind(this),this.on_resize=this.on_resize.bind(this),this.compile(),this.position=0,this.scroll_step=50,new s.Property(this,"disabled",!1),s.ajax.attach(this,this.elem),s.clock.schedule_frame((()=>this.render()))}get position(){return this._position||0}set position(e){this._position=this.safe_position(e),this.update(),this.trigger("on_position",this._position)}get pointer_events(){return"all"===this.elem.css("pointer-events")}set pointer_events(e){this.elem.css("pointer-events",e?"all":"none")}bind(){this.pointer_events=!0,this.elem.on("mousewheel wheel",this.on_scroll),this.elem.on("mouseenter mouseleave",this.on_hover),this.scrollbar.on("click",this.on_click),this.set_scope(this.thumb,t(document)),t(window).on("resize",this.on_resize)}unbind(){this.elem.off("mousewheel wheel",this.on_scroll),this.elem.off("mouseenter mouseleave",this.on_hover),this.scrollbar.off("click",this.on_click),t(this.thumb).off("mousedown",this._down_handle),t(window).off("resize",this.on_resize)}destroy(){this.unbind()}compile(){s.compile_template(this,'\n
\n
\n
\n
\n ',this.elem)}render(e){this.scrollbar.css(e,this.scrollsize),this.contentsize<=this.scrollsize?this.thumbsize=this.scrollsize:this.thumbsize=Math.pow(this.scrollsize,2)/this.contentsize,this.thumb.css(e,this.thumbsize),this.update()}safe_position(e){const t=this.contentsize-this.scrollsize;return e>=t?e=t:e<=0&&(e=0),e}on_disabled(e){e?this.unbind():this.bind()}on_resize(){this.render()}on_hover(e){e.preventDefault(),e.stopPropagation();const t=this.elem;(t.has(e.target).length>0||t.is(e.target))&&this.contentsize>this.scrollsize&&("mouseenter"===e.type?this.scrollbar.stop(!0,!0).fadeIn():"mouseleave"===e.type&&e.relatedTarget!==t.get(0)&&this.scrollbar.stop(!0,!0).fadeOut())}on_scroll(e){if(this.contentsize<=this.scrollsize)return;let t=e.originalEvent;"number"==typeof t.deltaY&&(t.deltaY>0?this.position+=this.scroll_step:t.deltaY<0&&(this.position-=this.scroll_step))}on_click(e){e.preventDefault(),this.thumb.addClass("active");let t=this.pos_from_evt(e)-this.offset-this.thumbsize/2;this.position=this.contentsize*t/this.scrollsize,this.thumb.removeClass("active")}down(e){this._mouse_pos=this.pos_from_evt(e)-this.offset,this._thumb_pos=this.position/(this.contentsize/this.scrollsize),this.elem.off("mouseenter mouseleave",this.on_hover),this.thumb.addClass("active")}move(e){let t=this.pos_from_evt(e)-this.offset,s=this._thumb_pos+t-this._mouse_pos;this.position=this.contentsize*s/this.scrollsize}up(e){delete this._mouse_pos,delete this._thumb_pos,this.elem.on("mouseenter mouseleave",this.on_hover),this.thumb.removeClass("active")}}class z extends k{get offset(){return this.elem.offset().left}get contentsize(){return this.content.outerWidth()}get scrollsize(){return this.elem.outerWidth()}compile(){super.compile(),this.thumb.css("height","6px"),this.scrollbar.css("height","6px").css("width",this.scrollsize),this.thumbsize=this.scrollsize/(this.contentsize/this.scrollsize),this.thumb.css("width",this.thumbsize)}render(){super.render("width")}update(){let e=this.position/(this.contentsize/this.scrollsize);this.content.css("right",this.position+"px"),this.thumb.css("left",e+"px")}pos_from_evt(e){return e.pageX}}class y extends k{get offset(){return this.elem.offset().top}get contentsize(){return this.content.outerHeight()}get scrollsize(){return this.elem.outerHeight()}compile(){super.compile(),this.thumb.css("width","6px"),this.scrollbar.css("width","6px").css("top","0px").css("height",this.scrollsize),this.thumbsize=this.scrollsize/(this.contentsize/this.scrollsize),this.thumb.css("height",this.thumbsize)}render(){super.render("height")}update(){let e=this.position/(this.contentsize/this.scrollsize);this.content.css("bottom",this.position+"px"),this.thumb.css("top",e+"px")}pos_from_evt(e){return e.pageY}}class x{static initialize(e){new x(e)}constructor(e){t("input.add_remove_role_for_principal",e).off("change").on("change",this.set_principal_role)}set_principal_role(e){e.preventDefault();let i,r=t(this);i=this.checked?"add_principal_role":"remove_principal_role";let a=r.parent().attr("ajax:target"),o={id:r.attr("name"),role:r.attr("value")};s.ajax.action({name:i,mode:"NONE",selector:"NONE",url:a,params:o})}}class j extends s.Motion{static initialize(e){const t=s.query_elem("#sidebar_left",e);t&&new j(t)}constructor(e){super(),this.elem=e,e.css("width",this.sidebar_width+"px"),this.scrollbar=s.query_elem(".scrollable-y",e).data("scrollbar");const i=s.query_elem(".scrollable-content",e),r=i.css("padding-left"),a=i.css("padding-right"),o=t("#header-logo").outerWidth(!0);e.css("min-width",`calc(${o}px + ${r} + ${a})`),this.on_click=this.on_click.bind(this);s.query_elem("#sidebar_collapse",e).on("click",this.on_click);const n=s.query_elem("#sidebar_resizer",e);this.set_scope(n,t(document))}get sidebar_width(){return localStorage.getItem("cone-app-sidebar-width")||300}set sidebar_width(e){localStorage.setItem("cone-app-sidebar-width",e)}get collapsed(){return"0px"===this.elem.css("width")}collapse(){this.elem.removeClass("expanded").addClass("collapsed"),p.trigger("on_sidebar_resize",this)}expand(){this.elem.removeClass("collapsed").addClass("expanded"),p.trigger("on_sidebar_resize",this)}on_click(e){this.collapsed?this.expand():this.collapse()}move(e){this.scrollbar.pointer_events=!1,e.pageX<=115&&(e.pageX=115),this.sidebar_width=parseInt(e.pageX),this.elem.css("width",this.sidebar_width),p.trigger("on_sidebar_resize",this)}up(){this.scrollbar.pointer_events=!0,p.trigger("on_sidebar_resize",this)}}class C{static initialize(e){r.initialize(e,".table_length select"),a.initialize(e,".table_filter input")}}class q{static initialize(e){t(".translation-nav",e).each((function(){new q(t(this))}))}constructor(e){this.nav_elem=e,this.fields_elem=e.next(),this.show_lang_handle=this.show_lang_handle.bind(this),t("li > a",e).on("click",this.show_lang_handle),t("li.error",e).length?t("li.error:first > a",e).click():t("li.active > a",e).click(),this.fields_elem.show()}show_lang_handle(e){e.preventDefault(),this.nav_elem.children().removeClass("active"),this.fields_elem.children().hide();let s=t(e.currentTarget);s.parent().addClass("active"),t(s.attr("href"),this.fields_elem).show()}}class S{constructor(e){this.options=e,this.selected=[],this.select_direction=0,this.firstclick=!0}reset(){this.selected=[]}add(e){this.remove(e),this.selected.push(e)}remove(e){let s=t.grep(this.selected,(function(t,s){return t!==e}));this.selected=s}select_no_key(e,t){e.children().removeClass("selected"),t.addClass("selected"),this.reset(),this.add(t.get(0))}select_ctrl_down(e){e.toggleClass("selected"),e.hasClass("selected")?this.add(e.get(0)):this.remove(e.get(0))}get_nearest(e,s){let i,r,a=e.children(".selected"),o=-1;return t(a).each((function(){r=t(this),i=r.index(),-1==o?o=i:s>i?this.select_direction>0?io&&(o=i):s