对的,这是可能的。您可以在命名空间中创建变量,然后创建一个新的 js 文件(根据需要创建 mywidgetconfig.js),该文件将仅包含您希望新团队更改的配置。
例如,您可以拥有如下所示的自定义小部件 (customwidget.js),它定义了其命名空间中的变量
/**
* @class Myns.CustomWidget
* @extends CQ.form.CompositeField
* This is a custom widget based on {@link CQ.form.CompositeField}.
* @constructor
* Creates a new CustomWidget.
* @param {Object} config The config object
*/
var Myns = {};
Myns.CustomWidget = CQ.Ext.extend(CQ.form.CompositeField, {
hiddenField: null,
/**
* @private
* @type CQ.Ext.form.TextField
*/
textf: null,
/**
* @private
* @type CQ.Ext.form.NumberField
*/
numberf: null,
constructor: function(config) {
config = config || { };
var defaults = {
"border": true,
"layout": "form"
};
config = CQ.Util.applyDefaults(config, defaults);
Myns.CustomWidget.superclass.constructor.call(this, config);
},
// overriding CQ.Ext.Component#initComponent
initComponent: function() {
Myns.CustomWidget.superclass.initComponent.call(this);
this.hiddenField = new CQ.Ext.form.Hidden({
name: this.name
});
this.add(this.hiddenField);
this.textf = new CQ.Ext.form.TextField({
fieldLabel: Myns.TEXTFIELDLABEL, //using variable
allowBlank: false
});
this.add(this.textf);
this.numberf = new CQ.Ext.form.NumberField({
fieldLabel: Myns.NUMBERFIELDLABEL, //using variable
allowBlank: false
});
this.add(this.numberf);
}
// rest of the code goes here
});
Myns.TEXTFIELDLABEL = "Enter Text"; //defining variable
Myns.NUMBERFIELDLABEL = "Enter a number"; //defining variable
// register xtype
CQ.Ext.reg('customwidget', Myns.CustomWidget);
你的 mywidgetconfig.js 将包含那些可以被其他人修改的变量。
/*
* Field Label for the text field
*/
Myns.TEXTFIELDLABEL = "New Text";
/*
* Field label for number field
*/
Myns.NUMBERFIELDLABEL = "New number";
在您的 js.txt 中,确保在您的 customwidget.js 下方添加 mywidgetconfig.js
#base=js
customwidget.js
mywidgetconfig.js