| 1 |
// $Id: smackdown.js,v 1.1.2.2.2.9 2009/08/24 21:17:34 sirkitree Exp $ |
// $Id: smackdown.js,v 1.1.2.2.2.10 2009/08/24 22:41:28 sirkitree Exp $ |
| 2 |
|
|
| 3 |
/** |
/** |
| 4 |
* Smackdown voting through AJAX |
* Smackdown voting through AJAX |
| 44 |
*/ |
*/ |
| 45 |
Drupal.smackdown.attachVote = function(context, selector) { |
Drupal.smackdown.attachVote = function(context, selector) { |
| 46 |
$(selector, context).each(function() { |
$(selector, context).each(function() { |
| 47 |
var $element = $(this), smackdownLocation = Drupal.settings.basePath + Drupal.theme('smackdownLocation'); |
var $element = $(this); |
| 48 |
// Attach the on-click popup behavior to the element. |
// Attach the on-click popup behavior to the element. |
| 49 |
$element.click(function(e){ |
$element.click(function(e){ |
| 50 |
Drupal.theme('voting', $element); |
Drupal.theme('voting', $element); |
| 53 |
var params = {'cid':nid, 'sid':sid}; |
var params = {'cid':nid, 'sid':sid}; |
| 54 |
// post nid and context to smackdown/vote |
// post nid and context to smackdown/vote |
| 55 |
ajaxOptions = { |
ajaxOptions = { |
| 56 |
url: Drupal.settings.basePath + 'smackdown/vote', |
url: Drupal.settings.basePath + 'smackdown/vote/' + Drupal.settings.smackdown.token, |
| 57 |
dataType: 'json', |
dataType: 'json', |
| 58 |
data: params, |
data: params, |
| 59 |
success: function(json) { |
success: function(json) { |
| 60 |
// we put the location into a variable so that it can be changed by other modules |
// we put the location into a variable so that it can be changed by other modules |
| 61 |
location.href = smackdownLocation; |
location.href = json.location |
| 62 |
} |
} |
| 63 |
}; |
}; |
| 64 |
$.ajax(ajaxOptions); |
$.ajax(ajaxOptions); |
| 88 |
element.parent().css({'background-color':'#ffc'}); |
element.parent().css({'background-color':'#ffc'}); |
| 89 |
return element.parent().append(output); |
return element.parent().append(output); |
| 90 |
}; |
}; |
|
|
|
|
Drupal.theme.prototype.smackdownLocation = function() { |
|
|
return Drupal.settings.smackdown.location; |
|
|
}; |
|
|
|
|
| 91 |
})(jQuery); |
})(jQuery); |