Fixed title editing issue on IE

This commit is contained in:
benweet 2014-09-06 01:09:35 +01:00
parent d33037e18d
commit f3b32e8d03

View File

@ -155,17 +155,22 @@ define([
$(".action-remove-file").click(function() { $(".action-remove-file").click(function() {
fileMgr.deleteFile(); fileMgr.deleteFile();
}); });
var titleEditing;
$fileTitleElt.click(function() { $fileTitleElt.click(function() {
if(window.viewerMode === true) { if(window.viewerMode === true) {
return; return;
} }
$fileTitleElt.addClass('hide'); $fileTitleElt.addClass('hide');
var fileTitleInput = $fileTitleInputElt.removeClass('hide'); var fileTitleInput = $fileTitleInputElt.removeClass('hide');
titleEditing = true;
setTimeout(function() { setTimeout(function() {
fileTitleInput.focus().get(0).select(); fileTitleInput.focus().get(0).select();
}, 10); }, 10);
}); });
function applyTitle() { function applyTitle() {
if(!titleEditing) {
return;
}
$fileTitleInputElt.addClass('hide'); $fileTitleInputElt.addClass('hide');
$fileTitleElt.removeClass('hide'); $fileTitleElt.removeClass('hide');
var title = $.trim($fileTitleInputElt.val()); var title = $.trim($fileTitleInputElt.val());
@ -176,12 +181,17 @@ define([
} }
$fileTitleInputElt.val(fileDesc.title); $fileTitleInputElt.val(fileDesc.title);
$editorElt.focus(); $editorElt.focus();
titleEditing = false;
} }
$fileTitleInputElt.blur(function() { $fileTitleInputElt.blur(function() {
setTimeout(function() {
applyTitle(); applyTitle();
}).keyup(function(e) { }, 0);
}).keypress(function(e) {
if(e.keyCode == 13) { if(e.keyCode == 13) {
applyTitle(); applyTitle();
e.preventDefault();
} }
if(e.keyCode == 27) { if(e.keyCode == 27) {
$fileTitleInputElt.val(""); $fileTitleInputElt.val("");