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 $('tickbut').style.visibility = "hidden";
61 $('tickbut').style.width = "0px";
63 this.clickable = true;
64 this.box.style.visibility = "visible";
69 $('tickbut').style.visibility = "visible";
70 $('tickbut').style.width = "20px";
72 this.clickable = false;
73 for (cur = this.first ; cur != null ; cur = cur.next) {
74 if (cur.notebox != null) {
81 add: function(table, title)
86 for (cur = this.first ; cur != null ; cur = cur.next) {
87 if (cur.table == table)
91 wag = new wagon(this, table, title);
92 if (this.first == null) {
97 for (cur = this.first ; cur.next != null ; cur = cur.next);
102 this.xend = -this.widthbox_get();
111 var prev = null, remo = null;
113 if (this.first == null) {
117 if (this.first.table == table) {
121 for (cur = this.first ; cur != null ; cur = cur.next) {
122 // recalculate the width and replace wagons
123 if (cur.table == table) {
130 remo.box.className = "wagon_disable";
131 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
132 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
133 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
139 rem_obj: function(obj)
141 var prev = null, remo = null;
143 if (this.first == null) {
148 if (this.first == obj) {
150 this.first = this.first.next;
153 for (cur = this.first ; cur != null ; cur = cur.next) {
154 // recalculate the width and replace wagons
159 prev.next = cur.next;
168 if (this.first == null) {
169 clearTimeout(this.timout);
174 stop_move: function()
179 start_move: function()
184 shut_wagon: function(args)
188 obj = arguments[0][0];
189 wag = arguments[0][1];
191 if (wag.shut_step == 0) {
192 wag.box.className = "wagon_disable";
196 if (wag.shut_step == 1) {
197 wag.w = wag.widthbox_get();
198 wag.box.className = "wagon_disable2";
199 wag.box.style.padding = "0px";
200 wag.box.style.width = (wag.w-2)+"px";
201 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
203 wag.box.innerHTML = "";
206 curw = wag.widthbox_get() - 10;
207 wag.w = curw + 2; // 2 for border pixels
209 obj.box.removeChild(wag.box);
215 wag.box.style.width = curw+"px";
216 wag.box.style.padding = "0px";
220 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
225 var maxw = 0, maxh = 0, curh;
227 for (cur = this.first ; cur != null ; cur = cur.next) {
228 // recalculate the width and replace wagons
229 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
230 curh = cur.height_get();
231 maxh = (maxh < curh ? curh : maxh);
236 for (cur = this.first ; cur != null ; cur = cur.next) {
237 // recalculate the width and replace wagons
239 curx += cur.width_get() + 4;
242 this.box.style.width = maxw+"px";
243 this.box.style.height = maxh+"px";
248 this.box.style.left = this.anc.offsetWidth+"px";
255 if (this.timout == null) {
256 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
262 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
264 // if (parseInt(this.box.style.left) >= this.xend) {
265 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
268 // this.box.style.left = this.anc.offsetWidth+"px";
269 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
271 if (parseInt(this.box.style.left) < this.xend) {
272 this.box.style.left = this.anc.offsetWidth+"px";
274 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
277 widthbox_get: function()
279 return (this.box.offsetWidth);
282 heightbox_get: function()
284 return (this.box.offsetHeight);
287 widthanc_get: function()
289 return (this.anc.offsetWidth);
292 heightanc_get: function()
294 return (this.anc.offsetHeight);
300 function wagon(anc, table, title) {
305 box = document.createElement("div");
306 box.className = "wagon";
310 box.innerHTML = "Tavolo "+table;
312 this.box.setAttribute("title", unescapeHTML(title));
314 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
315 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
316 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
318 this.anc.box.appendChild(box);
320 this.w = this.widthbox_get();
321 this.h = this.heightbox_get();
335 width_get: function()
340 height_get: function()
345 widthbox_get: function()
347 return (this.box.offsetWidth);
350 heightbox_get: function()
352 return (this.box.offsetHeight);
355 widthnotebox_get: function()
357 return (this.notebox.offsetWidth);
360 heightnotebox_get: function()
362 return (this.notebox.offsetHeight);
365 left_set: function(x)
367 this.box.style.left = x+"px";
372 if (this.anc.clickable == true) {
373 act_sitdown(this.table);
377 cb_mouseover: function()
381 notebox = document.createElement("div");
382 notebox.className = "notebox";
383 notebox.id = "wagon_note";
385 notebox.innerHTML = $("table"+this.table).innerHTML;
386 $("room_standup_orig").appendChild(notebox);
389 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
390 parseInt(getStyle(this.box, "left", "left")) +
391 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
393 notebox.style.left = deltax + "px";
394 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
395 notebox.style.visibility = "visible";
398 this.notebox = notebox;
403 cb_mouseout: function()
405 if (this.notebox != null) {
406 $("room_standup_orig").removeChild(this.notebox);