TagSpaces is an offline, open source, document manager with tagging support
Favorites renamed to connection in the code New created connection is now automatically opened after its creation
uggrockda91299d554e
diff --git a/data/index.html b/data/index.htmlindex 7ca4a8b94..565534bc2 100644--- a/data/index.html+++ b/data/index.html@@ -40,7 +40,7 @@<div id="directoryNavigator" class="west-center" style="padding: 0px"><div id="directoryNavigatorNorth" style="padding: 2px;" ><div class="btn-group" style="width: 100%;">- <button id="reloadTagSpace" style="width: 85%; text-align: left;" class="btn" data-dropdown="#favoritesList" >Select Location</button>+ <button id="reloadTagSpace" style="width: 85%; text-align: left;" class="btn" data-dropdown="#connectionsList" >Select Location</button><button id="selectTagSpace" style="width: 15%;" class="btn"><span class="caret"></span></button></div></div>@@ -345,7 +345,7 @@</div></div>- <ul id="favoritesList" class="dropdown-menu"></ul>+ <ul id="connectionsList" class="dropdown-menu"></ul><ul id="tagSuggestionsMenu" class="dropdown-menu has-tip anchor-right"></ul>diff --git a/data/js/core.api.js b/data/js/core.api.jsindex 6fa417516..4dc47fffa 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -69,7 +69,7 @@ define(function(require, exports, module) {$("#appVersion").text("["+tsSettings.DefaultSettings["appVersion"]+"beta]");$("#appVersion").attr("title","["+tsSettings.DefaultSettings["appVersion"]+"."+tsSettings.DefaultSettings["appBuild"]+"]");- tsDirectoriesUI.initFavorites();+ tsDirectoriesUI.initConnections();tsTagsUI.generateTagGroups();@@ -86,8 +86,8 @@ define(function(require, exports, module) {// Show start hintif(tsSettings.Settings.tagspacesList.length < 1 ) {$( "#createNewLocation" ).attr("title", "Start using TagSpaces by creating a new location.")- $( "#favoritesList" ).width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());- $( "#favoritesList" ).show().position({+ $( "#connectionsList" ).width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());+ $( "#connectionsList" ).show().position({my: "left top",at: "left bottom",of: $( "#reloadTagSpace" )@@ -345,7 +345,7 @@ define(function(require, exports, module) {// Proxying functions from directoriesUIexports.updateSubDirs = tsDirectoriesUI.updateSubDirs;- exports.initFavorites = tsDirectoriesUI.initFavorites;+ exports.initConnections = tsDirectoriesUI.initConnections;exports.showCreateDirectoryDialog = tsDirectoriesUI.showCreateDirectoryDialog;// Public variables definitiondiff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex 15fa122f7..17fc4a3c6 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -12,14 +12,16 @@ define(function(require, exports, module) {var dir4ContextMenu = null;- var nameCurrentFavorite = undefined;+ var nameCurrentConnection = undefined;- function openFavorite(path, title) {- console.log("Opening favorite in : "+path+" title: "+title);+ function openConnection(path) {+ console.log("Opening connection in : "+path);- document.title = title + " | " + TSCORE.Config.DefaultSettings.appName;+ nameCurrentConnection = TSCORE.Config.getConnectionName(path);++ document.title = nameCurrentConnection + " | " + TSCORE.Config.DefaultSettings.appName;- $( "#reloadTagSpace" ).text(title);+ $( "#reloadTagSpace" ).text(nameCurrentConnection);$( "#reloadTagSpace" ).attr("title",path);// Clears the directory history@@ -271,8 +273,8 @@ define(function(require, exports, module) {function initButtons() {$( "#selectTagSpace" ).click(function() {- //$("#favoritesList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());- $("#favoritesList").show().position({+ //$("#connectionsList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());+ $("#connectionsList").show().position({my: "left top",at: "left bottom",of: $( "#reloadTagSpace" )@@ -325,10 +327,11 @@ define(function(require, exports, module) {}});- $( "#createFolderConnectionButton" ).click( function() {- TSCORE.Config.createFavorite($("#connectionName").val(), $("#folderLocation").val());- initFavorites();- openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);+ $( "#createFolderConnectionButton" ).click( function() {+ var locationPath = $("#folderLocation").val();+ TSCORE.Config.createConnection($("#connectionName").val(), locationPath);+ initConnections();+ openConnection(locationPath);});}@@ -340,10 +343,13 @@ define(function(require, exports, module) {function deleteFolderConnection() {console.log("Deleting folder connection..");- TSCORE.Config.deleteFavorite(nameCurrentFavorite);- initFavorites();+ TSCORE.Config.deleteConnection(nameCurrentConnection);++ initConnections();++ //Opens the first location in the settings after deleting a locationif(TSCORE.Config.Settings["tagspacesList"][0] != undefined) {- openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);+ openConnection(TSCORE.Config.Settings["tagspacesList"][0].path);}}@@ -355,46 +361,46 @@ define(function(require, exports, module) {)}- function initFavorites() {+ function initConnections() {console.log("Creating location menu...");- $( "#favoritesList" ).empty();- var favoritesList = TSCORE.Config.Settings["tagspacesList"]- for (var i=0; i < favoritesList.length; i++) {- $( "#favoritesList" ).append(+ $( "#connectionsList" ).empty();+ var connectionsList = TSCORE.Config.Settings["tagspacesList"]+ for (var i=0; i < connectionsList.length; i++) {+ $( "#connectionsList" ).append($('<li>', {}).append($('<a>', {- title: favoritesList[i].path,- name: favoritesList[i].name,- text: " "+favoritesList[i].name+ title: "Connection pointing to "+connectionsList[i].path,+ path: connectionsList[i].path,+ name: connectionsList[i].name,+ text: " "+connectionsList[i].name} ).click(function() {- nameCurrentFavorite = $(this).attr( "name" );- openFavorite($(this).attr( "title" ), $(this).attr( "name" ));+ openConnection($(this).attr( "path" ));}).prepend("<i class='icon-bookmark'></i>")));};- $( "#favoritesList" ).append('<li class="divider"></li>');- $( "#favoritesList" ).append('<li id="createNewLocation"><a><i class="icon-bookmark-empty"></i> New Location</a></li>');- $( "#favoritesList" ).append('<li id="deleteFavorite"><a><i class="icon-trash"></i> Remove Location</a></li>');+ $( "#connectionsList" ).append('<li class="divider"></li>');+ $( "#connectionsList" ).append('<li id="createNewLocation"><a><i class="icon-bookmark-empty"></i> New Location</a></li>');+ $( "#connectionsList" ).append('<li id="deleteConnection"><a><i class="icon-trash"></i> Remove Location</a></li>');$( "#createNewLocation" ).click(function() {showCreateFolderConnectionDialog();});- $( "#deleteFavorite" ).click(function() {+ $( "#deleteConnection" ).click(function() {showDeleteFolderConnectionDialog();});}// Public API definition- exports.openFavorite = openFavorite;+ exports.openConnection = openConnection;exports.updateSubDirs = updateSubDirs;exports.initDialogs = initDialogs;exports.initButtons = initButtons;exports.initContextMenus = initContextMenus;- exports.initFavorites = initFavorites;+ exports.initConnections = initConnections;exports.showCreateDirectoryDialog = showCreateDirectoryDialog;});\ No newline at end of filediff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.jsindex 02f1f23e1..9771fb933 100644--- a/data/js/ioapi.mozilla.js+++ b/data/js/ioapi.mozilla.js@@ -23,7 +23,7 @@ document.documentElement.addEventListener("tsMessage", function(event) {console.log("Loading settings...: "+JSON.stringify(message.content));TSCORE.Config.updateSettingMozillaPreferences(message.content);- TSCORE.initFavorites();+ TSCORE.initConnections();TSCORE.generateTagGroups();} catch (ex) {diff --git a/data/js/postioapi.js b/data/js/postioapi.jsindex 06819d463..6b7b56b4a 100644--- a/data/js/postioapi.js+++ b/data/js/postioapi.js@@ -19,7 +19,6 @@ define(function(require, exports, module) {exports.createDirectory = function() {//TODO refresh the directory area- // TSCORE.openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);}exports.renameFile = function(oldFilePath, newFilePath) {diff --git a/data/js/settings.api.js b/data/js/settings.api.jsindex 8a031f081..f54dde17c 100644--- a/data/js/settings.api.js+++ b/data/js/settings.api.js@@ -28,10 +28,10 @@ define(function(require, exports, module) {*/}- var favoriteTemplate = {- "name": undefined,- "path": undefined- }+ var connectionTemplate = {+ "name": undefined,+ "path": undefined+ }var tagGroupTemplate = {"title": undefined,@@ -442,22 +442,48 @@ define(function(require, exports, module) {saveSettings();}- var createFavorite = function(name, location) {- var newFavoriteModel = JSON.parse( JSON.stringify(favoriteTemplate));+ var createConnection = function(name, location) {+ var newConnectionModel = JSON.parse( JSON.stringify(connectionTemplate));name = name.replace("\\", "\\\\");name = name.replace("\\\\\\", "\\\\");name = name.replace("\\\\\\\\", "\\\\");- newFavoriteModel.name = name;- newFavoriteModel.path = location;- exports.Settings["tagspacesList"].push(newFavoriteModel);- saveSettings();+ newConnectionModel.name = name;+ newConnectionModel.path = location;+ var createLocation = true;+ exports.Settings["tagspacesList"].forEach(function (value, index) {+ // TODO make this check from the ui dialog+ if(value.path == newConnectionModel.path) {+ TSCORE.showAlertDialog("Selected path is already used by a location!","Duplicated Location Path");+ createLocation = false;+ }+ if(value.name == newConnectionModel.name) {+ TSCORE.showAlertDialog("Selected location name is already used by a location!","Duplicated Location Name");+ createLocation = false;+ }+ })+ if(createLocation) {+ exports.Settings["tagspacesList"].push(newConnectionModel);+ saveSettings();+ }}++ var getConnectionName = function(connectionPath) {+ var connectionName = undefined;+ exports.Settings["tagspacesList"].forEach(function (value, index) {+ if(value.path == connectionPath) {+ connectionName = value.name;+ }+ })+ if(connectionName != undefined) {+ return connectionName;+ }+ }- var deleteFavorite = function(name) {+ var deleteConnection = function(name) {for(var i=0; i < exports.Settings["tagspacesList"].length; i++) {- console.log("Traversing favorite "+exports.Settings["tagspacesList"][i].name+" searching for "+name);+ console.log("Traversing connections "+exports.Settings["tagspacesList"][i].name+" searching for "+name);if(exports.Settings["tagspacesList"][i].name == name) {- console.log("Deleting favorite "+exports.Settings["tagspacesList"][i].name);+ console.log("Deleting connections "+exports.Settings["tagspacesList"][i].name);exports.Settings["tagspacesList"].splice(i, 1);break;}@@ -554,8 +580,9 @@ define(function(require, exports, module) {exports.moveTagGroup = moveTagGroup;exports.createTagGroup = createTagGroup;exports.duplicateTagGroup = duplicateTagGroup;- exports.createFavorite = createFavorite;- exports.deleteFavorite = deleteFavorite;+ exports.createConnection = createConnection;+ exports.deleteConnection = deleteConnection;+ exports.getConnectionName = getConnectionName;exports.updateSettingMozillaPreferences = updateSettingMozillaPreferences;exports.loadSettingsLocalStorage = loadSettingsLocalStorage;exports.loadDefaultSettings = loadDefaultSettings;