2008-02-08 18:39:24 +01:00
|
|
|
var LSview = new Class({
|
|
|
|
initialize: function(){
|
2009-02-20 15:05:22 +01:00
|
|
|
this.labels = varLSdefault.LSjsConfig['LSview_labels'];
|
|
|
|
if (!$type(this.labels)) {
|
|
|
|
this.labels = {
|
2020-06-04 17:10:24 +02:00
|
|
|
delete_confirm_text: 'Do you really want to delete "%{name}"?',
|
2009-02-20 15:05:22 +01:00
|
|
|
delete_confirm_title: "Caution",
|
|
|
|
delete_confirm_validate: "Delete"
|
|
|
|
};
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2020-06-04 17:10:24 +02:00
|
|
|
this.title = $('LSview_title');
|
|
|
|
if (this.title) {
|
|
|
|
this.object_name = this.title.innerHTML;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.title = $('LSform_title');
|
|
|
|
if (this.title) {
|
|
|
|
this.object_name = this.title.getProperty('data-object-name');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
$$('td.LSobject-list-names').each(function(el) {
|
|
|
|
el.addEvent('click',this.onTdLSobjectListNamesClick.bind(this,el));
|
|
|
|
}, this);
|
2008-11-10 15:00:43 +01:00
|
|
|
$$('a.LSobject-list-actions').each(function(el) {
|
2020-05-04 10:49:11 +02:00
|
|
|
var checkRemove = /\/remove$/;
|
2008-11-10 15:00:43 +01:00
|
|
|
if (checkRemove.exec(el.href)) {
|
|
|
|
el.addEvent('click',this.onRemoveListBtnClick.bindWithEvent(this,el));
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
$$('a.LSview-actions').each(function(el) {
|
2020-05-04 10:49:11 +02:00
|
|
|
var checkRemove = /\/remove$/;
|
2008-11-10 15:00:43 +01:00
|
|
|
if (checkRemove.exec(el.href)) {
|
|
|
|
el.addEvent('click',this.onRemoveViewBtnClick.bindWithEvent(this,el));
|
|
|
|
}
|
2011-05-20 18:42:21 +02:00
|
|
|
else if(el.hasClass('LScustomActions')) {
|
|
|
|
el.addEvent('click',this.onCustomActionBtnClick.bindWithEvent(this,el));
|
|
|
|
}
|
2008-11-10 15:00:43 +01:00
|
|
|
}, this);
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2010-02-03 02:10:04 +01:00
|
|
|
this.LSsearchForm = $('LSsearch_form');
|
|
|
|
this.LSsearchPredefinedFilter = $('LSview_search_predefinedFilter');
|
|
|
|
if($type(this.LSsearchPredefinedFilter) && $type('LSsearch_form')) {
|
|
|
|
this.LSsearchPredefinedFilter.addEvent('change',this.onLSsearchPredefinedFilterChange.bind(this));
|
|
|
|
}
|
2020-06-02 21:10:59 +02:00
|
|
|
|
|
|
|
$$('ul.LSview-actions').each(function(ul) {
|
|
|
|
ul.addEvent('click', this.toggleLSviewActions.bind(this, ul));
|
|
|
|
}, this);
|
|
|
|
this.onWindowResized();
|
|
|
|
window.addEvent('resize', this.onWindowResized.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
onWindowResized: function() {
|
|
|
|
var window_width = window.getWidth().toInt();
|
2020-06-04 17:10:24 +02:00
|
|
|
if (this.title) {
|
|
|
|
window_width = this.title.getWidth().toInt();
|
2020-06-02 21:10:59 +02:00
|
|
|
}
|
|
|
|
if ($('LSview_search_predefinedFilter')) {
|
2020-06-04 17:10:24 +02:00
|
|
|
window_width -= $('LSview_search_predefinedFilter').getWidth().toInt() + $('LSview_search_predefinedFilter').getPosition().x;
|
2020-06-02 21:10:59 +02:00
|
|
|
}
|
|
|
|
$$('ul.LSview-actions').each(function(ul) {
|
|
|
|
// Calculte menu width
|
|
|
|
var actions_width = 0;
|
|
|
|
ul.getElements('li').each(function (li) {
|
|
|
|
actions_width += li.getWidth().toInt() + 10; // Add 10 for margin/space between li
|
|
|
|
});
|
|
|
|
|
|
|
|
if (window.getWidth() < actions_width) {
|
|
|
|
ul.addClass('LSview-actions-dropdown');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ul.removeClass('LSview-actions-dropdown');
|
|
|
|
}
|
|
|
|
});
|
2010-02-03 02:10:04 +01:00
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2010-02-03 02:10:04 +01:00
|
|
|
onLSsearchPredefinedFilterChange: function() {
|
|
|
|
if (this.LSsearchForm) {
|
|
|
|
this.LSsearchForm.submit();
|
|
|
|
}
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
onTdLSobjectListNamesClick: function(td) {
|
|
|
|
window.location=td.getFirst().href;
|
|
|
|
},
|
|
|
|
|
2008-11-10 15:00:43 +01:00
|
|
|
onRemoveListBtnClick: function(event,a) {
|
|
|
|
Event(event).stop();
|
|
|
|
if (!this._confirmBoxOpen) {
|
|
|
|
this._confirmBoxOpen = 1;
|
2009-03-20 02:25:38 +01:00
|
|
|
var name = a.getParent().getParent().getFirst('td').getElement('a').innerHTML;
|
2008-11-10 15:00:43 +01:00
|
|
|
this.confirmBox = new LSconfirmBox({
|
2020-06-04 17:10:24 +02:00
|
|
|
text: getFData(this.labels.delete_confirm_text, name),
|
2008-11-10 15:00:43 +01:00
|
|
|
startElement: a,
|
|
|
|
onConfirm: this.removeFromA.bind(this,a),
|
|
|
|
onClose: this.onConfirmBoxClose.bind(this)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2008-11-10 15:00:43 +01:00
|
|
|
onRemoveViewBtnClick: function(event,a) {
|
|
|
|
Event(event).stop();
|
|
|
|
if (!this._confirmBoxOpen) {
|
|
|
|
this._confirmBoxOpen = 1;
|
2020-06-04 17:10:24 +02:00
|
|
|
var name = this.object_name;
|
2008-11-10 15:00:43 +01:00
|
|
|
this.confirmBox = new LSconfirmBox({
|
2020-06-04 17:10:24 +02:00
|
|
|
text: getFData(this.labels.delete_confirm_text, name),
|
2009-02-20 15:05:22 +01:00
|
|
|
title: this.labels.delete_confirm_title,
|
|
|
|
validate_label: this.labels.delete_confirm_yes_btn,
|
|
|
|
startElement: a,
|
|
|
|
onConfirm: this.removeFromA.bind(this,a),
|
|
|
|
onClose: this.onConfirmBoxClose.bind(this)
|
2008-11-10 15:00:43 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2008-11-10 15:00:43 +01:00
|
|
|
onConfirmBoxClose: function() {
|
|
|
|
this._confirmBoxOpen = 0;
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2008-11-10 15:00:43 +01:00
|
|
|
removeFromA: function(a) {
|
2020-05-04 10:49:11 +02:00
|
|
|
document.location = a.href+'?valid';
|
2011-05-20 15:56:19 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onCustomActionBtnClick: function(event,a) {
|
2011-07-06 15:53:51 +02:00
|
|
|
if (a.hasClass('LScustomActions_noConfirmation')) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-05-20 15:56:19 +02:00
|
|
|
Event(event).stop();
|
|
|
|
if (!this._confirmBoxOpen) {
|
|
|
|
this._confirmBoxOpen = 1;
|
2020-05-04 12:27:11 +02:00
|
|
|
var getName = new RegExp('customAction/([^/]*)');
|
2011-05-20 15:56:19 +02:00
|
|
|
var name = getName.exec(a.href)[1];
|
|
|
|
if (name) {
|
|
|
|
var title = a.innerHTML;
|
|
|
|
if ($type(this.labels['custom_action_'+name+'_confirm_text'])) {
|
|
|
|
var text = this.labels['custom_action_'+name+'_confirm_text']
|
|
|
|
}
|
|
|
|
else {
|
2020-06-04 17:10:24 +02:00
|
|
|
var text = getFData('Do you really want to execute custom action %{customAction} on %{objectname} ?',{customAction: name, objectname: this.object_name });
|
2011-05-20 15:56:19 +02:00
|
|
|
}
|
|
|
|
this.confirmBox = new LSconfirmBox({
|
|
|
|
text: text,
|
|
|
|
title: title,
|
|
|
|
startElement: a,
|
|
|
|
onConfirm: this.executeCustomActionFromA.bind(this,a),
|
|
|
|
onClose: this.onConfirmBoxClose.bind(this)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
executeCustomActionFromA: function(a) {
|
|
|
|
document.location = a.href+'&valid';
|
2020-06-02 21:10:59 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
toggleLSviewActions: function(ul) {
|
|
|
|
if (ul.hasClass('LSview-actions-dropdown')) {
|
|
|
|
ul.toggleClass('LSview-actions-dropdown-opened');
|
|
|
|
}
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
|
|
|
varLSview = new LSview();
|
|
|
|
});
|