From f9b0bd2e7b5298960ab007954932e93556474b8b Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Wed, 7 Mar 2018 17:07:26 +0530 Subject: [PATCH 1/6] Update Tag.js --- src/js/components/Tag.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js index 734b2b320..e7632f600 100644 --- a/src/js/components/Tag.js +++ b/src/js/components/Tag.js @@ -1,14 +1,27 @@ import { select, selectAll, on } from '../deps/utils' const tagButtons = selectAll('button.tags__tag') - +let isShiftSelected = false; const onClick = function() { + if(isShiftSelected){ + document.querySelector.classList.remove('is-active') + } + else{ tagButtons.forEach(button => button.classList.remove('is-active')) + } this.classList.add('is-active') EventHub.emit('Tag.click', { type: this.dataset.type }) } +onkeydown = e => ( + if(e.shiftKey){ + isShiftSelected = true; +}); +onkeyup = e => ( + if(e.shiftKey){ + isShiftSelected = false; +}); tagButtons.forEach(button => on(button, 'click', onClick)) From 7ec6a73242e3d16494768ab9782230c34c511c53 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Wed, 7 Mar 2018 18:52:36 +0530 Subject: [PATCH 2/6] Update Tag.js --- src/js/components/Tag.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js index e7632f600..9393bf9b4 100644 --- a/src/js/components/Tag.js +++ b/src/js/components/Tag.js @@ -3,16 +3,35 @@ import { select, selectAll, on } from '../deps/utils' const tagButtons = selectAll('button.tags__tag') let isShiftSelected = false; const onClick = function() { - if(isShiftSelected){ - document.querySelector.classList.remove('is-active') + let currentElements = [...document.querySelector('button.tags__tag.is-active')] + if(isShiftSelected && this.dataset.type === 'all'){ + tagButtons.forEach(button => button.classList.remove('is-active')) } - else{ - tagButtons.forEach(button => button.classList.remove('is-active')) + else if(isShiftSelected){ + document.querySelector('button[type=all]').classList.remove('is-active') + } + else { + tagButtons.forEach(button => button.classList.remove('is-active')) + } + if(this.classList.contains('is-active') && this.dataset.type === 'all'){ + this.classList.add('is-active') + currentElements = [this] + } + else if(this.classList.contains('is-active')){ + this.classList.remove('is-active') + currentElements.splice(currentElements.indexOf(this),1) + } + else { + this.classList.add('is-active'); + if(isShiftSelected){ + currentElements.push(this) + } + else{ + currentElements = [this] + } } - this.classList.add('is-active') - EventHub.emit('Tag.click', { - type: this.dataset.type + type: currentElements.map(el => el.dataset.type) }) } onkeydown = e => ( From f24da491b10034d24bf7297852db6f96456a9485 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Wed, 7 Mar 2018 18:54:35 +0530 Subject: [PATCH 3/6] Update Snippet.js --- src/js/components/Snippet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/Snippet.js b/src/js/components/Snippet.js index 01e6c0bad..cbba93f1e 100644 --- a/src/js/components/Snippet.js +++ b/src/js/components/Snippet.js @@ -4,9 +4,9 @@ const snippets = selectAll('.snippet') EventHub.on('Tag.click', data => { snippets.forEach(snippet => { snippet.style.display = 'block' - if (data.type === 'all') return + if (data.type.includes('all')) return const tags = selectAll('.tags__tag', snippet) - if (!tags.some(el => el.dataset.type === data.type)) { + if (!tags.some(el => data.type.includes(el.dataset.type))) { snippet.style.display = 'none' } }) From f6882990990fd0545a31dc9ad062a202fb1f8871 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Wed, 7 Mar 2018 21:12:40 +0530 Subject: [PATCH 4/6] Update Tag.js Make it shorter --- src/js/components/Tag.js | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js index 9393bf9b4..d18127680 100644 --- a/src/js/components/Tag.js +++ b/src/js/components/Tag.js @@ -3,35 +3,20 @@ import { select, selectAll, on } from '../deps/utils' const tagButtons = selectAll('button.tags__tag') let isShiftSelected = false; const onClick = function() { - let currentElements = [...document.querySelector('button.tags__tag.is-active')] if(isShiftSelected && this.dataset.type === 'all'){ - tagButtons.forEach(button => button.classList.remove('is-active')) - } - else if(isShiftSelected){ - document.querySelector('button[type=all]').classList.remove('is-active') - } - else { - tagButtons.forEach(button => button.classList.remove('is-active')) - } - if(this.classList.contains('is-active') && this.dataset.type === 'all'){ - this.classList.add('is-active') - currentElements = [this] - } - else if(this.classList.contains('is-active')){ - this.classList.remove('is-active') - currentElements.splice(currentElements.indexOf(this),1) - } - else { + tagButtons.forEach(button => button.classList.remove('is-active')); + this.classList.add('is-active'); + } + else if(isShiftSelected) { + this.classList.add('is-active'); + select('button[data-type=all]').classList.reomove('is-active'); + } + else { + tagButtons.forEach(button => button.classList.remove('is-active')); this.classList.add('is-active'); - if(isShiftSelected){ - currentElements.push(this) - } - else{ - currentElements = [this] - } } EventHub.emit('Tag.click', { - type: currentElements.map(el => el.dataset.type) + type: [...selectAll('button.tags__tag.is-avtive')] }) } onkeydown = e => ( From 08fd9b98a170b9a4413892194da12ee62d782a63 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Thu, 8 Mar 2018 19:57:11 +0530 Subject: [PATCH 5/6] Update Tag.js --- src/js/components/Tag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js index d18127680..cc2c2b221 100644 --- a/src/js/components/Tag.js +++ b/src/js/components/Tag.js @@ -16,7 +16,7 @@ const onClick = function() { this.classList.add('is-active'); } EventHub.emit('Tag.click', { - type: [...selectAll('button.tags__tag.is-avtive')] + type: [...selectAll('button.tags__tag.is-active')] }) } onkeydown = e => ( From b065ee65d83c13d76fcef3670b66a500998aa2b1 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Fri, 13 Apr 2018 20:21:32 +0530 Subject: [PATCH 6/6] Update Tag.js --- src/js/components/Tag.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js index cc2c2b221..099136546 100644 --- a/src/js/components/Tag.js +++ b/src/js/components/Tag.js @@ -19,13 +19,13 @@ const onClick = function() { type: [...selectAll('button.tags__tag.is-active')] }) } -onkeydown = e => ( +onkeydown = e => { if(e.shiftKey){ isShiftSelected = true; -}); +}}; -onkeyup = e => ( +onkeyup = e => { if(e.shiftKey){ isShiftSelected = false; -}); +}}; tagButtons.forEach(button => on(button, 'click', onClick))