jQuery(function($){ // ------------- TAB HANDLING --------------- // Remove the # from the hash, as different browsers may or may not include it var hash = location.hash.replace('#',''); if(hash != ''){ hash = parseInt(hash); $('.tabs a[tabid=' + Math.floor( hash / 100 ) + ']').trigger('click'); $('.tabs a[tabid=' + hash + ']').trigger('click'); } else { $('.tabs a[tabid=1]').trigger('click'); } $('.tabs a').on('click', function(){ location.hash = $(this).attr('tabid'); }); // ------------------------------------------ // -------- Individual Priorities ----------- $("#p_asp_submit").on('click', function(e){ e.preventDefault(); var data = { action: 'ajaxsearchpro_priorities', 'asp_priorities_request_nonce': $('#asp_priorities_request_nonce').val(), options: $("#asp_priorities").serialize(), ptask: "get" }; $('#p_asp_loader').css('display', 'block'); $('#p_asp_results').fadeOut(10); var post = $.post(ASP_PTS.ajax_url, data, function (response) { response = response.replace(/^\s*[\r\n]/gm, ""); response = response.match(/!!PASPSTART!!(.*[\s\S]*)!!PASPEND!!/)[1]; response = JSON.parse(response); var html = ''; $.each(response, function(k, v){ var input = ""; var old_priority = ""; if (typeof (v.priority) != 'undefined') { input = ""; old_priority = ""; } html += "

["+ v.id +"] " + v.title + "

" + input + old_priority + "

" + v.date + "

" + v.author + "

"; }); if (html == '') { $('#p_asp_loader').css('display', 'none'); $('#p_asp_results').html('

No results!

'); return true; } html += ""; $('#p_asp_results').html("
" + html + "
"); $('#p_asp_loader').css('display', 'none'); $('#p_asp_results').fadeIn(150); }, "text"); }); $('#p_asp_results').on('click', '.p_asp_save', function(e){ e.preventDefault(); var $this = $(this); var data = { action: 'ajaxsearchpro_priorities', 'asp_priorities_request_nonce': $('#asp_priorities_request_nonce').val(), options: $("#asp_priorities_list").serialize(), ptask: "set" }; $this.prop('disabled', true); $('#p_asp_results').fadeOut(10); $('#p_asp_loader').css('display', 'block'); var post = $.post(ASP_PTS.ajax_url, data, function (response) { response = response.replace(/^\s*[\r\n]/gm, ""); response = response.match(/!!PSASPSTART!!(.*[\s\S]*)!!PSASPEND!!/)[1]; response = JSON.parse(response); $this.prop('disabled', false); $('#p_asp_loader').css('display', 'none'); $("#p_asp_submit").trigger('click'); }, "text"); }); // ------------------------------------------- ETC ----------------------------------------------------------------- function msg(k) { return typeof ASP_PTS[k] != 'undefined' ? ASP_PTS[k] : ''; } });