@@ -1,6 +1,14 @@
2−function nativeMouse(elm) {
6+(function() {
9+ var Misc = Elm.Native.Misc;
3− var position = Elm.Signal.constant(Value.Tuple(0,0));
11+ var position = Elm.Signal.constant(Misc.Tuple(0,0));
4 position.defaultNumberOfKids = 2;
12 position.defaultNumberOfKids = 2;
6 // do not get rid of x and y. By setting their default number
14 // do not get rid of x and y. By setting their default number
@@ -13,7 +21,7 @@ function nativeMouse(elm) {
14 var isDown = Elm.Signal.constant(false);
22 var isDown = Elm.Signal.constant(false);
15 var isClicked = Elm.Signal.constant(false);
23 var isClicked = Elm.Signal.constant(false);
16− var clicks = Elm.Signal.constant(Value.Tuple());
24+ var clicks = Elm.Signal.constant(Misc.Tuple());
18 function getXY(e) {
26 function getXY(e) {
19 var posx = 0;
27 var posx = 0;
@@ -28,27 +36,27 @@ function nativeMouse(elm) {
28 posy = e.clientY + document.body.scrollTop +
36 posy = e.clientY + document.body.scrollTop +
29 document.documentElement.scrollTop;
37 document.documentElement.scrollTop;
31− return Value.Tuple(posx, posy);
39+ return Misc.Tuple(posx, posy);
34− Value.addListener(document, 'click', function(e) {
42+ Misc.addListener(document, 'click', function(e) {
35 var hasListener1 = Dispatcher.notify(isClicked.id, true);
43 var hasListener1 = Dispatcher.notify(isClicked.id, true);
36− var hasListener2 = Dispatcher.notify(clicks.id, Value.Tuple());
44+ var hasListener2 = Dispatcher.notify(clicks.id, Misc.Tuple());
37 Dispatcher.notify(isClicked.id, false);
45 Dispatcher.notify(isClicked.id, false);
38 if (!hasListener1 && !hasListener2)
46 if (!hasListener1 && !hasListener2)
39 this.removeEventListener('click',arguments.callee,false);
47 this.removeEventListener('click',arguments.callee,false);
41− Value.addListener(document, 'mousedown', function(e) {
49+ Misc.addListener(document, 'mousedown', function(e) {
42 var hasListener = Dispatcher.notify(isDown.id, true);
50 var hasListener = Dispatcher.notify(isDown.id, true);
43 if (!hasListener)
51 if (!hasListener)
44 this.removeEventListener('mousedown',arguments.callee,false);
52 this.removeEventListener('mousedown',arguments.callee,false);
46− Value.addListener(document, 'mouseup', function(e) {
54+ Misc.addListener(document, 'mouseup', function(e) {
47 var hasListener = Dispatcher.notify(isDown.id, false);
55 var hasListener = Dispatcher.notify(isDown.id, false);
48 if (!hasListener)
56 if (!hasListener)
49 this.removeEventListener('mouseup',arguments.callee,false);
57 this.removeEventListener('mouseup',arguments.callee,false);
51− Value.addListener(document, 'mousemove', function(e) {
59+ Misc.addListener(document, 'mousemove', function(e) {
52 var hasListener = Dispatcher.notify(position.id, getXY(e));
60 var hasListener = Dispatcher.notify(position.id, getXY(e));
53 if (!hasListener)
61 if (!hasListener)
54 this.removeEventListener('mousemove',arguments.callee,false);
62 this.removeEventListener('mousemove',arguments.callee,false);
@@ -57,17 +65,17 @@ function nativeMouse(elm) {
57 var clickedOn = function(elem) {
65 var clickedOn = function(elem) {
58 var node = Render.render(elem);
66 var node = Render.render(elem);
59 var click = Elm.Signal.constant(false);
67 var click = Elm.Signal.constant(false);
60− Value.addListener(node, 'click', function(e) {
68+ Misc.addListener(node, 'click', function(e) {
61 Dispatcher.notify(click.id, true);
69 Dispatcher.notify(click.id, true);
62 Dispatcher.notify(click.id, false);
70 Dispatcher.notify(click.id, false);
64− return Value.Tuple(Value.wrap(node), click);
72+ return Misc.Tuple(Misc.wrap(node), click);
66− elm.Native.Mouse = {position: position,
74+ Elm.Native.Mouse = {position: position,
69 isClicked: isClicked,
77 isClicked: isClicked,
70 isDown: isDown,
78 isDown: isDown,
71 clicks: clicks,
79 clicks: clicks,
72 isClickedOn: clickedOn};
80 isClickedOn: clickedOn};