From a6c3c77b091446b752f2867035e9667bdfec3683 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 12 Apr 2022 16:36:56 +0200 Subject: [PATCH] wip #4259 @1.5 --- images/symbols/cart-overlay.svg | 31 ++++++++++++----------------- js/libs/fluidbook/fluidbook.cart.js | 25 ++++++++++++++++++++--- style/cart.less | 25 +++++++++++++++++++++-- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/images/symbols/cart-overlay.svg b/images/symbols/cart-overlay.svg index 4088fa1a..85287f65 100644 --- a/images/symbols/cart-overlay.svg +++ b/images/symbols/cart-overlay.svg @@ -1,25 +1,20 @@ - - + + - - + + - - - + + + - - - + + + - - - + + + diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index 7e295077..506e992b 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -78,12 +78,31 @@ FluidbookCart.prototype = { if (this.fluidbook.settings.cartLinkAppearance === 'overlay') { $('a[data-cart-ref]').each(function () { - var paddingTop = 0.5 * ($(this).outerHeight() - 100); - var paddingLeft = 0.5 * ($(this).outerWidth() - 250); + var small = false; + var smallwidth = false; + var smallheight = false; + if ($(this).outerWidth() < 280) { + smallwidth = small = true; + $(this).addClass('small').addClass('smallwidth'); + } + if ($(this).outerHeight() < 130) { + smallheight = small = true; + $(this).addClass('small').addClass('smallheight'); + } + + var bw = 250; + var bh = 100; + if (small) { + bw = 170; + bh = 80; + } + + var paddingTop = 0.5 * ($(this).outerHeight() - bh); + var paddingLeft = 0.5 * ($(this).outerWidth() - bw); $(this).attr('data-tooltip', null).addClass('overlay').css({ paddingTop: paddingTop, paddingLeft: paddingLeft - }).html('
' + getSpriteIcon('link-cart-remove') + getSpriteIcon('link-cart-remove-hover') + '
' + getSpriteIcon('link-cart-add') + getSpriteIcon('link-cart-add-hover') + '
' + getSpriteIcon('link-cart-info')+'
'); + }).html('
' + getSpriteIcon('link-cart-remove') + getSpriteIcon('link-cart-remove-hover') + '
' + getSpriteIcon('link-cart-add') + getSpriteIcon('link-cart-add-hover') + '
' + getSpriteIcon('link-cart-info') + '
'); }); } }, diff --git a/style/cart.less b/style/cart.less index b30420d2..86779139 100644 --- a/style/cart.less +++ b/style/cart.less @@ -4,6 +4,26 @@ a[data-cart-ref] { &.overlay { color: #fff; + &.small { + div { + &.infos { + bottom: 15px; + right: 15px; + } + + @w: 80px; + + &.add { + margin-left: unit(10, px); + } + + &.add, &.remove { + width: @w; + height: @w; + } + } + } + div { &.infos { @w: 50px; @@ -17,6 +37,7 @@ a[data-cart-ref] { } @w: 100px; + &.add { margin-left: unit(@w*0.5, px); } @@ -31,8 +52,8 @@ a[data-cart-ref] { svg { top: 0; left: 0; - width: @w; - height: @w; + width: 100%; + height: 100%; overflow: visible; position: absolute; display: block; -- 2.39.5