Skip to content

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

initPerspectives merged with TS133-index-text-content

Borislav Sapundzhiev3b07ee10e9cf
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 315392a2c..52ce5ec65 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -58,7 +58,12 @@ define(function(require, exports, module) {
tsDirectoriesUI.initUI();
tsDirectoriesUI.initLocations();
tsFileOpener.initUI();
- tsPersManager.initPerspectives();
+ tsPersManager.initPerspectives().then(function(result) {
+ console.log("initPerspectives: " + result);
+ }).catch(function(err) {
+ alert("initPerspectives: " + err);
+ });
+
hideLoadingAnimation();
$(document).ready(function() {
initLayout();
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index 1d3598dac..b8393890b 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -8,7 +8,7 @@ define(function(require, exports, module) {
var TSCORE = require('tscore');
var TSPRO = require("tspro");
- var initPerspectives = function() {
+ var initPerspectivesOLD = function() {
perspectives = [];
$('#viewSwitcher').empty();
$('#viewToolbars').empty();
@@ -53,11 +53,74 @@ define(function(require, exports, module) {
if (isNode) {
TSCORE.IO.showMainWindow();
}
+
}
}
}); // jshint ignore:line
}
};
+
+ function initPerspective(extPath) {
+
+ return new Promise(function(resolve, reject) {
+
+ require([extPath], function(perspective) {
+ perspectives.push(perspective);
+
+ // Creating perspective's toolbar
+ $('#viewToolbars').append($('<div>', {
+ id: perspective.ID + 'Toolbar',
+ class: 'btn-toolbar'
+ }).hide());
+ // Creating perspective's container
+ $('#viewContainers').append($('<div>', {
+ id: perspective.ID + 'Container',
+ style: 'width: 100%; height: 100%'
+ }).hide());
+ // Creating perspective's footer
+ $('#viewFooters').append($('<div>', {
+ id: perspective.ID + 'Footer'
+ }).hide());
+ //TODO: return init as promise
+ perspective.init();
+ resolve(true);
+ }); // jshint ignore:line
+ });
+ }
+
+ function initPerspectives() {
+
+ perspectives = [];
+ $('#viewSwitcher').empty();
+ $('#viewToolbars').empty();
+ $('#viewContainers').empty();
+ $('#viewFooters').empty();
+ initWelcomeScreen();
+
+ var extensions = TSCORE.Config.getPerspectives();
+ var promises = [];
+ for (var i = 0; i < extensions.length; i++) {
+ var extPath = TSCORE.Config.getExtensionPath() + '/' + extensions[i].id + '/extension.js';
+ promises.push(initPerspective(extPath));
+ }
+
+ return Promise.all(promises).then(function() {
+ initPerspectiveSwitcher();
+ // Opening last saved location by the start of the application (not in firefox)
+ var lastLocation = TSCORE.Config.getLastOpenedLocation();
+ if (lastLocation !== undefined && lastLocation.length >= 1 && !isFirefox) {
+ TSCORE.openLocation(lastLocation);
+ TSCORE.IO.checkAccessFileURLAllowed();
+ var evt = TSCORE.createDocumentEvent("initApp");
+ TSCORE.fireDocumentEvent(evt);
+ }
+ $('#loading').hide();
+ if (isNode) {
+ TSCORE.IO.showMainWindow();
+ }
+ return true;
+ });
+ }
var initWelcomeScreen = function() {
/* require([