Skip to content

Commit

Permalink
focus editor on (re)open, hide notification correctly (fixes reusing …
Browse files Browse the repository at this point in the history
…editor), use on instead of live
  • Loading branch information
butonic committed Aug 1, 2013
1 parent ad8d47b commit 881d284
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions files_texteditor/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ function showControls(dir, filename, writeable) {
}

function bindControlEvents() {
$("#editor_save").die('click', doFileSave).live('click', doFileSave);
$('#editor_close').die('click', hideFileEditor).live('click', hideFileEditor);
$('#editorsearchval').die('keyup', doSearch).live('keyup', doSearch);
$('#clearsearchbtn').die('click', resetSearch).live('click', resetSearch);
$('#nextsearchbtn').die('click', nextSearchResult).live('click', nextSearchResult);
$('#content').on('click', '#editor_save', doFileSave);
$('#content').on('click', '#editor_close', hideFileEditor);
$('#content').on('keyup', '#editorsearchval', doSearch);
$('#content').on('click', '#clearsearchbtn', resetSearch);
$('#content').on('click', '#nextsearchbtn', nextSearchResult);
}

// returns true or false if the editor is in view or not
Expand Down Expand Up @@ -191,6 +191,9 @@ function showFileEditor(dir, filename) {
if (!editorIsShown()) {
is_editor_shown = true;
// Delete any old editors
if ($('#notification').data('reopeneditor')) {
OC.Notification.hide();
}
$('#editor').remove();
// Loads the file editor and display it.
$('#content').append('<div id="editor"></div>');
Expand Down Expand Up @@ -246,6 +249,7 @@ function showFileEditor(dir, filename) {
doFileSave();
}
});
giveEditorFocus();
} else {
// Failed to get the file.
OC.dialogs.alert(result.data.message, t('files_texteditor', 'An error occurred!'));
Expand Down Expand Up @@ -294,6 +298,7 @@ function reopenEditor() {
OC.Breadcrumb.push($('#editor').attr('data-filename') + ' *', '#');
document.title = $('#editor').attr('data-filename') + ' * - ownCloud';
is_editor_shown = true;
giveEditorFocus();
}

// resizes the editor window
Expand Down Expand Up @@ -352,7 +357,7 @@ $(document).ready(function () {
$('#notification').click(function () {
if ($('#notification').data('reopeneditor')) {
reopenEditor();
OC.Notification.hide();
}
$('#notification').fadeOut();
});
});

0 comments on commit 881d284

Please sign in to comment.