4 * Copyright (C) 2006-2008 Matteo Nastasi
5 * mailto: nastasi@alternativeoutput.it
6 * matteo.nastasi@milug.org
7 * web: http://www.alternativeoutput.it
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program; if
19 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
20 * Suite 330, Boston, MA 02111-1307, USA.
30 box = document.createElement("div");
31 box.className = "train";
33 box.style.left = "0px";
34 box.style.width = "0px";
35 box.style.height = "0px";
38 addEvent(box, "mouseover", function() { this.anc.stop_move(); } );
39 addEvent(box, "mouseout", function() { this.anc.start_move(); } );
42 this.anc.appendChild(box);
60 this.clickable = true;
61 this.box.style.visibility = "visible";
66 this.clickable = false;
67 for (cur = this.first ; cur != null ; cur = cur.next) {
68 if (cur.notebox != null) {
75 add: function(table, title)
80 for (cur = this.first ; cur != null ; cur = cur.next) {
81 if (cur.table == table)
85 wag = new wagon(this, table, title);
86 if (this.first == null) {
91 for (cur = this.first ; cur.next != null ; cur = cur.next);
96 this.xend = -this.widthbox_get();
105 var prev = null, remo = null;
107 if (this.first == null) {
111 if (this.first.table == table) {
115 for (cur = this.first ; cur != null ; cur = cur.next) {
116 // recalculate the width and replace wagons
117 if (cur.table == table) {
124 remo.box.className = "wagon_disable";
125 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
126 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
127 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
133 rem_obj: function(obj)
135 var prev = null, remo = null;
137 if (this.first == null) {
142 if (this.first == obj) {
144 this.first = this.first.next;
147 for (cur = this.first ; cur != null ; cur = cur.next) {
148 // recalculate the width and replace wagons
153 prev.next = cur.next;
162 if (this.first == null) {
163 clearTimeout(this.timout);
168 stop_move: function()
173 start_move: function()
178 shut_wagon: function(args)
182 obj = arguments[0][0];
183 wag = arguments[0][1];
185 if (wag.shut_step == 0) {
186 wag.box.className = "wagon_disable";
190 if (wag.shut_step == 1) {
191 wag.w = wag.widthbox_get();
192 wag.box.className = "wagon_disable2";
193 wag.box.style.padding = "0px";
194 wag.box.style.width = (wag.w-2)+"px";
195 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
197 wag.box.innerHTML = "";
200 curw = wag.widthbox_get() - 4;
201 wag.w = curw + 2; // 2 for border pixels
203 obj.box.removeChild(wag.box);
209 wag.box.style.width = curw+"px";
210 wag.box.style.padding = "0px";
214 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 100, [ obj, wag ]);
219 var maxw = 0, maxh = 0, curh;
221 for (cur = this.first ; cur != null ; cur = cur.next) {
222 // recalculate the width and replace wagons
223 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
224 curh = cur.height_get();
225 maxh = (maxh < curh ? curh : maxh);
230 for (cur = this.first ; cur != null ; cur = cur.next) {
231 // recalculate the width and replace wagons
233 curx += cur.width_get() + 4;
236 this.box.style.width = maxw+"px";
237 this.box.style.height = maxh+"px";
242 this.box.style.left = this.anc.offsetWidth+"px";
249 if (this.timout == null) {
250 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
256 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
258 // if (parseInt(this.box.style.left) >= this.xend) {
259 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
262 // this.box.style.left = this.anc.offsetWidth+"px";
263 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
265 if (parseInt(this.box.style.left) < this.xend) {
266 this.box.style.left = this.anc.offsetWidth+"px";
268 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
271 widthbox_get: function()
273 return (this.box.offsetWidth);
276 heightbox_get: function()
278 return (this.box.offsetHeight);
281 widthanc_get: function()
283 return (this.anc.offsetWidth);
286 heightanc_get: function()
288 return (this.anc.offsetHeight);
294 function wagon(anc, table, title) {
299 box = document.createElement("div");
300 box.className = "wagon";
304 box.innerHTML = "Tavolo "+table;
306 this.box.setAttribute("title", unescapeHTML(title));
308 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
309 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
310 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
312 this.anc.box.appendChild(box);
314 this.w = this.widthbox_get();
315 this.h = this.heightbox_get();
329 width_get: function()
334 height_get: function()
339 widthbox_get: function()
341 return (this.box.offsetWidth);
344 heightbox_get: function()
346 return (this.box.offsetHeight);
349 widthnotebox_get: function()
351 return (this.notebox.offsetWidth);
354 heightnotebox_get: function()
356 return (this.notebox.offsetHeight);
359 left_set: function(x)
361 this.box.style.left = x+"px";
366 if (this.anc.clickable == true) {
367 act_sitdown(this.table);
371 cb_mouseover: function()
375 notebox = document.createElement("div");
376 notebox.className = "notebox";
377 notebox.id = "wagon_note";
379 notebox.innerHTML = $("table"+this.table).innerHTML;
380 $("room_standup_orig").appendChild(notebox);
383 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
384 parseInt(getStyle(this.box, "left", "left")) +
385 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
387 notebox.style.left = deltax + "px";
388 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
389 notebox.style.visibility = "visible";
392 this.notebox = notebox;
397 cb_mouseout: function()
399 if (this.notebox != null) {
400 $("room_standup_orig").removeChild(this.notebox);