Merged upstream changes, fixed conflicts

This commit is contained in:
Mark Salsbery 2014-04-24 12:40:49 -07:00
commit 8232546d51
7 changed files with 133 additions and 74 deletions

View File

@ -50,6 +50,7 @@ OPENSEADRAGON CHANGELOG
* Added velocity (speed and direction) properties to the "canvas-drag" event * Added velocity (speed and direction) properties to the "canvas-drag" event
* Added double-click gesture detection to MouseTracker with corresponding dblClickHandler event callback (#392) * Added double-click gesture detection to MouseTracker with corresponding dblClickHandler event callback (#392)
* Added zoom on double-click feature to Viewer, with corresponding dblClickToZoom option added to the GestureSettings class (#392) * Added zoom on double-click feature to Viewer, with corresponding dblClickToZoom option added to the GestureSettings class (#392)
* Made it possible to run OpenSeadragon from local filesystem on some browsers (#379)
1.0.0: 1.0.0:

View File

@ -103,9 +103,17 @@ $.ButtonGroup = function( options ) {
} }
} }
}, },
pressHandler: function ( event ) {
if ( event.pointerType === 'touch' && !$.MouseTracker.haveTouchEnter ) {
var i;
for ( i = 0; i < _this.buttons.length; i++ ) {
_this.buttons[ i ].notifyGroupEnter();
}
}
},
releaseHandler: function ( event ) { releaseHandler: function ( event ) {
var i; var i;
if ( !event.insideElementReleased ) { if ( !event.insideElementReleased || ( event.pointerType === 'touch' && !$.MouseTracker.haveTouchEnter ) ) {
for ( i = 0; i < _this.buttons.length; i++ ) { for ( i = 0; i < _this.buttons.length; i++ ) {
_this.buttons[ i ].notifyGroupExit(); _this.buttons[ i ].notifyGroupExit();
} }

View File

@ -1696,7 +1696,6 @@
// Touch event model start, end, and move events are always captured so we don't need to capture explicitly // Touch event model start, end, and move events are always captured so we don't need to capture explicitly
} }
$.stopEvent( event );
$.cancelEvent( event ); $.cancelEvent( event );
} }
@ -1732,7 +1731,6 @@
updatePointersExit( tracker, event, gPoints ); updatePointersExit( tracker, event, gPoints );
} }
$.stopEvent( event );
$.cancelEvent( event ); $.cancelEvent( event );
} }
@ -1758,7 +1756,6 @@
updatePointersMove( tracker, event, gPoints ); updatePointersMove( tracker, event, gPoints );
$.stopEvent( event );
$.cancelEvent( event ); $.cancelEvent( event );
} }

View File

@ -282,7 +282,7 @@
* The maximum distance allowed between two pointer click events * The maximum distance allowed between two pointer click events
* to be treated as a double-click gesture. * to be treated as a double-click gesture.
* *
* @property {Number} [springStiffness=5.0] * @property {Number} [springStiffness=6.5]
* *
* @property {Number} [animationTime=1.2] * @property {Number} [animationTime=1.2]
* Specifies the animation duration per each {@link OpenSeadragon.Spring} * Specifies the animation duration per each {@link OpenSeadragon.Spring}
@ -296,8 +296,8 @@
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture * @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture
* @property {Number} [gestureSettingsMouse.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsMouse.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
* @property {Number} [gestureSettingsMouse.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture * @property {Number} [gestureSettingsMouse.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture
* *
* @property {OpenSeadragon.GestureSettings} [gestureSettingsTouch] * @property {OpenSeadragon.GestureSettings} [gestureSettingsTouch]
* Settings for gestures generated by a touch pointer device. (See {@link OpenSeadragon.GestureSettings}) * Settings for gestures generated by a touch pointer device. (See {@link OpenSeadragon.GestureSettings})
@ -307,8 +307,8 @@
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture * @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture
* @property {Number} [gestureSettingsTouch.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsTouch.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
* @property {Number} [gestureSettingsTouch.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture * @property {Number} [gestureSettingsTouch.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture
* *
* @property {OpenSeadragon.GestureSettings} [gestureSettingsPen] * @property {OpenSeadragon.GestureSettings} [gestureSettingsPen]
* Settings for gestures generated by a pen pointer device. (See {@link OpenSeadragon.GestureSettings}) * Settings for gestures generated by a pen pointer device. (See {@link OpenSeadragon.GestureSettings})
@ -318,8 +318,8 @@
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture * @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture
* @property {Number} [gestureSettingsPen.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsPen.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
* @property {Number} [gestureSettingsPen.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture * @property {Number} [gestureSettingsPen.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture
* *
* @property {OpenSeadragon.GestureSettings} [gestureSettingsUnknown] * @property {OpenSeadragon.GestureSettings} [gestureSettingsUnknown]
* Settings for gestures generated by unknown pointer devices. (See {@link OpenSeadragon.GestureSettings}) * Settings for gestures generated by unknown pointer devices. (See {@link OpenSeadragon.GestureSettings})
@ -329,8 +329,8 @@
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture * @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture
* @property {Number} [gestureSettingsUnknown.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsUnknown.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
* @property {Number} [gestureSettingsUnknown.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture * @property {Number} [gestureSettingsUnknown.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture
* *
* @property {Number} [zoomPerClick=2.0] * @property {Number} [zoomPerClick=2.0]
* The "zoom distance" per mouse click or touch tap. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the click-to-zoom feature (also see gestureSettings[Mouse|Touch|Pen].clickToZoom/dblClickToZoom).</em> * The "zoom distance" per mouse click or touch tap. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the click-to-zoom feature (also see gestureSettings[Mouse|Touch|Pen].clickToZoom/dblClickToZoom).</em>
@ -913,12 +913,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
clickDistThreshold: 5, clickDistThreshold: 5,
dblClickTimeThreshold: 300, dblClickTimeThreshold: 300,
dblClickDistThreshold: 20, dblClickDistThreshold: 20,
springStiffness: 5.0, springStiffness: 6.5,
animationTime: 1.2, animationTime: 1.2,
gestureSettingsMouse: { scrollToZoom: true, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 }, gestureSettingsMouse: { scrollToZoom: true, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25 },
gestureSettingsTouch: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 }, gestureSettingsTouch: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25 },
gestureSettingsPen: { scrollToZoom: false, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 }, gestureSettingsPen: { scrollToZoom: false, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25 },
gestureSettingsUnknown: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 }, gestureSettingsUnknown: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25 },
zoomPerClick: 2, zoomPerClick: 2,
zoomPerScroll: 1.2, zoomPerScroll: 1.2,
zoomPerSecond: 1.0, zoomPerSecond: 1.0,
@ -1824,38 +1824,64 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
return value ? value : null; return value ? value : null;
}, },
/**
createAjaxRequest: function(){ * Retrieves the protocol used by the url. The url can either be absolute
var request; * or relative.
* @function
if ( window.XMLHttpRequest ) { * @private
$.createAjaxRequest = function( ){ * @param {String} url The url to retrieve the protocol from.
return new XMLHttpRequest(); * @return {String} The protocol (http:, https:, file:, ftp: ...)
}; */
request = new XMLHttpRequest(); getUrlProtocol: function( url ) {
} else if ( window.ActiveXObject ) { var match = url.match(/^([a-z]+:)\/\//i);
/*jshint loopfunc:true*/ if ( match === null ) {
/* global ActiveXObject:true */ // Relative URL, retrive the protocol from window.location
for ( var i = 0; i < ACTIVEX.length; i++ ) { return window.location.protocol;
try {
request = new ActiveXObject( ACTIVEX[ i ] );
$.createAjaxRequest = function( ){
return new ActiveXObject( ACTIVEX[ i ] );
};
break;
} catch (e) {
continue;
}
}
} }
return match[1].toLowerCase();
if ( !request ) {
throw new Error( "Browser doesn't support XMLHttpRequest." );
}
return request;
}, },
/**
* Create an XHR object
* @private
* @param {type} [local] If set to true, the XHR will be file: protocol
* compatible if possible (but may raise a warning in the browser).
* @returns {XMLHttpRequest}
*/
createAjaxRequest: function( local ) {
// IE11 does not support window.ActiveXObject so we just try to
// create one to see if it is supported.
// See: http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx
var supportActiveX;
try {
/* global ActiveXObject:true */
supportActiveX = !!new ActiveXObject( "Microsoft.XMLHTTP" );
} catch( e ) {
supportActiveX = false;
}
if ( supportActiveX ) {
if ( window.XMLHttpRequest ) {
$.createAjaxRequest = function( local ) {
if ( local ) {
return new ActiveXObject( "Microsoft.XMLHTTP" );
}
return new XMLHttpRequest();
};
} else {
$.createAjaxRequest = function() {
return new ActiveXObject( "Microsoft.XMLHTTP" );
};
}
} else if ( window.XMLHttpRequest ) {
$.createAjaxRequest = function() {
return new XMLHttpRequest();
};
} else {
throw new Error( "Browser doesn't support XMLHttpRequest." );
}
return $.createAjaxRequest( local );
},
/** /**
* Makes an AJAX request. * Makes an AJAX request.
@ -1866,7 +1892,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* @throws {Error} * @throws {Error}
*/ */
makeAjaxRequest: function( url, onSuccess, onError ) { makeAjaxRequest: function( url, onSuccess, onError ) {
var request = $.createAjaxRequest(); var protocol = $.getUrlProtocol( url );
var request = $.createAjaxRequest( protocol === "file:" );
if ( !$.isFunction( onSuccess ) ) { if ( !$.isFunction( onSuccess ) ) {
throw new Error( "makeAjaxRequest requires a success callback" ); throw new Error( "makeAjaxRequest requires a success callback" );
@ -1877,10 +1904,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
if ( request.readyState == 4 ) { if ( request.readyState == 4 ) {
request.onreadystatechange = function(){}; request.onreadystatechange = function(){};
if ( request.status == 200 ) { var successStatus =
protocol === "http:" || protocol === "https:" ? 200 : 0;
if ( request.status === successStatus ) {
onSuccess( request ); onSuccess( request );
} else { } else {
$.console.log( "AJAX request returned %s: %s", request.status, url ); $.console.log( "AJAX request returned %d: %s", request.status, url );
if ( $.isFunction( onError ) ) { if ( $.isFunction( onError ) ) {
onError( request ); onError( request );
@ -2017,23 +2046,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* @returns {Document} * @returns {Document}
*/ */
parseXml: function( string ) { parseXml: function( string ) {
//TODO: yet another example where we can determine the correct if ( window.DOMParser ) {
// implementation once at start-up instead of everytime we use
// the function. DONE.
if ( window.ActiveXObject ) {
$.parseXml = function( string ){ $.parseXml = function( string ) {
var xmlDoc = null;
xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
xmlDoc.async = false;
xmlDoc.loadXML( string );
return xmlDoc;
};
} else if ( window.DOMParser ) {
$.parseXml = function( string ){
var xmlDoc = null, var xmlDoc = null,
parser; parser;
@ -2042,6 +2057,17 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
return xmlDoc; return xmlDoc;
}; };
} else if ( window.ActiveXObject ) {
$.parseXml = function( string ) {
var xmlDoc = null;
xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
xmlDoc.async = false;
xmlDoc.loadXML( string );
return xmlDoc;
};
} else { } else {
throw new Error( "Browser doesn't support XML DOM." ); throw new Error( "Browser doesn't support XML DOM." );
} }
@ -2082,12 +2108,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
}; };
var ACTIVEX = [ var FILEFORMATS = {
"Msxml2.XMLHTTP",
"Msxml3.XMLHTTP",
"Microsoft.XMLHTTP"
],
FILEFORMATS = {
"bmp": false, "bmp": false,
"jpeg": true, "jpeg": true,
"jpg": true, "jpg": true,

View File

@ -407,6 +407,7 @@ $.Viewer = function( options ) {
dblClickDistThreshold: this.dblClickDistThreshold, dblClickDistThreshold: this.dblClickDistThreshold,
enterHandler: $.delegate( this, onContainerEnter ), enterHandler: $.delegate( this, onContainerEnter ),
exitHandler: $.delegate( this, onContainerExit ), exitHandler: $.delegate( this, onContainerExit ),
pressHandler: $.delegate( this, onContainerPress ),
releaseHandler: $.delegate( this, onContainerRelease ) releaseHandler: $.delegate( this, onContainerRelease )
}).setTracking( this.mouseNavEnabled ? true : false ); // always tracking }).setTracking( this.mouseNavEnabled ? true : false ); // always tracking
@ -2537,8 +2538,15 @@ function onContainerExit( event ) {
}); });
} }
function onContainerPress( event ) {
if ( event.pointerType === 'touch' && !$.MouseTracker.haveTouchEnter ) {
THIS[ this.hash ].mouseInside = true;
abortControlsAutoHide( this );
}
}
function onContainerRelease( event ) { function onContainerRelease( event ) {
if ( !event.insideElementReleased ) { if ( !event.insideElementReleased || ( event.pointerType === 'touch' && !$.MouseTracker.haveTouchEnter ) ) {
THIS[ this.hash ].mouseInside = false; THIS[ this.hash ].mouseInside = false;
if ( !THIS[ this.hash ].animating ) { if ( !THIS[ this.hash ].animating ) {
beginControlsAutoHide( this ); beginControlsAutoHide( this );

View File

@ -56,7 +56,7 @@
equal($(".openseadragon-message").length, 1, "Open failures should display a message"); equal($(".openseadragon-message").length, 1, "Open failures should display a message");
ok(testLog.log.contains('["AJAX request returned %s: %s",404,"/test/data/not-a-real-file"]'), ok(testLog.log.contains('["AJAX request returned %d: %s",404,"/test/data/not-a-real-file"]'),
"AJAX failures should be logged to the console"); "AJAX failures should be logged to the console");
start(); start();

View File

@ -87,6 +87,30 @@
); );
}); });
test("getUrlProtocol", function() {
equal(OpenSeadragon.getUrlProtocol("test"), window.location.protocol,
"'test' url protocol should be window.location.protocol");
equal(OpenSeadragon.getUrlProtocol("/test"), window.location.protocol,
"'/test' url protocol should be window.location.protocol");
equal(OpenSeadragon.getUrlProtocol("//test"), window.location.protocol,
"'//test' url protocol should be window.location.protocol");
equal(OpenSeadragon.getUrlProtocol("http://test"), "http:",
"'http://test' url protocol should be http:");
equal(OpenSeadragon.getUrlProtocol("https://test"), "https:",
"'https://test' url protocol should be https:");
equal(OpenSeadragon.getUrlProtocol("file://test"), "file:",
"'file://test' url protocol should be file:");
equal(OpenSeadragon.getUrlProtocol("FTP://test"), "ftp:",
"'FTP://test' url protocol should be ftp:");
});
// ---------- // ----------
asyncTest("requestAnimationFrame", function() { asyncTest("requestAnimationFrame", function() {
var timeWatcher = Util.timeWatcher(); var timeWatcher = Util.timeWatcher();