refs #54 - added missing support for tilesource configuration as xml string or json string via Viewer.open

This commit is contained in:
thatcher 2013-03-26 14:35:43 -04:00
parent 86f101f02c
commit 9aecfddcbf
3 changed files with 14 additions and 9 deletions

View File

@ -216,6 +216,7 @@ function configureFromXML( tileSource, xmlDoc ){
configuration = {
Image: {
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
Url: root.getAttribute( "Url" ),
Format: root.getAttribute( "Format" ),
DisplayRect: null,
Overlap: parseInt( root.getAttribute( "Overlap" ), 10 ),
@ -315,8 +316,6 @@ function configureFromObject( tileSource, configuration ){
));
}
delete configuration.Image;
return $.extend(true, {
width: width, /* width *required */
height: height, /* height *required */

View File

@ -413,7 +413,7 @@ function processResponse( xhr ){
* @eprivate
* @inner
* @function
* @param {Object|Array} data - the tile source configuration object
* @param {Object|Array|Document} data - the tile source configuration object
* @param {String} url - the url where the tile source configuration object was
* loaded from, if any.
*/

View File

@ -309,18 +309,24 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
$TileSource,
options;
//allow plain xml strings or json strings to be parsed here
if( $.type( tileSource ) == 'string' ){
if( tileSource.match(/\s*<.*/) ){
tileSource = $.parseXml( tileSource );
}else if( tileSource.match(/\s*[\{\[].*/) ){
/*jshint evil:true*/
tileSource = eval( '('+tileSource+')' );
}
}
setTimeout(function(){
if ( $.type( tileSource ) == 'string') {
//TODO: We cant assume a string implies a dzi since all
//complete TileSource implementations should have a getInfo
//which allows them to be configured via AJAX. Im not sure
//if its better to use file extension or url pattern, or to
//inspect the resulting info object.
//If its still a string it means it must be a url at this point
tileSource = new $.TileSource( tileSource, function( readySource ){
openTileSource( _this, readySource );
});
} else if ( $.isPlainObject( tileSource ) ){
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){
if( $.isFunction( tileSource.getTileUrl ) ){
//Custom tile source
customTileSource = new $.TileSource(tileSource);