2012-09-26 09:08:11 +00:00

114 lines
2.8 KiB
JavaScript

$(document).ready(function(){
$('input[type=radio][name=method]').click(function()
{
var value = $('input[type=radio][name=method]:checked').val();
var list = ['M','C'];
for (type in list) {
if(list[type]!=value) {
$('#kbis'+list[type]).css('display', 'none');
}
}
if(value=='M' || value=='C') {
if($('#kbis'+value).css('display')=='none') {
$('#kbis'+value).css('display', 'inline');
}
} else {
window.location.href = value;
}
});
$('input.type[type=checkbox]').click(function()
{
var nbCheck = 0;
$('input.type[type=checkbox]:checked').each(function()
{
nbCheck++;
});
if( nbCheck>0 )
{
$('#privilegesM').css('display', 'block');
}else{
$('#privilegesM').css('display', 'none');
}
});
$('form[name=kbis]').submit(function(){
var method = $('input[name=method]:checked').val();
if(method=='C')
{
return true;
}else{
var eMail = jQuery('input[name=email]', this).val();
if(!checkEmail(eMail)){
alert('Veuillez saisir une adresse email.');
return false;
} else { return true; }
}
});
$('form[name=privileges]').submit(function(){
var eMail = jQuery('input[name=email]', this).val();
if(!checkEmail(eMail)){
alert('Veuillez saisir une adresse email.');
return false;
} else { return true; }
});
$('.dialogcmd').on('click', function(){
var href = $(this).attr('href');
if (href!='#') {
var title = $(this).attr('title');
var dialogOpts = {
bgiframe: true,
title: title,
width: 550,
height: 300,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Valider: function() {
if ($('form[name=commande]').length) {
$('#dialogcmd').dialog({ buttons: [ { text: "Fermer", click: function() { $(this).dialog("close"); } } ] });
$.post($('form[name=commande]').attr('action'),
$('form[name=commande]').serialize(), function(data){
$('#dialogcmd > #output').html(data);
});
} else {
$(this).dialog('close');
}
},
Annuler: function() { $(this).dialog('close'); }
},
close: function() { $('#dialogcmd').remove(); }
};
$('<div id="dialogcmd"></div>').dialog(dialogOpts);
return false;
}
});
$('span.fichier > a').on('click', function(e){
e.preventDefault();
var url = $(this).attr('href');
if (url!='#'){
var objet = $(this).parent('span');
objet.html('<br/>Chargement du fichier...');
$.post(url, function (data, textStatus){
if( data=='' || data=='FALSE' || textStatus=='timeout' )
{
data = '<br/>Le chargement du fichier a échoué';
}
objet.replaceWith(data);
}).error(function(){
objet.replaceWith('Unknown error');
});
}
});
});