ldapsaisie/trunk/includes/js/LSselect.js
Benjamin Renard 8d8ede930c - Passage à Mootools v1.2templates/LSrelations.tpl
-> config.inc.php : 
		- Deux fichiers js à include au lieu d'un seul
		- Suppression du Debugger (Debugger.js incompatible)
		- LSformElement_image : refonte de l'affichage
- Templates : 
	- LSview-action : Passage aux balises ul/li plutôt que p/a
	- select.tpl : correction d'un bug concernant la sélection du subDn actif
- Création de LSconfirmBox : module de confirmation
- JS :
	-> LSform.js : Modularisation du code :
		- LSformElement_select_object.js
		- LSformElement_image.js
		- LSformElement_password.js
- CSS : 
	-> Modularisation :
		- LSselect.css
		- LSrelation.css
- LSrelation : 
	-> Refonte du mécanisme JS
	-> Modification de l'affichage
	-> Ajout d'une confirmation à la suppresion (LSconfirmBox)
- LSsmoothbox : Refonte profonde
- view.php : 
 - Correction d'un bug : la colone action était vide lors de la mise en cache
   par LSselect.
- LSldapObject :
	- getDisplayValue() : ajout d'une possibilité de l'affichage du subDn en plus
	du nom
- LSsession : ajout d'un méthode haveSubDn()
- JS : 
 - Modularisation de la verification d'une requete Ajax
 	-> LSdefault : nouvelles méthodes :
		-> checkAjaxReturn() : Pour les retours JSON
		-> ajaxDisplayDebugAndError() : Pour les retours HTML (Type LSselect)
2008-07-05 20:28:49 +00:00

137 lines
4.7 KiB
JavaScript

var LSselect = new Class({
initialize: function(){
this.main_page = $('LSobject-select-main-div').getParent();
this.content = $('content');
this.LSselect_search_form = $('LSselect_search_form');
var input = new Element('input');
input.setProperty('name','ajax');
input.setProperty('type','hidden');
input.injectInside(this.LSselect_search_form);
this.tempInput = [];
this.LSselect_search_form.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this));
this.LSselect_topDn = $('LSselect_topDn');
if (this.LSselect_topDn) {
this.LSselect_topDn.addEvent('change',this.onChangeLSselect_topDn.bind(this));
}
this.LSselect_refresh_btn = $('LSselect_refresh_btn');
this.LSselect_refresh_btn.addEvent('click',this.onClickLSselect_refresh_btn.bind(this));
this.initializeContent();
},
initializeContent: function() {
$$('input.LSobject-select').each(function(el) {
el.addEvent('click',this.oncheckboxChange.bind(this,el));
}, this);
$$('a.LSobject-list-page').each(function(el) {
el.addEvent('click',this.onChangePageClick.bindWithEvent(this,el));
}, this);
$$('.sortBy_displayValue').each(function(el) {
el.addEvent('click',this.sortBy.bind(this,'displayValue'));
}, this);
$$('.sortBy_subDn').each(function(el) {
el.addEvent('click',this.sortBy.bind(this,'subDn'));
}, this);
},
oncheckboxChange: function(checkbox){
if (checkbox.checked) {
var data = {
template: 'LSselect',
action: 'addLSselectobject-item',
objectdn: checkbox.value,
objecttype: $('LSselect-object').getProperties('caption').caption
};
}
else {
var data = {
template: 'LSselect',
action: 'dropLSselectobject-item',
objectdn: checkbox.value,
objecttype: $('LSselect-object').getProperties('caption').caption
};
}
data.imgload=varLSdefault.loadingImgDisplay(checkbox.getParent().getNext(),'inside');
new Request({url: 'index_ajax.php', data: data, onSuccess: this.oncheckboxChangeComplete.bind(this)}).send();
},
oncheckboxChangeComplete: function(responseText, responseXML) {
var data = JSON.decode(responseText);
varLSdefault.loadingImgHide(data.imgload);
},
onChangePageClick: function(event, a) {
new Event(event).stop();
var data = {
ajax: true
};
this.searchImgload = varLSdefault.loadingImgDisplay($('title'),'inside');
new Request({url: a.href, data: data, onSuccess: this.onChangePageClickComplete.bind(this)}).send();
},
onChangePageClickComplete: function(responseText, responseXML) {
varLSdefault.loadingImgHide(this.searchImgload);
this.content.set('html',responseText);
this.initializeContent();
},
onChangeLSselect_topDn: function() {
this.submitSearchForm();
},
onSubmitSearchForm: function(event) {
new Event(event).stop();
this.submitSearchForm();
},
submitSearchForm: function() {
this.searchImgload = varLSdefault.loadingImgDisplay($('title'),'inside');
this.LSselect_search_form.set('send',{
data: this.LSselect_search_form,
evalScripts: true,
onSuccess: this.onSubmitSearchFormComplete.bind(this),
url: this.LSselect_search_form.get('action')
});
this.LSselect_search_form.send();
},
onSubmitSearchFormComplete: function(responseText, responseXML) {
varLSdefault.loadingImgHide(this.searchImgload);
this.content.set('html',responseText);
varLSdefault.ajaxDisplayDebugAndError();
this.tempInput.each(function(el) {
el.destroy();
},this);
this.initializeContent();
},
onClickLSselect_refresh_btn: function() {
this.tempInput['refresh'] = new Element('input');
this.tempInput['refresh'].setProperty('name','refresh');
this.tempInput['refresh'].setProperty('type','hidden');
this.tempInput['refresh'].setProperty('value',1);
this.tempInput['refresh'].injectInside(this.LSselect_search_form);
this.submitSearchForm();
},
sortBy: function(value) {
this.tempInput['sortBy'] = new Element('input');
this.tempInput['sortBy'].setProperty('name','orderby');
this.tempInput['sortBy'].setProperty('type','hidden');
this.tempInput['sortBy'].setProperty('value',value);
this.tempInput['sortBy'].injectInside(this.LSselect_search_form);
this.submitSearchForm();
}
});