|
@ -13,10 +13,10 @@ |
|
|
|
|
|
|
|
|
$.fn.dropdown = function(parameters) { |
|
|
$.fn.dropdown = function(parameters) { |
|
|
var |
|
|
var |
|
|
$allDropdowns = $(this), |
|
|
|
|
|
$document = $(document), |
|
|
|
|
|
|
|
|
$allModules = $(this), |
|
|
|
|
|
$document = $(document), |
|
|
|
|
|
|
|
|
settings = ( $.isPlainObject(parameters) ) |
|
|
|
|
|
|
|
|
settings = ( $.isPlainObject(parameters) ) |
|
|
? $.extend(true, {}, $.fn.dropdown.settings, parameters) |
|
|
? $.extend(true, {}, $.fn.dropdown.settings, parameters) |
|
|
: $.fn.dropdown.settings, |
|
|
: $.fn.dropdown.settings, |
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ $.fn.dropdown = function(parameters) { |
|
|
|
|
|
|
|
|
eventNamespace = '.' + namespace, |
|
|
eventNamespace = '.' + namespace, |
|
|
dropdownNamespace = 'module-' + namespace, |
|
|
dropdownNamespace = 'module-' + namespace, |
|
|
dropdownSelector = $allDropdowns.selector || '', |
|
|
|
|
|
|
|
|
dropdownSelector = $allModules.selector || '', |
|
|
|
|
|
|
|
|
time = new Date().getTime(), |
|
|
time = new Date().getTime(), |
|
|
performance = [], |
|
|
performance = [], |
|
@ -39,72 +39,72 @@ $.fn.dropdown = function(parameters) { |
|
|
invokedResponse |
|
|
invokedResponse |
|
|
; |
|
|
; |
|
|
|
|
|
|
|
|
$allDropdowns |
|
|
|
|
|
|
|
|
$allModules |
|
|
.each(function() { |
|
|
.each(function() { |
|
|
var |
|
|
var |
|
|
$dropdown = $(this), |
|
|
|
|
|
$item = $dropdown.find(selector.item), |
|
|
|
|
|
$text = $dropdown.find(selector.text), |
|
|
|
|
|
$input = $dropdown.find(selector.input), |
|
|
|
|
|
|
|
|
$module = $(this), |
|
|
|
|
|
$item = $module.find(selector.item), |
|
|
|
|
|
$text = $module.find(selector.text), |
|
|
|
|
|
$input = $module.find(selector.input), |
|
|
|
|
|
|
|
|
$menu = $dropdown.children(selector.menu), |
|
|
|
|
|
|
|
|
$menu = $module.children(selector.menu), |
|
|
|
|
|
|
|
|
isTouchDevice = ('ontouchstart' in document.documentElement), |
|
|
isTouchDevice = ('ontouchstart' in document.documentElement), |
|
|
|
|
|
|
|
|
element = this, |
|
|
element = this, |
|
|
instance = $dropdown.data(dropdownNamespace), |
|
|
|
|
|
dropdown |
|
|
|
|
|
|
|
|
instance = $module.data(dropdownNamespace), |
|
|
|
|
|
module |
|
|
; |
|
|
; |
|
|
|
|
|
|
|
|
dropdown = { |
|
|
|
|
|
|
|
|
module = { |
|
|
|
|
|
|
|
|
initialize: function() { |
|
|
initialize: function() { |
|
|
dropdown.debug('Initializing dropdown', settings); |
|
|
|
|
|
|
|
|
module.debug('Initializing dropdown', settings); |
|
|
if(isTouchDevice) { |
|
|
if(isTouchDevice) { |
|
|
$dropdown |
|
|
|
|
|
.on('touchstart' + eventNamespace, dropdown.event.test.toggle) |
|
|
|
|
|
|
|
|
$module |
|
|
|
|
|
.on('touchstart' + eventNamespace, module.event.test.toggle) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
else if(settings.on == 'click') { |
|
|
else if(settings.on == 'click') { |
|
|
$dropdown |
|
|
|
|
|
.on('click' + eventNamespace, dropdown.event.test.toggle) |
|
|
|
|
|
|
|
|
$module |
|
|
|
|
|
.on('click' + eventNamespace, module.event.test.toggle) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
else if(settings.on == 'hover') { |
|
|
else if(settings.on == 'hover') { |
|
|
$dropdown |
|
|
|
|
|
.on('mouseenter' + eventNamespace, dropdown.delay.show) |
|
|
|
|
|
.on('mouseleave' + eventNamespace, dropdown.delay.hide) |
|
|
|
|
|
|
|
|
$module |
|
|
|
|
|
.on('mouseenter' + eventNamespace, module.delay.show) |
|
|
|
|
|
.on('mouseleave' + eventNamespace, module.delay.hide) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$dropdown |
|
|
|
|
|
.on(settings.on + eventNamespace, dropdown.toggle) |
|
|
|
|
|
|
|
|
$module |
|
|
|
|
|
.on(settings.on + eventNamespace, module.toggle) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
if(settings.action == 'form') { |
|
|
if(settings.action == 'form') { |
|
|
dropdown.set.selected(); |
|
|
|
|
|
|
|
|
module.set.selected(); |
|
|
} |
|
|
} |
|
|
$item |
|
|
$item |
|
|
.on('mouseenter' + eventNamespace, dropdown.event.item.mouseenter) |
|
|
|
|
|
.on('mouseleave' + eventNamespace, dropdown.event.item.mouseleave) |
|
|
|
|
|
.on(dropdown.get.selectEvent() + eventNamespace, dropdown.event.item.click) |
|
|
|
|
|
|
|
|
.on('mouseenter' + eventNamespace, module.event.item.mouseenter) |
|
|
|
|
|
.on('mouseleave' + eventNamespace, module.event.item.mouseleave) |
|
|
|
|
|
.on(module.get.selectEvent() + eventNamespace, module.event.item.click) |
|
|
; |
|
|
; |
|
|
dropdown.instantiate(); |
|
|
|
|
|
|
|
|
module.instantiate(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
instantiate: function() { |
|
|
instantiate: function() { |
|
|
dropdown.verbose('Storing instance of dropdown', dropdown); |
|
|
|
|
|
$dropdown |
|
|
|
|
|
.data(dropdownNamespace, dropdown) |
|
|
|
|
|
|
|
|
module.verbose('Storing instance of dropdown', module); |
|
|
|
|
|
$module |
|
|
|
|
|
.data(dropdownNamespace, module) |
|
|
; |
|
|
; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
destroy: function() { |
|
|
destroy: function() { |
|
|
dropdown.verbose('Destroying previous dropdown for', $dropdown); |
|
|
|
|
|
|
|
|
module.verbose('Destroying previous dropdown for', $module); |
|
|
$item |
|
|
$item |
|
|
.off(eventNamespace) |
|
|
.off(eventNamespace) |
|
|
; |
|
|
; |
|
|
$dropdown |
|
|
|
|
|
|
|
|
$module |
|
|
.off(eventNamespace) |
|
|
.off(eventNamespace) |
|
|
.removeData(dropdownNamespace) |
|
|
.removeData(dropdownNamespace) |
|
|
; |
|
|
; |
|
@ -118,11 +118,11 @@ $.fn.dropdown = function(parameters) { |
|
|
|
|
|
|
|
|
test: { |
|
|
test: { |
|
|
toggle: function(event) { |
|
|
toggle: function(event) { |
|
|
dropdown.determine.intent(event, dropdown.toggle); |
|
|
|
|
|
|
|
|
module.determine.intent(event, module.toggle); |
|
|
event.stopImmediatePropagation(); |
|
|
event.stopImmediatePropagation(); |
|
|
}, |
|
|
}, |
|
|
hide: function(event) { |
|
|
hide: function(event) { |
|
|
dropdown.determine.intent(event, dropdown.hide); |
|
|
|
|
|
|
|
|
module.determine.intent(event, module.hide); |
|
|
event.stopPropagation(); |
|
|
event.stopPropagation(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -135,11 +135,11 @@ $.fn.dropdown = function(parameters) { |
|
|
$otherMenus = $(this).siblings(selector.item).children(selector.menu) |
|
|
$otherMenus = $(this).siblings(selector.item).children(selector.menu) |
|
|
; |
|
|
; |
|
|
if( $currentMenu.size() > 0 ) { |
|
|
if( $currentMenu.size() > 0 ) { |
|
|
clearTimeout(dropdown.itemTimer); |
|
|
|
|
|
dropdown.itemTimer = setTimeout(function() { |
|
|
|
|
|
dropdown.animate.hide(false, $otherMenus); |
|
|
|
|
|
dropdown.verbose('Showing sub-menu', $currentMenu); |
|
|
|
|
|
dropdown.animate.show(false, $currentMenu); |
|
|
|
|
|
|
|
|
clearTimeout(module.itemTimer); |
|
|
|
|
|
module.itemTimer = setTimeout(function() { |
|
|
|
|
|
module.animate.hide(false, $otherMenus); |
|
|
|
|
|
module.verbose('Showing sub-menu', $currentMenu); |
|
|
|
|
|
module.animate.show(false, $currentMenu); |
|
|
}, settings.delay.show * 2); |
|
|
}, settings.delay.show * 2); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -149,10 +149,10 @@ $.fn.dropdown = function(parameters) { |
|
|
$currentMenu = $(this).find(selector.menu) |
|
|
$currentMenu = $(this).find(selector.menu) |
|
|
; |
|
|
; |
|
|
if($currentMenu.size() > 0) { |
|
|
if($currentMenu.size() > 0) { |
|
|
clearTimeout(dropdown.itemTimer); |
|
|
|
|
|
dropdown.itemTimer = setTimeout(function() { |
|
|
|
|
|
dropdown.verbose('Hiding sub-menu', $currentMenu); |
|
|
|
|
|
dropdown.animate.hide(false, $currentMenu); |
|
|
|
|
|
|
|
|
clearTimeout(module.itemTimer); |
|
|
|
|
|
module.itemTimer = setTimeout(function() { |
|
|
|
|
|
module.verbose('Hiding sub-menu', $currentMenu); |
|
|
|
|
|
module.animate.hide(false, $currentMenu); |
|
|
}, settings.delay.hide); |
|
|
}, settings.delay.hide); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -164,14 +164,14 @@ $.fn.dropdown = function(parameters) { |
|
|
value = $choice.data(metadata.value) || text |
|
|
value = $choice.data(metadata.value) || text |
|
|
; |
|
|
; |
|
|
if( $choice.find(selector.menu).size() === 0 ) { |
|
|
if( $choice.find(selector.menu).size() === 0 ) { |
|
|
dropdown.verbose('Adding active state to selected item'); |
|
|
|
|
|
|
|
|
module.verbose('Adding active state to selected item'); |
|
|
$item |
|
|
$item |
|
|
.removeClass(className.active) |
|
|
.removeClass(className.active) |
|
|
; |
|
|
; |
|
|
$choice |
|
|
$choice |
|
|
.addClass(className.active) |
|
|
.addClass(className.active) |
|
|
; |
|
|
; |
|
|
dropdown.determine.selectAction(text, value); |
|
|
|
|
|
|
|
|
module.determine.selectAction(text, value); |
|
|
$.proxy(settings.onChange, element)(value, text); |
|
|
$.proxy(settings.onChange, element)(value, text); |
|
|
event.stopPropagation(); |
|
|
event.stopPropagation(); |
|
|
} |
|
|
} |
|
@ -187,46 +187,46 @@ $.fn.dropdown = function(parameters) { |
|
|
|
|
|
|
|
|
determine: { |
|
|
determine: { |
|
|
selectAction: function(text, value) { |
|
|
selectAction: function(text, value) { |
|
|
dropdown.verbose('Determining action', settings.action); |
|
|
|
|
|
if( $.isFunction( dropdown[settings.action] ) ) { |
|
|
|
|
|
dropdown.verbose('Triggering preset action', settings.action); |
|
|
|
|
|
dropdown[ settings.action ](text, value); |
|
|
|
|
|
|
|
|
module.verbose('Determining action', settings.action); |
|
|
|
|
|
if( $.isFunction( module[settings.action] ) ) { |
|
|
|
|
|
module.verbose('Triggering preset action', settings.action); |
|
|
|
|
|
module[ settings.action ](text, value); |
|
|
} |
|
|
} |
|
|
else if( $.isFunction(settings.action) ) { |
|
|
else if( $.isFunction(settings.action) ) { |
|
|
dropdown.verbose('Triggering user action', settings.action); |
|
|
|
|
|
|
|
|
module.verbose('Triggering user action', settings.action); |
|
|
settings.action(text, value); |
|
|
settings.action(text, value); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.error(error.action); |
|
|
|
|
|
|
|
|
module.error(error.action); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
intent: function(event, callback) { |
|
|
intent: function(event, callback) { |
|
|
dropdown.debug('Determining whether event occurred in dropdown', event.target); |
|
|
|
|
|
|
|
|
module.debug('Determining whether event occurred in dropdown', event.target); |
|
|
callback = callback || function(){}; |
|
|
callback = callback || function(){}; |
|
|
if( $(event.target).closest($menu).size() === 0 ) { |
|
|
if( $(event.target).closest($menu).size() === 0 ) { |
|
|
dropdown.verbose('Triggering event', callback); |
|
|
|
|
|
|
|
|
module.verbose('Triggering event', callback); |
|
|
callback(); |
|
|
callback(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.verbose('Event occurred in dropdown, canceling callback'); |
|
|
|
|
|
|
|
|
module.verbose('Event occurred in dropdown, canceling callback'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
bind: { |
|
|
bind: { |
|
|
intent: function() { |
|
|
intent: function() { |
|
|
dropdown.verbose('Binding hide intent event to document'); |
|
|
|
|
|
|
|
|
module.verbose('Binding hide intent event to document'); |
|
|
$document |
|
|
$document |
|
|
.on(dropdown.get.selectEvent(), dropdown.event.test.hide) |
|
|
|
|
|
|
|
|
.on(module.get.selectEvent(), module.event.test.hide) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
unbind: { |
|
|
unbind: { |
|
|
intent: function() { |
|
|
intent: function() { |
|
|
dropdown.verbose('Removing hide intent event from document'); |
|
|
|
|
|
|
|
|
module.verbose('Removing hide intent event from document'); |
|
|
$document |
|
|
$document |
|
|
.off(dropdown.get.selectEvent()) |
|
|
|
|
|
|
|
|
.off(module.get.selectEvent()) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -234,14 +234,14 @@ $.fn.dropdown = function(parameters) { |
|
|
nothing: function() {}, |
|
|
nothing: function() {}, |
|
|
|
|
|
|
|
|
changeText: function(text, value) { |
|
|
changeText: function(text, value) { |
|
|
dropdown.set.text(text); |
|
|
|
|
|
dropdown.hide(); |
|
|
|
|
|
|
|
|
module.set.text(text); |
|
|
|
|
|
module.hide(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
updateForm: function(text, value) { |
|
|
updateForm: function(text, value) { |
|
|
dropdown.set.text(text); |
|
|
|
|
|
dropdown.set.value(value); |
|
|
|
|
|
dropdown.hide(); |
|
|
|
|
|
|
|
|
module.set.text(text); |
|
|
|
|
|
module.set.value(value); |
|
|
|
|
|
module.hide(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
get: { |
|
|
get: { |
|
@ -275,27 +275,27 @@ $.fn.dropdown = function(parameters) { |
|
|
|
|
|
|
|
|
set: { |
|
|
set: { |
|
|
text: function(text) { |
|
|
text: function(text) { |
|
|
dropdown.debug('Changing text', text, $text); |
|
|
|
|
|
|
|
|
module.debug('Changing text', text, $text); |
|
|
$text.removeClass(className.placeholder); |
|
|
$text.removeClass(className.placeholder); |
|
|
$text.text(text); |
|
|
$text.text(text); |
|
|
}, |
|
|
}, |
|
|
value: function(value) { |
|
|
value: function(value) { |
|
|
dropdown.debug('Adding selected value to hidden input', value, $input); |
|
|
|
|
|
|
|
|
module.debug('Adding selected value to hidden input', value, $input); |
|
|
$input.val(value); |
|
|
$input.val(value); |
|
|
}, |
|
|
}, |
|
|
active: function() { |
|
|
active: function() { |
|
|
$dropdown.addClass(className.active); |
|
|
|
|
|
|
|
|
$module.addClass(className.active); |
|
|
}, |
|
|
}, |
|
|
visible: function() { |
|
|
visible: function() { |
|
|
$dropdown.addClass(className.visible); |
|
|
|
|
|
|
|
|
$module.addClass(className.visible); |
|
|
}, |
|
|
}, |
|
|
selected: function(value) { |
|
|
selected: function(value) { |
|
|
var |
|
|
var |
|
|
$selectedItem = dropdown.get.item(value), |
|
|
|
|
|
|
|
|
$selectedItem = module.get.item(value), |
|
|
selectedText |
|
|
selectedText |
|
|
; |
|
|
; |
|
|
if($selectedItem) { |
|
|
if($selectedItem) { |
|
|
dropdown.debug('Setting selected menu item to', $selectedItem); |
|
|
|
|
|
|
|
|
module.debug('Setting selected menu item to', $selectedItem); |
|
|
selectedText = $selectedItem.data(metadata.text) || $selectedItem.text(); |
|
|
selectedText = $selectedItem.data(metadata.text) || $selectedItem.text(); |
|
|
$item |
|
|
$item |
|
|
.removeClass(className.active) |
|
|
.removeClass(className.active) |
|
@ -303,17 +303,17 @@ $.fn.dropdown = function(parameters) { |
|
|
$selectedItem |
|
|
$selectedItem |
|
|
.addClass(className.active) |
|
|
.addClass(className.active) |
|
|
; |
|
|
; |
|
|
dropdown.set.text(selectedText); |
|
|
|
|
|
|
|
|
module.set.text(selectedText); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
remove: { |
|
|
remove: { |
|
|
active: function() { |
|
|
active: function() { |
|
|
$dropdown.removeClass(className.active); |
|
|
|
|
|
|
|
|
$module.removeClass(className.active); |
|
|
}, |
|
|
}, |
|
|
visible: function() { |
|
|
visible: function() { |
|
|
$dropdown.removeClass(className.visible); |
|
|
|
|
|
|
|
|
$module.removeClass(className.visible); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -337,7 +337,7 @@ $.fn.dropdown = function(parameters) { |
|
|
return (isTouchDevice || settings.on == 'click'); |
|
|
return (isTouchDevice || settings.on == 'click'); |
|
|
}, |
|
|
}, |
|
|
show: function() { |
|
|
show: function() { |
|
|
return !$dropdown.hasClass(className.disabled); |
|
|
|
|
|
|
|
|
return !$module.hasClass(className.disabled); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -347,8 +347,8 @@ $.fn.dropdown = function(parameters) { |
|
|
$currentMenu = $subMenu || $menu |
|
|
$currentMenu = $subMenu || $menu |
|
|
; |
|
|
; |
|
|
callback = callback || function(){}; |
|
|
callback = callback || function(){}; |
|
|
if( dropdown.is.hidden($currentMenu) ) { |
|
|
|
|
|
dropdown.verbose('Doing menu show animation', $currentMenu); |
|
|
|
|
|
|
|
|
if( module.is.hidden($currentMenu) ) { |
|
|
|
|
|
module.verbose('Doing menu show animation', $currentMenu); |
|
|
if(settings.transition == 'none') { |
|
|
if(settings.transition == 'none') { |
|
|
callback(); |
|
|
callback(); |
|
|
} |
|
|
} |
|
@ -370,10 +370,10 @@ $.fn.dropdown = function(parameters) { |
|
|
.delay(50) |
|
|
.delay(50) |
|
|
.animate({ |
|
|
.animate({ |
|
|
opacity : 1 |
|
|
opacity : 1 |
|
|
}, settings.duration, 'easeOutQuad', dropdown.event.resetStyle) |
|
|
|
|
|
|
|
|
}, settings.duration, 'easeOutQuad', module.event.resetStyle) |
|
|
.end() |
|
|
.end() |
|
|
.slideDown(100, 'easeOutQuad', function() { |
|
|
.slideDown(100, 'easeOutQuad', function() { |
|
|
$.proxy(dropdown.event.resetStyle, this)(); |
|
|
|
|
|
|
|
|
$.proxy(module.event.resetStyle, this)(); |
|
|
callback(); |
|
|
callback(); |
|
|
}) |
|
|
}) |
|
|
; |
|
|
; |
|
@ -383,13 +383,13 @@ $.fn.dropdown = function(parameters) { |
|
|
.hide() |
|
|
.hide() |
|
|
.clearQueue() |
|
|
.clearQueue() |
|
|
.fadeIn(settings.duration, function() { |
|
|
.fadeIn(settings.duration, function() { |
|
|
$.proxy(dropdown.event.resetStyle, this)(); |
|
|
|
|
|
|
|
|
$.proxy(module.event.resetStyle, this)(); |
|
|
callback(); |
|
|
callback(); |
|
|
}) |
|
|
}) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.error(error.transition); |
|
|
|
|
|
|
|
|
module.error(error.transition); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -398,8 +398,8 @@ $.fn.dropdown = function(parameters) { |
|
|
$currentMenu = $subMenu || $menu |
|
|
$currentMenu = $subMenu || $menu |
|
|
; |
|
|
; |
|
|
callback = callback || function(){}; |
|
|
callback = callback || function(){}; |
|
|
if(dropdown.is.visible($currentMenu) ) { |
|
|
|
|
|
dropdown.verbose('Doing menu hide animation', $currentMenu); |
|
|
|
|
|
|
|
|
if(module.is.visible($currentMenu) ) { |
|
|
|
|
|
module.verbose('Doing menu hide animation', $currentMenu); |
|
|
if($.fn.transition !== undefined) { |
|
|
if($.fn.transition !== undefined) { |
|
|
$currentMenu.transition({ |
|
|
$currentMenu.transition({ |
|
|
animation : settings.transition + ' out', |
|
|
animation : settings.transition + ' out', |
|
@ -420,11 +420,11 @@ $.fn.dropdown = function(parameters) { |
|
|
.css('opacity', 1) |
|
|
.css('opacity', 1) |
|
|
.animate({ |
|
|
.animate({ |
|
|
opacity : 0 |
|
|
opacity : 0 |
|
|
}, 100, 'easeOutQuad', dropdown.event.resetStyle) |
|
|
|
|
|
|
|
|
}, 100, 'easeOutQuad', module.event.resetStyle) |
|
|
.end() |
|
|
.end() |
|
|
.delay(50) |
|
|
.delay(50) |
|
|
.slideUp(100, 'easeOutQuad', function() { |
|
|
.slideUp(100, 'easeOutQuad', function() { |
|
|
$.proxy(dropdown.event.resetStyle, this)(); |
|
|
|
|
|
|
|
|
$.proxy(module.event.resetStyle, this)(); |
|
|
callback(); |
|
|
callback(); |
|
|
}) |
|
|
}) |
|
|
; |
|
|
; |
|
@ -434,72 +434,72 @@ $.fn.dropdown = function(parameters) { |
|
|
.show() |
|
|
.show() |
|
|
.clearQueue() |
|
|
.clearQueue() |
|
|
.fadeOut(150, function() { |
|
|
.fadeOut(150, function() { |
|
|
$.proxy(dropdown.event.resetStyle, this)(); |
|
|
|
|
|
|
|
|
$.proxy(module.event.resetStyle, this)(); |
|
|
callback(); |
|
|
callback(); |
|
|
}) |
|
|
}) |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.error(error.transition); |
|
|
|
|
|
|
|
|
module.error(error.transition); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
show: function() { |
|
|
show: function() { |
|
|
dropdown.debug('Checking if dropdown can show'); |
|
|
|
|
|
if( dropdown.is.hidden() ) { |
|
|
|
|
|
dropdown.hideOthers(); |
|
|
|
|
|
dropdown.set.active(); |
|
|
|
|
|
dropdown.animate.show(dropdown.set.visible); |
|
|
|
|
|
if( dropdown.can.click() ) { |
|
|
|
|
|
dropdown.bind.intent(); |
|
|
|
|
|
|
|
|
module.debug('Checking if dropdown can show'); |
|
|
|
|
|
if( module.is.hidden() ) { |
|
|
|
|
|
module.hideOthers(); |
|
|
|
|
|
module.set.active(); |
|
|
|
|
|
module.animate.show(module.set.visible); |
|
|
|
|
|
if( module.can.click() ) { |
|
|
|
|
|
module.bind.intent(); |
|
|
} |
|
|
} |
|
|
$.proxy(settings.onShow, element)(); |
|
|
$.proxy(settings.onShow, element)(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
hide: function() { |
|
|
hide: function() { |
|
|
if( dropdown.is.visible() ) { |
|
|
|
|
|
dropdown.debug('Hiding dropdown'); |
|
|
|
|
|
if( dropdown.can.click() ) { |
|
|
|
|
|
dropdown.unbind.intent(); |
|
|
|
|
|
|
|
|
if( module.is.visible() ) { |
|
|
|
|
|
module.debug('Hiding dropdown'); |
|
|
|
|
|
if( module.can.click() ) { |
|
|
|
|
|
module.unbind.intent(); |
|
|
} |
|
|
} |
|
|
dropdown.remove.active(); |
|
|
|
|
|
dropdown.animate.hide(dropdown.remove.visible); |
|
|
|
|
|
|
|
|
module.remove.active(); |
|
|
|
|
|
module.animate.hide(module.remove.visible); |
|
|
$.proxy(settings.onHide, element)(); |
|
|
$.proxy(settings.onHide, element)(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
delay: { |
|
|
delay: { |
|
|
show: function() { |
|
|
show: function() { |
|
|
dropdown.verbose('Delaying show event to ensure user intent'); |
|
|
|
|
|
clearTimeout(dropdown.timer); |
|
|
|
|
|
dropdown.timer = setTimeout(dropdown.show, settings.delay.show); |
|
|
|
|
|
|
|
|
module.verbose('Delaying show event to ensure user intent'); |
|
|
|
|
|
clearTimeout(module.timer); |
|
|
|
|
|
module.timer = setTimeout(module.show, settings.delay.show); |
|
|
}, |
|
|
}, |
|
|
hide: function() { |
|
|
hide: function() { |
|
|
dropdown.verbose('Delaying hide event to ensure user intent'); |
|
|
|
|
|
clearTimeout(dropdown.timer); |
|
|
|
|
|
dropdown.timer = setTimeout(dropdown.hide, settings.delay.hide); |
|
|
|
|
|
|
|
|
module.verbose('Delaying hide event to ensure user intent'); |
|
|
|
|
|
clearTimeout(module.timer); |
|
|
|
|
|
module.timer = setTimeout(module.hide, settings.delay.hide); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
hideOthers: function() { |
|
|
hideOthers: function() { |
|
|
dropdown.verbose('Finding other dropdowns to hide'); |
|
|
|
|
|
$allDropdowns |
|
|
|
|
|
.not($dropdown) |
|
|
|
|
|
|
|
|
module.verbose('Finding other dropdowns to hide'); |
|
|
|
|
|
$allModules |
|
|
|
|
|
.not($module) |
|
|
.has(selector.menu + ':visible') |
|
|
.has(selector.menu + ':visible') |
|
|
.dropdown('hide') |
|
|
.dropdown('hide') |
|
|
; |
|
|
; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
toggle: function() { |
|
|
toggle: function() { |
|
|
dropdown.verbose('Toggling menu visibility'); |
|
|
|
|
|
if( dropdown.is.hidden() ) { |
|
|
|
|
|
dropdown.show(); |
|
|
|
|
|
|
|
|
module.verbose('Toggling menu visibility'); |
|
|
|
|
|
if( module.is.hidden() ) { |
|
|
|
|
|
module.show(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.hide(); |
|
|
|
|
|
|
|
|
module.hide(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -519,41 +519,41 @@ $.fn.dropdown = function(parameters) { |
|
|
internal: function(name, value) { |
|
|
internal: function(name, value) { |
|
|
if(value !== undefined) { |
|
|
if(value !== undefined) { |
|
|
if( $.isPlainObject(name) ) { |
|
|
if( $.isPlainObject(name) ) { |
|
|
$.extend(true, dropdown, name); |
|
|
|
|
|
|
|
|
$.extend(true, module, name); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown[name] = value; |
|
|
|
|
|
|
|
|
module[name] = value; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
return dropdown[name]; |
|
|
|
|
|
|
|
|
return module[name]; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
debug: function() { |
|
|
debug: function() { |
|
|
if(settings.debug) { |
|
|
if(settings.debug) { |
|
|
if(settings.performance) { |
|
|
if(settings.performance) { |
|
|
dropdown.performance.log(arguments); |
|
|
|
|
|
|
|
|
module.performance.log(arguments); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
|
|
|
|
dropdown.debug.apply(console, arguments); |
|
|
|
|
|
|
|
|
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
|
|
|
|
module.debug.apply(console, arguments); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
verbose: function() { |
|
|
verbose: function() { |
|
|
if(settings.verbose && settings.debug) { |
|
|
if(settings.verbose && settings.debug) { |
|
|
if(settings.performance) { |
|
|
if(settings.performance) { |
|
|
dropdown.performance.log(arguments); |
|
|
|
|
|
|
|
|
module.performance.log(arguments); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
|
|
|
|
dropdown.verbose.apply(console, arguments); |
|
|
|
|
|
|
|
|
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
|
|
|
|
module.verbose.apply(console, arguments); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
error: function() { |
|
|
error: function() { |
|
|
dropdown.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
|
|
|
|
dropdown.error.apply(console, arguments); |
|
|
|
|
|
|
|
|
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
|
|
|
|
module.error.apply(console, arguments); |
|
|
}, |
|
|
}, |
|
|
performance: { |
|
|
performance: { |
|
|
log: function(message) { |
|
|
log: function(message) { |
|
@ -574,8 +574,8 @@ $.fn.dropdown = function(parameters) { |
|
|
'Execution Time' : executionTime |
|
|
'Execution Time' : executionTime |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
clearTimeout(dropdown.performance.timer); |
|
|
|
|
|
dropdown.performance.timer = setTimeout(dropdown.performance.display, 100); |
|
|
|
|
|
|
|
|
clearTimeout(module.performance.timer); |
|
|
|
|
|
module.performance.timer = setTimeout(module.performance.display, 100); |
|
|
}, |
|
|
}, |
|
|
display: function() { |
|
|
display: function() { |
|
|
var |
|
|
var |
|
@ -583,7 +583,7 @@ $.fn.dropdown = function(parameters) { |
|
|
totalTime = 0 |
|
|
totalTime = 0 |
|
|
; |
|
|
; |
|
|
time = false; |
|
|
time = false; |
|
|
clearTimeout(dropdown.performance.timer); |
|
|
|
|
|
|
|
|
clearTimeout(module.performance.timer); |
|
|
$.each(performance, function(index, data) { |
|
|
$.each(performance, function(index, data) { |
|
|
totalTime += data['Execution Time']; |
|
|
totalTime += data['Execution Time']; |
|
|
}); |
|
|
}); |
|
@ -591,7 +591,6 @@ $.fn.dropdown = function(parameters) { |
|
|
if(dropdownSelector) { |
|
|
if(dropdownSelector) { |
|
|
title += ' \'' + dropdownSelector + '\''; |
|
|
title += ' \'' + dropdownSelector + '\''; |
|
|
} |
|
|
} |
|
|
title += ' ' + '(' + $allDropdowns.size() + ')'; |
|
|
|
|
|
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
|
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
|
console.groupCollapsed(title); |
|
|
console.groupCollapsed(title); |
|
|
if(console.table) { |
|
|
if(console.table) { |
|
@ -625,7 +624,7 @@ $.fn.dropdown = function(parameters) { |
|
|
found = instance[value]; |
|
|
found = instance[value]; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
dropdown.error(error.method); |
|
|
|
|
|
|
|
|
module.error(error.method); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -638,15 +637,15 @@ $.fn.dropdown = function(parameters) { |
|
|
|
|
|
|
|
|
if(methodInvoked) { |
|
|
if(methodInvoked) { |
|
|
if(instance === undefined) { |
|
|
if(instance === undefined) { |
|
|
dropdown.initialize(); |
|
|
|
|
|
|
|
|
module.initialize(); |
|
|
} |
|
|
} |
|
|
invokedResponse = dropdown.invoke(query); |
|
|
|
|
|
|
|
|
invokedResponse = module.invoke(query); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if(instance !== undefined) { |
|
|
if(instance !== undefined) { |
|
|
dropdown.destroy(); |
|
|
|
|
|
|
|
|
module.destroy(); |
|
|
} |
|
|
} |
|
|
dropdown.initialize(); |
|
|
|
|
|
|
|
|
module.initialize(); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
; |
|
|
; |
|
|