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();
112 var prev = null, remo = null;
114 if (this.first == null) {
118 if (this.first.table == table) {
122 for (cur = this.first ; cur != null ; cur = cur.next) {
123 // recalculate the width and replace wagons
124 if (cur.table == table) {
131 remo.box.className = "wagon_disable";
132 removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
133 removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
134 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
140 rem_obj: function(obj)
142 var prev = null, remo = null;
144 if (this.first == null) {
149 if (this.first == obj) {
151 this.first = this.first.next;
154 for (cur = this.first ; cur != null ; cur = cur.next) {
155 // recalculate the width and replace wagons
160 prev.next = cur.next;
169 if (this.first == null) {
170 clearTimeout(this.timout);
175 stop_move: function()
180 start_move: function()
185 shut_wagon: function(args)
189 obj = arguments[0][0];
190 wag = arguments[0][1];
192 if (wag.shut_step == 0) {
193 wag.box.className = "wagon_disable";
197 if (wag.shut_step == 1) {
198 wag.w = wag.widthbox_get();
199 wag.box.className = "wagon_disable2";
200 wag.box.style.padding = "0px";
201 wag.box.style.width = (wag.w-2)+"px";
202 wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
204 wag.box.innerHTML = "";
207 curw = wag.widthbox_get() - 10;
208 wag.w = curw + 2; // 2 for border pixels
212 obj.box.removeChild(wag.box);
218 wag.box.style.width = curw+"px";
219 wag.box.style.padding = "0px";
223 setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
228 var maxw = 0, maxh = 0, curh;
230 for (cur = this.first ; cur != null ; cur = cur.next) {
231 // recalculate the width and replace wagons
232 maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
233 curh = cur.height_get();
234 maxh = (maxh < curh ? curh : maxh);
239 for (cur = this.first ; cur != null ; cur = cur.next) {
240 // recalculate the width and replace wagons
242 curx += cur.width_get() + 4;
245 this.box.style.width = maxw+"px";
246 this.box.style.height = maxh+"px";
252 this.clickable = true;
254 this.box.style.left = this.anc.offsetWidth+"px";
261 if (this.timout == null) {
262 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
268 this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
270 // if (parseInt(this.box.style.left) >= this.xend) {
271 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
274 // this.box.style.left = this.anc.offsetWidth+"px";
275 // this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
277 if (parseInt(this.box.style.left) < this.xend) {
278 this.box.style.left = this.anc.offsetWidth+"px";
280 this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
283 widthbox_get: function()
285 return (this.box.offsetWidth);
288 heightbox_get: function()
290 return (this.box.offsetHeight);
293 widthanc_get: function()
295 return (this.anc.offsetWidth);
298 heightanc_get: function()
300 return (this.anc.offsetHeight);
306 function wagon(anc, table, title) {
311 box = document.createElement("div");
312 box.className = "wagon";
316 box.innerHTML = "Tavolo "+table;
318 this.box.setAttribute("title", unescapeHTML(title));
320 addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
321 addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
322 addEvent(this.box, "click", function() { this.anc.cb_click(); } );
324 this.anc.box.appendChild(box);
326 this.w = this.widthbox_get();
327 this.h = this.heightbox_get();
341 width_get: function()
346 height_get: function()
351 widthbox_get: function()
353 return (this.box.offsetWidth);
356 heightbox_get: function()
358 return (this.box.offsetHeight);
361 widthnotebox_get: function()
363 return (this.notebox.offsetWidth);
366 heightnotebox_get: function()
368 return (this.notebox.offsetHeight);
371 left_set: function(x)
373 this.box.style.left = x+"px";
378 if (this.anc.clickable == true) {
379 act_sitdown(this.table);
383 cb_mouseover: function()
387 notebox = document.createElement("div");
388 notebox.className = "notebox";
389 notebox.id = "wagon_note";
391 notebox.innerHTML = $("table"+this.table).innerHTML;
392 $("room_standup_orig").appendChild(notebox);
395 deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
396 parseInt(getStyle(this.box, "left", "left")) +
397 ((this.box.offsetWidth - notebox.offsetWidth) / 2);
399 notebox.style.left = deltax + "px";
400 notebox.style.top = (-10 -notebox.offsetHeight)+"px";
401 notebox.style.visibility = "visible";
404 this.notebox = notebox;
409 cb_mouseout: function()
411 if (this.notebox != null) {
412 $("room_standup_orig").removeChild(this.notebox);