open: fix docs, tileHost

* Updated documentation to match actual parameters (see #53)
* tileHost was completely broken for dzi files. Now it's based on
  the DZI source URL (e.g. `foo.dzi` -> tileHost + `foo_files/` vs. `_files/`).
This commit is contained in:
Chris Adams 2013-03-25 16:36:13 -04:00
parent 3b1b9cd2f1
commit 6b39a81ef7

View File

@ -1389,9 +1389,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* and provides a callback hook for the resulting Document * and provides a callback hook for the resulting Document
* @function * @function
* @name OpenSeadragon.createFromDZI * @name OpenSeadragon.createFromDZI
* @param {String} xmlUrl * @param {String} dziUrlOrString
* @param {String} xmlString
* @param {Function} callback * @param {Function} callback
* @param {String} tileHostname
* @deprecated * @deprecated
*/ */
createFromDZI: function( dzi, callback, tileHost) { createFromDZI: function( dzi, callback, tileHost) {
@ -1408,13 +1408,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
tilesUrl, tilesUrl,
callbackName; callbackName;
if (tileHost) { if (tileHost) {
tilesUrl = tileHost + '/' + dziUrl.replace(/^.*\/(.*)\.dzi$/, '$1') + '_files/';
tilesUrl = tileHost + "/_files/";
} else if (dziUrl) { } else if (dziUrl) {
urlParts = dziUrl.split( '/' ); urlParts = dziUrl.split( '/' );
filename = urlParts[ urlParts.length - 1 ]; filename = urlParts[ urlParts.length - 1 ];
if( filename.match(/_dzi\.js$/) ){ if( filename.match(/_dzi\.js$/) ){
@ -1431,7 +1427,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
tilesUrl = urlParts.join( '/' ) + "_files/"; tilesUrl = urlParts.join( '/' ) + "_files/";
} }
function finish( func, obj ) { function finish( func, obj ) {
@ -1449,7 +1444,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
if ( async ) { if ( async ) {
if ( dziString ) { if ( dziString ) {
window.setTimeout( function() { window.setTimeout( function() {
var source = finish( processDZIXml, $.parseXml( xmlString ) ); var source = finish( processDZIXml, $.parseXml( dziString ) );
// call after finish sets error // call after finish sets error
callback( source, error ); callback( source, error );
}, 1); }, 1);