added inital support for moving to a nodejs build with grunt. build only includes concant and lint. fixed all lint warning where appropriate and added lint inline ignores where appropriate. when build script is complete we will start transition to new repo. also currently researching how to prune unfriendly portion of history that make repo large due to large binary files in web app. I like git well enough but using branches for web apps unrelated to code base has made me weary once again of social web fads that force convention without long term consideration of cost.

This commit is contained in:
thatcher 2013-02-12 22:40:08 -05:00
parent 855e753225
commit a0fd2b3324
16 changed files with 581 additions and 466 deletions

View File

@ -6,7 +6,7 @@
PROJECT: openseadragon PROJECT: openseadragon
BUILD_MAJOR: 0 BUILD_MAJOR: 0
BUILD_MINOR: 9 BUILD_MINOR: 9
BUILD_ID: 111 BUILD_ID: 113s
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}

71
grunt.js Normal file
View File

@ -0,0 +1,71 @@
module.exports = function(grunt) {
var distribution = "openseadragon.js",
sources = [
"src/openseadragon.js",
"src/eventhandler.js",
"src/mousetracker.js",
"src/control.js",
"src/controldock.js",
"src/viewer.js",
"src/navigator.js",
"src/strings.js",
"src/point.js",
//"src/profiler.js",
"src/tilesource.js",
"src/dzitilesource.js",
"src/iiiftilesource.js",
"src/osmtilesource.js",
"src/tmstilesource.js",
"src/legacytilesource.js",
"src/tilesourcecollection.js",
"src/button.js",
"src/buttongroup.js",
"src/rectangle.js",
"src/referencestrip.js",
"src/displayrectangle.js",
"src/spring.js",
"src/tile.js",
"src/overlay.js",
"src/drawer.js",
"src/viewport.js"
];
// Project configuration.
grunt.initConfig({
concat: {
dist: {
src: sources,
dest: distribution
}
},
lint: {
beforeconcat: sources,
afterconcat: [ distribution ]
},
jshint: {
options: {
browser: true,
eqeqeq: false,
loopfunc: false
/*curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,*/
},
globals: {
OpenSeadragon: true
}
}
});
// Default task.
grunt.registerTask('default', 'lint:beforeconcat concat lint:afterconcat');
};

View File

@ -1,7 +1,7 @@
/*globals OpenSeadragon*/ /*globals OpenSeadragon*/
/** /**
* @version OpenSeadragon 0.9.111 * @version OpenSeadragon 0.9.113s
* *
* @fileOverview * @fileOverview
* <h2> * <h2>
@ -315,7 +315,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* @see <a href='http://www.jquery.com/'>jQuery</a> * @see <a href='http://www.jquery.com/'>jQuery</a>
*/ */
$.type = function( obj ) { $.type = function( obj ) {
return obj == null ? return ( obj === null ) || ( obj === undefined ) ?
String( obj ) : String( obj ) :
class2type[ toString.call(obj) ] || "object"; class2type[ toString.call(obj) ] || "object";
}; };
@ -419,7 +419,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values // Only deal with non-null/undefined values
if ( ( options = arguments[ i ] ) != null ) { options = arguments[ i ];
if ( options !== null || options !== undefined ) {
// Extend the base object // Extend the base object
for ( name in options ) { for ( name in options ) {
src = target[ name ]; src = target[ name ];
@ -472,6 +473,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
//PAN AND ZOOM SETTINGS AND CONSTRAINTS //PAN AND ZOOM SETTINGS AND CONSTRAINTS
panHorizontal: true, panHorizontal: true,
panVertical: true, panVertical: true,
constrainDuringPan: false,
wrapHorizontal: false, wrapHorizontal: false,
wrapVertical: false, wrapVertical: false,
visibilityRatio: 0.5, visibilityRatio: 0.5,
@ -599,9 +601,11 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
*/ */
delegate: function( object, method ) { delegate: function( object, method ) {
return function(){ return function(){
if ( arguments === undefined ) var args = arguments;
arguments = []; if ( args === undefined ){
return method.apply( object, arguments ); args = [];
}
return method.apply( object, args );
}; };
}, },
@ -832,21 +836,21 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
window.innerWidth, window.innerWidth,
window.innerHeight window.innerHeight
); );
} };
} else if ( docElement.clientWidth || docElement.clientHeight ) { } else if ( docElement.clientWidth || docElement.clientHeight ) {
$.getWindowSize = function(){ $.getWindowSize = function(){
return new $.Point( return new $.Point(
document.documentElement.clientWidth, document.documentElement.clientWidth,
document.documentElement.clientHeight document.documentElement.clientHeight
); );
} };
} else if ( body.clientWidth || body.clientHeight ) { } else if ( body.clientWidth || body.clientHeight ) {
$.getWindowSize = function(){ $.getWindowSize = function(){
return new $.Point( return new $.Point(
document.body.clientWidth, document.body.clientWidth,
document.body.clientHeight document.body.clientHeight
); );
} };
} else { } else {
throw new Error("Unknown window size, no known technique."); throw new Error("Unknown window size, no known technique.");
} }
@ -1113,7 +1117,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
$.cancelEvent = function( event ){ $.cancelEvent = function( event ){
// W3C for preventing default // W3C for preventing default
event.preventDefault(); event.preventDefault();
} };
} else { } else {
$.cancelEvent = function( event ){ $.cancelEvent = function( event ){
event = $.getEvent( event ); event = $.getEvent( event );
@ -1212,6 +1216,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
// we could determine once at startup which activeX object // we could determine once at startup which activeX object
// was supported. This will have significant impact on // was supported. This will have significant impact on
// performance for IE Browsers DONE // performance for IE Browsers DONE
/*jshint loopfunc:true*/
for ( i = 0; i < ACTIVEX.length; i++ ) { for ( i = 0; i < ACTIVEX.length; i++ ) {
try { try {
request = new ActiveXObject( ACTIVEX[ i ] ); request = new ActiveXObject( ACTIVEX[ i ] );
@ -1268,7 +1273,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
/** @ignore */ /** @ignore */
request.onreadystatechange = function() { request.onreadystatechange = function() {
if ( request.readyState == 4) { if ( request.readyState == 4) {
request.onreadystatechange = new function() { }; request.onreadystatechange = function(){};
options.success( request ); options.success( request );
} }
}; };
@ -1692,7 +1697,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} else { } else {
return element.offsetParent; return element.offsetParent;
} }
}; }
/** /**
* @private * @private
@ -1724,7 +1729,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} }
return processDZIXml( doc, tilesUrl ); return processDZIXml( doc, tilesUrl );
}; }
/** /**
* @private * @private
@ -1758,7 +1763,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} }
throw new Error( $.getString( "Errors.Dzi" ) ); throw new Error( $.getString( "Errors.Dzi" ) );
}; }
/** /**
* @private * @private
@ -1772,10 +1777,10 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
var fileFormat = imageNode.getAttribute( "Format" ), var fileFormat = imageNode.getAttribute( "Format" ),
sizeNode = imageNode.getElementsByTagName( "Size" )[ 0 ], sizeNode = imageNode.getElementsByTagName( "Size" )[ 0 ],
dispRectNodes = imageNode.getElementsByTagName( "DisplayRect" ), dispRectNodes = imageNode.getElementsByTagName( "DisplayRect" ),
width = parseInt( sizeNode.getAttribute( "Width" ) ), width = parseInt( sizeNode.getAttribute( "Width" ), 10 ),
height = parseInt( sizeNode.getAttribute( "Height" ) ), height = parseInt( sizeNode.getAttribute( "Height" ), 10 ),
tileSize = parseInt( imageNode.getAttribute( "TileSize" ) ), tileSize = parseInt( imageNode.getAttribute( "TileSize" ), 10 ),
tileOverlap = parseInt( imageNode.getAttribute( "Overlap" ) ), tileOverlap = parseInt( imageNode.getAttribute( "Overlap" ), 10 ),
dispRects = [], dispRects = [],
dispRectNode, dispRectNode,
rectNode, rectNode,
@ -1792,12 +1797,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ]; rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ];
dispRects.push( new $.DisplayRect( dispRects.push( new $.DisplayRect(
parseInt( rectNode.getAttribute( "X" ) ), parseInt( rectNode.getAttribute( "X" ), 10 ),
parseInt( rectNode.getAttribute( "Y" ) ), parseInt( rectNode.getAttribute( "Y" ), 10 ),
parseInt( rectNode.getAttribute( "Width" ) ), parseInt( rectNode.getAttribute( "Width" ), 10 ),
parseInt( rectNode.getAttribute( "Height" ) ), parseInt( rectNode.getAttribute( "Height" ), 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( dispRectNode.getAttribute( "MaxLevel" ) ) parseInt( dispRectNode.getAttribute( "MaxLevel" ), 10 )
)); ));
} }
return new $.DziTileSource( return new $.DziTileSource(
@ -1809,7 +1814,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
fileFormat, fileFormat,
dispRects dispRects
); );
}; }
/** /**
* @private * @private
@ -1823,10 +1828,10 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
var fileFormat = imageData.Format, var fileFormat = imageData.Format,
sizeData = imageData.Size, sizeData = imageData.Size,
dispRectData = imageData.DisplayRect || [], dispRectData = imageData.DisplayRect || [],
width = parseInt( sizeData.Width ), width = parseInt( sizeData.Width, 10 ),
height = parseInt( sizeData.Height ), height = parseInt( sizeData.Height, 10 ),
tileSize = parseInt( imageData.TileSize ), tileSize = parseInt( imageData.TileSize, 10 ),
tileOverlap = parseInt( imageData.Overlap ), tileOverlap = parseInt( imageData.Overlap, 10 ),
dispRects = [], dispRects = [],
rectData, rectData,
i; i;
@ -1841,12 +1846,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
rectData = dispRectData[ i ].Rect; rectData = dispRectData[ i ].Rect;
dispRects.push( new $.DisplayRect( dispRects.push( new $.DisplayRect(
parseInt( rectData.X ), parseInt( rectData.X, 10 ),
parseInt( rectData.Y ), parseInt( rectData.Y, 10 ),
parseInt( rectData.Width ), parseInt( rectData.Width, 10 ),
parseInt( rectData.Height ), parseInt( rectData.Height, 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( rectData.MaxLevel ) parseInt( rectData.MaxLevel, 10 )
)); ));
} }
return new $.DziTileSource( return new $.DziTileSource(
@ -1858,7 +1863,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
fileFormat, fileFormat,
dispRects dispRects
); );
}; }
/** /**
* @private * @private
* @inner * @inner
@ -1872,9 +1878,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
message = messageNode.firstChild.nodeValue; message = messageNode.firstChild.nodeValue;
throw new Error(message); throw new Error(message);
}; }
}( OpenSeadragon )); }( OpenSeadragon ));
/*globals OpenSeadragon */ /*globals OpenSeadragon */
@ -2084,23 +2088,23 @@ $.EventHandler.prototype = {
* Position of last mouse down * Position of last mouse down
*/ */
THIS[ this.hash ] = { THIS[ this.hash ] = {
"mouseover": function( event ){ onMouseOver( _this, event ); }, mouseover: function( event ){ onMouseOver( _this, event ); },
"mouseout": function( event ){ onMouseOut( _this, event ); }, mouseout: function( event ){ onMouseOut( _this, event ); },
"mousedown": function( event ){ onMouseDown( _this, event ); }, mousedown: function( event ){ onMouseDown( _this, event ); },
"mouseup": function( event ){ onMouseUp( _this, event ); }, mouseup: function( event ){ onMouseUp( _this, event ); },
"click": function( event ){ onMouseClick( _this, event ); }, click: function( event ){ onMouseClick( _this, event ); },
"DOMMouseScroll": function( event ){ onMouseWheelSpin( _this, event ); }, DOMMouseScroll: function( event ){ onMouseWheelSpin( _this, event ); },
"mousewheel": function( event ){ onMouseWheelSpin( _this, event ); }, mousewheel: function( event ){ onMouseWheelSpin( _this, event ); },
"mouseupie": function( event ){ onMouseUpIE( _this, event ); }, mouseupie: function( event ){ onMouseUpIE( _this, event ); },
"mousemoveie": function( event ){ onMouseMoveIE( _this, event ); }, mousemoveie: function( event ){ onMouseMoveIE( _this, event ); },
"mouseupwindow": function( event ){ onMouseUpWindow( _this, event ); }, mouseupwindow: function( event ){ onMouseUpWindow( _this, event ); },
"mousemove": function( event ){ onMouseMove( _this, event ); }, mousemove: function( event ){ onMouseMove( _this, event ); },
"touchstart": function( event ){ onTouchStart( _this, event ); }, touchstart: function( event ){ onTouchStart( _this, event ); },
"touchmove": function( event ){ onTouchMove( _this, event ); }, touchmove: function( event ){ onTouchMove( _this, event ); },
"touchend": function( event ){ onTouchEnd( _this, event ); }, touchend: function( event ){ onTouchEnd( _this, event ); },
"keypress": function( event ){ onKeyPress( _this, event ); }, keypress: function( event ){ onKeyPress( _this, event ); },
"focus": function( event ){ onFocus( _this, event ); }, focus: function( event ){ onFocus( _this, event ); },
"blur": function( event ){ onBlur( _this, event ); }, blur: function( event ){ onBlur( _this, event ); },
tracking: false, tracking: false,
capturing: false, capturing: false,
buttonDown: false, buttonDown: false,
@ -2355,32 +2359,32 @@ $.EventHandler.prototype = {
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseup" ], delegate.mouseup,
false false
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseupie" ], delegate.mouseupie,
true true
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mousemove", "mousemove",
delegate[ "mousemoveie" ], delegate.mousemoveie,
true true
); );
} else { } else {
$.addEvent( $.addEvent(
window, window,
"mouseup", "mouseup",
delegate[ "mouseupwindow" ], delegate.mouseupwindow,
true true
); );
$.addEvent( $.addEvent(
window, window,
"mousemove", "mousemove",
delegate[ "mousemove" ], delegate.mousemove,
true true
); );
} }
@ -2402,32 +2406,32 @@ $.EventHandler.prototype = {
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mousemove", "mousemove",
delegate[ "mousemoveie" ], delegate.mousemoveie,
true true
); );
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseupie" ], delegate.mouseupie,
true true
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseup" ], delegate.mouseup,
false false
); );
} else { } else {
$.removeEvent( $.removeEvent(
window, window,
"mousemove", "mousemove",
delegate[ "mousemove" ], delegate.mousemove,
true true
); );
$.removeEvent( $.removeEvent(
window, window,
"mouseup", "mouseup",
delegate[ "mouseupwindow" ], delegate.mouseupwindow,
true true
); );
} }
@ -2501,7 +2505,7 @@ $.EventHandler.prototype = {
event.keyCode ? event.keyCode : event.charCode, event.keyCode ? event.keyCode : event.charCode,
event.shiftKey event.shiftKey
); );
if( propagate === false ){ if( !propagate ){
$.cancelEvent( event ); $.cancelEvent( event );
} }
} }
@ -2514,17 +2518,17 @@ $.EventHandler.prototype = {
*/ */
function onMouseOver( tracker, event ) { function onMouseOver( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( $.Browser.vendor == $.BROWSERS.IE && if ( $.Browser.vendor == $.BROWSERS.IE &&
$.Browser.version < 9 && $.Browser.version < 9 &&
delegate.capturing && delegate.capturing &&
!isChild( event.srcElement, tracker.element ) ) { !isChild( event.srcElement, tracker.element ) ) {
triggerOthers( tracker, onMouseOver, event ); triggerOthers( tracker, onMouseOver, event );
} }
var to = event.target ? var to = event.target ?
@ -2560,10 +2564,11 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function onMouseOut( tracker, event ) { function onMouseOut( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( $.Browser.vendor == $.BROWSERS.IE && if ( $.Browser.vendor == $.BROWSERS.IE &&
$.Browser.version < 9 && $.Browser.version < 9 &&
delegate.capturing && delegate.capturing &&
@ -2607,10 +2612,11 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function onMouseDown( tracker, event ) { function onMouseDown( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -2683,14 +2689,15 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function onMouseUp( tracker, event ) { function onMouseUp( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
//were we inside the tracked element when we were pressed //were we inside the tracked element when we were pressed
insideElementPress = delegate.buttonDown, insideElementPress = delegate.buttonDown,
//are we still inside the tracked element when we released //are we still inside the tracked element when we released
insideElementRelease = delegate.insideElement, insideElementRelease = delegate.insideElement,
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -2721,8 +2728,8 @@ $.EventHandler.prototype = {
*/ */
function onTouchEnd( tracker, event ) { function onTouchEnd( tracker, event ) {
if( event.touches.length == 0 && if( event.touches.length === 0 &&
event.targetTouches.length == 0 && event.targetTouches.length === 0 &&
event.changedTouches.length == 1 ){ event.changedTouches.length == 1 ){
THIS[ tracker.hash ].lastTouch = null; THIS[ tracker.hash ].lastTouch = null;
@ -2748,10 +2755,11 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function onMouseUpIE( tracker, event ) { function onMouseUpIE( tracker, event ) {
var event = $.getEvent( event ), var othertracker,
othertracker,
i; i;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -2846,10 +2854,11 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function handleMouseClick( tracker, event ) { function handleMouseClick( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -2879,11 +2888,14 @@ $.EventHandler.prototype = {
* @inner * @inner
*/ */
function onMouseMove( tracker, event ) { function onMouseMove( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ], delta,
point = getMouseAbsolute( event ), propagate,
delta = point.minus( delegate.lastPoint ), point;
propagate;
event = $.getEvent( event );
point = getMouseAbsolute( event );
delta = point.minus( delegate.lastPoint );
delegate.lastPoint = point; delegate.lastPoint = point;
@ -3790,7 +3802,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
overlay = this.overlayControls[ i ]; overlay = this.overlayControls[ i ];
if ( overlay.point != null ) { if ( overlay.point ) {
this.drawer.addOverlay( this.drawer.addOverlay(
overlay.id, overlay.id,
@ -4482,6 +4494,9 @@ function onCanvasDrag( tracker, position, delta, shift ) {
delta.negate() delta.negate()
) )
); );
if( this.constrainDuringPan ){
this.viewport.applyConstraints();
}
} }
} }
@ -5081,7 +5096,7 @@ $.extend( $, {
} }
return string.replace(/\{\d+\}/g, function(capture) { return string.replace(/\{\d+\}/g, function(capture) {
var i = parseInt( capture.match( /\d+/ ) ) + 1; var i = parseInt( capture.match( /\d+/ ), 10 ) + 1;
return i < args.length ? return i < args.length ?
args[ i ] : args[ i ] :
""; "";
@ -5341,6 +5356,7 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
$.extend( true, this, options ); $.extend( true, this, options );
//Any functions that are passed as arguments are bound to the ready callback //Any functions that are passed as arguments are bound to the ready callback
/*jshint loopfunc:true*/
for( i = 0; i < arguments.length; i++ ){ for( i = 0; i < arguments.length; i++ ){
if( $.isFunction( arguments[i] ) ){ if( $.isFunction( arguments[i] ) ){
callback = arguments[ i ]; callback = arguments[ i ];
@ -5470,7 +5486,6 @@ $.TileSource.prototype = {
*/ */
getImageInfo: function( url ) { getImageInfo: function( url ) {
var _this = this, var _this = this,
url = url,
error, error,
callbackName, callbackName,
callback, callback,
@ -5630,6 +5645,7 @@ function processResponse( xhr ){
data = xhr.responseText; data = xhr.responseText;
} }
}else if( responseText.match(/\s*[\{\[].*/) ){ }else if( responseText.match(/\s*[\{\[].*/) ){
/*jshint evil:true*/
data = eval( '('+responseText+')' ); data = eval( '('+responseText+')' );
}else{ }else{
data = responseText; data = responseText;
@ -5772,7 +5788,7 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
} }
if( url && !options.tilesUrl ){ if( url && !options.tilesUrl ){
if( !( 'http' == url.substring( 0, 4 ) ) ){ if( 'http' !== url.substring( 0, 4 ) ){
host = location.protocol + '//' + location.host; host = location.protocol + '//' + location.host;
} }
dziPath = url.split('/'); dziPath = url.split('/');
@ -5881,11 +5897,11 @@ function configureFromXML( tileSource, xmlDoc ){
xmlns: "http://schemas.microsoft.com/deepzoom/2008", xmlns: "http://schemas.microsoft.com/deepzoom/2008",
Format: root.getAttribute( "Format" ), Format: root.getAttribute( "Format" ),
DisplayRect: null, DisplayRect: null,
Overlap: parseInt( root.getAttribute( "Overlap" ) ), Overlap: parseInt( root.getAttribute( "Overlap" ), 10 ),
TileSize: parseInt( root.getAttribute( "TileSize" ) ), TileSize: parseInt( root.getAttribute( "TileSize" ), 10 ),
Size: { Size: {
Height: parseInt( sizeNode.getAttribute( "Height" ) ), Height: parseInt( sizeNode.getAttribute( "Height" ), 10 ),
Width: parseInt( sizeNode.getAttribute( "Width" ) ) Width: parseInt( sizeNode.getAttribute( "Width" ), 10 )
} }
} }
}; };
@ -5903,12 +5919,12 @@ function configureFromXML( tileSource, xmlDoc ){
displayRects.push({ displayRects.push({
Rect: { Rect: {
X: parseInt( rectNode.getAttribute( "X" ) ), X: parseInt( rectNode.getAttribute( "X" ), 10 ),
Y: parseInt( rectNode.getAttribute( "Y" ) ), Y: parseInt( rectNode.getAttribute( "Y" ), 10 ),
Width: parseInt( rectNode.getAttribute( "Width" ) ), Width: parseInt( rectNode.getAttribute( "Width" ), 10 ),
Height: parseInt( rectNode.getAttribute( "Height" ) ), Height: parseInt( rectNode.getAttribute( "Height" ), 10 ),
MinLevel: 0, // ignore MinLevel attribute, bug in Deep Zoom Composer MinLevel: 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
MaxLevel: parseInt( dispRectNode.getAttribute( "MaxLevel" ) ) MaxLevel: parseInt( dispRectNode.getAttribute( "MaxLevel" ), 10 )
} }
}); });
} }
@ -5931,7 +5947,7 @@ function configureFromXML( tileSource, xmlDoc ){
} }
throw new Error( $.getString( "Errors.Dzi" ) ); throw new Error( $.getString( "Errors.Dzi" ) );
}; }
/** /**
* @private * @private
@ -5944,10 +5960,10 @@ function configureFromObject( tileSource, configuration ){
fileFormat = imageData.Format, fileFormat = imageData.Format,
sizeData = imageData.Size, sizeData = imageData.Size,
dispRectData = imageData.DisplayRect || [], dispRectData = imageData.DisplayRect || [],
width = parseInt( sizeData.Width ), width = parseInt( sizeData.Width, 10 ),
height = parseInt( sizeData.Height ), height = parseInt( sizeData.Height, 10 ),
tileSize = parseInt( imageData.TileSize ), tileSize = parseInt( imageData.TileSize, 10 ),
tileOverlap = parseInt( imageData.Overlap ), tileOverlap = parseInt( imageData.Overlap, 10 ),
displayRects = [], displayRects = [],
rectData, rectData,
i; i;
@ -5969,12 +5985,12 @@ function configureFromObject( tileSource, configuration ){
rectData = dispRectData[ i ].Rect; rectData = dispRectData[ i ].Rect;
displayRects.push( new $.DisplayRect( displayRects.push( new $.DisplayRect(
parseInt( rectData.X ), parseInt( rectData.X, 10 ),
parseInt( rectData.Y ), parseInt( rectData.Y, 10 ),
parseInt( rectData.Width ), parseInt( rectData.Width, 10 ),
parseInt( rectData.Height ), parseInt( rectData.Height, 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( rectData.MaxLevel ) parseInt( rectData.MaxLevel, 10 )
)); ));
} }
@ -5991,7 +6007,7 @@ function configureFromObject( tileSource, configuration ){
displayRects: displayRects /* displayRects */ displayRects: displayRects /* displayRects */
}; };
}; }
}( OpenSeadragon )); }( OpenSeadragon ));
(function( $ ){ (function( $ ){
@ -6088,7 +6104,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
service = url.split('/'); service = url.split('/');
service.pop(); //info.json or info.xml service.pop(); //info.json or info.xml
service = service.join('/'); service = service.join('/');
if( !( 'http' == url.substring( 0, 4 ) ) ){ if( 'http' !== url.substring( 0, 4 ) ){
host = location.protocol + '//' + location.host; host = location.protocol + '//' + location.host;
service = host + service; service = host + service;
} }
@ -6188,7 +6204,6 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
</info> </info>
*/ */
function configureFromXml( tileSource, xmlDoc ){ function configureFromXml( tileSource, xmlDoc ){
var configuration = {};
//parse the xml //parse the xml
if ( !xmlDoc || !xmlDoc.documentElement ) { if ( !xmlDoc || !xmlDoc.documentElement ) {
@ -6207,14 +6222,12 @@ function configureFromXml( tileSource, xmlDoc ){
try { try {
configuration = { configuration = {
"ns": root.namespaceURI "ns": root.namespaceURI
}; };
parseXML( root, configuration ); parseXML( root, configuration );
return configureFromObject( tileSource, configuration ); return configureFromObject( tileSource, configuration );
} catch ( e ) { } catch ( e ) {
@ -6226,7 +6239,7 @@ function configureFromXml( tileSource, xmlDoc ){
throw new Error( $.getString( "Errors.IIIF" ) ); throw new Error( $.getString( "Errors.IIIF" ) );
}; }
/** /**
@ -6283,7 +6296,7 @@ function configureFromObject( tileSource, configuration ){
configuration.tilesUrl = configuration.image_host; configuration.tilesUrl = configuration.image_host;
} }
return configuration; return configuration;
}; }
}( OpenSeadragon ));(function( $ ){ }( OpenSeadragon ));(function( $ ){
@ -6360,7 +6373,7 @@ $.extend( $.OsmTileSource.prototype, $.TileSource.prototype, {
return ( return (
data.type && data.type &&
"openstreetmaps" == data.type "openstreetmaps" == data.type
) );
}, },
/** /**
@ -6781,7 +6794,7 @@ $.TileSourceCollection = function( tileSize, tileSources, rows, layout ) {
tilesPerRow = Math.ceil( options.tileSources.length / options.rows ), tilesPerRow = Math.ceil( options.tileSources.length / options.rows ),
longSide = tilesPerRow >= options.rows ? longSide = tilesPerRow >= options.rows ?
tilesPerRow : tilesPerRow :
options.rows options.rows;
if( 'horizontal' == options.layout ){ if( 'horizontal' == options.layout ){
options.width = ( options.tileSize ) * tilesPerRow; options.width = ( options.tileSize ) * tilesPerRow;
@ -6840,7 +6853,7 @@ $.extend( $.TileSourceCollection.prototype, $.TileSource.prototype, {
* @name OpenSeadragon.TileSourceCollection.prototype.configure * @name OpenSeadragon.TileSourceCollection.prototype.configure
*/ */
configure: function( data, url ){ configure: function( data, url ){
return return;
}, },
@ -7441,6 +7454,7 @@ $.Rect.prototype = {
}( OpenSeadragon )); }( OpenSeadragon ));
(function( $ ){ (function( $ ){
// dictionary from id to private properties // dictionary from id to private properties
@ -7473,6 +7487,7 @@ $.ReferenceStrip = function( options ){
miniViewer, miniViewer,
minPixelRatio, minPixelRatio,
element, element,
style,
i; i;
//We may need to create a new element and id if they did not //We may need to create a new element and id if they did not
@ -7501,7 +7516,6 @@ $.ReferenceStrip = function( options ){
}); });
$.extend( this, options ); $.extend( this, options );
//Private state properties //Private state properties
THIS[ this.id ] = { THIS[ this.id ] = {
"animating": false "animating": false
@ -7509,7 +7523,7 @@ $.ReferenceStrip = function( options ){
this.minPixelRatio = this.viewer.minPixelRatio; this.minPixelRatio = this.viewer.minPixelRatio;
(function( style ){ style = thie.element.style;
style.marginTop = '0px'; style.marginTop = '0px';
style.marginRight = '0px'; style.marginRight = '0px';
style.marginBottom = '0px'; style.marginBottom = '0px';
@ -7519,7 +7533,6 @@ $.ReferenceStrip = function( options ){
style.border = '0px'; style.border = '0px';
style.background = '#000'; style.background = '#000';
style.position = 'relative'; style.position = 'relative';
}( this.element.style ));
$.setElementOpacity( this.element, 0.8 ); $.setElementOpacity( this.element, 0.8 );
@ -7533,8 +7546,6 @@ $.ReferenceStrip = function( options ){
keyHandler: $.delegate( this, onKeyPress ) keyHandler: $.delegate( this, onKeyPress )
}).setTracking( true ); }).setTracking( true );
//Controls the position and orientation of the reference strip and sets the //Controls the position and orientation of the reference strip and sets the
//appropriate width and height //appropriate width and height
if( options.width && options.height ){ if( options.width && options.height ){
@ -7585,32 +7596,31 @@ $.ReferenceStrip = function( options ){
this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8; this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8;
this.panels = []; this.panels = [];
/*jshint loopfunc:true*/
for( i = 0; i < viewer.tileSources.length; i++ ){ for( i = 0; i < viewer.tileSources.length; i++ ){
element = $.makeNeutralElement('div'); element = $.makeNeutralElement('div');
element.id = this.element.id + "-" + i; element.id = this.element.id + "-" + i;
(function(style){ element.style.width = _this.panelWidth + 'px';
style.width = _this.panelWidth + 'px'; element.style.height = _this.panelHeight + 'px';
style.height = _this.panelHeight + 'px'; element.style.display = 'inline';
style.display = 'inline'; element.style.float = 'left'; //Webkit
style.float = 'left'; //Webkit element.style.cssFloat = 'left'; //Firefox
style.cssFloat = 'left'; //Firefox element.style.styleFloat = 'left'; //IE
style.styleFloat = 'left'; //IE element.style.padding = '2px';
style.padding = '2px';
}(element.style));
element.innerTracker = new $.MouseTracker({ element.innerTracker = new $.MouseTracker({
element: element, element: element,
clickTimeThreshold: this.clickTimeThreshold, clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold, clickDistThreshold: this.clickDistThreshold,
pressHandler: function( tracker ){ pressHandler: function( tracker ){
tracker.dragging = +new Date; tracker.dragging = +new Date();
}, },
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){ releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
var id = tracker.element.id, var id = tracker.element.id,
page = Number( id.split( '-' )[ 2 ] ), page = Number( id.split( '-' )[ 2 ] ),
now = +new Date; now = +new Date();
if ( insideElementPress && if ( insideElementPress &&
insideElementRelease && insideElementRelease &&
@ -7747,7 +7757,7 @@ function onStripDrag( tracker, position, delta, shift ) {
} }
return false; return false;
}; }
@ -7795,7 +7805,7 @@ function onStripScroll( tracker, position, scroll, shift ) {
} }
//cancels event //cancels event
return false; return false;
}; }
function loadPanels(strip, viewerSize, scroll){ function loadPanels(strip, viewerSize, scroll){
@ -7803,6 +7813,7 @@ function loadPanels(strip, viewerSize, scroll){
activePanelsStart, activePanelsStart,
activePanelsEnd, activePanelsEnd,
miniViewer, miniViewer,
style,
i; i;
if( 'horizontal' == strip.scroll ){ if( 'horizontal' == strip.scroll ){
panelSize = strip.panelWidth; panelSize = strip.panelWidth;
@ -7833,7 +7844,7 @@ function loadPanels(strip, viewerSize, scroll){
miniViewer.displayRegion.id = element.id + '-displayregion'; miniViewer.displayRegion.id = element.id + '-displayregion';
miniViewer.displayRegion.className = 'displayregion'; miniViewer.displayRegion.className = 'displayregion';
(function( style ){ style = miniViewer.displayRegion.style;
style.position = 'relative'; style.position = 'relative';
style.top = '0px'; style.top = '0px';
style.left = '0px'; style.left = '0px';
@ -7846,7 +7857,6 @@ function loadPanels(strip, viewerSize, scroll){
style.cursor = 'default'; style.cursor = 'default';
style.width = ( strip.panelWidth - 4 ) + 'px'; style.width = ( strip.panelWidth - 4 ) + 'px';
style.height = ( strip.panelHeight - 4 ) + 'px'; style.height = ( strip.panelHeight - 4 ) + 'px';
}( miniViewer.displayRegion.style ));
miniViewer.displayRegion.innerTracker = new $.MouseTracker({ miniViewer.displayRegion.innerTracker = new $.MouseTracker({
element: miniViewer.displayRegion element: miniViewer.displayRegion
@ -7859,7 +7869,7 @@ function loadPanels(strip, viewerSize, scroll){
element.activePanel = true; element.activePanel = true;
} }
} }
}; }
/** /**
@ -7885,8 +7895,8 @@ function onStripEnter( tracker ) {
tracker.element.style.marginLeft = "0px"; tracker.element.style.marginLeft = "0px";
} }
return false return false;
}; }
/** /**
@ -7915,7 +7925,7 @@ function onStripExit( tracker ) {
} }
return false; return false;
}; }
@ -7957,7 +7967,7 @@ function onKeyPress( tracker, keyCode, shiftKey ){
//console.log( 'navigator keycode %s', keyCode ); //console.log( 'navigator keycode %s', keyCode );
return true; return true;
} }
}; }
@ -8507,10 +8517,10 @@ var DEVICE_SCREEN = $.getWindowSize(),
( BROWSER == $.BROWSERS.IE && BROWSER_VERSION >= 9 ) ( BROWSER == $.BROWSERS.IE && BROWSER_VERSION >= 9 )
), ),
USE_CANVAS = SUBPIXEL_RENDERING USE_CANVAS = SUBPIXEL_RENDERING &&
&& !( DEVICE_SCREEN.x <= 400 || DEVICE_SCREEN.y <= 400 ) !( DEVICE_SCREEN.x <= 400 || DEVICE_SCREEN.y <= 400 ) &&
&& !( navigator.appVersion.match( 'Mobile' ) ) !( navigator.appVersion.match( 'Mobile' ) ) &&
&& $.isFunction( document.createElement( "canvas" ).getContext ); $.isFunction( document.createElement( "canvas" ).getContext );
//console.error( 'USE_CANVAS ' + USE_CANVAS ); //console.error( 'USE_CANVAS ' + USE_CANVAS );
@ -8604,50 +8614,7 @@ $.Drawer = function( options ) {
for( i = 0; i < this.overlays.length; i++ ){ for( i = 0; i < this.overlays.length; i++ ){
if( $.isPlainObject( this.overlays[ i ] ) ){ if( $.isPlainObject( this.overlays[ i ] ) ){
(function( _this, overlay ){ addOverlayFromConfiguration( this, this.overlays[ i ]);
var element = null,
rect = ( overlay.height && overlay.width ) ? new $.Rect(
overlay.x || overlay.px,
overlay.y || overlay.py,
overlay.width,
overlay.height
) : new $.Point(
overlay.x || overlay.px,
overlay.y || overlay.py
),
id = overlay.id ?
overlay.id :
"openseadragon-overlay-"+Math.floor(Math.random()*10000000);
element = $.getElement(overlay.id);
if( !element ){
element = document.createElement("a");
element.href = "#/overlay/"+id;
}
element.id = id;
element.className = element.className + " " + ( overlay.className ?
overlay.className :
"openseadragon-overlay"
);
if(overlay.px !== undefined){
//if they specified 'px' so its in pixel coordinates so
//we need to translate to viewport coordinates
rect = _this.viewport.imageToViewportRectangle( rect );
}
if( overlay.placement ){
_this.overlays[ i ] = new $.Overlay(
element,
_this.viewport.pointFromPixel(rect),
$.OverlayPlacement[overlay.placement.toUpperCase()]
);
}else{
_this.overlays[ i ] = new $.Overlay( element, rect );
}
}( this, this.overlays[ i ] ));
} else if ( $.isFunction( this.overlays[ i ] ) ){ } else if ( $.isFunction( this.overlays[ i ] ) ){
//TODO //TODO
@ -8851,6 +8818,55 @@ $.Drawer.prototype = {
} }
}; };
/**
* @private
* @inner
*/
function addOverlayFromConfiguration( drawer, overlay ){
var element = null,
rect = ( overlay.height && overlay.width ) ? new $.Rect(
overlay.x || overlay.px,
overlay.y || overlay.py,
overlay.width,
overlay.height
) : new $.Point(
overlay.x || overlay.px,
overlay.y || overlay.py
),
id = overlay.id ?
overlay.id :
"openseadragon-overlay-"+Math.floor(Math.random()*10000000);
element = $.getElement(overlay.id);
if( !element ){
element = document.createElement("a");
element.href = "#/overlay/"+id;
}
element.id = id;
element.className = element.className + " " + ( overlay.className ?
overlay.className :
"openseadragon-overlay"
);
if(overlay.px !== undefined){
//if they specified 'px' so its in pixel coordinates so
//we need to translate to viewport coordinates
rect = drawer.viewport.imageToViewportRectangle( rect );
}
if( overlay.placement ){
drawer.overlays[ i ] = new $.Overlay(
element,
drawer.viewport.pointFromPixel(rect),
$.OverlayPlacement[overlay.placement.toUpperCase()]
);
}else{
drawer.overlays[ i ] = new $.Overlay( element, rect );
}
}
/** /**
* @private * @private
* @inner * @inner
@ -9514,20 +9530,18 @@ function drawTiles( drawer, lastDrawn ){
] ]
}); });
(function(style){
//TODO: IE seems to barf on this, not sure if its just the border //TODO: IE seems to barf on this, not sure if its just the border
// but we probably need to clear this up with a better // but we probably need to clear this up with a better
// test of support for various css features // test of support for various css features
if( SUBPIXEL_RENDERING ){ if( SUBPIXEL_RENDERING ){
style['-webkit-box-reflect'] = viewer.element.style.border = '1px solid rgba(255,255,255,0.38)';
viewer.element.style['-webkit-box-reflect'] =
'below 0px -webkit-gradient('+ 'below 0px -webkit-gradient('+
'linear,left '+ 'linear,left '+
'top,left '+ 'top,left '+
'bottom,from(transparent),color-stop(62%,transparent),to(rgba(255,255,255,0.62))'+ 'bottom,from(transparent),color-stop(62%,transparent),to(rgba(255,255,255,0.62))'+
')'; ')';
style['border'] = '1px solid rgba(255,255,255,0.38)';
} }
}(viewer.element.style));
drawer.addOverlay( drawer.addOverlay(
viewer.element, viewer.element,
@ -9579,7 +9593,7 @@ function drawDebugInfo( drawer, tile, count, i ){
tile.size.x, tile.size.x,
tile.size.y tile.size.y
); );
if( tile.x == 0 && tile.y == 0 ){ if( tile.x === 0 && tile.y === 0 ){
drawer.context.fillText( drawer.context.fillText(
"Zoom: " + drawer.viewport.getZoom(), "Zoom: " + drawer.viewport.getZoom(),
tile.position.x, tile.position.x,

4
package.json Normal file
View File

@ -0,0 +1,4 @@
{
"name": "openseadragon",
"version": "0.9.113"
}

View File

@ -14,10 +14,10 @@ var DEVICE_SCREEN = $.getWindowSize(),
( BROWSER == $.BROWSERS.IE && BROWSER_VERSION >= 9 ) ( BROWSER == $.BROWSERS.IE && BROWSER_VERSION >= 9 )
), ),
USE_CANVAS = SUBPIXEL_RENDERING USE_CANVAS = SUBPIXEL_RENDERING &&
&& !( DEVICE_SCREEN.x <= 400 || DEVICE_SCREEN.y <= 400 ) !( DEVICE_SCREEN.x <= 400 || DEVICE_SCREEN.y <= 400 ) &&
&& !( navigator.appVersion.match( 'Mobile' ) ) !( navigator.appVersion.match( 'Mobile' ) ) &&
&& $.isFunction( document.createElement( "canvas" ).getContext ); $.isFunction( document.createElement( "canvas" ).getContext );
//console.error( 'USE_CANVAS ' + USE_CANVAS ); //console.error( 'USE_CANVAS ' + USE_CANVAS );
@ -111,50 +111,7 @@ $.Drawer = function( options ) {
for( i = 0; i < this.overlays.length; i++ ){ for( i = 0; i < this.overlays.length; i++ ){
if( $.isPlainObject( this.overlays[ i ] ) ){ if( $.isPlainObject( this.overlays[ i ] ) ){
(function( _this, overlay ){ addOverlayFromConfiguration( this, this.overlays[ i ]);
var element = null,
rect = ( overlay.height && overlay.width ) ? new $.Rect(
overlay.x || overlay.px,
overlay.y || overlay.py,
overlay.width,
overlay.height
) : new $.Point(
overlay.x || overlay.px,
overlay.y || overlay.py
),
id = overlay.id ?
overlay.id :
"openseadragon-overlay-"+Math.floor(Math.random()*10000000);
element = $.getElement(overlay.id);
if( !element ){
element = document.createElement("a");
element.href = "#/overlay/"+id;
}
element.id = id;
element.className = element.className + " " + ( overlay.className ?
overlay.className :
"openseadragon-overlay"
);
if(overlay.px !== undefined){
//if they specified 'px' so its in pixel coordinates so
//we need to translate to viewport coordinates
rect = _this.viewport.imageToViewportRectangle( rect );
}
if( overlay.placement ){
_this.overlays[ i ] = new $.Overlay(
element,
_this.viewport.pointFromPixel(rect),
$.OverlayPlacement[overlay.placement.toUpperCase()]
);
}else{
_this.overlays[ i ] = new $.Overlay( element, rect );
}
}( this, this.overlays[ i ] ));
} else if ( $.isFunction( this.overlays[ i ] ) ){ } else if ( $.isFunction( this.overlays[ i ] ) ){
//TODO //TODO
@ -358,6 +315,55 @@ $.Drawer.prototype = {
} }
}; };
/**
* @private
* @inner
*/
function addOverlayFromConfiguration( drawer, overlay ){
var element = null,
rect = ( overlay.height && overlay.width ) ? new $.Rect(
overlay.x || overlay.px,
overlay.y || overlay.py,
overlay.width,
overlay.height
) : new $.Point(
overlay.x || overlay.px,
overlay.y || overlay.py
),
id = overlay.id ?
overlay.id :
"openseadragon-overlay-"+Math.floor(Math.random()*10000000);
element = $.getElement(overlay.id);
if( !element ){
element = document.createElement("a");
element.href = "#/overlay/"+id;
}
element.id = id;
element.className = element.className + " " + ( overlay.className ?
overlay.className :
"openseadragon-overlay"
);
if(overlay.px !== undefined){
//if they specified 'px' so its in pixel coordinates so
//we need to translate to viewport coordinates
rect = drawer.viewport.imageToViewportRectangle( rect );
}
if( overlay.placement ){
drawer.overlays[ i ] = new $.Overlay(
element,
drawer.viewport.pointFromPixel(rect),
$.OverlayPlacement[overlay.placement.toUpperCase()]
);
}else{
drawer.overlays[ i ] = new $.Overlay( element, rect );
}
}
/** /**
* @private * @private
* @inner * @inner
@ -1021,20 +1027,18 @@ function drawTiles( drawer, lastDrawn ){
] ]
}); });
(function(style){
//TODO: IE seems to barf on this, not sure if its just the border //TODO: IE seems to barf on this, not sure if its just the border
// but we probably need to clear this up with a better // but we probably need to clear this up with a better
// test of support for various css features // test of support for various css features
if( SUBPIXEL_RENDERING ){ if( SUBPIXEL_RENDERING ){
style['-webkit-box-reflect'] = viewer.element.style.border = '1px solid rgba(255,255,255,0.38)';
viewer.element.style['-webkit-box-reflect'] =
'below 0px -webkit-gradient('+ 'below 0px -webkit-gradient('+
'linear,left '+ 'linear,left '+
'top,left '+ 'top,left '+
'bottom,from(transparent),color-stop(62%,transparent),to(rgba(255,255,255,0.62))'+ 'bottom,from(transparent),color-stop(62%,transparent),to(rgba(255,255,255,0.62))'+
')'; ')';
style['border'] = '1px solid rgba(255,255,255,0.38)';
} }
}(viewer.element.style));
drawer.addOverlay( drawer.addOverlay(
viewer.element, viewer.element,
@ -1086,7 +1090,7 @@ function drawDebugInfo( drawer, tile, count, i ){
tile.size.x, tile.size.x,
tile.size.y tile.size.y
); );
if( tile.x == 0 && tile.y == 0 ){ if( tile.x === 0 && tile.y === 0 ){
drawer.context.fillText( drawer.context.fillText(
"Zoom: " + drawer.viewport.getZoom(), "Zoom: " + drawer.viewport.getZoom(),
tile.position.x, tile.position.x,

View File

@ -107,7 +107,7 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
} }
if( url && !options.tilesUrl ){ if( url && !options.tilesUrl ){
if( !( 'http' == url.substring( 0, 4 ) ) ){ if( 'http' !== url.substring( 0, 4 ) ){
host = location.protocol + '//' + location.host; host = location.protocol + '//' + location.host;
} }
dziPath = url.split('/'); dziPath = url.split('/');
@ -216,11 +216,11 @@ function configureFromXML( tileSource, xmlDoc ){
xmlns: "http://schemas.microsoft.com/deepzoom/2008", xmlns: "http://schemas.microsoft.com/deepzoom/2008",
Format: root.getAttribute( "Format" ), Format: root.getAttribute( "Format" ),
DisplayRect: null, DisplayRect: null,
Overlap: parseInt( root.getAttribute( "Overlap" ) ), Overlap: parseInt( root.getAttribute( "Overlap" ), 10 ),
TileSize: parseInt( root.getAttribute( "TileSize" ) ), TileSize: parseInt( root.getAttribute( "TileSize" ), 10 ),
Size: { Size: {
Height: parseInt( sizeNode.getAttribute( "Height" ) ), Height: parseInt( sizeNode.getAttribute( "Height" ), 10 ),
Width: parseInt( sizeNode.getAttribute( "Width" ) ) Width: parseInt( sizeNode.getAttribute( "Width" ), 10 )
} }
} }
}; };
@ -238,12 +238,12 @@ function configureFromXML( tileSource, xmlDoc ){
displayRects.push({ displayRects.push({
Rect: { Rect: {
X: parseInt( rectNode.getAttribute( "X" ) ), X: parseInt( rectNode.getAttribute( "X" ), 10 ),
Y: parseInt( rectNode.getAttribute( "Y" ) ), Y: parseInt( rectNode.getAttribute( "Y" ), 10 ),
Width: parseInt( rectNode.getAttribute( "Width" ) ), Width: parseInt( rectNode.getAttribute( "Width" ), 10 ),
Height: parseInt( rectNode.getAttribute( "Height" ) ), Height: parseInt( rectNode.getAttribute( "Height" ), 10 ),
MinLevel: 0, // ignore MinLevel attribute, bug in Deep Zoom Composer MinLevel: 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
MaxLevel: parseInt( dispRectNode.getAttribute( "MaxLevel" ) ) MaxLevel: parseInt( dispRectNode.getAttribute( "MaxLevel" ), 10 )
} }
}); });
} }
@ -266,7 +266,7 @@ function configureFromXML( tileSource, xmlDoc ){
} }
throw new Error( $.getString( "Errors.Dzi" ) ); throw new Error( $.getString( "Errors.Dzi" ) );
}; }
/** /**
* @private * @private
@ -279,10 +279,10 @@ function configureFromObject( tileSource, configuration ){
fileFormat = imageData.Format, fileFormat = imageData.Format,
sizeData = imageData.Size, sizeData = imageData.Size,
dispRectData = imageData.DisplayRect || [], dispRectData = imageData.DisplayRect || [],
width = parseInt( sizeData.Width ), width = parseInt( sizeData.Width, 10 ),
height = parseInt( sizeData.Height ), height = parseInt( sizeData.Height, 10 ),
tileSize = parseInt( imageData.TileSize ), tileSize = parseInt( imageData.TileSize, 10 ),
tileOverlap = parseInt( imageData.Overlap ), tileOverlap = parseInt( imageData.Overlap, 10 ),
displayRects = [], displayRects = [],
rectData, rectData,
i; i;
@ -304,12 +304,12 @@ function configureFromObject( tileSource, configuration ){
rectData = dispRectData[ i ].Rect; rectData = dispRectData[ i ].Rect;
displayRects.push( new $.DisplayRect( displayRects.push( new $.DisplayRect(
parseInt( rectData.X ), parseInt( rectData.X, 10 ),
parseInt( rectData.Y ), parseInt( rectData.Y, 10 ),
parseInt( rectData.Width ), parseInt( rectData.Width, 10 ),
parseInt( rectData.Height ), parseInt( rectData.Height, 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( rectData.MaxLevel ) parseInt( rectData.MaxLevel, 10 )
)); ));
} }
@ -326,6 +326,6 @@ function configureFromObject( tileSource, configuration ){
displayRects: displayRects /* displayRects */ displayRects: displayRects /* displayRects */
}; };
}; }
}( OpenSeadragon )); }( OpenSeadragon ));

View File

@ -92,7 +92,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
service = url.split('/'); service = url.split('/');
service.pop(); //info.json or info.xml service.pop(); //info.json or info.xml
service = service.join('/'); service = service.join('/');
if( !( 'http' == url.substring( 0, 4 ) ) ){ if( 'http' !== url.substring( 0, 4 ) ){
host = location.protocol + '//' + location.host; host = location.protocol + '//' + location.host;
service = host + service; service = host + service;
} }
@ -192,7 +192,6 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
</info> </info>
*/ */
function configureFromXml( tileSource, xmlDoc ){ function configureFromXml( tileSource, xmlDoc ){
var configuration = {};
//parse the xml //parse the xml
if ( !xmlDoc || !xmlDoc.documentElement ) { if ( !xmlDoc || !xmlDoc.documentElement ) {
@ -211,14 +210,12 @@ function configureFromXml( tileSource, xmlDoc ){
try { try {
configuration = { configuration = {
"ns": root.namespaceURI "ns": root.namespaceURI
}; };
parseXML( root, configuration ); parseXML( root, configuration );
return configureFromObject( tileSource, configuration ); return configureFromObject( tileSource, configuration );
} catch ( e ) { } catch ( e ) {
@ -230,7 +227,7 @@ function configureFromXml( tileSource, xmlDoc ){
throw new Error( $.getString( "Errors.IIIF" ) ); throw new Error( $.getString( "Errors.IIIF" ) );
}; }
/** /**
@ -287,6 +284,6 @@ function configureFromObject( tileSource, configuration ){
configuration.tilesUrl = configuration.image_host; configuration.tilesUrl = configuration.image_host;
} }
return configuration; return configuration;
}; }
}( OpenSeadragon )); }( OpenSeadragon ));

View File

@ -108,23 +108,23 @@
* Position of last mouse down * Position of last mouse down
*/ */
THIS[ this.hash ] = { THIS[ this.hash ] = {
"mouseover": function( event ){ onMouseOver( _this, event ); }, mouseover: function( event ){ onMouseOver( _this, event ); },
"mouseout": function( event ){ onMouseOut( _this, event ); }, mouseout: function( event ){ onMouseOut( _this, event ); },
"mousedown": function( event ){ onMouseDown( _this, event ); }, mousedown: function( event ){ onMouseDown( _this, event ); },
"mouseup": function( event ){ onMouseUp( _this, event ); }, mouseup: function( event ){ onMouseUp( _this, event ); },
"click": function( event ){ onMouseClick( _this, event ); }, click: function( event ){ onMouseClick( _this, event ); },
"DOMMouseScroll": function( event ){ onMouseWheelSpin( _this, event ); }, DOMMouseScroll: function( event ){ onMouseWheelSpin( _this, event ); },
"mousewheel": function( event ){ onMouseWheelSpin( _this, event ); }, mousewheel: function( event ){ onMouseWheelSpin( _this, event ); },
"mouseupie": function( event ){ onMouseUpIE( _this, event ); }, mouseupie: function( event ){ onMouseUpIE( _this, event ); },
"mousemoveie": function( event ){ onMouseMoveIE( _this, event ); }, mousemoveie: function( event ){ onMouseMoveIE( _this, event ); },
"mouseupwindow": function( event ){ onMouseUpWindow( _this, event ); }, mouseupwindow: function( event ){ onMouseUpWindow( _this, event ); },
"mousemove": function( event ){ onMouseMove( _this, event ); }, mousemove: function( event ){ onMouseMove( _this, event ); },
"touchstart": function( event ){ onTouchStart( _this, event ); }, touchstart: function( event ){ onTouchStart( _this, event ); },
"touchmove": function( event ){ onTouchMove( _this, event ); }, touchmove: function( event ){ onTouchMove( _this, event ); },
"touchend": function( event ){ onTouchEnd( _this, event ); }, touchend: function( event ){ onTouchEnd( _this, event ); },
"keypress": function( event ){ onKeyPress( _this, event ); }, keypress: function( event ){ onKeyPress( _this, event ); },
"focus": function( event ){ onFocus( _this, event ); }, focus: function( event ){ onFocus( _this, event ); },
"blur": function( event ){ onBlur( _this, event ); }, blur: function( event ){ onBlur( _this, event ); },
tracking: false, tracking: false,
capturing: false, capturing: false,
buttonDown: false, buttonDown: false,
@ -379,32 +379,32 @@
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseup" ], delegate.mouseup,
false false
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseupie" ], delegate.mouseupie,
true true
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mousemove", "mousemove",
delegate[ "mousemoveie" ], delegate.mousemoveie,
true true
); );
} else { } else {
$.addEvent( $.addEvent(
window, window,
"mouseup", "mouseup",
delegate[ "mouseupwindow" ], delegate.mouseupwindow,
true true
); );
$.addEvent( $.addEvent(
window, window,
"mousemove", "mousemove",
delegate[ "mousemove" ], delegate.mousemove,
true true
); );
} }
@ -426,32 +426,32 @@
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mousemove", "mousemove",
delegate[ "mousemoveie" ], delegate.mousemoveie,
true true
); );
$.removeEvent( $.removeEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseupie" ], delegate.mouseupie,
true true
); );
$.addEvent( $.addEvent(
tracker.element, tracker.element,
"mouseup", "mouseup",
delegate[ "mouseup" ], delegate.mouseup,
false false
); );
} else { } else {
$.removeEvent( $.removeEvent(
window, window,
"mousemove", "mousemove",
delegate[ "mousemove" ], delegate.mousemove,
true true
); );
$.removeEvent( $.removeEvent(
window, window,
"mouseup", "mouseup",
delegate[ "mouseupwindow" ], delegate.mouseupwindow,
true true
); );
} }
@ -525,7 +525,7 @@
event.keyCode ? event.keyCode : event.charCode, event.keyCode ? event.keyCode : event.charCode,
event.shiftKey event.shiftKey
); );
if( propagate === false ){ if( !propagate ){
$.cancelEvent( event ); $.cancelEvent( event );
} }
} }
@ -538,17 +538,17 @@
*/ */
function onMouseOver( tracker, event ) { function onMouseOver( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( $.Browser.vendor == $.BROWSERS.IE && if ( $.Browser.vendor == $.BROWSERS.IE &&
$.Browser.version < 9 && $.Browser.version < 9 &&
delegate.capturing && delegate.capturing &&
!isChild( event.srcElement, tracker.element ) ) { !isChild( event.srcElement, tracker.element ) ) {
triggerOthers( tracker, onMouseOver, event ); triggerOthers( tracker, onMouseOver, event );
} }
var to = event.target ? var to = event.target ?
@ -584,10 +584,11 @@
* @inner * @inner
*/ */
function onMouseOut( tracker, event ) { function onMouseOut( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( $.Browser.vendor == $.BROWSERS.IE && if ( $.Browser.vendor == $.BROWSERS.IE &&
$.Browser.version < 9 && $.Browser.version < 9 &&
delegate.capturing && delegate.capturing &&
@ -631,10 +632,11 @@
* @inner * @inner
*/ */
function onMouseDown( tracker, event ) { function onMouseDown( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -707,14 +709,15 @@
* @inner * @inner
*/ */
function onMouseUp( tracker, event ) { function onMouseUp( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
//were we inside the tracked element when we were pressed //were we inside the tracked element when we were pressed
insideElementPress = delegate.buttonDown, insideElementPress = delegate.buttonDown,
//are we still inside the tracked element when we released //are we still inside the tracked element when we released
insideElementRelease = delegate.insideElement, insideElementRelease = delegate.insideElement,
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -745,8 +748,8 @@
*/ */
function onTouchEnd( tracker, event ) { function onTouchEnd( tracker, event ) {
if( event.touches.length == 0 && if( event.touches.length === 0 &&
event.targetTouches.length == 0 && event.targetTouches.length === 0 &&
event.changedTouches.length == 1 ){ event.changedTouches.length == 1 ){
THIS[ tracker.hash ].lastTouch = null; THIS[ tracker.hash ].lastTouch = null;
@ -772,10 +775,11 @@
* @inner * @inner
*/ */
function onMouseUpIE( tracker, event ) { function onMouseUpIE( tracker, event ) {
var event = $.getEvent( event ), var othertracker,
othertracker,
i; i;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -870,10 +874,11 @@
* @inner * @inner
*/ */
function handleMouseClick( tracker, event ) { function handleMouseClick( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ],
propagate; propagate;
event = $.getEvent( event );
if ( event.button == 2 ) { if ( event.button == 2 ) {
return; return;
} }
@ -903,11 +908,14 @@
* @inner * @inner
*/ */
function onMouseMove( tracker, event ) { function onMouseMove( tracker, event ) {
var event = $.getEvent( event ), var delegate = THIS[ tracker.hash ],
delegate = THIS[ tracker.hash ], delta,
point = getMouseAbsolute( event ), propagate,
delta = point.minus( delegate.lastPoint ), point;
propagate;
event = $.getEvent( event );
point = getMouseAbsolute( event );
delta = point.minus( delegate.lastPoint );
delegate.lastPoint = point; delegate.lastPoint = point;

View File

@ -315,7 +315,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* @see <a href='http://www.jquery.com/'>jQuery</a> * @see <a href='http://www.jquery.com/'>jQuery</a>
*/ */
$.type = function( obj ) { $.type = function( obj ) {
return obj == null ? return ( obj === null ) || ( obj === undefined ) ?
String( obj ) : String( obj ) :
class2type[ toString.call(obj) ] || "object"; class2type[ toString.call(obj) ] || "object";
}; };
@ -419,7 +419,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values // Only deal with non-null/undefined values
if ( ( options = arguments[ i ] ) != null ) { options = arguments[ i ];
if ( options !== null || options !== undefined ) {
// Extend the base object // Extend the base object
for ( name in options ) { for ( name in options ) {
src = target[ name ]; src = target[ name ];
@ -472,6 +473,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
//PAN AND ZOOM SETTINGS AND CONSTRAINTS //PAN AND ZOOM SETTINGS AND CONSTRAINTS
panHorizontal: true, panHorizontal: true,
panVertical: true, panVertical: true,
constrainDuringPan: false,
wrapHorizontal: false, wrapHorizontal: false,
wrapVertical: false, wrapVertical: false,
visibilityRatio: 0.5, visibilityRatio: 0.5,
@ -599,9 +601,11 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
*/ */
delegate: function( object, method ) { delegate: function( object, method ) {
return function(){ return function(){
if ( arguments === undefined ) var args = arguments;
arguments = []; if ( args === undefined ){
return method.apply( object, arguments ); args = [];
}
return method.apply( object, args );
}; };
}, },
@ -832,21 +836,21 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
window.innerWidth, window.innerWidth,
window.innerHeight window.innerHeight
); );
} };
} else if ( docElement.clientWidth || docElement.clientHeight ) { } else if ( docElement.clientWidth || docElement.clientHeight ) {
$.getWindowSize = function(){ $.getWindowSize = function(){
return new $.Point( return new $.Point(
document.documentElement.clientWidth, document.documentElement.clientWidth,
document.documentElement.clientHeight document.documentElement.clientHeight
); );
} };
} else if ( body.clientWidth || body.clientHeight ) { } else if ( body.clientWidth || body.clientHeight ) {
$.getWindowSize = function(){ $.getWindowSize = function(){
return new $.Point( return new $.Point(
document.body.clientWidth, document.body.clientWidth,
document.body.clientHeight document.body.clientHeight
); );
} };
} else { } else {
throw new Error("Unknown window size, no known technique."); throw new Error("Unknown window size, no known technique.");
} }
@ -1113,7 +1117,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
$.cancelEvent = function( event ){ $.cancelEvent = function( event ){
// W3C for preventing default // W3C for preventing default
event.preventDefault(); event.preventDefault();
} };
} else { } else {
$.cancelEvent = function( event ){ $.cancelEvent = function( event ){
event = $.getEvent( event ); event = $.getEvent( event );
@ -1212,6 +1216,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
// we could determine once at startup which activeX object // we could determine once at startup which activeX object
// was supported. This will have significant impact on // was supported. This will have significant impact on
// performance for IE Browsers DONE // performance for IE Browsers DONE
/*jshint loopfunc:true*/
for ( i = 0; i < ACTIVEX.length; i++ ) { for ( i = 0; i < ACTIVEX.length; i++ ) {
try { try {
request = new ActiveXObject( ACTIVEX[ i ] ); request = new ActiveXObject( ACTIVEX[ i ] );
@ -1268,7 +1273,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
/** @ignore */ /** @ignore */
request.onreadystatechange = function() { request.onreadystatechange = function() {
if ( request.readyState == 4) { if ( request.readyState == 4) {
request.onreadystatechange = new function() { }; request.onreadystatechange = function(){};
options.success( request ); options.success( request );
} }
}; };
@ -1692,7 +1697,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} else { } else {
return element.offsetParent; return element.offsetParent;
} }
}; }
/** /**
* @private * @private
@ -1724,7 +1729,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} }
return processDZIXml( doc, tilesUrl ); return processDZIXml( doc, tilesUrl );
}; }
/** /**
* @private * @private
@ -1758,7 +1763,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
} }
throw new Error( $.getString( "Errors.Dzi" ) ); throw new Error( $.getString( "Errors.Dzi" ) );
}; }
/** /**
* @private * @private
@ -1772,10 +1777,10 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
var fileFormat = imageNode.getAttribute( "Format" ), var fileFormat = imageNode.getAttribute( "Format" ),
sizeNode = imageNode.getElementsByTagName( "Size" )[ 0 ], sizeNode = imageNode.getElementsByTagName( "Size" )[ 0 ],
dispRectNodes = imageNode.getElementsByTagName( "DisplayRect" ), dispRectNodes = imageNode.getElementsByTagName( "DisplayRect" ),
width = parseInt( sizeNode.getAttribute( "Width" ) ), width = parseInt( sizeNode.getAttribute( "Width" ), 10 ),
height = parseInt( sizeNode.getAttribute( "Height" ) ), height = parseInt( sizeNode.getAttribute( "Height" ), 10 ),
tileSize = parseInt( imageNode.getAttribute( "TileSize" ) ), tileSize = parseInt( imageNode.getAttribute( "TileSize" ), 10 ),
tileOverlap = parseInt( imageNode.getAttribute( "Overlap" ) ), tileOverlap = parseInt( imageNode.getAttribute( "Overlap" ), 10 ),
dispRects = [], dispRects = [],
dispRectNode, dispRectNode,
rectNode, rectNode,
@ -1792,12 +1797,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ]; rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ];
dispRects.push( new $.DisplayRect( dispRects.push( new $.DisplayRect(
parseInt( rectNode.getAttribute( "X" ) ), parseInt( rectNode.getAttribute( "X" ), 10 ),
parseInt( rectNode.getAttribute( "Y" ) ), parseInt( rectNode.getAttribute( "Y" ), 10 ),
parseInt( rectNode.getAttribute( "Width" ) ), parseInt( rectNode.getAttribute( "Width" ), 10 ),
parseInt( rectNode.getAttribute( "Height" ) ), parseInt( rectNode.getAttribute( "Height" ), 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( dispRectNode.getAttribute( "MaxLevel" ) ) parseInt( dispRectNode.getAttribute( "MaxLevel" ), 10 )
)); ));
} }
return new $.DziTileSource( return new $.DziTileSource(
@ -1809,7 +1814,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
fileFormat, fileFormat,
dispRects dispRects
); );
}; }
/** /**
* @private * @private
@ -1823,10 +1828,10 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
var fileFormat = imageData.Format, var fileFormat = imageData.Format,
sizeData = imageData.Size, sizeData = imageData.Size,
dispRectData = imageData.DisplayRect || [], dispRectData = imageData.DisplayRect || [],
width = parseInt( sizeData.Width ), width = parseInt( sizeData.Width, 10 ),
height = parseInt( sizeData.Height ), height = parseInt( sizeData.Height, 10 ),
tileSize = parseInt( imageData.TileSize ), tileSize = parseInt( imageData.TileSize, 10 ),
tileOverlap = parseInt( imageData.Overlap ), tileOverlap = parseInt( imageData.Overlap, 10 ),
dispRects = [], dispRects = [],
rectData, rectData,
i; i;
@ -1841,12 +1846,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
rectData = dispRectData[ i ].Rect; rectData = dispRectData[ i ].Rect;
dispRects.push( new $.DisplayRect( dispRects.push( new $.DisplayRect(
parseInt( rectData.X ), parseInt( rectData.X, 10 ),
parseInt( rectData.Y ), parseInt( rectData.Y, 10 ),
parseInt( rectData.Width ), parseInt( rectData.Width, 10 ),
parseInt( rectData.Height ), parseInt( rectData.Height, 10 ),
0, // ignore MinLevel attribute, bug in Deep Zoom Composer 0, // ignore MinLevel attribute, bug in Deep Zoom Composer
parseInt( rectData.MaxLevel ) parseInt( rectData.MaxLevel, 10 )
)); ));
} }
return new $.DziTileSource( return new $.DziTileSource(
@ -1858,7 +1863,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
fileFormat, fileFormat,
dispRects dispRects
); );
}; }
/** /**
* @private * @private
* @inner * @inner
@ -1872,8 +1878,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
message = messageNode.firstChild.nodeValue; message = messageNode.firstChild.nodeValue;
throw new Error(message); throw new Error(message);
}; }
}( OpenSeadragon )); }( OpenSeadragon ));

View File

@ -73,7 +73,7 @@ $.extend( $.OsmTileSource.prototype, $.TileSource.prototype, {
return ( return (
data.type && data.type &&
"openstreetmaps" == data.type "openstreetmaps" == data.type
) );
}, },
/** /**

View File

@ -1,3 +1,4 @@
(function( $ ){ (function( $ ){
// dictionary from id to private properties // dictionary from id to private properties
@ -30,6 +31,7 @@ $.ReferenceStrip = function( options ){
miniViewer, miniViewer,
minPixelRatio, minPixelRatio,
element, element,
style,
i; i;
//We may need to create a new element and id if they did not //We may need to create a new element and id if they did not
@ -58,7 +60,6 @@ $.ReferenceStrip = function( options ){
}); });
$.extend( this, options ); $.extend( this, options );
//Private state properties //Private state properties
THIS[ this.id ] = { THIS[ this.id ] = {
"animating": false "animating": false
@ -66,7 +67,7 @@ $.ReferenceStrip = function( options ){
this.minPixelRatio = this.viewer.minPixelRatio; this.minPixelRatio = this.viewer.minPixelRatio;
(function( style ){ style = thie.element.style;
style.marginTop = '0px'; style.marginTop = '0px';
style.marginRight = '0px'; style.marginRight = '0px';
style.marginBottom = '0px'; style.marginBottom = '0px';
@ -76,7 +77,6 @@ $.ReferenceStrip = function( options ){
style.border = '0px'; style.border = '0px';
style.background = '#000'; style.background = '#000';
style.position = 'relative'; style.position = 'relative';
}( this.element.style ));
$.setElementOpacity( this.element, 0.8 ); $.setElementOpacity( this.element, 0.8 );
@ -90,8 +90,6 @@ $.ReferenceStrip = function( options ){
keyHandler: $.delegate( this, onKeyPress ) keyHandler: $.delegate( this, onKeyPress )
}).setTracking( true ); }).setTracking( true );
//Controls the position and orientation of the reference strip and sets the //Controls the position and orientation of the reference strip and sets the
//appropriate width and height //appropriate width and height
if( options.width && options.height ){ if( options.width && options.height ){
@ -142,32 +140,31 @@ $.ReferenceStrip = function( options ){
this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8; this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8;
this.panels = []; this.panels = [];
/*jshint loopfunc:true*/
for( i = 0; i < viewer.tileSources.length; i++ ){ for( i = 0; i < viewer.tileSources.length; i++ ){
element = $.makeNeutralElement('div'); element = $.makeNeutralElement('div');
element.id = this.element.id + "-" + i; element.id = this.element.id + "-" + i;
(function(style){ element.style.width = _this.panelWidth + 'px';
style.width = _this.panelWidth + 'px'; element.style.height = _this.panelHeight + 'px';
style.height = _this.panelHeight + 'px'; element.style.display = 'inline';
style.display = 'inline'; element.style.float = 'left'; //Webkit
style.float = 'left'; //Webkit element.style.cssFloat = 'left'; //Firefox
style.cssFloat = 'left'; //Firefox element.style.styleFloat = 'left'; //IE
style.styleFloat = 'left'; //IE element.style.padding = '2px';
style.padding = '2px';
}(element.style));
element.innerTracker = new $.MouseTracker({ element.innerTracker = new $.MouseTracker({
element: element, element: element,
clickTimeThreshold: this.clickTimeThreshold, clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold, clickDistThreshold: this.clickDistThreshold,
pressHandler: function( tracker ){ pressHandler: function( tracker ){
tracker.dragging = +new Date; tracker.dragging = +new Date();
}, },
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){ releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
var id = tracker.element.id, var id = tracker.element.id,
page = Number( id.split( '-' )[ 2 ] ), page = Number( id.split( '-' )[ 2 ] ),
now = +new Date; now = +new Date();
if ( insideElementPress && if ( insideElementPress &&
insideElementRelease && insideElementRelease &&
@ -304,7 +301,7 @@ function onStripDrag( tracker, position, delta, shift ) {
} }
return false; return false;
}; }
@ -352,7 +349,7 @@ function onStripScroll( tracker, position, scroll, shift ) {
} }
//cancels event //cancels event
return false; return false;
}; }
function loadPanels(strip, viewerSize, scroll){ function loadPanels(strip, viewerSize, scroll){
@ -360,6 +357,7 @@ function loadPanels(strip, viewerSize, scroll){
activePanelsStart, activePanelsStart,
activePanelsEnd, activePanelsEnd,
miniViewer, miniViewer,
style,
i; i;
if( 'horizontal' == strip.scroll ){ if( 'horizontal' == strip.scroll ){
panelSize = strip.panelWidth; panelSize = strip.panelWidth;
@ -390,7 +388,7 @@ function loadPanels(strip, viewerSize, scroll){
miniViewer.displayRegion.id = element.id + '-displayregion'; miniViewer.displayRegion.id = element.id + '-displayregion';
miniViewer.displayRegion.className = 'displayregion'; miniViewer.displayRegion.className = 'displayregion';
(function( style ){ style = miniViewer.displayRegion.style;
style.position = 'relative'; style.position = 'relative';
style.top = '0px'; style.top = '0px';
style.left = '0px'; style.left = '0px';
@ -403,7 +401,6 @@ function loadPanels(strip, viewerSize, scroll){
style.cursor = 'default'; style.cursor = 'default';
style.width = ( strip.panelWidth - 4 ) + 'px'; style.width = ( strip.panelWidth - 4 ) + 'px';
style.height = ( strip.panelHeight - 4 ) + 'px'; style.height = ( strip.panelHeight - 4 ) + 'px';
}( miniViewer.displayRegion.style ));
miniViewer.displayRegion.innerTracker = new $.MouseTracker({ miniViewer.displayRegion.innerTracker = new $.MouseTracker({
element: miniViewer.displayRegion element: miniViewer.displayRegion
@ -416,7 +413,7 @@ function loadPanels(strip, viewerSize, scroll){
element.activePanel = true; element.activePanel = true;
} }
} }
}; }
/** /**
@ -442,8 +439,8 @@ function onStripEnter( tracker ) {
tracker.element.style.marginLeft = "0px"; tracker.element.style.marginLeft = "0px";
} }
return false return false;
}; }
/** /**
@ -472,7 +469,7 @@ function onStripExit( tracker ) {
} }
return false; return false;
}; }
@ -514,7 +511,7 @@ function onKeyPress( tracker, keyCode, shiftKey ){
//console.log( 'navigator keycode %s', keyCode ); //console.log( 'navigator keycode %s', keyCode );
return true; return true;
} }
}; }

View File

@ -57,7 +57,7 @@ $.extend( $, {
} }
return string.replace(/\{\d+\}/g, function(capture) { return string.replace(/\{\d+\}/g, function(capture) {
var i = parseInt( capture.match( /\d+/ ) ) + 1; var i = parseInt( capture.match( /\d+/ ), 10 ) + 1;
return i < args.length ? return i < args.length ?
args[ i ] : args[ i ] :
""; "";

View File

@ -83,6 +83,7 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
$.extend( true, this, options ); $.extend( true, this, options );
//Any functions that are passed as arguments are bound to the ready callback //Any functions that are passed as arguments are bound to the ready callback
/*jshint loopfunc:true*/
for( i = 0; i < arguments.length; i++ ){ for( i = 0; i < arguments.length; i++ ){
if( $.isFunction( arguments[i] ) ){ if( $.isFunction( arguments[i] ) ){
callback = arguments[ i ]; callback = arguments[ i ];
@ -212,7 +213,6 @@ $.TileSource.prototype = {
*/ */
getImageInfo: function( url ) { getImageInfo: function( url ) {
var _this = this, var _this = this,
url = url,
error, error,
callbackName, callbackName,
callback, callback,
@ -372,6 +372,7 @@ function processResponse( xhr ){
data = xhr.responseText; data = xhr.responseText;
} }
}else if( responseText.match(/\s*[\{\[].*/) ){ }else if( responseText.match(/\s*[\{\[].*/) ){
/*jshint evil:true*/
data = eval( '('+responseText+')' ); data = eval( '('+responseText+')' );
}else{ }else{
data = responseText; data = responseText;

View File

@ -29,7 +29,7 @@ $.TileSourceCollection = function( tileSize, tileSources, rows, layout ) {
tilesPerRow = Math.ceil( options.tileSources.length / options.rows ), tilesPerRow = Math.ceil( options.tileSources.length / options.rows ),
longSide = tilesPerRow >= options.rows ? longSide = tilesPerRow >= options.rows ?
tilesPerRow : tilesPerRow :
options.rows options.rows;
if( 'horizontal' == options.layout ){ if( 'horizontal' == options.layout ){
options.width = ( options.tileSize ) * tilesPerRow; options.width = ( options.tileSize ) * tilesPerRow;
@ -88,7 +88,7 @@ $.extend( $.TileSourceCollection.prototype, $.TileSource.prototype, {
* @name OpenSeadragon.TileSourceCollection.prototype.configure * @name OpenSeadragon.TileSourceCollection.prototype.configure
*/ */
configure: function( data, url ){ configure: function( data, url ){
return return;
}, },

View File

@ -471,7 +471,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
overlay = this.overlayControls[ i ]; overlay = this.overlayControls[ i ];
if ( overlay.point != null ) { if ( overlay.point ) {
this.drawer.addOverlay( this.drawer.addOverlay(
overlay.id, overlay.id,
@ -1163,6 +1163,9 @@ function onCanvasDrag( tracker, position, delta, shift ) {
delta.negate() delta.negate()
) )
); );
if( this.constrainDuringPan ){
this.viewport.applyConstraints();
}
} }
} }

View File

@ -9,12 +9,19 @@ the minimum and maximum zoom range as well as the range of panning.
the options: <ul> the options: <ul>
<li> <li>
<strong>panHorizontal</strong><em>(default:) true</em> <strong>panHorizontal</strong><em>(default:) true</em>
</li>
<li> <li>
<strong>panVertical</strong><em>(default:) true</em> <strong>panVertical</strong><em>(default:) true</em>
</li>
<li>
<strong>constrainDuringPan</strong><em>(default:) false</em>
</li>
<li> <li>
<strong> wrapHorizontal</strong><em>(default:) false</em> <strong> wrapHorizontal</strong><em>(default:) false</em>
</li>
<li> <li>
<strong>wrapVertical</strong><em>(default:) false</em> <strong>wrapVertical</strong><em>(default:) false</em>
</li>
<li> <li>
<strong>visibilityRatio</strong><em>(default:) 0.5</em> <strong>visibilityRatio</strong><em>(default:) 0.5</em>
</li> </li>
@ -40,13 +47,16 @@ the minimum and maximum zoom range as well as the range of panning.
</p> </p>
<div class="description"> <div class="description">
<h3>Constraining by viewport visibility as a ratio.</h3> <h3>Constraining by viewport visibility as a ratio, and constraining during panning</h3>
<p> <p>
The option The option
<strong>visibilityRatio</strong>, which is by default <strong>0.5</strong>, <strong>visibilityRatio</strong>, which is by default <strong>0.5</strong>,
ensure that you cannot pan the image far enough to fill the viewport with ensure that you cannot pan the image far enough to fill the viewport with
more than 50% background. Setting it to 1, as in this example, ensure more than 50% background. Setting it to 1, as in this example, ensure
the image cannot be panned so as to show any background. the image cannot be panned so as to show any background. Normally OpenSeadragon
will enforce this by 'bouncing' back when the pan dragging is released. In this
example we also add <strong>constrainDuringPan: true</strong> which stop the drag
immediately when it hits the bounding area.
</p> </p>
</div> </div>
<div class="demoarea"> <div class="demoarea">
@ -60,7 +70,8 @@ the minimum and maximum zoom range as well as the range of panning.
id: "visibility-ratio-1", id: "visibility-ratio-1",
prefixUrl: "/openseadragon/images/", prefixUrl: "/openseadragon/images/",
tileSources: "/openseadragon/examples/images/highsmith/highsmith.dzi", tileSources: "/openseadragon/examples/images/highsmith/highsmith.dzi",
visibilityRatio: 1.0 visibilityRatio: 1.0,
constrainDuringPan: true
}); });
</script> </script>
<p> <p>
@ -69,6 +80,7 @@ the minimum and maximum zoom range as well as the range of panning.
<pre>OpenSeadragon({ <pre>OpenSeadragon({
... ...
visibilityRatio: 1.0, visibilityRatio: 1.0,
constrainDuringPan: true
... ...
}); });
</pre> </pre>
@ -83,7 +95,7 @@ the minimum and maximum zoom range as well as the range of panning.
</div> </div>
<div class="demoarea"> <div class="demoarea">
<div class="demoheading"> <div class="demoheading">
A visibilityRatio of 1. Vertical scroll and zoom.
</div> </div>
<div id="vertical-scrolling" class="openseadragon"></div> <div id="vertical-scrolling" class="openseadragon"></div>
</div> </div>