var $,add_filters,ajaxify_form,enable_filters,exports,process_filter_response,show_filters;$=jQuery;exports=this;exports.show_url=filter_url;exports.add_url=filter_add_url;process_filter_response=function(data){var html,links,url;if(data.success){links=build_links(data.active_filters);url=window.location.pathname+'.json';$('#fhl').empty();if(links!==""){$('#fhl').append(links);$('.mkbox').removeClass('hide');}else{$('.mkbox').removeClass('show');$('.mkbox').addClass('hide');}$('#fhl a').bind('click',function(e){e.preventDefault();enable_filters(this.href);return 1;});ajaxrequest(url);1;}else{html=$.mustache(exports.errbox,{msg:data.errors.msg});if($('#alertmsg').length){$('#alertmsg').empty();$('#alertmsg').remove();}$('#heading').after(html);1;}return 1;};enable_filters=function(url){$.ajax(url+'.json',{type:'GET',cache:false,dataType:'json',beforeSend:function(XHR){exports.inprogress=true;$('#spinner').show();return 1;},success:process_filter_response,error:ajax_error_redirect,complete:function(XHR,textStatus){exports.inprogress=false;$('#spinner').hide();return 1;}});return 1;};ajaxify_form=function(){$('#afform .closeflash').bind('click',function(e){e.preventDefault();$('.form_area').hide();return $('#form-area').hide();});$('#filter-form').submit(function(e){var request_data,text,url;e.preventDefault();$("#filter_form_submit").attr({disabled:'disabled',value:gettext('Loading')});text=gettext('Processing request.............');$('#afform').after('<div class="grid_16 drow" id="filter-ajax"><div class="grid_7">'+text+'</div></div>');request_data={filtered_field:$("#filtered_field").val(),filtered_by:$("#filtered_by").val(),filtered_value:$("#filtered_value").val(),csrf_token:$("#csrf_token").val()};url=$('#filter-form').attr('action');return $.ajax(url+'.json',{type:'POST',cache:false,data:request_data,success:process_filter_response,dataType:'json',beforeSend:function(XHR){exports.inprogress=true;return 1;},error:display_ajax_error,complete:function(XHR,textStatus){$("#filter_form_submit").removeAttr('disabled').attr({value:gettext('Add Filter')});$("#filter-ajax").remove();exports.inprogress=false;return 1;}});});return 1;};show_filters=function(){$.ajax(exports.show_url,{type:'GET',dataType:'html',cache:false,beforeSend:function(XHR){exports.inprogress=true;$('#spinner').show();return 1;},success:function(data,textStatus,XHR){if(!$('#applied_filters').length)if(!$('.form_area').length)$('#sublinks').after(data);else $('.form_area').after(data);$('.mkbox').removeClass('hide');if(!$('#fhl a').length)$('#fhl').html('<span id="tmpinfo">'+gettext('Non applied at the moment')+'</span>');$('#fhl a').bind('click',function(e){e.preventDefault();return enable_filters(this.href);});return 1;},complete:function(XHR,textStatus){exports.inprogress=false;$('#spinner').hide();return 1;},error:display_ajax_error});return 1;};add_filters=function(){if(exports.inprogress)return;if(!$('.form_area').length)$.ajax(exports.add_url,{type:'GET',dataType:'html',cache:true,beforeSend:function(XHR){exports.inprogress=true;$('#spinner').show();return 1;},success:function(data,textStatus,XHR){if(!$('.form_area').length)$('#sublinks').after(data);init_form();ajaxify_form();return 1;},complete:function(XHR,textStatus){exports.inprogress=false;return $('#spinner').hide();},error:display_ajax_error});$('.form_area').show();return 1;};