-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template improvements #394
base: master
Are you sure you want to change the base?
Conversation
item.addClass('current'); | ||
|
||
// CURRENT | ||
var similarElements = getElementsOfSameClass(before); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can achieve similar functionality with:
var elementClasses = before.attr('class');
var similarElements = before.siblings(`[class="${elementClasses}"]`);
@@ -149,22 +159,59 @@ | |||
} | |||
} | |||
|
|||
function updateProgressIndicator(before, after, opts) { | |||
// if we're the first entry in the batch | |||
before = $(before); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to create new variables instead reusing existing ones.
var $before = $(before);
before.addClass('processed'); | ||
|
||
var allProcessed = true; | ||
similarElements.each(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to jQuery documentation:
.hasClass( className )
Description: Determine whether any of the matched elements are assigned the given class.
...you can just do:
if (!similarElements.hasClass('processed')) {
(...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or as a one-liner:
var allProcessed = !similarElements.hasClass('processed');
function getMenuItemCorrespondingTo(path) { | ||
var item = false; | ||
$.each($('.list-group .list-group-item a'), function() { | ||
if ($(this).attr('href').substring(1) == path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ===
strict comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole function can also be a one-liner:
return $(`.list-group .list-group-item a[href="/${path}"]`);
var path = before.find('.path').attr('name'); | ||
var item = getMenuItemCorrespondingTo(path); | ||
|
||
item.addClass('checked'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually add is-
or has-
prefix to boolean class names:
is-checked
It makes it a tiny little bit cleaner IMO.
Use left/right arrow keys for changing to next/prev gallery slide
Started work on improving the slideshow template, but ran out of time before properly addressing the progress indicator work. Ought to add keyboard controls too, for easy full-screen navigation.