Index: lams_central/web/css/jquery.jRating.css =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/css/jquery.jRating.css,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/css/jquery.jRating.css 15 Nov 2012 14:35:17 -0000 1.1 @@ -0,0 +1,50 @@ +/*********************/ +/** jRating CSS **/ +/*********************/ + +/**Div containing the color of the stars */ +.jRatingAverage { + background-color:#f62929; + position:relative; + top:0; + left:0; + z-index:2; + height:100%; +} +.jRatingColor { + background-color:#f4c239; /* bgcolor of the stars*/ + position:relative; + top:0; + left:0; + z-index:2; + height:100%; +} + +/** Div containing the stars **/ +.jStar { + position:relative; + left:0; + z-index:3; +} + +/** P containing the rate informations **/ +p.jRatingInfos { + position: absolute; + z-index:9999; + background: transparent url('../images/css/jquery.jRating-background.png') no-repeat; /** customized url by LAMS **/ + color: #FFF; + display: none; + width: 91px; + height: 29px; + font-size:16px; + text-align:center; + padding-top:5px; +} + p.jRatingInfos span.maxRate { + color:#c9c9c9; + font-size:14px; + } + +/** Please, note this is a LAMS customization. In case of library upgrade copy these lines manually. **/ +.rating-stars-div {float:left; padding-right: 12px; margin-top: -8px;} +.rating-stars-caption {text-align: center; padding-top: 6px;} Index: lams_central/web/images/css/jquery.jRating-background.png =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/images/css/jquery.jRating-background.png,v diff -u Binary files differ Index: lams_central/web/images/css/jquery.jRating-small.png =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/images/css/jquery.jRating-small.png,v diff -u Binary files differ Index: lams_central/web/images/css/jquery.jRating-stars.png =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/images/css/jquery.jRating-stars.png,v diff -u Binary files differ Index: lams_central/web/includes/javascript/jquery.jRating.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/jquery.jRating.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/includes/javascript/jquery.jRating.js 15 Nov 2012 14:35:17 -0000 1.1 @@ -0,0 +1,212 @@ +/************************************************************************ +************************************************************************* +@Name : jRating - jQuery Plugin +@Revison : 2.3 +@Date : 07/09/2012 +@Author: ALPIXEL - (www.myjqueryplugins.com - www.alpixel.fr) +@License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php + +************************************************************************** +*************************************************************************/ + +/** Before upgrading watch out for "customized by LAMS" notes **/ + +(function($) { + $.fn.jRating = function(op) { + var defaults = { + /** String vars **/ + /** customized by LAMS **/ + bigStarsPath : pathToImageFolder + '/jquery.jRating-stars.png', // path of the icon stars.png. + /** customized by LAMS **/ + smallStarsPath : pathToImageFolder + '/jquery.jRating-small.png', // path of the icon small.png + phpPath : 'php/jRating.php', // path of the php file jRating.php + type : 'big', // can be set to 'small' or 'big' + + /** Boolean vars **/ + step:false, // if true, mouseover binded star by star, + isDisabled:false, + showRateInfo: true, + + /** Integer vars **/ + length:5, // number of star to display + decimalLength : 0, // number of decimals.. Max 3, but you can complete the function 'getNote' + rateMax : 20, // maximal rate - integer from 0 to 9999 (or more) + rateInfosX : -45, // relative position in X axis of the info box when mouseover + rateInfosY : 5, // relative position in Y axis of the info box when mouseover + + /** Functions **/ + onSuccess : null, + onError : null + }; + + if(this.length>0) + return this.each(function() { + var opts = $.extend(defaults, op), + newWidth = 0, + starWidth = 0, + starHeight = 0, + bgPath = ''; + + if($(this).hasClass('jDisabled') || opts.isDisabled) + var jDisabled = true; + else + var jDisabled = false; + + getStarWidth(); + $(this).height(starHeight); + + var average = parseFloat($(this).attr('id').split('_')[0]), + idBox = parseInt($(this).attr('id').split('_')[1]), // get the id of the box + widthRatingContainer = starWidth*opts.length, // Width of the Container + widthColor = average/opts.rateMax*widthRatingContainer, // Width of the color Container + + quotient = + $('
', + { + 'class' : 'jRatingColor', + css:{ + width:widthColor + } + }).appendTo($(this)), + + average = + $('
', + { + 'class' : 'jRatingAverage', + css:{ + width:0, + top:- starHeight + } + }).appendTo($(this)), + + jstar = + $('
', + { + 'class' : 'jStar', + css:{ + width:widthRatingContainer, + height:starHeight, + top:- (starHeight*2), + background: 'url('+bgPath+') repeat-x' + } + }).appendTo($(this)); + + + $(this).css({width: widthRatingContainer,overflow:'hidden',zIndex:1,position:'relative'}); + + if(!jDisabled) + $(this).unbind().bind({ + mouseenter : function(e){ + var realOffsetLeft = findRealLeft(this); + var relativeX = e.pageX - realOffsetLeft; + if (opts.showRateInfo) + var tooltip = + $('

',{ + 'class' : 'jRatingInfos', + html : getNote(relativeX)+' / '+opts.rateMax+'', + css : { + top: (e.pageY + opts.rateInfosY), + left: (e.pageX + opts.rateInfosX) + } + }).appendTo('body').show(); + }, + mouseover : function(e){ + $(this).css('cursor','pointer'); + }, + mouseout : function(){ + $(this).css('cursor','default'); + average.width(0); + }, + mousemove : function(e){ + var realOffsetLeft = findRealLeft(this); + var relativeX = e.pageX - realOffsetLeft; + if(opts.step) newWidth = Math.floor(relativeX/starWidth)*starWidth + starWidth; + else newWidth = relativeX; + average.width(newWidth); + if (opts.showRateInfo) + $("p.jRatingInfos") + .css({ + left: (e.pageX + opts.rateInfosX) + }) + .html(getNote(newWidth) +' / '+opts.rateMax+''); + }, + mouseleave : function(){ + $("p.jRatingInfos").remove(); + }, + click : function(e){ + var element = this; + $(this).unbind().css('cursor','default').addClass('jDisabled'); + if (opts.showRateInfo) $("p.jRatingInfos").fadeOut('fast',function(){$(this).remove();}); + e.preventDefault(); + var rate = getNote(newWidth); + average.width(newWidth); + + $.post(opts.phpPath,{ + idBox : idBox, + rate : rate, + action : 'rating' + }, + function(data) { + if(!data.error) + { + + /** Here you can display an alert box, + or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify + exemple : */ + /** customized by LAMS **/ + if(opts.onSuccess) opts.onSuccess( data, idBox ); + } + else + { + + /** Here you can display an alert box, + or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify + exemple : */ + if(opts.onError) opts.onError( element, rate ); + } + }, + 'json' + ); + } + }); + + function getNote(relativeX) { + var noteBrut = parseFloat((relativeX*100/widthRatingContainer)*opts.rateMax/100); + switch(opts.decimalLength) { + case 1 : + var note = Math.round(noteBrut*10)/10; + break; + case 2 : + var note = Math.round(noteBrut*100)/100; + break; + case 3 : + var note = Math.round(noteBrut*1000)/1000; + break; + default : + var note = Math.round(noteBrut*1)/1; + } + return note; + }; + + function getStarWidth(){ + switch(opts.type) { + case 'small' : + starWidth = 12; // width of the picture small.png + starHeight = 10; // height of the picture small.png + bgPath = opts.smallStarsPath; + break; + default : + starWidth = 23; // width of the picture stars.png + starHeight = 20; // height of the picture stars.png + bgPath = opts.bigStarsPath; + } + }; + + function findRealLeft(obj) { + if( !obj ) return 0; + return obj.offsetLeft + findRealLeft( obj.offsetParent ); + }; + }); + + } +})(jQuery); \ No newline at end of file