2013-05-01 08:46:16 +04:00
|
|
|
/*
|
2013-05-14 08:00:24 +04:00
|
|
|
* OpenSeadragon - ReferenceStrip
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
2013-05-14 07:32:09 +04:00
|
|
|
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
(function( $ ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
// dictionary from id to private properties
|
|
|
|
var THIS = {};
|
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
/**
|
|
|
|
* The CollectionDrawer is a reimplementation if the Drawer API that
|
2013-06-19 21:33:25 +04:00
|
|
|
* focuses on allowing a viewport to be redefined as a collection
|
2012-08-30 04:55:36 +04:00
|
|
|
* of smaller viewports, defined by a clear number of rows and / or
|
|
|
|
* columns of which each item in the matrix of viewports has its own
|
2013-06-19 21:33:25 +04:00
|
|
|
* source.
|
2012-08-30 04:55:36 +04:00
|
|
|
*
|
|
|
|
* This idea is a reexpression of the idea of dzi collections
|
|
|
|
* which allows a clearer algorithm to reuse the tile sources already
|
|
|
|
* supported by OpenSeadragon, in heterogenious or homogenious
|
|
|
|
* sequences just like mixed groups already supported by the viewer
|
|
|
|
* for the purpose of image sequnces.
|
|
|
|
*
|
|
|
|
* TODO: The difficult part of this feature is figuring out how to express
|
2013-06-19 21:33:25 +04:00
|
|
|
* this functionality as a combination of the functionality already
|
|
|
|
* provided by Drawer, Viewport, TileSource, and Navigator. It may
|
2012-08-30 04:55:36 +04:00
|
|
|
* require better abstraction at those points in order to effeciently
|
|
|
|
* reuse those paradigms.
|
|
|
|
*/
|
|
|
|
$.ReferenceStrip = function( options ){
|
|
|
|
|
|
|
|
var _this = this,
|
|
|
|
viewer = options.viewer,
|
|
|
|
viewerSize = $.getElementSize( viewer.element ),
|
|
|
|
miniViewer,
|
|
|
|
minPixelRatio,
|
|
|
|
element,
|
2013-02-13 07:40:08 +04:00
|
|
|
style,
|
2012-08-30 04:55:36 +04:00
|
|
|
i;
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
//We may need to create a new element and id if they did not
|
|
|
|
//provide the id for the existing element
|
|
|
|
if( !options.id ){
|
|
|
|
options.id = 'referencestrip-' + (+new Date());
|
|
|
|
this.element = $.makeNeutralElement( "div" );
|
|
|
|
this.element.id = options.id;
|
|
|
|
this.element.className = 'referencestrip';
|
|
|
|
}
|
|
|
|
|
|
|
|
options = $.extend( true, {
|
|
|
|
sizeRatio: $.DEFAULT_SETTINGS.referenceStripSizeRatio,
|
|
|
|
position: $.DEFAULT_SETTINGS.referenceStripPosition,
|
|
|
|
scroll: $.DEFAULT_SETTINGS.referenceStripScroll,
|
|
|
|
clickTimeThreshold: $.DEFAULT_SETTINGS.clickTimeThreshold
|
|
|
|
}, options, {
|
|
|
|
//required overrides
|
|
|
|
element: this.element,
|
|
|
|
//These need to be overridden to prevent recursion since
|
|
|
|
//the navigator is a viewer and a viewer has a navigator
|
|
|
|
showNavigator: false,
|
|
|
|
mouseNavEnabled: false,
|
|
|
|
showNavigationControl: false,
|
|
|
|
showSequenceControl: false
|
|
|
|
});
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
$.extend( this, options );
|
|
|
|
//Private state properties
|
|
|
|
THIS[ this.id ] = {
|
|
|
|
"animating": false
|
|
|
|
};
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2012-09-07 16:55:19 +04:00
|
|
|
this.minPixelRatio = this.viewer.minPixelRatio;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-02-28 23:37:32 +04:00
|
|
|
style = this.element.style;
|
2013-02-13 07:40:08 +04:00
|
|
|
style.marginTop = '0px';
|
|
|
|
style.marginRight = '0px';
|
|
|
|
style.marginBottom = '0px';
|
|
|
|
style.marginLeft = '0px';
|
|
|
|
style.left = '0px';
|
|
|
|
style.bottom = '0px';
|
|
|
|
style.border = '0px';
|
|
|
|
style.background = '#000';
|
|
|
|
style.position = 'relative';
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2012-09-07 16:55:19 +04:00
|
|
|
$.setElementOpacity( this.element, 0.8 );
|
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
this.viewer = viewer;
|
|
|
|
this.innerTracker = new $.MouseTracker({
|
|
|
|
element: this.element,
|
|
|
|
dragHandler: $.delegate( this, onStripDrag ),
|
|
|
|
scrollHandler: $.delegate( this, onStripScroll ),
|
|
|
|
enterHandler: $.delegate( this, onStripEnter ),
|
2012-09-05 18:52:57 +04:00
|
|
|
exitHandler: $.delegate( this, onStripExit ),
|
|
|
|
keyHandler: $.delegate( this, onKeyPress )
|
2012-08-30 04:55:36 +04:00
|
|
|
}).setTracking( true );
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
//Controls the position and orientation of the reference strip and sets the
|
2012-08-30 04:55:36 +04:00
|
|
|
//appropriate width and height
|
|
|
|
if( options.width && options.height ){
|
|
|
|
this.element.style.width = options.width + 'px';
|
|
|
|
this.element.style.height = options.height + 'px';
|
2013-06-19 21:33:25 +04:00
|
|
|
viewer.addControl(
|
|
|
|
this.element,
|
2013-03-15 18:59:47 +04:00
|
|
|
{anchor: $.ControlAnchor.BOTTOM_LEFT}
|
2012-08-30 04:55:36 +04:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if( "horizontal" == options.scroll ){
|
2013-06-19 21:33:25 +04:00
|
|
|
this.element.style.width = (
|
|
|
|
viewerSize.x *
|
|
|
|
options.sizeRatio *
|
2012-08-30 04:55:36 +04:00
|
|
|
viewer.tileSources.length
|
|
|
|
) + ( 12 * viewer.tileSources.length ) + 'px';
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
this.element.style.height = (
|
|
|
|
viewerSize.y *
|
|
|
|
options.sizeRatio
|
2012-08-30 04:55:36 +04:00
|
|
|
) + 'px';
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
viewer.addControl(
|
|
|
|
this.element,
|
2013-03-15 18:59:47 +04:00
|
|
|
{anchor: $.ControlAnchor.BOTTOM_LEFT}
|
2012-08-30 04:55:36 +04:00
|
|
|
);
|
|
|
|
}else {
|
2013-06-19 21:33:25 +04:00
|
|
|
this.element.style.height = (
|
|
|
|
viewerSize.y *
|
|
|
|
options.sizeRatio *
|
2012-08-30 04:55:36 +04:00
|
|
|
viewer.tileSources.length
|
|
|
|
) + ( 12 * viewer.tileSources.length ) + 'px';
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
this.element.style.width = (
|
|
|
|
viewerSize.x *
|
|
|
|
options.sizeRatio
|
2012-08-30 04:55:36 +04:00
|
|
|
) + 'px';
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
viewer.addControl(
|
|
|
|
this.element,
|
2013-03-15 18:59:47 +04:00
|
|
|
{anchor: $.ControlAnchor.TOP_LEFT}
|
2012-08-30 04:55:36 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
this.panelWidth = ( viewerSize.x * this.sizeRatio ) + 8;
|
|
|
|
this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8;
|
|
|
|
this.panels = [];
|
|
|
|
|
2013-02-13 07:40:08 +04:00
|
|
|
/*jshint loopfunc:true*/
|
2012-08-30 04:55:36 +04:00
|
|
|
for( i = 0; i < viewer.tileSources.length; i++ ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
element = $.makeNeutralElement('div');
|
|
|
|
element.id = this.element.id + "-" + i;
|
|
|
|
|
2013-02-13 07:40:08 +04:00
|
|
|
element.style.width = _this.panelWidth + 'px';
|
|
|
|
element.style.height = _this.panelHeight + 'px';
|
|
|
|
element.style.display = 'inline';
|
|
|
|
element.style.float = 'left'; //Webkit
|
|
|
|
element.style.cssFloat = 'left'; //Firefox
|
|
|
|
element.style.styleFloat = 'left'; //IE
|
|
|
|
element.style.padding = '2px';
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
element.innerTracker = new $.MouseTracker({
|
2013-02-13 07:40:08 +04:00
|
|
|
element: element,
|
2013-06-19 21:33:25 +04:00
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
2012-09-05 18:52:57 +04:00
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
2012-08-30 04:55:36 +04:00
|
|
|
pressHandler: function( tracker ){
|
2013-02-13 07:40:08 +04:00
|
|
|
tracker.dragging = +new Date();
|
2012-08-30 04:55:36 +04:00
|
|
|
},
|
|
|
|
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
|
|
|
|
var id = tracker.element.id,
|
|
|
|
page = Number( id.split( '-' )[ 2 ] ),
|
2013-02-13 07:40:08 +04:00
|
|
|
now = +new Date();
|
2013-06-19 21:33:25 +04:00
|
|
|
|
|
|
|
if ( insideElementPress &&
|
|
|
|
insideElementRelease &&
|
2012-08-30 04:55:36 +04:00
|
|
|
tracker.dragging &&
|
|
|
|
( now - tracker.dragging ) < tracker.clickTimeThreshold ){
|
|
|
|
tracker.dragging = null;
|
2012-10-13 07:40:59 +04:00
|
|
|
viewer.goToPage( page );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}).setTracking( true );
|
|
|
|
|
|
|
|
this.element.appendChild( element );
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
element.activePanel = false;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
this.panels.push( element );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
loadPanels( this, this.scroll == 'vertical' ? viewerSize.y : viewerSize.y, 0);
|
2012-10-13 07:40:59 +04:00
|
|
|
this.setFocus( 0 );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
$.extend( $.ReferenceStrip.prototype, $.EventHandler.prototype, $.Viewer.prototype, {
|
|
|
|
|
2012-10-13 07:40:59 +04:00
|
|
|
setFocus: function( page ){
|
|
|
|
var element = $.getElement( this.element.id + '-' + page ),
|
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas ),
|
|
|
|
scrollWidth = Number(this.element.style.width.replace('px','')),
|
|
|
|
scrollHeight = Number(this.element.style.height.replace('px','')),
|
|
|
|
offsetLeft = -Number(this.element.style.marginLeft.replace('px','')),
|
|
|
|
offsetTop = -Number(this.element.style.marginTop.replace('px','')),
|
|
|
|
offset;
|
|
|
|
|
|
|
|
if ( this.currentSelected !== element ){
|
|
|
|
if( this.currentSelected ){
|
|
|
|
this.currentSelected.style.background = '#000';
|
|
|
|
}
|
|
|
|
this.currentSelected = element;
|
|
|
|
this.currentSelected.style.background = '#999';
|
|
|
|
|
|
|
|
if( 'horizontal' == this.scroll ){
|
|
|
|
//right left
|
2012-10-13 10:39:42 +04:00
|
|
|
offset = (Number(page)) * ( this.panelWidth + 3 );
|
2012-10-13 07:40:59 +04:00
|
|
|
if( offset > offsetLeft + viewerSize.x - this.panelWidth){
|
|
|
|
offset = Math.min(offset, (scrollWidth - viewerSize.x));
|
|
|
|
this.element.style.marginLeft = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, -offset );
|
|
|
|
}else if( offset < offsetLeft ){
|
|
|
|
offset = Math.max(0, offset - viewerSize.x / 2);
|
|
|
|
this.element.style.marginLeft = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, -offset );
|
|
|
|
}
|
|
|
|
}else{
|
2012-10-13 10:39:42 +04:00
|
|
|
offset = (Number(page) ) * ( this.panelHeight + 3 );
|
2012-10-13 07:40:59 +04:00
|
|
|
if( offset > offsetTop + viewerSize.y - this.panelHeight){
|
|
|
|
offset = Math.min(offset, (scrollHeight - viewerSize.y));
|
|
|
|
this.element.style.marginTop = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, -offset );
|
|
|
|
}else if( offset < offsetTop ){
|
|
|
|
offset = Math.max(0, offset - viewerSize.y / 2);
|
|
|
|
this.element.style.marginTop = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, -offset );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentPage = page;
|
2012-10-13 10:39:42 +04:00
|
|
|
$.getElement( element.id + '-displayregion' ).focus();
|
2012-10-13 07:40:59 +04:00
|
|
|
onStripEnter.call( this, this.innerTracker );
|
|
|
|
}
|
|
|
|
},
|
2012-08-30 04:55:36 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2013-02-20 07:53:54 +04:00
|
|
|
* @name OpenSeadragon.ReferenceStrip.prototype.update
|
2012-08-30 04:55:36 +04:00
|
|
|
*/
|
|
|
|
update: function( viewport ){
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
if( THIS[ this.id ].animating ){
|
|
|
|
$.console.log('image reference strip update');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onStripDrag( tracker, position, delta, shift ) {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
var offsetLeft = Number(this.element.style.marginLeft.replace('px','')),
|
|
|
|
offsetTop = Number(this.element.style.marginTop.replace('px','')),
|
|
|
|
scrollWidth = Number(this.element.style.width.replace('px','')),
|
|
|
|
scrollHeight = Number(this.element.style.height.replace('px','')),
|
2012-09-05 19:35:42 +04:00
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas );
|
2012-08-30 04:55:36 +04:00
|
|
|
this.dragging = true;
|
|
|
|
if ( this.element ) {
|
|
|
|
if( 'horizontal' == this.scroll ){
|
|
|
|
if ( -delta.x > 0 ) {
|
|
|
|
//forward
|
|
|
|
if( offsetLeft > -(scrollWidth - viewerSize.x)){
|
|
|
|
this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px';
|
2012-09-05 19:35:42 +04:00
|
|
|
loadPanels( this, viewerSize.x, offsetLeft + (delta.x * 2) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
} else if ( -delta.x < 0 ) {
|
|
|
|
//reverse
|
|
|
|
if( offsetLeft < 0 ){
|
|
|
|
this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px';
|
2012-10-13 10:39:42 +04:00
|
|
|
loadPanels( this, viewerSize.x, offsetLeft + (delta.x * 2) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if ( -delta.y > 0 ) {
|
|
|
|
//forward
|
|
|
|
if( offsetTop > -(scrollHeight - viewerSize.y)){
|
|
|
|
this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px';
|
2012-09-05 19:35:42 +04:00
|
|
|
loadPanels( this, viewerSize.y, offsetTop + (delta.y * 2) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
} else if ( -delta.y < 0 ) {
|
|
|
|
//reverse
|
|
|
|
if( offsetTop < 0 ){
|
|
|
|
this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px';
|
2012-10-13 10:39:42 +04:00
|
|
|
loadPanels( this, viewerSize.y, offsetTop + (delta.y * 2) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-05 19:35:42 +04:00
|
|
|
return false;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onStripScroll( tracker, position, scroll, shift ) {
|
|
|
|
var offsetLeft = Number(this.element.style.marginLeft.replace('px','')),
|
|
|
|
offsetTop = Number(this.element.style.marginTop.replace('px','')),
|
|
|
|
scrollWidth = Number(this.element.style.width.replace('px','')),
|
|
|
|
scrollHeight = Number(this.element.style.height.replace('px','')),
|
2012-09-05 18:52:57 +04:00
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas );
|
2012-08-30 04:55:36 +04:00
|
|
|
if ( this.element ) {
|
|
|
|
if( 'horizontal' == this.scroll ){
|
|
|
|
if ( scroll > 0 ) {
|
|
|
|
//forward
|
|
|
|
if( offsetLeft > -(scrollWidth - viewerSize.x)){
|
2012-09-05 18:52:57 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft - (scroll * 60) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, offsetLeft - (scroll * 60) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
} else if ( scroll < 0 ) {
|
|
|
|
//reverse
|
|
|
|
if( offsetLeft < 0 ){
|
2012-09-05 18:52:57 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft - (scroll * 60) ) + 'px';
|
2012-10-13 10:39:42 +04:00
|
|
|
loadPanels( this, viewerSize.x, offsetLeft - (scroll * 60) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if ( scroll < 0 ) {
|
|
|
|
//scroll up
|
|
|
|
if( offsetTop > viewerSize.y - scrollHeight ){
|
2012-09-05 18:52:57 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + (scroll * 60) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, offsetTop + (scroll * 60) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
} else if ( scroll > 0 ) {
|
|
|
|
//scroll dowm
|
|
|
|
if( offsetTop < 0 ){
|
2012-09-05 18:52:57 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + (scroll * 60) ) + 'px';
|
2012-10-13 10:39:42 +04:00
|
|
|
loadPanels( this, viewerSize.y, offsetTop + (scroll * 60) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//cancels event
|
|
|
|
return false;
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
function loadPanels(strip, viewerSize, scroll){
|
|
|
|
var panelSize,
|
2012-10-13 07:40:59 +04:00
|
|
|
activePanelsStart,
|
|
|
|
activePanelsEnd,
|
2012-09-05 18:52:57 +04:00
|
|
|
miniViewer,
|
2013-02-13 07:40:08 +04:00
|
|
|
style,
|
2012-09-05 18:52:57 +04:00
|
|
|
i;
|
|
|
|
if( 'horizontal' == strip.scroll ){
|
|
|
|
panelSize = strip.panelWidth;
|
|
|
|
}else{
|
|
|
|
panelSize = strip.panelHeight;
|
|
|
|
}
|
2012-10-13 10:39:42 +04:00
|
|
|
activePanelsStart = Math.ceil( viewerSize / panelSize ) + 5;
|
2012-10-13 07:40:59 +04:00
|
|
|
activePanelsEnd = Math.ceil( (Math.abs(scroll) + viewerSize ) / panelSize ) + 1;
|
2012-10-13 10:39:42 +04:00
|
|
|
activePanelsStart = activePanelsEnd - activePanelsStart;
|
2012-10-13 07:40:59 +04:00
|
|
|
activePanelsStart = activePanelsStart < 0 ? 0 : activePanelsStart;
|
2012-09-05 18:52:57 +04:00
|
|
|
|
2012-10-13 07:40:59 +04:00
|
|
|
for( i = activePanelsStart; i < activePanelsEnd && i < strip.panels.length; i++ ){
|
2012-09-05 18:52:57 +04:00
|
|
|
element = strip.panels[ i ];
|
|
|
|
if ( !element.activePanel ){
|
|
|
|
miniViewer = new $.Viewer( {
|
|
|
|
id: element.id,
|
|
|
|
tileSources: [ strip.viewer.tileSources[ i ] ],
|
|
|
|
element: element,
|
|
|
|
navigatorSizeRatio: strip.sizeRatio,
|
|
|
|
showNavigator: false,
|
|
|
|
mouseNavEnabled: false,
|
|
|
|
showNavigationControl: false,
|
2013-03-06 14:51:31 +04:00
|
|
|
showSequenceControl: false,
|
|
|
|
immediateRender: true,
|
|
|
|
blendTime: 0,
|
|
|
|
animationTime: 0
|
2013-06-19 21:33:25 +04:00
|
|
|
} );
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
miniViewer.displayRegion = $.makeNeutralElement( "textarea" );
|
|
|
|
miniViewer.displayRegion.id = element.id + '-displayregion';
|
|
|
|
miniViewer.displayRegion.className = 'displayregion';
|
|
|
|
|
2013-02-13 07:40:08 +04:00
|
|
|
style = miniViewer.displayRegion.style;
|
|
|
|
style.position = 'relative';
|
|
|
|
style.top = '0px';
|
|
|
|
style.left = '0px';
|
|
|
|
style.fontSize = '0px';
|
|
|
|
style.overflow = 'hidden';
|
|
|
|
style.float = 'left'; //Webkit
|
|
|
|
style.cssFloat = 'left'; //Firefox
|
|
|
|
style.styleFloat = 'left'; //IE
|
|
|
|
style.zIndex = 999999999;
|
|
|
|
style.cursor = 'default';
|
|
|
|
style.width = ( strip.panelWidth - 4 ) + 'px';
|
|
|
|
style.height = ( strip.panelHeight - 4 ) + 'px';
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
miniViewer.displayRegion.innerTracker = new $.MouseTracker({
|
2012-09-07 16:55:19 +04:00
|
|
|
element: miniViewer.displayRegion
|
2012-09-05 18:52:57 +04:00
|
|
|
});
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
element.getElementsByTagName('form')[ 0 ].appendChild(
|
|
|
|
miniViewer.displayRegion
|
2012-09-05 18:52:57 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
element.activePanel = true;
|
|
|
|
}
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onStripEnter( tracker ) {
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//$.setElementOpacity(tracker.element, 0.8);
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//tracker.element.style.border = '1px solid #555';
|
|
|
|
//tracker.element.style.background = '#000';
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
if( 'horizontal' == this.scroll ){
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//tracker.element.style.paddingTop = "0px";
|
2012-08-30 04:55:36 +04:00
|
|
|
tracker.element.style.marginBottom = "0px";
|
|
|
|
|
|
|
|
} else {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//tracker.element.style.paddingRight = "0px";
|
2012-08-30 04:55:36 +04:00
|
|
|
tracker.element.style.marginLeft = "0px";
|
|
|
|
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onStripExit( tracker ) {
|
|
|
|
|
|
|
|
var viewerSize = $.getElementSize( this.viewer.element );
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//$.setElementOpacity(tracker.element, 0.4);
|
|
|
|
//tracker.element.style.border = 'none';
|
|
|
|
//tracker.element.style.background = '#fff';
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-10-13 07:40:59 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
if( 'horizontal' == this.scroll ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//tracker.element.style.paddingTop = "10px";
|
2012-10-13 07:40:59 +04:00
|
|
|
tracker.element.style.marginBottom = "-" + ( $.getElementSize( tracker.element ).y / 2 ) + "px";
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
} else {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
//tracker.element.style.paddingRight = "10px";
|
2012-10-13 07:40:59 +04:00
|
|
|
tracker.element.style.marginLeft = "-" + ( $.getElementSize( tracker.element ).x / 2 )+ "px";
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
2012-09-11 20:31:42 +04:00
|
|
|
return false;
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onKeyPress( tracker, keyCode, shiftKey ){
|
|
|
|
//console.log( keyCode );
|
|
|
|
|
|
|
|
switch( keyCode ){
|
|
|
|
case 61://=|+
|
|
|
|
onStripScroll.call(this, this.tracker, null, 1, null);
|
|
|
|
return false;
|
|
|
|
case 45://-|_
|
|
|
|
onStripScroll.call(this, this.tracker, null, -1, null);
|
|
|
|
return false;
|
|
|
|
case 48://0|)
|
|
|
|
case 119://w
|
|
|
|
case 87://W
|
|
|
|
case 38://up arrow
|
|
|
|
onStripScroll.call(this, this.tracker, null, 1, null);
|
|
|
|
return false;
|
|
|
|
case 115://s
|
|
|
|
case 83://S
|
|
|
|
case 40://down arrow
|
|
|
|
onStripScroll.call(this, this.tracker, null, -1, null);
|
|
|
|
return false;
|
|
|
|
case 97://a
|
|
|
|
case 37://left arrow
|
|
|
|
onStripScroll.call(this, this.tracker, null, -1, null);
|
|
|
|
return false;
|
|
|
|
case 100://d
|
|
|
|
case 39://right arrow
|
|
|
|
onStripScroll.call(this, this.tracker, null, 1, null);
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
//console.log( 'navigator keycode %s', keyCode );
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-01 08:46:16 +04:00
|
|
|
}( OpenSeadragon ));
|