From 00c9bca61e853b4c00d54f96699befca0722e3a2 Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <renaud.legac@free.fr>
Date: Sat, 15 Jan 2011 16:50:15 +0000
Subject: [PATCH] Continue with JSlint check. Move all inline function at the
 begining of a function.

---
 static/plugin_dbui/lib/appbase.js             |  1 -
 static/plugin_dbui/lib/appform.js             |  6 ++-
 static/plugin_dbui/lib/appform2.js            | 18 ++++---
 static/plugin_dbui/lib/appgrid.js             |  3 +-
 static/plugin_dbui/lib/appgridfilter.js       | 25 +++++----
 static/plugin_dbui/lib/appgridpaging.js       |  6 ++-
 static/plugin_dbui/lib/appgridroweditor.js    | 53 ++++++++++---------
 .../plugin_dbui/lib/appviewportintreegrid.js  | 31 +++++------
 8 files changed, 74 insertions(+), 69 deletions(-)

diff --git a/static/plugin_dbui/lib/appbase.js b/static/plugin_dbui/lib/appbase.js
index 67a2c932..e437d75f 100644
--- a/static/plugin_dbui/lib/appbase.js
+++ b/static/plugin_dbui/lib/appbase.js
@@ -6,7 +6,6 @@
  * $Id$
  * 
  */
-
 Ext.namespace('App');
 
 /**
diff --git a/static/plugin_dbui/lib/appform.js b/static/plugin_dbui/lib/appform.js
index a06538d6..975c9bbb 100644
--- a/static/plugin_dbui/lib/appform.js
+++ b/static/plugin_dbui/lib/appform.js
@@ -51,11 +51,15 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, {
 	 */	
 	initComponent: function () {
 		
+		function resetForm() {
+			this.reset();
+		}
+		
 		// construct the underlying class. DON'T MOVE
 		App.form.FormPanel.superclass.initComponent.call(this);
 		
 		// reset the form
-		this.buttonClear.on('click', function () {this.reset(); }, this.getForm());
+		this.buttonClear.on('click', resetForm, this.getForm());
 	},
 
 	/**
diff --git a/static/plugin_dbui/lib/appform2.js b/static/plugin_dbui/lib/appform2.js
index 2b8af001..ce20b6b6 100644
--- a/static/plugin_dbui/lib/appform2.js
+++ b/static/plugin_dbui/lib/appform2.js
@@ -73,7 +73,7 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, {
 		// 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){
+		for (i = 0; i < fields.length; i += 1) {
 			field = fields[i];
 			if (field.tipText) {
 				field.on('render', App.form.setToolTip);
@@ -86,6 +86,14 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, {
 	 */		
 	onSubmit: function () {
 
+		function onFailure(form, action) {
+			if (action.response) {
+				if (action.response.status !== 200) {
+					Ext.MessageBox.alert('Error', action.response.responseText);
+				}
+			}			
+		}
+		
 		this.getForm().submit({
 			clientValidation: true,
 			url: this.url,
@@ -97,13 +105,7 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, {
 			},
 			reset: true,
 			waitMsg: 'Saving Record...',			
-			failure: function (form, action) {
-				if (action.response) {
-					if (action.response.status !== 200) {
-						Ext.MessageBox.alert('Error', action.response.responseText);
-					}
-				}
-			}
+			failure: onFailure
 		});
 	}
 });
diff --git a/static/plugin_dbui/lib/appgrid.js b/static/plugin_dbui/lib/appgrid.js
index 335fe124..f6744017 100644
--- a/static/plugin_dbui/lib/appgrid.js
+++ b/static/plugin_dbui/lib/appgrid.js
@@ -112,8 +112,7 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, {
 		// the number of rows per page and will reload the store accordingly.
 		if (isPagingPlugin) {
 			grid.store.load({params: {start: 0, limit: 1}});
-		}
-		else {
+		} else {
 			grid.store.load();
 		}
 		return true;
diff --git a/static/plugin_dbui/lib/appgridfilter.js b/static/plugin_dbui/lib/appgridfilter.js
index 608e557f..595f6e74 100644
--- a/static/plugin_dbui/lib/appgridfilter.js
+++ b/static/plugin_dbui/lib/appgridfilter.js
@@ -42,8 +42,10 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
 	 * NOTE: 
 	 * the enableKeyEvents is mandatory for Ext.form.TextField
 	 */
-	defaults: {anchor: '100%',
-			   enableKeyEvents: true},
+	defaults: {
+		anchor: '100%',
+		enableKeyEvents: true
+	},
 	
 	/**
 	 * private method requests by the component model of Ext JS
@@ -63,11 +65,10 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
 			// catch a change of value for combobox
 			if (field.xtype === 'xcombobox') {
 				field.on('select', this.onChange, this);
-			}
-			
-			// catch the key pressed enter for other fields
-			// wait that user finish to type to run the handler
-			else {
+				
+			} else {
+				// catch the key pressed enter for other fields
+				// wait that user finish to type to run the handler
 				field.on('keyup', this.onChange, this, {buffer: 500});
 			}
 		}
@@ -138,17 +139,16 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
 		
 		if (value === '') {
 			delete this.filterConditions[field.name];
-		}
-		else {
+		} else {
 			this.filterConditions[field.name] = where;
 		}
 					
 		// build the complete where clause
-		for (i = 0; i < this.initialFilterConditions.length; i += 1){
+		for (i = 0; i < this.initialFilterConditions.length; i += 1) {
 			conditions.push(this.initialFilterConditions[i]);
 		}
 		
-		for( k in this.filterConditions){
+		for (k in this.filterConditions) {
 			if (this.filterConditions.hasOwnProperty(k)) {
 				conditions.push(this.filterConditions[k]);
 			}
@@ -169,8 +169,7 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
 		
 		if (this.pagingToolbar) {
 			this.pagingToolbar.doRefresh();
-		}
-		else {
+		} else {
 			this.store.load();
 		}		
 	}
diff --git a/static/plugin_dbui/lib/appgridpaging.js b/static/plugin_dbui/lib/appgridpaging.js
index 1891ec9c..68f4413e 100644
--- a/static/plugin_dbui/lib/appgridpaging.js
+++ b/static/plugin_dbui/lib/appgridpaging.js
@@ -33,8 +33,10 @@ App.grid.Paging = Ext.extend(Object, {
 				 {
 					xtype: 'slider',
 					plugins: new Ext.slider.Tip(),
-					listeners: {changecomplete: this.onChangePageSize,
-								scope: bbar},
+					listeners: {
+						changecomplete: this.onChangePageSize,
+						scope: bbar
+					},
 					minValue: 1,
 					width: 100
 				 }, 
diff --git a/static/plugin_dbui/lib/appgridroweditor.js b/static/plugin_dbui/lib/appgridroweditor.js
index 7415268d..bb5ce113 100644
--- a/static/plugin_dbui/lib/appgridroweditor.js
+++ b/static/plugin_dbui/lib/appgridroweditor.js
@@ -64,6 +64,25 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
 
 		var cbrec,  combo, combos, i, item, values;
 		
+		function onUpdateStore(store, rec, op) {
+			if (op === Ext.data.Record.COMMIT && Ext.version >= '3.2.1') {
+
+				values = this.formPanel.getForm().getValues();
+				for (item in values) {
+					if (values.hasOwnProperty(item)) {
+						rec.data[item] = values[item];
+					}
+				}
+
+				combos = this.findByType('xcombobox');
+				for (i = 0; i < combos.length; i += 1) {
+					combo = combos[i];
+					cbrec = combo.findRecord(combo.valueField, combo.getValue());
+					rec.data[combo.displayField] = cbrec.get(combo.displayField);
+				}
+			}
+		}
+		
 		this.grid = grid;
 		this.formPanel = this.items.first();
 
@@ -87,25 +106,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
 		// HACK: In version 3.2.1 the data in the record are lost somewhere
 		// As a consequence, the values appearing in the grid after an
 		// update are empty. This fix correct this issue.
-		this.grid.store.on("update", function (store, rec, op) {
-			if (op === Ext.data.Record.COMMIT && Ext.version >= '3.2.1') {
-
-				values = this.formPanel.getForm().getValues();
-				for (item in values) {
-					if (values.hasOwnProperty(item)) {
-						rec.data[item] = values[item];
-					}
-				}
-
-				combos = this.findByType('xcombobox');
-				for (i = 0; i < combos.length; i += 1) {
-					combo = combos[i];
-					cbrec = combo.findRecord(combo.valueField, combo.getValue());
-					rec.data[combo.displayField] = cbrec.get(combo.displayField);
-				}
-				
-			}
-		}, this);	
+		this.grid.store.on("update", onUpdateStore, this);	
 	},
 
 	/**
@@ -276,7 +277,14 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
 	 */
 	onViewRow: function () {
 
-        var record = this.getSelected();
+		var record;
+		
+		function onHide() {
+			this.formPanel.buttonClear.show();
+			this.formPanel.buttonCreate.show();			
+		}
+		
+        record = this.getSelected();
 		if (!record) {return; }
 
 		this.setTitle("View the record...");
@@ -287,10 +295,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
 		this.formPanel.buttonClear.hide();
 		this.formPanel.buttonCreate.hide();
 
-		this.on("hide", function () {
-			this.formPanel.buttonClear.show();
-			this.formPanel.buttonCreate.show();
-		}, this);
+		this.on("hide", onHide, this);
 		
 	},
 	
diff --git a/static/plugin_dbui/lib/appviewportintreegrid.js b/static/plugin_dbui/lib/appviewportintreegrid.js
index 1214b82f..2c545bbd 100644
--- a/static/plugin_dbui/lib/appviewportintreegrid.js
+++ b/static/plugin_dbui/lib/appviewportintreegrid.js
@@ -40,17 +40,7 @@ App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, {
 
 		var cfg, grid, gridfilter, table, wdg;
 		
-		// protection -- add widget when we are concern !				
-		if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) {
-			return;
-		}
-		
-		// get the name of the table from the tab id
-		table = this.getNodeNameFromId(component.id);
-		
-		// Ask the server the widget configuration and create it
-		cfgSvc.getGridModel(table, function (provider, response) {
-		
+		function createGrid(provider, response) {
 			cfg = response.result;
 			wdg = Ext.ComponentMgr.create(cfg);
 			
@@ -84,17 +74,22 @@ App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, {
 
 				// connect the reset button
 				wdg.resetButton.on('click', gridfilter.onReset, gridfilter);
-
-			} else {
-				
-				// create a stand alone grid
-				
 			}
 					
 			component.add(wdg);
 			component.doLayout();
-			
-		}, this);
+		}
+		
+		// protection -- add widget when we are concern !				
+		if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) {
+			return;
+		}
+		
+		// get the name of the table from the tab id
+		table = this.getNodeNameFromId(component.id);
+		
+		// Ask the server the widget configuration and create it
+		cfgSvc.getGridModel(table, createGrid, this);
 	}
 });
 
-- 
GitLab