eggification
[PlinnDocument.git] / Products / PlinnDocument / skins / dd_trigger.js
1 // (c) BenoƮt PIN 2006-2007
2 // http://plinn.org
3 // Licence GPL
4
5 function ddEventDispatch() {
6 addListener(document, 'mousedown', raisemousedown);
7 addListener(document, 'mousemove', raisemousemove);
8 addListener(document, 'mouseup', raisemouseup);
9 }
10
11
12 function getRectangleNode() {
13 var docid = document.id;
14 docid = document.id.slice(DocPrefixLength);
15 var frameId = IFramePrefix + docid;
16 iframe = window.parent.document.getElementById(frameId);
17 if (!iframe)
18 iframe = window.parent.document.getElementById("EpozEditor");
19 return iframe.parentNode;
20 }
21
22 var raisemousedown, raisemousemove, raisemouseup;
23
24 if (browser.isIE55 || browser.isIE6up) {
25 raisemousedown = function() {
26 var rect = getRectangleNode();
27 rect.fireEvent('onmousedown', window.event);
28 };
29
30 raisemousemove = function() {
31 var rect = getRectangleNode();
32 rect.fireEvent('onmousemove', window.event);
33 rect.fireEvent('onmouseover', window.event);
34 };
35
36 raisemouseup = function() {
37 var rect = getRectangleNode();
38 rect.fireEvent('onmouseup', window.event);
39 };
40 }
41 else if (browser.isDOM2Event) {
42 // initMouseEvent("eventType", bubblesFlas, cancelableFlag, view, detailVal, screenX, screenY, clientX, clientY, ctrlKeyFlag, altKeyFlag, shiftKeyFlag, metaKeyFlag, buttonCode, relatedTargetNodeRef)
43
44 raisemousedown = function(e) {
45 var event = document.createEvent("MouseEvents");
46 var rect = getRectangleNode()
47 event.initMouseEvent("mousedown", true, true, window.parent, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, rect);
48 rect.dispatchEvent(event);
49 };
50
51
52 raisemousemove = function(e) {
53 var overEvent = document.createEvent("MouseEvents");
54 overEvent.initMouseEvent("mouseover", true, true, window.parent, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, rect);
55 var event = document.createEvent("MouseEvents");
56 var rect = getRectangleNode()
57 event.initMouseEvent("mousemove", true, true, window.parent, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, rect);
58 rect.dispatchEvent(event);
59 rect.dispatchEvent(overEvent);
60 };
61
62
63 raisemouseup = function(e) {
64 var event = document.createEvent("MouseEvents");
65 var rect = getRectangleNode()
66 event.initMouseEvent("mouseup", true, true, window.parent, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, rect);
67 rect.dispatchEvent(event);
68 };
69 }