0

I have created a button, this will be visible in the toolbar only on opening a Component. I have written config and js file for the same, but the problem is this button is appearing as disabled. Button is there but its not enabled. Please help me, how can I make it enabled.

EDITED

Type.registerNamespace("Extensions.Commands");

Extensions.Commands.Button = function Extensions.Commands$Button(element) {
Type.enableInterface(this, "Extensions.Commands.Button");
this.addInterface("Tridion.Cme.Command", [element]);
this.addInterface("Tridion.Cme.FaCommand", [element]);
alert('inside the pageload');
}; 

Extensions.Commands.Button.prototype._isAvailable = function Button$_isAvailable(target) {
alert('inside the available mode');
if (target.editor.getDisposed()) {
    return false;
}

return true;
};

Extensions.Commands.Button.prototype._isEnabled = function Button$_isEnabled(target) {
alert('inside the enable mode');
if (!Tridion.OO.implementsInterface(target.editor, "Tridion.FormatArea") ||     target.editor.getDisposed()) {
alert('indise if loop');
    return false;
}

return true;
};

My Config file is like this :

<resources cache="true">
<cfg:filters/>
<cfg:groups>
  <cfg:group name="Extensions.Commands" >
    <cfg:fileset>          
      <cfg:file type="script">/Popups/PopupReference.js</cfg:file>

    </cfg:fileset>

    <cfg:dependencies>
      <cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
      <cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
    </cfg:dependencies>
  </cfg:group>

   <cfg:group name="Extensions.Commands.Button.Commands"  merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor"   include="byreference" merge="release">
    <cfg:fileset>
      <cfg:file type="script">/Commands/Button.js</cfg:file>

      <cfg:file type="reference">Extensions.Button.CommandSet</cfg:file>
    </cfg:fileset>

    <cfg:dependencies>
      <cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
      <cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
    </cfg:dependencies>
  </cfg:group> 

  </cfg:groups>
 </resources>
 <definitionfiles/>
 <extensions>
   <ext:editorextensions>
  <ext:editorextension target="CME">
    <ext:editurls/>
    <ext:listdefinitions/>
    <ext:taskbars/>
    <ext:commands/>
    <ext:commandextensions/>
    <ext:contextmenus/>
    <ext:lists/>
    <ext:tabpages/>
    <ext:toolbars/>
    <ext:ribbontoolbars>
      <ext:add>
        <!-- RIBBON TAB -->
 <!-- GROUPS -->
        <ext:extension assignid="ExtensionGroup" pageid="FormatPage" name="ExtensionsName">
          <ext:group/>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>

        <!-- BUTTONS -->
        <ext:extension pageid="FormatPage" groupid="ExtensionGroup" name="Button" assignid="Button">
          <ext:command>Button</ext:command>
          <ext:title>Button</ext:title>
          <ext:dependencies>
            <cfg:dependency>Extensions.Commands.Button</cfg:dependency>
          </ext:dependencies>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>
      </ext:add>
    </ext:ribbontoolbars>
  </ext:editorextension>
  </ext:editorextensions>
  <ext:dataextenders/>
</extensions>            
<commands>
 <cfg:commandset id="Extensions.Commands.Button.CommandSet">
  <cfg:command name="Button" implementation="Extensions.Commands.Button"/>
  <cfg:dependencies>
<cfg:dependency>Extensions.Commands.Button</cfg:dependency>
    <cfg:dependency />
  </cfg:dependencies>
 </cfg:commandset>
 </commands>
 <contextmenus/>
 <localization/>
 <settings>
<defaultpage/>
<navigatorurl/>
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
  <path>Themes</path>
</theme>
<customconfiguration/>
 </settings>

Bart Koopman
  • 4,835
  • 17
  • 30
SDLBeginner
  • 829
  • 1
  • 7
  • 19
  • Is your _isEnabled method being invoked? If not, there is probably something wrong with the way your register your dependencies and ***you*** should double check those against a working example. – Frank van Puffelen Aug 02 '12 at 18:23
  • @Frank van Puffelen : Just now i found that my Js is not getting triggered. :( Dont know why. I checked the dependencies also. Its all well set. Not able to find where is the error. :( – SDLBeginner Aug 03 '12 at 05:17

2 Answers2

4

The resources group "Extensions.Commands.Button.Commands" is never referenced in the configuration file. Besides that in the Button extension group you have dependency on the "Extensions.Commands.Button" group, which doesn't exist in config file. So suggestion will be to clean up the configuration file, remove not needed dependencies etc.

P.S. There is no need to inherit from both "Tridion.Cme.Command" and "Tridion.Cme.FaCommand" because the last one already inherits first one.

Boris Ponomarenko
  • 1,324
  • 6
  • 7
2

As Frank says I'd check the _IsEnabled. When this method returns true the button will be enabled within the SDL Tridion GUI

I would debug this the following way (Note: I'm a bit old school in my JS debugging :))

RTFExtensions.Commands.Button.prototype._isEnabled = function Customtags$_isEnabled(target) {
if (!Tridion.OO.implementsInterface(target.editor, "Tridion.FormatArea") ||  target.editor.getDisposed()) {
    return false;
}

In the following way:

  • Check in firebug for any JS errors
  • Put an alert in the _isEnabled to see if it is being entered
  • Put an alert in the IF statement to see if this is always entered

Once you've got it working, I'd be interested to know what's going wrong, perhaps you could provide the solution here?

johnwinter
  • 3,624
  • 15
  • 24