Fixed smart upload button issues (Bug #2615)
This commit is contained in:
parent
bcd865a8e5
commit
de8067b119
1 changed files with 25 additions and 5 deletions
|
@ -383,10 +383,15 @@ function kolab_files_upload_input(button)
|
||||||
file = $('<input>'),
|
file = $('<input>'),
|
||||||
offset = link.offset();
|
offset = link.offset();
|
||||||
|
|
||||||
|
function move_file_input(e) {
|
||||||
|
file.css({top: (e.pageY - offset.top - 10) + 'px', left: (e.pageX - offset.left - 10) + 'px'});
|
||||||
|
}
|
||||||
|
|
||||||
file.attr({name: 'file[]', type: 'file', multiple: 'multiple', size: 5})
|
file.attr({name: 'file[]', type: 'file', multiple: 'multiple', size: 5})
|
||||||
.change(function() { rcmail.files_upload('#filesuploadform'); })
|
.change(function() { rcmail.files_upload('#filesuploadform'); })
|
||||||
|
.click(function() { setTimeout(function() { link.mouseleave(); }, 20); })
|
||||||
// opacity:0 does the trick, display/visibility doesn't work
|
// opacity:0 does the trick, display/visibility doesn't work
|
||||||
.css({opacity: 0, cursor: 'pointer', outline: 'none', position: 'absolute', top: '10000px', left: '10000px'});
|
.css({opacity: 0, cursor: 'pointer', outline: 'none', position: 'absolute'});
|
||||||
|
|
||||||
// In FF and IE we need to move the browser file-input's button under the cursor
|
// In FF and IE we need to move the browser file-input's button under the cursor
|
||||||
// Thanks to the size attribute above we know the length of the input field
|
// Thanks to the size attribute above we know the length of the input field
|
||||||
|
@ -394,17 +399,32 @@ function kolab_files_upload_input(button)
|
||||||
file.css({marginLeft: '-80px'});
|
file.css({marginLeft: '-80px'});
|
||||||
|
|
||||||
// Note: now, I observe problem with cursor style on FF < 4 only
|
// Note: now, I observe problem with cursor style on FF < 4 only
|
||||||
link.css({overflow: 'hidden', cursor: 'pointer'})
|
// Need position: relative (Bug #2615)
|
||||||
|
link.css({overflow: 'hidden', cursor: 'pointer', position: 'relative'})
|
||||||
|
.mouseenter(function() { this.__isactive = true; })
|
||||||
// place button under the cursor
|
// place button under the cursor
|
||||||
.mousemove(function(e) {
|
.mousemove(function(e) {
|
||||||
if (rcmail.commands['files-upload'])
|
if (rcmail.commands['files-upload'] && this.__isactive)
|
||||||
file.css({top: (e.pageY - offset.top - 10) + 'px', left: (e.pageX - offset.left - 10) + 'px'});
|
move_file_input(e);
|
||||||
// move the input away if button is disabled
|
// move the input away if button is disabled
|
||||||
else
|
else
|
||||||
$(this).mouseleave();
|
$(this).mouseleave();
|
||||||
})
|
})
|
||||||
.mouseleave(function() { file.css({top: '10000px', left: '10000px'}); })
|
.mouseleave(function() {
|
||||||
|
file.css({top: '-10000px', left: '-10000px'});
|
||||||
|
this.__isactive = false;
|
||||||
|
})
|
||||||
.attr('onclick', '') // remove default button action
|
.attr('onclick', '') // remove default button action
|
||||||
|
.click(function(e) {
|
||||||
|
// forward click if mouse-enter event was missed
|
||||||
|
if (this.__isactive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.__isactive = true;
|
||||||
|
move_file_input(e);
|
||||||
|
file.trigger(e);
|
||||||
|
})
|
||||||
|
.mouseleave() // initially disable/hide input
|
||||||
.append(file);
|
.append(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue