rsence 2.0.0.10.pre → 2.0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +10 -0
- data/INSTALL.rdoc +52 -86
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.rdoc +52 -49
- data/VERSION +1 -1
- data/bin/rsence +4 -6
- data/conf/default_conf.yaml +314 -305
- data/conf/default_strings.yaml +70 -71
- data/docs/ExampleGuiPlugin.rdoc +193 -0
- data/{js/comm/comm/autosync/js.inc → docs/JavascriptBundles.rdoc} +0 -0
- data/docs/PluginBundleInfo.rdoc +173 -0
- data/docs/PluginBundles.rdoc +96 -0
- data/docs/Values.rdoc +163 -0
- data/js/comm/{comm/autosync → autosync}/autosync.js +1 -2
- data/js/comm/{comm → autosync}/js.inc +0 -0
- data/js/comm/{comm/comm.js → comm.js} +1 -0
- data/js/comm/{comm/queue/js.inc → js.inc} +0 -0
- data/js/comm/jsloader/jsloader.js +2 -4
- data/js/comm/{comm/session → queue}/js.inc +0 -0
- data/js/comm/{comm/queue → queue}/queue.js +1 -0
- data/js/comm/{comm/sessionwatcher → session}/js.inc +0 -0
- data/js/comm/{comm/session → session}/session.js +4 -3
- data/js/comm/{comm/transporter → sessionwatcher}/js.inc +0 -0
- data/js/comm/{comm/sessionwatcher → sessionwatcher}/sessionwatcher.js +1 -0
- data/js/comm/{comm/urlresponder → transporter}/js.inc +0 -0
- data/js/comm/{comm/transporter → transporter}/transporter.js +1 -0
- data/js/comm/{comm/values → urlresponder}/js.inc +0 -0
- data/js/comm/{comm/urlresponder → urlresponder}/urlresponder.js +1 -0
- data/js/comm/{reloadapp → values}/js.inc +0 -0
- data/js/comm/{comm/values → values}/values.js +1 -0
- data/js/controls/button/button.js +10 -1
- data/js/controls/checkbox/checkbox.js +2 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -0
- data/js/controls/dialogs/sheet/sheet.js +1 -0
- data/js/controls/imageview/imageview.js +1 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +1 -0
- data/js/controls/progress/progressbar/progressbar.js +1 -0
- data/js/controls/progress/progressindicator/progressindicator.js +1 -0
- data/js/controls/radiobutton/radiobutton.js +3 -1
- data/js/controls/sliders/slider/slider.js +1 -0
- data/js/controls/sliders/vslider/vslider.js +1 -0
- data/js/controls/stepper/stepper.js +1 -0
- data/js/controls/stringview/stringview.js +2 -2
- data/js/controls/tab/tab.js +7 -5
- data/js/controls/textarea/textarea.js +1 -0
- data/js/controls/textcontrol/textcontrol.js +3 -1
- data/js/controls/uploader/uploader.js +1 -0
- data/js/controls/validatorview/validatorview.js +62 -59
- data/js/controls/window/window.js +1 -0
- data/js/core/class/class.js +2 -1
- data/js/core/elem/elem.js +27 -27
- data/js/core/event/event.js +3 -874
- data/js/{comm/sha → core/rsence_ns}/js.inc +0 -0
- data/js/core/rsence_ns/rsence_ns.js +15 -0
- data/js/{controls/datetime → datetime}/calendar/calendar.js +1 -0
- data/js/{comm/values/value → datetime/calendar}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.css +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.html +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/{controls/datetime → datetime}/datetimevalue/datetimevalue.js +1 -0
- data/js/{comm/values/valuematrix → datetime/datetimevalue}/js.inc +0 -0
- data/js/{controls/datetime/calendar → datetime/timesheet}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet/timesheet.js +1 -0
- data/js/{controls/datetime/datetimevalue → datetime/timesheet_item}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/timesheet_item.js +1 -0
- data/js/{controls/datetime/timesheet → datetime/timesheet_item_edit}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item_edit/timesheet_item_edit.js +1 -1
- data/js/foundation/application/application.js +1 -2
- data/js/foundation/control/control.js +1 -4
- data/js/foundation/control/controldefaults/controldefaults.js +1 -4
- data/js/foundation/control/dummyvalue/dummyvalue.js +1 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +1 -2
- data/js/foundation/control/eventresponder/eventresponder.js +11 -3
- data/js/{controls/datetime/timesheet_item → foundation/control/valuematrix}/js.inc +0 -0
- data/js/{comm/values → foundation/control}/valuematrix/valuematrix.js +2 -5
- data/js/foundation/control/valueresponder/valueresponder.js +3 -1
- data/js/foundation/eventmanager/eventmanager.js +884 -0
- data/js/{controls/datetime/timesheet_item_edit → foundation/eventmanager}/js.inc +0 -0
- data/js/foundation/geom/point/point.js +2 -2
- data/js/foundation/geom/rect/rect.js +1 -0
- data/js/foundation/json_renderer/json_renderer.js +2 -0
- data/js/foundation/system/system.js +2 -1
- data/js/foundation/thememanager/thememanager.js +29 -23
- data/js/{controls/lists/checkboxlist → foundation/value}/js.inc +0 -0
- data/js/{comm/values → foundation}/value/value.js +1 -0
- data/js/foundation/view/markupview/markupview.js +2 -1
- data/js/foundation/view/morphanimation/morphanimation.js +1 -0
- data/js/foundation/view/view.js +6 -12
- data/js/foundation/view/viewdefaults/viewdefaults.js +1 -0
- data/js/{controls/lists → lists}/checkboxlist/checkboxlist.js +1 -0
- data/js/{controls/lists/listitems → lists/checkboxlist}/js.inc +0 -0
- data/js/{controls/lists/radiobuttonlist → lists/listitems}/js.inc +0 -0
- data/js/{controls/lists → lists}/listitems/listitems.js +22 -3
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/{controls/lists → lists}/radiobuttonlist/radiobuttonlist.js +2 -12
- data/js/util/reloadapp/js.inc +0 -0
- data/js/{comm → util}/reloadapp/reloadapp.js +10 -8
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/{comm → util}/sha/sha.js +27 -33
- data/js/views/centerview/centerview.js +33 -3
- data/js/views/inlineview/inlineview.js +1 -0
- data/js/views/scrollview/scrollview.js +1 -0
- data/lib/conf/argv.rb +34 -22
- data/lib/conf/default.rb +165 -173
- data/lib/daemon/daemon.rb +9 -9
- data/lib/daemon/sigcomm.rb +4 -4
- data/lib/http/broker.rb +30 -27
- data/lib/http/rackup.rb +2 -3
- data/lib/http/request.rb +1 -2
- data/lib/http/response.rb +10 -10
- data/lib/plugins/dependencies.rb +2 -1
- data/lib/plugins/gui_plugin.rb +77 -50
- data/lib/plugins/guiparser.rb +26 -22
- data/lib/plugins/plugin.rb +207 -427
- data/lib/plugins/plugin_base.rb +162 -0
- data/lib/plugins/plugin_plugins.rb +21 -15
- data/lib/plugins/plugin_sqlite_db.rb +45 -20
- data/lib/plugins/pluginmanager.rb +10 -5
- data/lib/plugins/plugins.rb +65 -31
- data/lib/plugins/servlet.rb +74 -26
- data/lib/rsence.rb +32 -0
- data/lib/session/msg.rb +131 -96
- data/lib/session/sessionmanager.rb +5 -4
- data/lib/session/sessionstorage.rb +4 -3
- data/lib/transporter/transporter.rb +30 -21
- data/lib/util/gzstring.rb +4 -2
- data/lib/util/ruby19_fixes.rb +18 -0
- data/lib/values/hvalue.rb +139 -88
- data/lib/values/valuemanager.rb +60 -46
- data/plugins/client_pkg/client_pkg.rb +6 -5
- data/plugins/client_pkg/lib/client_pkg_build.rb +5 -5
- data/plugins/client_pkg/lib/client_pkg_serve.rb +8 -0
- data/plugins/index_html/index_html.rb +3 -1
- data/plugins/index_html/tmpl/index.html +2 -3
- data/plugins/main/js/main.js +84 -0
- data/plugins/main/main.rb +54 -27
- data/plugins/ticket/lib/common.rb +4 -2
- data/plugins/ticket/lib/favicon.rb +3 -2
- data/plugins/ticket/lib/file.rb +2 -2
- data/plugins/ticket/lib/img.rb +2 -2
- data/plugins/ticket/lib/objblob.rb +2 -2
- data/plugins/ticket/lib/rsrc.rb +2 -2
- data/plugins/ticket/lib/upload.rb +9 -8
- data/plugins/ticket/ticket.rb +141 -8
- data/setup/welcome/welcome.rb +1 -0
- metadata +76 -72
- data/lib/plugins/plugin_util.rb +0 -107
- data/plugins/index_html/tmpl/startup_index.html +0 -29
- data/plugins/main/js/riassence_ns.js +0 -87
- data/setup/legacy/info.yaml +0 -18
- data/setup/legacy/legacy.rb +0 -17
- data/setup/welcome/gui/welcome.yaml +0 -68
- data/setup/welcome/text/welcome.html +0 -8
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* RSence
|
2
|
+
* Copyright 2010 Riassence Inc.
|
3
|
+
* http://riassence.com/
|
4
|
+
*
|
5
|
+
* You should have received a copy of the GNU General Public License along
|
6
|
+
* with this software package. If not, contact licensing@riassence.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
// RSence namespace, nothing here yet.
|
10
|
+
// However, a future version of client_pkg will pack var's assigned like..
|
11
|
+
// var//RSence
|
12
|
+
// ..into this namespace.
|
13
|
+
// Additional logic for handling the namespaces will however be required.
|
14
|
+
var RSence = {};
|
15
|
+
|
@@ -11,6 +11,7 @@
|
|
11
11
|
** and weeks as rows. Its value is a date/time number specified in seconds
|
12
12
|
** since or before epoch (1970-01-01 00:00:00 UTC).
|
13
13
|
***/
|
14
|
+
var//RSence.DateTime
|
14
15
|
HCalendar = HControl.extend({
|
15
16
|
componentName: 'calendar',
|
16
17
|
weekdays_localized: ['Wk','Mon','Tue','Wed','Thu','Fri','Sat','Sun'],
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -14,12 +14,9 @@
|
|
14
14
|
* for extension reference.
|
15
15
|
*
|
16
16
|
**/
|
17
|
+
var//RSence.Foundation
|
17
18
|
HControl = HView.extend({
|
18
19
|
|
19
|
-
/** Component behaviour includes 'view' and 'control' as a default.
|
20
|
-
**/
|
21
|
-
componentBehaviour: ['view','control'],
|
22
|
-
|
23
20
|
/** A flag: when true, calls the +refreshValue+ method whenever
|
24
21
|
* +self.value+ is changed.
|
25
22
|
**/
|
@@ -10,6 +10,7 @@
|
|
10
10
|
** Define default setting here. Will be used, when no or invalid constructor
|
11
11
|
** options are supplied.
|
12
12
|
***/
|
13
|
+
var//RSence.Foundation
|
13
14
|
HControlDefaults = HClass.extend({
|
14
15
|
|
15
16
|
/** The default label. A label is the "visual value" of a component that
|
@@ -53,7 +54,3 @@ HControlDefaults = HClass.extend({
|
|
53
54
|
maxValue: 2147483648
|
54
55
|
|
55
56
|
});
|
56
|
-
|
57
|
-
// Alias for backwards-compatibility.
|
58
|
-
HComponentDefaults = HControlDefaults;
|
59
|
-
|
@@ -39,6 +39,7 @@
|
|
39
39
|
** +gainedActiveStatus+:: Called when the component gets activated.
|
40
40
|
** +lostActiveStatus+:: Called when the component gets deactivated.
|
41
41
|
***/
|
42
|
+
var//RSence.Foundation
|
42
43
|
HEventResponder = HClass.extend({
|
43
44
|
|
44
45
|
/** Default event listeners.
|
@@ -428,9 +429,16 @@ HEventResponder = HClass.extend({
|
|
428
429
|
**/
|
429
430
|
gainedActiveStatus: function(_lastActiveControl) {
|
430
431
|
|
431
|
-
|
432
|
-
|
433
|
-
|
432
|
+
var
|
433
|
+
_parents = this.parents,
|
434
|
+
_parentIdx = _parents.length-1;
|
435
|
+
|
436
|
+
if ( (HSystem.windowFocusMode === 1) && ( _parentIdx > 1 ) ) {
|
437
|
+
for( ; _parentIdx > 0; _parentIdx-- ){
|
438
|
+
// Send gainedActiveStatus to HWindow parent(s)
|
439
|
+
if(_parents[_parentIdx]['windowFocus']!==undefined){
|
440
|
+
_parents[_parentIdx].gainedActiveStatus();
|
441
|
+
}
|
434
442
|
}
|
435
443
|
}
|
436
444
|
|
File without changes
|
@@ -12,10 +12,9 @@
|
|
12
12
|
** A HRadioButton is an example of an class that implements
|
13
13
|
** the HValueMatrixInterface.
|
14
14
|
***/
|
15
|
+
var//RSence.Foundation
|
15
16
|
HValueMatrixInterface = {
|
16
17
|
|
17
|
-
componentBehaviour: ['view','control','matrix'],
|
18
|
-
|
19
18
|
/** = Description
|
20
19
|
* Standard +HControl+ constructor model.
|
21
20
|
* Passes parameters through to its base class's constructor,
|
@@ -62,14 +61,12 @@ HValueMatrixInterface = {
|
|
62
61
|
}
|
63
62
|
};
|
64
63
|
|
65
|
-
// Alias for backwards compatibility.
|
66
|
-
HValueMatrixComponentExtension = HValueMatrixInterface;
|
67
|
-
|
68
64
|
/*** = Description
|
69
65
|
** A HValueMatrix operates a number of components that operate on boolean
|
70
66
|
** values, like the HRadioButton using a separate value for selecting the
|
71
67
|
** index of selected items.
|
72
68
|
***/
|
69
|
+
var//RSence.Foundation
|
73
70
|
HValueMatrix = HClass.extend({
|
74
71
|
|
75
72
|
/** The constructor doesn't take parameters.
|
@@ -11,6 +11,7 @@
|
|
11
11
|
** Defines a minimal +HValue+ responder interface.
|
12
12
|
** It's implemented by default by +HControl+.
|
13
13
|
***/
|
14
|
+
var//RSence.Foundation
|
14
15
|
HValueResponder = HClass.extend({
|
15
16
|
|
16
17
|
/** = Description
|
@@ -73,5 +74,6 @@ HValueResponder = HClass.extend({
|
|
73
74
|
}
|
74
75
|
return this;
|
75
76
|
}
|
77
|
+
|
78
|
+
});
|
76
79
|
|
77
|
-
});
|
@@ -0,0 +1,884 @@
|
|
1
|
+
/* RSence
|
2
|
+
* Copyright 2007 Riassence Inc.
|
3
|
+
* http://riassence.com/
|
4
|
+
*
|
5
|
+
* You should have received a copy of the GNU General Public License along
|
6
|
+
* with this software package. If not, contact licensing@riassence.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*** = Description
|
10
|
+
** Mid-level event abstraction manager.
|
11
|
+
**
|
12
|
+
** This engine serves the HControl classes, so usually the existence of it
|
13
|
+
** is not obvious. The main interface to use it is the methods in HControl.
|
14
|
+
***/
|
15
|
+
var//RSence.Foundation
|
16
|
+
EVENT = {
|
17
|
+
|
18
|
+
// Default options for focus (all false)
|
19
|
+
_defaultFocusOptions: {
|
20
|
+
mouseMove: false,
|
21
|
+
mouseDown: false,
|
22
|
+
click: false,
|
23
|
+
mouseUp: false,
|
24
|
+
draggable: false,
|
25
|
+
droppable: false,
|
26
|
+
keyDown: false,
|
27
|
+
keyUp: false,
|
28
|
+
mouseWheel: false,
|
29
|
+
resize: false,
|
30
|
+
textEnter: false
|
31
|
+
},
|
32
|
+
|
33
|
+
/** = Description
|
34
|
+
* Array that keeps the last known global event status type.
|
35
|
+
*
|
36
|
+
* The format is an array with an index per "interesting" event value.
|
37
|
+
*
|
38
|
+
* = Indexes
|
39
|
+
* +EVENT.status[ EVENT.button1 ]+:: The state of the left mouse button.
|
40
|
+
* 0 when not pressed
|
41
|
+
* 1 when pressed.
|
42
|
+
*
|
43
|
+
* +EVENT.status[ EVENT.button2 ]+:: The state of the right mouse button.
|
44
|
+
* 0 when not pressed
|
45
|
+
* 1 when pressed.
|
46
|
+
*
|
47
|
+
* +EVENT.status[ EVENT.crsrX ]+:: The x-coordinate of the mouse cursor.
|
48
|
+
*
|
49
|
+
* +EVENT.status[ EVENT.crsrY ]+:: The y-coordinate of the mouse cursor.
|
50
|
+
*
|
51
|
+
* +EVENT.status[ EVENT.keysDown ]+:: A list of keycodes of all the keys
|
52
|
+
* currently held down in the order of
|
53
|
+
* occurrence (first pressed comes first,
|
54
|
+
* last pressed last).
|
55
|
+
*
|
56
|
+
* +EVENT.status[ EVENT.altKeyDown ]+:: The boolean status of the Alt
|
57
|
+
* modifier key being held down.
|
58
|
+
*
|
59
|
+
* +EVENT.status[ EVENT.ctrlKeyDown ]+:: The boolean status of the Ctrl
|
60
|
+
* modifier key being held down.
|
61
|
+
*
|
62
|
+
* +EVENT.status[ EVENT.shiftKeyDown ]+:: The boolean status of the Shift
|
63
|
+
* modifier key being held down.
|
64
|
+
*
|
65
|
+
**/
|
66
|
+
status: [false, false, 0, 0, [], false, false, false],
|
67
|
+
|
68
|
+
/** The index in the status array for the left mouse button.
|
69
|
+
**/
|
70
|
+
button1: 0,
|
71
|
+
|
72
|
+
/** The index in the status array for the right mouse button.
|
73
|
+
**/
|
74
|
+
button2: 1,
|
75
|
+
|
76
|
+
/** The index in the status array for the mouse cursor x coordinate.
|
77
|
+
**/
|
78
|
+
crsrX: 2,
|
79
|
+
|
80
|
+
/** The index in the status array for the mouse cursor y coordinate.
|
81
|
+
**/
|
82
|
+
crsrY: 3,
|
83
|
+
|
84
|
+
/** The index in the status array for the list of keycodes of all the
|
85
|
+
* keys currently held down in the order of occurrence (first pressed
|
86
|
+
* comes first, last pressed last).
|
87
|
+
*
|
88
|
+
**/
|
89
|
+
keysDown: 4,
|
90
|
+
|
91
|
+
/** The index in the status orray for the state of the Alt modifier key.
|
92
|
+
**/
|
93
|
+
altKeyDown: 5,
|
94
|
+
|
95
|
+
/** The index in the status orray for the state of the Ctrl modifier key.
|
96
|
+
**/
|
97
|
+
ctrlKeyDown: 6,
|
98
|
+
|
99
|
+
/** The index in the status orray for the state of the Shift modifier key.
|
100
|
+
**/
|
101
|
+
shiftKeyDown: 7,
|
102
|
+
|
103
|
+
/** A flag to disable, if your applications don't need drop events.
|
104
|
+
* Setting this to false when not needed improves overall performance,
|
105
|
+
* because the drop events need constant calculation of the mouse cursor
|
106
|
+
* location against all possible drop targets.
|
107
|
+
*
|
108
|
+
**/
|
109
|
+
enableDroppableChecks: true,
|
110
|
+
|
111
|
+
/** Initializes the members used by the drop -related events.
|
112
|
+
* This method is called from within EVENT and is never called,
|
113
|
+
* if enableDroppableChecks is false.
|
114
|
+
**/
|
115
|
+
startDroppable: function() {
|
116
|
+
var _this = EVENT;
|
117
|
+
_this.hovered = [];
|
118
|
+
// items currently under the mouse cursor
|
119
|
+
_this.hoverInterval = 50;
|
120
|
+
// 50 means send hover events at most with 50ms intervals
|
121
|
+
_this.hoverTimer = new Date().getTime();
|
122
|
+
// Time since last hover event triggered
|
123
|
+
},
|
124
|
+
|
125
|
+
/** Starts event listening.
|
126
|
+
**/
|
127
|
+
start: function() {
|
128
|
+
var _globalEventTargetElement = BROWSER_TYPE.ie?document:window,
|
129
|
+
_this = EVENT;
|
130
|
+
// _eventMap = [
|
131
|
+
Event.observe( _globalEventTargetElement, 'mousemove', _this.mouseMove );
|
132
|
+
Event.observe( _globalEventTargetElement, 'mouseup', _this.mouseUp );
|
133
|
+
Event.observe( _globalEventTargetElement, 'mousedown', _this.mouseDown );
|
134
|
+
Event.observe( _globalEventTargetElement, 'click', _this.click );
|
135
|
+
Event.observe( _globalEventTargetElement, 'keyup', _this.keyUp );
|
136
|
+
Event.observe( _globalEventTargetElement, 'keydown', _this.keyDown );
|
137
|
+
Event.observe( _globalEventTargetElement, 'keypress', _this.keyPress );
|
138
|
+
Event.observe( _globalEventTargetElement, 'contextmenu', _this.contextMenu );
|
139
|
+
Event.observe( _globalEventTargetElement, 'resize', _this.resize );
|
140
|
+
Event.observe( _globalEventTargetElement, 'mousewheel', _this.mouseWheel );
|
141
|
+
// ],
|
142
|
+
// i = 0;
|
143
|
+
// for (; i !== _eventMap.length; i++) {
|
144
|
+
// Event.observe(_globalEventTargetElement, _eventMap[i][0], _eventMap[i][1]);
|
145
|
+
// }
|
146
|
+
if (window.addEventListener) {
|
147
|
+
window.addEventListener('DOMMouseScroll', EVENT.mouseWheel, false);
|
148
|
+
window.addEventListener('resize', EVENT.resize, false);
|
149
|
+
}
|
150
|
+
//window.onmousewheel=document.onmousewheel=EVENT.mouseWheel;
|
151
|
+
_this.listeners = [];
|
152
|
+
// keep elemId buffer of all listeners
|
153
|
+
_this.focused = [];
|
154
|
+
// keep elemId buffer of all focused listeners
|
155
|
+
_this.resizeListeners = [];
|
156
|
+
// list of resize-event listeners
|
157
|
+
_this.coordListeners = [];
|
158
|
+
// global mouse movement listeners
|
159
|
+
_this.focusOptions = {};
|
160
|
+
// keep property lists by elemId
|
161
|
+
_this.dragItems = [];
|
162
|
+
// elemId of currently dragged items
|
163
|
+
if (_this.enableDroppableChecks) {
|
164
|
+
_this.startDroppable();
|
165
|
+
}
|
166
|
+
|
167
|
+
_this.topmostDroppable = null;
|
168
|
+
// the currently hovered element accepting droppable items
|
169
|
+
_this.textEnterCtrls = [];
|
170
|
+
// ID of controls with textfields
|
171
|
+
// position caching benefits performance, see coordCacheFlush
|
172
|
+
_this._coordCache = [];
|
173
|
+
_this._coordCacheFlag = true;
|
174
|
+
_this._lastCoordFlushTimeout = null;
|
175
|
+
|
176
|
+
_this.activeControl = null;
|
177
|
+
// control that currently has the focus
|
178
|
+
_this._lastKeyDown = null;
|
179
|
+
// the most recent keypress
|
180
|
+
},
|
181
|
+
|
182
|
+
/** Flushes the position cache by elemId, if no elemId is specified,
|
183
|
+
* everything is flushed.
|
184
|
+
**/
|
185
|
+
coordCacheFlush: function(_elemId) {
|
186
|
+
if (_elemId) {
|
187
|
+
EVENT._coordCache[_elemId] = null;
|
188
|
+
}
|
189
|
+
else {
|
190
|
+
EVENT._coordCache = [];
|
191
|
+
}
|
192
|
+
},
|
193
|
+
|
194
|
+
/** Registers the _ctrl object by event listener flags in _focusOptions.
|
195
|
+
**/
|
196
|
+
reg: function(_ctrl, _focusOptions) {
|
197
|
+
var _elemId,
|
198
|
+
_elem,
|
199
|
+
_this = EVENT,
|
200
|
+
_propIn;
|
201
|
+
// Binds the class to the element (so it can be called on the event)
|
202
|
+
_elemId = _ctrl.elemId;
|
203
|
+
_elem = ELEM.get(_elemId);
|
204
|
+
if (BROWSER_TYPE.ie) {
|
205
|
+
_elem.setAttribute('ctrl', _ctrl);
|
206
|
+
}
|
207
|
+
else {
|
208
|
+
_elem.ctrl = _ctrl;
|
209
|
+
}
|
210
|
+
_this.listeners[_elemId] = true;
|
211
|
+
_this.focused[_elemId] = false;
|
212
|
+
for (_propIn in _this._defaultFocusOptions) {
|
213
|
+
if (_focusOptions[_propIn] === undefined) {
|
214
|
+
_focusOptions[_propIn] = _defaultFocusOptions[_propIn];
|
215
|
+
}
|
216
|
+
}
|
217
|
+
_this.focusOptions[_elemId] = _focusOptions;
|
218
|
+
var _coordListenIdx = _this.coordListeners.indexOf(_elemId);
|
219
|
+
if (_focusOptions.mouseMove) {
|
220
|
+
if (_coordListenIdx === -1) {
|
221
|
+
_this.coordListeners.push(_elemId);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
else if (_coordListenIdx !== -1) {
|
225
|
+
_this.coordListeners.splice(_coordListenIdx, 1);
|
226
|
+
}
|
227
|
+
//console.log('focusOptions:',_focusOptions);
|
228
|
+
//console.log('focusOptions.textEnter: ',_focusOptions.textEnter);
|
229
|
+
if (_focusOptions.textEnter) {
|
230
|
+
if (_this.textEnterCtrls.indexOf(_ctrl.viewId) === -1) {
|
231
|
+
_this.textEnterCtrls.push(_ctrl.viewId);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
if (_focusOptions.resize) {
|
235
|
+
if (_this.resizeListeners.indexOf(_ctrl.viewId) === -1) {
|
236
|
+
_this.resizeListeners.push(_ctrl.viewId);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
Event.observe(_elem, 'mouseover', _this._mouseOver);
|
240
|
+
},
|
241
|
+
|
242
|
+
/** Unregisters the _ctrl object event listeners
|
243
|
+
**/
|
244
|
+
unreg: function(_ctrl) {
|
245
|
+
var _this = EVENT,
|
246
|
+
_elemId,
|
247
|
+
_elem;
|
248
|
+
if (_ctrl === this.activeControl) {
|
249
|
+
_this.changeActiveControl(null);
|
250
|
+
}
|
251
|
+
_elemId = _ctrl.elemId;
|
252
|
+
_elem = ELEM.get(_elemId);
|
253
|
+
|
254
|
+
_this._coordCache[_elemId] = null;
|
255
|
+
|
256
|
+
_this.listeners[_elemId] = false;
|
257
|
+
_this.focused[_elemId] = false;
|
258
|
+
_this.focusOptions[_elemId] = { ctrl: _ctrl };
|
259
|
+
var _coordListenIdx = _this.coordListeners.indexOf(_elemId);
|
260
|
+
if (_coordListenIdx !== -1) {
|
261
|
+
_this.coordListeners.splice(_coordListenIdx, 1);
|
262
|
+
}
|
263
|
+
|
264
|
+
var _textEnterIndex = _this.textEnterCtrls.indexOf(_ctrl.viewId);
|
265
|
+
if (_textEnterIndex !== -1) {
|
266
|
+
_this.textEnterCtrls.splice(_textEnterIndex, 1);
|
267
|
+
}
|
268
|
+
var _resizeIndex = _this.resizeListeners.indexOf(_ctrl.viewId);
|
269
|
+
if (_resizeIndex !== -1) {
|
270
|
+
_this.resizeListeners.splice(_resizeIndex, 1);
|
271
|
+
}
|
272
|
+
if (_elem !== undefined) {
|
273
|
+
Event.stopObserving(_elem, 'mouseover', _this._mouseOver);
|
274
|
+
}
|
275
|
+
},
|
276
|
+
|
277
|
+
/** Receiver of the onResize event.
|
278
|
+
* Delegates calls to the high-level event receivers of all
|
279
|
+
* controls registered for the event.
|
280
|
+
**/
|
281
|
+
resize: function(e) {
|
282
|
+
var i = 0,
|
283
|
+
_this = EVENT,
|
284
|
+
_ctrlID,
|
285
|
+
_ctrl;
|
286
|
+
for (; i < _this.resizeListeners.length; i++) {
|
287
|
+
_ctrlID = _this.resizeListeners[i];
|
288
|
+
_ctrl = HSystem.views[_ctrlID];
|
289
|
+
if (_ctrl['resize']) {
|
290
|
+
_ctrl.resize();
|
291
|
+
}
|
292
|
+
if (_ctrl['onResize']) {
|
293
|
+
_ctrl.onResize();
|
294
|
+
}
|
295
|
+
}
|
296
|
+
},
|
297
|
+
|
298
|
+
/* Element-specific mouse over/out event receiver. */
|
299
|
+
_mouseOver: function(e) {
|
300
|
+
if (!Event.element) {
|
301
|
+
return;
|
302
|
+
}
|
303
|
+
var _that = Event.element(e);
|
304
|
+
while (_that && _that.ctrl === undefined) {
|
305
|
+
_that = _that.parentNode;
|
306
|
+
}
|
307
|
+
if (!_that) {
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
var _this = _that.ctrl;
|
311
|
+
EVENT.focus(_this);
|
312
|
+
Event.stop(e);
|
313
|
+
},
|
314
|
+
|
315
|
+
/* Element-specific mouse over/out event receiver. */
|
316
|
+
_mouseOut: function(e) {
|
317
|
+
if (!Event.element) {
|
318
|
+
return;
|
319
|
+
}
|
320
|
+
var _that = Event.element(e);
|
321
|
+
while (_that && _that.ctrl === undefined) {
|
322
|
+
_that = _that.parentNode;
|
323
|
+
}
|
324
|
+
if (!_that) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
var _this = _that.ctrl;
|
328
|
+
EVENT.blur(_this);
|
329
|
+
Event.stop(e);
|
330
|
+
},
|
331
|
+
|
332
|
+
/** Mid-level focus manager.
|
333
|
+
* Gets called on the onMouseOver event.
|
334
|
+
* Starts listening for onMouseOut to blur.
|
335
|
+
* Delegates focus calls to the high-level event receivers of all
|
336
|
+
* enabled controls registered.
|
337
|
+
**/
|
338
|
+
focus: function(_ctrl) {
|
339
|
+
var _this = EVENT,
|
340
|
+
_elemId = _ctrl.elemId,
|
341
|
+
_elem = ELEM.get(_elemId);
|
342
|
+
if (_this.focused[_elemId] === false ){ // && _this.dragItems.indexOf(_elemId) === -1) {
|
343
|
+
Event.stopObserving(_elem, 'mouseover', _this._mouseOver);
|
344
|
+
Event.observe(_elem, 'mouseout', _this._mouseOut);
|
345
|
+
_this.focused[_elemId] = true;
|
346
|
+
if (_ctrl['focus']) {
|
347
|
+
_ctrl.focus();
|
348
|
+
}
|
349
|
+
}
|
350
|
+
},
|
351
|
+
|
352
|
+
/** Mid-level blur (focus lost) manager.
|
353
|
+
* Gets called on the onMouseOut event.
|
354
|
+
* Starts listening for onMouseOver to (re)focus.
|
355
|
+
* Delegates blur calls to the high-level event receivers of all
|
356
|
+
* enabled controls registered.
|
357
|
+
**/
|
358
|
+
blur: function(_ctrl) {
|
359
|
+
var _this = EVENT,
|
360
|
+
_elemId = _ctrl.elemId,
|
361
|
+
_elem = ELEM.get(_elemId);
|
362
|
+
if (_this.focused[_elemId] === true ){ // && _this.dragItems.indexOf(_elemId) === -1) {
|
363
|
+
Event.stopObserving(_elem, 'mouseout', _this._mouseOut);
|
364
|
+
Event.observe(_elem, 'mouseover', _this._mouseOver);
|
365
|
+
_this.focused[_elemId] = false;
|
366
|
+
if (_ctrl['blur']) {
|
367
|
+
_ctrl.blur();
|
368
|
+
}
|
369
|
+
}
|
370
|
+
},
|
371
|
+
|
372
|
+
/** Mid-level mouse movement manager.
|
373
|
+
* Gets called on the onMouseMove event.
|
374
|
+
* Delegates the following calls to the high-level event receivers of all
|
375
|
+
* enabled controls registered, depending on the events they registered:
|
376
|
+
* - drag
|
377
|
+
* - mouseMove
|
378
|
+
* - endHover
|
379
|
+
* - startHover
|
380
|
+
*
|
381
|
+
**/
|
382
|
+
mouseMove: function(e) {
|
383
|
+
var _this = EVENT,
|
384
|
+
x = Event.pointerX(e),
|
385
|
+
y = Event.pointerY(e),
|
386
|
+
_currentlyDragging = _this.flushMouseMove(x, y);
|
387
|
+
_this.status[_this.crsrX] = x;
|
388
|
+
_this.status[_this.crsrY] = y;
|
389
|
+
_this._modifiers(e);
|
390
|
+
// might work
|
391
|
+
if (_currentlyDragging) {
|
392
|
+
Event.stop(e);
|
393
|
+
}
|
394
|
+
// Only prevent default action when we are dragging something.
|
395
|
+
},
|
396
|
+
|
397
|
+
/** Processes dragging calculations, triggered by mouseMove.
|
398
|
+
**/
|
399
|
+
flushMouseMove: function(x, y) {
|
400
|
+
var _this = EVENT,
|
401
|
+
_currentlyDragging = false,
|
402
|
+
i = 0,
|
403
|
+
j,
|
404
|
+
_elemId,
|
405
|
+
_ctrl;
|
406
|
+
|
407
|
+
clearTimeout(_this._lastCoordFlushTimeout);
|
408
|
+
|
409
|
+
// send drag event to all drag-interested ctrls
|
410
|
+
for (; i !== _this.dragItems.length; i++) {
|
411
|
+
_elemId = _this.dragItems[i];
|
412
|
+
_this.focusOptions[_elemId].ctrl.drag(x, y);
|
413
|
+
_this.coordCacheFlush(_elemId);
|
414
|
+
_currentlyDragging = true;
|
415
|
+
}
|
416
|
+
|
417
|
+
if (_this.enableDroppableChecks) {
|
418
|
+
// Check which items are under the mouse coordinates now.
|
419
|
+
if (new Date().getTime() > _this.hoverTimer + _this.hoverInterval) {
|
420
|
+
// sends mouseMove pseudo-events to ctrls interested
|
421
|
+
for (i = 0; i !== _this.coordListeners.length; i++) {
|
422
|
+
_elemId = _this.coordListeners[i];
|
423
|
+
_ctrl = _this.focusOptions[_elemId].ctrl;
|
424
|
+
_ctrl.mouseMove(x, y);
|
425
|
+
}
|
426
|
+
if (_this.enableDroppableChecks) {
|
427
|
+
_this._updateHoverItems();
|
428
|
+
}
|
429
|
+
// sends drag&drop pseudo-events
|
430
|
+
var _wasTopmostDroppable;
|
431
|
+
for (i = 0; i !== _this.dragItems.length; i++) {
|
432
|
+
// Find the current droppable while dragging.
|
433
|
+
_wasTopmostDroppable = _this.topmostDroppable;
|
434
|
+
_this.topmostDroppable = null;
|
435
|
+
_elemId = _this.dragItems[i];
|
436
|
+
_ctrl = _this.focusOptions[_elemId].ctrl;
|
437
|
+
|
438
|
+
// Check for a drop target from the currently hovered items
|
439
|
+
var _hoverIndex,
|
440
|
+
_dropCtrl;
|
441
|
+
for (j = 0; j !== _this.hovered.length; j++) {
|
442
|
+
_hoverIndex = _this.hovered[j];
|
443
|
+
if (_hoverIndex !== _elemId && _this.focusOptions[_hoverIndex].ctrl) {
|
444
|
+
_dropCtrl = _this.focusOptions[_hoverIndex].ctrl;
|
445
|
+
if (!_this.topmostDroppable ||
|
446
|
+
// First time
|
447
|
+
_dropCtrl.zIndex() > _this.topmostDroppable.zIndex() ||
|
448
|
+
// Z beaten
|
449
|
+
_dropCtrl.supr === _this.topmostDroppable) {
|
450
|
+
// subview
|
451
|
+
if (_this.focusOptions[_dropCtrl.elemId].droppable) {
|
452
|
+
_this.topmostDroppable = _dropCtrl;
|
453
|
+
// Finally, the item must accept drop events.
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
// Topmost item has changed, send startHover or endHover to the droppable.
|
460
|
+
if (_wasTopmostDroppable !== _this.topmostDroppable) {
|
461
|
+
if (_wasTopmostDroppable) {
|
462
|
+
_wasTopmostDroppable.endHover(_ctrl);
|
463
|
+
}
|
464
|
+
if (_this.topmostDroppable) {
|
465
|
+
_this.topmostDroppable.startHover(_ctrl);
|
466
|
+
}
|
467
|
+
}
|
468
|
+
}
|
469
|
+
_this.hoverTimer = new Date().getTime();
|
470
|
+
}
|
471
|
+
else {
|
472
|
+
_this._lastCoordFlushTimeout = setTimeout(
|
473
|
+
function(){
|
474
|
+
EVENT.flushMouseMove(x,y);
|
475
|
+
}, _this.hoverInterval
|
476
|
+
);
|
477
|
+
}
|
478
|
+
}
|
479
|
+
return _currentlyDragging;
|
480
|
+
},
|
481
|
+
|
482
|
+
// Loops through all registered items and store indices of elements
|
483
|
+
// that are currenly under the mouse cursor in .hovered array. Uses
|
484
|
+
// cached position and dimensions value when possible.
|
485
|
+
_updateHoverItems: function() {
|
486
|
+
var _this = EVENT,
|
487
|
+
x = _this.status[_this.crsrX],
|
488
|
+
y = _this.status[_this.crsrY],
|
489
|
+
i = 0,
|
490
|
+
_ctrl,
|
491
|
+
_elem,
|
492
|
+
_pos,
|
493
|
+
_size,
|
494
|
+
_coords;
|
495
|
+
_this.hovered = [];
|
496
|
+
for (; i !== _this.listeners.length; i++) {
|
497
|
+
if (!_this.listeners[i] || !_this.focusOptions[i].ctrl) {
|
498
|
+
continue;
|
499
|
+
}
|
500
|
+
_ctrl = _this.focusOptions[i].ctrl;
|
501
|
+
_elem = ELEM.get(i);
|
502
|
+
if (!_this._coordCacheFlag || !_this._coordCache[i]) {
|
503
|
+
_pos = ELEM.getVisiblePosition(_ctrl.elemId);
|
504
|
+
// [x,y]
|
505
|
+
_size = ELEM.getVisibleSize(_ctrl.elemId);
|
506
|
+
// [w,h]
|
507
|
+
_this._coordCache[i] = [_pos[0], _pos[1], _size[0], _size[1]];
|
508
|
+
}
|
509
|
+
_coords = _this._coordCache[i];
|
510
|
+
|
511
|
+
// Is the mouse pointer inside the element's rectangle?
|
512
|
+
if (x >= _coords[0] && x <= _coords[0] + _coords[2] && y >= _coords[1] && y <= _coords[1] + _coords[3]) {
|
513
|
+
_this.hovered.push(i);
|
514
|
+
}
|
515
|
+
}
|
516
|
+
},
|
517
|
+
|
518
|
+
/** = Description
|
519
|
+
* Starts dragging the control given.
|
520
|
+
*
|
521
|
+
* Call this method to start dragging another component.
|
522
|
+
*
|
523
|
+
* = Parameters
|
524
|
+
* +_ctrl+:: An object that uses the HControl API, becomes new drag target.
|
525
|
+
*
|
526
|
+
**/
|
527
|
+
startDragging: function(_ctrl) {
|
528
|
+
var _this = EVENT;
|
529
|
+
_this.dragItems = [_ctrl.elemId];
|
530
|
+
_this.focus(_ctrl);
|
531
|
+
_this.changeActiveControl(_ctrl);
|
532
|
+
_ctrl.startDrag(_this.status[_this.crsrX], _this.status[_this.crsrY]);
|
533
|
+
},
|
534
|
+
|
535
|
+
/** Mid-level mouse button press manager.
|
536
|
+
* Gets called on the onMouseDown event.
|
537
|
+
* Delegates the following calls to the high-level event receivers of all
|
538
|
+
* enabled controls registered, depending on the events they registered:
|
539
|
+
* - mouseDown
|
540
|
+
* - startDrag
|
541
|
+
*
|
542
|
+
**/
|
543
|
+
mouseDown: function(e, _isLeftButton) {
|
544
|
+
var _this = EVENT,
|
545
|
+
_didStartDrag = false,
|
546
|
+
x = _this.status[_this.crsrX],
|
547
|
+
y = _this.status[_this.crsrY],
|
548
|
+
i = 0,
|
549
|
+
|
550
|
+
// Unset the active control when clicking on anything.
|
551
|
+
_newActiveControl = null,
|
552
|
+
|
553
|
+
// The startDrag and mouseDown event receivers are first collected into
|
554
|
+
// these arrays and the events are sent after the active control status has
|
555
|
+
// been changed.
|
556
|
+
_startDragElementIds = [],
|
557
|
+
_mouseDownElementIds = [];
|
558
|
+
|
559
|
+
_this._modifiers(e);
|
560
|
+
if (_isLeftButton === undefined) {
|
561
|
+
_isLeftButton = Event.isLeftClick(e);
|
562
|
+
}
|
563
|
+
if (_isLeftButton) {
|
564
|
+
_this.status[_this.button1] = true;
|
565
|
+
}
|
566
|
+
else {
|
567
|
+
_this.status[_this.button2] = true;
|
568
|
+
}
|
569
|
+
|
570
|
+
for (; i !== _this.focused.length; i++) {
|
571
|
+
if (_this.focused[i] === true) {
|
572
|
+
// Set the active control to the currently focused item.
|
573
|
+
if (_this.focusOptions[i].ctrl.enabled) {
|
574
|
+
_newActiveControl = _this.focusOptions[i].ctrl;
|
575
|
+
}
|
576
|
+
if ((_this.focusOptions[i].draggable === true) && _this.dragItems.indexOf(i) === -1) {
|
577
|
+
_startDragElementIds.push(i);
|
578
|
+
}
|
579
|
+
else if (_this.focusOptions[i].mouseDown === true) {
|
580
|
+
_mouseDownElementIds.push(i);
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|
584
|
+
// Handle the active control selection.
|
585
|
+
if (_newActiveControl) {
|
586
|
+
_this.changeActiveControl(_newActiveControl);
|
587
|
+
}
|
588
|
+
// Call the mouseDown and startDrag events after the active control change has been handled.
|
589
|
+
for (i = 0; i !== _startDragElementIds.length; i++) {
|
590
|
+
_this.dragItems.push(_startDragElementIds[i]);
|
591
|
+
_this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y);
|
592
|
+
_didStartDrag = true;
|
593
|
+
}
|
594
|
+
|
595
|
+
var _stopEvent = _mouseDownElementIds.length;
|
596
|
+
for (i = 0; i !== _mouseDownElementIds.length; i++) {
|
597
|
+
if (_this.focusOptions[_mouseDownElementIds[i]].ctrl.mouseDown(x, y, _isLeftButton)) {
|
598
|
+
_stopEvent--;
|
599
|
+
}
|
600
|
+
}
|
601
|
+
if (_didStartDrag) {
|
602
|
+
// Remove possible selections.
|
603
|
+
document.body.focus();
|
604
|
+
// Prevent text selection in MSIE when dragging starts.
|
605
|
+
_this._storedOnSelectStart = document.onselectstart;
|
606
|
+
document.onselectstart = function() {
|
607
|
+
return false;
|
608
|
+
};
|
609
|
+
Event.stop(e);
|
610
|
+
}
|
611
|
+
// Stop the event only when we are hovering over some control, allows normal DOM events to co-exist.
|
612
|
+
if (this.enableDroppableChecks) {
|
613
|
+
if ((_stopEvent === 0) && (_this.hovered.length !== 0) && (_newActiveControl && (_newActiveControl.textElemId === false))) {
|
614
|
+
Event.stop(e);
|
615
|
+
}
|
616
|
+
}
|
617
|
+
return true;
|
618
|
+
},
|
619
|
+
|
620
|
+
/** Mid-level mouse click manager.
|
621
|
+
* Gets called on the onClick event.
|
622
|
+
* Delegates click calls to the high-level event receivers of all
|
623
|
+
* controls registered for that event.
|
624
|
+
*
|
625
|
+
**/
|
626
|
+
click: function(e, _isLeftButton) {
|
627
|
+
var _this = EVENT,
|
628
|
+
x = _this.status[_this.crsrX],
|
629
|
+
y = _this.status[_this.crsrY],
|
630
|
+
i = 0,
|
631
|
+
// Unset the active control when clicking on anything.
|
632
|
+
_newActiveControl = null,
|
633
|
+
// The startDrag and mouseDown event receivers are first collected into
|
634
|
+
// these arrays and the events are sent after the active control status has
|
635
|
+
// been changed.
|
636
|
+
_clickElementIds = [];
|
637
|
+
_this._modifiers(e);
|
638
|
+
if (_isLeftButton === undefined) {
|
639
|
+
_isLeftButton = Event.isLeftClick(e);
|
640
|
+
}
|
641
|
+
if (_isLeftButton) {
|
642
|
+
_this.status[_this.button1] = true;
|
643
|
+
}
|
644
|
+
else {
|
645
|
+
_this.status[_this.button2] = true;
|
646
|
+
}
|
647
|
+
for (; i !== _this.focused.length; i++) {
|
648
|
+
if (_this.focused[i] === true) {
|
649
|
+
// Set the active control to the currently focused item.
|
650
|
+
if (_this.focusOptions[i].ctrl.enabled) {
|
651
|
+
_newActiveControl = _this.focusOptions[i].ctrl;
|
652
|
+
}
|
653
|
+
if (_this.focusOptions[i].click === true) {
|
654
|
+
_clickElementIds.push(i);
|
655
|
+
}
|
656
|
+
}
|
657
|
+
}
|
658
|
+
// Handle the active control selection.
|
659
|
+
if (_newActiveControl) {
|
660
|
+
_this.changeActiveControl(_newActiveControl);
|
661
|
+
}
|
662
|
+
var _stopEvent = _clickElementIds.length;
|
663
|
+
for (i = 0; i !== _clickElementIds.length; i++) {
|
664
|
+
if (_this.focusOptions[_clickElementIds[i]].ctrl.click(x, y, _isLeftButton)) {
|
665
|
+
_stopEvent--;
|
666
|
+
}
|
667
|
+
}
|
668
|
+
// Stop the event only when we are hovering over some control, allows normal DOM events to co-exist.
|
669
|
+
if (_this.enableDroppableChecks) {
|
670
|
+
if ((_stopEvent === 0) && (_this.hovered.length !== 0) && (_newActiveControl && (_newActiveControl.textElemId === false))) {
|
671
|
+
Event.stop(e);
|
672
|
+
}
|
673
|
+
}
|
674
|
+
//if(_this.hovered.length!==0){Event.stop(e);}
|
675
|
+
return true;
|
676
|
+
},
|
677
|
+
|
678
|
+
/** Changes active ctrl.
|
679
|
+
* The previous active ctrl gets the _lostActiveStatus pseudo-event,
|
680
|
+
* The new active ctrl gets the _gainedActiveStatus pseudo-event
|
681
|
+
**/
|
682
|
+
changeActiveControl: function(_ctrl) {
|
683
|
+
//console.log('EVENT.changeActiveControl: ',_ctrl);
|
684
|
+
var _this = EVENT,
|
685
|
+
// Store the currently active control so we can inform it, if it no longer is the active control.
|
686
|
+
_prevActiveCtrl = _this.activeControl;
|
687
|
+
// Did the active control change?
|
688
|
+
if (_ctrl !== _prevActiveCtrl) {
|
689
|
+
if (_prevActiveCtrl) {
|
690
|
+
// Previously active control just lost the active status.
|
691
|
+
_prevActiveCtrl.active = false;
|
692
|
+
_prevActiveCtrl._lostActiveStatus(_ctrl);
|
693
|
+
}
|
694
|
+
_this.activeControl = null;
|
695
|
+
if (_ctrl) {
|
696
|
+
// A new control gained the active status.
|
697
|
+
_ctrl.active = true;
|
698
|
+
_this.activeControl = _ctrl;
|
699
|
+
_ctrl._gainedActiveStatus(_prevActiveCtrl);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
},
|
703
|
+
|
704
|
+
|
705
|
+
/** Mid-level mouse button release manager.
|
706
|
+
* Gets called on the onMouseUp event.
|
707
|
+
* Delegates the following calls to the high-level event receivers of all
|
708
|
+
* enabled controls registered, depending on the events they registered:
|
709
|
+
* - mouseUp
|
710
|
+
* - endHover
|
711
|
+
* - drop
|
712
|
+
* - endDrag
|
713
|
+
*
|
714
|
+
**/
|
715
|
+
mouseUp: function(e) {
|
716
|
+
var _this = EVENT,
|
717
|
+
_didEndDrag = false,
|
718
|
+
_isLeftButton = Event.isLeftClick(e),
|
719
|
+
x = _this.status[_this.crsrX],
|
720
|
+
y = _this.status[_this.crsrY],
|
721
|
+
_elemId,
|
722
|
+
_ctrl,
|
723
|
+
i = 0;
|
724
|
+
_this._modifiers(e);
|
725
|
+
_this.status[_this.button1] = false;
|
726
|
+
_this.status[_this.button2] = false;
|
727
|
+
// Send endDrag for the currently dragged items even when they don't have focus, and clear the drag item array.
|
728
|
+
for (; i !== _this.dragItems.length; i++) {
|
729
|
+
_elemId = _this.dragItems[i];
|
730
|
+
_ctrl = _this.focusOptions[_elemId].ctrl;
|
731
|
+
_ctrl.endDrag(x, y);
|
732
|
+
_didEndDrag = true;
|
733
|
+
// If the mouse slipped off the dragged item before the mouse button was released, blur the item manually
|
734
|
+
if (_this.enableDroppableChecks) {
|
735
|
+
_this._updateHoverItems();
|
736
|
+
if (_this.hovered.indexOf(_elemId) === -1) {
|
737
|
+
_this.blur(_ctrl);
|
738
|
+
}
|
739
|
+
}
|
740
|
+
// If there is a drop target in the currently hovered items, send drop to it.
|
741
|
+
if (_this.topmostDroppable) {
|
742
|
+
// Droppable found at the release point.
|
743
|
+
_this.topmostDroppable.endHover(_ctrl);
|
744
|
+
_this.topmostDroppable.drop(_ctrl);
|
745
|
+
_this.topmostDroppable = null;
|
746
|
+
}
|
747
|
+
}
|
748
|
+
_this.dragItems = [];
|
749
|
+
// Restore MSIE's ability to select text after dragging has ended.
|
750
|
+
if (_didEndDrag) {
|
751
|
+
document.onselectstart = _this._storedOnSelectStart;
|
752
|
+
}
|
753
|
+
// Check for mouseUp listeners.
|
754
|
+
for (i = 0; i !== _this.focused.length; i++) {
|
755
|
+
if (_this.focused[i] === true) {
|
756
|
+
if (_this.focusOptions[i].mouseUp === true) {
|
757
|
+
_this.focusOptions[i].ctrl.mouseUp(x, y, _isLeftButton);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
}
|
761
|
+
return true;
|
762
|
+
},
|
763
|
+
|
764
|
+
|
765
|
+
/** Mid-level key press manager.
|
766
|
+
* Gets called on the onKeyDown event.
|
767
|
+
* Delegates keyDown calls to the high-level event receivers of all
|
768
|
+
* controls registered for that event.
|
769
|
+
**/
|
770
|
+
keyDown: function(e) {
|
771
|
+
var _this = EVENT,
|
772
|
+
_theKeyCode = e.keyCode;
|
773
|
+
_this._modifiers(e);
|
774
|
+
if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
|
775
|
+
Event.stop(e);
|
776
|
+
// Workaround for msie rapid fire keydown
|
777
|
+
if (_this._lastKeyDown !== _theKeyCode) {
|
778
|
+
_this.activeControl.keyDown(_theKeyCode);
|
779
|
+
}
|
780
|
+
}
|
781
|
+
// Insert key to the realtime array, remove in keyUp
|
782
|
+
if (_this.status[_this.keysDown].indexOf(_theKeyCode) === -1) {
|
783
|
+
_this.status[_this.keysDown].push(_theKeyCode);
|
784
|
+
}
|
785
|
+
_this._lastKeyDown = _theKeyCode;
|
786
|
+
},
|
787
|
+
|
788
|
+
|
789
|
+
/** Mid-level key release manager.
|
790
|
+
* Gets called on the onKeyUp event.
|
791
|
+
* Delegates keyUp calls to the high-level event receivers of all
|
792
|
+
* controls registered for that event.
|
793
|
+
* Also delegates the textEnter calls to all controls
|
794
|
+
* registered for that event.
|
795
|
+
**/
|
796
|
+
keyUp: function(e) {
|
797
|
+
var _this = EVENT,
|
798
|
+
_theKeyCode = e.keyCode,
|
799
|
+
_keyCodeIndex,
|
800
|
+
i = 0,
|
801
|
+
_ctrlId,
|
802
|
+
_ctrl;
|
803
|
+
_this._modifiers(e);
|
804
|
+
_this._lastKeyDown = null;
|
805
|
+
if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyUp === true) {
|
806
|
+
_this.activeControl.keyUp(_theKeyCode);
|
807
|
+
}
|
808
|
+
for (; i < _this.textEnterCtrls.length; i++) {
|
809
|
+
_ctrlId = _this.textEnterCtrls[i];
|
810
|
+
_ctrl = HSystem.views[_ctrlId];
|
811
|
+
if (_ctrl.textEnter) {
|
812
|
+
_ctrl.textEnter();
|
813
|
+
}
|
814
|
+
}
|
815
|
+
// Remove the key from the realtime array, inserted in keyDown
|
816
|
+
_keyCodeIndex = _this.status[_this.keysDown].indexOf(_theKeyCode);
|
817
|
+
if (_keyCodeIndex !== -1) {
|
818
|
+
_this.status[_this.keysDown].splice(_keyCodeIndex, 1);
|
819
|
+
}
|
820
|
+
},
|
821
|
+
|
822
|
+
/* Prevents the onKeyPress event (key being hold down; we don't need that event) */
|
823
|
+
keyPress: function(e) {
|
824
|
+
var _this = EVENT;
|
825
|
+
if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
|
826
|
+
Event.stop(e);
|
827
|
+
}
|
828
|
+
},
|
829
|
+
|
830
|
+
|
831
|
+
/** Mid-level mouse scroll wheel event manager.
|
832
|
+
* Delegates mouseWheel calls to the high-level event receivers of all
|
833
|
+
* controls registered for that event.
|
834
|
+
**/
|
835
|
+
mouseWheel: function(e) {
|
836
|
+
var _this = EVENT,
|
837
|
+
_delta = 0,
|
838
|
+
i = 0;
|
839
|
+
if (!e) {
|
840
|
+
e = window.event;
|
841
|
+
}
|
842
|
+
if (e.wheelDelta) {
|
843
|
+
_delta = 0 - (e.wheelDelta / 120);
|
844
|
+
}
|
845
|
+
else if (e.detail) {
|
846
|
+
_delta = 0 - (e.detail / 3);
|
847
|
+
}
|
848
|
+
if (BROWSER_TYPE.opera || BROWSER_TYPE.safari) {
|
849
|
+
_delta = 0 - _delta;
|
850
|
+
}
|
851
|
+
for (; i !== _this.focused.length; i++) {
|
852
|
+
if (_this.focused[i] === true) {
|
853
|
+
if (_this.focusOptions[i].mouseWheel === true) {
|
854
|
+
Event.stop(e);
|
855
|
+
_this.focusOptions[i].ctrl.mouseWheel(_delta);
|
856
|
+
}
|
857
|
+
}
|
858
|
+
}
|
859
|
+
},
|
860
|
+
|
861
|
+
/* Alternative right button detection, wrapper for the mouseDown method */
|
862
|
+
contextMenu: function(e) {
|
863
|
+
EVENT.mouseDown(e, false);
|
864
|
+
Event.stop(e);
|
865
|
+
},
|
866
|
+
|
867
|
+
/* Handle the event modifiers. */
|
868
|
+
_modifiers: function(e) {
|
869
|
+
var _this = EVENT;
|
870
|
+
_this.status[_this.altKeyDown] = e.altKey;
|
871
|
+
_this.status[_this.ctrlKeyDown] = e.ctrlKey;
|
872
|
+
_this.status[_this.shiftKeyDown] = e.shiftKey;
|
873
|
+
}
|
874
|
+
|
875
|
+
};
|
876
|
+
|
877
|
+
/** Starts the only instance
|
878
|
+
*/
|
879
|
+
LOAD(
|
880
|
+
function() {
|
881
|
+
EVENT.start();
|
882
|
+
}
|
883
|
+
);
|
884
|
+
|