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.
Related Issues
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | waypoints-use_libraries_api-2082639-25.patch | 14.59 KB | temkin |
Comments
Comment #1
pbuyle commentedThe attached patch:
waypoints_libraries_infowaypoints_librarydevel_use_uncompressed_jquery) fileshook_requirementsto ensure the library is installedComment #2
pbuyle commentedComment #3
pbuyle commentedThe patch in #1 does not set the path the the waypoint[.min].js file correctly.
Comment #4
cameron prince commentedI 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-corefrom 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."
Comment #5
cameron prince commentedComment #6
pbuyle commentedhook_requirements()when$phase == 'install'. Sorry about that.$('#myelement').waypoint('remove');I get the same exception, I guess the latest Waypoints (2.0.3) does not have a 'remove' method. Likely, the fix for #1939576: Update Waypoints JS library from 1.0.2 to 2.0.2 would produce the same result.Comment #7
pbuyle commentedHere 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.
Comment #8
AkliOnet commentedTo 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().
Comment #8.0
AkliOnet commentedAdd the update issue in the problem description.
Comment #9
das-peter commentedPatch looks good and almost works (Windows has trouble with
DIRECTORY_SEPARATOR) details below:Do not use t() or st() in installation phase hooks, use $t = get_t() to retrieve the appropriate localization function name.
DIRECTORY_SEPARATORwill 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.
Comment #10
discipolo commentedinstead of DIRECTORY_SEPARATOR just '/' should work fine or not?
Comment #11
discipolo commenteddoes this work now?
Comment #12
m4oliveiI 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
Comment #13
rooby commentedThis 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.
Comment #14
rooby commentedActually 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 path to place it in needs fixing.
Comment #15
rooby commented#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.
Comment #16
tripper54 commentedComment #17
tripper54 commentedComment #18
jordanmagnuson commentedWould like to see this committed. Waypoints 2.x is now at 2.0.5.
For a nice implementation of optional Libraries integration, see Timeago.
Comment #19
cjoy commentedPatch #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:
When I go ahead and manually create the directory "sites/all/libraries/jquery.waypoints", the error message changes:
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.
Comment #20
deanflory commentedAnything on this?
Comment #21
skaughtit 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.
Comment #22
skaughta 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.
Comment #23
jrabeemer commentedv2.0.5 seems to work as a drop-in replacement of waypoints.min.js Anything newer doesn't work.
Comment #24
temkin commentedAnother attempt at switching this to Libraries API.
Comment #25
temkin commentedHere is a better version with a couple of minor things fixed.
Comment #26
temkin commentedCould 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!
Comment #27
temkin commentedComment #28
levmyshkinHi 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.
Comment #30
levmyshkin