% content_for :document_ready do %> $( window ).resize(function() { var vph = ($( window ).height() - 250); $('#tst_medias').css({'height': vph}); }); $("#pw_search_form").submit(function() { $("#pw_provider_form :input:checked").each(function() { $("#pw_search_form").append("") }); }); $("#search").scroll(function () { var $this = $(this), height = this.scrollHeight - $this.height(), scroll = $this.scrollTop(), overf = height - scroll, page = $('#page_encours').val(); page = parseInt(page); var scrollpage = $('#page_scroll').val(); scrollpage = parseInt(scrollpage); var total_pages = $('#total_pages').val(); if (overf < 400 && page == scrollpage && page < parseInt(total_pages)) { page += 1; $('#page_scroll').attr('value', page); <% if params[:search] %> $.get("home.js?page="+page+"&search="+<%=params[:search]%>); <% elsif params[:ags] %> $.get("home.js?page="+page+"&ags=<%= params[:ags] %>&pp_params=<%= params[:pp_params] %>"); <% else %> $.get("home.js?media_typ=all&page="+page); <% end %> } }); $( document ).on( "change", "#search_since, #sort", function(){ $("#pw_provider_form :input:checked").each(function() { $("#pw_search_form").append("") }); document.pw_search_form.submit(); }); $( document ).on( "change", "#perpage", function(){ var defpage = $(this).val(); $('#default_per_page').attr('value',defpage); $("#pw_provider_form :input:checked").each(function() { $("#pw_search_form").append("") }); document.pw_search_form.submit(); }); $('.facet_search').click(function(event){ var prov = $(this).attr('p_id'); $('.hideprov').each(function() { $(this).remove(); }); $("#pw_search_form").append(""); document.pw_search_form.submit(); event.preventDefault(); }); function location_v(p) { if (p > <%= @medias.total_pages %>) { alert('La page demandée n\'existe pas'); event.preventDefault(); } else { if (location.href.indexOf('?') > 0) { $(location).attr('href',location.href+'&page='+p); } else { $(location).attr('href',location.href+'?page='+p); } } }; $('.haut').keyup(function(event) { if (event.which == '37' ) { // <- previous_page = $('.pagination:first .previous_page').attr('href'); if (previous_page){ document.location = previous_page }; } else if (event.which == '39') { // -> next_page = $('.pagination:first .u_next_page').attr('href'); if (next_page){ document.location = next_page }; } else if (event.which == '13') { // enter var v = parseInt($(this).val()); location_v(v); } else { event.preventDefault(); } }); $('.bas').keyup(function(event) { if (event.which == '37' ) { // <- previous_page = $('.pagination:first .previous_page').attr('href'); if (previous_page){ document.location = previous_page }; } else if (event.which == '39') { // -> next_page = $('.pagination:first .u_next_page').attr('href'); if (next_page){ document.location = next_page }; } else if (event.which == '13') { // enter var v = parseInt($(this).val()); location_v(v); } else { event.preventDefault(); } }); $('.multi').click(function() { var res = 'ids[]='; res += $('#pw_results :checkbox:checked').map(function() { return this.id.replace('med_',''); }).get().join('&ids[]='); curr_href = $(this).attr('href'); if ($(this).attr('href').indexOf("?") > 0 ){ $(this).attr('href', curr_href+'&'+res); } else { $(this).attr('href', curr_href+'?'+res); } }); $('#page_encours').focus(); <% end %> <% if session[:provs] && session[:provs].count > 1 && Pixways.get_pixtech_param_value(session[:pixtech],'hide_providers_panel') != 'true' %>