4 * Copyright (C) 2006-2011 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.
28 box = document.createElement("div");
29 box.className = "train";
31 box.style.left = "0px";
32 box.style.width = "0px";
33 box.style.height = "0px";
36 addEvent(box, "mouseover", function() { this.anc.stop_move(); } );
37 addEvent(box, "mouseout", function() { this.anc.start_move(); } );
40 this.anc.appendChild(box);
58 $('tickbut').style.visibility = "hidden";
59 $('tickbut').style.width = "0px";
61 this.clickable = true;
62 this.box.style.visibility = "visible";
67 $('tickbut').style.visibility = "visible";
68 $('tickbut').style.width = "20px";
70 this.clickable = false;
71 for (cur = this.first ; cur != null ; cur = cur.next) {
72 if (cur.notebox != null) {
79 hide_noauth: function()
81 for (cur = this.first ; cur != null ; cur = cur.next) {
82 if (cur.table >= g_tables_auth_n) {
88 show_noauth: function()
90 for (cur = this.first ; cur != null ; cur = cur.next) {
91 if (cur.table >= g_tables_auth_n) {
97 add: function(table, title)
102 for (cur = this.first ; cur != null ; cur = cur.next) {
103 if (cur.table == table)
107 wag = new wagon(this, table, title);
108 if (this.first == null) {
113 for (cur = this.first ; cur.next != null ; cur = cur.next);
118 this.xend = -this.widthbox_get();
128 var prev = null, remo = null;
130 if (this.first == null) {
134 if (this.first.table == table) {
138 for (cur = this.first ; cur != null ; cur = cur.next) {
139 // recalculate the width and replace wagons
140 if (cur.table == table) {
147 remo.box.className = "wagon_disable";
148 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
149 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
150 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
156 rem_obj: function(obj)
158 var prev = null, remo = null;
160 if (this.first == null) {
165 if (this.first == obj) {
167 this.first = this.first.next;
170 for (cur = this.first ; cur != null ; cur = cur.next) {
171 // recalculate the width and replace wagons
176 prev.next = cur.next;
185 if (this.first == null) {
186 clearTimeout(this.timout);
191 stop_move: function()
196 start_move: function()
201 shut_wagon: function(args)
205 obj = arguments[0][0];
206 wag = arguments[0][1];
208 if (wag.shut_step == 0) {
209 wag.box.className = "wagon_disable";
213 if (wag.shut_step == 1) {
214 wag.w = wag.widthbox_get();
215 wag.box.className = "wagon_disable2";
216 wag.box.style.padding = "0px";
217 wag.box.style.width = (wag.w-2)+"px";
218 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
220 wag.box.innerHTML = "";
223 curw = wag.widthbox_get() - 10;
224 wag.w = curw + 2; // 2 for border pixels
228 obj.box.removeChild(wag.box);
234 wag.box.style.width = curw+"px";
235 wag.box.style.padding = "0px";
239 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
244 var maxw = 0, maxh = 0, curh;
246 for (cur = this.first ; cur != null ; cur = cur.next) {
247 // recalculate the width and replace wagons
248 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
249 curh = cur.height_get();
250 maxh = (maxh < curh ? curh : maxh);
255 for (cur = this.first ; cur != null ; cur = cur.next) {
256 // recalculate the width and replace wagons
258 curx += cur.width_get() + 4;
261 this.box.style.width = maxw+"px";
262 this.box.style.height = maxh+"px";
268 this.clickable = true;
270 this.box.style.left = this.anc.offsetWidth+"px";
277 if (this.timout == null) {
278 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
284 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
286 // if (parseInt(this.box.style.left) >= this.xend) {
287 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
290 // this.box.style.left = this.anc.offsetWidth+"px";
291 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
293 if (parseInt(this.box.style.left) < this.xend) {
294 this.box.style.left = this.anc.offsetWidth+"px";
296 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
299 widthbox_get: function()
301 return (this.box.offsetWidth);
304 heightbox_get: function()
306 return (this.box.offsetHeight);
309 widthanc_get: function()
311 return (this.anc.offsetWidth);
314 heightanc_get: function()
316 return (this.anc.offsetHeight);
322 function wagon(anc, table, title) {
327 box = document.createElement("div");
328 box.className = "wagon";
332 box.innerHTML = "Tavolo "+table;
334 this.box.setAttribute("title", unescapeHTML(title));
336 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
337 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
338 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
341 if (g_listen & l_list_isol && table >= g_tables_auth_n) {
342 this.box.style.visibility = "hidden";
344 this.anc.box.appendChild(box);
346 this.w = this.widthbox_get();
347 this.h = this.heightbox_get();
363 this.box.style.visibility = "visible";
368 this.box.style.visibility = "hidden";
372 width_get: function()
377 height_get: function()
382 widthbox_get: function()
384 return (this.box.offsetWidth);
387 heightbox_get: function()
389 return (this.box.offsetHeight);
392 widthnotebox_get: function()
394 return (this.notebox.offsetWidth);
397 heightnotebox_get: function()
399 return (this.notebox.offsetHeight);
402 left_set: function(x)
404 this.box.style.left = x+"px";
409 if (this.anc.clickable == true) {
410 act_sitdown(this.table);
414 cb_mouseover: function()
418 notebox = document.createElement("div");
419 notebox.className = "notebox";
420 notebox.id = "wagon_note";
422 notebox.innerHTML = $("table"+this.table).innerHTML;
423 $("room_standup_orig").appendChild(notebox);
426 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
427 parseInt(getStyle(this.box, "left", "left")) +
428 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
430 notebox.style.left = deltax + "px";
431 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
432 notebox.style.visibility = "visible";
435 this.notebox = notebox;
440 cb_mouseout: function()
442 if (this.notebox != null) {
443 $("room_standup_orig").removeChild(this.notebox);