我创建了一个按钮,只有在打开组件时才能在工具栏中看到它。我已经编写了相同的配置和 js 文件,但问题是这个按钮显示为禁用。按钮在那里,但未启用。请帮助我,我怎样才能启用它。
已编辑
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;
};
我的配置文件是这样的:
<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>