Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Needham <tom@owncloud.com>2015-11-04 17:40:24 +0300
committerTom Needham <needham.thomas@gmail.com>2015-11-25 15:28:10 +0300
commit171cf42cfebe4969dc87ef1ab58180669991bacb (patch)
tree2e91988d265397efd658d402f992508445b51c95 /js/editor.js
parentc5a39a4eb6f3cf1f69bdc715a9a62aaf949af40d (diff)
Implement closing when clicking outside the editor container
Use correct selector
Diffstat (limited to 'js/editor.js')
-rw-r--r--js/editor.js30
1 files changed, 29 insertions, 1 deletions
diff --git a/js/editor.js b/js/editor.js
index b90fd13..296fb8f 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -282,6 +282,7 @@ var Files_Texteditor = {
// Show the controls
_self.loadControlBar(file, _self.currentContext);
window.aceEditor.getSession().on('change', _self.setupAutosave);
+ _self.bindVisibleActions();
window.aceEditor.focus();
if (_self.previewPlugins[file.mime]){
@@ -518,6 +519,7 @@ var Files_Texteditor = {
closeEditor: function() {
this.$container.html('').show();
this.unloadControlBar();
+ this.unBindVisibleActions();
if (this.fileInfoModel) {
this.fileInfoModel.set({
// temp dummy, until we can do a PROPFIND
@@ -535,6 +537,7 @@ var Files_Texteditor = {
hideEditor: function() {
this.$container.hide();
document.title = this.oldTitle;
+ this.unBindVisibleActions();
},
/**
@@ -543,7 +546,32 @@ var Files_Texteditor = {
setupAutosave: function() {
clearTimeout(this.saveTimer);
this.saveTimer = setTimeout(OCA.Files_Texteditor._onSaveTrigger, 3000);
- }
+ },
+
+ /**
+ * Handles event when clicking outside editor
+ */
+ _onClickDocument: function(event) {
+ // Check if click was inside the editor or not.
+ if(!$(event.target).closest('#editor_container').length) {
+ // Edit the editor
+ OCA.Files_Texteditor._onCloseTrigger();
+ }
+ },
+
+ /*
+ * Binds actions that need to happen whilst the editor is visible
+ */
+ bindVisibleActions: function() {
+ $(document).bind('click', this._onClickDocument);
+ },
+
+ /**
+ * Unbinds actions that happen whilst the editor is visible
+ */
+ unBindVisibleActions: function() {
+ $(document).unbind('click', this._onClickDocument);
+ }
};