mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 08:36:10 +03:00
Merge pull request #237 from msalsbery/Event-Names-Normalize
Event names normalize
This commit is contained in:
commit
5ce3da2548
@ -5,6 +5,16 @@ OPENSEADRAGON CHANGELOG
|
|||||||
|
|
||||||
* BREAKING CHANGE: Renamed EventHandler to EventSource (#225)
|
* BREAKING CHANGE: Renamed EventHandler to EventSource (#225)
|
||||||
* BREAKING CHANGE: MouseTracker event handler method signatures changed to 'handlerMethod( tracker, eventData)' (#23)
|
* BREAKING CHANGE: MouseTracker event handler method signatures changed to 'handlerMethod( tracker, eventData)' (#23)
|
||||||
|
* BREAKING CHANGE: Event names changed for consistency: changed to lower case, compound names hyphenated, and "on" prefixes removed (#226):
|
||||||
|
* Viewer "animationstart" changed to "animation-start"
|
||||||
|
* Viewer "animationfinish" changed to "animation-finish"
|
||||||
|
* Button "onPress" changed to "press"
|
||||||
|
* Button "onRelease" changed to "release"
|
||||||
|
* Button "onClick" changed to "click"
|
||||||
|
* Button "onEnter" changed to "enter"
|
||||||
|
* Button "onExit" changed to "exit"
|
||||||
|
* Button "onFocus" changed to "focus"
|
||||||
|
* Button "onBlur" changed to "blur"
|
||||||
* MouseTracker now passes the original event objects to its handler methods (#23)
|
* MouseTracker now passes the original event objects to its handler methods (#23)
|
||||||
* MouseTracker now supports an optional 'moveHandler' method for tracking mousemove events (#215)
|
* MouseTracker now supports an optional 'moveHandler' method for tracking mousemove events (#215)
|
||||||
* Fixed: Element-relative mouse coordinates now correct if the element and/or page is scrolled (using new OpenSeadragon.getElementOffset() method) (#131)
|
* Fixed: Element-relative mouse coordinates now correct if the element and/or page is scrolled (using new OpenSeadragon.getElementOffset() method) (#131)
|
||||||
|
@ -152,13 +152,13 @@ $.Button = function( options ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.addHandler( "onPress", this.onPress );
|
this.addHandler( "press", this.onPress );
|
||||||
this.addHandler( "onRelease", this.onRelease );
|
this.addHandler( "release", this.onRelease );
|
||||||
this.addHandler( "onClick", this.onClick );
|
this.addHandler( "click", this.onClick );
|
||||||
this.addHandler( "onEnter", this.onEnter );
|
this.addHandler( "enter", this.onEnter );
|
||||||
this.addHandler( "onExit", this.onExit );
|
this.addHandler( "exit", this.onExit );
|
||||||
this.addHandler( "onFocus", this.onFocus );
|
this.addHandler( "focus", this.onFocus );
|
||||||
this.addHandler( "onBlur", this.onBlur );
|
this.addHandler( "blur", this.onBlur );
|
||||||
|
|
||||||
this.currentState = $.ButtonState.GROUP;
|
this.currentState = $.ButtonState.GROUP;
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ $.Button = function( options ) {
|
|||||||
enterHandler: function( tracker, eventData ) {
|
enterHandler: function( tracker, eventData ) {
|
||||||
if ( eventData.insideElementPressed ) {
|
if ( eventData.insideElementPressed ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "onEnter", _this );
|
_this.raiseEvent( "enter", _this );
|
||||||
} else if ( !eventData.buttonDownAny ) {
|
} else if ( !eventData.buttonDownAny ) {
|
||||||
inTo( _this, $.ButtonState.HOVER );
|
inTo( _this, $.ButtonState.HOVER );
|
||||||
}
|
}
|
||||||
@ -186,30 +186,30 @@ $.Button = function( options ) {
|
|||||||
|
|
||||||
focusHandler: function ( tracker, eventData ) {
|
focusHandler: function ( tracker, eventData ) {
|
||||||
this.enterHandler( tracker, eventData );
|
this.enterHandler( tracker, eventData );
|
||||||
_this.raiseEvent( "onFocus", _this );
|
_this.raiseEvent( "focus", _this );
|
||||||
},
|
},
|
||||||
|
|
||||||
exitHandler: function( tracker, eventData ) {
|
exitHandler: function( tracker, eventData ) {
|
||||||
outTo( _this, $.ButtonState.GROUP );
|
outTo( _this, $.ButtonState.GROUP );
|
||||||
if ( eventData.insideElementPressed ) {
|
if ( eventData.insideElementPressed ) {
|
||||||
_this.raiseEvent( "onExit", _this );
|
_this.raiseEvent( "exit", _this );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
blurHandler: function ( tracker, eventData ) {
|
blurHandler: function ( tracker, eventData ) {
|
||||||
this.exitHandler( tracker, eventData );
|
this.exitHandler( tracker, eventData );
|
||||||
_this.raiseEvent( "onBlur", _this );
|
_this.raiseEvent( "blur", _this );
|
||||||
},
|
},
|
||||||
|
|
||||||
pressHandler: function ( tracker, eventData ) {
|
pressHandler: function ( tracker, eventData ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "onPress", _this );
|
_this.raiseEvent( "press", _this );
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseHandler: function( tracker, eventData ) {
|
releaseHandler: function( tracker, eventData ) {
|
||||||
if ( eventData.insideElementPressed && eventData.insideElementReleased ) {
|
if ( eventData.insideElementPressed && eventData.insideElementReleased ) {
|
||||||
outTo( _this, $.ButtonState.HOVER );
|
outTo( _this, $.ButtonState.HOVER );
|
||||||
_this.raiseEvent( "onRelease", _this );
|
_this.raiseEvent( "release", _this );
|
||||||
} else if ( eventData.insideElementPressed ) {
|
} else if ( eventData.insideElementPressed ) {
|
||||||
outTo( _this, $.ButtonState.GROUP );
|
outTo( _this, $.ButtonState.GROUP );
|
||||||
} else {
|
} else {
|
||||||
@ -219,15 +219,15 @@ $.Button = function( options ) {
|
|||||||
|
|
||||||
clickHandler: function( tracker, eventData ) {
|
clickHandler: function( tracker, eventData ) {
|
||||||
if ( eventData.quick ) {
|
if ( eventData.quick ) {
|
||||||
_this.raiseEvent("onClick", _this);
|
_this.raiseEvent("click", _this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
keyHandler: function( tracker, eventData ){
|
keyHandler: function( tracker, eventData ){
|
||||||
//console.log( "%s : handling key %s!", _this.tooltip, eventData.keyCode);
|
//console.log( "%s : handling key %s!", _this.tooltip, eventData.keyCode);
|
||||||
if( 13 === eventData.keyCode ){
|
if( 13 === eventData.keyCode ){
|
||||||
_this.raiseEvent( "onClick", _this );
|
_this.raiseEvent( "click", _this );
|
||||||
_this.raiseEvent( "onRelease", _this );
|
_this.raiseEvent( "release", _this );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -36,12 +36,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* For use by classes which want to support custom, non-browser events.
|
* For use by classes which want to support custom, non-browser events.
|
||||||
* TODO: This is an awful name! This thing represents an "event source",
|
* TODO: Add a method 'one' which automatically unbinds a listener after
|
||||||
* not an "event handler". PLEASE change the to EventSource. Also please
|
* the first triggered event that matches.
|
||||||
* change 'addHandler', 'removeHandler' and 'raiseEvent' to 'bind',
|
|
||||||
* 'unbind', and 'trigger' respectively. Finally add a method 'one' which
|
|
||||||
* automatically unbinds a listener after the first triggered event that
|
|
||||||
* matches.
|
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
$.EventSource = function() {
|
$.EventSource = function() {
|
||||||
|
@ -46,7 +46,7 @@ var I18N = {
|
|||||||
Security: "It looks like a security restriction stopped us from " +
|
Security: "It looks like a security restriction stopped us from " +
|
||||||
"loading this Deep Zoom Image.",
|
"loading this Deep Zoom Image.",
|
||||||
Status: "This space unintentionally left blank ({0} {1}).",
|
Status: "This space unintentionally left blank ({0} {1}).",
|
||||||
"Open-Failed": "Unable to open {0}: {1}"
|
OpenFailed: "Unable to open {0}: {1}"
|
||||||
},
|
},
|
||||||
|
|
||||||
Tooltips: {
|
Tooltips: {
|
||||||
|
@ -173,7 +173,7 @@ $.Viewer = function( options ) {
|
|||||||
$.EventSource.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.OpenFailed", args.source, args.message);
|
||||||
_this._showMessage( msg );
|
_this._showMessage( msg );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -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 );
|
||||||
|
@ -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,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getStringWithPlaceholders", function() {
|
test("getStringWithPlaceholders", function() {
|
||||||
equal(OpenSeadragon.getString("Errors.Open-Failed", "foo", "bar"),
|
equal(OpenSeadragon.getString("Errors.OpenFailed", "foo", "bar"),
|
||||||
"Unable to open foo: bar",
|
"Unable to open foo: bar",
|
||||||
"String placeholder replacement");
|
"String placeholder replacement");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user