Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/core/Stratcom.js
Show All 35 Lines | JX.install('Stratcom', { | ||||
statics : { | statics : { | ||||
ready : false, | ready : false, | ||||
_targets : {}, | _targets : {}, | ||||
_handlers : [], | _handlers : [], | ||||
_need : {}, | _need : {}, | ||||
_auto : '*', | _auto : '*', | ||||
_data : {}, | _data : {}, | ||||
_execContext : [], | _execContext : [], | ||||
_touchState: null, | |||||
/** | /** | ||||
* Node metadata is stored in a series of blocks to prevent collisions | * Node metadata is stored in a series of blocks to prevent collisions | ||||
* between indexes that are generated on the server side (and potentially | * between indexes that are generated on the server side (and potentially | ||||
* concurrently). Block 0 is for metadata on the initial page load, block 1 | * concurrently). Block 0 is for metadata on the initial page load, block 1 | ||||
* is for metadata added at runtime with JX.Stratcom.siglize(), and blocks | * is for metadata added at runtime with JX.Stratcom.siglize(), and blocks | ||||
* 2 and up are for metadata generated from other sources (e.g. JX.Request). | * 2 and up are for metadata generated from other sources (e.g. JX.Request). | ||||
* Use allocateMetadataBlock() to reserve a block, and mergeData() to fill | * Use allocateMetadataBlock() to reserve a block, and mergeData() to fill | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | dispatch : function(event) { | ||||
var etype = event.type; | var etype = event.type; | ||||
if (etype == 'focusin') { | if (etype == 'focusin') { | ||||
etype = 'focus'; | etype = 'focus'; | ||||
} else if (etype == 'focusout') { | } else if (etype == 'focusout') { | ||||
etype = 'blur'; | etype = 'blur'; | ||||
} | } | ||||
// Map of touch events and whether they are unique per touch. | |||||
var touch_map = { | |||||
touchstart: true, | |||||
touchend: true, | |||||
mousedown: true, | |||||
mouseup: true, | |||||
click: true, | |||||
// These can conceivably fire multiple times per touch, so if we see | |||||
// them more than once that doesn't tell us that we're handling a new | |||||
// event. | |||||
mouseover: false, | |||||
mouseout: false, | |||||
mousemove: false, | |||||
touchmove: false | |||||
}; | |||||
// If this is a 'touchstart', we're handling touch events. | |||||
if (etype == 'touchstart') { | |||||
this._touchState = {}; | |||||
} | |||||
// If this is a unique touch event that we haven't seen before, remember | |||||
// it as part of the current touch state. On the other hand, if we've | |||||
// already seen it, we can deduce that we must be handling a new cursor | |||||
// event that is unrelated to the last touch we saw, and conclude that | |||||
// we are no longer processing a touch event. | |||||
if (touch_map[etype] && this._touchState) { | |||||
if (!this._touchState[etype]) { | |||||
this._touchState[etype] = true; | |||||
} else { | |||||
this._touchState = null; | |||||
} | |||||
} | |||||
// This event is a touch event if we're carrying some touch state. | |||||
var is_touch = (etype in touch_map) && | |||||
(this._touchState !== null); | |||||
var proxy = new JX.Event() | var proxy = new JX.Event() | ||||
.setRawEvent(event) | .setRawEvent(event) | ||||
.setData(event.customData) | .setData(event.customData) | ||||
.setType(etype) | .setType(etype) | ||||
.setTarget(target) | .setTarget(target) | ||||
.setNodes(nodes) | .setNodes(nodes) | ||||
.setNodeDistances(distances) | .setNodeDistances(distances) | ||||
.setIsTouchEvent(is_touch) | |||||
.setPath(path.reverse()); | .setPath(path.reverse()); | ||||
// Don't touch this for debugging purposes | // You can uncomment this to print out all events flowing through | ||||
// Stratcom, which tends to make debugging easier. | |||||
//JX.log('~> '+proxy.toString()); | //JX.log('~> '+proxy.toString()); | ||||
return this._dispatchProxy(proxy); | return this._dispatchProxy(proxy); | ||||
}, | }, | ||||
/** | /** | ||||
* Dispatch a previously constructed proxy :JX.Event. | * Dispatch a previously constructed proxy :JX.Event. | ||||
▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines |