1(function ($) { 2 Drupal.behaviors.rate = { 3 attach: function(context) { 4 $('.rate-widget:not(.rate-processed)', context).addClass('rate-processed').each(function () { 5 var widget = $(this); 6 // as we use drupal_html_id() to generate unique ids 7 // we have to truncate the '--<id>' 8 var ids = widget.attr('id').split('--'); 9 ids = ids[0].match(/^rate\-([a-z]+)\-([0-9]+)\-([0-9]+)\-([0-9])$/); 10 var data = { 11 content_type: ids[1], 12 content_id: ids[2], 13 widget_id: ids[3], 14 widget_mode: ids[4] 15 }; 16 17 $('a.rate-button', widget).click(function() { 18 var token = this.getAttribute('href').match(/rate\=([a-zA-Z0-9\-_]{32,64})/)[1]; 19 return Drupal.rateVote(widget, data, token); 20 }); 21 }); 22 } 23 }; 24 25 Drupal.rateVote = function(widget, data, token) { 26 // Invoke JavaScript hook. 27 widget.trigger('eventBeforeRate', [data]); 28 29 $(".rate-info", widget).text(Drupal.t('Saving vote...')); 30 31 // Random number to prevent caching, see http://drupal.org/node/1042216#comment-4046618 32 var random = Math.floor(Math.random() * 99999); 33 34 var q = (Drupal.settings.rate.basePath.match(/\?/) ? '&' : '?') + 'widget_id=' + data.widget_id + '&content_type=' + data.content_type + '&content_id=' + data.content_id + '&widget_mode=' + data.widget_mode + '&token=' + token + '&destination=' + encodeURIComponent(Drupal.settings.rate.destination) + '&r=' + random; 35 if (data.value) { 36 q = q + '&value=' + data.value; 37 } 38 39 // fetch all widgets with this id as class 40 widget = $('.' + widget.attr('id')); 41 42 $.get(Drupal.settings.rate.basePath + q, function(response) { 43 if (response.match(/^https?\:\/\/[^\/]+\/(.*)$/)) { 44 // We got a redirect. 45 document.location = response; 46 } 47 else { 48 // get parent object 49 var p = widget.parent(); 50 51 // Invoke JavaScript hook. 52 widget.trigger('eventAfterRate', [data]); 53 54 widget.before(response); 55 56 // remove widget 57 widget.remove(); 58 widget = undefined; 59 60 Drupal.attachBehaviors(p); 61 } 62 }); 63 64 return false; 65 } 66})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.