Article Jump is a Drupal module to add jQuery functionality to a page to scroll from one article to the next via a hotkey. For instance you can scroll down through a stream of node teasers by pressing "j" several times. Then scroll back to the previous article by pressing "k".
Demonstration
You can see a demo of how the module works by visiting this Demo Site and pressing "j" and "k" to scroll through the stream of articles.
I ran the code through pareview and fixed all issues: http://ventral.org/pareview/httpgitdrupalorgsandboxbartlantz1685434git
Project: http://drupal.org/sandbox/bartlantz/1685434
Git: git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/bartlantz/1685434.git article_jump
Reviews of Other Projects
http://drupal.org/node/1682682#comment-6239912
http://drupal.org/node/1668528#comment-6240408
http://drupal.org/node/1676528#comment-6241814
Additional Reviews of Other Projects
http://drupal.org/node/1700754#comment-6278426
http://drupal.org/node/1624464#comment-6274562
http://drupal.org/node/1702606#comment-6295762
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | drupalcs-result.txt | 1.14 KB | klausi |
Comments
Comment #0.0
bartlantz commentedadded a project review link
Comment #0.1
bartlantz commentedAdded a second project review
Comment #1
bartlantz commentedAdd the review bonus tag.
Comment #1.0
bartlantz commentedAdded a third manual project review
Comment #2
sanchi.girotra commentedBartlantz - It's very handy module and code is almost perfect.
.module file
There is one issue in hook_init(). You haven't added mousetrap.min.js in your module file but in the else condition, you are referring to it.
So either you may like to remove this else condition or you may want to add mousetrap.min.js in your module folder.
READEME.txt file
In Installation, point 3, you have mentioned incorrect folder name 'library'. It should be 'libraries'.
Comment #3
bartlantz commentedHi sanchi.girotra,
Thanks for the review!
The errors you found have been fixed.
1. I've removed the else statement.
2. The typo in the README.txt file is fixed.
Thanks,
Bart
Comment #4
eyal shalev@bartlantz,
Very nice module, it is simple, direct & most of all just works!
Here are some issues / suggestions I've found digging into your code.
Architectual Design Issues:
Say I'm using your module to scroll down some articles than I use the scrollers to go up the last article clicking
nwill bring me down twice and clickingpwill leave me where I am.This can be fixed by checking the scroll position when the user clicks
n&p.Alternatively you could offer a choice for the admin to select.
Suggestions:
n&ptoj&k:Though I understand that
nstands for Next and thatpstands for Previous, You should remember that usually only power users use keyboard shortcuts and they are used to usingj&k.While it isn't in the JavaScript coding standards it is good practice to wrap your javascript code inside a self executing function.
Using the above will replace your need of using the jQuery keyword instead of the common $ sign.
You can learn more about self executing functions in here.
It can be useful for site developers if an error will show (in the module settings page) when the moustrap library is not installed.
I do see why the uninstall function is usefull there is no need to add the install function. These values are defined in the second argument of variable_get (the default value argument).
In Drupal 6 & 7 we can declare javascript file stright from the info file using the scripts[] array. You can read more about it here.
Comment #4.0
eyal shalevadded reference to demo site
Comment #4.1
bartlantz commentedupdated hotkeys
Comment #5
bartlantz commentedHi Eyal,
Thanks for the in-depth review!
1. I agree, that is a bit confusing, so I changed the behavior, to take in to account whether the user has manually scrolled when calculating the previous and next articles.
2. I made the hot keys configurable. Also, I changed the defaults to "j" and "k" out of respect for the vim and nethack users out there. (I use emacs mostly, but C-n and C-p are impossible to use in browsers as they are mapped to new browser and print page.)
3. I wrapped the js in (function ($) { ... }(jQuery))
4. I added a hook_requirements() to article_jump.install. This will not allow the admin to enable the module until they have installed the mousetrap library.
5. I agree, I removed the unnecessary article_jump_install() hook
6. I don't think I can change where I load the article_jump.js, as I need to include mousetrap.min.js in hook_init() and I need to make sure I include article_jump.js after mousetrap.
Thanks,
Bart
Comment #6
eyal shalevBart,
I'm flattered you accepted my suggestions.
P.S.
About loading the article_jump.js using the info file, because you are using the behaviors attach function I don't think you'll have a problem to use mouse trap. When I tested it it worked fine. Even if the mouse trap file is loaded after your own javascript file the attach function happens much later.
Regards,
Eyal
Comment #7
bartlantz commentedHi Eyal,
They were all good, logical suggestions! The first suggestion was kind of tricky to get both FF and Chrome to work consistently but I think the change makes the functionality more intuitive.
I changed the loading of the article_jump.js to the .info file. You were correct, with Drupal behaviors it doesn't matter if I load it there. I guess loading this way should allow the file to be cached better.
~Bart
Comment #8
klausiReview of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
But that are just minor issues, otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #8.0
klausihotkeys
Comment #9
bartlantz commentedThanks for the review Klausi. I fixed the code sniffer issues. Also I added the review bonus again, as I have reviewed some more projects.
Comment #10
klausiWhat about the permission "administer article_jump" that is never used?
Comment #11
bartlantz commentedHi Klausi,
You are correct, I though I was using that. I believe checking the permission for "administer site configuration" is sufficient. I have removed the function article_jump_permissions().
Thanks,
Bart
Comment #12
klausiNo objections in more than a week, so ...
Thanks for your contribution, bartlantz!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
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 get involved!
Thanks, 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 to the dedicated reviewer(s) as well.
Comment #13
eyal shalevCongratulations
Comment #14
bartlantz commentedAwesome! Thanks for your help Klausi and Eyal!
Comment #15.0
(not verified) commentedAdded 3 Additional project reviews