mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Separate properties for buttonGroup and customButtons
This makes it more clear what we're testing for or calling methods on, vs. assigning to this.buttons in both the useGroup true and false cases.
This commit is contained in:
parent
8178687298
commit
0ede8992de
@ -409,14 +409,14 @@ $.Viewer = function( options ) {
|
|||||||
if (!this.drawer.canRotate()) {
|
if (!this.drawer.canRotate()) {
|
||||||
// Disable/remove the rotate left/right buttons since they aren't supported
|
// Disable/remove the rotate left/right buttons since they aren't supported
|
||||||
if (this.rotateLeft) {
|
if (this.rotateLeft) {
|
||||||
i = this.buttons.buttons.indexOf(this.rotateLeft);
|
i = this.buttonGroup.buttons.indexOf(this.rotateLeft);
|
||||||
this.buttons.buttons.splice(i, 1);
|
this.buttonGroup.buttons.splice(i, 1);
|
||||||
this.buttons.element.removeChild(this.rotateLeft.element);
|
this.buttonGroup.element.removeChild(this.rotateLeft.element);
|
||||||
}
|
}
|
||||||
if (this.rotateRight) {
|
if (this.rotateRight) {
|
||||||
i = this.buttons.buttons.indexOf(this.rotateRight);
|
i = this.buttonGroup.buttons.indexOf(this.rotateRight);
|
||||||
this.buttons.buttons.splice(i, 1);
|
this.buttonGroup.buttons.splice(i, 1);
|
||||||
this.buttons.element.removeChild(this.rotateRight.element);
|
this.buttonGroup.element.removeChild(this.rotateRight.element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,13 +774,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
|
|
||||||
this.removeAllHandlers();
|
this.removeAllHandlers();
|
||||||
|
|
||||||
if (this.buttons) {
|
if (this.buttonGroup) {
|
||||||
if (this.buttons instanceof $.ButtonGroup) {
|
this.buttonGroup.destroy();
|
||||||
this.buttons.destroy();
|
} else if (this.customButtons) {
|
||||||
} else {
|
while (this.customButtons.length) {
|
||||||
while (this.buttons.length) {
|
this.customButtons.pop().destroy();
|
||||||
this.buttons.pop().destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1855,13 +1853,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( useGroup ) {
|
if ( useGroup ) {
|
||||||
this.buttons = new $.ButtonGroup({
|
this.buttonGroup = new $.ButtonGroup({
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
clickTimeThreshold: this.clickTimeThreshold,
|
clickTimeThreshold: this.clickTimeThreshold,
|
||||||
clickDistThreshold: this.clickDistThreshold
|
clickDistThreshold: this.clickDistThreshold
|
||||||
});
|
});
|
||||||
|
|
||||||
this.navControl = this.buttons.element;
|
this.navControl = this.buttonGroup.element;
|
||||||
this.addHandler( 'open', $.delegate( this, lightUp ) );
|
this.addHandler( 'open', $.delegate( this, lightUp ) );
|
||||||
|
|
||||||
if( this.toolbar ){
|
if( this.toolbar ){
|
||||||
@ -1876,7 +1874,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.buttons = buttons;
|
this.customButtons = buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3490,8 +3488,10 @@ function doSingleZoomOut() {
|
|||||||
|
|
||||||
|
|
||||||
function lightUp() {
|
function lightUp() {
|
||||||
this.buttons.emulateEnter();
|
if (this.buttonGroup) {
|
||||||
this.buttons.emulateExit();
|
this.buttonGroup.emulateEnter();
|
||||||
|
this.buttonGroup.emulateExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3510,8 +3510,8 @@ function onFullScreen() {
|
|||||||
this.setFullScreen( !this.isFullPage() );
|
this.setFullScreen( !this.isFullPage() );
|
||||||
}
|
}
|
||||||
// correct for no mouseout event on change
|
// correct for no mouseout event on change
|
||||||
if ( this.buttons ) {
|
if ( this.buttonGroup ) {
|
||||||
this.buttons.emulateExit();
|
this.buttonGroup.emulateExit();
|
||||||
}
|
}
|
||||||
this.fullPageButton.element.focus();
|
this.fullPageButton.element.focus();
|
||||||
if ( this.viewport ) {
|
if ( this.viewport ) {
|
||||||
|
12
test/modules/controls.js
vendored
12
test/modules/controls.js
vendored
@ -53,9 +53,9 @@
|
|||||||
assert.ok(viewer.showZoomControl, 'showZoomControl should be on');
|
assert.ok(viewer.showZoomControl, 'showZoomControl should be on');
|
||||||
assert.ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
assert.ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
||||||
assert.ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
assert.ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomInButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.zoomInButton), -1,
|
||||||
"The zoomIn button should be present");
|
"The zoomIn button should be present");
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomOutButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.zoomOutButton), -1,
|
||||||
"The zoomOut button should be present");
|
"The zoomOut button should be present");
|
||||||
|
|
||||||
var oldZoom = viewer.viewport.getZoom();
|
var oldZoom = viewer.viewport.getZoom();
|
||||||
@ -108,7 +108,7 @@
|
|||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
assert.ok(viewer.showHomeControl, 'showHomeControl should be on');
|
assert.ok(viewer.showHomeControl, 'showHomeControl should be on');
|
||||||
assert.ok(!!viewer.homeButton, "Home button should not be null");
|
assert.ok(!!viewer.homeButton, "Home button should not be null");
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.homeButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.homeButton), -1,
|
||||||
"The home button should be present");
|
"The home button should be present");
|
||||||
|
|
||||||
viewer.viewport.zoomBy(1.1);
|
viewer.viewport.zoomBy(1.1);
|
||||||
@ -167,7 +167,7 @@
|
|||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
assert.ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
assert.ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
||||||
assert.ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
assert.ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.fullPageButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.fullPageButton), -1,
|
||||||
"The full page button should be present");
|
"The full page button should be present");
|
||||||
|
|
||||||
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
||||||
@ -223,9 +223,9 @@
|
|||||||
assert.ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
||||||
assert.ok(viewer.showRotationControl, 'showRotationControl should be true');
|
assert.ok(viewer.showRotationControl, 'showRotationControl should be true');
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateLeftButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.rotateLeftButton), -1,
|
||||||
"rotateLeft should be found");
|
"rotateLeft should be found");
|
||||||
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateRightButton), -1,
|
assert.notEqual(viewer.buttonGroup.buttons.indexOf(viewer.rotateRightButton), -1,
|
||||||
"rotateRight should be found");
|
"rotateRight should be found");
|
||||||
|
|
||||||
// Now simulate the left/right button clicks.
|
// Now simulate the left/right button clicks.
|
||||||
|
Loading…
Reference in New Issue
Block a user