2008-02-05 17:11:21 +01:00
|
|
|
var LSdefault = new Class({
|
|
|
|
initialize: function(){
|
2008-02-08 18:39:24 +01:00
|
|
|
this.LSdebug = $('LSdebug');
|
2009-01-21 18:08:09 +01:00
|
|
|
this.LSdebug.addEvent('dblclick',this.hideLSdebug.bind(this));
|
2008-02-08 18:39:24 +01:00
|
|
|
this.LSdebugInfos = $('LSdebug_infos');
|
|
|
|
this.LSdebug.setOpacity(0);
|
|
|
|
|
|
|
|
this.LSdebugHidden = $('LSdebug_hidden');
|
2009-01-21 18:08:09 +01:00
|
|
|
this.LSdebugHidden.addEvent('click',this.hideLSdebug.bind(this));
|
2008-07-05 22:28:49 +02:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
this.LSerror = $('LSerror');
|
|
|
|
this.LSerror.setOpacity(0);
|
2009-01-21 18:08:09 +01:00
|
|
|
this.LSerror.addEvent('dblclick',this.hideLSerror.bind(this));
|
2008-09-09 17:48:07 +02:00
|
|
|
|
|
|
|
this.LSinfos = $('LSinfos');
|
2008-07-05 22:28:49 +02:00
|
|
|
|
2008-07-18 16:02:46 +02:00
|
|
|
this.LSjsConfigEl = $('LSjsConfig');
|
|
|
|
if ($type(this.LSjsConfigEl)) {
|
|
|
|
this.LSjsConfig = JSON.decode(this.LSjsConfigEl.innerHTML);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.LSjsConfig = [];
|
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
this.loading_img=[];
|
|
|
|
this.loading_img_id=-1;
|
2008-04-25 15:48:12 +02:00
|
|
|
|
|
|
|
this.LSsession_topDn = $('LSsession_topDn');
|
|
|
|
if (this.LSsession_topDn) {
|
|
|
|
this.LSsession_topDn.addEvent('change',this.onLSsession_topDnChange.bind(this));
|
|
|
|
}
|
2008-07-05 22:28:49 +02:00
|
|
|
|
|
|
|
this.fx = {
|
|
|
|
LSdebug: new Fx.Tween(this.LSdebug,{property: 'opacity',duration:600}),
|
2008-09-09 17:48:07 +02:00
|
|
|
LSerror: new Fx.Tween(this.LSerror,{property: 'opacity',duration:500}),
|
|
|
|
LSinfos: new Fx.Tween(this.LSinfos,{property: 'opacity',duration:500})
|
2008-07-05 22:28:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
if (this.LSdebugInfos.innerHTML != '') {
|
|
|
|
this.displayDebugBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LSerror.innerHTML != '') {
|
2008-07-18 16:43:19 +02:00
|
|
|
this.displayErrorBox();
|
2008-07-05 22:28:49 +02:00
|
|
|
}
|
2008-09-09 17:48:07 +02:00
|
|
|
|
|
|
|
if (this.LSinfos.innerHTML != '') {
|
|
|
|
this.displayInfosBox();
|
|
|
|
}
|
2008-11-14 18:36:49 +01:00
|
|
|
|
2008-11-25 00:40:47 +01:00
|
|
|
var getMoo = /moo$/;
|
|
|
|
if (getMoo.exec(window.location)) {
|
|
|
|
var mooTxt = " (__)\n (oo)\n /------\\\/\n / | ||\n * /\---/\\\n ~~ ~~";
|
|
|
|
var ulMoo = this.LSinfos.getElement('ul');
|
|
|
|
var preMoo = new Element('pre');
|
|
|
|
preMoo.set('html',mooTxt);
|
|
|
|
if ($type(ulMoo)) {
|
|
|
|
var liMoo = new Element('li');
|
|
|
|
liMoo.injectInside(ulMoo);
|
|
|
|
preMoo.injectInside(liMoo);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
preMoo.injectInside(this.LSinfos);
|
|
|
|
}
|
|
|
|
this.displayInfosBox();
|
|
|
|
}
|
|
|
|
|
2008-11-14 18:36:49 +01:00
|
|
|
this.LStips = new Tips('.LStips');
|
2008-04-25 15:48:12 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onLSsession_topDnChange: function() {
|
|
|
|
$('LSsession_topDn_form').submit();
|
2008-02-05 17:11:21 +01:00
|
|
|
},
|
|
|
|
|
2009-01-21 18:08:09 +01:00
|
|
|
hideLSdebug: function(){
|
2008-07-05 22:28:49 +02:00
|
|
|
this.fx.LSdebug.start(0.8,0);
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
2009-01-21 18:08:09 +01:00
|
|
|
|
|
|
|
hideLSerror: function(){
|
|
|
|
this.fx.LSerror.start(0.9,0);
|
|
|
|
},
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2008-07-05 22:28:49 +02:00
|
|
|
checkAjaxReturn: function(data) {
|
2008-11-10 00:18:35 +01:00
|
|
|
if ($type(data) == 'object') {
|
2009-01-21 18:08:09 +01:00
|
|
|
if (($type(data.LSredirect)) && (!$type(data.LSdebug)) ) {
|
|
|
|
document.location = data.LSredirect;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-11-10 00:18:35 +01:00
|
|
|
if ($type(data.imgload)) {
|
2008-07-05 22:28:49 +02:00
|
|
|
this.loadingImgHide(data.imgload);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.loadingImgHide();
|
|
|
|
}
|
|
|
|
|
2008-11-10 00:18:35 +01:00
|
|
|
if ($type(data.LSdebug)) {
|
2008-07-05 22:28:49 +02:00
|
|
|
LSdebug(data.LSdebug);
|
|
|
|
this.displayDebug(data.LSdebug);
|
|
|
|
}
|
|
|
|
|
2008-11-10 00:18:35 +01:00
|
|
|
if ($type(data.LSinfos)) {
|
|
|
|
this.displayInfos(data.LSinfos);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($type(data.LSerror)) {
|
2008-07-05 22:28:49 +02:00
|
|
|
this.displayError(data.LSerror);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LSdebug('retour non-interprétable');
|
|
|
|
this.loadingImgHide();
|
|
|
|
return;
|
|
|
|
}
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
displayError: function(html) {
|
2008-07-05 22:28:49 +02:00
|
|
|
this.LSerror.set('html',html);
|
|
|
|
this.displayErrorBox();
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2008-04-25 15:48:12 +02:00
|
|
|
displayDebug: function(html) {
|
2008-07-05 22:28:49 +02:00
|
|
|
this.LSdebugInfos.set('html',html);
|
2008-04-25 15:48:12 +02:00
|
|
|
this.displayDebugBox();
|
|
|
|
},
|
2008-09-25 17:15:33 +02:00
|
|
|
|
|
|
|
displayInfos: function(html) {
|
|
|
|
this.LSinfos.set('html',html);
|
|
|
|
this.displayInfosBox();
|
|
|
|
},
|
|
|
|
|
2008-07-05 22:28:49 +02:00
|
|
|
displayErrorBox: function() {
|
2008-02-26 18:40:05 +01:00
|
|
|
this.LSerror.setStyle('top',getScrollTop()+10);
|
2008-07-05 22:28:49 +02:00
|
|
|
this.fx.LSerror.start(0,0.8);
|
|
|
|
},
|
|
|
|
|
2008-09-09 17:48:07 +02:00
|
|
|
displayInfosBox: function() {
|
|
|
|
this.LSinfos.setStyle('top',getScrollTop()+10);
|
|
|
|
this.fx.LSinfos.start(0,0.9);
|
|
|
|
(function(){this.fx.LSinfos.start(0.9,0);}).delay(5000, this);
|
|
|
|
},
|
|
|
|
|
2008-07-05 22:28:49 +02:00
|
|
|
displayDebugBox: function() {
|
|
|
|
this.LSdebug.setStyle('top',getScrollTop()+10);
|
|
|
|
this.fx.LSdebug.start(0,0.8);
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2008-05-15 17:21:54 +02:00
|
|
|
loadingImgDisplay: function(el,position,size) {
|
2008-02-26 18:40:05 +01:00
|
|
|
this.loading_img_id++;
|
|
|
|
this.loading_img[this.loading_img_id] = new Element('img');
|
2008-05-15 17:21:54 +02:00
|
|
|
if (size=='big') {
|
2008-10-09 11:50:38 +02:00
|
|
|
var src = this.imagePath('loading.gif');
|
2008-05-15 17:21:54 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-10-09 11:50:38 +02:00
|
|
|
var src = this.imagePath('ajax-loader.gif');
|
2008-05-15 17:21:54 +02:00
|
|
|
}
|
|
|
|
this.loading_img[this.loading_img_id].src=src;
|
2008-02-26 18:40:05 +01:00
|
|
|
if (position=='inside') {
|
|
|
|
this.loading_img[this.loading_img_id].injectInside(el);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.loading_img[this.loading_img_id].injectAfter(el);
|
|
|
|
}
|
|
|
|
return this.loading_img_id;
|
2008-02-08 18:39:24 +01:00
|
|
|
},
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
loadingImgHide: function(id) {
|
|
|
|
if (isNaN(id)) {
|
|
|
|
this.loading_img.each(function(el) {
|
|
|
|
if (typeof(el) != 'undefined')
|
2008-07-05 22:28:49 +02:00
|
|
|
el.destroy();
|
2008-02-26 18:40:05 +01:00
|
|
|
},this);
|
|
|
|
this.loading_img_id=-1;
|
|
|
|
}
|
|
|
|
else {
|
2008-07-05 22:28:49 +02:00
|
|
|
this.loading_img[id].destroy();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
ajaxDisplayDebugAndError: function() {
|
|
|
|
var LSdebug_txt = $('LSdebug_txt');
|
|
|
|
if (LSdebug_txt) {
|
|
|
|
var debug = LSdebug_txt.innerHTML;
|
|
|
|
if (debug) {
|
|
|
|
this.displayDebug(debug.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var LSerror_txt = $('LSerror_txt');
|
|
|
|
if (LSerror_txt) {
|
|
|
|
var error=LSerror_txt.innerHTML;
|
|
|
|
if (error) {
|
|
|
|
this.displayError(error.toString());
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-10-09 03:31:33 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
imagePath: function(image) {
|
|
|
|
return this.LSjsConfig['LS_IMAGES_DIR'] + '/' + image;
|
2008-10-16 14:01:26 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getParams: function(name) {
|
|
|
|
if ($type(this.LSjsConfig[name])) {
|
|
|
|
return this.LSjsConfig[name];
|
|
|
|
}
|
|
|
|
return new Hash();
|
2008-11-10 03:10:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
addHelpInfo: function(el,group,name) {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'])) {
|
|
|
|
if ($type(el)=='element') {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'][group])) {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'][group][name])) {
|
2008-11-14 18:36:49 +01:00
|
|
|
this.addTip(el);
|
2008-11-10 03:10:42 +01:00
|
|
|
el.store('tip:title',this.LSjsConfig['helpInfos'][group][name]);
|
2008-11-13 20:05:06 +01:00
|
|
|
el.store('tip:text',"");
|
2008-11-10 03:10:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setHelpInfo: function(el,group,name) {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'])) {
|
|
|
|
if ($type(el)=='element') {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'][group])) {
|
|
|
|
if ($type(this.LSjsConfig['helpInfos'][group][name])) {
|
|
|
|
el.store('tip:title',this.LSjsConfig['helpInfos'][group][name]);
|
2008-11-13 20:05:06 +01:00
|
|
|
el.store('tip:text',"");
|
2008-11-10 03:10:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 18:36:49 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
addTip: function(el) {
|
|
|
|
this.LStips.attach(el);
|
|
|
|
},
|
|
|
|
|
|
|
|
removeTip: function(el) {
|
|
|
|
this.LStips.detach(el);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
|
|
|
});
|
2008-07-28 18:30:40 +02:00
|
|
|
|
2008-02-05 17:11:21 +01:00
|
|
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
2008-02-08 18:39:24 +01:00
|
|
|
varLSdefault = new LSdefault();
|
2008-02-05 17:11:21 +01:00
|
|
|
});
|