Autocomplete on key press in some dropdown menus

This commit is contained in:
yflory
2017-03-06 12:18:12 +01:00
parent c04819538b
commit cb88227e2b
7 changed files with 112 additions and 16 deletions

View File

@@ -81,7 +81,7 @@ define([
editor.setOption('mode', mode);
if ($select) {
var name = $select.find('a[data-value="' + mode + '"]').text() || 'Mode';
$select.find('.buttonTitle').text(name);
$select.setValue(name);
}
};
@@ -110,7 +110,9 @@ define([
}
editor.setOption('theme', theme);
}
if ($select) { $select.find('.buttonTitle').text(theme || 'Theme'); }
if ($select) {
$select.setValue(theme || 'Theme');
}
};
}());
@@ -438,13 +440,14 @@ define([
text: 'Mode', // Button initial text
options: options, // Entries displayed in the menu
left: true, // Open to the left of the button
isSelect: true,
};
var $block = module.$language = Cryptpad.createDropdown(dropdownConfig);
var $button = $block.find('.buttonTitle');
$block.find('a').click(function (e) {
setMode($(this).attr('data-value'));
$button.text($(this).text());
setMode($(this).attr('data-value'), $block);
onLocal();
});
$rightside.append($block);
@@ -471,6 +474,8 @@ define([
text: 'Theme', // Button initial text
options: options, // Entries displayed in the menu
left: true, // Open to the left of the button
isSelect: true,
initialValue: lastTheme
};
var $block = module.$theme = Cryptpad.createDropdown(dropdownConfig);
var $button = $block.find('.buttonTitle');
@@ -480,7 +485,6 @@ define([
$block.find('a').click(function (e) {
var theme = $(this).attr('data-value');
setTheme(theme, $block);
$button.text($(this).text());
localStorage.setItem(themeKey, theme);
});