mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Renamed EventHandler to EventSource (#225)
This commit is contained in:
parent
5335048c64
commit
dab182757d
@ -22,7 +22,7 @@ module.exports = function(grunt) {
|
||||
sources = [
|
||||
"src/openseadragon.js",
|
||||
"src/fullscreen.js",
|
||||
"src/eventhandler.js",
|
||||
"src/eventsource.js",
|
||||
"src/mousetracker.js",
|
||||
"src/control.js",
|
||||
"src/controldock.js",
|
||||
|
@ -50,7 +50,7 @@ $.ButtonState = {
|
||||
* as fading the bottons out when the user has not interacted with them
|
||||
* for a specified period.
|
||||
* @class
|
||||
* @extends OpenSeadragon.EventHandler
|
||||
* @extends OpenSeadragon.EventSource
|
||||
* @param {Object} options
|
||||
* @param {String} options.tooltip Provides context help for the button we the
|
||||
* user hovers over it.
|
||||
@ -83,7 +83,7 @@ $.Button = function( options ) {
|
||||
|
||||
var _this = this;
|
||||
|
||||
$.EventHandler.call( this );
|
||||
$.EventSource.call( this );
|
||||
|
||||
$.extend( true, this, {
|
||||
|
||||
@ -238,7 +238,7 @@ $.Button = function( options ) {
|
||||
outTo( this, $.ButtonState.REST );
|
||||
};
|
||||
|
||||
$.extend( $.Button.prototype, $.EventHandler.prototype, {
|
||||
$.extend( $.Button.prototype, $.EventSource.prototype, {
|
||||
|
||||
/**
|
||||
* TODO: Determine what this function is intended to do and if it's actually
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenSeadragon - EventHandler
|
||||
* OpenSeadragon - EventSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
||||
@ -44,11 +44,11 @@
|
||||
* matches.
|
||||
* @class
|
||||
*/
|
||||
$.EventHandler = function() {
|
||||
$.EventSource = function() {
|
||||
this.events = {};
|
||||
};
|
||||
|
||||
$.EventHandler.prototype = {
|
||||
$.EventSource.prototype = {
|
||||
|
||||
/**
|
||||
* Add an event handler for a given event.
|
@ -43,7 +43,7 @@
|
||||
* @class
|
||||
* @name OpenSeadragon.Navigator
|
||||
* @extends OpenSeadragon.Viewer
|
||||
* @extends OpenSeadragon.EventHandler
|
||||
* @extends OpenSeadragon.EventSource
|
||||
* @param {Object} options
|
||||
* @param {String} options.viewerId
|
||||
*/
|
||||
@ -196,7 +196,7 @@ $.Navigator = function( options ){
|
||||
|
||||
};
|
||||
|
||||
$.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, {
|
||||
$.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, {
|
||||
|
||||
/**
|
||||
* @function
|
||||
|
@ -219,7 +219,7 @@ $.ReferenceStrip = function ( options ) {
|
||||
|
||||
};
|
||||
|
||||
$.extend( $.ReferenceStrip.prototype, $.EventHandler.prototype, $.Viewer.prototype, {
|
||||
$.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototype, {
|
||||
|
||||
setFocus: function ( page ) {
|
||||
var element = $.getElement( this.element.id + '-' + page ),
|
||||
|
@ -49,7 +49,7 @@
|
||||
* side in M (in pixels), where N is the smallest integer which satisfies
|
||||
* <strong>2^(N+1) >= M</strong>.
|
||||
* @class
|
||||
* @extends OpenSeadragon.EventHandler
|
||||
* @extends OpenSeadragon.EventSource
|
||||
* @param {Number|Object|Array|String} width
|
||||
* If more than a single argument is supplied, the traditional use of
|
||||
* positional parameters is supplied and width is expected to be the width
|
||||
@ -104,7 +104,7 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
||||
|
||||
//Tile sources supply some events, namely 'ready' when they must be configured
|
||||
//by asyncronously fetching their configuration data.
|
||||
$.EventHandler.call( this );
|
||||
$.EventSource.call( this );
|
||||
|
||||
//we allow options to override anything we dont treat as
|
||||
//required via idiomatic options or which is functionally
|
||||
@ -412,7 +412,7 @@ $.TileSource.prototype = {
|
||||
};
|
||||
|
||||
|
||||
$.extend( true, $.TileSource.prototype, $.EventHandler.prototype );
|
||||
$.extend( true, $.TileSource.prototype, $.EventSource.prototype );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ var THIS = {},
|
||||
* as arguments and we translate a positional call into an idiomatic call.
|
||||
*
|
||||
* @class
|
||||
* @extends OpenSeadragon.EventHandler
|
||||
* @extends OpenSeadragon.EventSource
|
||||
* @extends OpenSeadragon.ControlDock
|
||||
* @param {Object} options
|
||||
* @param {String} options.element Id of Element to attach to,
|
||||
@ -170,7 +170,7 @@ $.Viewer = function( options ) {
|
||||
this._updateRequestId = null;
|
||||
|
||||
//Inherit some behaviors and properties
|
||||
$.EventHandler.call( this );
|
||||
$.EventSource.call( this );
|
||||
|
||||
this.addHandler( 'open-failed', function (source, args) {
|
||||
var msg = $.getString( "Errors.Open-Failed", args.source, args.message);
|
||||
@ -356,7 +356,7 @@ $.Viewer = function( options ) {
|
||||
|
||||
};
|
||||
|
||||
$.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, {
|
||||
$.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -61,15 +61,15 @@
|
||||
} );
|
||||
|
||||
// ----------
|
||||
asyncTest( 'MouseTracker, EventHandler canvas-drag canvas-release canvas-click', function () {
|
||||
asyncTest( 'MouseTracker, EventSource canvas-drag canvas-release canvas-click', function () {
|
||||
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||
mouseTracker = null,
|
||||
userData = { item1: 'Test user data', item2: Math.random() },
|
||||
originalUserData = { item1: userData.item1, item2: userData.item2 },
|
||||
dragCount = 10,
|
||||
dragsHandledEventHandler = 0,
|
||||
releasesHandledEventHandler = 0,
|
||||
clicksHandledEventHandler = 0,
|
||||
dragsHandledEventSource = 0,
|
||||
releasesHandledEventSource = 0,
|
||||
clicksHandledEventSource = 0,
|
||||
eventsHandledMouseTracker = 0,
|
||||
originalEventsPassedMouseTracker = 0,
|
||||
releasesExpected = 1,
|
||||
@ -78,9 +78,9 @@
|
||||
var onOpen = function ( eventSender, eventData ) {
|
||||
viewer.removeHandler( 'open', onOpen );
|
||||
|
||||
viewer.addHandler( 'canvas-drag', onEventHandlerDrag );
|
||||
viewer.addHandler( 'canvas-release', onEventHandlerRelease );
|
||||
viewer.addHandler( 'canvas-click', onEventHandlerClick );
|
||||
viewer.addHandler( 'canvas-drag', onEventSourceDrag );
|
||||
viewer.addHandler( 'canvas-release', onEventSourceRelease );
|
||||
viewer.addHandler( 'canvas-click', onEventSourceClick );
|
||||
|
||||
mouseTracker = new OpenSeadragon.MouseTracker( {
|
||||
element: $canvas[0],
|
||||
@ -115,20 +115,22 @@
|
||||
$canvas.simulate( 'blur', event );
|
||||
};
|
||||
|
||||
var onEventHandlerDrag = function ( eventSender, eventData ) {
|
||||
dragsHandledEventHandler++;
|
||||
var onEventSourceDrag = function ( eventSender, eventData ) {
|
||||
dragsHandledEventSource++;
|
||||
};
|
||||
|
||||
var onEventHandlerRelease = function ( eventSender, eventData ) {
|
||||
releasesHandledEventHandler++;
|
||||
var onEventSourceRelease = function ( eventSender, eventData ) {
|
||||
releasesHandledEventSource++;
|
||||
};
|
||||
|
||||
var onEventHandlerClick = function ( eventSender, eventData ) {
|
||||
clicksHandledEventHandler++;
|
||||
var onEventSourceClick = function ( eventSender, eventData ) {
|
||||
clicksHandledEventSource++;
|
||||
};
|
||||
|
||||
var checkOriginalEventReceived = function ( eventData ) {
|
||||
eventsHandledMouseTracker++;
|
||||
//TODO Provide a better check for the original event...simulate doesn't currently extend the object
|
||||
// with arbitrary user data.
|
||||
if ( eventData && eventData.originalEvent ) {
|
||||
originalEventsPassedMouseTracker++;
|
||||
}
|
||||
@ -170,13 +172,13 @@
|
||||
checkOriginalEventReceived( eventData );
|
||||
|
||||
mouseTracker.destroy();
|
||||
viewer.removeHandler( 'canvas-drag', onEventHandlerDrag );
|
||||
viewer.removeHandler( 'canvas-release', onEventHandlerRelease );
|
||||
viewer.removeHandler( 'canvas-click', onEventHandlerClick );
|
||||
viewer.removeHandler( 'canvas-drag', onEventSourceDrag );
|
||||
viewer.removeHandler( 'canvas-release', onEventSourceRelease );
|
||||
viewer.removeHandler( 'canvas-click', onEventSourceClick );
|
||||
|
||||
equal( dragsHandledEventHandler, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
|
||||
equal( releasesHandledEventHandler, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
||||
equal( clicksHandledEventHandler, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
||||
equal( dragsHandledEventSource, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
|
||||
equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
||||
equal( clicksHandledEventSource, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
||||
|
||||
equal( originalEventsPassedMouseTracker, eventsHandledMouseTracker, "Original event received count matches expected (" + eventsHandledMouseTracker + ")" );
|
||||
deepEqual( eventData.userData, originalUserData, 'MouseTracker userData was untouched' );
|
||||
|
Loading…
Reference in New Issue
Block a user