Skip to content

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

improving require integration

uggrock9228fa135824
diff --git a/data/js/fileviewer.ui.js b/data/js/fileviewer.ui.js
index d007aa622..a3ac52ca7 100644
--- a/data/js/fileviewer.ui.js
+++ b/data/js/fileviewer.ui.js
@@ -3,7 +3,9 @@
* can be found in the LICENSE file. */
//define(function(require, exports, module) {
//"use strict";
-
+// console.log(module.id);
+// console.log(module.uri);
+
console.debug("Loading FileViewer...");
var FileViewer = (typeof FileViewer == 'object' && FileViewer != null) ? FileViewer : {};
@@ -33,8 +35,8 @@ FileViewer.openFile = function(fileName) {
console.debug("File Viewer: "+viewerExt);
// TODO Consider page width by opening, e.g. responsive design
- layoutContainer.open("east");
- // layoutContainer.close("west");
+ UIAPI.layoutContainer.open("east");
+ // UIAPI.layoutContainer.close("west");
UIAPI.isFileOpened = true;
@@ -87,7 +89,9 @@ FileViewer.constructFileViewerUI = function(fileName, filePath) {
// Generate tag buttons
$( "#fileTags" ).empty();
for (var i=0; i < tags.length; i++) {
- $( "#fileTags" ).append('<button title="Opens context menu for '+tags[i]+'" tag="'+tags[i]+'" filename="'+fileName+'" class="tagButton">'+tags[i]+'</button>');
+ $( "#fileTags" ).append( // title="Opens context menu for '+tags[i]+'"
+ $("<button>", { class: "tagButton", tag: tags[i], filename: fileName }).text(tags[i])
+ );
};
// Activate tagButtons in file view
@@ -179,8 +183,8 @@ FileViewer.addCloseButton = function(container) {
})
.click(function() {
UIAPI.isFileOpened = false;
- layoutContainer.open("west");
- layoutContainer.close("east");
+ UIAPI.layoutContainer.open("west");
+ UIAPI.layoutContainer.close("east");
});
}
diff --git a/data/js/main.js b/data/js/main.js
index a0a67930a..370cfb42f 100644
--- a/data/js/main.js
+++ b/data/js/main.js
@@ -10,20 +10,10 @@ define([
'jsoneditor',
'less'
], function($){
-"use strict";
+"use strict";
-var layoutContainer = undefined;
-
-var initUI = function(){
+var initApp = function(){
console.debug("Initializing UI...");
-/*
- var FileViewer = undefined;
- var TagsUI = undefined;
- var BasicViewsUI = undefined;
- var SettingsUI = undefined;
-// var IOAPI = undefined;
- var UIAPI = undefined;
-*/
var editor = undefined; // Needed for JSON Editor
// Setting up the communication between the extension and tagspace app
@@ -37,7 +27,8 @@ var initUI = function(){
"js/ioapi.chrome"
]);
}
-
+
+ // TODO refactor all libs for integration of backbone.js
require([
"js/fileviewer.ui",
"js/tags.ui",
@@ -48,7 +39,12 @@ var initUI = function(){
"js/tagspace.api",
"js/directories.ui",
],
- function() {
+ function() {
+ /* $(document).ready({
+ layoutContainer = initLayout();
+ });*/
+ UIAPI.initLayout();
+
TagsUI.initContextMenus();
TagsUI.initDialogs();
TagsUI.initTagTree();
@@ -69,12 +65,14 @@ var initUI = function(){
TSSETTINGS.loadSettingsLocalStorage();
- // By empty local storage and a mozilla browser, trying to load from mozilla preferences
+ // In firefox, by empty local storage trying to load fteh settings from mozilla preferences
if(TSSETTINGS.Settings == undefined && $.browser.mozilla) {
setTimeout(IOAPI.loadSettings, 1000); // executes initUI and updateSettingMozillaPreferences by success
console.debug("Loading setting with from mozilla pref execured with delay...");
}
+ // If still nothing found, loading the default setting from the application javascript
+ // This is usually the case by a new installation
if(TSSETTINGS.Settings == undefined) {
TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
}
@@ -83,104 +81,8 @@ var initUI = function(){
});
}
-var initLayout = function(){
- console.debug("Initializing Layout...");
- layoutContainer = $('#container').layout(
- {
- fxName: "none"
-
- // some resizing/toggling settings
- , north__resizable: false // OVERRIDE the pane-default of 'slidable=true'
- , north__spacing_open: 0 // no resizer-bar when open (zero height)
- // , north__togglerLength_closed: '100%' // toggle-button is full-width of resizer-bar
- // , north__spacing_closed: 20 // big resizer-bar when open (zero height)
- , north__size: 33
-
- , south__resizable: false // OVERRIDE the pane-default of 'resizable=true'
- , south__spacing_open: 0 // no resizer-bar when open (zero height)
- // , south__spacing_closed: 20 // big resizer-bar when open (zero height)
-
- // west settings
- , west__resizable: true
- , west__minSize: .1
-// , west__maxSize: .4
- , west__size: 200
- , west__spacing_open: 3
-
- // east settings
- , east__resizable: true
- , east__size: .45
- , east__minSize: .2
-// , east__maxSize: .8 // 80% of layout width
- , east__spacing_open: 3
-
- // center settings
- , center__resizable: true
- , center__minSize: 0.5
-
- // enable showOverflow on west-pane so CSS popups will overlap north pane
- , west__showOverflowOnHover: true
-
- // enable state management
- , stateManagement__enabled: false // automatic cookie load & save enabled by default
-
- , showDebugMessages: true // log and/or display messages from debugging & testing code
- }
-
- );
-
- var westLayout = $('div.ui-layout-west').layout({
- minSize: 50 // ALL panes
- , center__paneSelector: ".west-center"
- , south__paneSelector: ".west-south"
- , south__size: .5
- , south__spacing_open: 3
- });
-
- var centerLayout = $('div.ui-layout-center').layout({
- name: "middle"
- , north__paneSelector: ".middle-north"
- , center__paneSelector: ".middle-center"
- , south__paneSelector: ".middle-south"
- , minSize: 0 // ALL panes
- , center__minSize: 300
- , north__size: 32
- , north__resizable: false
- , north__spacing_open: 0
- , south__spacing_open: 0
- , south__size: 1
- });
-
- // File Viewer / Editor
- var eastLayout = $('div.ui-layout-east').layout({
- minSize: 30 // ALL panes
- , north__paneSelector: ".east-north"
- , center__paneSelector: ".east-center"
- , south__paneSelector: ".east-south"
- , north__size: 80
- , north__resizable: false
- , north__spacing_open: 0
- , south__size: 25
- , south__spacing_open: 0
- });
-
- var dirNavigationLayout = $('#directoryNavigator').layout({
- minSize: 30 // ALL panes
- , north__paneSelector: "#directoryNavigatorNorth"
- , center__paneSelector: "#dirTree"
- , north__size: 30
- , north__resizable: false
- , north__spacing_open: 0
- });
-
- // Hide Document Viewer by default
- layoutContainer.toggle("east");
-}
-
return {
- initializeUI: initUI,
- initializeLayout: initLayout
+ initializeApp: initApp,
};
-});
-
+});
\ No newline at end of file
diff --git a/data/js/misc.ui.js b/data/js/misc.ui.js
index b4719482c..d9e9e38b1 100644
--- a/data/js/misc.ui.js
+++ b/data/js/misc.ui.js
@@ -335,7 +335,6 @@ UIAPI.handleElementActivation = function() {
}
}
-
UIAPI.initUI = function() {
try {
console.debug("Initializing UI...");
@@ -362,6 +361,103 @@ UIAPI.reloadUI = function() {
location.reload();
}
+UIAPI.layoutContainer = undefined;
+
+UIAPI.initLayout = function(){
+ console.debug("Initializing Layout...");
+
+ UIAPI.layoutContainer = $('#container').layout(
+ {
+ fxName: "none"
+
+ // some resizing/toggling settings
+ , north__resizable: false // OVERRIDE the pane-default of 'slidable=true'
+ , north__spacing_open: 0 // no resizer-bar when open (zero height)
+ // , north__togglerLength_closed: '100%' // toggle-button is full-width of resizer-bar
+ // , north__spacing_closed: 20 // big resizer-bar when open (zero height)
+ , north__size: 33
+
+ , south__resizable: false // OVERRIDE the pane-default of 'resizable=true'
+ , south__spacing_open: 0 // no resizer-bar when open (zero height)
+ // , south__spacing_closed: 20 // big resizer-bar when open (zero height)
+
+ // west settings
+ , west__resizable: true
+ , west__minSize: .1
+// , west__maxSize: .4
+ , west__size: 200
+ , west__spacing_open: 3
+
+ // east settings
+ , east__resizable: true
+ , east__size: .45
+ , east__minSize: .2
+// , east__maxSize: .8 // 80% of layout width
+ , east__spacing_open: 3
+
+ // center settings
+ , center__resizable: true
+ , center__minSize: 0.5
+
+ // enable showOverflow on west-pane so CSS popups will overlap north pane
+ , west__showOverflowOnHover: true
+
+ // enable state management
+ , stateManagement__enabled: false // automatic cookie load & save enabled by default
+
+ , showDebugMessages: true // log and/or display messages from debugging & testing code
+ }
+
+ );
+
+ var westLayout = $('div.ui-layout-west').layout({
+ minSize: 50 // ALL panes
+ , center__paneSelector: ".west-center"
+ , south__paneSelector: ".west-south"
+ , south__size: .5
+ , south__spacing_open: 3
+ });
+
+ var centerLayout = $('div.ui-layout-center').layout({
+ name: "middle"
+ , north__paneSelector: ".middle-north"
+ , center__paneSelector: ".middle-center"
+ , south__paneSelector: ".middle-south"
+ , minSize: 0 // ALL panes
+ , center__minSize: 300
+ , north__size: 32
+ , north__resizable: false
+ , north__spacing_open: 0
+ , south__spacing_open: 0
+ , south__size: 1
+ });
+
+ // File Viewer / Editor
+ var eastLayout = $('div.ui-layout-east').layout({
+ minSize: 30 // ALL panes
+ , north__paneSelector: ".east-north"
+ , center__paneSelector: ".east-center"
+ , south__paneSelector: ".east-south"
+ , north__size: 80
+ , north__resizable: false
+ , north__spacing_open: 0
+ , south__size: 25
+ , south__spacing_open: 0
+ });
+
+ var dirNavigationLayout = $('#directoryNavigator').layout({
+ minSize: 30 // ALL panes
+ , north__paneSelector: "#directoryNavigatorNorth"
+ , center__paneSelector: "#dirTree"
+ , north__size: 30
+ , north__resizable: false
+ , north__spacing_open: 0
+ });
+
+ // Closes the viewer area by init
+ UIAPI.layoutContainer.close("east");
+}
+
//return UIAPI;
//});
diff --git a/data/loader.js b/data/loader.js
index 91027906b..7f5ccd3c1 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -59,7 +59,6 @@ require.config({
// Init Application
require(['js/main'],
function(Main) {
- $(document).ready(Main.initializeLayout());
- Main.initializeUI();
+ Main.initializeApp();
}
);
\ No newline at end of file