diff --git a/src/modules/rating.js b/src/modules/rating.js index 0eabb5953..af7d1f4c1 100755 --- a/src/modules/rating.js +++ b/src/modules/rating.js @@ -49,14 +49,15 @@ $.fn.rating = function(parameters) { module = { initialize: function() { - module.verbose('Initializing rating module'); + module.verbose('Initializing rating module', settings); + if(settings.interactive) { - $icon - .bind('mouseenter' + eventNamespace, module.event.mouseenter) - .bind('mouseleave' + eventNamespace, module.event.mouseleave) - .bind('click' + eventNamespace, module.event.click) - ; + module.enable(); } + else { + module.disable(); + } + if(settings.initialRating) { module.debug('Setting initial rating'); module.setRating(settings.initialRating); @@ -65,9 +66,6 @@ $.fn.rating = function(parameters) { module.debug('Rating found in metadata'); module.setRating( $module.data(metadata.rating) ); } - $module - .addClass(className.active) - ; module.instantiate(); }, @@ -141,6 +139,28 @@ $.fn.rating = function(parameters) { return currentRating; }, + enable: function() { + module.debug('Setting rating to interactive mode'); + $icon + .on('mouseenter' + eventNamespace, module.event.mouseenter) + .on('mouseleave' + eventNamespace, module.event.mouseleave) + .on('click' + eventNamespace, module.event.click) + ; + $module + .addClass(className.active) + ; + }, + + disable: function() { + module.debug('Setting rating to read-only mode'); + $icon + .off(eventNamespace) + ; + $module + .removeClass(className.active) + ; + }, + setRating: function(rating) { var ratingIndex = (rating - 1 >= 0) diff --git a/src/modules/rating.less b/src/modules/rating.less index df1388a4f..2bfe18b81 100755 --- a/src/modules/rating.less +++ b/src/modules/rating.less @@ -15,6 +15,8 @@ .ui.rating { display: inline-block; + + font-size: 0em; vertical-align: baseline; margin: 0em 0.5em 0em 0em; } @@ -78,11 +80,7 @@ --------------------*/ .ui.star.rating .icon { - width: 1em; - margin-right: 0.1em; -} -.ui.star.rating .icon:last-child { - margin: 0em; + width: 1.2em; } /* Star */ @@ -103,11 +101,7 @@ --------------------*/ .ui.heart.rating .icon { - width: 1em; - margin-right: 0.1em; -} -.ui.heart.rating .icon:last-child { - margin: 0em; + width: 1.2em; } .ui.heart.rating .icon:before { content: '\f08a'; @@ -169,21 +163,21 @@ Variations *******************************/ -.ui.small.rating { - font-size: 0.75em; +.ui.small.rating .icon { + font-size: 0.75rem; } -.ui.rating { - font-size: 1em; +.ui.rating .icon { + font-size: 1rem; } -.ui.large.rating { - font-size: 1.5em; +.ui.large.rating .icon { + font-size: 1.5rem; vertical-align: middle; } -.ui.huge.rating { - font-size: 2em; +.ui.huge.rating .icon { + font-size: 2rem; vertical-align: middle; } -.ui.massive.rating { - font-size: 3em; +.ui.massive.rating .icon { + font-size: 3rem; vertical-align: middle; } \ No newline at end of file