diff --git a/components/ILIAS/UI/resources/js/MainControls/dist/mainbar.js b/components/ILIAS/UI/resources/js/MainControls/dist/mainbar.js index f6febba37737..272e61d1a4b0 100644 --- a/components/ILIAS/UI/resources/js/MainControls/dist/mainbar.js +++ b/components/ILIAS/UI/resources/js/MainControls/dist/mainbar.js @@ -730,7 +730,6 @@ var persistence = function() { ,page_has_engaged_slated: 'with-mainbar-slates-engaged' ,tools_btn: 'il-mainbar-tools-button' ,toolentries_wrapper: 'il-mainbar-tools-entries' - ,remover_class: 'il-mainbar-remove-tool' ,mainbar: 'il-mainbar' ,mainbar_buttons: '.il-mainbar .il-mainbar-entries .btn-bulky, .il-mainbar .il-mainbar-entries .link-bulky' ,mainbar_entries: 'il-mainbar-entries' @@ -836,15 +835,6 @@ var persistence = function() { } } }, - removers: { - getElement: function(){ - return $('.' + css.remover_class); - }, - mb_hide: function() { - this.getElement().hide(); - } - - }, tools_area: Object.assign({}, dom_element, { getElement: function(){ return $(' .' + css.toolentries_wrapper); diff --git a/components/ILIAS/UI/resources/js/MainControls/dist/maincontrols.min.js b/components/ILIAS/UI/resources/js/MainControls/dist/maincontrols.min.js index 5f37bc629541..26f255abbb77 100644 --- a/components/ILIAS/UI/resources/js/MainControls/dist/maincontrols.min.js +++ b/components/ILIAS/UI/resources/js/MainControls/dist/maincontrols.min.js @@ -12,4 +12,4 @@ * https://www.ilias.de * https://github.com/ILIAS-eLearning */ -!function(t,e){"use strict";const n="engaged",s="il-maincontrols-metabar",a="il-metabar-slates",i="il-metabar-more-button",o="il-metabar-more-slate",r="il-maincontrols-slate",l="engaged";function c(t){t.removeClass(n),t.attr("aria-expanded",!1)}class u{#t;#e;#n;#s;#a;#i;#o;constructor(t,e,n,s,a,i){this.#t=t,this.#e=e,this.#s=n,this.#a=s,this.#i=a,this.#o=i}registerSignals(t,e){this.#t(document).on(t,((t,e)=>(this.#r(t,e),this.#s()&&this.#i(),!1))),this.#t(document).on(e,(()=>(this.onClickDisengageAll(),!1))),this.#t(`.${s}`).on("click",(()=>{this.#n=!0})),this.#t("body").on("click",(()=>{this.#n?this.#n=!1:this.onClickDisengageAll()})),this.#t(`.${a} > .${r}`).on("focusout",(t=>{if(!this.#s()){const e=t.relatedTarget,n=t.currentTarget;null===e||n.contains(e)||this.onClickDisengageAll()}}))}#r(t,e){const s=e.triggerer;!function(t){return t.hasClass(n)}(s)?(this.disengageAll(),function(t){t.addClass(n),t.attr("aria-expanded",!0)}(s),setTimeout((()=>{const t=s[0];this.focusInEngagedSlate(t)}),10)):c(s)}onClickDisengageAll(){this.disengageAllButtons(),this.disengageAllSlates()}disengageAllButtons(){document.querySelectorAll(`#${this.#e}.${s} > li > .btn.${n}`).forEach((t=>{c($(t))}));document.querySelectorAll(`#${this.#e}.${s} > li > .${a} > .${o} > .il-maincontrols-slate-content > .btn.${n}`).forEach((t=>{c($(t))}))}disengageAllSlates(){this.getEngagedSlates().each(((t,e)=>{this.#o(this.#t(e))}))}disengageAll(){this.disengageAllSlates(),this.disengageAllButtons()}getEngagedSlates(){const t=`#${this.#e} .${r}.${l}`;return this.#t(t)}focusInEngagedSlate(t){const e=function(t,e){let n=t.parentElement;for(;n&&!n.classList.contains(e);)n=n.parentElement;return n||console.warn(`No parent element with class "${e}" found.`),n}(t,s);if(e){const t=e.querySelector(`.${r}.${l}`);if(t){const e=t.querySelector("input, button");e&&e.focus()}}}init(){this.#l(),this.#c(),this.#s()?this.#u():this.#h(),this.#t(`.${s}`).css("visibility","visible"),this.#t(`#${this.#e} .${a}`).children(`.${r}`).attr("aria-hidden",!0)}#u(){this.#g(),this.#d().hide(),this.getMoreButton().show(),this.#y()}#h(){this.getMoreButton().hide(),this.#d().show()}#l(){if(0===this.getMoreButton().length){const t=this.#t(`#${this.#e}.${s}`).find(".btn, .il-link").last();this.#t(t).addClass(i)}}#c(){if(0===this.#S().length){const t=this.#t(`#${this.#e} .${a}`).children(`.${r}`).last();this.#t(t).addClass(o)}}getMoreButton(){return this.#t(`.${i}`)}#S(){return this.#t(`.${o}`)}#d(){return this.#t(`#${this.#e}.${s}`).children("li").children(".btn, .il-link").not(`.${i}`)}#g(){const t=this.#S().children(".il-maincontrols-slate-content");0===t.children().length&&this.#d().clone(!0,!0).appendTo(t)}#y(){const t=this.#a.getCounterObjectOrNull(this.#S());t&&this.#a.getCounterObject(this.getMoreButton()).setNoveltyTo(t.getNoveltyCount()).setStatusTo(t.getStatusCount())}}const h="engaged",g="disengaged";function d(t){return t.hasClass(h)}function y(t){t.removeClass(g),t.addClass(h),t.attr("aria-expanded","true"),t.attr("aria-hidden","false")}function S(t){t.removeClass(h),t.addClass(g),t.attr("aria-expanded","false"),t.attr("aria-hidden","true")}function m(t){d(t)?S(t):y(t)}var f=function(t){var e="il-counter",n={getCounterObject:function(t){let e;return e=s(t),console.assert(e.length>0,"Passed jQuery Object does not contain a counter"),a(e)},getCounterObjectOrNull:function(t){let e;return e=s(t),0===e.length?null:a(e)}},s=function(n){console.assert(n instanceof t,"$object_containing_counter is not a jQuery Object, param: "+n);var s=n;return n.hasClass(e)||(s=n.find("."+e)),s},a=function(e){return b.bind({})(e,t)};return n},b=function(t,e){const n=" Counter does not exist in the DOM. Make sure the respective Counter type has been rendered before applying this operations.",s=" is not a number";this.getStatusCount=function(){return r(o(t))},this.getNoveltyCount=function(){return r(i(t))},this.hasNoveltyObject=function(){return i(t).length>0},this.hasStatusObject=function(){return o(t).length>0},this.setNoveltyTo=function(e){console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s);var a=i(t);return a.html(e),0===e?a.hide():a.show(),this},this.setStatusTo=function(e){console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s);var a=o(t);return a.html(e),0===e?a.hide():a.show(),this},this.incrementNoveltyCount=function(e){return console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasNoveltyObject()&&t.setNoveltyTo(t.getNoveltyCount()+e)}),t),this},this.decrementNoveltyCount=function(e){return console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasNoveltyObject()&&t.setNoveltyTo(t.getNoveltyCount()-e)}),t),this},this.incrementStatusCount=function(e){return console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasStatusObject()&&t.setStatusTo(t.getStatusCount()+e)}),t),this},this.decrementStatusCount=function(e){return console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasStatusObject()&&t.setStatusTo(t.getStatusCount()-e)}),t),this},this.setTotalNoveltyToStatusCount=function(){return console.assert(this.hasStatusObject(),"Status "+n),console.assert(this.hasNoveltyObject(),"Novelty "+n),this.incrementStatusCount(this.getNoveltyCount()).setNoveltyTo(0)};var a={getNoveltyCount:this.getNoveltyCount,getStatusCount:this.getStatusCount,hasNoveltyObject:this.hasNoveltyObject,hasStatusObject:this.hasStatusObject,setNoveltyTo:this.setNoveltyTo,setStatusTo:this.setStatusTo,incrementNoveltyCount:this.incrementNoveltyCount,decrementNoveltyCount:this.decrementNoveltyCount,incrementStatusCount:this.incrementStatusCount,decrementStatusCount:this.decrementStatusCount,setTotalNoveltyToStatusCount:this.setTotalNoveltyToStatusCount},i=function(t){return t.find(".il-counter-novelty")},o=function(t){return t.find(".il-counter-status")},r=function(t){var n=0;return t.each((function(){var t=e(this).text();n+=parseInt(t)})),n},l=function(t,n){n.each((function(){var n=f(e).getCounterObject(e(this));t(n,e(this))}))};return a};t.UI=t.UI||{},t.UI.maincontrols=t.UI.maincontrols||{},t.UI.maincontrols.metabar=new class{#t;#m=[];#s;#a;#i;#o;constructor(t,e,n,s,a){this.#t=t,this.#s=e,this.#a=n,this.#i=s,this.#o=a}init(t){if(void 0!==this.#m[t])throw new Error(`Metabar with id '${t}' has already been initialized.`);this.#m[t]=new u(this.#t,t,this.#s,this.#a,this.#i,this.#o)}get(t){return this.#m[t]??null}disengageAll(){Object.values(this.#m).forEach((t=>t.disengageAll()))}}(e,(()=>t.UI.page.isSmallScreen()),f(e),(()=>t.UI.maincontrols.mainbar.disengageAll()),(e=>t.UI.maincontrols.slate.disengage(e))),t.UI.maincontrols.slate=new class{#t;#f;#b;constructor(t,e,n){this.#t=t,this.#f=e,this.#b=n}onSignal(t,e,n,s){const a=this.#t(`#${s}`),{triggerer:i}=n,o=i.parents(".il-metabar-more-slate").length>0;if("toggle"===t)this.#p(a,i,o);else if("engage"===t)y(a);else{if("replace"!==t)throw new Error(`No such SignalType: ${t}`);this.#C(s,n)}}#p(t,e,n){const s=t.closest(".il-maincontrols-metabar").attr("id"),a=this.#b.get(s);e.attr("id")!==a.getMoreButton().attr("id")?(m(t),n||(d(t)?(e.addClass(h),e.removeClass(g),t.trigger("in_view")):(e.removeClass(h),e.addClass(g)))):a.getEngagedSlates().length>0?a.disengageAllSlates():m(t)}disengage=S;#C(t,e){const{url:n}=e.options;this.#f(t,n,"content")}}(e,function(t){return function(e,n,s){t.ajax({url:n,dataType:"html"}).done((function(n){var a=t("
"+n+"
"),i=a.find("[data-replace-marker='"+s+"']").first();0==i.length?t("#"+e+" [data-replace-marker='"+s+"']").html(n):(t("#"+e+" [data-replace-marker='"+s+"']").first().replaceWith(i),t("#"+e+" [data-replace-marker='"+s+"']").first().after(a.find("[data-replace-marker='script']")))}))}}(e),t.UI.maincontrols.metabar)}(il,$); +!function(t,e){"use strict";const n="engaged",s="il-maincontrols-metabar",a="il-metabar-slates",i="il-metabar-more-button",o="il-metabar-more-slate",r="il-maincontrols-slate",l="engaged";function c(t){t.removeClass(n),t.attr("aria-expanded",!1)}class u{#t;#e;#n;#s;#a;#i;#o;constructor(t,e,n,s,a,i){this.#t=t,this.#e=e,this.#s=n,this.#a=s,this.#i=a,this.#o=i}registerSignals(t,e){this.#t(document).on(t,((t,e)=>(this.#r(t,e),this.#s()&&this.#i(),!1))),this.#t(document).on(e,(()=>(this.onClickDisengageAll(),!1))),this.#t(`.${s}`).on("click",(()=>{this.#n=!0})),this.#t("body").on("click",(()=>{this.#n?this.#n=!1:this.onClickDisengageAll()})),this.#t(`.${a} > .${r}`).on("focusout",(t=>{if(!this.#s()){const e=t.relatedTarget,n=t.currentTarget;null===e||n.contains(e)||this.onClickDisengageAll()}}))}#r(t,e){const s=e.triggerer;!function(t){return t.hasClass(n)}(s)?(this.disengageAll(),function(t){t.addClass(n),t.attr("aria-expanded",!0)}(s),setTimeout((()=>{const t=s[0];this.focusInEngagedSlate(t)}),10)):c(s)}onClickDisengageAll(){this.disengageAllButtons(),this.disengageAllSlates()}disengageAllButtons(){document.querySelectorAll(`#${this.#e}.${s} > li > .btn.${n}`).forEach((t=>{c($(t))}));document.querySelectorAll(`#${this.#e}.${s} > li > .${a} > .${o} > .il-maincontrols-slate-content > .btn.${n}`).forEach((t=>{c($(t))}))}disengageAllSlates(){this.getEngagedSlates().each(((t,e)=>{this.#o(this.#t(e))}))}disengageAll(){this.disengageAllSlates(),this.disengageAllButtons()}getEngagedSlates(){const t=`#${this.#e} .${r}.${l}`;return this.#t(t)}focusInEngagedSlate(t){const e=function(t,e){let n=t.parentElement;for(;n&&!n.classList.contains(e);)n=n.parentElement;return n||console.warn(`No parent element with class "${e}" found.`),n}(t,s);if(e){const t=e.querySelector(`.${r}.${l}`);if(t){const e=t.querySelector("input, button");e&&e.focus()}}}init(){this.#l(),this.#c(),this.#s()?this.#u():this.#h(),this.#t(`.${s}`).css("visibility","visible"),this.#t(`#${this.#e} .${a}`).children(`.${r}`).attr("aria-hidden",!0)}#u(){this.#g(),this.#d().hide(),this.getMoreButton().show(),this.#y()}#h(){this.getMoreButton().hide(),this.#d().show()}#l(){if(0===this.getMoreButton().length){const t=this.#t(`#${this.#e}.${s}`).find(".btn, .il-link").last();this.#t(t).addClass(i)}}#c(){if(0===this.#S().length){const t=this.#t(`#${this.#e} .${a}`).children(`.${r}`).last();this.#t(t).addClass(o)}}getMoreButton(){return this.#t(`.${i}`)}#S(){return this.#t(`.${o}`)}#d(){return this.#t(`#${this.#e}.${s}`).children("li").children(".btn, .il-link").not(`.${i}`)}#g(){const t=this.#S().children(".il-maincontrols-slate-content");0===t.children().length&&this.#d().clone(!0,!0).appendTo(t)}#y(){const t=this.#a.getCounterObjectOrNull(this.#S());t&&this.#a.getCounterObject(this.getMoreButton()).setNoveltyTo(t.getNoveltyCount()).setStatusTo(t.getStatusCount())}}const h="engaged",g="disengaged";function d(t){return t.hasClass(h)}function y(t){t.removeClass(g),t.addClass(h),t.attr("aria-expanded","true"),t.attr("aria-hidden","false")}function S(t){t.removeClass(h),t.addClass(g),t.attr("aria-expanded","false"),t.attr("aria-hidden","true")}function m(t){d(t)?S(t):y(t)}var f=function(t){var e="il-counter",n={getCounterObject:function(t){let e;return e=s(t),console.assert(e.length>0,"Passed jQuery Object does not contain a counter"),a(e)},getCounterObjectOrNull:function(t){let e;return e=s(t),0===e.length?null:a(e)}},s=function(n){console.assert(n instanceof t,"$object_containing_counter is not a jQuery Object, param: "+n);var s=n;return n.hasClass(e)||(s=n.find("."+e)),s},a=function(e){return b.bind({})(e,t)};return n},b=function(t,e){const n=" Counter does not exist in the DOM. Make sure the respective Counter type has been rendered before applying this operations.",s=" is not a number";this.getStatusCount=function(){return r(o(t))},this.getNoveltyCount=function(){return r(i(t))},this.hasNoveltyObject=function(){return i(t).length>0},this.hasStatusObject=function(){return o(t).length>0},this.setNoveltyTo=function(e){console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s);var a=i(t);return a.html(e),0===e?a.hide():a.show(),this},this.setStatusTo=function(e){console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s);var a=o(t);return a.html(e),0===e?a.hide():a.show(),this},this.incrementNoveltyCount=function(e){return console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasNoveltyObject()&&t.setNoveltyTo(t.getNoveltyCount()+e)}),t),this},this.decrementNoveltyCount=function(e){return console.assert(this.hasNoveltyObject(),"Novelty "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasNoveltyObject()&&t.setNoveltyTo(t.getNoveltyCount()-e)}),t),this},this.incrementStatusCount=function(e){return console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasStatusObject()&&t.setStatusTo(t.getStatusCount()+e)}),t),this},this.decrementStatusCount=function(e){return console.assert(this.hasStatusObject(),"Status "+n),console.assert("number"==typeof e,e+s),l((function(t){t.hasStatusObject()&&t.setStatusTo(t.getStatusCount()-e)}),t),this},this.setTotalNoveltyToStatusCount=function(){return console.assert(this.hasStatusObject(),"Status "+n),console.assert(this.hasNoveltyObject(),"Novelty "+n),this.incrementStatusCount(this.getNoveltyCount()).setNoveltyTo(0)};var a={getNoveltyCount:this.getNoveltyCount,getStatusCount:this.getStatusCount,hasNoveltyObject:this.hasNoveltyObject,hasStatusObject:this.hasStatusObject,setNoveltyTo:this.setNoveltyTo,setStatusTo:this.setStatusTo,incrementNoveltyCount:this.incrementNoveltyCount,decrementNoveltyCount:this.decrementNoveltyCount,incrementStatusCount:this.incrementStatusCount,decrementStatusCount:this.decrementStatusCount,setTotalNoveltyToStatusCount:this.setTotalNoveltyToStatusCount},i=function(t){return t.find(".il-counter-novelty")},o=function(t){return t.find(".il-counter-status")},r=function(t){var n=0;return t.each((function(){var t=e(this).text();n+=parseInt(t)})),n},l=function(t,n){n.each((function(){var n=f(e).getCounterObject(e(this));t(n,e(this))}))};return a};t.UI=t.UI||{},t.UI.maincontrols=t.UI.maincontrols||{},t.UI.maincontrols.metabar=new class{#t;#m=[];#s;#a;#i;#o;constructor(t,e,n,s,a){this.#t=t,this.#s=e,this.#a=n,this.#i=s,this.#o=a}init(t){if(void 0!==this.#m[t])throw new Error(`Metabar with id '${t}' has already been initialized.`);this.#m[t]=new u(this.#t,t,this.#s,this.#a,this.#i,this.#o)}get(t){return this.#m[t]??null}disengageAll(){Object.values(this.#m).forEach((t=>t.disengageAll()))}}(e,(()=>t.UI.page.isSmallScreen()),f(e),(()=>t.UI.maincontrols.mainbar.disengageAll()),(e=>t.UI.maincontrols.slate.disengage(e))),t.UI.maincontrols.slate=new class{#t;#f;#b;constructor(t,e,n){this.#t=t,this.#f=e,this.#b=n}onSignal(t,e,n,s){const a=this.#t(`#${s}`),{triggerer:i}=n,o=i.parents(".il-metabar-more-slate").length>0;if("toggle"===t)this.#p(a,i,o);else if("engage"===t)y(a);else{if("replace"!==t)throw new Error(`No such SignalType: ${t}`);this.#C(s,n)}}#p(t,e,n){const s=t.closest(".il-maincontrols-metabar").attr("id"),a=this.#b.get(s);a instanceof u&&e.attr("id")===a.getMoreButton().attr("id")?a.getEngagedSlates().length>0?a.disengageAllSlates():m(t):(m(t),n||(d(t)?(e.addClass(h),e.removeClass(g),t.trigger("in_view")):(e.removeClass(h),e.addClass(g))))}disengage=S;#C(t,e){const{url:n}=e.options;this.#f(t,n,"content")}}(e,function(t){return function(e,n,s){t.ajax({url:n,dataType:"html"}).done((function(n){var a=t("
"+n+"
"),i=a.find("[data-replace-marker='"+s+"']").first();0==i.length?t("#"+e+" [data-replace-marker='"+s+"']").html(n):(t("#"+e+" [data-replace-marker='"+s+"']").first().replaceWith(i),t("#"+e+" [data-replace-marker='"+s+"']").first().after(a.find("[data-replace-marker='script']")))}))}}(e),t.UI.maincontrols.metabar)}(il,$); diff --git a/components/ILIAS/UI/resources/js/MainControls/src/metabar.class.js b/components/ILIAS/UI/resources/js/MainControls/src/metabar.class.js index c15a5adf2c34..ca5fbcd20415 100755 --- a/components/ILIAS/UI/resources/js/MainControls/src/metabar.class.js +++ b/components/ILIAS/UI/resources/js/MainControls/src/metabar.class.js @@ -356,23 +356,14 @@ export default class Metabar { } } - /** - * @return {void} - */ getMoreButton() { return this.#jquery(`.${classForMoreBtn}`); } - /** - * @return {void} - */ #getMoreSlate() { return this.#jquery(`.${classForMoreSlate}`); } - /** - * @return {void} - */ #getMetabarEntries() { return this.#jquery(`#${this.#id}.${classForEntries}`) .children('li').children('.btn, .il-link') diff --git a/components/ILIAS/UI/resources/js/MainControls/src/slate.class.js b/components/ILIAS/UI/resources/js/MainControls/src/slate.class.js index 53f849501886..ce2d1a3077e5 100755 --- a/components/ILIAS/UI/resources/js/MainControls/src/slate.class.js +++ b/components/ILIAS/UI/resources/js/MainControls/src/slate.class.js @@ -14,6 +14,8 @@ * ******************************************************************** */ +import Metabar from './metabar.class.js'; + /** * @type {string} */ @@ -133,7 +135,7 @@ export default class Slate { const metabarId = slate.closest('.il-maincontrols-metabar').attr('id'); const metabar = this.#metabarFactory.get(metabarId); - if (triggerer.attr('id') === metabar.getMoreButton().attr('id')) { + if (metabar instanceof Metabar && triggerer.attr('id') === metabar.getMoreButton().attr('id')) { if (metabar.getEngagedSlates().length > 0) { metabar.disengageAllSlates(); } else {