我一直在下面GUI扩展和通知示例使用两种_isEnabled或isEnabled,没有下划线.两者似乎都可以扩展或可能替换现有功能.
例如,PowerTools基类(似乎不"扩展"现有功能)具有:
PowerTools.BaseCommand.prototype.isEnabled = function(selection, pipeline)
{
var p = this.properties;
if (!p.initialized)
{
this.initialize();
}
if (!this.isToolConfigured())
{
return false;
}
if (this.isValidSelection)
{
return this.isValidSelection(selection, pipeline);
}
return true;
};
Run Code Online (Sandbox Code Playgroud)
工具可以使用此基类并声明.isValidSelection,例如:
PowerTools.Commands.CountItems.prototype.isValidSelection =
function (selection) { ... }
Run Code Online (Sandbox Code Playgroud)
我看到Anguilla ._isEnabled用于现有功能(在代码中的许多地方的Chrome控制台中).例如,WhereUsed有:
Tridion.Cme.Commands.WhereUsed.prototype._isAvailable =
function WhereUsed$_isAvailable(selection) ...
Run Code Online (Sandbox Code Playgroud)
我熟悉前面的下划线是私有变量的命名约定._isEnabled和其他以下划线"私有"开头的函数是什么?如果是的话,那么
我假设相同的方法适用于以下划线开头的其他函数,例如_isAvailable,和_invoke.