// ************************************ // // jQuery ACP Functions // // ************************************ // /** * IPS namespace */ var ips = {}; !function($, window, document, _undefined) { $.extend(ips, { /** * Binds all registered functions to elements within the DOM */ init: function() { Debug.write('Initialising ips jQuery object'); /* Hide menus */ $(".acp-menu").hide(); /* Set up the modal */ $("#modal").css( { height: ( $(window).height() - parseInt( $("#header").height() ) ) } ); $(window).resize( function(e) { $("#modal").css( { height: ( $(window).height() - parseInt( $("#header").height() ) ) } ); } ); /* Bindings */ if ( $('#edit_tabs').length ) { $('#edit_tabs').on( 'click', function(e) { window.location = ips.acpUrl + '&app=core&module=mycp§ion=tabs'; } ); } Debug.write("All jQueried up in here"); }, /** * POSTs and always expects JSON * * @param string url to GET * @param object hash to POST * @param function Method to run * @param object Options * * @return XMLHttpRequest */ ajax: function( url, data, success, options ) { url = url.replace( /&/g, '&' ); var ajaxOptions = $.extend(true, { data: data, url: url, success: function( data, textStatus, jqXHR ) { success( data, textStatus, jqXHR ); }, type: 'POST', dataType: 'json', error: function(xhr, textStatus, errorThrown) { try { /* If its JSON, run it anyway */ success.call(null, $.parseJSON(xhr.responseText), textStatus); } catch (e) { /* Throw error */ console.error( xhr.responseText ); } }, timeout: 30000 }, options); return $.ajax(ajaxOptions); }, /** * Loads CSS * @param url */ loadCss: function( url ) { if ( url ) { $('').appendTo( $('head') ); } }, /** * Loads JS * @param url */ loadJs: function( url ) { if ( url && ( this.loadedJs.indexOf( url ) == -1 ) ) { $('