Event Names Normalized

Compound event names lower case with hyphen.
Button event names removed "on" and made lower case.
This commit is contained in:
Mark Salsbery 2013-09-30 10:22:06 -07:00
parent c0a16dacc4
commit ec3141a778
7 changed files with 49 additions and 49 deletions

View File

@ -204,7 +204,7 @@ $.Drawer.prototype = {
}) ); }) );
this.updateAgain = true; this.updateAgain = true;
if( this.viewer ){ if( this.viewer ){
this.viewer.raiseEvent( 'addoverlay', { this.viewer.raiseEvent( 'add-overlay', {
viewer: this.viewer, viewer: this.viewer,
element: element, element: element,
location: options.location, location: options.location,
@ -236,7 +236,7 @@ $.Drawer.prototype = {
this.updateAgain = true; this.updateAgain = true;
} }
if( this.viewer ){ if( this.viewer ){
this.viewer.raiseEvent( 'updateoverlay', { this.viewer.raiseEvent( 'update-overlay', {
viewer: this.viewer, viewer: this.viewer,
element: element, element: element,
location: location, location: location,
@ -266,7 +266,7 @@ $.Drawer.prototype = {
this.updateAgain = true; this.updateAgain = true;
} }
if( this.viewer ){ if( this.viewer ){
this.viewer.raiseEvent( 'removeoverlay', { this.viewer.raiseEvent( 'remove-overlay', {
viewer: this.viewer, viewer: this.viewer,
element: element element: element
}); });
@ -286,7 +286,7 @@ $.Drawer.prototype = {
this.updateAgain = true; this.updateAgain = true;
} }
if( this.viewer ){ if( this.viewer ){
this.viewer.raiseEvent( 'clearoverlay', { this.viewer.raiseEvent( 'clear-overlay', {
viewer: this.viewer viewer: this.viewer
}); });
} }
@ -481,7 +481,7 @@ function updateViewport( drawer ) {
drawer.updateAgain = false; drawer.updateAgain = false;
if( drawer.viewer ){ if( drawer.viewer ){
drawer.viewer.raiseEvent( 'updateviewport', { drawer.viewer.raiseEvent( 'update-viewport', {
viewer: drawer.viewer viewer: drawer.viewer
}); });
} }
@ -657,7 +657,7 @@ function updateLevel( drawer, haveDrawn, drawLevel, level, levelOpacity, levelVi
if( drawer.viewer ){ if( drawer.viewer ){
drawer.viewer.raiseEvent( 'updatelevel', { drawer.viewer.raiseEvent( 'update-level', {
viewer: drawer.viewer, viewer: drawer.viewer,
havedrawn: haveDrawn, havedrawn: haveDrawn,
level: level, level: level,
@ -721,7 +721,7 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le
drawTile = drawLevel; drawTile = drawLevel;
if( drawer.viewer ){ if( drawer.viewer ){
drawer.viewer.raiseEvent( 'updatetile', { drawer.viewer.raiseEvent( 'update-tile', {
viewer: drawer.viewer, viewer: drawer.viewer,
tile: tile tile: tile
}); });
@ -1235,7 +1235,7 @@ function drawTiles( drawer, lastDrawn ){
} }
if( drawer.viewer ){ if( drawer.viewer ){
drawer.viewer.raiseEvent( 'tiledrawn', { drawer.viewer.raiseEvent( 'tile-drawn', {
viewer: drawer.viewer, viewer: drawer.viewer,
tile: tile tile: tile
}); });

View File

@ -301,7 +301,7 @@ $.TileSource.prototype = {
callback = function( data ){ callback = function( data ){
var $TileSource = $.TileSource.determineType( _this, data, url ); var $TileSource = $.TileSource.determineType( _this, data, url );
if ( !$TileSource ) { if ( !$TileSource ) {
_this.raiseEvent( 'openfailed', { message: "Unable to load TileSource", source: url } ); _this.raiseEvent( 'open-failed', { message: "Unable to load TileSource", source: url } );
return; return;
} }
@ -351,7 +351,7 @@ $.TileSource.prototype = {
msg = formattedExc + " attempting to load TileSource"; msg = formattedExc + " attempting to load TileSource";
} }
_this.raiseEvent( 'openfailed', { _this.raiseEvent( 'open-failed', {
message: msg, message: msg,
source: url source: url
}); });

View File

@ -172,7 +172,7 @@ $.Viewer = function( options ) {
//Inherit some behaviors and properties //Inherit some behaviors and properties
$.EventSource.call( this ); $.EventSource.call( this );
this.addHandler( 'openfailed', function (source, args) { this.addHandler( 'open-failed', function (source, args) {
var msg = $.getString( "Errors.OpenFailed", args.source, args.message); var msg = $.getString( "Errors.OpenFailed", args.source, args.message);
_this._showMessage( msg ); _this._showMessage( msg );
}); });
@ -441,8 +441,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
tileSource = new $.TileSource( tileSource, function( readySource ){ tileSource = new $.TileSource( tileSource, function( readySource ){
openTileSource( _this, readySource ); openTileSource( _this, readySource );
}); });
tileSource.addHandler( 'openfailed', function ( name, args ) { tileSource.addHandler( 'open-failed', function ( name, args ) {
_this.raiseEvent( 'openfailed', args ); _this.raiseEvent( 'open-failed', args );
}); });
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){ } else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){
@ -455,7 +455,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
//inline configuration //inline configuration
$TileSource = $.TileSource.determineType( _this, tileSource ); $TileSource = $.TileSource.determineType( _this, tileSource );
if ( !$TileSource ) { if ( !$TileSource ) {
_this.raiseEvent( 'openfailed', { _this.raiseEvent( 'open-failed', {
message: "Unable to load TileSource", message: "Unable to load TileSource",
source: tileSource source: tileSource
}); });
@ -569,7 +569,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
*/ */
setMouseNavEnabled: function( enabled ){ setMouseNavEnabled: function( enabled ){
this.innerTracker.setTracking( enabled ); this.innerTracker.setTracking( enabled );
this.raiseEvent( 'mouseenabled', { enabled: enabled, viewer: this } ); this.raiseEvent( 'mouse-enabled', { enabled: enabled, viewer: this } );
return this; return this;
}, },
@ -603,7 +603,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
} else { } else {
beginControlsAutoHide( this ); beginControlsAutoHide( this );
} }
this.raiseEvent( 'controlsenabled', { enabled: enabled, viewer: this } ); this.raiseEvent( 'controls-enabled', { enabled: enabled, viewer: this } );
return this; return this;
}, },
@ -1439,7 +1439,7 @@ function onCanvasClick( tracker, eventData ) {
); );
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
this.raiseEvent( 'canvasclick', { this.raiseEvent( 'canvas-click', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
quick: eventData.quick, quick: eventData.quick,
@ -1464,7 +1464,7 @@ function onCanvasDrag( tracker, eventData ) {
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
} }
this.raiseEvent( 'canvasdrag', { this.raiseEvent( 'canvas-drag', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
delta: eventData.delta, delta: eventData.delta,
@ -1476,7 +1476,7 @@ function onCanvasRelease( tracker, eventData ) {
if ( eventData.insideElementPressed && this.viewport ) { if ( eventData.insideElementPressed && this.viewport ) {
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
this.raiseEvent( 'canvasrelease', { this.raiseEvent( 'canvas-release', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
insideElementPressed: eventData.insideElementPressed, insideElementPressed: eventData.insideElementPressed,
@ -1494,7 +1494,7 @@ function onCanvasScroll( tracker, eventData ) {
); );
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
this.raiseEvent( 'canvasscroll', { this.raiseEvent( 'canvas-scroll', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
scroll: eventData.scroll, scroll: eventData.scroll,
@ -1511,7 +1511,7 @@ function onContainerExit( tracker, eventData ) {
beginControlsAutoHide( this ); beginControlsAutoHide( this );
} }
} }
this.raiseEvent( 'containerexit', { this.raiseEvent( 'container-exit', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
insideElementPressed: eventData.insideElementPressed, insideElementPressed: eventData.insideElementPressed,
@ -1526,7 +1526,7 @@ function onContainerRelease( tracker, eventData ) {
beginControlsAutoHide( this ); beginControlsAutoHide( this );
} }
} }
this.raiseEvent( 'containerrelease', { this.raiseEvent( 'container-release', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
insideElementPressed: eventData.insideElementPressed, insideElementPressed: eventData.insideElementPressed,
@ -1537,7 +1537,7 @@ function onContainerRelease( tracker, eventData ) {
function onContainerEnter( tracker, eventData ) { function onContainerEnter( tracker, eventData ) {
THIS[ this.hash ].mouseInside = true; THIS[ this.hash ].mouseInside = true;
abortControlsAutoHide( this ); abortControlsAutoHide( this );
this.raiseEvent( 'containerenter', { this.raiseEvent( 'container-enter', {
tracker: tracker, tracker: tracker,
position: eventData.position, position: eventData.position,
insideElementPressed: eventData.insideElementPressed, insideElementPressed: eventData.insideElementPressed,
@ -1589,7 +1589,7 @@ function updateOnce( viewer ) {
} }
if ( !THIS[ viewer.hash ].animating && animated ) { if ( !THIS[ viewer.hash ].animating && animated ) {
viewer.raiseEvent( "animationstart" ); viewer.raiseEvent( "animation-start" );
abortControlsAutoHide( viewer ); abortControlsAutoHide( viewer );
} }
@ -1608,7 +1608,7 @@ function updateOnce( viewer ) {
} }
if ( THIS[ viewer.hash ].animating && !animated ) { if ( THIS[ viewer.hash ].animating && !animated ) {
viewer.raiseEvent( "animationfinish" ); viewer.raiseEvent( "animation-finish" );
if ( !THIS[ viewer.hash ].mouseInside ) { if ( !THIS[ viewer.hash ].mouseInside ) {
beginControlsAutoHide( viewer ); beginControlsAutoHide( viewer );

View File

@ -121,7 +121,7 @@ $.Viewport.prototype = {
this.homeBounds = new $.Rect( 0, 0, 1, this.contentAspectY ); this.homeBounds = new $.Rect( 0, 0, 1, this.contentAspectY );
if( this.viewer ){ if( this.viewer ){
this.viewer.raiseEvent( 'resetsize', { this.viewer.raiseEvent( 'reset-size', {
contentSize: contentSize, contentSize: contentSize,
viewer: this.viewer viewer: this.viewer
}); });

View File

@ -51,7 +51,7 @@
start(); start();
}); });
viewer.addHandler('openfailed', function(eventSender, eventData) { viewer.addHandler('open-failed', function(eventSender, eventData) {
ok(true, "The open-failed event should be fired when the source 404s"); ok(true, "The open-failed event should be fired when the source 404s");
equal($(".openseadragon-message").length, 1, "Open failures should display a message"); equal($(".openseadragon-message").length, 1, "Open failures should display a message");
@ -73,12 +73,12 @@
equal(viewport.getZoom(), 1, 'We start out unzoomed'); equal(viewport.getZoom(), 1, 'We start out unzoomed');
var zoomHandler = function() { var zoomHandler = function() {
viewer.removeHandler('animationfinish', zoomHandler); viewer.removeHandler('animation-finish', zoomHandler);
equal(viewport.getZoom(), 2, 'Zoomed correctly'); equal(viewport.getZoom(), 2, 'Zoomed correctly');
start(); start();
}; };
viewer.addHandler('animationfinish', zoomHandler); viewer.addHandler('animation-finish', zoomHandler);
viewport.zoomTo(2); viewport.zoomTo(2);
}); });
viewer.open('/test/data/testpattern.dzi'); viewer.open('/test/data/testpattern.dzi');
@ -93,13 +93,13 @@
ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned'); ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
var panHandler = function() { var panHandler = function() {
viewer.removeHandler('animationfinish', panHandler); viewer.removeHandler('animation-finish', panHandler);
center = viewport.getCenter(); center = viewport.getCenter();
ok(center.x === 0.1 && center.y === 0.1, 'Panned correctly'); ok(center.x === 0.1 && center.y === 0.1, 'Panned correctly');
start(); start();
}; };
viewer.addHandler('animationfinish', panHandler); viewer.addHandler('animation-finish', panHandler);
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1)); viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
}); });
@ -119,25 +119,25 @@
var viewport = viewer.viewport, var viewport = viewer.viewport,
center = viewport.getCenter(); center = viewport.getCenter();
viewer.removeHandler('animationfinish', stage1); viewer.removeHandler('animation-finish', stage1);
ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned'); ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned');
notEqual(viewport.getZoom(), 1, 'We start out zoomed'); notEqual(viewport.getZoom(), 1, 'We start out zoomed');
var homeHandler = function() { var homeHandler = function() {
viewer.removeHandler('animationfinish', homeHandler); viewer.removeHandler('animation-finish', homeHandler);
center = viewport.getCenter(); center = viewport.getCenter();
ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned'); ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned');
equal(viewport.getZoom(), 1, 'We end up unzoomed'); equal(viewport.getZoom(), 1, 'We end up unzoomed');
start(); start();
}; };
viewer.addHandler('animationfinish', homeHandler); viewer.addHandler('animation-finish', homeHandler);
viewport.goHome(true); viewport.goHome(true);
} }
viewer.addHandler("open", opener); viewer.addHandler("open", opener);
viewer.addHandler("animationfinish", stage1); viewer.addHandler("animation-finish", stage1);
viewer.open('/test/data/testpattern.dzi'); viewer.open('/test/data/testpattern.dzi');
}); });
@ -152,14 +152,14 @@
equal(viewport.getZoom(), 1, 'We start out unzoomed'); equal(viewport.getZoom(), 1, 'We start out unzoomed');
var clickHandler = function() { var clickHandler = function() {
viewer.removeHandler('animationfinish', clickHandler); viewer.removeHandler('animation-finish', clickHandler);
center = viewport.getCenter(); center = viewport.getCenter();
ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly'); ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly');
equal(viewport.getZoom(), 2, 'Zoomed correctly'); equal(viewport.getZoom(), 2, 'Zoomed correctly');
start(); start();
}; };
viewer.addHandler('animationfinish', clickHandler); viewer.addHandler('animation-finish', clickHandler);
Util.simulateViewerClickWithDrag( { Util.simulateViewerClickWithDrag( {
viewer: viewer, viewer: viewer,
widthFactor: 0.25, widthFactor: 0.25,

View File

@ -61,7 +61,7 @@
} ); } );
// ---------- // ----------
asyncTest( 'MouseTracker, EventSource canvasdrag canvasrelease canvasclick', 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() },
@ -78,9 +78,9 @@
var onOpen = function ( eventSender, eventData ) { var onOpen = function ( eventSender, eventData ) {
viewer.removeHandler( 'open', onOpen ); viewer.removeHandler( 'open', onOpen );
viewer.addHandler( 'canvasdrag', onEventSourceDrag ); viewer.addHandler( 'canvas-drag', onEventSourceDrag );
viewer.addHandler( 'canvasrelease', onEventSourceRelease ); viewer.addHandler( 'canvas-release', onEventSourceRelease );
viewer.addHandler( 'canvasclick', onEventSourceClick ); viewer.addHandler( 'canvas-click', onEventSourceClick );
mouseTracker = new OpenSeadragon.MouseTracker( { mouseTracker = new OpenSeadragon.MouseTracker( {
element: $canvas[0], element: $canvas[0],
@ -172,13 +172,13 @@
checkOriginalEventReceived( eventData ); checkOriginalEventReceived( eventData );
mouseTracker.destroy(); mouseTracker.destroy();
viewer.removeHandler( 'canvasdrag', onEventSourceDrag ); viewer.removeHandler( 'canvas-drag', onEventSourceDrag );
viewer.removeHandler( 'canvasrelease', onEventSourceRelease ); viewer.removeHandler( 'canvas-release', onEventSourceRelease );
viewer.removeHandler( 'canvasclick', onEventSourceClick ); viewer.removeHandler( 'canvas-click', onEventSourceClick );
equal( dragsHandledEventSource, dragCount, "'canvasdrag' event count matches 'mousemove' event count (" + dragCount + ")" ); equal( dragsHandledEventSource, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
equal( releasesHandledEventSource, releasesExpected, "'canvasrelease' event count matches expected (" + releasesExpected + ")" ); equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
equal( clicksHandledEventSource, releasesExpected, "'canvasclick' 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' );

View File

@ -29,11 +29,11 @@
var openHandler = function(eventSender, eventData) { var openHandler = function(eventSender, eventData) {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
ok(true, 'Open event was sent'); ok(true, 'Open event was sent');
viewer.addHandler('tiledrawn', tileDrawnHandler); viewer.addHandler('tile-drawn', tileDrawnHandler);
}; };
var tileDrawnHandler = function(eventSender, eventData) { var tileDrawnHandler = function(eventSender, eventData) {
viewer.removeHandler('tiledrawn', tileDrawnHandler); viewer.removeHandler('tile-drawn', tileDrawnHandler);
ok(true, 'A tile has been drawn'); ok(true, 'A tile has been drawn');
viewer.addHandler('close', closeHandler); viewer.addHandler('close', closeHandler);
viewer.close(); viewer.close();