This is a developer module.
'collapsible_list' exposes theme_collapsible_list, which will theme an array as a collapsible list (ordered or unordered).
Only few list items are shown by default. The rest is hidden and a 'View all' button is provided after the last visible list item. When selected, all list items are shown, followed by a 'View less' button.
The show/hide toggle functionality is fully accessible.
Project page:
https://www.drupal.org/sandbox/gosia-m/2840084
Git clone command:
git clone --branch 7.x-1.x https://git.drupal.org/sandbox/gosia-m/2840084.git collapsible_list
cd collapsible_list
Comments
Comment #2
PA robot commentedFixed the git clone URL in the issue summary for non-maintainer users.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
bojan.m commentedThis module is written by coding standards but it is not user friendly.
I suggest you to add some administration pages so it would be more easy for use.
Comment #4
andystone78 commentedHi Goska
Thanks for you contribution, i have a few observations...
• .module:56 use drupal_attributes rather than $output = '<div class="item-list ' . $wrapper_class .'" data-js="collapsible-list">';
• Not a problems per se, but in conditionals, use string == variable rather than variable == string (replace $key == ‘data’ with ‘data’ == $key), this demonstrates defensive coding (should you mistakenly miss off a = then $key = ‘data’ is still valid syntax whereas with ‘data’ = $key is a syntax error).
• Maybe theme_collapsible_list should be building $output as a render array rather than string concatenation.
• $type, should only be passed to theme_item_list, never added in this module.
• Use theme_item_list in all cases, just alter $attributes for first and last li rather than manually adding li. It appears in its current state that you will end up with nested ul/ol tags (one from theme_item_list, one from lines 70/120.
• Remove drupal_add_js(drupal_get_path('module', 'collapsible_list') . 'js/collapsible_list.js');, this file should already be present from your entry in the .info file.
• A nice to have would be to validate $type (only allow ul, ol, etc) if invalid use default and add watchdog warning.
• $show_text and $hide_text should be wrapped in t() to allow default (and possibly supplied) values to be translated.
Kind regards
Andy
Comment #5
rajveergangwarHi,
Below are my review
function CollapsibleList(element, options) {Comment #6
klausi@rajveergang: Removing review bonus tag, this should only be added to your own application. Can you check that you only added it there?
Comment #7
rajveergangwar@klausi,
My mistake.
Comment #8
goska_m commentedHi @bojan_m,
Thank you for your comment.
I don’t think adding an administration page is a good solution here, as this is a developer module. It’s meant to be used by developers, just like the 'theme_item_list' function is used by developers to render and customize ordered or unordered lists of items.
Also, you may want to assign different values to the available variables depending on the location of the ‘collapsible list’ element on the site. For example, on one page you may want to be able to show 5 list items and hide the rest, and provide a button labelled ‘Show all documents’ / ‘Show less documents’, and on another page you may want to display only 3 list items, followed by a button ‘View more news’ / ‘View less news’.
However, if you think this is not well explained on the project page or in the README file, please let me know how I can make the documentation better and more user-friendly.
Thank you!
Comment #9
goska_m commentedHi @rajveergang,
thank you for reviewing my code.
According to JavaScript coding standards all variables should be camelCased.
Comment #10
emcoward commentedHi Gosia,
This looks like a really useful module, just a couple of things to update:
In collapsible_list.module:
26: Title should be translatable e.g. wrapped in the t() function.
30 & 31: 'View all' and 'View less' need to be translatable e.g. wrapped in the t() function.
In collapsible_list.js:
There are quite a few references that suggest the JavaScript is being used for a particular type of list e.g. a documents list. I would suggest changing things like 'totalDocsToShow', 'document-list' and 'totalDocuments' to generic names e.g. itemList.
Ah I see you've translated the 'view all' in the JavaScript but not the 'view less'. Might be an idea to do the translation in the .module file rather than the JavaScript.
There are quite a few hard coded classes in the JavaScript which use BEM naming convention. Suggest providing options to allow developers to override these classes if they need to rather than assuming people are using BEM.
The destroy method looks like it needs to remove the the aria, tabindex and id values you are adding on the list and list items.
In the readme:
You could add which version/s of jQuery this is compatible with.
Suggestions for future improvement:
- It might be nice to make the title of the list into a link, or at least provide this as an option.
- Have you thought about including definition lists?
Comment #11
emcoward commentedComment #12
goska_m commented@andystone78, @emcoward,
Thank you both for the useful feedback!
I think I've implemented all suggested changes with the exception of:
As I understand it's not advisable to pass variables to t() function (automated test returned warnings 'Only string literals should be passed to t() where possible'). However, the strings can be translated by a calling function (I've added few examples on my Project page).
I haven't added definition list as one of the allowed list types, but it's on my TODO list :)
Comment #13
andystone78 commentedHi @goska_m
This looks really good, cant see any further issues.
Comment #14
andystone78 commentedHi @goska_m
I think you need to account for the possibility than one collapsible list may occur on a single page, so the settings need to be applied per list.
Thanks
Andy
Comment #15
goska_m commentedThanks @andystone78, you're right!
This should be fixed now.
Comment #16
satyam upadhyay commentedHi goska_m,
I have review on your module and found:
Regards
Satyam
Comment #17
goska_m commentedHi Satyam,
Thank you for taking your time to review my module!
Kind regards,
Gosia
Comment #18
fadonascimento commentedManual Review
Hi @goska_m
I have review on your module and I suggest the following changes:
The examples in project page is wrong, in the page documentation is the following code;
But in your module, you are manipulating the variables without
#;You should correct the documentation or the code.
[JS]
You should call the plugin inside Drupal behaviors, it's possible you add the context, just a good recommendation, because after Drupal ajax is called all behavior to bind the new elements.
This a good article https://www.lullabot.com/articles/understanding-javascript-behaviors-in-... about it.
Comment #19
fadonascimento commentedHi @goska_m
I send a patch with some modifications in your JS file(collapsible_list.js).
I organized the functions. Now it actually works as a plugin without having dependency on template settings.
You can try to destroy the plugin so easily, just call the below code:
jQuery('[data-js="collapsible-list"]').collapsibleList('destroy');And call again to bind the plugin:
jQuery('[data-js="collapsible-list"]').collapsibleList();And if call again the plugin, it not create a other button, the plugin will be use the same instance, this is great for performance.
I think this is a great contribution to your module, but it needs to be revised, so I'm going back to Needs Work.
Comment #20
fadonascimento commentedComment #21
fadonascimento commentedPlease consider this patch, thank you.
Comment #22
goska_m commentedHi @fadonascimento,
Thanks for the review and feedback, very useful!
I've applied your patch and updated the documentation.
Comment #23
Drupal8 commentedBoth local and pareview.sh pass without an issue.
Manual review
I didn't find something but in collapsible_list.js i would advise that you add some comments to help work with it in the future.
Comment #24
klausi@Drupal8: looks like you forgot to change the status. Anything else that you found or should this be set to RTBC?
Comment #25
Drupal8 commentedCode reviewed return no issue.
Comment #26
avpadernoThank you for your contribution!
I updated your account so you can opt into security advisory coverage now.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thank you, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks go the dedicated reviewer(s) as well.
Comment #27
avpaderno