тест

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* @namespace GA_project
* @sdoc ga.sdoc
* @id GA
*/
typeof GA == 'undefined' && (GA = {})
/** @id GA.eventWatcherClass */
GA.eventWatcherClass = function(eventType, nodeClassName, onInMethodName, onOutMethodName) {
//если нет параметров выходим.
if (!eventType || !nodeClassName) return;
var s,
eventWatcherParams = {
'onIn': onInMethodName || false,
'onOut': onOutMethodName || false
};
this.watchedEvents = {};
if (nodeClassName.constructor == RegExp) {
eventWatcherParams.classReg = nodeClassName
} else {
s = '(?:\\s|^)'+nodeClassName+'(?:\\s|$)';
eventWatcherParams.classReg = new RegExp(s);
if (typeof eventWatcherParams.classReg.compile != 'undefined') {
eventWatcherParams.classReg.compile(s)
}
}
eventType.constructor != Array && (eventType = [eventType]);
for (var i = eventType.length; i--; ) {
this.watchedEvents[eventType[i]] =
this.methodIntoEventProcessing('eventProcessing', eventType[i], document, eventWatcherParams)
}
}
GA.eventWatcherClass.removeEventProcessing = document.addEventListener ?
function(sEvent, handler, oNode) {
oNode.removeEventListener(sEvent, handler, false)
}:
function(sEvent, handler, oNode){
oNode.detachEvent('on'+sEvent, handler)
}
GA.eventWatcherClass.prototype = {
'eventProcessing': function(oNode, pos, e, eventWatcherParams) {
var initialNode = oNode;
do {
if (/*this.*/eventWatcherParams.classReg.test(oNode.className)) {
// событие произошло на узле с заданным классом.
return /*this.*/eventWatcherParams.onIn ?
this[/*this.*/eventWatcherParams.onIn](oNode, pos, e):
null
}
} while (oNode = oNode.parentNode);
// событие произошло вне узла с заданным классом.
return /*this.*/eventWatcherParams.onOut?
this[/*this.*/eventWatcherParams.onOut](initialNode, pos, e):
null
},
'methodIntoEventProcessing': document.addEventListener ?
function(methodName, sEvent, oNode, oParams) {
var handler = (
function(obj, methodName, oParams) {
return function(e) {
obj[methodName](e.target, {'x': e.pageX, 'y': e.pageY}, e, oParams) === false && e.preventDefault()
}
}
)(this, methodName, oParams || null);
oNode.addEventListener( sEvent, handler, false );
return handler
}:
function(methodName, sEvent, oNode, oParams) {
var handler = (
function(obj, methodName, oParams) {
return function() {
var e = window.event,
t = document.documentElement,
r = {
'x': e.clientX + t.scrollLeft ,
'y': e.clientY + t.scrollTop
};
if (t = document.body) {
r.x += t.scrollLeft;
r.y += t.scrollTop
}
e.srcElement &&
obj[methodName](e.srcElement, r, e, oParams) === false &&
(e.returnValue = false)
}
}
)(this, methodName, oParams || null);
oNode.attachEvent('on'+sEvent, handler);
return handler
}
}