2014-08-19 03:04:49 +04:00
|
|
|
/* globals $, App */
|
|
|
|
|
2014-07-18 03:24:28 +04:00
|
|
|
(function() {
|
|
|
|
|
2014-08-19 03:04:49 +04:00
|
|
|
window.App = {
|
2014-07-18 03:24:28 +04:00
|
|
|
init: function() {
|
|
|
|
var self = this;
|
|
|
|
|
2014-10-17 01:00:07 +04:00
|
|
|
var config = {
|
2014-07-22 22:13:22 +04:00
|
|
|
debugMode: true,
|
|
|
|
zoomPerScroll: 1.02,
|
2014-08-01 02:54:20 +04:00
|
|
|
// showNavigator: true,
|
2014-07-18 03:24:28 +04:00
|
|
|
id: "contentDiv",
|
2014-07-22 22:13:22 +04:00
|
|
|
prefixUrl: "../../../build/openseadragon/images/"
|
2014-10-17 01:00:07 +04:00
|
|
|
};
|
2014-07-18 03:24:28 +04:00
|
|
|
|
2014-10-22 04:11:09 +04:00
|
|
|
var testMargins = false;
|
|
|
|
|
|
|
|
var margins;
|
|
|
|
|
|
|
|
if (testMargins) {
|
|
|
|
margins = {
|
|
|
|
top: 250,
|
|
|
|
left: 250,
|
|
|
|
right: 250,
|
|
|
|
bottom: 250
|
|
|
|
};
|
|
|
|
|
|
|
|
config.viewportMargins = margins;
|
|
|
|
}
|
2014-10-18 01:27:24 +04:00
|
|
|
|
2014-10-17 01:00:07 +04:00
|
|
|
this.viewer = OpenSeadragon(config);
|
|
|
|
|
2014-10-22 04:11:09 +04:00
|
|
|
if (testMargins) {
|
|
|
|
this.viewer.addHandler('animation', function() {
|
|
|
|
var box = new OpenSeadragon.Rect(margins.left, margins.top,
|
|
|
|
$('#contentDiv').width() - (margins.left + margins.right),
|
|
|
|
$('#contentDiv').height() - (margins.top + margins.bottom));
|
|
|
|
|
|
|
|
self.viewer.drawer.debugRect(box);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-10-17 01:00:07 +04:00
|
|
|
this.basicTest();
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
basicTest: function() {
|
2014-10-22 04:11:09 +04:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.viewer.addHandler('open', function() {
|
|
|
|
});
|
|
|
|
|
2014-10-17 01:00:07 +04:00
|
|
|
this.viewer.open("../../data/testpattern.dzi");
|
2014-08-27 02:27:55 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
crossTest: function() {
|
|
|
|
var self = this;
|
|
|
|
|
2014-07-18 03:24:28 +04:00
|
|
|
this.viewer.addHandler( "open", function() {
|
2014-08-27 02:27:55 +04:00
|
|
|
var options = {
|
|
|
|
tileSource: '../../data/wide.dzi',
|
|
|
|
opacity: 1,
|
|
|
|
x: 0,
|
|
|
|
y: 1.5,
|
|
|
|
height: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
var addItemHandler = function( event ) {
|
|
|
|
if ( event.options === options ) {
|
|
|
|
self.viewer.world.removeHandler( "add-item", addItemHandler );
|
|
|
|
self.viewer.viewport.goHome();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
self.viewer.world.addHandler( "add-item", addItemHandler );
|
|
|
|
self.viewer.addTiledImage( options );
|
2014-07-18 03:24:28 +04:00
|
|
|
});
|
2014-07-22 22:13:22 +04:00
|
|
|
|
|
|
|
this.viewer.open("../../data/tall.dzi", {
|
|
|
|
x: 1.5,
|
|
|
|
y: 0,
|
2014-08-01 02:54:20 +04:00
|
|
|
width: 1
|
2014-07-22 22:13:22 +04:00
|
|
|
});
|
2014-07-18 03:24:28 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
2014-08-27 02:27:55 +04:00
|
|
|
gridTest: function() {
|
2014-07-18 03:24:28 +04:00
|
|
|
var self = this;
|
2014-08-27 02:27:55 +04:00
|
|
|
var startX = -3;
|
|
|
|
var expected = 0;
|
|
|
|
var loaded = 0;
|
|
|
|
|
|
|
|
this.viewer.addHandler( "open", function() {
|
|
|
|
self.viewer.world.addHandler('add-item', function() {
|
|
|
|
loaded++;
|
|
|
|
if (loaded === expected) {
|
|
|
|
self.viewer.viewport.goHome();
|
|
|
|
}
|
|
|
|
});
|
2014-07-18 03:24:28 +04:00
|
|
|
|
2014-08-27 02:27:55 +04:00
|
|
|
var x, y;
|
|
|
|
for (y = 0; y < 6; y++) {
|
|
|
|
for (x = 0; x < 6; x++) {
|
|
|
|
if (!x && !y) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
tileSource: '../../data/testpattern.dzi',
|
|
|
|
x: startX + x,
|
|
|
|
y: y,
|
|
|
|
width: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
expected++;
|
|
|
|
self.viewer.addTiledImage( options );
|
|
|
|
}
|
2014-07-18 03:24:28 +04:00
|
|
|
}
|
2014-08-27 02:27:55 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
this.viewer.open("../../data/testpattern.dzi", {
|
|
|
|
x: startX,
|
|
|
|
y: 0,
|
|
|
|
width: 1
|
|
|
|
});
|
2014-10-17 01:00:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
bigTest: function() {
|
|
|
|
this.viewer.open("../../data/testpattern.dzi", {
|
|
|
|
x: -2,
|
|
|
|
y: -2,
|
|
|
|
width: 6
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
cjTest: function() {
|
|
|
|
var imageKey = "e-pluribus-unum";
|
|
|
|
var imageXML = '<?xml version="1.0" encoding="UTF-8"?><Image TileSize="254" Overlap="1" Format="png" xmlns="http://schemas.microsoft.com/deepzoom/2008"><Size Width="88560" Height="88560"/></Image>';
|
|
|
|
var $xml = $($.parseXML(imageXML));
|
|
|
|
var $image = $xml.find('Image');
|
|
|
|
var $size = $xml.find('Size');
|
|
|
|
|
|
|
|
var dzi = {
|
|
|
|
Image: {
|
|
|
|
xmlns: $image.attr('xmlns'),
|
|
|
|
Url: "http://chrisjordan.com/dzi/" + imageKey + '_files/',
|
|
|
|
Format: $image.attr('Format'),
|
|
|
|
Overlap: $image.attr('Overlap'),
|
|
|
|
TileSize: $image.attr('TileSize'),
|
|
|
|
Size: {
|
|
|
|
Height: $size.attr('Height'),
|
|
|
|
Width: $size.attr('Width')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.viewer.open(dzi, {
|
|
|
|
width: 100
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
stanfordTest: function() {
|
|
|
|
var info = {"@context":"http://library.stanford.edu/iiif/image-api/1.1/context.json","@id":"http://ids.lib.harvard.edu/ids/iiif/48530377","width":6251,"height":109517,"scale_factors":[1,2,4,8,16,32],"tile_width":256,"tile_height":256,"formats":["jpg"],"qualities":["native"],"profile":"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1"};
|
|
|
|
|
|
|
|
this.viewer.open(info);
|
2014-07-18 03:24:28 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
App.init();
|
|
|
|
});
|
|
|
|
|
|
|
|
})();
|