LSselect : code cleaning

This commit is contained in:
Emmanuel Saracco 2022-06-16 12:59:14 +02:00
parent 3eba1e24d6
commit 855bcc8564

View file

@ -7,11 +7,7 @@ var LSselect = new Class({
this.multiple = this.LSselect_search_form.getElement('input[name=multiple]').value;
// Add ajax hidden input
var input = new Element('input');
input.setProperty('name','ajax');
input.setProperty('type','hidden');
input.setProperty('value',1);
input.injectInside(this.LSselect_search_form);
this.injectHiddenInput('ajax', 1);
this.tempInput = [];
this.lastCheckboxChanged = null;
@ -35,11 +31,19 @@ var LSselect = new Class({
}
},
injectHiddenInput: function(name, value) {
var input = new Element('input');
input.setProperty('type', 'hidden');
input.setProperty('name', name);
input.setProperty('value', value);
input.injectInside(this.LSselect_search_form);
return input;
},
initializeTabs: function(ul) {
this.tabs_ul.getElements('li').addEvent('click', function (event) {
console.log(event.target);
this.LSselect_search_form.getElement('input[name=LSobject]').value = event.target.getProperty('data-object-type');
this.tabs_ul.getElements('li.current').each(function(li){ console.log(li); li.removeClass('current'); });
this.tabs_ul.getElements('li.current').each(function(li){ li.removeClass('current'); });
event.target.addClass('current');
this.submitSearchForm();
}.bind(this));
@ -112,7 +116,7 @@ var LSselect = new Class({
},
onChangePageClick: function(event, a) {
new Event(event).stop();
event.preventDefault();
var data = {
ajax: true
};
@ -131,7 +135,7 @@ var LSselect = new Class({
},
onSubmitSearchForm: function(event) {
new Event(event).stop();
event.preventDefault();
this.submitSearchForm();
},
@ -162,20 +166,12 @@ var LSselect = new Class({
},
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.tempInput['refresh'] = this.injectHiddenInput('refresh', 1);
this.submitSearchForm();
},
sortBy: function(value) {
this.tempInput['sortBy'] = new Element('input');
this.tempInput['sortBy'].setProperty('name','sortBy');
this.tempInput['sortBy'].setProperty('type','hidden');
this.tempInput['sortBy'].setProperty('value',value);
this.tempInput['sortBy'].injectInside(this.LSselect_search_form);
this.tempInput['sortBy'] = this.injectHiddenInput('sortBy', value);
this.submitSearchForm();
},