]> _ Git - fluidbook-html5.git/commitdiff
fix #3767 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2020 17:56:51 +0000 (19:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2020 17:56:51 +0000 (19:56 +0200)
js/libs/cube/util.js
js/libs/fluidbook/fluidbook.bookmarks.js
js/libs/fluidbook/menu/fluidbook.index.js

index 14b25075890ddd66db494d7628e94a6797b74bef..d74353b5d313172be74b1015a98b52faa76ee967 100644 (file)
@@ -156,3 +156,5 @@ Object.size = function (obj) {
     return size;
 };
 
+/*! sprintf-js v1.1.2 | Copyright (c) 2007-present, Alexandru Mărășteanu <hello@alexei.ro> | BSD-3-Clause */
+!function(){"use strict";var g={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function y(e){return function(e,t){var r,n,i,s,a,o,p,c,l,u=1,f=e.length,d="";for(n=0;n<f;n++)if("string"==typeof e[n])d+=e[n];else if("object"==typeof e[n]){if((s=e[n]).keys)for(r=t[u],i=0;i<s.keys.length;i++){if(null==r)throw new Error(y('[sprintf] Cannot access property "%s" of undefined value "%s"',s.keys[i],s.keys[i-1]));r=r[s.keys[i]]}else r=s.param_no?t[s.param_no]:t[u++];if(g.not_type.test(s.type)&&g.not_primitive.test(s.type)&&r instanceof Function&&(r=r()),g.numeric_arg.test(s.type)&&"number"!=typeof r&&isNaN(r))throw new TypeError(y("[sprintf] expecting number but found %T",r));switch(g.number.test(s.type)&&(c=0<=r),s.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,s.width?parseInt(s.width):0);break;case"e":r=s.precision?parseFloat(r).toExponential(s.precision):parseFloat(r).toExponential();break;case"f":r=s.precision?parseFloat(r).toFixed(s.precision):parseFloat(r);break;case"g":r=s.precision?String(Number(r.toPrecision(s.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=s.precision?r.substring(0,s.precision):r;break;case"t":r=String(!!r),r=s.precision?r.substring(0,s.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=s.precision?r.substring(0,s.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=s.precision?r.substring(0,s.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}g.json.test(s.type)?d+=r:(!g.number.test(s.type)||c&&!s.sign?l="":(l=c?"+":"-",r=r.toString().replace(g.sign,"")),o=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",p=s.width-(l+r).length,a=s.width&&0<p?o.repeat(p):"",d+=s.align?l+r+a:"0"===o?l+a+r:a+l+r)}return d}(function(e){if(p[e])return p[e];var t,r=e,n=[],i=0;for(;r;){if(null!==(t=g.text.exec(r)))n.push(t[0]);else if(null!==(t=g.modulo.exec(r)))n.push("%");else{if(null===(t=g.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){i|=1;var s=[],a=t[2],o=[];if(null===(o=g.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(o[1]);""!==(a=a.substring(o[0].length));)if(null!==(o=g.key_access.exec(a)))s.push(o[1]);else{if(null===(o=g.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(o[1])}t[2]=s}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}r=r.substring(t[0].length)}return p[e]=n}(e),arguments)}function e(e,t){return y.apply(null,[e].concat(t||[]))}var p=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=y,exports.vsprintf=e),"undefined"!=typeof window&&(window.sprintf=y,window.vsprintf=e,"function"==typeof define&&define.amd&&define(function(){return{sprintf:y,vsprintf:e}}))}();
\ No newline at end of file
index 52ae0899ebb9c9414bf1e60d190f398094fdd9c9..9fadbe5e036fd640a56051921a43df5f9fab1d7d 100644 (file)
@@ -13,6 +13,8 @@ function FluidbookBookmarks(fluidbook) {
 
     this._txtAdd = this.fluidbook.l10n.translate('add a bookmark', false);
     this._txtRemove = this.fluidbook.l10n.translate('remove the bookmark', false);
+    this._labelRemove = this.fluidbook.l10n.translate('remove the bookmark on page %s', false);
+    this._labelAdd = this.fluidbook.l10n.translate('add a bookmark on page %s', false);
 
     this._cornersIndex = [];
     this._cornersPages = [];
@@ -402,15 +404,17 @@ FluidbookBookmarks.prototype = {
             shortcut = "Control+Shift+D";
         }
 
+
+        var virtual = this.fluidbook.physicalToVirtual(pageNr);
         bookmarks += "<a href=\"#\" class=\"bookmark " + side + "\" data-page=\"" + pageNr + "\"";
         bookmarks += ' aria-keyshortcuts="' + shortcut + '" role="button"'
         if (this.isBookmarked(pageNr)) {
             bookmarks += " data-enabled=\"enabled\"";
             bookmarks += " data-tooltip=\"" + this._txtRemove + "\"";
-            bookmarks += " aria-label=\"" + this._txtRemove + "\"";
+            bookmarks += " aria-label=\"" + sprintf(this._labelRemove, virtual) + "\"";
         } else {
             bookmarks += " data-tooltip=\"" + this._txtAdd + "\"";
-            bookmarks += " aria-label=\"" + this._txtAdd + "\"";
+            bookmarks += " aria-label=\"" + sprintf(this._labelAdd, virtual) + "\"";
         }
 
         bookmarks += '>' + getSpriteIcon('bookmark-corner') + '</a>';
@@ -426,7 +430,7 @@ FluidbookBookmarks.prototype = {
             title = this.fluidbook.l10n.__('bookmarks');
         }
         var index = '<div class="bookmarkssub">';
-        index+=this.fluidbook.menu.getCaption(title);
+        index += this.fluidbook.menu.getCaption(title);
         index += c;
         index += '</div>';
         return index;
index 5b2adf628ab80b413a7e2b79b04a2e2640da8ecc..4b70488fdbf879a50afa060001887495f6401a67 100644 (file)
@@ -38,7 +38,7 @@ FluidbookIndex.prototype = {
         var c = !closeAll ? ' one' : '';
         var index = this.fluidbook.menu.getCaption(title);
         index += this.getView(group);
-        this.fluidbook.menu.viewWrap(index,'index');
+        this.fluidbook.menu.viewWrap(index, 'index');
         // Mark current page
         var cp = this.fluidbook.currentPage;
 
@@ -84,7 +84,7 @@ FluidbookIndex.prototype = {
             res += '<div class="indexViewMessage">' + this.fluidbook.settings.indexMessage + '</div>';
         }
 
-        res += '<div class="indexViewHolder">';
+        res += '<nav class="indexViewHolder">';
         var j = 0;
         var ix1 = '', ix2 = '', ix = '';
         var c = '';
@@ -118,7 +118,7 @@ FluidbookIndex.prototype = {
             }
 
             if (i > 0) {
-                ix1 += '<div class="thumb ' + s1 + '"' + dim.thumb + '><a href="#/page/' + i + '">' + this.fluidbook.loader.getThumbImage(i, true, dim.thumb) + '</a><span class="number"' + dim.pagenumber + '>' + this.fluidbook.physicalToVirtual(i) + '</span>';
+                ix1 += this._thumb(i, s1, height);
                 if (this.fluidbook.bookmarks.enabled) {
                     ix1 += this.fluidbook.bookmarks.getBookmarkForPage(i, mobileFirst, this.fluidbook.settings.bookmarkPermanentIcon);
                 }
@@ -137,7 +137,7 @@ FluidbookIndex.prototype = {
             }
             if (!this.singleMode) {
                 if (j <= this.fluidbook.contentlock.getMaxPage()) {
-                    ix2 += '<div class="thumb ' + s1 + '"><a href="#/page/' + j + '">' + this.fluidbook.loader.getThumbImage(j, true, dim.thumb) + '</a><span class="number">' + this.fluidbook.physicalToVirtual(j) + '</span>';
+                    ix2 += this._thumb(j, s1, height);
                     if (this.fluidbook.bookmarks.enabled) {
                         ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true);
                     }
@@ -159,10 +159,16 @@ FluidbookIndex.prototype = {
             res += '<div class="doubleThumb' + c + '" page="' + i + '" data-pages="' + pages.join(',') + '"' + dim.doublethumb + '>' + ix;
             res += '</div>';
         }
-        res += '</div></div></div>';
+        res += '</nav></div></div>';
         return res;
     },
 
+    _thumb: function (page, side, height) {
+        var dim = this.getThumbDimensions(page, height);
+        var virtual = this.fluidbook.physicalToVirtual(page);
+        return '<div class="thumb ' + side + '" ' + dim.thumb + '><a role="button" aria-label="' + sprintf(this.fluidbook.l10n.__('goto page %s'), virtual) + '" href="#/page/' + page + '">' + this.fluidbook.loader.getThumbImage(page, true, dim.thumb) + '</a><span aria-hidden="true" class="number" ' + dim.pagenumber + '>' + virtual + '</span>';
+    },
+
     getThumbDimensions: function (page, height) {
         var h = '';
         var pnt = '';