Mercurial > public > sg101
comparison media/js/downloads/rating.js @ 255:2ba1a6d3b984
Close #104; downloads javascript has incorrect hard-coded path to star graphics. Also correct count fields in downloads category fixture.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 21 Sep 2010 00:52:55 +0000 |
parents | b43e1288ff80 |
children |
comparison
equal
deleted
inserted
replaced
254:e43b1be24ccc | 255:2ba1a6d3b984 |
---|---|
3 var div = $(this).parent('div'); | 3 var div = $(this).parent('div'); |
4 var stars = $('img', div); | 4 var stars = $('img', div); |
5 for (var i = 0; i <= event.data; ++i) | 5 for (var i = 0; i <= event.data; ++i) |
6 { | 6 { |
7 var star = $(stars[i]); | 7 var star = $(stars[i]); |
8 star.attr('src', '/static/downloads/stars/rating_over.gif'); | 8 star.attr('src', '/media/downloads/stars/rating_over.gif'); |
9 } | 9 } |
10 } | 10 } |
11 | 11 |
12 function dlRatingOut(event) | 12 function dlRatingOut(event) |
13 { | 13 { |
14 var div = $(this).parent('div'); | 14 var div = $(this).parent('div'); |
15 var stars = $('img', div); | 15 var stars = $('img', div); |
16 for (var i = 0; i <= event.data; ++i) | 16 for (var i = 0; i <= event.data; ++i) |
17 { | 17 { |
18 var star = $(stars[i]); | 18 var star = $(stars[i]); |
19 star.attr('src', '/static/downloads/stars/rating_' + star.attr('class') + '.gif'); | 19 star.attr('src', '/media/downloads/stars/rating_' + star.attr('class') + '.gif'); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 function dlRatingClick(event) | 23 function dlRatingClick(event) |
24 { | 24 { |
46 { | 46 { |
47 var s = $(stars[i]); | 47 var s = $(stars[i]); |
48 s.removeClass(s.attr('class')); | 48 s.removeClass(s.attr('class')); |
49 if (rating >= 1.0) | 49 if (rating >= 1.0) |
50 { | 50 { |
51 s.attr('src', '/static/downloads/stars/rating_on.gif'); | 51 s.attr('src', '/media/downloads/stars/rating_on.gif'); |
52 s.addClass('on') | 52 s.addClass('on') |
53 rating -= 1.0; | 53 rating -= 1.0; |
54 } | 54 } |
55 else if (rating >= 0.5) | 55 else if (rating >= 0.5) |
56 { | 56 { |
57 s.attr('src', '/static/downloads/stars/rating_half.gif'); | 57 s.attr('src', '/media/downloads/stars/rating_half.gif'); |
58 s.addClass('half') | 58 s.addClass('half') |
59 rating = 0; | 59 rating = 0; |
60 } | 60 } |
61 else | 61 else |
62 { | 62 { |
63 s.attr('src', '/static/downloads/stars/rating_off.gif'); | 63 s.attr('src', '/media/downloads/stars/rating_off.gif'); |
64 s.addClass('off') | 64 s.addClass('off') |
65 } | 65 } |
66 } | 66 } |
67 }, | 67 }, |
68 error: function (xhr, textStatus, ex) { | 68 error: function (xhr, textStatus, ex) { |
87 for (var i = 0; i < 5; ++i) | 87 for (var i = 0; i < 5; ++i) |
88 { | 88 { |
89 var star = $('<img />'); | 89 var star = $('<img />'); |
90 if (rating >= 1) | 90 if (rating >= 1) |
91 { | 91 { |
92 star.attr('src', '/static/downloads/stars/rating_on.gif'); | 92 star.attr('src', '/media/downloads/stars/rating_on.gif'); |
93 star.addClass('on') | 93 star.addClass('on') |
94 --rating; | 94 --rating; |
95 } | 95 } |
96 else if (rating >= 0.5) | 96 else if (rating >= 0.5) |
97 { | 97 { |
98 star.attr('src', '/static/downloads/stars/rating_half.gif'); | 98 star.attr('src', '/media/downloads/stars/rating_half.gif'); |
99 star.addClass('half') | 99 star.addClass('half') |
100 rating = 0; | 100 rating = 0; |
101 } | 101 } |
102 else | 102 else |
103 { | 103 { |
104 star.attr('src', '/static/downloads/stars/rating_off.gif'); | 104 star.attr('src', '/media/downloads/stars/rating_off.gif'); |
105 star.addClass('off') | 105 star.addClass('off') |
106 } | 106 } |
107 star.attr('alt', 'star'); | 107 star.attr('alt', 'star'); |
108 star.attr('id', 'star-' + numeric_id + '-' + i); | 108 star.attr('id', 'star-' + numeric_id + '-' + i); |
109 star.bind('mouseover', i, dlRatingOver); | 109 star.bind('mouseover', i, dlRatingOver); |