-
Notifications
You must be signed in to change notification settings - Fork 3
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
added collapsible contents block #217
base: 1.x
Are you sure you want to change the base?
Conversation
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.
Thanks for this Josh. There's a few things that'll need to change before we could merge this. I've added some comments to the MR.
js/localgov-publications.js
Outdated
const menuCollapseBreakpoint = 992; | ||
|
||
var headers = [ | ||
$('.bfc-publication-navigation__content-header', context), |
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 looks like some Bracknell forest specific code.
js/localgov-publications.js
Outdated
*/ | ||
Drupal.behaviors.publicationMenuToggle = { | ||
attach: function(context) { | ||
const menuCollapseBreakpoint = 992; |
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.
Is this value correct for every LGD site? If not, it'll need to be configurable somehow, or done another way.
js/localgov-publications.js
Outdated
}); | ||
} | ||
headers.forEach(function(header, index) { | ||
if (!header.data('menuToggleAttached')) { |
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 looks like it's re-inventing once. Could it use once instead?
js/localgov-publications.js
Outdated
@@ -15,3 +15,54 @@ | |||
} | |||
}; | |||
})(jQuery, Drupal); | |||
|
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.
All this code should be inside the closure that the existing JS code defines.
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.
Actually, I've just realised the existing code is only for admin pages. This new code should probably be in its own file and library definition.
js/localgov-publications.js
Outdated
header.data('menuToggleAttached', true); | ||
} | ||
}); | ||
initializeStateForMenus(); |
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.
We'll need a way to make this feature optional. It can be defaulted to on for new installs, but we can't enable it by default for existing sites.
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 could be achieved by adding a toggle in the block config for setting enabled/disabled?
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.
Yeah, that seems like a sensible approach.
Thank you for your insight @rupertj, I will review and improve this based on the suggestions provided. |
What does this change?
Adds a collapsible contents block to LocalGov publication pages.