[vhffs-dev] [1516] Loading feedback is now shown on any remote action, not just links

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1516
Author:   beuss
Date:     2009-08-07 07:30:17 +0200 (Fri, 07 Aug 2009)

Log Message:
-----------
Loading feedback is now shown on any remote action, not just links

Modified Paths:
--------------
    trunk/vhffs-panel/js/vhffs/Common.js


Modified: trunk/vhffs-panel/js/vhffs/Common.js
===================================================================
--- trunk/vhffs-panel/js/vhffs/Common.js	2009-08-06 23:19:20 UTC (rev 1515)
+++ trunk/vhffs-panel/js/vhffs/Common.js	2009-08-07 05:30:17 UTC (rev 1516)
@@ -48,14 +48,12 @@
 		dojo.forEach(dojo.query('a.ajax', rootNode), function(link) {
 			dojo.connect(link, 'onclick', function(e) {
 				dojo.stopEvent(e);
-				vhffs.Common.showLoading();
 				var href = dojo.attr(link, 'href');
 				if(href != '#') {
 					dojo.back.addToHistory(new vhffs.Common.pageState(href, contentTarget));
 					dojo.xhrGet({
 						url: href,
 						load: function(response) {
-							vhffs.Common.hideLoading();
 							vhffs.Common.loadContent(contentTarget, response);
 						}
 					});
@@ -189,3 +187,23 @@
 	dojo.back.setInitialState(initState);
 });
 
+
+/* Redefines core dojo XHR function to show
+ * loading feedback.
+ */
+dojo.oldXhr = dojo.xhr
+dojo.xhr = function(method, args, hasBody) {
+	// Show the loading logo
+	vhffs.Common.showLoading();
+	// Back up the old load function and replace with our
+	args['real_load'] = args['load'];
+	args['load'] = function(response, ioArgs) {
+		// Call the original load function
+		if(args['real_load']) {
+			args['real_load'](response, ioArgs);
+		}
+		// Everything's done, hide loading logo
+		vhffs.Common.hideLoading();
+	}
+	dojo.oldXhr(method, args, hasBody);
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/