Fix select file via MenuItem in Firefox
instead of an inline FileButton, just use an unattached input element to trigger the select file dialog.
This commit is contained in:
parent
c4413d9fd7
commit
03c2f9f3a1
2 changed files with 32 additions and 26 deletions
|
@ -463,10 +463,6 @@ Ox.Menu = function(options, self) {
|
||||||
item = that.items[self.options.selected];
|
item = that.items[self.options.selected];
|
||||||
if (item) {
|
if (item) {
|
||||||
item.removeClass('OxSelected');
|
item.removeClass('OxSelected');
|
||||||
if (item.options('file')) {
|
|
||||||
item.$button.blurButton();
|
|
||||||
that.bindEvent({key_enter: clickSelectedItem})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* disabled
|
/* disabled
|
||||||
that.triggerEvent('deselect', {
|
that.triggerEvent('deselect', {
|
||||||
|
@ -485,10 +481,6 @@ Ox.Menu = function(options, self) {
|
||||||
});
|
});
|
||||||
item.options('items').length && that.submenus[item.options('id')].showMenu();
|
item.options('items').length && that.submenus[item.options('id')].showMenu();
|
||||||
item.addClass('OxSelected');
|
item.addClass('OxSelected');
|
||||||
if (item.options('file')) {
|
|
||||||
item.$button.focusButton();
|
|
||||||
that.unbindEvent('key_enter');
|
|
||||||
}
|
|
||||||
that.triggerEvent('select', {
|
that.triggerEvent('select', {
|
||||||
id: item.options('id'),
|
id: item.options('id'),
|
||||||
title: Ox.isString(item.options('title')[0])
|
title: Ox.isString(item.options('title')[0])
|
||||||
|
|
|
@ -51,9 +51,6 @@ Ox.MenuItem = function(options, self) {
|
||||||
that[
|
that[
|
||||||
self.options.disabled ? 'addClass' : 'removeClass'
|
self.options.disabled ? 'addClass' : 'removeClass'
|
||||||
]('OxDisabled');
|
]('OxDisabled');
|
||||||
self.options.file && that.$button.options({
|
|
||||||
disabled: self.options.disabled
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
keyboard: function() {
|
keyboard: function() {
|
||||||
self.options.keyboard = parseKeyboard(self.options.keyboard);
|
self.options.keyboard = parseKeyboard(self.options.keyboard);
|
||||||
|
@ -77,6 +74,27 @@ Ox.MenuItem = function(options, self) {
|
||||||
self.options.checked = false;
|
self.options.checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.options.file) {
|
||||||
|
self.$input = $('<input>')
|
||||||
|
.attr(
|
||||||
|
Ox.extend({
|
||||||
|
type: 'file'
|
||||||
|
}, self.options.file.multiple ? {
|
||||||
|
multiple: true
|
||||||
|
} : {})
|
||||||
|
)
|
||||||
|
.on({
|
||||||
|
change: function(event) {
|
||||||
|
var filelist = this.files
|
||||||
|
var files = [];
|
||||||
|
Ox.loop(filelist.length, function(i) {
|
||||||
|
files.push(filelist.item(i));
|
||||||
|
});
|
||||||
|
self.options.menu.clickItem(self.options.position, files);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
that.append(
|
that.append(
|
||||||
that.$status = Ox.$('<td>')
|
that.$status = Ox.$('<td>')
|
||||||
.addClass('OxCell OxStatus')
|
.addClass('OxCell OxStatus')
|
||||||
|
@ -104,21 +122,17 @@ Ox.MenuItem = function(options, self) {
|
||||||
: {}
|
: {}
|
||||||
)
|
)
|
||||||
.html(
|
.html(
|
||||||
self.options.file
|
|
||||||
? that.$button = Ox.FileButton(Ox.extend({
|
|
||||||
disabled: self.options.disabled,
|
|
||||||
title: self.options.title[0]
|
|
||||||
}, self.options.file)).bindEvent({
|
|
||||||
click: function(data) {
|
|
||||||
self.options.menu.clickItem(self.options.position, data.files);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
: (
|
|
||||||
Ox.isString(self.options.title[0])
|
Ox.isString(self.options.title[0])
|
||||||
? self.options.title[0]
|
? self.options.title[0]
|
||||||
: Ox.$('<div>').html(self.options.title[0]).html()
|
: Ox.$('<div>').html(self.options.title[0]).html()
|
||||||
)
|
).on({
|
||||||
)
|
click: self.options.file ? function(event) {
|
||||||
|
!self.options.disabled && self.$input.click()
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
} : null
|
||||||
|
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.append(
|
.append(
|
||||||
that.$modifiers = Ox.$('<td>')
|
that.$modifiers = Ox.$('<td>')
|
||||||
|
|
Loading…
Reference in a new issue