From 0714d0748a1edfc4b9503880cf8a91590d862580 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sun, 30 Jan 2011 13:29:45 +0000 Subject: [PATCH] Migrate the creation of field tooltips listeners from xentry to xform. In that case work in all case: a pure form or a form from a grid. --- static/plugin_dbui/src/appform.js | 29 +++++++++++++++++++++++++++++ static/plugin_dbui/src/appform2.js | 29 +---------------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index a3479153..09e39dc4 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 d1f557a0..8eeea9a1 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); }, /** -- GitLab