js/foundation/eventmanager/eventmanager.js in rsence-2.1.11 vs js/foundation/eventmanager/eventmanager.js in rsence-2.2.0
- old
+ new
@@ -273,11 +273,13 @@
if(_init){
Event.observe(_elem, 'mouseover', _this._mouseOver);
}
if(_ctrl.drawn){
_this._updateHoverItems();
- (_this.hovered.length !== 0) && (_this.hovered.indexOf(_ctrl.elemId) === _this.hovered.length-1) && _this.focus(_ctrl);
+ if (_this.hovered.length !== 0 && _this.hovered.indexOf(_ctrl.elemId) === _this.hovered.length-1){
+ _this.focus(_ctrl);
+ }
}
},
/** Unregisters the _ctrl object event listeners
**/
@@ -579,10 +581,11 @@
* = Parameters
* +_ctrl+:: An object that uses the HControl API, becomes new drag target.
*
**/
startDragging: function(_ctrl, _isLeftButton) {
+ // console.log('startDragging');
var _this = EVENT;
_this.dragItems = [_ctrl.elemId];
_this.focus(_ctrl);
_this.changeActiveControl(_ctrl);
_ctrl.startDrag( _this.status[_this.crsrX], _this.status[_this.crsrY], _isLeftButton );
@@ -595,25 +598,27 @@
* - mouseDown
* - startDrag
*
**/
mouseDown: function(e, _isLeftButton) {
- var _this = EVENT,
- _didStartDrag = false,
- x = _this.status[_this.crsrX],
- y = _this.status[_this.crsrY],
- i = 0,
-
- // Unset the active control when clicking on anything.
- _newActiveControl = null,
-
- // The startDrag and mouseDown event receivers are first collected into
- // these arrays and the events are sent after the active control status has
- // been changed.
- _startDragElementIds = [],
- _mouseDownElementIds = [];
+ // console.log('mouseDown');
+ var
+ _this = EVENT,
+ _didStartDrag = false,
+ x = _this.status[_this.crsrX],
+ y = _this.status[_this.crsrY],
+ i = 0,
+ // Unset the active control when clicking on anything.
+ _newActiveControl = null,
+
+ // The startDrag and mouseDown event receivers are first collected into
+ // these arrays and the events are sent after the active control status has
+ // been changed.
+ _startDragElementIds = [],
+ _mouseDownElementIds = [];
+
_this._modifiers(e);
if (_isLeftButton === undefined) {
_isLeftButton = Event.isLeftClick(e);
}
if (_isLeftButton) {
@@ -663,25 +668,36 @@
return false;
};
Event.stop(e);
}
// Stop the event only when we are hovering over some control, allows normal DOM events to co-exist.
- if (this.enableDroppableChecks) {
- if ((_stopEvent === 0) && (_this.hovered.length !== 0) && _newActiveControl) {
+ if (_this.enableDroppableChecks) {
+ // console.log('stopEvent:',_stopEvent,', hoverlen:',(_this.hovered.length !== 0),', newActive:',_newActiveControl);
+ if ( (_mouseDownElementIds.length !== 0) && (_stopEvent === 0) && (_this.hovered.length !== 0) && _newActiveControl) {
Event.stop(e);
}
}
+ // else {
+ // console.log('not enableDroppableChecks');
+ // }
return true;
},
/** Mid-level mouse click manager.
* Gets called on the onClick event.
* Delegates click calls to the high-level event receivers of all
* controls registered for that event.
*
**/
click: function(e, _isLeftButton) {
+ // if( new Date().getTime() - EVENT.lastMouseUp < 10 ){
+ // console.log('should prevent click?');
+ // // return false; // prevent click and mousedown coexistence
+ // }
+ // else{
+ // console.log('click');
+ // }
var _this = EVENT,
x = _this.status[_this.crsrX],
y = _this.status[_this.crsrY],
i = 0,
// Unset the active control when clicking on anything.
@@ -715,18 +731,22 @@
}
}
}
// Handle the active control selection.
if (_newActiveControl) {
+ // console.log('click new active control');
_this.changeActiveControl(_newActiveControl);
}
var _stopEvent = _clickElementIds.length;
for (i = 0; i !== _clickElementIds.length; i++) {
if (_this.focusOptions[_clickElementIds[i]].ctrl.click(x, y, _isLeftButton)) {
_stopEvent--;
}
}
+ if( _stopEvent === 0 ){
+ Event.stop(e);
+ }
return true;
},
focusTrace: false,
prevActiveCtrl: null,
@@ -736,22 +756,34 @@
* The new active ctrl gets the _gainedActiveStatus pseudo-event
**/
changeActiveControl: function(_ctrl) {
var
_this = EVENT,
+ _disAllowLose = true,
// Store the currently active control so we can inform it,
// if it's no longer the active control.
_prevActiveCtrl = _this.activeControl;
// Did the active control change?
- if (_ctrl && (_ctrl !== _prevActiveCtrl) && (_ctrl._gainedActiveStatus || _prevActiveCtrl._lostActiveStatus)) {
+ if (_ctrl && (_ctrl !== _prevActiveCtrl) && (_ctrl._gainedActiveStatus || (_prevActiveCtrl && _prevActiveCtrl._lostActiveStatus))) {
if (_prevActiveCtrl && _prevActiveCtrl._lostActiveStatus) {
// Previously active control just lost the active status.
- _prevActiveCtrl.active = false;
- _prevActiveCtrl._lostActiveStatus(_ctrl);
- if(_this.focusTrace){
- _prevActiveCtrl.setStyle('border','2px solid green');
- _this.prevActiveCtrl && _this.prevActiveCtrl.setStyle('border','2px solid blue');
+ if( _prevActiveCtrl ){
+ _disAllowLose = _prevActiveCtrl._lostActiveStatus(_ctrl) === false;
+ if( _disAllowLose ){
+ // console.log('disallow losing focus: ',_prevActiveCtrl.componentName,' -> ',_ctrl.componentName);
+ return;
+ }
+ // else{
+ // console.log('allow losing focus: ',_prevActiveCtrl.componentName,' -> ',_ctrl.componentName);
+ // }
+ _prevActiveCtrl.active = false;
+ if(_this.focusTrace){
+ _prevActiveCtrl.setStyle('border','2px solid green');
+ if( _this.prevActiveCtrl ){
+ _this.prevActiveCtrl.setStyle('border','2px solid blue');
+ }
+ }
}
_this.prevActiveCtrl = _prevActiveCtrl;
}
if (_ctrl && _ctrl._gainedActiveStatus) {
// A new control gained the active status.
@@ -777,19 +809,23 @@
* - endHover
* - drop
* - endDrag
*
**/
+ // lastMouseUp: 0,
mouseUp: function(e) {
- var _this = EVENT,
- _didEndDrag = false,
- _isLeftButton = Event.isLeftClick(e),
- x = _this.status[_this.crsrX],
- y = _this.status[_this.crsrY],
- _elemId,
- _ctrl,
- i = 0;
+ // console.log('mouseUp',EVENT.dragItems.length);
+ // EVENT.lastMouseUp = new Date().getTime();
+ var
+ _this = EVENT,
+ _didEndDrag = false,
+ _isLeftButton = Event.isLeftClick(e),
+ x = _this.status[_this.crsrX],
+ y = _this.status[_this.crsrY],
+ _elemId,
+ _ctrl,
+ i = 0;
_this._modifiers(e);
// Send endDrag for the currently dragged items even when they don't have focus, and clear the drag item array.
for (; i !== _this.dragItems.length; i++) {
_elemId = _this.dragItems[i];
_ctrl = _this.focusOptions[_elemId].ctrl;
@@ -818,11 +854,13 @@
// Check for mouseUp listeners.
for (i = 0; i < _this.focused.length; i++) {
if (_this.focused[i] === true) {
_ctrl = _this.focusOptions[i].ctrl;
if (_this.focusOptions[i].mouseUp === true) {
- _ctrl.mouseUp(x, y, _isLeftButton);
+ if( _ctrl.mouseUp(x, y, _isLeftButton) ){
+ // Event.stop(e);
+ }
}
}
}
if(_isLeftButton){
_this.status[_this.button1] = false;
@@ -875,10 +913,10 @@
_delta = 0 - (e.wheelDelta / 120);
}
else if (e.detail) {
_delta = 0 - (e.detail / 3);
}
- if (BROWSER_TYPE.opera || BROWSER_TYPE.safari) {
+ if (BROWSER_TYPE.opera || BROWSER_TYPE.safari || BROWSER_TYPE.ie) {
_delta = 0 - _delta;
}
for (; i !== _this.focused.length; i++) {
if (_this.focused[i] === true) {
if (_this.focusOptions[i].mouseWheel === true) {