Browse Source

Fixes #949 popup and dropdown on sam element causes dropdown to show on popup visible

pull/1129/head
jlukic 10 years ago
parent
commit
9b01ca3e42
3 changed files with 67 additions and 30 deletions
  1. 63
      src/definitions/modules/dropdown.js
  2. 14
      src/definitions/modules/dropdown.less
  3. 20
      src/definitions/modules/popup.js

63
src/definitions/modules/dropdown.js

@ -139,19 +139,35 @@ $.fn.dropdown = function(parameters) {
}
},
select: function() {
module.debug('Dropdown initialized on a select, generating html');
// redefine module as wrapped element
$input = $module;
$module = $('<div />')
.attr('class', $input.attr('class') )
.addClass(className.selection)
.html( settings.templates.select(module.get.selectValues()))
.insertBefore($input)
;
$input
.removeAttr('class')
.prependTo($module)
var
selectValues = module.get.selectValues()
;
module.debug('Dropdown initialized on a select', selectValues);
// see if select exists inside a dropdown
$input = $module;
if($module.closest(className.dropdown) > 0) {
module.debug('Creating dropdown menu only from template');
$module = $module.closest(className.dropdown);
$('<div />')
.addClass(className.menu)
.html( settings.templates.menu( selectValues ))
.appendTo($module)
;
}
else {
module.debug('Creating entire dropdown from template');
$module = $('<div />')
.attr('class', $input.attr('class') )
.addClass(className.selection)
.html( settings.templates.dropdown(selectValues) )
.insertBefore($input)
;
$input
.removeAttr('class')
.prependTo($module)
;
}
module.refresh();
}
},
@ -483,7 +499,7 @@ $.fn.dropdown = function(parameters) {
callback = function() {
$search.val('');
module.determine.selectAction(text, value);
$.proxy(settings.onChange, element)(value, text);
$.proxy(settings.onChange, $choice[0])(value, text);
},
openingSubMenu = ($choice.find(selector.menu).size() > 0)
;
@ -1323,7 +1339,9 @@ $.fn.dropdown.settings = {
className : {
active : 'active',
disabled : 'disabled',
dropdown : 'ui dropdown',
filtered : 'filtered',
menu : 'menu',
placeholder : 'default',
search : 'search',
selected : 'selected',
@ -1334,7 +1352,24 @@ $.fn.dropdown.settings = {
};
$.fn.dropdown.settings.templates = {
select: function(select) {
menu: function(select) {
var
placeholder = select.placeholder || false,
values = select.values || {},
html = ''
;
html += '<div class="menu">';
$.each(select.values, function(value, name) {
if(value === name) {
html += '<div class="item">' + name + '</div>';
}
else {
html += '<div class="item" data-value="' + value + '">' + name + '</div>';
}
});
return html;
},
dropdown: function(select) {
var
placeholder = select.placeholder || false,
values = select.values || {},

14
src/definitions/modules/dropdown.less

@ -383,11 +383,6 @@ select.ui.dropdown {
color: @selectionVisibleTextColor;
}
/*
.ui.selection.dropdown .menu .active.item {
display: none;
}*/
/* Connecting Border */
.ui.active.selection.dropdown,
@ -423,10 +418,6 @@ select.ui.dropdown {
States
*******************************/
/* Dropdown Visible */
.ui.visible.dropdown > .menu {
display: block;
}
/*--------------------
Hover
@ -581,7 +572,10 @@ select.ui.dropdown {
overflow: hidden;
}
/* Visible */
.ui.simple.visible.dropdown > .menu {
display: block;
}
/*--------------
Fluid

20
src/definitions/modules/popup.js

@ -139,7 +139,7 @@ $.fn.popup = function(parameters) {
;
clearTimeout(module.hideTimer);
module.showTimer = setTimeout(function() {
if( module.is.hidden() ) {
if( module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
module.show();
}
}, delay);
@ -647,12 +647,18 @@ $.fn.popup = function(parameters) {
},
is: {
active: function() {
return $module.hasClass(className.active);
},
animating: function() {
return ( $popup && $popup.is(':animated') || $popup.hasClass(className.animating) );
},
visible: function() {
return $popup && $popup.is(':visible');
},
dropdown: function() {
return $module.hasClass(className.dropdown);
},
hidden: function() {
return !module.is.visible();
}
@ -909,11 +915,13 @@ $.fn.popup.settings = {
},
className : {
animating : 'animating',
loading : 'loading',
popup : 'ui popup',
position : 'top left center bottom right',
visible : 'visible'
active : 'active',
animating : 'animating',
dropdown : 'dropdown',
loading : 'loading',
popup : 'ui popup',
position : 'top left center bottom right',
visible : 'visible'
},
selector : {

Loading…
Cancel
Save