From 8baec3bc1b0954d76b83d2b1f957bc4e98b7f65a Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Sun, 28 Feb 2016 17:55:25 +0000 Subject: [PATCH 1/3] fix #329 --- .../gallery_template/slideshow_template.erb | 66 ++++++++++++++++--- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/lib/wraith/gallery_template/slideshow_template.erb b/lib/wraith/gallery_template/slideshow_template.erb index baead8e2..4496bd8e 100644 --- a/lib/wraith/gallery_template/slideshow_template.erb +++ b/lib/wraith/gallery_template/slideshow_template.erb @@ -105,13 +105,56 @@ margin-right: 20px; max-width: 30%; } + + .compare-modal ~ .prev { + z-index: 9999; + position: fixed; + top: 0; + left: 0; + width: 4%; + padding: 7px; + } + + .compare-modal ~ .next { + z-index: 9999; + position: fixed; + top: 0; + right: 0; + width: 4%; + padding: 7px; + } + + .compare-modal h1 { + color: white; + } + From d424ef4afa39d5db68444fe6b3fca771004c29e3 Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Sun, 28 Feb 2016 18:42:20 +0000 Subject: [PATCH 2/3] started work on #328 --- .../gallery_template/slideshow_template.erb | 85 ++++++++++++++----- 1 file changed, 66 insertions(+), 19 deletions(-) diff --git a/lib/wraith/gallery_template/slideshow_template.erb b/lib/wraith/gallery_template/slideshow_template.erb index 4496bd8e..824a9b54 100644 --- a/lib/wraith/gallery_template/slideshow_template.erb +++ b/lib/wraith/gallery_template/slideshow_template.erb @@ -33,8 +33,8 @@ margin-top: 60px; } - .prev span:before, - .next span:before { + .prev span::before, + .next span::before { font-size: 35px; padding: 10px; display: block; @@ -43,21 +43,19 @@ display: block; } - .prev span:before { + .prev span::before { content:"\f0d9"; } - .next span:before { + .next span::before { content:"\f0da"; } - .list-group-item.checked a:after { - color: #23e343; - } + .list-group-item a span { word-wrap: break-word; width: 95%; display: block; } - .list-group-item a:after { + .list-group-item a::after { content:"\f00c"; font-family: "FontAwesome"; color: #eae6e6; @@ -65,6 +63,18 @@ right: 10px; top: 10px; } + + .list-group-item.current a::after { + color: #E1AB2F; + font-weight: bold; + content: "---"; + } + .list-group-item.checked a::after { + color: #23e343; + content:"\f00c"; + font-weight: normal; + } + .checked a { color: #000; } @@ -79,7 +89,7 @@ margin-left: 20px; } - .compare:before { + .compare::before { font-family: "FontAwesome"; content:"\f0c5"; font-size: 30px; @@ -149,22 +159,59 @@ } } + function updateProgressIndicator(before, after, opts) { + // if we're the first entry in the batch + before = $(before); + after = $(after); + + // NEXT + $('.current').removeClass('current'); + var path = after.find('.path').attr('name'); + var item = getMenuItemCorrespondingTo(path); + item.addClass('current'); + + // CURRENT + var similarElements = getElementsOfSameClass(before); + before.addClass('processed'); + + var allProcessed = true; + similarElements.each(function () { + if ( !$(this).hasClass('processed') ) { + allProcessed = false; + } + }); + + if (allProcessed) { + var path = before.find('.path').attr('name'); + var item = getMenuItemCorrespondingTo(path); + + item.addClass('checked'); + } + } + + function getElementsOfSameClass(element) { + var classNamesOfElement = element.attr('class').split(/\s+/), + similarElements = element.parent().find('.' + classNamesOfElement.join('.')); + return similarElements; + } + + function getMenuItemCorrespondingTo(path) { + var item = false; + $.each($('.list-group .list-group-item a'), function() { + if ($(this).attr('href').substring(1) == path) { + item = $(this).parent(); + } + }) + return item; + } + // http://jquery.malsup.com/cycle/options.html $('.slideshow').cycle({ fx: 'cover', prev: '.prev', next: '.next', speed: 300, - before: function (curr, next, opts) { - $('.current').removeClass('current'); - var path = $(next).find('.path').attr('name'); - $.each($('.list-group .list-group-item a'), function() { - if ($(this).attr('href').substring(1) == path) { - $(this).parent().addClass('checked'); - $(this).parent().addClass('current'); - } - }) - }, + before: updateProgressIndicator, after: function () { if (fullscreen) { $('.compare-modal').remove(); From ee569d71c542a3bb45fb3b82598f145a9dbef30c Mon Sep 17 00:00:00 2001 From: Viktor Fonic Date: Wed, 16 Nov 2016 13:41:47 +0700 Subject: [PATCH 3/3] Use left/right arrow keys for changing to next/prev gallery slide --- lib/wraith/gallery_template/slideshow_template.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/wraith/gallery_template/slideshow_template.erb b/lib/wraith/gallery_template/slideshow_template.erb index 5f40c79c..8d1a3d90 100644 --- a/lib/wraith/gallery_template/slideshow_template.erb +++ b/lib/wraith/gallery_template/slideshow_template.erb @@ -148,6 +148,20 @@ $(this).remove(); }) }) + + window.addEventListener('keydown', function(e){ + var leftArrowKeyCode = 37; + var rightArrowKeyCode = 39; + + e = e || window.event; + + if (e.keyCode === leftArrowKeyCode) { + $('.slideshow').cycle('prev'); + } + else if (e.keyCode === rightArrowKeyCode) { + $('.slideshow').cycle('next'); + } + }); })