LSform : Added warning box

This commit is contained in:
Benjamin Renard 2010-11-17 15:15:56 +01:00
parent a338b0af75
commit f864ce49d7
3 changed files with 40 additions and 0 deletions

View file

@ -138,3 +138,12 @@ dt.LSform-errors {
img.LSform-add-field-btn, img.LSform-remove-field-btn {
cursor: pointer;
}
/* -- LSformWarnBox -- */
div.LSformWarnBox {
top: 100px!important;
left: 25%!important;
background-color: #f59a67!important;
border: 1px solid #f00!important;
color: #fff!important;
}

View file

@ -45,6 +45,8 @@ class LSform {
var $maxFileSize = NULL;
var $warnings = array();
/**
* Constructeur
*
@ -135,6 +137,10 @@ class LSform {
'ajaxSubmit' => ((isset($this -> config['LSform']['ajaxSubmit']))?$this -> config['LSform']['ajaxSubmit']:1)
);
if (!empty($this -> warnings)) {
$JSconfig['warnings']=$this -> warnings;
}
LSsession :: addJSconfigParam('LSform_'.$this -> idForm,$JSconfig);
if($this -> can_validate) {
@ -549,6 +555,16 @@ class LSform {
$this -> maxFileSize = $size;
}
/**
* Ajoute un avertissement au sujet du formulaire
*
* @param[in] $txt string Le texte de l'avertissement
*
* @retval void
**/
function addWarning($txt) {
$this -> warnings[]=$txt;
}
/**
* Méthode Ajax permetant de retourner le code HTML d'un élément du formulaire vide

View file

@ -27,6 +27,21 @@ var LSform = new Class({
this.params={};
}
this._ajaxSubmit=this.params.ajaxSubmit;
if ($type(this.params.warnings)) {
this.warnBox = new LSinfosBox({
name: 'LSformWarnBox',
fxDuration: 600,
closeBtn: 1,
autoClose: 0
});
this.warnTxt = '<ul>';
this.params.warnings.each(function(w) {
this.warnTxt +='<li>'+w+'</li>';
},this);
this.warnTxt += '</ul>';
this.warnBox.display(this.warnTxt);
}
LSdebug(this.params);
}