/** * Arie Nugraha 2009 * this file need jQuery library * library to works * * AJAX related functions */ jQuery.extend({ ajaxHistory: new Array(), addAjaxHistory: function(strURL, strElement) { jQuery.ajaxHistory.unshift({url: strURL, elmt: strElement}); // delete the last element if (jQuery.ajaxHistory.length > 5) { jQuery.ajaxHistory.pop(); } }, ajaxPrevious: function() { if (jQuery.ajaxHistory.length < 1) { return; } var moveBack = 1; if (arguments[0] != undefined) { moveBack = arguments[0]; } if (moveBack >= jQuery.ajaxHistory.length) { moveBack -= 1; } if (jQuery.ajaxHistory.length <= 1) { top.location.href = location.pathname + location.search; return; } $(jQuery.ajaxHistory[moveBack].elmt).simbioAJAX(jQuery.ajaxHistory[moveBack].url, {method: 'get'}); } }); /** * Function to Set AJAX content * * @param string strSelector : string of CSS and XPATH selector * @param string strURL : URL of AJAX request * @return void */ jQuery.fn.simbioAJAX = function(strURL, params) { var options = { method: 'get', insertMode: 'replace', addData: '', returnType: 'html', loadingMessage: 'LOADING CONTENT... PLEASE WAIT' }; jQuery.extend(options, params); var ajaxContainer = $(this); var currLoaderMessage = $(".loader").html(); $(".loader").html(options.loadingMessage); $(".loader").ajaxStart(function(){ $(this).addClass('loadingImage'); }); $(".loader").ajaxSuccess(function(){ $(this).html(currLoaderMessage); // no history on post AJAX request if (options.method != 'post') { var historyURL = strURL; if (options.addData.length > 0) { var addParam = options.addData; if (Array.prototype.isPrototypeOf(options.addData)) { addParam = jQuery.param(options.addData); } if (historyURL.indexOf('?', 0) > -1) { historyURL += '&' + addParam; } else { historyURL += '?' + addParam; } } jQuery.addAjaxHistory(historyURL, ajaxContainer[0]); } }); $(".loader").ajaxStop(function(){ $(this).removeClass('loadingImage'); }); $(".loader").ajaxError(function(event, request, settings){ $(this).html("