From ee989f67e6275f5351357b078a1840a59a2fdb2e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 17 Apr 2018 19:06:54 +0200 Subject: [PATCH] wip #1927 @0.5 --- js/libs/fluidbook/fluidbook.cart.js | 2 +- js/libs/fluidbook/fluidbook.tooltip.js | 19 +++++++++++++------ style/fluidbook.less | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index ed1242bd..ed613472 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -22,7 +22,7 @@ FluidbookCart.prototype = { $(document).on('click', '[data-cart-ref]', function () { $this.instance.addToCart($(this).data('cart-ref')); - $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart")); + $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart"), 'invert'); return false; }); }, diff --git a/js/libs/fluidbook/fluidbook.tooltip.js b/js/libs/fluidbook/fluidbook.tooltip.js index c426ac74..d2592585 100644 --- a/js/libs/fluidbook/fluidbook.tooltip.js +++ b/js/libs/fluidbook/fluidbook.tooltip.js @@ -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('
'); }, @@ -67,7 +67,10 @@ FluidbookTooltip.prototype = { var maxx = this.fluidbook.resize.ww - w; var maxy = this.fluidbook.resize.hh - h; - $("#tooltip").attr('data-pos-x', x).attr('data-pos-y', y).css({top: Math.max(1, Math.min(top, maxy)), left: Math.max(1, Math.min(left, maxx))}); + $("#tooltip").attr('data-pos-x', x).attr('data-pos-y', y).css({ + top: Math.max(1, Math.min(top, maxy)), + left: Math.max(1, Math.min(left, maxx)) + }); }, eventTriggered: function (target) { @@ -107,8 +110,12 @@ FluidbookTooltip.prototype = { return false; }, - displayTooltip: function (text) { + displayTooltip: function (text, style) { var t = $("#tooltip"); + if (style == undefined) { + style = ''; + } + t.attr('data-style', style); t.css('maxWidth', 250).html(text).show() var nbchars = t.text().length; diff --git a/style/fluidbook.less b/style/fluidbook.less index cb4890f3..256bedb1 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -2284,6 +2284,24 @@ ul.chapters { box-sizing: border-box; pointer-events: none; + &[data-style="invert"] { + font-weight: 700; + background-color: @tooltip-color; + color: @tooltip-background; + + &[data-pos-y="n"] { + &:after { + border-bottom-color: @tooltip-color; + } + } + + &[data-pos-y="s"] { + &:after { + border-top-color: @tooltip-color; + } + } + } + &:after { content: ""; position: absolute; -- 2.39.5