diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 24d731bba..2d6102cf0 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -67,6 +67,7 @@ $.fn.dropdown = function(parameters) { element = this, instance = $module.data(moduleNamespace), + initialLoad, pageLostFocus, elementNamespace, id, @@ -87,27 +88,10 @@ $.fn.dropdown = function(parameters) { module.save.defaults(); - if(settings.apiSettings) { - if(settings.saveRemoteData) { - module.restore.remoteValues(); - } - else { - module.clearValue(); - } - } - else { - module.set.selected(); - } + module.restore.values(); if(module.is.multiple()) { - if(settings.allowAdditions) { - if(!settings.useLabels) { - module.error(error.labels); - settings.useLabels = true; - } - module.create.userLabels(); - } - module.check.maxSelections(); + module.restore.labels(); } module.create.id(); @@ -1631,6 +1615,37 @@ $.fn.dropdown = function(parameters) { } } }, + labels: function() { + if(settings.allowAdditions) { + if(!settings.useLabels) { + module.error(error.labels); + settings.useLabels = true; + } + module.debug('Restoring selected values'); + module.create.userLabels(); + } + module.check.maxSelections(); + }, + values: function() { + module.debug('Restoring selected values'); + if(settings.fireOnInit === false) { + initialLoad = true; + } + if(settings.apiSettings) { + if(settings.saveRemoteData) { + module.restore.remoteValues(); + } + else { + module.clearValue(); + } + } + else { + module.set.selected(); + } + if(settings.fireOnInit === false) { + initialLoad = false; + } + }, remoteValues: function() { var values = module.get.remoteValues() @@ -1638,14 +1653,12 @@ $.fn.dropdown = function(parameters) { module.debug('Recreating selected from session data', values); if(values) { if( module.is.single() ) { - console.log('single text', values, name); $.each(values, function(value, name) { module.set.text(name); }); } else { $.each(values, function(value, name) { - console.log(value, name); module.add.label(value, name); }); } @@ -1663,7 +1676,6 @@ $.fn.dropdown = function(parameters) { return; } name = sessionStorage.getItem(value); - console.log('reading', value, name); return (name !== undefined) ? name : false @@ -1693,7 +1705,6 @@ $.fn.dropdown = function(parameters) { module.error(error.noStorage); return; } - console.log('saving', value, name); sessionStorage.setItem(value, name); } }, @@ -1787,6 +1798,9 @@ $.fn.dropdown = function(parameters) { text = text || $module.data(metadata.placeholderText); module.set.text(text); $text.addClass(className.placeholder); + }, + input: function() { + }, tabbable: function() { if( module.has.search() ) { @@ -1913,36 +1927,10 @@ $.fn.dropdown = function(parameters) { var hasInput = ($input.length > 0), isAddition = !module.has.value(value), - currentValue = module.get.values() + currentValue = module.get.values(), + newValue ; - if($input.length > 0) { - - if( module.is.multiple() ) { - - if(value === '') { - module.debug('Cannot select blank values from multiselect'); - return; - } - - // extend currently selected values - value = [value]; - if($.isArray(currentValue)) { - value = currentValue.concat(value); - value = module.get.uniqueArray(value); - } - - // set values - if( $input.is('select') ) { - module.debug('Setting multiple removing selected'); - $input - .find('option[value="' + value + '"]') - .prop('selected', false) - ; + module.verbose('Input is