diff --git a/js/src/sidebar.js b/js/src/sidebar.js index 2ef25ddf..a634292e 100644 --- a/js/src/sidebar.js +++ b/js/src/sidebar.js @@ -68,8 +68,7 @@ export class Sidebar extends ts.Motion { } move(evt) { - // prevent scrollbar from toggling - this.scrollbar.elem.css('pointer-events', 'none'); + this.scrollbar.disabled = true; if (evt.pageX <= 115) { evt.pageX = 115; } @@ -78,7 +77,6 @@ export class Sidebar extends ts.Motion { } up() { - // enable scrollbar toggling again - this.scrollbar.elem.css('pointer-events', 'all'); + this.scrollbar.disabled = false; } } diff --git a/src/cone/app/browser/static/cone/cone.app.protected.js b/src/cone/app/browser/static/cone/cone.app.protected.js index a69597f1..445a00cf 100644 --- a/src/cone/app/browser/static/cone/cone.app.protected.js +++ b/src/cone/app/browser/static/cone/cone.app.protected.js @@ -810,7 +810,7 @@ var cone_app_protected = (function (exports, $, ts) { .addClass('expanded'); } move(evt) { - this.scrollbar.elem.css('pointer-events', 'none'); + this.scrollbar.disabled = true; if (evt.pageX <= 115) { evt.pageX = 115; } @@ -818,7 +818,7 @@ var cone_app_protected = (function (exports, $, ts) { this.elem.css('width', this.sidebar_width); } up() { - this.scrollbar.elem.css('pointer-events', 'all'); + this.scrollbar.disabled = false; } } diff --git a/src/cone/app/browser/static/cone/cone.app.protected.min.js b/src/cone/app/browser/static/cone/cone.app.protected.min.js index ecbba333..c20cc1d9 100644 --- a/src/cone/app/browser/static/cone/cone.app.protected.min.js +++ b/src/cone/app/browser/static/cone/cone.app.protected.min.js @@ -1 +1 @@ -var cone_app_protected=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")),a=t.attr("ajax:event");if(i.params[this.name]=e,t.attr("ajax:path")){let o=t.attr("ajax:path-event");o||(o=a),s.ajax.path({path:i.path+i.query+"&"+this.name+"="+e,event:o,target:i})}let o=a.split(":");s.ajax.trigger({name:o[0],selector:o[1],target:i})}}class a extends i{static initialize(e,s=".batched_items_slice_size select"){t(s,e).each((function(){new a(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 o extends i{static initialize(e,s=".batched_items_filter input",i="term"){t(s,e).each((function(){new o(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 r{static initialize(e){new r(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),a=new Array;i.each((function(){a.push(t(this).attr("ajax:target"))}));let o=a.join("::");s.create_cookie(e,o),o.length?t(this.paste_action).removeClass("disabled"):t(this.paste_action).addClass("disabled")}read_selected_from_cookie(e,i){let a=s.read_cookie(e);if(!a)return;let o,r,l=a.split("::"),n=this;t("table tr.selectable",this.context).each((function(){o=t(this),r=o.attr("ajax:target");for(let e in l)if(l[e]==r){o.addClass("selected"),i&&o.addClass(i),n.selectable.add(o.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 a=s.ajax.parse_target(i.attr("ajax:target"));s.ajax.action({name:"paste",mode:"NONE",selector:"NONE",url:a.url,params:a.params})}}let l={shift_down:!1,ctrl_down:!1};class n{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:l.shift_down=!0;break;case 17:l.ctrl_down=!0}}key_up(e){switch(e.keyCode||e.which){case 16:l.shift_down=!1;break;case 17:l.ctrl_down=!1}}}class c{static initialize(e){if(!e)return;let s=e.parents("div.modal");if(!s.length)return;let i=s.data("overlay"),a=i.ref_target;t("a.addreference",e).each((function(){new h(t(this),a,i)})),t("a.removereference",e).each((function(){new d(t(this),a,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,a=this;t("div.referencebrowser a",i.elem).each((function(){let e=t(this);e.attr("ajax:target")&&a.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 a=new Array;for(let e in i.params)a.push(e+"="+i.params[e]);e.attr("ajax:target",i.url+"?"+a.join("&"))}}class h extends c{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,a=s.attr("id");a=a.substring(4,a.length);let o=t(".reftitle",s.parent()).html();if(this.single_value()){i.attr("value",o);let e='[name="'+i.attr("name")+'.uid"]';return t(e).attr("value",a),this.set_selected_on_ajax_target(i.parent(),[a]),void this.overlay.close()}if(this.multi_value()){if(t('[value="'+a+'"]',i.parent()).length)return;let e=t("");e.val(a).html(o).attr("selected","selected"),i.append(e),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class d extends c{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,a=s.attr("id");if(a=a.substring(4,a.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="'+a+'"]';if(!t(e,i.parent()).length)return;t(e,i).remove(),i.trigger("change")}this.reset_selected(i),this.toggle_enabled(s)}}class _{static initialize(e){t(".referencebrowser_trigger",e).each((function(){new _(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 h(t(this),s,e)})),t("a.removereference",e.elem).each((function(){new d(t(this),s,e)}))}}function p(e,t){_.initialize(t)}function u(e,s,i){t(".referencebrowser_trigger",s).each((function(){let s=t(this),a=s.data("reference-name"),o=e.base_id.replace(/\-/g,".");s.data("reference-name",e.set_value_index(a,o,i,"."))}))}t((function(){void 0!==window.yafowil_array&&(yafowil_array.on_array_event("on_add",p),yafowil_array.on_array_event("on_index",u))}));class m{static initialize(e){new m(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,a=t(this);i=this.checked?"add_principal_role":"remove_principal_role";let o=a.parent().attr("ajax:target"),r={id:a.attr("name"),role:a.attr("value")};s.ajax.action({name:i,mode:"NONE",selector:"NONE",url:o,params:r})}}class f{static initialize(e){a.initialize(e,".table_length select"),o.initialize(e,".table_filter input")}}class g{static initialize(e){t(".translation-nav",e).each((function(){new g(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 b extends s.ChangeListener{static initialize(e){const t=s.query_elem("#colortoggle-switch",e);t&&new b(t)}constructor(e){super({elem:e}),this.bind(),this.set_theme(this.preferred_theme)}get match_media(){return window.matchMedia("(prefers-color-scheme: dark)")}get stored_theme(){return localStorage.getItem("cone-app-color-theme")}set stored_theme(e){localStorage.setItem("cone-app-color-theme",e)}get preferred_theme(){return this.stored_theme?this.stored_theme:this.match_media.matches?"dark":"light"}bind(){const e=this.stored_theme;this.match_media.addEventListener("change",(()=>{"light"===e&&"dark"===e||this.set_theme(this.preferred_theme)}))}set_theme(e){const t=document.documentElement;"auto"===e&&this.match_media.matches?(t.setAttribute("data-bs-theme","dark"),this.elem.trigger("click")):t.setAttribute("data-bs-theme",e),this.stored_theme=e,"dark"!==e||this.elem.is(":checked")||this.elem.trigger("click")}on_change(){const e=this.elem.is(":checked")?"dark":"light";this.set_theme(e)}}class v extends s.Events{static initialize(e){t(".scrollable-x",e).each((function(){new w(t(this))})),t(".scrollable-y",e).each((function(){new k(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)}bind(){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.css("pointer-events","none"),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 ',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=r+t-o;this.position=this.contentsize*s/this.scrollsize}.bind(this),a=function(){var e=t.Event("dragend");t(window).trigger(e),t(document).off("mousemove",i).off("mouseup",a),this.thumb.removeClass("active"),this.elem.on("mouseenter mouseleave",this.on_hover)}.bind(this),o=this.pos_from_evt(e)-this.offset,r=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",a)}}class w extends v{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 k extends v{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 z extends s.Motion{static initialize(e){const t=s.query_elem("#sidebar_left",e);t&&new z(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),a=i.css("padding-left"),o=i.css("padding-right"),r=t("#header-logo").outerWidth(!0);e.css("min-width",`calc(${r}px + ${a} + ${o})`),this.on_click=this.on_click.bind(this);s.query_elem("#sidebar_collapse",e).on("click",this.on_click);const l=s.query_elem("#sidebar_resizer",e);this.set_scope(l,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")}on_click(e){this.collapsed?this.expand():this.collapse()}collapse(){this.elem.removeClass("expanded").addClass("collapsed")}expand(){this.elem.removeClass("collapsed").addClass("expanded")}move(e){this.scrollbar.elem.css("pointer-events","none"),e.pageX<=115&&(e.pageX=115),this.sidebar_width=parseInt(e.pageX),this.elem.css("width",this.sidebar_width)}up(){this.scrollbar.elem.css("pointer-events","all")}}class y extends s.Events{static initialize(e){const t=s.query_elem("#header-main",e);t&&new y(t)}constructor(e){super(),this.elem=e,this.personal_tools=t("#personaltools",this.elem),this.navbar_content=t("#navbar-content",this.elem),this.header_content=t("#header-content",this.elem),this.scrollable=t(".scrollable-x",this.elem),this.place_elements=this.place_elements.bind(this),t(window).on("resize",this.place_elements),this.place_elements(),s.ajax.attach(this,this.elem)}destroy(){t(window).off("resize",this.place_elements)}place_elements(){const e=t(window).width(),s=e<=576,i=e<=992,a=t("#personaltools",this.navbar_content).length>0;s?a||this.personal_tools.detach().appendTo(this.navbar_content):a&&(this.personal_tools.detach().prependTo(this.header_content),t(".dropdown-menu.show").removeClass("show")),i?this.disable_horizontal_scrolling():(this.navbar_content.removeClass("show"),this.enable_horizontal_scrolling())}disable_horizontal_scrolling(){this.scrollable.each(((e,s)=>{const i=t(s).data("scrollbar");i.disabled||(i.position=0,i.disabled=!0)}))}enable_horizontal_scrolling(){this.scrollable.each(((e,s)=>{const i=t(s).data("scrollbar");i.disabled&&(i.disabled=!1)}))}}class x{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,a,o=e.children(".selected"),r=-1;return t(o).each((function(){a=t(this),i=a.index(),-1==r?r=i:s>i?this.select_direction>0?i