Browse Source

#2042 add delegated events to rating

pull/2053/head
jlukic 9 years ago
parent
commit
3520e510be
1 changed files with 23 additions and 11 deletions
  1. 34
      src/definitions/modules/rating.js

34
src/definitions/modules/rating.js

@ -87,12 +87,10 @@ $.fn.rating = function(parameters) {
destroy: function() { destroy: function() {
module.verbose('Destroying previous instance', instance); module.verbose('Destroying previous instance', instance);
module.remove.events();
$module $module
.removeData(moduleNamespace) .removeData(moduleNamespace)
; ;
$icon
.off(eventNamespace)
;
}, },
refresh: function() { refresh: function() {
@ -169,13 +167,29 @@ $.fn.rating = function(parameters) {
return currentRating; return currentRating;
}, },
bind: {
events: function() {
module.verbose('Binding events');
$module
.on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter)
.on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave)
.on('click' + eventNamespace, selector.icon, module.event.click)
;
}
},
remove: {
events: function() {
module.verbose('Removing events');
$module
.off(eventNamespace)
;
}
},
enable: function() { enable: function() {
module.debug('Setting rating to interactive mode'); 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.bind.events();
$module $module
.removeClass(className.disabled) .removeClass(className.disabled)
; ;
@ -183,9 +197,7 @@ $.fn.rating = function(parameters) {
disable: function() { disable: function() {
module.debug('Setting rating to read-only mode'); module.debug('Setting rating to read-only mode');
$icon
.off(eventNamespace)
;
module.remove.events();
$module $module
.addClass(className.disabled) .addClass(className.disabled)
; ;

Loading…
Cancel
Save