mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-23 10:29:07 +01:00
6f52489a59
pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
226 lines
6.2 KiB
JavaScript
226 lines
6.2 KiB
JavaScript
var LSform = new Class({
|
|
initialize: function(){
|
|
this._modules=[];
|
|
this._elements=[];
|
|
|
|
if ($type($('LSform_idform'))) {
|
|
this.objecttype = $('LSform_objecttype').value;
|
|
this.objectdn = $('LSform_objectdn').value;
|
|
this.idform = $('LSform_idform').value;
|
|
}
|
|
|
|
this.initializeLSform();
|
|
this.initializeLSformLayout();
|
|
},
|
|
|
|
initializeLSform: function(el) {
|
|
if (this.idform) {
|
|
if (typeof(el) == 'undefined') {
|
|
el = document;
|
|
}
|
|
el.getElements('ul.LSform').each(function(ul) {
|
|
this._elements[ul.id] = new LSformElement(this,ul.id,ul);
|
|
}, this);
|
|
}
|
|
|
|
LSforms = $$('form.LSform');
|
|
if ($type(LSforms[0])) {
|
|
this.LSform = LSforms[0];
|
|
this.LSformAjaxInput = new Element('input');
|
|
this.LSformAjaxInput.setProperties ({
|
|
type: 'hidden',
|
|
name: 'ajax',
|
|
value: '1'
|
|
});
|
|
this.LSformAjaxInput.injectInside(this.LSform);
|
|
|
|
this.LSform.addEvent('submit',this.ajaxSubmit.bindWithEvent(this));
|
|
}
|
|
},
|
|
|
|
initializeLSformLayout: function(el) {
|
|
$$('.LSform_layout').each(function(el) {
|
|
el.addClass('LSform_layout_active');
|
|
},this);
|
|
|
|
var LIs = $$('li.LSform_layout');
|
|
LIs.each(function(li) {
|
|
li.getFirst('a').addEvent('click',this.onTabBtnClick.bindWithEvent(this,li));
|
|
},this);
|
|
|
|
if (LIs.length != 0) {
|
|
this._currentTab = 'default_value';
|
|
document.getElement('li.LSform_layout').getFirst('a').fireEvent('click');
|
|
}
|
|
},
|
|
|
|
getLayoutBtn: function(div) {
|
|
var getName = new RegExp('LSform_layout_div_(.*)');
|
|
var name = getName.exec(div.id);
|
|
if (!name) {
|
|
return;
|
|
}
|
|
return $('LSform_layout_btn_'+name[1]);
|
|
},
|
|
|
|
getLayout: function(btn) {
|
|
var getName = new RegExp('LSform_layout_btn_(.*)');
|
|
var name = getName.exec(btn.id);
|
|
if (!name) {
|
|
return;
|
|
}
|
|
return $('LSform_layout_div_'+name[1]);
|
|
},
|
|
|
|
onTabBtnClick: function(event,li) {
|
|
if ($type(event)) {
|
|
event = new Event(event);
|
|
event.stop();
|
|
if ($type(event.target.blur)) {
|
|
event.target.blur();
|
|
}
|
|
}
|
|
|
|
if (this._currentTab!=li) {
|
|
if (this._currentTab!='default_value') {
|
|
this._currentTab.removeClass('LSform_layout_current');
|
|
var oldDiv = this.getLayout(this._currentTab);
|
|
if ($type(oldDiv)) {
|
|
oldDiv.removeClass('LSform_layout_current');
|
|
}
|
|
}
|
|
|
|
this._currentTab = li;
|
|
li.addClass('LSform_layout_current');
|
|
var div = this.getLayout(li);
|
|
if ($type(div)) {
|
|
div.addClass('LSform_layout_current');
|
|
|
|
// Focus
|
|
var ul = div.getElement('ul.LSform');
|
|
if ($type(ul)) {
|
|
var el = ul.getElement('input');
|
|
if (!$type(el)) {
|
|
el = ul.getElement('textarea');
|
|
}
|
|
if (!$type(el)) {
|
|
el = ul.getElement('select');
|
|
}
|
|
if ($type(el)) {
|
|
if(el.type!='hidden') {
|
|
el.focus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
addModule: function(name,obj) {
|
|
this._modules[name]=obj;
|
|
},
|
|
|
|
initializeModule: function(fieldType,li) {
|
|
if ($type(this._modules[fieldType])) {
|
|
try {
|
|
this._modules[fieldType].reinitialize(li);
|
|
}
|
|
catch(e) {
|
|
LSdebug('Pas de reinitialise pour ' + fieldType);
|
|
}
|
|
}
|
|
},
|
|
|
|
getValue: function(fieldName) {
|
|
var retVal = Array();
|
|
var ul = $(fieldName);
|
|
if ($type(ul)) {
|
|
var elements = ul.getElements('input');
|
|
elements.combine(ul.getElements('textarea'));
|
|
elements.combine(ul.getElements('select'));
|
|
|
|
var getName = new RegExp('([a-zA-Z0-9]*)(\[.*\])?');
|
|
elements.each(function(el){
|
|
var name = getName.exec(el.name);
|
|
LSdebug(name);
|
|
if (name) {
|
|
if (name[1]==fieldName) {
|
|
if ($type(el.value)) {
|
|
if (el.value!="") {
|
|
retVal.include(el.value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},this);
|
|
}
|
|
return retVal;
|
|
},
|
|
|
|
ajaxSubmit: function(event) {
|
|
event = new Event(event);
|
|
event.stop();
|
|
|
|
this.resetErrors();
|
|
|
|
this.LSform.set('send',{
|
|
data: this.LSform,
|
|
onSuccess: this.onAjaxSubmitComplete.bind(this),
|
|
url: this.LSform.get('action'),
|
|
imgload: varLSdefault.loadingImgDisplay($('LSform_title'),'inside')
|
|
});
|
|
this.LSform.send();
|
|
},
|
|
|
|
onAjaxSubmitComplete: function(responseText, responseXML) {
|
|
var data = JSON.decode(responseText);
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
if ($type(data.LSformErrors) == 'object') {
|
|
data.LSformErrors = new Hash(data.LSformErrors);
|
|
data.LSformErrors.each(this.addError,this);
|
|
}
|
|
}
|
|
},
|
|
|
|
resetErrors: function() {
|
|
$$('dd.LSform-errors').each(function(dd) {
|
|
dd.destroy();
|
|
});
|
|
$$('dt.LSform-errors').each(function(dt) {
|
|
dt.removeClass('LSform-errors');
|
|
});
|
|
$$('li.LSform_layout_errors').each(function(li) {
|
|
li.removeClass('LSform_layout_errors');
|
|
});
|
|
|
|
},
|
|
|
|
addError: function(errors,name) {
|
|
var ul = $(name);
|
|
if ($type(ul)) {
|
|
errors = new Array(errors);
|
|
errors.each(function(txt){
|
|
var dd = new Element('dd');
|
|
dd.addClass('LSform');
|
|
dd.addClass('LSform-errors');
|
|
dd.set('html',txt);
|
|
dd.injectAfter(this.getParent());
|
|
},ul);
|
|
|
|
var dt = ul.getParent().getPrevious('dt');
|
|
dt.addClass('LSform-errors');
|
|
|
|
var layout = ul.getParent('div.LSform_layout_active');
|
|
if ($type(layout)) {
|
|
var li = this.getLayoutBtn(layout);
|
|
if($type(li)) {
|
|
li.addClass('LSform_layout_errors');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
|
varLSform = new LSform();
|
|
});
|