| 8 | | function rcUpdate(entry_id, rating, hover) |
|---|
| 9 | | { |
|---|
| 10 | | var i, image, image_file; |
|---|
| 11 | | for( i = 0; i <= 5; i++ ) |
|---|
| 12 | | { |
|---|
| 13 | | image = document.getElementById(entry_id + '-rc-' + i); |
|---|
| 14 | | if( !image ) |
|---|
| 15 | | return false; |
|---|
| 16 | | if( i > 0 ) |
|---|
| 17 | | if( i <= rating ) |
|---|
| 18 | | image_file = 'star'; |
|---|
| 19 | | else |
|---|
| 20 | | image_file = 'bullet'; |
|---|
| 21 | | else |
|---|
| 22 | | image_file = 'no_rating'; |
|---|
| 23 | | if( hover ) |
|---|
| 24 | | if( ( image_file == 'star' ) || ( ( image_file == 'no_rating' ) && ( rating == 0 ) ) ) |
|---|
| 25 | | image_file = image_file + '-hover'; |
|---|
| 26 | | if( image_file != '' ) |
|---|
| 27 | | image.src = '<MTStaticWebPath>plugins/FiveStarRating/' + image_file + '.gif'; |
|---|
| 28 | | } |
|---|
| 29 | | return true; |
|---|
| 30 | | } |
|---|
| 31 | | function rcOut(entry_id) { |
|---|
| 32 | | var obj = document.getElementById(entry_id + '-rating'); |
|---|
| 33 | | if( !obj ) |
|---|
| 34 | | return false; |
|---|
| 35 | | var rating = obj.innerHTML; |
|---|
| 36 | | return rcUpdate(entry_id, rating, false); |
|---|
| | 9 | |
|---|
| | 10 | // FiveStarScore Specific Functions |
|---|
| | 11 | function fiveStarScoreUpdate(obj_id, score, hover) { mtScoreUpdate('fivestar', obj_id, score, 5, hover, 'star', 'bullet', 'no_rating', 'FiveStarRating') } |
|---|
| | 12 | function fiveStarScoreOut(obj_id) { mtScoreOut('fivestar', obj_id, fiveStarScoreUpdate) } |
|---|
| | 13 | function fiveStarScore(obj_id, score) { mtScore('fivestar', obj_id, score, 'fivestar-pending', 'fivestar-complete') } |
|---|
| | 14 | function fiveStarScoreResponse(obj_id, score) { |
|---|
| | 15 | mtScoreResponse('fivestar', obj_id, score, 'fivestar-pending', 'fivestar-complete'); |
|---|
| | 16 | fiveStarScoreUpdate(obj_id, score, false); |
|---|
| 38 | | function rcClick(entry_id, rating) { |
|---|
| | 18 | |
|---|
| | 19 | // Generic mtScoring Functions |
|---|
| | 20 | function mtScore(ns, obj_id, score, pending, complete) { |
|---|
| | 21 | var el = document.getElementById(ns + obj_id); |
|---|
| | 22 | if( !el ) return false; |
|---|
| | 23 | if (DOM.hasClassName(el, pending)) return false; |
|---|
| | 24 | if (DOM.hasClassName(el, complete)) return false; |
|---|
| 54 | | function fivestar_response(entry_id, stars) { |
|---|
| 55 | | var obj = document.getElementById(entry_id + '-rating'); |
|---|
| 56 | | if( !obj ) |
|---|
| 57 | | return false; |
|---|
| 58 | | obj.innerHTML = stars; |
|---|
| 59 | | return rcUpdate(entry_id, stars, false); |
|---|
| | 41 | function mtScoreResponse(ns, obj_id, score, pending, complete) { |
|---|
| | 42 | var el = document.getElementById(ns + obj_id); |
|---|
| | 43 | if (!el) |
|---|
| | 44 | return false; |
|---|
| | 45 | el.innerHTML = score; |
|---|
| | 46 | DOM.removeClassName( el, pending ); |
|---|
| | 47 | DOM.addClassName( el, complete ); |
|---|
| | 49 | function mtScoreOut(ns, obj_id, callbackf) { |
|---|
| | 50 | var obj = document.getElementById(ns + obj_id); |
|---|
| | 51 | if( !obj ) |
|---|
| | 52 | return false; |
|---|
| | 53 | var score = obj.innerHTML; |
|---|
| | 54 | callbackf.call(this, obj_id, score, false); |
|---|
| | 55 | } |
|---|
| | 56 | function mtScoreUpdate(ns, obj_id, score, size, hover, on_img, off_img, zero_img, plugin_name) |
|---|
| | 57 | { |
|---|
| | 58 | var i, image, image_file; |
|---|
| | 59 | for( i = 0; i <= size; i++ ) |
|---|
| | 60 | { |
|---|
| | 61 | image = document.getElementById(ns + obj_id + '-' + i); |
|---|
| | 62 | if( !image ) |
|---|
| | 63 | return false; |
|---|
| | 64 | if( i > 0 ) |
|---|
| | 65 | if( i <= score ) |
|---|
| | 66 | image_file = on_img; |
|---|
| | 67 | else |
|---|
| | 68 | image_file = off_img; |
|---|
| | 69 | else |
|---|
| | 70 | image_file = zero_img; |
|---|
| | 71 | if( hover ) |
|---|
| | 72 | if( ( image_file == on_img ) || ( ( image_file == zero_img ) && ( score == 0 ) ) ) |
|---|
| | 73 | image_file = image_file + '-hover'; |
|---|
| | 74 | if( image_file != '' ) |
|---|
| | 75 | image.src = '<$mt:StaticWebPath$>plugins/' + plugin_name +'/' + image_file + '.gif'; |
|---|
| | 76 | } |
|---|
| | 77 | return true; |
|---|
| | 78 | } |
|---|
| | 79 | |
|---|