Expand my Community achievements bar.

SOLVED

Mode selector in AEM page

Avatar

Level 2

Hi All,

I have a requirement where I do not want timewarp and scaffolding option in my page mode selector. How do I disable these? Any help would be much appreciated.

Screen Shot 2018-05-10 at 12.24.03 PM.png

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

if you really want to do this, you can use javascript also like below to disable modes, create clientlib with cq.authoring.dialog category

(function($, $document) {

    "use strict";

    $(document).on("click", ".editor-GlobalBar-layerSwitcher", function(e) {

    var field = $("button.js-editor-LayerSwitcherTrigger[coral-list-item]");

    if (typeof field !== undefined) {

      field.each(function() {

      if($( this ).val() === "Scaffolding" || $( this ).val()==="Timewarp"){

      $( this ).attr("disabled", true);

      }

      });

    }

    });

})($, $(document));

If you want to remove these two mode,  play with javascript to remove selected elements from DOM.

Thanks

Arun



Arun Patidar

View solution in original post

6 Replies

Avatar

Level 8

overlay the js below

go to line # 142 and add conditon

/libs/cq/gui/components/authoring/editors/clientlibs/core/js/ui/ui.globalBar.js

Avatar

Administrator

From what I know, and please anyone correct me if I am wrong, there is no overlaying of clientlibs.

Clientlibs are registered globally via a 'Category Name'.

Categorys are then called on to be placed into a page.

If you create a custom javascript, and add it to a category that already exists, say 'cq.authoring.dialog' then when that clientlib is called, that code gets called as well. If you create a file that already exists in the clientlib, it doesn't replace that file during clientlib resolution, it just gets stacked onto it. The method you are suggestion would might be working but it would be calling both of the scripts.

You can do this just extending the clientlib, and this is performed just putting in your clientlib the same categories of foundation clientlib.

-Kautuk



Kautuk Sahni

Avatar

Level 10

Also - if you do not want to use a specific feature of AEM - then do not use it. Can you explain why its a requirement to remove a menu item in the UI?

Avatar

Correct answer by
Community Advisor

if you really want to do this, you can use javascript also like below to disable modes, create clientlib with cq.authoring.dialog category

(function($, $document) {

    "use strict";

    $(document).on("click", ".editor-GlobalBar-layerSwitcher", function(e) {

    var field = $("button.js-editor-LayerSwitcherTrigger[coral-list-item]");

    if (typeof field !== undefined) {

      field.each(function() {

      if($( this ).val() === "Scaffolding" || $( this ).val()==="Timewarp"){

      $( this ).attr("disabled", true);

      }

      });

    }

    });

})($, $(document));

If you want to remove these two mode,  play with javascript to remove selected elements from DOM.

Thanks

Arun



Arun Patidar

Avatar

Level 8

Well I am not sure if both the scripts are called.

I created the same folder structure under apps and added the specific js file

/apps/cq/gui/components/authoring/editors/clientlibs/core/js/ui/ui.globalBar.js

It works.

Avatar

Level 2

thanks.. your post was really helpful