Skip to content
Snippets Groups Projects
Commit 0714d074 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

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.
parent bda310c6
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
},
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment