Browse Source

Adds automatic action detection to dropdown, select dropdowns now can use default action and update form fields. Improvement #171

Former-commit-id: 06c373e064
Former-commit-id: b1ddbfc183
pull/258/head
jlukic 11 years ago
parent
commit
ef1e91caa6
1 changed files with 19 additions and 5 deletions
  1. 24
      src/modules/dropdown.js

24
src/modules/dropdown.js

@ -188,12 +188,22 @@ $.fn.dropdown = function(parameters) {
determine: { determine: {
selectAction: function(text, value) { selectAction: function(text, value) {
module.verbose('Determining action', settings.action); module.verbose('Determining action', settings.action);
if( $.isFunction( module[settings.action] ) ) {
module.verbose('Triggering preset action', settings.action);
if(settings.action == 'auto') {
if(module.is.selection()) {
module.debug('Selection dropdown used updating form', text, value);
module.updateForm(text, value);
}
else {
module.debug('No action specified hiding dropdown', text, value);
module.hide();
}
}
else if( $.isFunction( module[settings.action] ) ) {
module.verbose('Triggering preset action', settings.action, text, value);
module[ settings.action ](text, value); module[ settings.action ](text, value);
} }
else if( $.isFunction(settings.action) ) { else if( $.isFunction(settings.action) ) {
module.verbose('Triggering user action', settings.action);
module.verbose('Triggering user action', settings.action, text, value);
settings.action(text, value); settings.action(text, value);
} }
else { else {
@ -318,6 +328,9 @@ $.fn.dropdown = function(parameters) {
}, },
is: { is: {
selection: function() {
return $module.hasClass(className.selection);
},
visible: function($subMenu) { visible: function($subMenu) {
return ($subMenu) return ($subMenu)
? $subMenu.is(':animated, :visible') ? $subMenu.is(':animated, :visible')
@ -666,7 +679,7 @@ $.fn.dropdown.settings = {
performance : true, performance : true,
on : 'click', on : 'click',
action : 'hide',
action : 'auto',
delay: { delay: {
show: 200, show: 200,
@ -702,7 +715,8 @@ $.fn.dropdown.settings = {
active : 'active', active : 'active',
placeholder : 'default', placeholder : 'default',
disabled : 'disabled', disabled : 'disabled',
visible : 'visible'
visible : 'visible',
selection : 'selection'
} }
}; };

Loading…
Cancel
Save