I needed to add classes to the NQ links so I could style them differently - such as showing add/remove icons. To do this I modded the module and nodequeue.js (see attached patch).
The patch adds two classes - toggle-add & toggle-remove. These are added to function nodequeue_link, so that the appropriate class is added on page load.
The patch also mods the nodequeue.js click function by first removing both classes (my icons are on the left, so I needed to make room for the link to move over for the throbber), and then adds the correct class back in to show the new state.
I have included a screen shot of my links - on click the thumbs change to reflect the new state (all done with CSS).
I'm pretty new to Jquery and JavaScript so I'm not 100% this is the right approach etc, it works for us in our new site.
RE the patch: for some reason every time I generated a patch against 5.2 it kept including changes for nodequeue_init (look like formatting changes) not sure why but it appears to be the same code.
Comment | File | Size | Author |
---|---|---|---|
#8 | 318207-5.patch | 2.5 KB | ezra-g |
#8 | 318207-6.patch | 2.48 KB | ezra-g |
#7 | nodequeue-toggle-class-2.patch | 1.76 KB | eromba |
nq-toggle.png | 76.54 KB | Jeff Burnz | |
nodequeue-toggle-class.patch | 3.53 KB | Jeff Burnz | |
Comments
Comment #1
Jeff Burnz CreditAttribution: Jeff Burnz commentedBugger me, I forgot something - you need jQuery Update module for this to work. http://drupal.org/project/jquery_update
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThe idea looks good but the patch seems to add some extra linefeeds for no apparent reason?
Comment #3
Jeff Burnz CreditAttribution: Jeff Burnz commentedYeah, keep having issues with my patches like this, I'll re-roll once I get my patch issues sorted out.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedI'm against adding a dependency on jquery update. I'm sure we can do something that doesn't require that.
Comment #5
Jeff Burnz CreditAttribution: Jeff Burnz commentedFully agree, I just need to figure out why it doesn't work without it :)
Comment #6
ezra-g CreditAttribution: ezra-g commentedBumping to 6.x. This would be a great user interface enhancement.
Comment #7
eromba CreditAttribution: eromba commentedI have been waiting for this feature as well. I updated the original patch for the 5.x branch. It now works without the jQuery Update module and seems to be completely operational. I hope this makes the next 5.x release!
Comment #8
ezra-g CreditAttribution: ezra-g commentedI rerolled this for both the Drupal 5 and 6 Branches. Here's what I changed:
-- I moved the
$(a).removeClass('toggle-add');
so that the add/remove toggle classes are added and removed at the same time to avoid potentially unwanted behavior and for consistency.-- The toggle links now specify the qid and subqueue id as individual classes so that links for a queue as well as a specific subqueue can be targeted and styled by CSS. This allows us to, for example, have different styles for the "Add to My Favorite Posts" and "Add to Frontpage" links. These classes are in the format "nodequeue-toggle-q-123" and "nodequeue-toggle-sq-123"
-- These classes now apply to the LI's which wrap the $links from hook_link by default.
-- These classes don't also contain the word 'ajax' but I don't foresee them overlapping with other classes at this point, and that makes the classes smaller for readability and saves the transfer overhead four whole ASCII characters on every request ;).
I would love to get this tested and committed for the next RC :).
Comment #9
ezra-g CreditAttribution: ezra-g commentedOn further thought it might be nice to also expose the subqueue reference as a classs so that it would be easy for a themer to tell if a subqueue belongs to a particular user.
Comment #10
ezra-g CreditAttribution: ezra-g commentedI added a class for the subqueue reference to my previous patch and committed this to both the Drupal 5 and 6 branches. Thanks everyone -- This is excellent!!!
Comment #11
Jeff Burnz CreditAttribution: Jeff Burnz commentedWow, thanks ezra-g, I've just been so snowed past few months, glad you took the ball and ran with it and even made it better - cheers!
Comment #13
Francis47 CreditAttribution: Francis47 commentedSorry to reopen this issue after 3,5 years :)
Is there any plans for this patch to be ported to D7?