The "extend" option does not work because the Drupal.settings API passes whatever you type in the box as a string, rather than a raw Javascript Function.
The Galleria documentation on the options array states that the "extend" option expects a function. However, for some reason, Drupal's drupal_add_js(..., 'setting') is making it into a string.
You can see a demonstration of a working "extend" option by viewing the source of Galleria's Classic Demo #2.
Assigning to myself so that I can write some steps to reproduce.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | views-slideshow-galleria-936480-12.patch | 1.07 KB | sgabe |
| #7 | views_slideshow_galleria-936480.patch | 8.97 KB | mparker17 |
| #2 | views_slideshow_galleria-936480.patch | 1.1 KB | mparker17 |
Comments
Comment #1
mparker17Confirmed that this happens on 6.x-1.x-dev.
Turns out that all options passed through Drupal.settings are being output as JavaScript strings; so I'm changing the title of this.
Comment #2
mparker17After a bit of experimentation, it seems that, by casting the output of
views_slideshow_galleria_variable_get(), I can get it to work. See attached patch file for one example.Comment #3
mparker17I've been testing a bit here; and I'm starting to see that there are multiple issues which prevent me from having Galleria execute my "extend" JavaScript. Expect a bunch more bugs to be filed later.
However, let's make steps to reproduce:
Platform
Client
Server
Modules enabled:
Steps to Reproduce
sites/default/modules.sites/all/libraries. When I unzipped mine, it was automatically namedaino-galleria-cf9ab01.Administer->Site building->Modules, check off the boxes next toContent,FileField,ImageField,jQuery Update,Views,Views Slideshow,Views Slideshow: GalleriaandViews UI, then clickSave configuration.Administer->Site building->Views->Views Slideshow: Galleria, ensure that thePath to the Galleria Pluginis set to thesrcsub-folder of the Galleria folder you extracted earlier. In my case, Views Slideshow: Galleria automatically detected Galleria atsites/all/libraries/aino-galleria-cf9ab01/src.Administer->Content management->Content types, add a content type.Add content type. Set the name toAlbum, the type toalbum, and clickSave content type.manage fieldsin theOperationscolumn next to the newalbumtype.Images, the Field namefield_album_images, the field typeFileand the form elementImage. ClickSave. Drupal will prompt you for more information about the image field. UnderGlobal settings, check offRequired, but leave everything else at the default. Make sure toSave field settings.Create content->Album, add two or three album-type nodes. I always click theUploadbutton before saving the page.Administer->Site building->Views, clickAddand create the view:album_galleryand make it a view on typeNode. Leave the other options at their defaults.Node: Type; set it toIs one ofand check offAlbum.Content: images (field_album_images). FromFormat, chooseImage; leave the other options at their defaults.Style, chooseSlideshow. LeaveList typeasUnordered list. EnsureSlideshow modeis set toGalleria.Pagedisplay. Set it's path togallery.Galleria options, expandAdvanced settings, and enter the following into theExtendbox:function() { this.bind(Galleria.IMAGE, function(e) { $(e.imageTarget).css('cursor','pointer').click(this.proxy(function() { this.openLightbox(); })); }); }(this extend code was copied from the source of the Galleria homepage's Classic Demo 02).http://yoursite.example.com/gallery, click on the image that appears and observe the behavior.Expected Behaviour
I should be able to click on an image to have it pop up in one of Galleria's lightboxes.
Actual Behaviour
I'm not able to click on an image to have it pop up in one of Galleria's lightboxes.
Comment #4
mparker17Wow, I really wandered off-topic from my original problem here... resetting the title.
Comment #5
izmeez commentedDo the steps in #3 work with the patch in #2 ?
Comment #6
mparker17Sorry, no. The patch in #2 is just an example. I'm still working on this one... I had a patch ready, but when I was doing my QA, it didn't work, so I've got to look over it and see what I've done wrong. I should assign it to myself, as I am more than half way there.
Check out #945084-6: Settings passed as wrong type. That patch doesn't fix the problem where JavaScript functions are being passed as strings; but it does solve problems with other variables.
Comment #7
mparker17I've got a patch that works for Galleria at commit cf9ab014d15c41ce89faccb258da6612e677fccf. It disables some options that break when settings.extend is defined (there are comments).
Because the JavaScript functions need to be passed un-escaped to the page, I've added a permission. A user must have that permission in order to edit the fields that must be output raw.
The Galleria library has changed a lot since I created this ticket. I'll try to adjust the patch to work with the latest version of Galleria.
Comment #8
mparker17Whoops... forgot to mark this as "needs review"
Comment #9
sgabe commentedI just encountered this bug. I would like to set the advanced "data_config" option to add rich HTML captions as described here. I tried the patch in #7, but that broke the whole gallery. So far I couldn't make it work, any help would be appreciated.
Comment #10
mparker17Unfortunately, the Galleria JavaScript library is still quite unstable. The folks at Aino promised us a stable release in November 2010, but (at the time of writing, 2011-Feb-07) they haven't done so yet. The Galleria library's API has changed significantly since I started this issue on 2010-Oct-08, and Galleria's documentation isn't always accurate (as I found out when trying to fix this problem).
When I wrote the patch in #7, I was using the version of Galleria at commit cf9ab014d15c41ce89faccb258da6612e677fccf and the version of Views Slideshow: Galleria at the HEAD of the 6.x-1.x branch (last commit 2010-Nov-12 — at the time of writing, this is the most recent commit on the 6.x-1.x branch). Ensure that you have those versions installed before applying my patch.
It would seem that @aaron hasn't been able to keep up with all the API changes in the Galleria library (and honestly, due to circumstances beyond my control, I haven't touched Galleria since November either). If you really need to use the latest version of Galleria, you could help the community by writing and submitting a patch to this module so that it would work with the latest changes to the Galleria library (submit your patch in a separate issue though: it's a more–general—issue than this one). Once that's done (and, assuming that your patch doesn't fix this issue), let me know and I can try re-rolling this patch.
Comment #11
sgabe commentedThis is still an issue for the 3.x branch. The "modify raw Galleria JavaScript" permission is a good call, but IMO it should be handled in a separate issue.
Comment #12
sgabe commentedThe attached patch is committed to the 3.x branches.