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";
63 for (cur = this.first ; cur != null ; cur = cur.next) {
64 cur.box.style.borderColor = "green green green green";
70 $('tickbut').style.visibility = "visible";
71 $('tickbut').style.width = "20px";
73 this.clickable = false;
74 this.box.style.visibility = "visible";
76 for (cur = this.first ; cur != null ; cur = cur.next) {
77 if (cur.notebox != null) {
80 cur.box.style.borderColor = "gray gray gray gray";
85 hide_noauth: function()
87 for (cur = this.first ; cur != null ; cur = cur.next) {
88 if (cur.table >= g_tables_auth_n) {
94 show_noauth: function()
96 for (cur = this.first ; cur != null ; cur = cur.next) {
97 if (cur.table >= g_tables_auth_n) {
103 add: function(table, title)
108 for (cur = this.first ; cur != null ; cur = cur.next) {
109 if (cur.table == table)
113 wag = new wagon(this, table, title);
114 if (this.first == null) {
119 for (cur = this.first ; cur.next != null ; cur = cur.next);
124 this.xend = -this.widthbox_get();
134 var prev = null, remo = null;
136 if (this.first == null) {
140 if (this.first.table == table) {
144 for (cur = this.first ; cur != null ; cur = cur.next) {
145 // recalculate the width and replace wagons
146 if (cur.table == table) {
153 remo.box.className = "wagon_disable";
154 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
155 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
156 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
162 rem_obj: function(obj)
164 var prev = null, remo = null;
166 if (this.first == null) {
171 if (this.first == obj) {
173 this.first = this.first.next;
176 for (cur = this.first ; cur != null ; cur = cur.next) {
177 // recalculate the width and replace wagons
182 prev.next = cur.next;
191 if (this.first == null) {
192 clearTimeout(this.timout);
197 stop_move: function()
202 start_move: function()
207 shut_wagon: function(args)
211 obj = arguments[0][0];
212 wag = arguments[0][1];
214 if (wag.shut_step == 0) {
215 wag.box.className = "wagon_disable";
219 if (wag.shut_step == 1) {
220 wag.w = wag.widthbox_get();
221 wag.box.className = "wagon_disable2";
222 wag.box.style.padding = "0px";
223 wag.box.style.width = (wag.w-2)+"px";
224 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
226 wag.box.innerHTML = "";
229 curw = wag.widthbox_get() - 10;
230 wag.w = curw + 2; // 2 for border pixels
234 obj.box.removeChild(wag.box);
240 wag.box.style.width = curw+"px";
241 wag.box.style.padding = "0px";
245 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
250 var maxw = 0, maxh = 0, curh;
252 for (cur = this.first ; cur != null ; cur = cur.next) {
253 // recalculate the width and replace wagons
254 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
255 curh = cur.height_get();
256 maxh = (maxh < curh ? curh : maxh);
261 for (cur = this.first ; cur != null ; cur = cur.next) {
262 // recalculate the width and replace wagons
264 curx += cur.width_get() + 4;
267 this.box.style.width = maxw+"px";
268 this.box.style.height = maxh+"px";
275 this.box.style.left = this.anc.offsetWidth+"px";
282 if (this.timout == null) {
283 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
289 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
291 // if (parseInt(this.box.style.left) >= this.xend) {
292 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
295 // this.box.style.left = this.anc.offsetWidth+"px";
296 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
298 if (parseInt(this.box.style.left) < this.xend) {
299 this.box.style.left = this.anc.offsetWidth+"px";
301 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
304 widthbox_get: function()
306 return (this.box.offsetWidth);
309 heightbox_get: function()
311 return (this.box.offsetHeight);
314 widthanc_get: function()
316 return (this.anc.offsetWidth);
319 heightanc_get: function()
321 return (this.anc.offsetHeight);
327 function wagon(anc, table, title) {
332 box = document.createElement("div");
333 box.className = "wagon";
335 if (anc.clickable == false)
336 box.style.borderColor = "gray gray gray gray";
339 box.innerHTML = "Tavolo "+table;
341 this.box.setAttribute("title", unescapeHTML(title));
343 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
344 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
345 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
348 if (g_listen & l_list_isol && table >= g_tables_auth_n) {
349 this.box.style.visibility = "hidden";
351 this.anc.box.appendChild(box);
353 this.w = this.widthbox_get();
354 this.h = this.heightbox_get();
370 this.box.style.visibility = "visible";
375 this.box.style.visibility = "hidden";
379 width_get: function()
384 height_get: function()
389 widthbox_get: function()
391 return (this.box.offsetWidth);
394 heightbox_get: function()
396 return (this.box.offsetHeight);
399 widthnotebox_get: function()
401 return (this.notebox.offsetWidth);
404 heightnotebox_get: function()
406 return (this.notebox.offsetHeight);
409 left_set: function(x)
411 this.box.style.left = x+"px";
416 if (this.anc.clickable == true) {
417 act_sitdown(this.table);
421 cb_mouseover: function()
425 notebox = document.createElement("div");
426 notebox.className = "notebox";
427 notebox.id = "wagon_note";
429 notebox.innerHTML = $("table"+this.table).innerHTML;
430 $("room_standup_orig").appendChild(notebox);
433 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
434 parseInt(getStyle(this.box, "left", "left")) +
435 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
437 notebox.style.left = deltax + "px";
438 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
439 notebox.style.visibility = "visible";
442 this.notebox = notebox;
447 cb_mouseout: function()
449 if (this.notebox != null) {
450 $("room_standup_orig").removeChild(this.notebox);