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