Skip to content

Commit

Permalink
Rebuild dist for jsfiddle #2637
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Aug 11, 2015
1 parent 50264e3 commit d4143c1
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 89 deletions.
114 changes: 74 additions & 40 deletions dist/components/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ $.fn.dropdown = function(parameters) {
});
}
},
menu: function() {
$menu = $('<div />')
.addClass(className.menu)
.appendTo($module)
;
}
},

search: function(query) {
Expand Down Expand Up @@ -268,6 +274,9 @@ $.fn.dropdown = function(parameters) {
module.setup.select();
module.setup.returnedObject();
}
if( !module.has.menu() ) {
module.create.menu();
}
if( module.is.search() && !module.has.search() ) {
module.verbose('Adding search input');
$search = $('<input />')
Expand All @@ -278,12 +287,6 @@ $.fn.dropdown = function(parameters) {
if(settings.allowTab) {
module.set.tabbable();
}
if($menu.length === 0) {
$menu = $('<div />')
.addClass(className.menu)
.appendTo($module)
;
}
},
select: function() {
var
Expand All @@ -297,7 +300,10 @@ $.fn.dropdown = function(parameters) {
if($input.parent(selector.dropdown).length > 0) {
module.debug('UI dropdown already exists. Creating dropdown menu only');
$module = $input.closest(selector.dropdown);
$menu = $module.children(selector.menu);
if( !module.has.menu() ) {
module.create.menu();
}
$menu = $module.children(selector.menu);
module.setup.menu(selectValues);
}
else {
Expand Down Expand Up @@ -400,10 +406,11 @@ $.fn.dropdown = function(parameters) {
;
if( module.can.show() && !module.is.active() ) {
module.debug('Showing dropdown');
if(module.is.multiple()) {
if(!module.has.search() && module.is.allFiltered()) {
return true;
}
if(module.is.multiple() && !module.has.search() && module.is.allFiltered()) {
return true;
}
if(module.has.message() && !module.has.maxSelections()) {
module.remove.message();
}
module.animate.show(function() {
if( module.can.click() ) {
Expand Down Expand Up @@ -668,7 +675,7 @@ $.fn.dropdown = function(parameters) {
beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm')
;
// avoid loop if we're matching nothing
if(searchTerm === '') {
if( !module.has.query() ) {
$results = $item;
}
else {
Expand Down Expand Up @@ -765,7 +772,7 @@ $.fn.dropdown = function(parameters) {
: $activeItem,
hasSelected = ($selectedItem.size() > 0)
;
if(hasSelected) {
if( hasSelected && module.has.query() ) {
module.debug('Forcing partial selection to selected item', $selectedItem);
module.event.item.click.call($selectedItem);
}
Expand Down Expand Up @@ -903,7 +910,9 @@ $.fn.dropdown = function(parameters) {
touch: function(event) {
module.determine.eventOnElement(event, function() {
if(event.type == 'touchstart') {
module.timer = setTimeout(module.hide, settings.delay.touch);
module.timer = setTimeout(function() {
module.hide();
}, settings.delay.touch);
}
else if(event.type == 'touchmove') {
clearTimeout(module.timer);
Expand Down Expand Up @@ -953,15 +962,17 @@ $.fn.dropdown = function(parameters) {
}, settings.delay.hide);
}
},
touchend: function() {
},
click: function (event) {
var
$choice = $(this),
$target = (event)
$choice = $(this),
$target = (event)
? $(event.target)
: $(''),
$subMenu = $choice.find(selector.menu),
text = module.get.choiceText($choice),
value = module.get.choiceValue($choice, text),
$subMenu = $choice.find(selector.menu),
text = module.get.choiceText($choice),
value = module.get.choiceValue($choice, text),
hasSubMenu = ($subMenu.length > 0),
isBubbledEvent = ($subMenu.find($target).length > 0)
;
Expand Down Expand Up @@ -1361,6 +1372,15 @@ $.fn.dropdown = function(parameters) {
id: function() {
return id;
},
defaultText: function() {
return $module.data(metadata.defaultText);
},
defaultValue: function() {
return $module.data(metadata.defaultValue);
},
placeholderText: function() {
return $module.data(metadata.placeholderText) || '';
},
text: function() {
return $text.text();
},
Expand Down Expand Up @@ -1626,7 +1646,7 @@ $.fn.dropdown = function(parameters) {
;
shouldSearch = (isMultiple)
? (value.length > 0)
: (value !== undefined && value !== '' && value !== null)
: (value !== undefined && value !== null)
;
isMultiple = (module.is.multiple() && $.isArray(value));
strict = (value === '' || value === 0)
Expand Down Expand Up @@ -1711,15 +1731,21 @@ $.fn.dropdown = function(parameters) {
},
defaultText: function() {
var
defaultText = $module.data(metadata.defaultText)
defaultText = module.get.defaultText(),
placeholderText = module.get.placeholderText
;
module.debug('Restoring default text', defaultText);
module.set.text(defaultText);
$text.addClass(className.placeholder);
if(defaultText === placeholderText) {
module.debug('Restoring default placeholder text', defaultText);
module.set.placeholderText(defaultText);
}
else {
module.debug('Restoring default text', defaultText);
module.set.text(defaultText);
}
},
defaultValue: function() {
var
defaultValue = $module.data(metadata.defaultValue)
defaultValue = module.get.defaultValue()
;
if(defaultValue !== undefined) {
module.debug('Restoring default value', defaultValue);
Expand Down Expand Up @@ -1831,7 +1857,7 @@ $.fn.dropdown = function(parameters) {
var
text
;
if($text.hasClass(className.placeholder)) {
if(settings.placeholder !== false && $text.hasClass(className.placeholder)) {
text = module.get.text();
module.verbose('Saving placeholder text as', text);
$module.data(metadata.placeholderText, text);
Expand Down Expand Up @@ -1865,8 +1891,8 @@ $.fn.dropdown = function(parameters) {

scrollPage: function(direction, $selectedItem) {
var
$selectedItem = $selectedItem || module.get.selectedItem(),
$menu = $selectedItem.closest(selector.menu),
$currentItem = $selectedItem || module.get.selectedItem(),
$menu = $currentItem.closest(selector.menu),
menuHeight = $menu.outerHeight(),
currentScroll = $menu.scrollTop(),
itemHeight = $item.eq(0).outerHeight(),
Expand All @@ -1881,8 +1907,8 @@ $.fn.dropdown = function(parameters) {
elementIndex
;
elementIndex = (direction == 'up')
? $selectableItem.index($selectedItem) - itemsPerPage
: $selectableItem.index($selectedItem) + itemsPerPage
? $selectableItem.index($currentItem) - itemsPerPage
: $selectableItem.index($currentItem) + itemsPerPage
;
isWithinRange = (direction == 'up')
? (elementIndex >= 0)
Expand All @@ -1896,7 +1922,7 @@ $.fn.dropdown = function(parameters) {
;
if($nextSelectedItem.length > 0) {
module.debug('Scrolling page', direction, $nextSelectedItem);
$selectedItem
$currentItem
.removeClass(className.selected)
;
$nextSelectedItem
Expand Down Expand Up @@ -1938,12 +1964,10 @@ $.fn.dropdown = function(parameters) {
$module.addClass(className.loading);
},
placeholderText: function(text) {
text = text || $module.data(metadata.placeholderText);
if(text) {
module.debug('Restoring placeholder text');
module.set.text(text);
$text.addClass(className.placeholder);
}
text = text || module.get.placeholderText();
module.debug('Setting placeholder text', text);
module.set.text(text);
$text.addClass(className.placeholder);
},
tabbable: function() {
if( module.has.search() ) {
Expand Down Expand Up @@ -2026,10 +2050,12 @@ $.fn.dropdown = function(parameters) {
}
}
else {
if(text !== module.get.placeholderText()) {
$text.removeClass(className.placeholder);
}
module.debug('Changing text', text, $text);
$text
.removeClass(className.filtered)
.removeClass(className.placeholder)
;
if(settings.preserveHTML) {
$text.html(text);
Expand Down Expand Up @@ -2115,8 +2141,13 @@ $.fn.dropdown = function(parameters) {
module.debug('Updating input value', value, currentValue);
$input
.val(value)
.trigger('change')
;
if(settings.fireOnInit === false && module.is.initialLoad()) {
module.debug('Input native change event ignored on initial load');
}
else {
$input.trigger('change');
}
}
else {
module.verbose('Storing value in metadata', value, $input);
Expand Down Expand Up @@ -2395,7 +2426,7 @@ $.fn.dropdown = function(parameters) {
}

if(settings.fireOnInit === false && module.is.initialLoad()) {
module.verbose('No callback on initial load', settings.onAdd);
module.verbose('Skipping onadd callback on initial load', settings.onAdd);
}
else {
settings.onAdd.call(element, addedValue, addedText, $selectedItem);
Expand Down Expand Up @@ -2645,6 +2676,9 @@ $.fn.dropdown = function(parameters) {
allResultsFiltered: function() {
return ($item.filter(selector.unselectable).length === $item.length);
},
query: function() {
return (module.get.query() !== '');
},
value: function(value) {
var
values = module.get.values(),
Expand Down
5 changes: 3 additions & 2 deletions dist/components/dropdown.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit d4143c1

Please sign in to comment.