From 105b368b1e80cf181d16a547e03599f5da7e6cf2 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Wed, 4 Aug 2010 12:30:25 -0500 Subject: [PATCH] refactor helper processing to use in progressbar --- www/extras/admin/admin.js | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 1b20cbdfa..19d0100ff 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -431,22 +431,7 @@ WebGUI.Admin.prototype.requestHelper var callback = { success : function (o) { var resp = YAHOO.lang.JSON.parse( o.responseText ); - - if ( resp.openTab ) { - this.openTab( resp.openTab ); - } - else if ( resp.openDialog ) { - this.openModalDialog( resp.openDialog, resp.width, resp.height ); - } - else if ( resp.scriptFile ) { - this.loadAndRun( resp.scriptFile, resp.scriptFunc, resp.scriptArgs ); - } - else if ( resp.message ) { - this.showInfoMessage( resp.message ); - } - else { - alert( "Unknown helper response: " + resp ); - } + this.processHelper( resp ); }, failure : function (o) { @@ -458,6 +443,36 @@ WebGUI.Admin.prototype.requestHelper var ajax = YAHOO.util.Connect.asyncRequest( 'GET', url, callback ); }; +/** + * processHelper( response ) + * Process the helper response. Possible responses include: + * message : A message to the user + * error : An error message + * openDialog : Open a dialog with the given URL + * redirect : Redirect the View pane to the given URL + * scriptFile : Load a JS file + * scriptFunc : Run a JS function. Used with scriptFile + * scriptArgs : Arguments to scriptFunc. Used with scriptFile + */ +WebGUI.Admin.prototype.processHelper += function ( resp ) { + if ( resp.openTab ) { + this.openTab( resp.openTab ); + } + else if ( resp.openDialog ) { + this.openModalDialog( resp.openDialog, resp.width, resp.height ); + } + else if ( resp.scriptFile ) { + this.loadAndRun( resp.scriptFile, resp.scriptFunc, resp.scriptArgs ); + } + else if ( resp.message ) { + this.showInfoMessage( resp.message ); + } + else { + alert( "Unknown helper response: " + resp ); + } +}; + /** * openModalDialog( url, width, height ) * Open a modal dialog with an iframe containing the given URL.