diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index a347915353949b98300a416d23d4b5fbe0f08d15..09e39dc478e152d93ea8e435198d555852e6ea3c 100644 --- a/static/plugin_dbui/src/appform.js +++ b/static/plugin_dbui/src/appform.js @@ -60,8 +60,37 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { // reset the form this.buttonClear.on('click', resetForm, this.getForm()); + + // activate fields tooltip listeners + this.fieldToolTipsListeners(); }, + /** + * Private function to link fields tooltip + * Require the configuration parameter Ext.form.Field.tipText. + */ + fieldToolTipsListeners: function () { + var form; + + function createToolTip (c) { + //NOTE: don't remove the new keyword although JSlint require it + new Ext.ToolTip({ + target: c.getEl(), + title: c.fieldLabel, + anchor: 'left', + trackMouse: false, + html: Ext.util.Format.htmlEncode(c.tipText) + }); + } + + form = this.getForm(); + form.items.each(function (field) { + if (field.tipText) { + field.on('render', createToolTip); + } + }); + }, + /** * Helper function to enable/disable all fields of the form * @param {Object} boolean diff --git a/static/plugin_dbui/src/appform2.js b/static/plugin_dbui/src/appform2.js index d1f557a050a6eb5f01fdb0933f3a2179693625b8..8eeea9a14e2bcc2bbfaf30194ab72b4e77e2486f 100644 --- a/static/plugin_dbui/src/appform2.js +++ b/static/plugin_dbui/src/appform2.js @@ -21,21 +21,6 @@ Ext.namespace('App.form'); -/** - * Helper function to render the tooltip associate to a field - * @param {Object} c - */ -App.form.setToolTip = function (c) { - //NOTE: don't remove the new keyword although JSlint require it - new Ext.ToolTip({ - target: c.getEl(), - title: c.fieldLabel, - anchor: 'left', - trackMouse: false, - html: Ext.util.Format.htmlEncode(c.tipText) - }); -}; - App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { @@ -59,24 +44,12 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { */ initComponent: function () { - var fields, field, i; - if (!this.tableName) { throw new Error("the property tablename is missing !!!"); } App.form.EntryFormPanel.superclass.initComponent.call(this); - this.buttonCreate.on("click", this.onSubmit, this); - - // Add handler to display tool tip for each field - // Require the configuration parameter tipText. - fields = this.findByType('field'); - for (i = 0; i < fields.length; i += 1) { - field = fields[i]; - if (field.tipText) { - field.on('render', App.form.setToolTip); - } - } + this.buttonCreate.on("click", this.onSubmit, this); }, /**