2008-09-28 13:05:02 +02:00
|
|
|
var LSformElement_select_object_field = new Class({
|
|
|
|
initialize: function(ul){
|
|
|
|
this.ul=ul;
|
|
|
|
this.dd=ul.getParent();
|
2008-10-16 17:35:20 +02:00
|
|
|
this.name = ul.id;
|
|
|
|
this.params = varLSdefault.LSjsConfig[this.name];
|
2008-09-28 13:05:02 +02:00
|
|
|
if ($type(this.params)) {
|
2008-10-16 17:35:20 +02:00
|
|
|
this.initializeLSformElement_select_object();
|
2008-09-28 13:05:02 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initializeLSformElement_select_object: function() {
|
2009-02-17 14:46:41 +01:00
|
|
|
// Class of UL
|
2008-09-28 13:05:02 +02:00
|
|
|
if (this.params.multiple) {
|
|
|
|
this.ul.addClass('LSformElement_select_object_edit');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete btns
|
|
|
|
this.ul.getElements('a.LSformElement_select_object').each(function(a){
|
2015-01-21 16:35:23 +01:00
|
|
|
this.addOrderedBtns(a);
|
2008-11-05 15:57:19 +01:00
|
|
|
this.addDeleteBtn(a);
|
2008-09-28 13:05:02 +02:00
|
|
|
},this);
|
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
|
|
|
|
|
2008-09-28 13:05:02 +02:00
|
|
|
if (this.params.multiple) {
|
|
|
|
// li
|
|
|
|
this.ul.getElements('li').each(function(li){
|
|
|
|
li.addClass('LSformElement_select_object');
|
|
|
|
},this);
|
|
|
|
|
|
|
|
// Head
|
|
|
|
this.li = new Element('li');
|
|
|
|
this.li.addClass('LSformElement_select_object_addBtn');
|
|
|
|
|
|
|
|
this.addBtn = new Element('span');
|
|
|
|
this.addBtn.addClass('btn');
|
|
|
|
this.addBtn.set('html',this.params.addBtn);
|
2008-11-06 11:14:14 +01:00
|
|
|
this.addBtn.addEvent('click',this.onAddBtnClick.bindWithEvent(this));
|
2008-09-28 13:05:02 +02:00
|
|
|
this.addBtn.injectInside(this.li);
|
2008-11-10 04:23:29 +01:00
|
|
|
varLSdefault.addHelpInfo(this.addBtn,'LSformElement_select_object','add');
|
2008-09-28 13:05:02 +02:00
|
|
|
|
|
|
|
this.li.inject(this.ul,'top');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.addSingleAddBtn(this.ul.getFirst());
|
|
|
|
}
|
2008-11-05 15:57:19 +01:00
|
|
|
|
|
|
|
this._searchAddOpen = 0;
|
|
|
|
document.addEvent('click',this.closeIfOpenSearchAdd.bind(this));
|
2008-11-06 12:23:21 +01:00
|
|
|
this.addSearchAddBtn();
|
2008-11-05 15:57:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
addDeleteBtn: function(a) {
|
|
|
|
var btn = new Element('img');
|
|
|
|
btn.addClass('btn');
|
|
|
|
btn.setProperties({
|
2013-06-19 02:17:39 +02:00
|
|
|
src: varLSdefault.imagePath('delete'),
|
2008-11-05 15:57:19 +01:00
|
|
|
alt: this.params.deleteBtns
|
|
|
|
});
|
2008-11-06 12:23:21 +01:00
|
|
|
btn.addEvent('click',this.onDeleteBtnClick.bind(this,btn));
|
2008-11-05 15:57:19 +01:00
|
|
|
btn.injectAfter(a);
|
2008-11-10 04:23:29 +01:00
|
|
|
varLSdefault.addHelpInfo(btn,'LSformElement_select_object','delete');
|
2008-09-28 13:05:02 +02:00
|
|
|
},
|
|
|
|
|
2015-01-21 16:35:23 +01:00
|
|
|
addOrderedBtns: function(a) {
|
|
|
|
if (!this.params.ordered) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
var btn_down = new Element('img');
|
|
|
|
btn_down.addClass('btn');
|
|
|
|
btn_down.setProperties({
|
|
|
|
src: varLSdefault.imagePath('down'),
|
|
|
|
alt: this.params.down_label
|
|
|
|
});
|
|
|
|
btn_down.addEvent('click',this.onDownBtnClick.bind(this,btn_down));
|
|
|
|
btn_down.injectAfter(a);
|
|
|
|
|
|
|
|
var btn_up = new Element('img');
|
|
|
|
btn_up.addClass('btn');
|
|
|
|
btn_up.setProperties({
|
|
|
|
src: varLSdefault.imagePath('up'),
|
|
|
|
alt: this.params.up_label
|
|
|
|
});
|
|
|
|
btn_up.addEvent('click',this.onUpBtnClick.bind(this,btn_up));
|
|
|
|
btn_up.injectAfter(a);
|
|
|
|
},
|
|
|
|
|
|
|
|
onUpBtnClick: function(btn) {
|
|
|
|
var li = btn.getParent();
|
|
|
|
var prev = li.getPrevious('li');
|
|
|
|
if ($type(prev) && !prev.hasClass('LSformElement_select_object_addBtn')) {
|
|
|
|
li.inject(prev,'before');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDownBtnClick: function(btn) {
|
|
|
|
var li = btn.getParent();
|
|
|
|
var next = li.getNext('li');
|
|
|
|
if ($type(next)) {
|
|
|
|
li.inject(next,'after');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-09-28 13:05:02 +02:00
|
|
|
addSingleAddBtn: function(insideEl) {
|
|
|
|
this.addBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.addBtn.setProperty('src',varLSdefault.imagePath('modify'));
|
2008-09-28 13:05:02 +02:00
|
|
|
this.addBtn.addClass('btn');
|
2008-11-06 11:14:14 +01:00
|
|
|
this.addBtn.addEvent('click',this.onAddBtnClick.bindWithEvent(this));
|
2008-09-28 13:05:02 +02:00
|
|
|
this.addBtn.injectInside(insideEl);
|
2008-11-10 04:23:29 +01:00
|
|
|
varLSdefault.addHelpInfo(this.addBtn,'LSformElement_select_object','add');
|
2008-09-28 13:05:02 +02:00
|
|
|
},
|
|
|
|
|
2008-11-06 12:23:21 +01:00
|
|
|
addSearchAddBtn: function() {
|
|
|
|
this.searchAddBtn = new Element('img');
|
2013-06-19 02:17:39 +02:00
|
|
|
this.searchAddBtn.setProperty('src',varLSdefault.imagePath('add'));
|
2008-11-06 12:23:21 +01:00
|
|
|
this.searchAddBtn.addClass('btn');
|
|
|
|
this.searchAddBtn.addEvent('click',this.onSearchAddBtnClick.bindWithEvent(this));
|
|
|
|
this.searchAddBtn.injectAfter(this.addBtn);
|
2008-11-10 04:23:29 +01:00
|
|
|
varLSdefault.addHelpInfo(this.searchAddBtn,'LSformElement_select_object','searchAdd');
|
2008-11-06 12:23:21 +01:00
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
onAddBtnClick: function(event) {
|
2008-09-28 13:05:02 +02:00
|
|
|
new Event(event).stop();
|
|
|
|
|
|
|
|
values = new Array();
|
2008-11-05 15:57:19 +01:00
|
|
|
var inputname=this.name+'[]';
|
2008-09-28 13:05:02 +02:00
|
|
|
this.ul.getElements('input.LSformElement_select_object').each(function(el) {
|
2008-11-05 15:57:19 +01:00
|
|
|
if (el.name==inputname) {
|
|
|
|
values.push(el.getProperty('value'));
|
|
|
|
}
|
2008-09-28 13:05:02 +02:00
|
|
|
}, this);
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
template: 'LSselect',
|
|
|
|
action: 'refreshSession',
|
|
|
|
objecttype: this.params['object_type'],
|
|
|
|
values: JSON.encode(values)
|
|
|
|
};
|
|
|
|
|
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.addBtn,'inside');
|
2008-11-06 11:14:14 +01:00
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAddBtnClickComplete.bind(this)}).send();
|
2008-09-28 13:05:02 +02:00
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
onAddBtnClickComplete: function(responseText, responseXML) {
|
2008-09-28 13:05:02 +02:00
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
|
|
varLSsmoothbox.asNew();
|
|
|
|
varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this));
|
|
|
|
varLSsmoothbox.displayValidBtn();
|
2013-11-15 18:59:50 +01:00
|
|
|
varLSsmoothbox.openURL('select.php?LSobject='+this.params['object_type']+((this.params['multiple'])?'&multiple=1':'')+((this.params['filter64'])?'&filter64='+this.params['filter64']:''),{width: 635});
|
2008-09-28 13:05:02 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onLSsmoothboxValid: function() {
|
|
|
|
var data = {
|
2009-02-20 15:05:22 +01:00
|
|
|
template: 'LSformElement_select_object',
|
|
|
|
action: 'refresh',
|
2008-10-16 17:35:20 +02:00
|
|
|
attribute: this.name,
|
2008-11-03 20:25:22 +01:00
|
|
|
objecttype: varLSform.objecttype,
|
|
|
|
objectdn: varLSform.objectdn,
|
|
|
|
idform: varLSform.idform
|
2008-09-28 13:05:02 +02:00
|
|
|
};
|
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.addBtn);
|
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send();
|
|
|
|
},
|
|
|
|
|
|
|
|
onLSsmoothboxValidComplete: function(responseText, responseXML) {
|
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
2008-11-06 11:14:14 +01:00
|
|
|
this.clearUl();
|
|
|
|
if ($type(data.objects)) {
|
|
|
|
var objs = new Hash(data.objects);
|
|
|
|
objs.each(this.addLi,this);
|
|
|
|
}
|
|
|
|
this.addNoValueLabelIfEmpty();
|
2008-09-28 13:05:02 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
clearUl: function() {
|
2008-11-06 13:01:55 +01:00
|
|
|
if (this.params.multiple) {
|
|
|
|
this.ul.getElements('li.LSformElement_select_object').each(function(li){
|
|
|
|
li.destroy();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var a = this.ul.getElement('a.LSformElement_select_object');
|
|
|
|
if ($type(a)) {
|
|
|
|
a.set('html',this.params.noValueLabel);
|
|
|
|
a.removeClass('LSformElement_select_object_deleted');
|
|
|
|
var input = this.ul.getElement('input.LSformElement_select_object');
|
|
|
|
input.value = "";
|
|
|
|
}
|
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
},
|
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
clearUlIfNoValue: function() {
|
|
|
|
if (!$type(this.ul.getElement('a.LSformElement_select_object'))) {
|
2008-11-06 11:14:14 +01:00
|
|
|
this.clearUl();
|
2008-11-05 15:57:19 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
addLi: function(name,dn) {
|
2008-11-06 13:01:55 +01:00
|
|
|
if (this.params.multiple) { // Multiple
|
2008-11-14 16:32:09 +01:00
|
|
|
var current = 0;
|
|
|
|
this.ul.getElements("input[type=hidden]").each(function(input){
|
|
|
|
if ((input.value==dn)&&(input.name != this.name+'[]')) {
|
|
|
|
current=input;
|
|
|
|
}
|
|
|
|
},this);
|
|
|
|
if (current) {
|
|
|
|
this.toggleDeleteLi(current.getParent());
|
|
|
|
return true;
|
|
|
|
}
|
2008-11-05 15:57:19 +01:00
|
|
|
var li = new Element('li');
|
|
|
|
li.addClass('LSformElement_select_object');
|
|
|
|
|
|
|
|
var a = new Element('a');
|
|
|
|
a.addClass('LSformElement_select_object');
|
|
|
|
a.href="view.php?LSobject="+this.params['object_type']+"&dn="+dn;
|
|
|
|
a.set('html',name);
|
|
|
|
a.injectInside(li);
|
|
|
|
|
|
|
|
var input = new Element('input');
|
|
|
|
input.setProperties({
|
|
|
|
type: 'hidden',
|
|
|
|
value: dn,
|
|
|
|
name: this.name+'[]'
|
|
|
|
});
|
|
|
|
input.addClass('LSformElement_select_object');
|
|
|
|
input.injectAfter(a);
|
|
|
|
|
2015-01-21 16:35:23 +01:00
|
|
|
this.addOrderedBtns(a);
|
2008-11-05 15:57:19 +01:00
|
|
|
this.addDeleteBtn(a);
|
|
|
|
|
|
|
|
li.injectInside(this.ul);
|
|
|
|
}
|
2008-11-06 13:01:55 +01:00
|
|
|
else { // Non Multiple
|
2008-11-05 15:57:19 +01:00
|
|
|
var a = this.ul.getElement('a');
|
2008-11-06 13:01:55 +01:00
|
|
|
if ($type(a)) { // Deja initialise
|
2008-11-06 12:23:21 +01:00
|
|
|
a.href="view.php?LSobject="+this.params['object_type']+"&dn="+dn;
|
|
|
|
a.set('html',name);
|
|
|
|
a.removeClass('LSformElement_select_object_deleted');
|
2008-11-05 15:57:19 +01:00
|
|
|
|
2008-11-06 12:23:21 +01:00
|
|
|
var input = this.ul.getElement('input');
|
|
|
|
input.setProperties({
|
|
|
|
value: dn,
|
|
|
|
name: this.name+'[]'
|
|
|
|
});
|
|
|
|
}
|
2008-11-06 13:01:55 +01:00
|
|
|
else { // Non initialise (No Value)
|
2008-11-06 12:23:21 +01:00
|
|
|
this.ul.empty();
|
|
|
|
var li = new Element('li');
|
|
|
|
|
|
|
|
var a = new Element('a');
|
|
|
|
a.addClass('LSformElement_select_object');
|
|
|
|
a.href="view.php?LSobject="+this.params['object_type']+"&dn="+dn;
|
|
|
|
a.set('html',name);
|
|
|
|
a.injectInside(li);
|
|
|
|
|
|
|
|
var input = new Element('input');
|
|
|
|
input.setProperties({
|
|
|
|
type: 'hidden',
|
|
|
|
value: dn,
|
|
|
|
name: this.name+'[]'
|
|
|
|
});
|
|
|
|
input.addClass('LSformElement_select_object');
|
|
|
|
input.injectAfter(a);
|
|
|
|
|
|
|
|
this.addDeleteBtn(a);
|
|
|
|
li.injectInside(this.ul);
|
|
|
|
this.addSingleAddBtn(li);
|
|
|
|
this.addSearchAddBtn();
|
|
|
|
}
|
2008-11-05 15:57:19 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
addNoValueLabelIfEmpty: function() {
|
2008-11-06 12:23:21 +01:00
|
|
|
if (this.params.multiple) {
|
|
|
|
if (!$type(this.ul.getElement('a.LSformElement_select_object'))) {
|
|
|
|
var li = new Element('li');
|
|
|
|
li.addClass('LSformElement_select_object');
|
|
|
|
li.addClass('LSformElement_select_object_noValue');
|
|
|
|
li.set('html',this.params.noValueLabel);
|
|
|
|
li.injectInside(this.ul);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var a = this.ul.getElement('a.LSformElement_select_object');
|
|
|
|
if ($type(a)) {
|
|
|
|
if (a.hasClass("LSformElement_select_object_deleted")) {
|
|
|
|
a.set('html',this.params.noValueLabel);
|
|
|
|
a.removeClass('LSformElement_select_object_deleted');
|
|
|
|
var input = this.ul.getElement('input.LSformElement_select_object');
|
|
|
|
input.value = "";
|
|
|
|
}
|
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-11-06 12:23:21 +01:00
|
|
|
onDeleteBtnClick: function(img) {
|
2008-10-15 11:12:20 +02:00
|
|
|
var li = img.getParent();
|
2008-11-14 16:32:09 +01:00
|
|
|
this.toggleDeleteLi(li);
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleDeleteLi: function(li) {
|
2008-10-15 11:12:20 +02:00
|
|
|
var a = li.getFirst('a');
|
|
|
|
var input = li.getFirst('input');
|
2008-11-06 12:23:21 +01:00
|
|
|
if (input.value!="") {
|
|
|
|
if (a.hasClass('LSformElement_select_object_deleted')) {
|
|
|
|
input.name=this.name+'[]';
|
|
|
|
a.removeClass('LSformElement_select_object_deleted');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
input.name=($random(1,10000));
|
|
|
|
a.addClass('LSformElement_select_object_deleted');
|
|
|
|
}
|
2008-09-28 13:05:02 +02:00
|
|
|
}
|
2008-11-05 15:57:19 +01:00
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
onSearchAddBtnClick: function(event) {
|
2008-11-05 15:57:19 +01:00
|
|
|
if (this._searchAddOpen==0) {
|
|
|
|
this._searchAddOpen = 1;
|
|
|
|
if (!$type(this.searchAddInput)) {
|
2008-11-14 16:32:09 +01:00
|
|
|
this.tr = this.ul.getParent().getParent();
|
2008-11-06 11:14:14 +01:00
|
|
|
|
|
|
|
this.td2 = new Element('td');
|
|
|
|
this.td2.addClass('LSformElement_select_object_searchAdd');
|
|
|
|
this.td2.injectInside(this.tr);
|
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
this.searchAddInput = new Element('input');
|
|
|
|
this.searchAddInput.addClass('LSformElement_select_object_searchAdd');
|
|
|
|
this.searchAddInput.addEvent('keydown',this.onKeyUpSearchAddInput.bindWithEvent(this));
|
2008-11-06 11:14:14 +01:00
|
|
|
this.searchAddInput.injectInside(this.td2);
|
2008-11-05 15:57:19 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.searchAddInput.value = "";
|
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
this._lastSearch = "";
|
2008-11-06 12:23:21 +01:00
|
|
|
this.searchAddInput.setStyle('display','inline');
|
2008-11-05 15:57:19 +01:00
|
|
|
this.searchAddInput.focus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onKeyUpSearchAddInput: function(event) {
|
|
|
|
event = new Event(event);
|
|
|
|
|
|
|
|
if ((event.key=='enter')||(event.key=='tab')) {
|
|
|
|
event.stop();
|
|
|
|
if (this.searchAddInput.value!="") {
|
|
|
|
this.launchSearchAdd();
|
|
|
|
}
|
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
|
|
|
|
if (event.key=='esc') {
|
|
|
|
this.closeSearchAdd();
|
|
|
|
}
|
2008-11-05 15:57:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
launchSearchAdd: function() {
|
|
|
|
if (this._lastSearch!=this.searchAddInput.value) {
|
|
|
|
this._lastSearch=this.searchAddInput.value;
|
|
|
|
var data = {
|
2009-02-20 15:05:22 +01:00
|
|
|
template: 'LSformElement_select_object',
|
|
|
|
action: 'searchAdd',
|
2008-11-05 15:57:19 +01:00
|
|
|
attribute: this.name,
|
|
|
|
objecttype: varLSform.objecttype,
|
|
|
|
idform: varLSform.idform,
|
|
|
|
pattern: this.searchAddInput.value
|
|
|
|
};
|
2008-11-06 12:23:21 +01:00
|
|
|
data.imgload=varLSdefault.loadingImgDisplay(this.searchAddInput);
|
2008-11-05 15:57:19 +01:00
|
|
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSearchAddComplete.bind(this)}).send();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onSearchAddComplete: function(responseText, responseXML) {
|
|
|
|
var data = JSON.decode(responseText);
|
|
|
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
|
|
|
if (!$type(this.searchAddUl)) {
|
|
|
|
this.searchAddUl = new Element('ul');
|
|
|
|
this.searchAddUl.addClass('LSformElement_select_object_searchAdd');
|
|
|
|
this.searchAddUl.injectAfter(this.searchAddInput);
|
|
|
|
}
|
|
|
|
this.searchAddUl.empty();
|
|
|
|
if (data.objects) {
|
|
|
|
var objs = new Hash(data.objects);
|
|
|
|
objs.each(this.addSearchAddLi,this);
|
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
this.addSearchAddNoValueLabelIfEmpty();
|
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
this.searchAddUl.setStyle('display','block');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
addSearchAddLi: function(name,dn) {
|
|
|
|
var current = 0;
|
|
|
|
this.ul.getElements("input[type=hidden]").each(function(input){
|
2008-11-14 16:32:09 +01:00
|
|
|
if ((input.value==dn)&&(input.name == this.name+'[]')) {
|
2008-11-05 15:57:19 +01:00
|
|
|
current=1;
|
|
|
|
}
|
|
|
|
},this);
|
|
|
|
|
|
|
|
var li = new Element('li');
|
|
|
|
li.addClass('LSformElement_select_object_searchAdd');
|
|
|
|
li.id = dn;
|
|
|
|
li.set('html',name);
|
|
|
|
li.addEvent('mouseenter',this.onSearchAddLiMouseEnter.bind(this,li));
|
|
|
|
li.addEvent('mouseleave',this.onSearchAddLiMouseLeave.bind(this,li));
|
|
|
|
if (current) {
|
|
|
|
li.addClass('LSformElement_select_object_searchAdd_current');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
li.addEvent('click',this.onSearchAddLiClick.bind(this,li));
|
|
|
|
}
|
|
|
|
li.injectInside(this.searchAddUl);
|
|
|
|
},
|
|
|
|
|
2008-11-06 11:14:14 +01:00
|
|
|
addSearchAddNoValueLabelIfEmpty: function() {
|
|
|
|
if (!$type(this.searchAddUl.getElement('li.LSformElement_select_object_searchAdd'))) {
|
|
|
|
var li = new Element('li');
|
|
|
|
li.addClass('LSformElement_select_object_searchAdd');
|
2008-11-06 13:01:55 +01:00
|
|
|
li.set('html',this.params.noResultLabel);
|
2008-11-06 11:14:14 +01:00
|
|
|
li.injectInside(this.searchAddUl);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-11-05 15:57:19 +01:00
|
|
|
onSearchAddLiMouseEnter: function(li) {
|
|
|
|
li.addClass('LSformElement_select_object_searchAdd_over');
|
|
|
|
},
|
|
|
|
|
|
|
|
onSearchAddLiMouseLeave: function(li) {
|
|
|
|
li.removeClass('LSformElement_select_object_searchAdd_over');
|
|
|
|
},
|
|
|
|
|
|
|
|
onSearchAddLiClick: function(li) {
|
2008-11-06 11:14:14 +01:00
|
|
|
this.clearUlIfNoValue();
|
|
|
|
this.addLi(li.innerHTML,li.id);
|
2008-11-05 15:57:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
closeIfOpenSearchAdd: function(event) {
|
|
|
|
event = new Event(event);
|
|
|
|
if (this._searchAddOpen == 1 && event.target!=this.searchAddBtn && event.target!=this.searchAddInput && event.target!=this.searchAddUl) {
|
2008-11-06 11:14:14 +01:00
|
|
|
this.closeSearchAdd();
|
2008-11-05 15:57:19 +01:00
|
|
|
}
|
2008-11-06 11:14:14 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
closeSearchAdd: function() {
|
|
|
|
this.searchAddInput.setStyle('display','none');
|
|
|
|
if ($type(this.searchAddUl)) {
|
|
|
|
this.searchAddUl.setStyle('display','none');
|
|
|
|
}
|
|
|
|
this._searchAddOpen = 0;
|
2008-09-28 13:05:02 +02:00
|
|
|
}
|
|
|
|
});
|