]> _ Git - fluidbook-html5.git/commitdiff
done #1711 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Oct 2017 15:57:49 +0000 (17:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Oct 2017 15:57:49 +0000 (17:57 +0200)
js/libs/fluidbook/fluidbook.l10n.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.slider.js

index 0af39ff1a0b7ee87e7170ba7118365534eac9111..12ce4336222980cd12ce6153c41ee2c92d7e889a 100644 (file)
@@ -16,6 +16,8 @@ FluidbookL10N.prototype = {
         this.lang = lang;
 
         this.dir = this.getLanguageDirection(this.getActiveLang());
+        this.ltr = (this.dir == 'ltr');
+        this.rtl = !this.ltr;
         $('html').attr('dir', this.dir);
         if (this.dir == 'rtl') {
             $('html').removeClass('ltr').addClass('rtl');
@@ -132,7 +134,7 @@ FluidbookL10N.prototype = {
             return name;
         }
 
-        switch(this.fluidbook.datas.multilangDisplay) {
+        switch (this.fluidbook.datas.multilangDisplay) {
             case 'lang':
                 name = details.langName;
                 break;
index 5ecfd529154169698acc20eea33eed6e4004d77b..79ab0256cae7229b6e48909ff93cebe85337f2bb 100644 (file)
@@ -172,7 +172,7 @@ FluidbookLoader.prototype = {
         $(page).children('.clinks').html(this.fluidbook.datas.clinks[pageNr]);
         $(page).children(".shade").html(this.loadPageShade(position));
     },
-    loadPageShade:function(position){
+    loadPageShade: function (position) {
         return this.loadImage('images/shadows/pages/' + position + '.png', this.fluidbook.datas.width / 4, this.fluidbook.datas.height);
     },
     loadLeftPage: function (page, doublePage, callback) {
@@ -264,7 +264,7 @@ FluidbookLoader.prototype = {
             div = $('<div />');
         }
 
-        left = (page % 2 == 0);
+        left = ((page % 2 == 0) && this.fluidbook.l10n.ltr) || ((page % 2 == 1) && this.fluidbook.l10n.rtl);
 
         var h = this.fluidbook.datas.thumbHeight;
         var s = Math.floor((page - 1) / 100);
index 3cc3597e649b17c162a84a328244a924dc92f73e..464d48b83e4afe32eed373d9fd87fcc9470b8793 100644 (file)
@@ -95,6 +95,11 @@ FluidbookSlider.prototype = {
 
     getPageByX: function (pos) {
         var page;
+
+        if (this.fluidbook.l10n.rtl) {
+            pos = Math.max(0, this.sliderWidth - pos);
+        }
+
         if (this.fluidbook.resize.orientation == 'portrait') {
             page = Math.floor(pos / (this.sliderWidth / this.snapsCount)) + 1;
             pageMin = 1;
@@ -104,6 +109,7 @@ FluidbookSlider.prototype = {
         }
 
         return Math.min(this.fluidbook.datas.pages, Math.max(pageMin, page));
+
     },
 
     resize: function (ww, hh, single) {
@@ -158,6 +164,9 @@ FluidbookSlider.prototype = {
 
     getCursorXByPage: function (page) {
         var left;
+        if (this.fluidbook.l10n.rtl) {
+            page = this.fluidbook.datas.pages - page;
+        }
         if (this.fluidbook.resize.orientation == 'portrait') {
             left = this.snapsWidth * (page - 1);
         } else {
@@ -207,8 +216,14 @@ FluidbookSlider.prototype = {
         }
 
 
-        this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.left'), left, !single);
-        this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.right'), right, !single);
+        if (this.fluidbook.l10n.ltr) {
+            this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.left'), left, !single);
+            this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.right'), right, !single);
+        } else {
+            this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.left'), right, !single);
+            this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.right'), left, !single);
+        }
+
         this.fluidbook.bookmarks.updateBookmarks();
         $("#sliderthumb").css('left', this.getCursorXByPage(page) + (this.cursorWidth / 2) - ($("#sliderthumb").outerWidth() / 2));
     },