Skip to content

TagSpaces is an offline, open source, document manager with tagging support

refactoring

kristiyandda28a62bf6efb
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 0e29d6822..b0867e2e6 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -239,20 +239,6 @@ define(function(require, exports, module) {
Mousetrap.bind(tsSettings.getOpenFileExternallyKeyBinding(), function() {
TSCORE.IO.openFile(TSCORE.selectedFiles[0]);
});
- Mousetrap.unbind(TSCORE.Config.getPrevDocumentKeyBinding());
- Mousetrap.bind(TSCORE.Config.getPrevDocumentKeyBinding(), function() {
- if (TSCORE.selectedFiles[0]) {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(TSCORE.FileOpener.getOpenedFilePath()));
- }
- return false;
- });
- Mousetrap.unbind(TSCORE.Config.getNextDocumentKeyBinding());
- Mousetrap.bind(TSCORE.Config.getNextDocumentKeyBinding(), function() {
- if (TSCORE.selectedFiles[0]) {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(TSCORE.FileOpener.getOpenedFilePath()));
- }
- return false;
- });
}
function checkForNewVersion() {
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 9a82fa22b..d355401e6 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -2,7 +2,7 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-/* global define, Handlebars, isNode, isFirefox */
+/* global define, Handlebars, isNode, isFirefox, Mousetrap */
define(function(require, exports) {
'use strict';
@@ -64,6 +64,29 @@ define(function(require, exports) {
}
}
});
+
+ Mousetrap.unbind(TSCORE.Config.getPrevDocumentKeyBinding());
+ Mousetrap.bind(TSCORE.Config.getPrevDocumentKeyBinding(), function() {
+ if (TSCORE.selectedFiles[0]) {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(TSCORE.FileOpener.getOpenedFilePath()));
+ TSCORE.PerspectiveManager.selectFile(TSCORE.FileOpener.getOpenedFilePath());
+ } else {
+ console.log(TSCORE.fileList[0].path);
+ TSCORE.FileOpener.openFile(TSCORE.fileList[0].path);
+ }
+ return false;
+ });
+ Mousetrap.unbind(TSCORE.Config.getNextDocumentKeyBinding());
+ Mousetrap.bind(TSCORE.Config.getNextDocumentKeyBinding(), function() {
+ if (TSCORE.selectedFiles[0]) {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(TSCORE.FileOpener.getOpenedFilePath()));
+ TSCORE.PerspectiveManager.selectFile(TSCORE.FileOpener.getOpenedFilePath());
+ } else {
+ console.log(TSCORE.fileList[0].path);
+ TSCORE.FileOpener.openFile(TSCORE.fileList[0].path);
+ }
+ return false;
+ });
}
$('#addFileInput').on('change', function(selection) {
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index 4f3a38dd2..54d28e621 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -188,6 +188,19 @@ define(function(require, exports, module) {
}
}
+ function selectFile(filePath) {
+ for (var i = 0; i < perspectives.length; i++) {
+ if (perspectives[i].ID === TSCORE.currentPerspectiveID) {
+ try {
+ console.log(perspectives[i]);
+ return perspectives[i].selectFile(filePath);
+ } catch (e) {
+ console.warn("Error while executing 'selectFile' on " + perspectives[i].ID + ' ' + e);
+ }
+ }
+ }
+ }
+
function updateTreeData(treeData) {
for (var i = 0; i < perspectives.length; i++) {
try {
@@ -378,6 +391,7 @@ define(function(require, exports, module) {
exports.redrawCurrentPerspective = redrawCurrentPerspective;
exports.getNextFile = getNextFile;
exports.getPrevFile = getPrevFile;
+ exports.selectFile = selectFile;
exports.updateTreeData = updateTreeData;
exports.updateFileBrowserData = updateFileBrowserData;
exports.refreshFileListContainer = refreshFileListContainer;