mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 07:05:56 +00:00
* fox.form.Select: add several properties allowing it to better
imitate other controls like DropDownButton, etc. * rework several main toolbar items to use fox.form.Select instead of other controls * replace HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM with HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2 because of markup change (option instead of menuitem) * PluginHost: add some explicit typecasts to make intellephense shut up
This commit is contained in:
@@ -1,8 +1,66 @@
|
||||
/* global dijit, define */
|
||||
define(["dojo/_base/declare", "dijit/form/Select"], function (declare) {
|
||||
return declare("fox.form.Select", dijit.form.Select, {
|
||||
/* eslint-disable prefer-rest-params */
|
||||
/* global define */
|
||||
// FIXME: there probably is a better, more dojo-like notation for custom data- properties
|
||||
define(["dojo/_base/declare",
|
||||
"dijit/form/Select",
|
||||
"dojo/_base/lang", // lang.hitch
|
||||
"dijit/MenuItem",
|
||||
"dijit/MenuSeparator",
|
||||
"dojo/aspect",
|
||||
], function (declare, select, lang, MenuItem, MenuSeparator, aspect) {
|
||||
return declare("fox.form.Select", select, {
|
||||
focus: function() {
|
||||
return; // Stop dijit.form.Select from keeping focus after closing the menu
|
||||
},
|
||||
startup: function() {
|
||||
this.inherited(arguments);
|
||||
|
||||
if (this.attr('data-dropdown-skip-first') == 'true') {
|
||||
aspect.before(this, "_loadChildren", () => {
|
||||
this.options = this.options.splice(1);
|
||||
});
|
||||
}
|
||||
},
|
||||
// hook invoked when dropdown MenuItem is clicked
|
||||
onItemClick: function(/*item, menu*/) {
|
||||
//
|
||||
},
|
||||
_setValueAttr: function(/*anything*/ newValue, /*Boolean?*/ priorityChange){
|
||||
if (this.attr('data-prevent-value-change') == 'true' && newValue != '')
|
||||
return;
|
||||
|
||||
this.inherited(arguments);
|
||||
},
|
||||
// the only difference from dijit/form/Select is _onItemClicked() handler
|
||||
_getMenuItemForOption: function(/*_FormSelectWidget.__SelectOption*/ option){
|
||||
// summary:
|
||||
// For the given option, return the menu item that should be
|
||||
// used to display it. This can be overridden as needed
|
||||
if (!option.value && !option.label){
|
||||
// We are a separator (no label set for it)
|
||||
return new MenuSeparator({ownerDocument: this.ownerDocument});
|
||||
} else {
|
||||
// Just a regular menu option
|
||||
const click = lang.hitch(this, "_setValueAttr", option);
|
||||
const item = new MenuItem({
|
||||
option: option,
|
||||
label: (this.labelType === 'text' ? (option.label || '').toString()
|
||||
.replace(/&/g, '&').replace(/</g, '<') :
|
||||
option.label) || this.emptyLabel,
|
||||
onClick: () => {
|
||||
this.onItemClick(item, this.dropDown);
|
||||
|
||||
click();
|
||||
},
|
||||
ownerDocument: this.ownerDocument,
|
||||
dir: this.dir,
|
||||
textDir: this.textDir,
|
||||
disabled: option.disabled || false
|
||||
});
|
||||
item.focusNode.setAttribute("role", "option");
|
||||
|
||||
return item;
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user