2012-01-02 19:14:04 +00:00

160 lines
4.4 KiB
JavaScript

$(document).ready(function(){
$( "#tabs" ).tabs({
cookie: { expires: 1 },
});
$(".tooltip").each(function(){
var title = $(this).attr('title');
var width = $(this).attr('wdth');
$(this).attr('title', '');
$(this).qtip({
solo:true,
content: title,
style: {
width: width,
classes: "ui-tooltip-dark"
},
position: {
at: $('#at').val(),
my: $('#my').val(),
viewport: $(window),
adjust: {
method: $('#adjust_method').val(),
x: parseInt($('#adjust_x').val(), 10) || 0,
y: parseInt($('#adjust_y').val(), 10) || 0
}
}
});
});
slider = $( ".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, 100000000000000],
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 ]);
},
});
var dates = $( ".from, .to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 2,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "maxDate" : "minDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
$( ".datepicker" ).datepicker( "option", "dateFormat", "yymmdd" );
$('.printCritere').click(function(){
var name = $(this).attr('name');
var block = $('.'+$(this).attr('name')).css('display');
if(block == 'block') {
$(this).css('background-image', 'url(/themes/default/images/ajouter.png)');
$('.'+name).hide('slide');
}
else {
$(this).css('background-image', 'url(/themes/default/images/moins.png)');
$('.'+name).show('slide');
}
});
$( "#accordion" ).accordion({
autoHeight: false,
navigation: true
});
$( "#sortable" ).sortable({
placeholder: "ui-state-highlight"
});
$( "#sortable" ).disableSelection();
$( ".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( "<span class='ui-icon ui-icon-minusthick'></span>")
.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 : <span class="valeur">' +
data.count + '</span> (dont <span class="valeur">'+
data.insee +'</span> unité(s) insee)';
$('#attente').css('display', 'none');
$('#comptage').html(html).css('display','block');
}, 'json')
.error(function(){ alert('error'); });
}