author | Tero Marttila <terom@fixme.fi> |
Thu, 28 Aug 2008 01:34:14 +0300 | |
changeset 44 | 03a7e064f833 |
parent 28 | c239c5c3beda |
permissions | -rw-r--r-- |
27
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
// script.aculo.us dragdrop.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
// |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
// script.aculo.us is freely distributable under the terms of an MIT-style license. |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
// For details, see the script.aculo.us web site: http://script.aculo.us/ |
28
c239c5c3beda
strip down the scriptaculous javascript code to a bare minimum, and rewrite tiles.js as tiles2.js - uses Classes, so the code is a lot neater. Still a couple bugs to work out, but mostly works
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
8 |
// |
c239c5c3beda
strip down the scriptaculous javascript code to a bare minimum, and rewrite tiles.js as tiles2.js - uses Classes, so the code is a lot neater. Still a couple bugs to work out, but mostly works
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
9 |
// Modified by Tero Marttila to strip unused code |
27
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
var Draggables = { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
drags: [], |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
observers: [], |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
register: function(draggable) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
if(this.drags.length == 0) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
this.eventMouseUp = this.endDrag.bindAsEventListener(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
this.eventMouseMove = this.updateDrag.bindAsEventListener(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
this.eventKeypress = this.keyPress.bindAsEventListener(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
Event.observe(document, "mouseup", this.eventMouseUp); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
Event.observe(document, "mousemove", this.eventMouseMove); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
Event.observe(document, "keypress", this.eventKeypress); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
this.drags.push(draggable); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
unregister: function(draggable) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
this.drags = this.drags.reject(function(d) { return d==draggable }); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
if(this.drags.length == 0) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
Event.stopObserving(document, "mouseup", this.eventMouseUp); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
Event.stopObserving(document, "mousemove", this.eventMouseMove); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
Event.stopObserving(document, "keypress", this.eventKeypress); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
activate: function(draggable) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
if(draggable.options.delay) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
this._timeout = setTimeout(function() { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
Draggables._timeout = null; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
window.focus(); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
Draggables.activeDraggable = draggable; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
}.bind(this), draggable.options.delay); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
} else { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
this.activeDraggable = draggable; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
deactivate: function() { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
this.activeDraggable = null; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
54 |
updateDrag: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
if(!this.activeDraggable) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
56 |
var pointer = [Event.pointerX(event), Event.pointerY(event)]; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
57 |
// Mozilla-based browsers fire successive mousemove events with |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
58 |
// the same coordinates, prevent needless redrawing (moz bug?) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
this._lastPointer = pointer; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
this.activeDraggable.updateDrag(event, pointer); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
64 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
65 |
endDrag: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
66 |
if(this._timeout) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
67 |
clearTimeout(this._timeout); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
68 |
this._timeout = null; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
if(!this.activeDraggable) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
this._lastPointer = null; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
this.activeDraggable.endDrag(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
73 |
this.activeDraggable = null; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
74 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
75 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
76 |
keyPress: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
77 |
if(this.activeDraggable) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
78 |
this.activeDraggable.keyPress(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
79 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
80 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
81 |
addObserver: function(observer) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
82 |
this.observers.push(observer); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
83 |
this._cacheObserverCallbacks(); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
85 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
86 |
removeObserver: function(element) { // element instead of observer fixes mem leaks |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
87 |
this.observers = this.observers.reject( function(o) { return o.element==element }); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
88 |
this._cacheObserverCallbacks(); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
89 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
90 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
91 |
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
92 |
if(this[eventName+'Count'] > 0) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
93 |
this.observers.each( function(o) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
94 |
if(o[eventName]) o[eventName](eventName, draggable, event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
95 |
}); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
96 |
if(draggable.options[eventName]) draggable.options[eventName](draggable, event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
97 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
98 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
99 |
_cacheObserverCallbacks: function() { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
100 |
['onStart','onEnd','onDrag'].each( function(eventName) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
101 |
Draggables[eventName+'Count'] = Draggables.observers.select( |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
102 |
function(o) { return o[eventName]; } |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
103 |
).length; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
104 |
}); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
105 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
106 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
107 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
108 |
/*--------------------------------------------------------------------------*/ |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
109 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
110 |
var Draggable = Class.create({ |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
111 |
initialize: function(element) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
112 |
var defaults = { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
113 |
handle: false, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
114 |
zindex: 1000, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
115 |
quiet: false, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
116 |
delay: 0 |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
117 |
}; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
118 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
119 |
var options = Object.extend(defaults, arguments[1] || { }); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
120 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
121 |
this.element = $(element); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
122 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
123 |
if(options.handle && Object.isString(options.handle)) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
124 |
this.handle = this.element.down('.'+options.handle, 0); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
125 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
126 |
if(!this.handle) this.handle = $(options.handle); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
127 |
if(!this.handle) this.handle = this.element; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
128 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
129 |
Element.makePositioned(this.element); // fix IE |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
131 |
this.options = options; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
132 |
this.dragging = false; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
133 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
134 |
this.eventMouseDown = this.initDrag.bindAsEventListener(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
135 |
Event.observe(this.handle, "mousedown", this.eventMouseDown); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
136 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
137 |
Draggables.register(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
138 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
139 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
140 |
destroy: function() { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
141 |
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
142 |
Draggables.unregister(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
143 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
144 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
145 |
currentDelta: function() { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
146 |
return([ |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
147 |
parseInt(Element.getStyle(this.element,'left') || '0'), |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
148 |
parseInt(Element.getStyle(this.element,'top') || '0')]); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
149 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
150 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
151 |
initDrag: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
152 |
if(!Object.isUndefined(Draggable._dragging[this.element]) && |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
153 |
Draggable._dragging[this.element]) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
154 |
if(Event.isLeftClick(event)) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
155 |
// abort on form elements, fixes a Firefox issue |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
156 |
var src = Event.element(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
157 |
if((tag_name = src.tagName.toUpperCase()) && ( |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
158 |
tag_name=='INPUT' || |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
159 |
tag_name=='SELECT' || |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
160 |
tag_name=='OPTION' || |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
161 |
tag_name=='BUTTON' || |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
162 |
tag_name=='TEXTAREA')) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
163 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
164 |
var pointer = [Event.pointerX(event), Event.pointerY(event)]; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
165 |
var pos = Position.cumulativeOffset(this.element); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
166 |
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
167 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
168 |
Draggables.activate(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
169 |
Event.stop(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
170 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
171 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
172 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
173 |
startDrag: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
174 |
this.dragging = true; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
175 |
if(!this.delta) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
176 |
this.delta = this.currentDelta(); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
177 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
178 |
if(this.options.zindex) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
179 |
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
180 |
this.element.style.zIndex = this.options.zindex; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
181 |
} |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
182 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
183 |
Draggables.notify('onStart', this, event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
184 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
185 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
186 |
updateDrag: function(event, pointer) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
187 |
if(!this.dragging) this.startDrag(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
188 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
189 |
Draggables.notify('onDrag', this, event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
190 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
191 |
this.draw(pointer); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
192 |
if(this.options.change) this.options.change(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
193 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
194 |
// fix AppleWebKit rendering |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
195 |
if(Prototype.Browser.WebKit) window.scrollBy(0,0); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
196 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
197 |
Event.stop(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
198 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
199 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
200 |
finishDrag: function(event, success) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
201 |
this.dragging = false; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
202 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
203 |
Draggables.notify('onEnd', this, event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
204 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
205 |
var d = this.currentDelta(); |
28
c239c5c3beda
strip down the scriptaculous javascript code to a bare minimum, and rewrite tiles.js as tiles2.js - uses Classes, so the code is a lot neater. Still a couple bugs to work out, but mostly works
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
206 |
this.delta = d; |
27
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
207 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
208 |
if(this.options.zindex) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
209 |
this.element.style.zIndex = this.originalZ; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
210 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
211 |
Draggables.deactivate(this); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
212 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
213 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
214 |
keyPress: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
215 |
if(event.keyCode!=Event.KEY_ESC) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
216 |
this.finishDrag(event, false); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
217 |
Event.stop(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
218 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
219 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
220 |
endDrag: function(event) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
221 |
if(!this.dragging) return; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
222 |
this.finishDrag(event, true); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
223 |
Event.stop(event); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
224 |
}, |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
225 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
226 |
draw: function(point) { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
227 |
var pos = Position.cumulativeOffset(this.element); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
228 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
229 |
var d = this.currentDelta(); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
230 |
pos[0] -= d[0]; pos[1] -= d[1]; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
231 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
232 |
var p = [0,1].map(function(i){ |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
233 |
return (point[i]-pos[i]-this.offset[i]) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
234 |
}.bind(this)); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
235 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
236 |
var style = this.element.style; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
237 |
if((!this.options.constraint) || (this.options.constraint=='horizontal')) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
238 |
style.left = p[0] + "px"; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
239 |
if((!this.options.constraint) || (this.options.constraint=='vertical')) |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
240 |
style.top = p[1] + "px"; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
241 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
242 |
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
243 |
}, |
28
c239c5c3beda
strip down the scriptaculous javascript code to a bare minimum, and rewrite tiles.js as tiles2.js - uses Classes, so the code is a lot neater. Still a couple bugs to work out, but mostly works
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
244 |
|
27
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
245 |
}); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
246 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
247 |
Draggable._dragging = { }; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
248 |