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

CommentFileSizeAuthor
#8 drupalcs-result.txt1.14 KBklausi

Comments

bartlantz’s picture

Issue summary: View changes

added a project review link

bartlantz’s picture

Issue summary: View changes

Added a second project review

bartlantz’s picture

Issue tags: +PAreview: review bonus

Add the review bonus tag.

bartlantz’s picture

Issue summary: View changes

Added a third manual project review

sanchi.girotra’s picture

Status: Needs review » Needs work

Bartlantz - 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.

if ($path = libraries_get_path("mousetrap")) {
  drupal_add_js($path . '/mousetrap.min.js');
}
else {
  drupal_add_js(drupal_get_path('module', 'article_jump') . '/mousetrap.min.js');
}

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'.

bartlantz’s picture

Status: Needs work » Needs review

Hi 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

eyal shalev’s picture

@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:

  • Article Jump does not considre user manual scroll:
    Say I'm using your module to scroll down some articles than I use the scrollers to go up the last article clicking n will bring me down twice and clicking p will 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:

  • Switching n&p to j&k:
    Though I understand that n stands for Next and that p stands for Previous, You should remember that usually only power users use keyboard shortcuts and they are used to using j & k.
  • Using self executing functions (JavaScript):
    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.
  • Alerting when the library is not installed:
    It can be useful for site developers if an error will show (in the module settings page) when the moustrap library is not installed.
  • Removing the install function:
    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).
  • Declare JavaScript in info file:
    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.
eyal shalev’s picture

Issue summary: View changes

added reference to demo site

bartlantz’s picture

Issue summary: View changes

updated hotkeys

bartlantz’s picture

Hi 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

eyal shalev’s picture

Bart,

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

bartlantz’s picture

Hi 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

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus
StatusFileSize
new1.14 KB

Review 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:

  1. article_jump_permission(): that permission is never used?

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.

klausi’s picture

Issue summary: View changes

hotkeys

bartlantz’s picture

Issue tags: +PAreview: review bonus

Thanks for the review Klausi. I fixed the code sniffer issues. Also I added the review bonus again, as I have reviewed some more projects.

klausi’s picture

What about the permission "administer article_jump" that is never used?

bartlantz’s picture

Hi 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

klausi’s picture

Status: Reviewed & tested by the community » Fixed

No 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.

eyal shalev’s picture

Congratulations

bartlantz’s picture

Awesome! Thanks for your help Klausi and Eyal!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added 3 Additional project reviews