var Ajax; if (Ajax && (Ajax != null)) { Ajax.Responders.register({ onCreate: function() { if($('spinner') && Ajax.activeRequestCount>0) Effect.Appear('spinner',{duration:0.5,queue:'end'}); }, onComplete: function() { if($('spinner') && Ajax.activeRequestCount==0) Effect.Fade('spinner',{duration:0.5,queue:'end'}); } }); } // jQuery AJAX utils. function loadingIndication() { return jQuery('#jQueryAjaxLoading').clone(); } function errorIndication(jqXHR, textStatus, errorThrown) { return jQuery('#jQueryAjaxDefaultError').clone().append('Status:'+jqXHR.status+', '+textStatus+'.'); } // Apply updates to multiple page elements. // @json JSON response object from an ajax request. // @json.updates Array of element updates to apply. // @element.mode The update mode: execute or replace, prepend, append. // @element.script Script to execute, if execute mode. // @element.target jQuery target selector, if update mode. // @element.content Content to update target with, if update mode. function applyElementUpdates(json) { var updates; var script; if(json.updates) { updates = json.updates; var element; var scripts = new Array(); for(element in updates) { element = updates[element]; switch(element.mode) { case 'execute': scripts.push(element.script); break; case 'replace': jQuery(element.target).html(element.content); break; case 'prepend': jQuery(element.target).prepend(element.content); break; case 'append': jQuery(element.target).append(element.content); break; } } // Run scripts. for(script in scripts) { script = scripts[script]; eval(script); } } // if(json.updates) } // applyElementUpdates