mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 08:06:08 +03:00
Added setDebugMode function to Viewer.
Added SetDebugMode tests. Update in respose to PR review.
This commit is contained in:
parent
265625df75
commit
bfa0ac0137
@ -860,6 +860,22 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Turns debugging mode on or off for this viewer.
|
||||
*
|
||||
* @function
|
||||
* @param {Boolean} true to turn debug on, false to turn debug off.
|
||||
*/
|
||||
setDebugMode: function(debugMode){
|
||||
|
||||
for (var i = 0; i < this.world.getItemCount(); i++) {
|
||||
this.world.getItemAt(i).debugMode = debugMode;
|
||||
}
|
||||
|
||||
this.debugMode = debugMode;
|
||||
this.forceRedraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @return {Boolean}
|
||||
|
44
test/demo/setdebugmode.html
Normal file
44
test/demo/setdebugmode.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>OpenSeadragon Basic Demo</title>
|
||||
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
||||
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
|
||||
<style type="text/css">
|
||||
.openseadragon1 {
|
||||
width: 800px;
|
||||
height: 600px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
Turn debug mode on and off after viewer has been created.
|
||||
<button onclick="debugModeOn()">Debug Mode On</button>
|
||||
<button onclick="debugModeOff()">Debug Mode Off</button>
|
||||
</div>
|
||||
<div id="contentDiv" class="openseadragon1"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var viewer = OpenSeadragon({
|
||||
// debugMode: true,
|
||||
id: "contentDiv",
|
||||
prefixUrl: "../../build/openseadragon/images/",
|
||||
tileSources: "../data/testpattern.dzi",
|
||||
showNavigator: true,
|
||||
debugMode: true
|
||||
});
|
||||
|
||||
function debugModeOn() {
|
||||
viewer.setDebugMode(true);
|
||||
}
|
||||
|
||||
function debugModeOff() {
|
||||
viewer.setDebugMode(false);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -424,6 +424,40 @@
|
||||
|
||||
} );
|
||||
|
||||
|
||||
asyncTest('SetDebugMode', function() {
|
||||
ok(viewer, 'Viewer exists');
|
||||
|
||||
var checkImageTilesDebugState = function (expectedState) {
|
||||
|
||||
for (var i = 0; i < viewer.world.getItemCount(); i++) {
|
||||
if(viewer.world.getItemAt(i).debugMode != expectedState) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var openHandler = function(event) {
|
||||
viewer.removeHandler('open', openHandler);
|
||||
|
||||
//Ensure we start with debug mode turned off
|
||||
viewer.setDebugMode(false);
|
||||
ok(checkImageTilesDebugState(false), "All image tiles have debug mode turned off.");
|
||||
ok(!viewer.debugMode, "Viewer debug mode is turned off.");
|
||||
|
||||
//Turn debug mode on and check that the Viewer and all tiled images are in debug mode.
|
||||
viewer.setDebugMode(true);
|
||||
ok(checkImageTilesDebugState(true), "All image tiles have debug mode turned on.");
|
||||
ok(viewer.debugMode, "Viewer debug mode is turned on.");
|
||||
|
||||
start();
|
||||
};
|
||||
|
||||
viewer.addHandler('open', openHandler);
|
||||
viewer.open('/test/data/testpattern.dzi');
|
||||
});
|
||||
|
||||
test('version object', function() {
|
||||
equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string");
|
||||
ok(OpenSeadragon.version.major >= 0, "major should be a positive number");
|
||||
|
Loading…
Reference in New Issue
Block a user