$(document).ready(function(){ $( "#tabs" ).tabs({ cookie: { expires: 1 }, }); $("li.tooltip").each(function(){ var title = $('a', this).attr('title'); var width = $(this).attr('wdth'); $(this).qtip({ solo:true, content: title, style: { width: width, classes: "ui-tooltip-dark" }, position: { my: 'top right', at: 'bottom right', } }); }); $("div.slider-range").slider({ range: true, create: function(event, ui) { var max = $("#"+$(this).attr('input')).attr('max'); var min = $("#"+$(this).attr('input')).attr('min'); $(this).slider( "option", "min", min ); $(this).slider( "option", "max", max ); }, values : [0, 10000000000], slide: function( event, ui ) { var name = $(this).attr('input'); $( "#"+name ).val( ui.values[ 0 ] + " , " + ui.values[ 1 ] ); }, step: 10, stop: function( event, ui ) { var name = $(this).attr('input'); set(name, ui.values[ 0 ] + "," + ui.values[ 1 ]); }, }); $("input.datepicker").datepicker({ dateFormat: 'yymmdd' } ); $( "#accordion" ).accordion({ autoHeight: false, navigation: true, icons: { header: "ui-icon-circle-arrow-e", headerSelected: "ui-icon-circle-arrow-s" } }); $( "#toggle" ).button().toggle(function() { $( "#accordion" ).accordion( "option", "icons", false ); }, function() { $( "#accordion" ).accordion( "option", "icons", icons ); }); $( ".column" ).sortable({ connectWith: ".column" }); $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "") .end() .find( ".portlet-content" ); $( ".portlet-header .ui-icon" ).click(function() { $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle(); }); $( ".column" ).disableSelection(); $('#tabs').delegate('select.criteres', 'change', function(e){ var valeur = $(this, ':selected').val(); e.stopPropagation(); if(valeur == 'tous') { $('#'+$(this).attr('name')).css('background-color', ''); } else { $('#'+$(this).attr('name')).css('background-color', '#CCF8D2'); } set($(this).attr('name'), $(this, ':selected').val()); }); $('#tabs').delegate('input[type=checkbox].criteres', 'click', function(e){ e.stopPropagation(); set($(this).attr('name'), $(this).val()); }); $('#tabs').delegate('input[type=radio].criteres', 'click', function(e){ e.stopPropagation(); set($(this).attr('name'), $(this).val()); }); $('#tabs').delegate('input[type=text].criteres', 'blur', function(e){ e.stopPropagation(); set($(this).attr('name'), $(this).val()); }); $('#tabs').delegate('a.interval', 'click', function(e){ e.preventDefault(); var key = $(this).attr('id'); var values = $('input[name='+key+'1]').val() + ',' + $('input[name='+key+'2]').val(); set(key, values); return false; }); }); function set(key, value) { $('#comptage').css('display', 'none'); $('#attente').css('display', 'block'); $.post('/comptage', { cle:key, valeur:value}, function(data, status) { var html = 'Nombre sélectionnées : ' + data.count + ' (dont '+ data.insee +' unité(s) insee)'; $('#attente').css('display', 'none'); $('#comptage').html(html).css('display','block'); }, 'json') .error(function(){ alert('error'); }); }