Browse Source

Adds disable/enable to ratings, fixes spacing and other goodness

Former-commit-id: e571cc6cdb
Former-commit-id: 67b2f06f1c
pull/258/head
jlukic 11 years ago
parent
commit
db4d49508e
2 changed files with 43 additions and 29 deletions
  1. 38
      src/modules/rating.js
  2. 34
      src/modules/rating.less

38
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)

34
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;
}
Loading…
Cancel
Save