From ec3141a778a8f564cfc6175ddae0fb8d8bca069e Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Mon, 30 Sep 2013 10:22:06 -0700 Subject: [PATCH] Event Names Normalized Compound event names lower case with hyphen. Button event names removed "on" and made lower case. --- src/drawer.js | 16 ++++++++-------- src/tilesource.js | 4 ++-- src/viewer.js | 30 +++++++++++++++--------------- src/viewport.js | 2 +- test/basic.js | 22 +++++++++++----------- test/events.js | 20 ++++++++++---------- test/formats.js | 4 ++-- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index c1b3646a..de94356c 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -204,7 +204,7 @@ $.Drawer.prototype = { }) ); this.updateAgain = true; if( this.viewer ){ - this.viewer.raiseEvent( 'addoverlay', { + this.viewer.raiseEvent( 'add-overlay', { viewer: this.viewer, element: element, location: options.location, @@ -236,7 +236,7 @@ $.Drawer.prototype = { this.updateAgain = true; } if( this.viewer ){ - this.viewer.raiseEvent( 'updateoverlay', { + this.viewer.raiseEvent( 'update-overlay', { viewer: this.viewer, element: element, location: location, @@ -266,7 +266,7 @@ $.Drawer.prototype = { this.updateAgain = true; } if( this.viewer ){ - this.viewer.raiseEvent( 'removeoverlay', { + this.viewer.raiseEvent( 'remove-overlay', { viewer: this.viewer, element: element }); @@ -286,7 +286,7 @@ $.Drawer.prototype = { this.updateAgain = true; } if( this.viewer ){ - this.viewer.raiseEvent( 'clearoverlay', { + this.viewer.raiseEvent( 'clear-overlay', { viewer: this.viewer }); } @@ -481,7 +481,7 @@ function updateViewport( drawer ) { drawer.updateAgain = false; if( drawer.viewer ){ - drawer.viewer.raiseEvent( 'updateviewport', { + drawer.viewer.raiseEvent( 'update-viewport', { viewer: drawer.viewer }); } @@ -657,7 +657,7 @@ function updateLevel( drawer, haveDrawn, drawLevel, level, levelOpacity, levelVi if( drawer.viewer ){ - drawer.viewer.raiseEvent( 'updatelevel', { + drawer.viewer.raiseEvent( 'update-level', { viewer: drawer.viewer, havedrawn: haveDrawn, level: level, @@ -721,7 +721,7 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le drawTile = drawLevel; if( drawer.viewer ){ - drawer.viewer.raiseEvent( 'updatetile', { + drawer.viewer.raiseEvent( 'update-tile', { viewer: drawer.viewer, tile: tile }); @@ -1235,7 +1235,7 @@ function drawTiles( drawer, lastDrawn ){ } if( drawer.viewer ){ - drawer.viewer.raiseEvent( 'tiledrawn', { + drawer.viewer.raiseEvent( 'tile-drawn', { viewer: drawer.viewer, tile: tile }); diff --git a/src/tilesource.js b/src/tilesource.js index 54c01241..9352487e 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -301,7 +301,7 @@ $.TileSource.prototype = { callback = function( data ){ var $TileSource = $.TileSource.determineType( _this, data, url ); if ( !$TileSource ) { - _this.raiseEvent( 'openfailed', { message: "Unable to load TileSource", source: url } ); + _this.raiseEvent( 'open-failed', { message: "Unable to load TileSource", source: url } ); return; } @@ -351,7 +351,7 @@ $.TileSource.prototype = { msg = formattedExc + " attempting to load TileSource"; } - _this.raiseEvent( 'openfailed', { + _this.raiseEvent( 'open-failed', { message: msg, source: url }); diff --git a/src/viewer.js b/src/viewer.js index 8057b717..65199316 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -172,7 +172,7 @@ $.Viewer = function( options ) { //Inherit some behaviors and properties $.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); _this._showMessage( msg ); }); @@ -441,8 +441,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, tileSource = new $.TileSource( tileSource, function( readySource ){ openTileSource( _this, readySource ); }); - tileSource.addHandler( 'openfailed', function ( name, args ) { - _this.raiseEvent( 'openfailed', args ); + tileSource.addHandler( 'open-failed', function ( name, args ) { + _this.raiseEvent( 'open-failed', args ); }); } else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){ @@ -455,7 +455,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, //inline configuration $TileSource = $.TileSource.determineType( _this, tileSource ); if ( !$TileSource ) { - _this.raiseEvent( 'openfailed', { + _this.raiseEvent( 'open-failed', { message: "Unable to load TileSource", source: tileSource }); @@ -569,7 +569,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, */ setMouseNavEnabled: function( enabled ){ this.innerTracker.setTracking( enabled ); - this.raiseEvent( 'mouseenabled', { enabled: enabled, viewer: this } ); + this.raiseEvent( 'mouse-enabled', { enabled: enabled, viewer: this } ); return this; }, @@ -603,7 +603,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } else { beginControlsAutoHide( this ); } - this.raiseEvent( 'controlsenabled', { enabled: enabled, viewer: this } ); + this.raiseEvent( 'controls-enabled', { enabled: enabled, viewer: this } ); return this; }, @@ -1439,7 +1439,7 @@ function onCanvasClick( tracker, eventData ) { ); this.viewport.applyConstraints(); } - this.raiseEvent( 'canvasclick', { + this.raiseEvent( 'canvas-click', { tracker: tracker, position: eventData.position, quick: eventData.quick, @@ -1464,7 +1464,7 @@ function onCanvasDrag( tracker, eventData ) { this.viewport.applyConstraints(); } } - this.raiseEvent( 'canvasdrag', { + this.raiseEvent( 'canvas-drag', { tracker: tracker, position: eventData.position, delta: eventData.delta, @@ -1476,7 +1476,7 @@ function onCanvasRelease( tracker, eventData ) { if ( eventData.insideElementPressed && this.viewport ) { this.viewport.applyConstraints(); } - this.raiseEvent( 'canvasrelease', { + this.raiseEvent( 'canvas-release', { tracker: tracker, position: eventData.position, insideElementPressed: eventData.insideElementPressed, @@ -1494,7 +1494,7 @@ function onCanvasScroll( tracker, eventData ) { ); this.viewport.applyConstraints(); } - this.raiseEvent( 'canvasscroll', { + this.raiseEvent( 'canvas-scroll', { tracker: tracker, position: eventData.position, scroll: eventData.scroll, @@ -1511,7 +1511,7 @@ function onContainerExit( tracker, eventData ) { beginControlsAutoHide( this ); } } - this.raiseEvent( 'containerexit', { + this.raiseEvent( 'container-exit', { tracker: tracker, position: eventData.position, insideElementPressed: eventData.insideElementPressed, @@ -1526,7 +1526,7 @@ function onContainerRelease( tracker, eventData ) { beginControlsAutoHide( this ); } } - this.raiseEvent( 'containerrelease', { + this.raiseEvent( 'container-release', { tracker: tracker, position: eventData.position, insideElementPressed: eventData.insideElementPressed, @@ -1537,7 +1537,7 @@ function onContainerRelease( tracker, eventData ) { function onContainerEnter( tracker, eventData ) { THIS[ this.hash ].mouseInside = true; abortControlsAutoHide( this ); - this.raiseEvent( 'containerenter', { + this.raiseEvent( 'container-enter', { tracker: tracker, position: eventData.position, insideElementPressed: eventData.insideElementPressed, @@ -1589,7 +1589,7 @@ function updateOnce( viewer ) { } if ( !THIS[ viewer.hash ].animating && animated ) { - viewer.raiseEvent( "animationstart" ); + viewer.raiseEvent( "animation-start" ); abortControlsAutoHide( viewer ); } @@ -1608,7 +1608,7 @@ function updateOnce( viewer ) { } if ( THIS[ viewer.hash ].animating && !animated ) { - viewer.raiseEvent( "animationfinish" ); + viewer.raiseEvent( "animation-finish" ); if ( !THIS[ viewer.hash ].mouseInside ) { beginControlsAutoHide( viewer ); diff --git a/src/viewport.js b/src/viewport.js index 3ea56afa..691851c4 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -121,7 +121,7 @@ $.Viewport.prototype = { this.homeBounds = new $.Rect( 0, 0, 1, this.contentAspectY ); if( this.viewer ){ - this.viewer.raiseEvent( 'resetsize', { + this.viewer.raiseEvent( 'reset-size', { contentSize: contentSize, viewer: this.viewer }); diff --git a/test/basic.js b/test/basic.js index ffab85ad..eb75b947 100644 --- a/test/basic.js +++ b/test/basic.js @@ -51,7 +51,7 @@ 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"); equal($(".openseadragon-message").length, 1, "Open failures should display a message"); @@ -73,12 +73,12 @@ equal(viewport.getZoom(), 1, 'We start out unzoomed'); var zoomHandler = function() { - viewer.removeHandler('animationfinish', zoomHandler); + viewer.removeHandler('animation-finish', zoomHandler); equal(viewport.getZoom(), 2, 'Zoomed correctly'); start(); }; - viewer.addHandler('animationfinish', zoomHandler); + viewer.addHandler('animation-finish', zoomHandler); viewport.zoomTo(2); }); viewer.open('/test/data/testpattern.dzi'); @@ -93,13 +93,13 @@ ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned'); var panHandler = function() { - viewer.removeHandler('animationfinish', panHandler); + viewer.removeHandler('animation-finish', panHandler); center = viewport.getCenter(); ok(center.x === 0.1 && center.y === 0.1, 'Panned correctly'); start(); }; - viewer.addHandler('animationfinish', panHandler); + viewer.addHandler('animation-finish', panHandler); viewport.panTo(new OpenSeadragon.Point(0.1, 0.1)); }); @@ -119,25 +119,25 @@ var viewport = viewer.viewport, 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'); notEqual(viewport.getZoom(), 1, 'We start out zoomed'); var homeHandler = function() { - viewer.removeHandler('animationfinish', homeHandler); + viewer.removeHandler('animation-finish', homeHandler); center = viewport.getCenter(); ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned'); equal(viewport.getZoom(), 1, 'We end up unzoomed'); start(); }; - viewer.addHandler('animationfinish', homeHandler); + viewer.addHandler('animation-finish', homeHandler); viewport.goHome(true); } viewer.addHandler("open", opener); - viewer.addHandler("animationfinish", stage1); + viewer.addHandler("animation-finish", stage1); viewer.open('/test/data/testpattern.dzi'); }); @@ -152,14 +152,14 @@ equal(viewport.getZoom(), 1, 'We start out unzoomed'); var clickHandler = function() { - viewer.removeHandler('animationfinish', clickHandler); + viewer.removeHandler('animation-finish', clickHandler); center = viewport.getCenter(); 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'); start(); }; - viewer.addHandler('animationfinish', clickHandler); + viewer.addHandler('animation-finish', clickHandler); Util.simulateViewerClickWithDrag( { viewer: viewer, widthFactor: 0.25, diff --git a/test/events.js b/test/events.js index 687387f3..d99799be 100644 --- a/test/events.js +++ b/test/events.js @@ -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' ), mouseTracker = null, userData = { item1: 'Test user data', item2: Math.random() }, @@ -78,9 +78,9 @@ var onOpen = function ( eventSender, eventData ) { viewer.removeHandler( 'open', onOpen ); - viewer.addHandler( 'canvasdrag', onEventSourceDrag ); - viewer.addHandler( 'canvasrelease', onEventSourceRelease ); - viewer.addHandler( 'canvasclick', onEventSourceClick ); + viewer.addHandler( 'canvas-drag', onEventSourceDrag ); + viewer.addHandler( 'canvas-release', onEventSourceRelease ); + viewer.addHandler( 'canvas-click', onEventSourceClick ); mouseTracker = new OpenSeadragon.MouseTracker( { element: $canvas[0], @@ -172,13 +172,13 @@ checkOriginalEventReceived( eventData ); mouseTracker.destroy(); - viewer.removeHandler( 'canvasdrag', onEventSourceDrag ); - viewer.removeHandler( 'canvasrelease', onEventSourceRelease ); - viewer.removeHandler( 'canvasclick', onEventSourceClick ); + viewer.removeHandler( 'canvas-drag', onEventSourceDrag ); + viewer.removeHandler( 'canvas-release', onEventSourceRelease ); + viewer.removeHandler( 'canvas-click', onEventSourceClick ); - equal( dragsHandledEventSource, dragCount, "'canvasdrag' event count matches 'mousemove' event count (" + dragCount + ")" ); - equal( releasesHandledEventSource, releasesExpected, "'canvasrelease' event count matches expected (" + releasesExpected + ")" ); - equal( clicksHandledEventSource, releasesExpected, "'canvasclick' 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' ); diff --git a/test/formats.js b/test/formats.js index 085e3712..0c673bcf 100644 --- a/test/formats.js +++ b/test/formats.js @@ -29,11 +29,11 @@ var openHandler = function(eventSender, eventData) { viewer.removeHandler('open', openHandler); ok(true, 'Open event was sent'); - viewer.addHandler('tiledrawn', tileDrawnHandler); + viewer.addHandler('tile-drawn', tileDrawnHandler); }; var tileDrawnHandler = function(eventSender, eventData) { - viewer.removeHandler('tiledrawn', tileDrawnHandler); + viewer.removeHandler('tile-drawn', tileDrawnHandler); ok(true, 'A tile has been drawn'); viewer.addHandler('close', closeHandler); viewer.close();