Issue #0001634: separer le script du view

This commit is contained in:
Aram HARUTYUNYAN 2013-06-10 08:42:13 +00:00
parent e5b9659860
commit 2166d0ab08
2 changed files with 47 additions and 53 deletions

View File

@ -26,12 +26,6 @@ $('a.dialog').on('click', function(e){
<?php } else {?>
<style>
label {
text-align:left;
margin-right:0px;
width:13em;
}
select, input {
width:5em;
}
@ -123,52 +117,6 @@ foreach($select as $item => $val) {
<div class="loading"><center><img style="padding-top:25%" src="/themes/default/images/giant/19-1.gif" /></center></div>
<script>
function validate() {
var allvals = true;
$("[required]").each(function() {
if(!$(this).val()) {
allvals = false;
$(this).addClass('brsr');
}
else { $(this).removeClass('brsr'); }
});
if ($('[name=encours]').val()<0 || $('[name=encours]').val()>500 || !$('[name=encours]').val()){
allvals = false;
$('[name=encours]').addClass('brsr');
}
else { $('[name=encours]').removeClass('brsr'); }
return allvals;
}
$(document).ready(function(){
validate();
});
$('[required]').blur(function(){
validate();
});
$('#dialog').dialog({ buttons: [
{ text: "Valider", click: function() {
var values = $(this).find('form').serialize();
if (validate()) {
if ($('.loading').css('display')=='none') {
$('.loading').css('display', 'block');
$('.ui-dialog-content').css('overflow','hidden');
$(".ui-dialog-buttonpane button:contains('Valider')").button("disable");
}
else { $('.loading').css('display', 'none');}
$.post('<?=$this->url(array('controller'=>'saisie','action'=>'scorecutoff'),null,true)?>', values, function(data) {
$('#dialog').html(data);
});
}
}},
{ text: "Fermer", click: function() {
if($(".message p").text()) { location.reload(); }
$(this).dialog('close');
}
}
] });
</script>
<script type="text/javascript" src="/themes/default/scripts/scorecutoff.js" />
<?php }?>

View File

@ -0,0 +1,46 @@
function validate() {
var allvals = true;
$("[required]").each(function() {
if(!$(this).val()) {
allvals = false;
$(this).addClass('brsr');
}
else { $(this).removeClass('brsr'); }
});
if ($('[name=encours]').val()<0 || $('[name=encours]').val()>500 || !$('[name=encours]').val()){
allvals = false;
$('[name=encours]').addClass('brsr');
}
else { $('[name=encours]').removeClass('brsr'); }
return allvals;
}
$(document).ready(function(){
validate();
});
$('[required]').blur(function(){
validate();
});
$('#dialog').dialog({ buttons: [
{ text: "Valider", click: function() {
var values = $(this).find('form').serialize();
if (validate()) {
if ($('.loading').css('display')=='none') {
$('.loading').css('display', 'block');
$('.ui-dialog-content').css('overflow','hidden');
$(".ui-dialog-buttonpane button:contains('Valider')").button("disable");
}
else { $('.loading').css('display', 'none');}
$.post('/saisie/scorecutoff', values, function(data) {
$('#dialog').html(data);
});
}
}},
{ text: "Fermer", click: function() {
if($(".message p").text()) { location.reload(); }
$(this).dialog('close');
}
}
] });