3

I have a small GUI extension that is hiding the Save button on the component view (thanks to Albert Romkes).

It works great, upon loading the Save button is gone - but - after loading, if you interact with the main item toolbar (click Organise for example) the Save button returns.

enter image description here

I'm assuming I need to hook into the events of the toolbar and re-trigger my hide function when a user clicks on one of the links but I can't find the right event to hook into.

Currently I have the following (shortened for brevity):

Company.Extensions.HideSaveCommand = function HideSaveCommand() {
    Type.enableInterface(this, "Company.Extensions.HideSaveCommand");
    this.addInterface("Tridion.Cme.Command", ["HideSaveCommand"]);

    $evt.addEventHandler($display, "start", this._onDisplayStarted);
};

Company.Extensions.HideSaveCommand.prototype._onDisplayStarted = function HideSaveCommand$_onDisplayStarted() 
{
    console.log("_onDisplayStarted called");
    $evt.removeEventHandler($display, "start", this._onDisplayStarted); 

    var item = $display.getItem();
    if (item) {
        if (item.getItemType() == "tcm:16") {                   
            var tabs = $display.getView().getWindow().$controls.getControl($("#ItemToolbar"), "Tridion.Controls.TabControl")
            if(typeof tabs !== "undefined"){
                tabs.addEventListener("click", function(t) { 
                    console.log("CLICKED" + t);
                    this.doHide();                  
                });
                tabs.addEventListener("switch", function(t) { 
                    console.log("switch" + t);
                    this.doHide();                  
                });             
                tabs.addEventListener("select", function(t) { 
                    console.log("select" + t);
                    this.doHide();                  
                });             
            };
        }
    }
}

There's no error in the console, but I never see any log when switching between items in the toolbar. I've debugged and know that tabs is set to the tab control, but I'm happy to rewrite if there's a better way to achieve what I'm after!

6

OK - the issue was my incorrect assumption that the Item Toolbar was of type Tridion.Controls.TabControl, when it is in fact Tridion.Controls.RibbonToolbar!

The following line:

var tabs = $display.getView().getWindow().$controls.getControl($("#ItemToolbar"), "Tridion.Controls.TabControl")

Had to become:

var tabs = $display.getView().getWindow().$controls.getControl($("#ItemToolbar"), "Tridion.Controls.RibbonToolbar")

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.