]> _ Git - fluidbook-html5.git/commitdiff
wip #1938 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 9 Feb 2018 17:34:59 +0000 (18:34 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 9 Feb 2018 17:34:59 +0000 (18:34 +0100)
js/libs/fluidbook/fluidbook.bookmarks.js
js/libs/fluidbook/fluidbook.tooltip.js

index 9375291ef589747e4fda983fbcd2e176cf37bdf4..0d3c663b2b1e5610b80731b8f84123d13b202efb 100644 (file)
@@ -8,6 +8,9 @@ function FluidbookBookmarks(fluidbook) {
     this._groups = 0;
     this._groupOrder = [];
 
+    this._txtAdd = this.fluidbook.l10n.__('add a bookmark',false);
+    this._txtRemove = this.fluidbook.l10n.__('remove the bookmark',false);
+
     this._cornersIndex = [];
     this._cornersPages = [];
 
@@ -20,6 +23,7 @@ FluidbookBookmarks.prototype = {
         var $this = this;
         $(document).on('click touchend', '.bookmark', function () {
             $this.toggleBookmark(parseInt($(this).attr('data-page')));
+            $this.fluidbook.tooltip.hideTooltip();
             return false;
         });
 
@@ -276,13 +280,13 @@ FluidbookBookmarks.prototype = {
     setCornersEnabled: function (page, enabled) {
         var bookmarks = $('.bookmark[data-page="' + page + '"]');
         if (enabled) {
-            $(bookmarks).attr('data-enabled', 'enabled');
+            $(bookmarks).attr('data-enabled', 'enabled').attr('data-tooltip', this._txtRemove);
         } else {
-            $(bookmarks).attr('data-enabled', null);
+            $(bookmarks).attr('data-enabled', null).attr('data-tooltip', this._txtAdd);
         }
     },
     disableCorners: function () {
-        $(".bookmark").attr('data-enabled', null);
+        $(".bookmark").attr('data-enabled', null).attr('data-tooltip', this._txtAdd);
     },
     toggleBookmark: function (page) {
 
@@ -358,6 +362,9 @@ FluidbookBookmarks.prototype = {
                 bookmarks += "<a href=\"#\" class=\"bookmark " + side + "\" data-page=\"" + i + "\"";
                 if (this.isBookmarked(i)) {
                     bookmarks += " data-enabled=\"enabled\"";
+                    bookmarks += " data-tooltip=\"" + this._txtRemove + "\"";
+                } else {
+                    bookmarks += " data-tooltip=\"" + this._txtAdd + "\"";
                 }
                 bookmarks += '></a>';
             }
@@ -369,8 +376,8 @@ FluidbookBookmarks.prototype = {
         if (c === false) {
             return c;
         }
-        if(title==''){
-            title=this.fluidbook.l10n.__('bookmarks');
+        if (title == '') {
+            title = this.fluidbook.l10n.__('bookmarks');
         }
         var index = '<div class="bookmarkssub"><div class="caption">' + this.fluidbook.menu.closeButton() + '<h2>' + title + '</h2>';
         index += '</div>';
index bb86822b2491b6c260bd5149db87b696a119d45e..c5de8e7401da251c47b98433bbaae78d032f2826 100644 (file)
@@ -19,10 +19,10 @@ FluidbookTooltip.prototype = {
         });
 
 
-            $(document).on('mouseover', 'a[data-tooltip]', function (e) {
-                $this.updateMousePosition(e);
-                $this.eventTriggered(this);
-            });
+        $(document).on('mouseover', 'a[data-tooltip]', function (e) {
+            $this.updateMousePosition(e);
+            $this.eventTriggered(this);
+        });
 
         $("body").append('<div id="tooltip"></div>');
     },
@@ -80,14 +80,13 @@ FluidbookTooltip.prototype = {
             return true;
         }
 
-
         var $this = this;
 
-        var text = $(target).data('tooltip');
+        var text = $(target).attr('data-tooltip');
         text = $('<textarea />').html(text).text();
         if (text.substr(0, 1) == '~') {
             var text = $this.fluidbook.l10n.__(text.substring(1));
-            $(target).data('tooltip', text);
+            $(target).attr('data-tooltip', text);
         }
         if (text == undefined || text == '') {
             return false;