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 hide_noauth: function()
83 for (cur = this.first ; cur != null ; cur = cur.next) {
84 if (cur.table >= g_tables_auth_n) {
90 show_noauth: function()
92 for (cur = this.first ; cur != null ; cur = cur.next) {
93 if (cur.table >= g_tables_auth_n) {
99 add: function(table, title)
104 for (cur = this.first ; cur != null ; cur = cur.next) {
105 if (cur.table == table)
109 wag = new wagon(this, table, title);
110 if (this.first == null) {
115 for (cur = this.first ; cur.next != null ; cur = cur.next);
120 this.xend = -this.widthbox_get();
130 var prev = null, remo = null;
132 if (this.first == null) {
136 if (this.first.table == table) {
140 for (cur = this.first ; cur != null ; cur = cur.next) {
141 // recalculate the width and replace wagons
142 if (cur.table == table) {
149 remo.box.className = "wagon_disable";
150 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
151 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
152 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
158 rem_obj: function(obj)
160 var prev = null, remo = null;
162 if (this.first == null) {
167 if (this.first == obj) {
169 this.first = this.first.next;
172 for (cur = this.first ; cur != null ; cur = cur.next) {
173 // recalculate the width and replace wagons
178 prev.next = cur.next;
187 if (this.first == null) {
188 clearTimeout(this.timout);
193 stop_move: function()
198 start_move: function()
203 shut_wagon: function(args)
207 obj = arguments[0][0];
208 wag = arguments[0][1];
210 if (wag.shut_step == 0) {
211 wag.box.className = "wagon_disable";
215 if (wag.shut_step == 1) {
216 wag.w = wag.widthbox_get();
217 wag.box.className = "wagon_disable2";
218 wag.box.style.padding = "0px";
219 wag.box.style.width = (wag.w-2)+"px";
220 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
222 wag.box.innerHTML = "";
225 curw = wag.widthbox_get() - 10;
226 wag.w = curw + 2; // 2 for border pixels
230 obj.box.removeChild(wag.box);
236 wag.box.style.width = curw+"px";
237 wag.box.style.padding = "0px";
241 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
246 var maxw = 0, maxh = 0, curh;
248 for (cur = this.first ; cur != null ; cur = cur.next) {
249 // recalculate the width and replace wagons
250 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
251 curh = cur.height_get();
252 maxh = (maxh < curh ? curh : maxh);
257 for (cur = this.first ; cur != null ; cur = cur.next) {
258 // recalculate the width and replace wagons
260 curx += cur.width_get() + 4;
263 this.box.style.width = maxw+"px";
264 this.box.style.height = maxh+"px";
270 this.clickable = true;
272 this.box.style.left = this.anc.offsetWidth+"px";
279 if (this.timout == null) {
280 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
286 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
288 // if (parseInt(this.box.style.left) >= this.xend) {
289 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
292 // this.box.style.left = this.anc.offsetWidth+"px";
293 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
295 if (parseInt(this.box.style.left) < this.xend) {
296 this.box.style.left = this.anc.offsetWidth+"px";
298 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
301 widthbox_get: function()
303 return (this.box.offsetWidth);
306 heightbox_get: function()
308 return (this.box.offsetHeight);
311 widthanc_get: function()
313 return (this.anc.offsetWidth);
316 heightanc_get: function()
318 return (this.anc.offsetHeight);
324 function wagon(anc, table, title) {
329 box = document.createElement("div");
330 box.className = "wagon";
334 box.innerHTML = "Tavolo "+table;
336 this.box.setAttribute("title", unescapeHTML(title));
338 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
339 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
340 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
343 if (g_listen & l_list_isol && table >= g_tables_auth_n) {
344 this.box.style.visibility = "hidden";
346 this.anc.box.appendChild(box);
348 this.w = this.widthbox_get();
349 this.h = this.heightbox_get();
365 this.box.style.visibility = "visible";
370 this.box.style.visibility = "hidden";
374 width_get: function()
379 height_get: function()
384 widthbox_get: function()
386 return (this.box.offsetWidth);
389 heightbox_get: function()
391 return (this.box.offsetHeight);
394 widthnotebox_get: function()
396 return (this.notebox.offsetWidth);
399 heightnotebox_get: function()
401 return (this.notebox.offsetHeight);
404 left_set: function(x)
406 this.box.style.left = x+"px";
411 if (this.anc.clickable == true) {
412 act_sitdown(this.table);
416 cb_mouseover: function()
420 notebox = document.createElement("div");
421 notebox.className = "notebox";
422 notebox.id = "wagon_note";
424 notebox.innerHTML = $("table"+this.table).innerHTML;
425 $("room_standup_orig").appendChild(notebox);
428 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
429 parseInt(getStyle(this.box, "left", "left")) +
430 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
432 notebox.style.left = deltax + "px";
433 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
434 notebox.style.visibility = "visible";
437 this.notebox = notebox;
442 cb_mouseout: function()
444 if (this.notebox != null) {
445 $("room_standup_orig").removeChild(this.notebox);