|
|
@ -15,19 +15,7 @@ $.fn.dropdown = function(parameters) { |
|
|
|
$allModules = $(this), |
|
|
|
$document = $(document), |
|
|
|
|
|
|
|
settings = ( $.isPlainObject(parameters) ) |
|
|
|
? $.extend(true, {}, $.fn.dropdown.settings, parameters) |
|
|
|
: $.fn.dropdown.settings, |
|
|
|
|
|
|
|
className = settings.className, |
|
|
|
metadata = settings.metadata, |
|
|
|
namespace = settings.namespace, |
|
|
|
selector = settings.selector, |
|
|
|
error = settings.error, |
|
|
|
|
|
|
|
eventNamespace = '.' + namespace, |
|
|
|
dropdownNamespace = 'module-' + namespace, |
|
|
|
dropdownSelector = $allModules.selector || '', |
|
|
|
moduleSelector = $allModules.selector || '', |
|
|
|
|
|
|
|
time = new Date().getTime(), |
|
|
|
performance = [], |
|
|
@ -41,17 +29,30 @@ $.fn.dropdown = function(parameters) { |
|
|
|
$allModules |
|
|
|
.each(function() { |
|
|
|
var |
|
|
|
$module = $(this), |
|
|
|
$item = $module.find(selector.item), |
|
|
|
$text = $module.find(selector.text), |
|
|
|
$input = $module.find(selector.input), |
|
|
|
settings = ( $.isPlainObject(parameters) ) |
|
|
|
? $.extend(true, {}, $.fn.dropdown.settings, parameters) |
|
|
|
: $.fn.dropdown.settings, |
|
|
|
|
|
|
|
className = settings.className, |
|
|
|
metadata = settings.metadata, |
|
|
|
namespace = settings.namespace, |
|
|
|
selector = settings.selector, |
|
|
|
error = settings.error, |
|
|
|
|
|
|
|
$menu = $module.children(selector.menu), |
|
|
|
eventNamespace = '.' + namespace, |
|
|
|
dropdownNamespace = 'module-' + namespace, |
|
|
|
isTouchDevice = ('ontouchstart' in document.documentElement), |
|
|
|
|
|
|
|
isTouchDevice = ('ontouchstart' in document.documentElement), |
|
|
|
$module = $(this), |
|
|
|
$item = $module.find(selector.item), |
|
|
|
$text = $module.find(selector.text), |
|
|
|
$input = $module.find(selector.input), |
|
|
|
|
|
|
|
element = this, |
|
|
|
instance = $module.data(dropdownNamespace), |
|
|
|
$menu = $module.children(selector.menu), |
|
|
|
|
|
|
|
|
|
|
|
element = this, |
|
|
|
instance = $module.data(dropdownNamespace), |
|
|
|
module |
|
|
|
; |
|
|
|
|
|
|
@ -595,8 +596,8 @@ $.fn.dropdown = function(parameters) { |
|
|
|
totalTime += data['Execution Time']; |
|
|
|
}); |
|
|
|
title += ' ' + totalTime + 'ms'; |
|
|
|
if(dropdownSelector) { |
|
|
|
title += ' \'' + dropdownSelector + '\''; |
|
|
|
if(moduleSelector) { |
|
|
|
title += ' \'' + moduleSelector + '\''; |
|
|
|
} |
|
|
|
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
|
|
console.groupCollapsed(title); |
|
|
@ -616,7 +617,8 @@ $.fn.dropdown = function(parameters) { |
|
|
|
invoke: function(query, passedArguments, context) { |
|
|
|
var |
|
|
|
maxDepth, |
|
|
|
found |
|
|
|
found, |
|
|
|
response |
|
|
|
; |
|
|
|
passedArguments = passedArguments || queryArguments; |
|
|
|
context = element || context; |
|
|
@ -624,21 +626,46 @@ $.fn.dropdown = function(parameters) { |
|
|
|
query = query.split(/[\. ]/); |
|
|
|
maxDepth = query.length - 1; |
|
|
|
$.each(query, function(depth, value) { |
|
|
|
var camelCaseValue = (depth != maxDepth) |
|
|
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) |
|
|
|
: query |
|
|
|
; |
|
|
|
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) { |
|
|
|
instance = instance[value]; |
|
|
|
} |
|
|
|
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) { |
|
|
|
instance = instance[camelCaseValue]; |
|
|
|
} |
|
|
|
else if( instance[value] !== undefined ) { |
|
|
|
found = instance[value]; |
|
|
|
return false; |
|
|
|
} |
|
|
|
else if( instance[camelCaseValue] !== undefined ) { |
|
|
|
found = instance[camelCaseValue]; |
|
|
|
return false; |
|
|
|
} |
|
|
|
else { |
|
|
|
module.error(error.method); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if ( $.isFunction( found ) ) { |
|
|
|
return found.apply(context, passedArguments); |
|
|
|
response = found.apply(context, passedArguments); |
|
|
|
} |
|
|
|
else if(found !== undefined) { |
|
|
|
response = found; |
|
|
|
} |
|
|
|
if($.isArray(invokedResponse)) { |
|
|
|
invokedResponse.push(response); |
|
|
|
} |
|
|
|
else if(typeof invokedResponse == 'string') { |
|
|
|
invokedResponse = [invokedResponse, response]; |
|
|
|
} |
|
|
|
else if(response !== undefined) { |
|
|
|
invokedResponse = response; |
|
|
|
} |
|
|
|
return found || false; |
|
|
|
return found; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|