Skip to content

Commit

Permalink
add tests, adjust some code to fix spelling errors and testability
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschylus committed Sep 14, 2017
1 parent c223755 commit 6e15d69
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 199 deletions.
4 changes: 4 additions & 0 deletions css/less/window.less
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@
margin: 0px;
height: 0px;
}

.v-direction-rtl {
direction: rtl;
}
}
6 changes: 1 addition & 5 deletions css/less/workspace.less
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,4 @@
left: 0;
display: none;
}

.v-direction-rtl {
direction: rtl;
}
}
}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="build/mirador/css/mirador-combined.min.css">
<link rel="stylesheet" type="text/css" href="build/mirador/css/mirador-combined.css">
<title>Mirador Viewer</title>
<style type="text/css">
#viewer {
Expand All @@ -16,7 +16,7 @@
<body>
<div id="viewer"></div>

<script src="build/mirador/mirador.min.js"></script>
<script src="build/mirador/mirador.js"></script>
<script type="text/javascript">

$(function() {
Expand Down
7 changes: 4 additions & 3 deletions js/src/manifests/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@
return canvas ? canvas.label : undefined;
}
},
getViewingDirection : function(){
var _this = this;
return _this.jsonLd.viewingDirection;
getViewingDirection : function() {
var _this = this;
return _this.jsonLd.viewingDirection || _this.jsonLd.sequences[0].viewingDirection;

}
};

Expand Down
96 changes: 48 additions & 48 deletions js/src/widgets/bookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
init: function() {
var _this = this;
if(this.vDirectionStatus == 'rtl'){
this.imagesList = this.imagesListRtl.concat();
this.imagesList = this.imagesListRtl.concat();
}
if (this.canvasID !== null) {
this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID);
Expand Down Expand Up @@ -83,14 +83,14 @@
},

template: $.Handlebars.compile([
'<div class="book-view">',
'</div>'
'<div class="book-view">',
'</div>'
].join('')),

listenForActions: function() {
var _this = this,
firstCanvasId = _this.imagesList[0]['@id'],
lastCanvasId = _this.imagesList[_this.imagesList.length-1]['@id'];
firstCanvasId = _this.imagesList[0]['@id'],
lastCanvasId = _this.imagesList[_this.imagesList.length-1]['@id'];

_this.eventEmitter.subscribe('bottomPanelSet.' + _this.windowId, function(event, visible) {
var dodgers = _this.element.find('.mirador-osd-toggle-bottom-panel, .mirador-pan-zoom-controls');
Expand Down Expand Up @@ -125,7 +125,7 @@
});
},

bindEvents: function() {
bindEvents: function() {
var _this = this;

this.element.find('.mirador-osd-next').on('click', function() {
Expand Down Expand Up @@ -200,12 +200,12 @@ bindEvents: function() {
this.osdOptions.osdBounds = this.osd.viewport.getBounds(true);
_this.eventEmitter.publish("imageBoundsUpdated", {
id: _this.windowId,
osdBounds: {
x: _this.osdOptions.osdBounds.x,
y: _this.osdOptions.osdBounds.y,
width: _this.osdOptions.osdBounds.width,
height: _this.osdOptions.osdBounds.height
}
osdBounds: {
x: _this.osdOptions.osdBounds.x,
y: _this.osdOptions.osdBounds.y,
width: _this.osdOptions.osdBounds.width,
height: _this.osdOptions.osdBounds.height
}
});
},

Expand Down Expand Up @@ -269,19 +269,19 @@ bindEvents: function() {

createOpenSeadragonInstance: function() {
var uniqueID = $.genUUID(),
osdId = 'mirador-osd-' + uniqueID,
osdToolBarId = osdId + '-toolbar',
elemOsd,
tileSources = [],
_this = this,
toolbarID = 'osd-toolbar-' + uniqueID,
dfd = jQuery.Deferred();
osdId = 'mirador-osd-' + uniqueID,
osdToolBarId = osdId + '-toolbar',
elemOsd,
tileSources = [],
_this = this,
toolbarID = 'osd-toolbar-' + uniqueID,
dfd = jQuery.Deferred();

this.element.find('.' + this.osdCls).remove();

jQuery.each(this.stitchList, function(index, image) {
var imageUrl = $.Iiif.getImageUrl(image),
infoJsonUrl = imageUrl + '/info.json';
infoJsonUrl = imageUrl + '/info.json';

jQuery.getJSON(infoJsonUrl).done(function (data, status, jqXHR) {
tileSources.splice(index, 0, data);
Expand All @@ -294,9 +294,9 @@ bindEvents: function() {

elemOsd =
jQuery('<div/>')
.addClass(_this.osdCls)
.attr('id', osdId)
.appendTo(_this.element);
.addClass(_this.osdCls)
.attr('id', osdId)
.appendTo(_this.element);

_this.osd = $.OpenSeadragon({
'id': elemOsd.attr('id'),
Expand Down Expand Up @@ -406,11 +406,11 @@ bindEvents: function() {
// Default to 'paged' and 'left-to-right'
// Set index(es) for any other images to stitch with selected image
var stitchList = [],
leftIndex = [],
rightIndex = [],
topIndex = [],
bottomIndex = [],
_this = this;
leftIndex = [],
rightIndex = [],
topIndex = [],
bottomIndex = [],
_this = this;

this.focusImages = [];

Expand All @@ -425,46 +425,46 @@ bindEvents: function() {
} else if (this.currentImgIndex % 2 === 0) {
// even, get previous page. set order in array based on viewingDirection
switch (this.viewingDirection) {
case "left-to-right":
leftIndex[0] = this.currentImgIndex-1;
case "left-to-right":
leftIndex[0] = this.currentImgIndex-1;
stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg];
break;
case "right-to-left":
rightIndex[0] = this.currentImgIndex-1;
case "right-to-left":
rightIndex[0] = this.currentImgIndex-1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]];
break;
case "top-to-bottom":
topIndex[0] = this.currentImgIndex-1;
case "top-to-bottom":
topIndex[0] = this.currentImgIndex-1;
stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg];
break;
case "bottom-to-top":
bottomIndex[0] = this.currentImgIndex-1;
case "bottom-to-top":
bottomIndex[0] = this.currentImgIndex-1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]];
break;
default:
break;
default:
break;
}
} else {
// odd, get next page
switch (this.viewingDirection) {
case "left-to-right":
rightIndex[0] = this.currentImgIndex+1;
case "left-to-right":
rightIndex[0] = this.currentImgIndex+1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]];
break;
case "right-to-left":
leftIndex[0] = this.currentImgIndex+1;
case "right-to-left":
leftIndex[0] = this.currentImgIndex+1;
stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg];
break;
case "top-to-bottom":
bottomIndex[0] = this.currentImgIndex+1;
case "top-to-bottom":
bottomIndex[0] = this.currentImgIndex+1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]];
break;
case "bottom-to-top":
topIndex[0] = this.currentImgIndex+1;
case "bottom-to-top":
topIndex[0] = this.currentImgIndex+1;
stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg];
break;
default:
break;
default:
break;
}
}
} else if (this.viewingHint === 'continuous') {
Expand Down
8 changes: 4 additions & 4 deletions js/src/widgets/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
vDirectionStatus: '',
lazyLoadingFactor: 1.5 //should be >= 1
}, options);

jQuery.extend($.ScrollView.prototype, $.ThumbnailsView.prototype);
this.init();
if(this.vDirectionStatus == 'rtl'){
jQuery('.scroll-view').addClass('v-direction-rtl');
if(this.vDirectionStatus == 'rtl') {
jQuery(this.appendTo).find('.scroll-view').addClass('v-direction-rtl');
}
};

}(Mirador));
15 changes: 7 additions & 8 deletions js/src/widgets/thumbnailsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,23 @@
this.init();
};


$.ThumbnailsView.prototype = {

init: function() {
if (this.canvasID !== null) {
this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID);
}
if(this.vDirectionStatus == 'rtl'){
this.imagesList = this.imagesListLtr.concat();
this.imagesList = this.imagesListLtr.concat();
}
this.loadContent();
if(this.vDirectionStatus == 'rtl'){
var fCanvasId = this.imagesList[0]['@id'];
var fCanvasThumSelector = 'img.thumbnail-image[data-image-id="'+fCanvasId+'"]';
jQuery(fCanvasThumSelector).parents('.panel-thumbnail-view').addClass('v-direction-rtl');
jQuery(fCanvasThumSelector).parents('.thumbnail-view').find('li').each(function(){
jQuery(this).addClass('thumbnail-rtl');
});
var firstCanvasId = this.imagesList[0]['@id'];
var firstCanvasThumbSelector = 'img.thumbnail-image[data-image-id="'+firstCanvasId+'"]';
jQuery(this.appendTo).find('.panel-thumbnail-view').addClass('v-direction-rtl');
jQuery(this.appendTo).find('.thumbnail-view').find('li').each(function(){
jQuery(this).addClass('thumbnail-rtl');
});
}
this.bindEvents();
this.listenForActions();
Expand Down
Loading

0 comments on commit 6e15d69

Please sign in to comment.