2009-04-14 20:09:45 +02:00
|
|
|
var LSinfosBox = new Class({
|
|
|
|
initialize: function(options){
|
|
|
|
// Default options
|
|
|
|
this._options = {
|
|
|
|
closeBtn: 0,
|
|
|
|
name: '',
|
|
|
|
fxDuration: 500,
|
|
|
|
opacity: 0.8,
|
|
|
|
autoClose: 3000
|
|
|
|
};
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
// Load options from argument
|
|
|
|
if ($type(options)=='object') {
|
|
|
|
$each(options,function(val,name) {
|
|
|
|
if ($type(this._options[name])) {
|
|
|
|
this._options[name]=val;
|
|
|
|
}
|
|
|
|
},this);
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.build();
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.opened=0;
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
build: function() {
|
|
|
|
var classes;
|
|
|
|
if (this._options.name!='') {
|
|
|
|
classes='LSinfosBox '+this._options.name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
classes='LSinfosBox'
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.core = new Element('div');
|
|
|
|
this.core.addClass(classes);
|
|
|
|
this.core.addEvent('dblclick',this.close.bind(this));
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
if(this._options.closeBtn) {
|
|
|
|
this.closeBtn = new Element('span');
|
|
|
|
this.closeBtn.addClass(classes);
|
|
|
|
this.closeBtn.set('html','X');
|
|
|
|
this.closeBtn.addEvent('click',this.close.bind(this));
|
|
|
|
this.closeBtn.injectInside(this.core);
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.content = new Element('p');
|
|
|
|
this.content.addEvent(classes);
|
|
|
|
this.content.injectInside(this.core);
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.fx = new Fx.Tween(
|
|
|
|
this.core,
|
|
|
|
{
|
|
|
|
property: 'opacity',
|
|
|
|
duration: this._options.fxDuration,
|
|
|
|
fps: 30
|
|
|
|
}
|
|
|
|
);
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.core.inject(document.body,'top');
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-10-29 22:28:18 +01:00
|
|
|
isOpened: function() {
|
|
|
|
return this.opened;
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
open: function() {
|
|
|
|
this.core.setStyle('top',getScrollTop()+10);
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
if (this._options.autoClose>0) {
|
|
|
|
this.closeTime = (new Date()).getTime();
|
|
|
|
this.autoClose.delay((this._options.autoClose+this._options.fxDuration),this,this.closeTime);
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
if (this.opened) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
this.fx.start(0,this._options.opacity);
|
|
|
|
this.opened = 1;
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
close: function(withoutEffect) {
|
|
|
|
if (this.opened) {
|
|
|
|
this.opened = 0;
|
|
|
|
if (withoutEffect==1) {
|
|
|
|
this.fx.set(0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.fx.start(this._options.opacity,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
autoClose: function(time) {
|
|
|
|
if (time==this.closeTime) {
|
|
|
|
this.close();
|
|
|
|
this.closeTime=0;
|
|
|
|
}
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
addInfo: function(html) {
|
2009-10-29 22:28:18 +01:00
|
|
|
var ul = this.content.getLast("ul");
|
2009-10-29 22:56:10 +01:00
|
|
|
var add = 1;
|
2009-10-29 22:28:18 +01:00
|
|
|
if (!$type(ul)) {
|
2009-10-29 22:56:10 +01:00
|
|
|
add=0;
|
2009-10-29 22:28:18 +01:00
|
|
|
ul = new Element('ul');
|
|
|
|
if (this.content.innerHTML!="") {
|
2009-04-14 20:09:45 +02:00
|
|
|
var c_li = new Element('li');
|
|
|
|
c_li.set('html',this.content.innerHTML);
|
|
|
|
c_li.injectInside(ul);
|
2009-10-29 22:28:18 +01:00
|
|
|
add=1;
|
2009-04-14 20:09:45 +02:00
|
|
|
}
|
2009-10-29 22:28:18 +01:00
|
|
|
this.content.empty();
|
|
|
|
ul.injectInside(this.content);
|
|
|
|
}
|
|
|
|
if (add) {
|
|
|
|
var b_li = new Element('li');
|
|
|
|
b_li.set('html','<hr/>');
|
|
|
|
b_li.injectInside(ul);
|
2009-04-14 20:09:45 +02:00
|
|
|
}
|
2009-10-29 22:28:18 +01:00
|
|
|
var li = new Element('li');
|
|
|
|
li.set('html',html);
|
|
|
|
li.injectInside(ul);
|
2009-04-14 20:09:45 +02:00
|
|
|
this.open();
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-04-14 20:09:45 +02:00
|
|
|
display: function(html) {
|
|
|
|
if ($type(html)) {
|
|
|
|
this.content.empty();
|
|
|
|
this.content.set('html',html);
|
|
|
|
}
|
|
|
|
this.open();
|
2009-10-29 22:56:10 +01:00
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-10-29 22:56:10 +01:00
|
|
|
displayInUl: function(html) {
|
|
|
|
if ($type(html)) {
|
|
|
|
ul = new Element('ul');
|
|
|
|
this.content.empty();
|
|
|
|
ul.set('html',html);
|
|
|
|
ul.inject(this.content);
|
|
|
|
}
|
|
|
|
this.open();
|
|
|
|
},
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2009-10-29 22:56:10 +01:00
|
|
|
displayOrAdd: function(html) {
|
|
|
|
if (this.isOpened()) {
|
|
|
|
this.addInfo(html);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.displayInUl(html);
|
|
|
|
}
|
2009-04-14 20:09:45 +02:00
|
|
|
}
|
|
|
|
});
|