Skip to content

Commit

Permalink
Merge pull request #1473 from ProjectMirador/kiyonoriNagasaki-develop
Browse files Browse the repository at this point in the history
Enable Right-to-Left viewing (from Kiyonori Nagasaki develop)
  • Loading branch information
aeschylus authored Sep 15, 2017
2 parents d03457b + 6e15d69 commit 804d978
Show file tree
Hide file tree
Showing 15 changed files with 380 additions and 176 deletions.
5 changes: 5 additions & 0 deletions css/less/views/gallery-view.less
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,9 @@
.hud-control .ui-slider-range {
background: @deep-sky-blue;
}

.thumbnail-rtl{
float: right !important;
}

}
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;
}
}
2 changes: 1 addition & 1 deletion css/less/workspace.less
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@
left: 0;
display: none;
}
}
}
5 changes: 5 additions & 0 deletions js/src/manifests/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@
var canvas = this.canvasMap[canvasId.split('#')[0]];
return canvas ? canvas.label : undefined;
}
},
getViewingDirection : function() {
var _this = this;
return _this.jsonLd.viewingDirection || _this.jsonLd.sequences[0].viewingDirection;

}
};

Expand Down
98 changes: 51 additions & 47 deletions js/src/widgets/bookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
stitchList: [],
canvasID: null,
imagesList: [],
imagesListRtl: [],
element: null,
focusImages: [],
manifest: null,
Expand All @@ -32,6 +33,9 @@

init: function() {
var _this = this;
if(this.vDirectionStatus == 'rtl'){
this.imagesList = this.imagesListRtl.concat();
}
if (this.canvasID !== null) {
this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID);
}
Expand Down Expand Up @@ -79,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 @@ -121,7 +125,7 @@
});
},

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

this.element.find('.mirador-osd-next').on('click', function() {
Expand Down Expand Up @@ -196,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 @@ -265,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 @@ -290,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 @@ -402,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 @@ -421,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: 6 additions & 2 deletions js/src/widgets/imageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
canvasID: null,
canvases: null,
imagesList: [],
imagesListRtl: [],
element: null,
elemOsd: null,
manifest: null,
Expand All @@ -22,7 +23,8 @@
annoCls: 'annotation-canvas',
annotationsLayer: null,
forceShowControls: false,
eventEmitter: null
eventEmitter: null,
vDirectionStatus: ''
}, options);

this.init();
Expand All @@ -34,7 +36,9 @@
var _this = this;
this.horizontallyFlipped = false;
this.originalDragHandler = null;

if(this.vDirectionStatus == 'rtl'){
this.imagesList = this.imagesListRtl.concat();
}
// check (for thumbnail view) if the canvasID is set.
// If not, make it page/item 1.
if (this.canvasID !== null) {
Expand Down
8 changes: 6 additions & 2 deletions js/src/widgets/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'},
windowId: null,
panel: false,
vDirectionStatus: '',
lazyLoadingFactor: 1.5 //should be >= 1
}, options);

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

}(Mirador));
15 changes: 13 additions & 2 deletions js/src/widgets/thumbnailsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
manifest: null,
element: null,
imagesList: [],
imagesListLtr: [],
vDirectionStatus: '',
appendTo: null,
thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'},
defaultThumbHeight: 150,
Expand All @@ -21,15 +23,24 @@
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.loadContent();
if(this.vDirectionStatus == '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 804d978

Please sign in to comment.