/[drupal]/contributions/modules/userreview/userreview.js
ViewVC logotype

Contents of /contributions/modules/userreview/userreview.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Mar 15 12:57:39 2007 UTC (2 years, 8 months ago) by gerdriesselmann
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.2: +47 -14 lines
File MIME type: text/javascript
Porting JS to jQuery, voting options table now created by JS
1 /* $Id: userreview.js,v 1.2 2006/05/03 09:31:59 dado Exp $ */
2
3 Drupal.Userreview = {};
4
5 Drupal.Userreview.build_table = function() {
6 // Hide select box
7 var html_table = '<table class="userreview_selector_table">';
8 html_table += '<tbody><tr>';
9 $('#edit-vote-value option').each(function() {
10 var cls = 'userreview_vote_option';
11 if (this.selected) {
12 cls += ' userreview_vote_selected';
13 }
14 html_table += '<td class="' + cls + '">';
15 html_table += '<span>' + $(this).text() + '</span>'
16 html_table += '<input type="hidden" name="userreview_option_value_' + this.value + '" value="' + this.value + '" />';
17 html_table += '</td>';
18 });
19 html_table += '</tr></tbody></table>';
20 $('#edit-vote-value').css({display:'none'}).parent().append(html_table);
21 }
22
23 Drupal.Userreview.init_highlight = function() {
24 $('.userreview_vote_option').hover(function() {
25 $(this).addClass("userreview_vote_option_hover");
26 },function(){
27 $(this).removeClass("userreview_vote_option_hover");
28 });
29 };
30
31 Drupal.Userreview.init_click = function() {
32 $('.userreview_vote_option').click(function() {
33 $('.userreview_vote_option').each(function() {
34 $(this).removeClass('userreview_vote_selected');
35 });
36 $(this).addClass('userreview_vote_selected');
37 var value = $(this).children('input[@type=hidden]').val();
38 $('#edit-vote-value option').each(function() {
39 this.selected = (this.value == value);
40 });
41 //alert($('#edit-vote-value').get(0).selectedIndex);
42 });
43 };
44
45 $(window).load(function() {
46 Drupal.Userreview.build_table();
47 Drupal.Userreview.init_highlight();
48 Drupal.Userreview.init_click();
49 });
50
51

  ViewVC Help
Powered by ViewVC 1.1.2