Problem/Motivation

The module currently include the jQuery Waypoints' .js file(s).

  • Updating jQuery Waypoints' .js files require overriding project provided files, with no guarantee future update will still be compatible.
  • jQuery Waypoints itself is licensed under the MIT License, hosting on Drupal.org GIT requires the code to be licensed under the GNU General Public License, version 2 or later (cf. https://drupal.org/licensing/faq#q1). Including the jQuery Waypoints files in the module is a violation of this requirements.

Proposed resolution

The recommended way to use external dependencies is the Libraries API. The module should use it.

API changes

It should be possible to keep the current API to include the libraries on the pages.

Comments

pbuyle’s picture

The attached patch:

  • Defines the jquery.waypoints library in waypoints_libraries_info
  • Re-uses that library in waypoints_library
  • Supports uncompressed (using the devel_use_uncompressed_jquery) files
  • Implements hook_requirements to ensure the library is installed
  • Provides a .make file to automagically download the library when Drush Make is used
  • Fixes the documentation of modified/added functions to follow https://drupal.org/coding-standards/docs
pbuyle’s picture

Status: Active » Needs review
pbuyle’s picture

The patch in #1 does not set the path the the waypoint[.min].js file correctly.

cameron prince’s picture

StatusFileSize
new61.99 KB

I tested the patch in #3 and it fails to detect the jquery.waypoints library. I tried both installing manually and using drush make sites/all/modules/waypoints/waypoints.make --no-core from the Drupal root. I believe this may be because the library is declared in the waypoints.module file, which hasn't been loaded at the time the hook_requirements() is called by the waypoints.install file. If I comment out hook_requirements() the module installs fine.

Additionally, the error message that is displayed is a bit of a mess. The text is duplicated, the download link doesn't work and the installation path is missing. See screenshot.

Even after resolving the install problem, the module doesn't work with views_load_more as it causes an "Error: uncaught exception: The remove method does not exist in jQuery Waypoints."

cameron prince’s picture

Status: Needs review » Needs work
pbuyle’s picture

pbuyle’s picture

Assigned: pbuyle » Unassigned
StatusFileSize
new15.85 KB

Here is an untested patch to avoid checking for the library on install (or update). I don't have a use for the module right now, so I cannot commit to work on this issue any longer. Sorry about that.

AkliOnet’s picture

To make work View load more with waypoints you must replace the remove method by the destroy methode. Remove() seem to have been replaced by the the destroy().

AkliOnet’s picture

Issue summary: View changes

Add the update issue in the problem description.

das-peter’s picture

Patch looks good and almost works (Windows has trouble with DIRECTORY_SEPARATOR) details below:

  1. +++ b/waypoints.install
    @@ -0,0 +1,40 @@
    +        'description' => t('The jQuery Waypoints plugin is required, please  <a href="@download">download it</a> and place it in @library_path.',
    ...
    +        'description' => t('The jQuery Waypoints plugin has been found in @library_path', array(
    +          '@library_path' => $library['library path'],
    +        )),
    

    Do not use t() or st() in installation phase hooks, use $t = get_t() to retrieve the appropriate localization function name.

  2. +++ b/waypoints.module
    @@ -58,22 +58,71 @@ function waypoints_init() {
    +        if (is_string($options)) {
    +          $options = $library['library path'] . DIRECTORY_SEPARATOR . $options;
    +        }
    +        else {
    +          $data = $library['library path'] . DIRECTORY_SEPARATOR . $data;
    

    DIRECTORY_SEPARATOR will return a backslash on windows and break the url.

There are various locations where the format of the doc for the hook implementation is wrong (Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().", or "* Implements hook_foo_BAR_ID_bar() for xyz_bar.tpl.php.".) but I think that can be handled later as it's not related to the patch.

As soon as the backslash thing is fixed I'd say this is RTBC.

discipolo’s picture

Issue summary: View changes
StatusFileSize
new16.38 KB

instead of DIRECTORY_SEPARATOR just '/' should work fine or not?

discipolo’s picture

Status: Needs work » Needs review

does this work now?

m4olivei’s picture

I can confirm that it works (I'm not on Windows though), great job on the patch. Can we get this committed? Waypoints is popular, I've seen it used in my projects custom theme and also in:

https://www.drupal.org/project/views_load_more
https://www.drupal.org/project/sticky_edit_actions

Would be good to have this module centralize waypoints inclusion in a Drupal project to encourage other module authors to use this so we can have one way to include waypoints instead of all module and theme authors that need it try to include it in their own way.

Thanks!
Matt

rooby’s picture

This is a great patch and is a big improvement for this module.

The patch in #10 does contain a few things that it shouldn't though.

The change to the module name, the "Implements" function comments, and the change to the waypoints_settings_form() params are technically unrelated to this issue, although it's up to the module maintainer whether or not they care about that.

rooby’s picture

Status: Needs review » Needs work

Actually I found one other thing that doesn't work properly:

On the setting page if you haven't installed the plugin you get this message:

The jQuery Waypoints plugin is required, please download it and place it in .

The path to place it in needs fixing.

rooby’s picture

#2289113: Warning: strcmp() expects parameter 1 to be string, array given in _system_sort_requirements is also a result of the patch in here I believe, although my system doesn't seem to be throwing that same error.

tripper54’s picture

jordanmagnuson’s picture

Would like to see this committed. Waypoints 2.x is now at 2.0.5.

For a nice implementation of optional Libraries integration, see Timeago.

cjoy’s picture

Patch #10 did not work for me.

after applying the patch, the configuration page at "admin/config/user-interface/waypoints" displays an error message. This is expected as the library was not yet added. However, the error message is err'd:

Not installed
The jQuery Waypoints plugin is required, please download it and place it in .

When I go ahead and manually create the directory "sites/all/libraries/jquery.waypoints", the error message changes:

Not installed
The jQuery Waypoints plugin is required, please download it and place it in sites/all/libraries/jquery.waypoints.

Now to download and add the js files:
The download link provided (https://codeload.github.com/imakewebthings/jquery-waypoints/legacy.zip/l...) is a 404.
Manually retrieving waypoints.js and waypoints.min.js from https://github.com/imakewebthings/waypoints/tree/v2.0.5 and adding them to the above libraries folder, does not resolve the error.

deanflory’s picture

Anything on this?

skaught’s picture

it seems that the waypoint github repo is now a different repo from patch#10. as well, it's been restructured with a 'jquery-less' which would be better not to have to work round jQuery update issues.
-- v3.0.0 repo tagged dec19/2014 . is now current at v4

i think this whole patch needs to be redone now because of this.

also.. this module seems abandoned by maintainer.

skaught’s picture

a follow up note:

i've spent some time playing with this and have found the https://github.com/imakewebthings/waypoints/tree/v1.1.7 version is compatible with jQuery 1.4.x

however, general performance/memory use of the waypoint plugin is terrible.. personally i'm moving to jquery.inview as a solution over the waypoints. I don't know if this performance is better in newer version -- i hope it is, but there too many other concerns for my own need.

good luck.

jrabeemer’s picture

v2.0.5 seems to work as a drop-in replacement of waypoints.min.js Anything newer doesn't work.

temkin’s picture

Status: Needs work » Needs review
StatusFileSize
new14.7 KB

Another attempt at switching this to Libraries API.

temkin’s picture

Here is a better version with a couple of minor things fixed.

temkin’s picture

Could someone please review and RTBC the latest patch? Maintainer @nehajyoti is planning to look into that soon and it will be helpful if the patch is already reviewed, so that she can just merge it. Thanks!

temkin’s picture

levmyshkin’s picture

Hi there, it's pretty old thread for Drupal 7. But if you want I can create 7.x-2.x branch and apply this path there. I don't wan't to apply it for 7.x-1.x branch because many devs will be needed to download waypoint.min.js file with drush or manually. So it's big change for major version update. Then developers will be aware that it's a new version of module and it's more likely they will read update instruction for 7.x-2.0 release.

  • levmyshkin committed 01940f4 on 2.0.x
    Issue #2082639 by pbuyle, discipolo, temkin: Use the Libraries API to...
levmyshkin’s picture

Status: Needs review » Closed (won't fix)