We observed that when ajax is enabled and the user votes, you see their votes.. but dont see the "reset your vote" link until the page is refreshed. It would be great if the reset your vote link showed up as soon as the user votes for the first time.

Files: 
CommentFileSizeAuthor
#28 0001-Issue-847846-by-mansspams-marvil07-jaydub-monotaga-P.patch12.12 KBmarvil07
#25 0001-Issue-847846-by-mansspams-marvil07-jaydub-monotaga-P.patch13.67 KBmarvil07
#23 reset-vote-widget-6.2-847846-23.patch10.08 KBjaydub
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch reset-vote-widget-6.2-847846-23.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#23 reset-vote-widget-6.3-847846-23.patch10.22 KBjaydub
PASSED: [[SimpleTest]]: [MySQL] 129 pass(es).
[ View ]
#15 reset-on-widget-v4.patch10.01 KBmarvil07
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch reset-on-widget-v4.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#12 vud.847846.patch7.07 KBjaydub
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch vud.847846.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#7 vote_up_down-847846-2.patch6.62 KBmansspams
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in vote_up_down-847846-2.patch.
[ View ]
#5 vote_up_down-847846.patch1.82 KBmonotaga
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

Comments

Title:Use Ajax to show "Reset your vote" link as soon as a user votes.Provide "Reset your vote" link on the widget.
Version:6.x-2.0-beta2» 6.x-3.x-dev

IMHO it would be more natural to do this in the widget.

...subscribing.

...subscribing -- thank you for the ups and downs.

sub

StatusFileSize
new1.82 KB
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

Hey, gang,

This is definitely not the right answer, as this calls for a patch to vud.theme.inc and because it doesn't use ajax for the vote reset call, but it seems to work well enough for a project I'm working on. Maybe it'll help in the move toward a better solution.

NOTES:
- #vud_reset() probably needs to be changed to give the ajax response instead of just redirecting the user via drupal_goto($_SERVER['HTTP_REFERER']);
- My application is only using a "vote up" button, and I want the button text to change from "Vote" to "Unvote" when the user has already voted. Therefore, I added the 'button_text_up' variable. I call it from my custom widget's widget.tpl.php using: <?php  if (empty($button_text_up)) $button_text_up = 'Vote'; ?> [...] <?php echo $button_text_up; ?>

Status:Active» Needs review

marking to avoid forgetting it

StatusFileSize
new6.62 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in vote_up_down-847846-2.patch.
[ View ]

I think I managed to create proper patch that adds reset options to theme with ajax. Now all is left is creating demo widget that uses variables like class_reset, link_class_reset and link_reset.

I took a liberty of moving function vud_reset to vud.theme.inc and add $widget argument, so it works same as function vud_vote.

added new class class_user_vote with possible values user_vote_up, user_vote_down and user_vote_empty. Makes theming easier. Will update patch.

Status:Needs review» Needs work

Thanks for the patches :-)

I did not try the patch at #7, but it looks good. I think it would be better to add this reset link to all the actual widgets.

@LavaMeTender aka mansspams: the mentioned classes at #8 do not seem to be a good idea (on this issue, to retain the subject)

subs

#7 works as advertised. Great job. Adding the missing class names and re-rolling the patch would be the cherry on top though.

Thx for a great addition to this module.

StatusFileSize
new7.07 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch vud.847846.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

The patch in #7 worked for me for the released version of 6.2 that I was using but no longer applies cleanly to latest CVS. I rerolled to address that and add one more line to set a reset variable that was missing in the original patch.

Patch applies cleanly to HEAD too although with offsets.

Status:Needs work» Reviewed & tested by the community

This patch #12 worked very well, and many-many thanks, this saved my life. :)

I've tested it the normal updown and the upanddown widget too, dsm(get_defined_vars()); in widget's tpl.php show the $link_reset variable.

I'used it in updown widget to make toogle +/- (if user have a + vote he can reset with link -, and vica versa).

Thanks again!

update: after this patch will be commited, my I have to contribute the widget, what I made? Exactly I ask, would you like to push a 5. widget in your module with this functions?

Status:Reviewed & tested by the community» Needs work

I am working on this, so will be uploading a new patch soon.

StatusFileSize
new10.01 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch reset-on-widget-v4.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

What is new on this patch:

  • Add a menu rebuild for modified votereset path.
  • minor: fix call to t() at vud_reset().
  • minor: better naming variable.
  • Fix current reset links.

This still needs work, as I mentioned in #9, we should use the new reset link on the current widgets.

Wondering what's the status on this issue? I'm using 6.x-2.6 and wondering if this patch ever made it into a recommended or dev release.

Im using 6.x-2.6 as well with Alternate widget.

When doing a dry run i get the following failed notices

patching file vud.install
Hunk #1 succeeded at 57 with fuzz 1 (offset 8 lines).
patching file vud.module
Hunk #1 succeeded at 82 with fuzz 1 (offset -1 lines).
Hunk #2 succeeded at 156 (offset -2 lines).
patching file vud.theme.inc
Hunk #1 succeeded at 131 (offset -5 lines).
Hunk #2 succeeded at 156 (offset -4 lines).
Hunk #3 succeeded at 233 (offset 15 lines).
Hunk #4 succeeded at 241 (offset 15 lines).
Hunk #5 succeeded at 432 (offset 15 lines).
patching file vud_comment.module
Hunk #1 FAILED at 183.
1 out of 1 hunk FAILED -- saving rejects to file vud_comment.module.rej
patching file vud_node.module
Hunk #1 FAILED at 294.
1 out of 1 hunk FAILED -- saving rejects to file vud_node.module.rej
patching file vud_term.module
Hunk #1 FAILED at 107.
Hunk #2 FAILED at 121.
2 out of 2 hunks FAILED -- saving rejects to file vud_term.module.rej

Hmm, patch applied correctly for me (although there were fuzz warnings) – I didn't get any failed errors, and manual inspection verified it applied correctly. I would try a separate download of a 6.x-2.6 and try the patch again.

I should also mention that the patch appears to be working great for me - I reworked my custom widget to use the reset with AJAX, and now I have a neat 'like/unlike' toggle - brilliant!

Ok the patch on #15 applied correctly now. Although i assumed it would just work for the default widgets. Like i said before im using Alternate widget, but from what im reading it seems that i will have to modify it so that i can use a 'like/unlike' toggle.

azarzag (nice handle):

It's easy to get started with a custom widget - I followed the instructions here to make a copy of the 'updown' widget in my theme, and then I could start modifying it. In case it's a help, here's my widget.tpl.php file that works with this patch to make an ajax like/unlike toggle. The class names (e.g. 'cclike-up', 'cclike-reset' are customized for my stylesheet).

<?php
/**
* @file
* widget.tpl.php
*
* cclike widget theme for Vote Up/Down
*/
?>

<div class="vud-widget vud-widget-cclike" id="<?php print $id; ?>">
  <div class="cclike-score">
    <span class="cclike-current-score"><?php print $unsigned_points; ?></span>
    <?php print $vote_label; ?>
  </div>
  <?php if ($show_links): ?>
    <?php if ($show_up_as_link): ?>
      <a href="<?php print $link_up; ?>" rel="nofollow" class="<?php print $link_class_up; ?>">
        <div class="<?php print $class_up; ?> cclike-up" title="<?php print t('Like this post'); ?>">Like</div>
        <div class="element-invisible"><?php print t('Like'); ?></div>
      </a>
    <?php else: ?>
      <a href="<?php print $link_reset; ?>" rel="nofollow" class="<?php print $link_class_reset; ?>">
        <div class="<?php print $class_reset; ?> cclike-reset" title="<?php print t('Unlike this post'); ?>">Unlike</div>
        <div class="element-invisible"><?php print t('Unlike'); ?></div>
      </a>
    <?php endif; ?>
  <?php endif; ?>
</div>

@laken Thanks for that. I actually ended up going through the code and figuring out what i had to add/change. My template file looks almost exactly the same as yours.

This patch is awesome
Cheers,

Status:Needs work» Needs review
StatusFileSize
new10.22 KB
PASSED: [[SimpleTest]]: [MySQL] 129 pass(es).
[ View ]
new10.08 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch reset-vote-widget-6.2-847846-23.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

I re-rolled the patches to the latest 6.2 and 6.3 branches. The only thing I'm unsure of is the change to vud.install. In the 6.2 branch I named the update function 6202 and in the 6.3 branch 6301.

Both patches should apply 100% clean to the 6.2 and 6.3 branches as of 11/14/2011.

Assigned:Unassigned» marvil07
Status:Needs review» Needs work

@jaydub: Thanks for the new patch.

The reason this patch is not yet on upstream is what I mentioned on comment 9 and 15: use the new reset link on the current widgets.

Let's see how far I can get now.

BTW this is a feature request, so it will only land on 6.x-3.x, since 6.x-2.x is feature frozen.

Assigned:marvil07» Unassigned
Status:Needs work» Fixed
StatusFileSize
new13.67 KB

OK, I finally moved this to upstream on 6.x-3.x

What's new on this patch:

  • Prepare some more variables about ajax reset for widgets.
  • Add ajax reset links to all widgets.

Version:6.x-3.x-dev» 7.x-1.x-dev
Status:Fixed» Patch (to be ported)

Uhm, now we need to port this to D7, but well, not today, time to get some sleep :-)

Sleep tight Marco. I don't know about the bed-bugs, but I'll help testing the 7.x port once available and I'll report back (Unfortunately I have no D6 installation available currently).

Status:Patch (to be ported)» Fixed
StatusFileSize
new12.12 KB

After reworking the patch here attached, I pushed it to 7.x-1.x.

From commit message:

This is a 7.x-1.x port of the original 6.x-3.x patch at #847846-25

Several changes was done in order to have D7 compatibility, but it's also
focused on vud and vud_field, trying to follow #1360572.

Status:Fixed» Closed (fixed)

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