Skip to content

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

Refactoring project to match new module structure

uggrock8a56dd9cd00f
diff --git a/data/ext/perspectiveBasic/extension.js b/data/ext/perspectiveBasic/extension.js
index 423d16cde..e4d6159aa 100644
--- a/data/ext/perspectiveBasic/extension.js
+++ b/data/ext/perspectiveBasic/extension.js
@@ -19,6 +19,8 @@ exports.Icon = "ui-icon-note";
console.debug("Loading view.basic.js");
+var TagsUI = require("tstagsui");
+
var viewContainer = undefined;
var viewToolbar = undefined;
var viewFooter = undefined;
diff --git a/data/ext/perspectiveSearch/extension.js b/data/ext/perspectiveSearch/extension.js
index 218cfc372..70567ff88 100644
--- a/data/ext/perspectiveSearch/extension.js
+++ b/data/ext/perspectiveSearch/extension.js
@@ -21,6 +21,8 @@ exports.License = "AGPL";
console.debug("Loading view.search.js");
+var TagsUI = require("tstagsui");
+
var viewContainer = undefined;
var viewToolbar = undefined;
var viewFooter = undefined;
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 085863329..bd02871f3 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -1,19 +1,100 @@
/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-/*
define([
'require',
'exports',
'module',
],function(require, exports, module) {
-*/
//"use strict";
console.debug("Loading core.api.js ...");
var UIAPI = (typeof UIAPI == 'object' && UIAPI != null) ? UIAPI : {};
+var TSSETTINGS = require("tssetting");
+
+UIAPI.updateSubDirs = undefined;
+
+UIAPI.initApp = function() {
+ console.debug("InitApplication");
+
+ require([
+ "tstagsui",
+ "tsdirectoriesui",
+ "tspersmanager",
+ "tstagutils",
+ "tsfileopener",
+ "tscoreui"
+ ],
+ function(
+ tsTagsUI,
+ tsDirectoriesUI,
+ tsPersManager,
+ tsTagUtils,
+ tsFileOpener,
+ tsCoreUI
+ ) {
+ UIAPI.ViewManager = tsPersManager;
+ UIAPI.TagUtils = tsTagUtils;
+ UIAPI.FileOpener = tsFileOpener;
+
+ tsCoreUI.initButtons();
+ tsCoreUI.initDialogs();
+
+ tsTagsUI.initContextMenus();
+ tsTagsUI.initDialogs();
+
+ tsDirectoriesUI.initDialogs();
+ tsDirectoriesUI.initButtons();
+ tsDirectoriesUI.initContextMenus();
+
+ // Proxying directoriesUI
+ UIAPI.updateSubDirs = tsDirectoriesUI.updateSubDirs;
+
+ TSSETTINGS.loadSettingsLocalStorage();
+
+ // In firefox, by empty local storage trying to load the settings from mozilla preferences
+ if(TSSETTINGS.Settings == undefined && $.browser.mozilla) {
+ window.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's javascript
+ // This is usually the case by a new installation
+ if(TSSETTINGS.Settings == undefined) {
+ TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
+ }
+
+ TSSETTINGS.upgradeSettings();
+
+ // Init views
+ UIAPI.ViewManager.initViews();
+
+ $("#appVersion").text("["+TSSETTINGS.DefaultSettings["appVersion"]+"]");
+ $("#appVersion").attr("title","["+TSSETTINGS.DefaultSettings["appBuild"]+"]");
+
+ tsDirectoriesUI.initFavorites();
+
+ tsTagsUI.generateTagGroups();
+
+ $( "#loading" ).hide();
+ $( "#container" ).show();
+
+ UIAPI.hideLoadingAnimation();
+ // TODO check if document.ready is really needed
+ $(document).ready(function() {
+ UIAPI.initLayout();
+ console.debug("Layout initialized");
+ });
+
+ // Show start hint
+ $( "#selectTagSpace" ).tooltip( "open" );
+
+ });
+
+}
+
// ONE_DIR_UP
UIAPI.parentDir = "..";
@@ -35,12 +116,6 @@ UIAPI.selectedTag = "";
UIAPI.selectedTagData = "";
-UIAPI.ViewManager = undefined;
-
-UIAPI.TagUtils = undefined;
-
-UIAPI.FileOpener = undefined;
-
UIAPI.IO = undefined;
UIAPI.setCurrentPath = function(path) {
@@ -273,5 +348,5 @@ UIAPI.initLayout = function(){
layoutContainer.close("east");
}
-//return UIAPI;
-//});
\ No newline at end of file
+return UIAPI;
+});
\ No newline at end of file
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 135565bae..33967fab5 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -8,371 +8,374 @@ define([
'jsoneditor',
// 'css!jsoneditorcss'
],function(require, exports, module) {
-//"use strict";
+"use strict";
console.debug("Loading core.ui.js ...");
-// Init JSON Editor
-// TODO variable editor is hardcoded due a bug in the JSONEditor lib
-var initJSONEditor = function() {
- var edEl = document.getElementById("settingsEditor");
- editor = new JSONEditor(edEl);
- formatter = new JSONFormatter(document.getElementById("settingsPlainJSON"));
-}
+ var editor = undefined; // Needed for JSON Editor
+ var formatter = undefined;
-var initButtons = function() {
- $( "#openSettings" ).button({
- text: true,
- icons: {
- primary: "ui-icon-wrench"
- }
- })
- .click(function() {
- initJSONEditor();
- $( "#dialogSetting" ).dialog( "open" );
- });
-
- $( "#openAboutBox" ).button({
- text: true,
- icons: {
- primary: "ui-icon-lightbulb"
- }
- })
- .click(function() {
- $( "#dialogAbout" ).dialog( "open" );
- });
-
- $( "#toggleLeftPanel" ).button({
- text: false,
- icons: {
- primary: "ui-icon-bookmark"
- }
- })
- .click(function() {
- UIAPI.toggleLeftPanel();
- });
-}
+ // Init JSON Editor
+ // TODO variable editor is hardcoded due a bug in the JSONEditor lib
+ var initJSONEditor = function() {
+ var edEl = document.getElementById("settingsEditor");
+ editor = new JSONEditor(edEl);
+ formatter = new JSONFormatter(document.getElementById("settingsPlainJSON"));
+ }
+
+ var initButtons = function() {
+ $( "#openSettings" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-wrench"
+ }
+ })
+ .click(function() {
+ initJSONEditor();
+ $( "#dialogSetting" ).dialog( "open" );
+ });
+
+ $( "#openAboutBox" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-lightbulb"
+ }
+ })
+ .click(function() {
+ $( "#dialogAbout" ).dialog( "open" );
+ });
+
+ $( "#toggleLeftPanel" ).button({
+ text: false,
+ icons: {
+ primary: "ui-icon-bookmark"
+ }
+ })
+ .click(function() {
+ UIAPI.toggleLeftPanel();
+ });
+ }
+
+ var initDialogs = function() {
+ var newDirName = $( "#dirname" );
+ var newFileName = $( "#newFileName" );
+ var renamedFileName = $( "#renamedFileName" );
+
+ // TODO evtl add smarttag and the others...
+ var allFields = $( [] ).add( newDirName );
+
+ var tips = $( ".validateTips" );
+
+ function updateTips( t ) {
+ tips
+ .text( t )
+ .addClass( "ui-state-highlight" );
+ setTimeout(function() {
+ tips.removeClass( "ui-state-highlight", 1500 );
+ }, 500 );
+ }
+
+ function checkLength( o, n, min, max ) {
+ if ( o.val().length > max || o.val().length < min ) {
+ o.addClass( "ui-state-error" );
+ updateTips( "Length of " + n + " must be between " +
+ min + " and " + max + "." );
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ function checkRegexp( o, regexp, n ) {
+ if ( !( regexp.test( o.val() ) ) ) {
+ o.addClass( "ui-state-error" );
+ updateTips( n );
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ $( "#fileTypeRadio" ).buttonset();
+
+ var fileContent = undefined;
+
+ $( "#txtFileTypeButton" ).click(function() {
+ // TODO Add to config options
+ fileContent = TSSETTINGS.getNewTextFileContent();
+ //Leave the filename as it is by no extension
+ if(newFileName.val().lastIndexOf(".")>=0) {
+ newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".txt");
+ }
+ });
+
+ $( "#htmlFileTypeButton" ).click(function() {
+ // TODO Add to config options
+ fileContent = TSSETTINGS.getNewHTMLFileContent();
+ //Leave the filename as it is by no extension
+ if(newFileName.val().lastIndexOf(".")>=0) {
+ newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".html");
+ }
+ });
+
+ $( "#mdFileTypeButton" ).click(function() {
+ // TODO Add to config options
+ fileContent = TSSETTINGS.getNewMDFileContent();
+ //Leave the filename as it is by no extension
+ if(newFileName.val().lastIndexOf(".")>=0) {
+ newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".md");
+ }
+ });
+
+ $( "#dialog-filecreate" ).dialog({
+ autoOpen: false,
+ height: 250,
+ width: 450,
+ modal: true,
+ buttons: {
+ "Create": function() {
+ var bValid = true;
+ allFields.removeClass( "ui-state-error" );
+
+ bValid = bValid && checkLength( newFileName, "filename", 4, 200 );
+ // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
+ if(UIAPI.fileExists(newFileName.val())) {
+ updateTips("File already exists.");
+ bValid = false;
+ }
+ if ( bValid ) {
+ IOAPI.saveTextFile(UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val(),fileContent);
+ $( this ).dialog( "close" );
+ IOAPI.listDirectory(UIAPI.currentPath);
+ }
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ close: function() {
+ allFields.val( "" ).removeClass( "ui-state-error" );
+ },
+ open: function() {
+ fileContent = TSSETTINGS.getNewTextFileContent(); // Default new file in text file
+ $( "#newFileName" ).val(".txt");
+ }
+ });
+
+ $( "#dialog-filerename" ).dialog({
+ autoOpen: false,
+ height: 220,
+ width: 450,
+ modal: true,
+ buttons: {
+ "Rename": function() {
+ var bValid = true;
+ allFields.removeClass( "ui-state-error" );
+
+ bValid = bValid && checkLength( renamedFileName, "filename", 3, 200 );
+ // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
+ if ( bValid ) {
+ var containingDir = UIAPI.TagUtils.extractContainingDirectoryPath(UIAPI.selectedFiles[0]);
+ IOAPI.renameFile(
+ UIAPI.selectedFiles[0],
+ containingDir+UIAPI.TagUtils.DIR_SEPARATOR+renamedFileName.val()
+ );
+ $( this ).dialog( "close" );
+ }
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ close: function() {
+ allFields.val( "" ).removeClass( "ui-state-error" );
+ },
+ open: function() {
+ $( "#renamedFileName" ).val(UIAPI.TagUtils.extractFileName(UIAPI.selectedFiles[0]));
+ }
+ });
+
+ $( "#dialog-confirmdelete" ).dialog({
+ autoOpen: false,
+ resizable: false,
+ height:140,
+ modal: true,
+ buttons: {
+ "Delete all items": function() {
+ IOAPI.deleteElement(UIAPI.selectedFiles[0]);
+ $( this ).dialog( "close" );
+ IOAPI.listDirectory(UIAPI.currentPath);
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+
+ $( "#dialogAddTags" ).dialog({
+ autoOpen: false,
+ resizable: false,
+ height:240,
+ modal: true,
+ buttons: {
+ "Add tags": function() {
+ var tags = $("#tags").val().split(",");
+ UIAPI.TagUtils.addTag(UIAPI.selectedFiles, tags);
+ $( this ).dialog( "close" );
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ open: function() {
+
+ function split( val ) {
+ return val.split( /,\s*/ );
+ }
+ function extractLast( term ) {
+ return split( term ).pop();
+ }
+
+ $( "#tags" )
+ // don't navigate away from the field on tab when selecting an item
+ .bind( "keydown", function( event ) {
+ if ( event.keyCode === $.ui.keyCode.TAB &&
+ $( this ).data( "autocomplete" ).menu.active ) {
+ event.preventDefault();
+ }
+ })
+ .autocomplete({
+ minLength: 0,
+ source: function( request, response ) {
+ // delegate back to autocomplete, but extract the last term
+ response( $.ui.autocomplete.filter(
+ TSSETTINGS.getAllTags(), extractLast( request.term ) ) );
+ },
+ focus: function() {
+ // prevent value inserted on focus
+ return false;
+ },
+ select: function( event, ui ) {
+ var terms = split( this.value );
+ // remove the current input
+ terms.pop();
+ // add the selected item
+ terms.push( ui.item.value );
+ // add placeholder to get the comma-and-space at the end
+ terms.push( "" );
+ this.value = terms.join( ", " );
+ return false;
+ }
+ });
+ }
+ });
+
+ $( "#tagTypeRadio" ).buttonset();
+
+ $( "#plainTagTypeButton" ).click(function() {
+ UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");
+ });
+
+ $( "#dateTagTypeButton" ).click(function() {
+ UIAPI.selectedTag, $( "#newTag" ).datepicker({
+ showWeek: true,
+ firstDay: 1,
+ dateFormat: "yymmdd"
+ });
+ });
+
+ $( "#currencyTagTypeButton" ).click(function() {
+ UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")
+ });
+
+ $( "#dialogEditTag" ).dialog({
+ autoOpen: false,
+ resizable: false,
+ height:240,
+ modal: true,
+ buttons: {
+ "Save": function() {
+ UIAPI.TagUtils.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());
+ IOAPI.listDirectory(UIAPI.currentPath);
+ $( this ).dialog( "close" );
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+
+ $( "#dialogAbout" ).dialog({
+ autoOpen: false,
+ resizable: true,
+ height: 370,
+ width: 600,
+ modal: true,
+ buttons: {
+ "Back": function() {
+ $("#aboutIframe").attr("src","about.html");
+ },
+ "Close": function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ open: function() {
+
+ }
+ });
+
+ $( "#dialogSetting" ).dialog({
+ autoOpen: false,
+ resizable: true,
+ height: 370,
+ width: 600,
+ modal: true,
+ buttons: {
+ // "Ext. Folder": function() {
+ // IOAPI.openExtensionsDirectory()
+ // },
+ "Editor": function() {
+ if($("#settingsEditor").is(":hidden") ) {
+ $("#settingsPlainJSON").hide();
+ $("#settingsEditor").show();
+ editor.set(formatter.get());
+ }
+ },
+ "Import/Export": function() {
+ if($("#settingsPlainJSON").is(":hidden") ) {
+ formatter.set(editor.get());
+ $("#settingsPlainJSON").show();
+ $("#settingsEditor").hide();
+ }
+ },
+ "Default Settings": function() {
+ if(confirm("Are you sure you want to restore the default application settings?\nAll manually made changes such as tags and taggroups will be lost.")) {
+ TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
+ TSSETTINGS.saveSettings();
+ UIAPI.reloadUI();
+ console.debug("Default settings loaded.");
+ }
+ },
+ "Save": function() {
+ TSSETTINGS.Settings = editor.get();
+ TSSETTINGS.saveSettings();
+ UIAPI.reloadUI();
+ console.debug("Settings saved and UI reloaded.");
+ $( this ).dialog( "close" );
+ },
+ "Cancel": function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ open: function() {
+ $("#settingsPlainJSON").hide();
+ editor.set(TSSETTINGS.Settings);
+ }
+ });
+ }
-var initDialogs = function() {
- var newDirName = $( "#dirname" );
- var newFileName = $( "#newFileName" );
- var renamedFileName = $( "#renamedFileName" );
-
- // TODO evtl add smarttag and the others...
- var allFields = $( [] ).add( newDirName );
-
- var tips = $( ".validateTips" );
-
- function updateTips( t ) {
- tips
- .text( t )
- .addClass( "ui-state-highlight" );
- setTimeout(function() {
- tips.removeClass( "ui-state-highlight", 1500 );
- }, 500 );
- }
-
- function checkLength( o, n, min, max ) {
- if ( o.val().length > max || o.val().length < min ) {
- o.addClass( "ui-state-error" );
- updateTips( "Length of " + n + " must be between " +
- min + " and " + max + "." );
- return false;
- } else {
- return true;
- }
- }
-
- function checkRegexp( o, regexp, n ) {
- if ( !( regexp.test( o.val() ) ) ) {
- o.addClass( "ui-state-error" );
- updateTips( n );
- return false;
- } else {
- return true;
- }
- }
-
- $( "#fileTypeRadio" ).buttonset();
-
- var fileContent = undefined;
-
- $( "#txtFileTypeButton" ).click(function() {
- // TODO Add to config options
- fileContent = TSSETTINGS.getNewTextFileContent();
- //Leave the filename as it is by no extension
- if(newFileName.val().lastIndexOf(".")>=0) {
- newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".txt");
- }
- });
-
- $( "#htmlFileTypeButton" ).click(function() {
- // TODO Add to config options
- fileContent = TSSETTINGS.getNewHTMLFileContent();
- //Leave the filename as it is by no extension
- if(newFileName.val().lastIndexOf(".")>=0) {
- newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".html");
- }
- });
-
- $( "#mdFileTypeButton" ).click(function() {
- // TODO Add to config options
- fileContent = TSSETTINGS.getNewMDFileContent();
- //Leave the filename as it is by no extension
- if(newFileName.val().lastIndexOf(".")>=0) {
- newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".md");
- }
- });
-
- $( "#dialog-filecreate" ).dialog({
- autoOpen: false,
- height: 250,
- width: 450,
- modal: true,
- buttons: {
- "Create": function() {
- var bValid = true;
- allFields.removeClass( "ui-state-error" );
-
- bValid = bValid && checkLength( newFileName, "filename", 4, 200 );
- // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
- if(UIAPI.fileExists(newFileName.val())) {
- updateTips("File already exists.");
- bValid = false;
- }
- if ( bValid ) {
- IOAPI.saveTextFile(UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val(),fileContent);
- $( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
- }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
- },
- open: function() {
- fileContent = TSSETTINGS.getNewTextFileContent(); // Default new file in text file
- $( "#newFileName" ).val(".txt");
- }
- });
-
- $( "#dialog-filerename" ).dialog({
- autoOpen: false,
- height: 220,
- width: 450,
- modal: true,
- buttons: {
- "Rename": function() {
- var bValid = true;
- allFields.removeClass( "ui-state-error" );
-
- bValid = bValid && checkLength( renamedFileName, "filename", 3, 200 );
- // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
- if ( bValid ) {
- var containingDir = UIAPI.TagUtils.extractContainingDirectoryPath(UIAPI.selectedFiles[0]);
- IOAPI.renameFile(
- UIAPI.selectedFiles[0],
- containingDir+UIAPI.TagUtils.DIR_SEPARATOR+renamedFileName.val()
- );
- $( this ).dialog( "close" );
- }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
- },
- open: function() {
- $( "#renamedFileName" ).val(UIAPI.TagUtils.extractFileName(UIAPI.selectedFiles[0]));
- }
- });
-
- $( "#dialog-confirmdelete" ).dialog({
- autoOpen: false,
- resizable: false,
- height:140,
- modal: true,
- buttons: {
- "Delete all items": function() {
- IOAPI.deleteElement(UIAPI.selectedFiles[0]);
- $( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- }
- });
-
- $( "#dialogAddTags" ).dialog({
- autoOpen: false,
- resizable: false,
- height:240,
- modal: true,
- buttons: {
- "Add tags": function() {
- var tags = $("#tags").val().split(",");
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, tags);
- $( this ).dialog( "close" );
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- open: function() {
-
- function split( val ) {
- return val.split( /,\s*/ );
- }
- function extractLast( term ) {
- return split( term ).pop();
- }
-
- $( "#tags" )
- // don't navigate away from the field on tab when selecting an item
- .bind( "keydown", function( event ) {
- if ( event.keyCode === $.ui.keyCode.TAB &&
- $( this ).data( "autocomplete" ).menu.active ) {
- event.preventDefault();
- }
- })
- .autocomplete({
- minLength: 0,
- source: function( request, response ) {
- // delegate back to autocomplete, but extract the last term
- response( $.ui.autocomplete.filter(
- TSSETTINGS.getAllTags(), extractLast( request.term ) ) );
- },
- focus: function() {
- // prevent value inserted on focus
- return false;
- },
- select: function( event, ui ) {
- var terms = split( this.value );
- // remove the current input
- terms.pop();
- // add the selected item
- terms.push( ui.item.value );
- // add placeholder to get the comma-and-space at the end
- terms.push( "" );
- this.value = terms.join( ", " );
- return false;
- }
- });
- }
- });
-
- $( "#tagTypeRadio" ).buttonset();
-
- $( "#plainTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");
- });
-
- $( "#dateTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker({
- showWeek: true,
- firstDay: 1,
- dateFormat: "yymmdd"
- });
- });
-
- $( "#currencyTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")
- });
-
- $( "#dialogEditTag" ).dialog({
- autoOpen: false,
- resizable: false,
- height:240,
- modal: true,
- buttons: {
- "Save": function() {
- UIAPI.TagUtils.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());
- IOAPI.listDirectory(UIAPI.currentPath);
- $( this ).dialog( "close" );
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- }
- });
-
- $( "#dialogAbout" ).dialog({
- autoOpen: false,
- resizable: true,
- height: 370,
- width: 600,
- modal: true,
- buttons: {
- "Back": function() {
- $("#aboutIframe").attr("src","about.html");
- },
- "Close": function() {
- $( this ).dialog( "close" );
- }
- },
- open: function() {
-
- }
- });
-
- $( "#dialogSetting" ).dialog({
- autoOpen: false,
- resizable: true,
- height: 370,
- width: 600,
- modal: true,
- buttons: {
-// "Ext. Folder": function() {
-// IOAPI.openExtensionsDirectory()
-// },
- "Editor": function() {
- if($("#settingsEditor").is(":hidden") ) {
- $("#settingsPlainJSON").hide();
- $("#settingsEditor").show();
- editor.set(formatter.get());
- }
- },
- "Import/Export": function() {
- if($("#settingsPlainJSON").is(":hidden") ) {
- formatter.set(editor.get());
- $("#settingsPlainJSON").show();
- $("#settingsEditor").hide();
- }
- },
- "Default Settings": function() {
- if(confirm("Are you sure you want to restore the default application settings?\nAll manually made changes such as tags and taggroups will be lost.")) {
- TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
- TSSETTINGS.saveSettings();
- UIAPI.reloadUI();
- console.debug("Default settings loaded.");
- }
- },
- "Save": function() {
- TSSETTINGS.Settings = editor.get();
- TSSETTINGS.saveSettings();
- UIAPI.reloadUI();
- console.debug("Settings saved and UI reloaded.");
- $( this ).dialog( "close" );
- },
- "Cancel": function() {
- $( this ).dialog( "close" );
- }
- },
- open: function() {
- $("#settingsPlainJSON").hide();
- editor.set(TSSETTINGS.Settings);
- }
- });
-}
-
-// Autoinitialization
-initButtons();
-initDialogs();
+ // Public API definition
+ exports.initButtons = initButtons;
+ exports.initDialogs = initDialogs;
});
\ No newline at end of file
diff --git a/data/js/directories.ui.js b/data/js/directories.ui.js
index 3aca9da05..9a4ee5542 100644
--- a/data/js/directories.ui.js
+++ b/data/js/directories.ui.js
@@ -1,6 +1,13 @@
/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
+define([
+ 'require',
+ 'exports',
+ 'module',
+],function(require, exports, module) {
+//"use strict";
+
console.debug("Loading DirectoriesUI...");
var DirectoriesUI = (typeof DirectoriesUI == 'object' && DirectoriesUI != null) ? DirectoriesUI : {};
@@ -218,7 +225,6 @@ DirectoriesUI.navigateToDirectory = function(directoryPath) {
});
}
-
UIAPI.currentPath = directoryPath;
IOAPI.getSubdirs(directoryPath);
IOAPI.listDirectory(directoryPath);
@@ -451,4 +457,8 @@ DirectoriesUI.initFavorites = function() {
}
});
$( "#favoritesList" ).hide();
-}
\ No newline at end of file
+}
+
+return DirectoriesUI;
+
+});
\ No newline at end of file
diff --git a/data/js/messaging.mozilla.js b/data/js/messaging.mozilla.js
index a9a5c182c..b74ed3705 100644
--- a/data/js/messaging.mozilla.js
+++ b/data/js/messaging.mozilla.js
@@ -7,7 +7,7 @@ define(function(require, exports, module) {
console.debug("Loading messaging.mozilla.js..");
document.documentElement.addEventListener("addon-message1", function(event) {
- console.debug("Message received in page script from content script"); //+JSON.stringify(event.detail));
+ console.debug("Message received in page script from content script: "); //+JSON.stringify(event.detail));
UIAPI.hideLoadingAnimation();
var message = event.detail;
switch (message.command) {
@@ -46,10 +46,8 @@ document.documentElement.addEventListener("addon-message1", function(event) {
UIAPI.selectedFiles[0] = message.content;
if(UIAPI.isFileOpened) {
UIAPI.openFile(UIAPI.selectedFiles[0]);
- }
-
+ }
UIAPI.refreshFileListContainer();
-
} else {
UIAPI.updateLogger("Rename failed");
}
@@ -106,7 +104,7 @@ document.documentElement.addEventListener("addon-message1", function(event) {
dirListing.push(message.content[i]);
}
// TODO JSON functions are a workarround for a bug....
- DirectoriesUI.updateSubDirs(JSON.parse( JSON.stringify(dirListing)));
+ UIAPI.updateSubDirs(JSON.parse( JSON.stringify(dirListing)));
} else {
UIAPI.updateLogger("Getting subdirs failed");
}
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index 139e627d7..c3f30f909 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -5,15 +5,18 @@ define([
'require',
'exports',
'module',
+ 'tscore'
],function(require, exports, module) {
-"use strict";
+//"use strict";
console.debug("Loading view.manager.js");
var views = undefined;
-
var searchViewer = undefined;
+var TSSETTINGS = require("tssetting");
+var UIAPI = require("tscore");
+
exports.initViews = function initViews() {
views = [];
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 4b33fa51b..e71a28d1a 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -1,11 +1,17 @@
/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
+define([
+ 'require',
+ 'exports',
+ 'module',
+],function(require, exports, module) {
+"use strict";
+
console.debug("Loading SettingsAPI.js..");
var TSSETTINGS = (typeof TSSETTINGS == "object" && TSSETTINGS != null) ? TSSETTINGS : {};
-
TSSETTINGS.TagTemplate = {
"title" : undefined,
"type" : "plain",
@@ -25,7 +31,6 @@ TSSETTINGS.TagTemplate = {
*/
}
-
TSSETTINGS.FavoriteTemplate = {
"name": undefined,
"path": undefined
@@ -387,3 +392,6 @@ TSSETTINGS.saveSettings = function() {
console.debug('Tagspace Settings Saved!');
}
+
+return TSSETTINGS;
+});
\ No newline at end of file
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index bb0ef458b..20d6036c1 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -1,14 +1,13 @@
/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-/*
define([
'require',
'exports',
'module',
],function(require, exports, module) {
"use strict";
-*/
+
console.debug("Loading TagsUI...");
var TagsUI = (typeof TagsUI == 'object' && TagsUI != null) ? TagsUI : {};
@@ -488,4 +487,6 @@ TagsUI.buttonizeFileName = function(fileName, filePath) {
})).html();
}
-//});
\ No newline at end of file
+return TagsUI;
+
+});
\ No newline at end of file
diff --git a/data/js/tagutils.js b/data/js/tagutils.js
index 359be0b44..fe99cfe76 100644
--- a/data/js/tagutils.js
+++ b/data/js/tagutils.js
@@ -1,16 +1,15 @@
/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-
define([
'require',
'exports',
'module'
], function (require, exports, module) {
"use strict";
-
- // var tsCore = require("js/core.api.js"),
- var tsCore = UIAPI;
+
+ // TODO Workarround
+ var ioAPI = IOAPI;
console.debug("Loading tagutils.js ...");
@@ -195,7 +194,7 @@ define([
var newFileName = generateFileName(fileName, extractedTags);
- tsCore.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
function addTag(filePathArray, tagArray) {
@@ -224,7 +223,7 @@ define([
var newFileName = generateFileName(fileName, extractedTags);
- tsCore.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
@@ -247,23 +246,23 @@ define([
var newFileName = generateFileName(fileName, newTags);
- tsCore.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
// Public API definition
exports.DIR_SEPARATOR = DIR_SEPARATOR;
- exports.isWindows = isWindows;
+ exports.isWindows = isWindows;
exports.extractFileName = extractFileName;
exports.extractContainingDirectoryPath = extractContainingDirectoryPath;
exports.extractFileExtension = extractFileExtension;
exports.extractTitle = extractTitle;
exports.formatFileSize = formatFileSize;
exports.formatDateTime = formatDateTime;
- exports.extractTags = extractTags;
- exports.suggestTags = suggestTags;
- exports.writeTagsToFile = writeTagsToFile;
- exports.renameTag = renameTag;
- exports.removeTag = removeTag;
- exports.addTag = addTag;
+ exports.extractTags = extractTags;
+ exports.suggestTags = suggestTags;
+ exports.writeTagsToFile = writeTagsToFile;
+ exports.renameTag = renameTag;
+ exports.removeTag = removeTag;
+ exports.addTag = addTag;
});
\ No newline at end of file
diff --git a/data/loader.js b/data/loader.js
index f27e7274f..3491d4492 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -40,6 +40,16 @@ require.config({
jquerydropdown: 'libs/jquerydropdown/jquery.dropdown',
jquerydropdowncss: 'libs/jquerydropdown/jquery.dropdown',
less: 'libs/less/less-1.3.3.min',
+
+ tscore: 'js/core.api',
+ tssetting: 'js/settings.api',
+ tspersmanager: "js/perspective.manager",
+ tstagutils: "js/tagutils",
+ tsfileopener: "js/fileopener",
+ tstagsui: "js/tags.ui",
+ tsdirectoriesui: "js/directories.ui",
+ tscoreui: "js/core.ui",
+
},
shim: {
'jquerylayout': {
@@ -105,6 +115,13 @@ require.config({
'jquery'
]
},
+
+ 'tscore': {
+ deps: [
+ 'tssetting',
+ ]
+ },
+
/* less: {
deps: [
'css!jquerylayoutcss',
@@ -118,8 +135,44 @@ require.config({
});
// Init Application
-require(['js/main'],
- function(Main) {
- Main.initializeApp();
+require([
+ 'jquery',
+ 'jqueryui',
+ 'datatables',
+ 'jsoneditor',
+ 'jquerylayout',
+ 'jquerydropdown',
+ 'jqueryuitooltips',
+ 'jqueryuidroppable',
+ 'less',
+],
+function() {
+ console.debug("Loading Application...");
+
+ var layoutContainer = undefined;
+
+ UIAPI = undefined;
+ TSSETTINGS = undefined;
+
+ // Setting up the IO functionality according to the plattform
+ if( $.browser.mozilla ) {
+ require([
+ "js/messaging.mozilla",
+ "js/ioapi.mozilla"
+ ]);
+ } else if ( $.browser.chrome ) {
+ require([
+ "js/ioapi.chrome"
+ ]);
+ } else { // TODO a more sophisticated check is required for cordova
+ require([
+ "js/ioapi.cordova"
+ ]);
}
-);
\ No newline at end of file
+
+ require(["tscore","tssetting"], function(tsCore, tsSettings) {
+ UIAPI = tsCore;
+ TSSETTINGS = tsSettings;
+ tsCore.initApp();
+ });
+});
\ No newline at end of file