TagSpaces is an offline, open source, document manager with tagging support
Improving the options dialog Adding settings for tag calculation, tagdelimiter and prefix of a tag container
Ilian945cd49fbb9d
diff --git a/data/assets/tagspaces.css b/data/assets/tagspaces.cssindex 059d2bb95..f623d113d 100644--- a/data/assets/tagspaces.css+++ b/data/assets/tagspaces.css@@ -704,3 +704,8 @@ input a.resetFilter {padding: 1px;}+.optionsTitle {+ text-transform: uppercase;+ font-weight: bold;+ color: gray;+}\ No newline at end of filediff --git a/data/index.html b/data/index.htmlindex 41179201e..5858ea081 100644--- a/data/index.html+++ b/data/index.html@@ -235,52 +235,6 @@ can be found in the LICENSE file.</div><!-- /.modal-content --></div><!-- /.modal-dialog --></div><!-- /.modal -->--<div id="dialogOptions" class="modal" tabindex="-1" role="dialog" aria-hidden="true">- <div class="modal-dialog">- <div class="modal-content">- <div class="modal-header">- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>- <h4>Options</h4>- </div>- <div class="modal-body form" style="max-height: 420px; overflow-y: auto;">- <h5 style="text-transform: uppercase; font-weight: bold; color: gray;">General</h5>- <!--div class='form-group'>- <label for='extensionsPathInput' data-i18n="app.extensionsFolder">Extensions folder</label>- <input type='text' class='form-control' id='extensionsPathInput'- data-i18n="[placeholder]app" placeholder='file:///c:\\tagspaces-extensions'- data-i18n="[title]app" title='Path to your tagspaces extensions'>- </div-->- <!--button class="btn btn-default" style="margin-bottom: 10px" id="switchLang" data-i18n="[title]app.switchLanguageTooltip;">- <i class="fa fa-asterisk"> Test Change Language</i>- </button-->- <div class='form-group'>- <label><input type='checkbox' id='showHiddenFilesCheckbox' /> Show files/directories with a dot(.) in front of the name</label>- </div>- <div class='form-group'>- <label><input type='checkbox' id='checkforUpdatesCheckbox' /> Check for new version on startup</label>- </div><hr />- <h5 style="text-transform: uppercase; font-weight: bold; color: gray;">Perspectives</h5>- <div id='perspectiveList' class='sortable' ></div>- <button class='btn btn-default' style="margin-top: 10px" id='addPerspectiveButton'>- <i class='fa fa-plus' data-i18n="app.addNewPerspective"> Add new perspective</i>- </button><hr />- <h5 style="text-transform: uppercase; font-weight: bold; color: gray;">File Types</h5>- <div id='fileTypesList'></div>- <button class='btn btn-default' style="margin-top: 10px" id='addFileTypeButton'>- <i class='fa fa-plus' data-i18n="app.addNewFileExtension"> Add new file extension</i>- </button>- </div>- <div class="modal-footer">- <h6>Some of the changes will not take effect until restarting the application.</h6>- <!--button class="btn btn-default pull-left" data-dismiss="modal" id="advancedSettings">Advanced Settings</button-->- <button class="btn btn-default pull-left" id="defaultSettingsButton" title="Restore Default Settings" aria-hidden="true">Default Settings</button>- <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>- <button class="btn btn-primary" id="saveSettingsCloseButton">Save</button>- </div>- </div><!-- /.modal-content -->- </div><!-- /.modal-dialog -->-</div><!-- /.modal --><div id="dialogAdvancedSetting" style="" class="modal" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog">@@ -527,7 +481,7 @@ can be found in the LICENSE file.</div><!-- /.modal-dialog --></div><!-- /.modal -->-<div id="alertDialog" class="modal">+<div id="alertDialog" class="modal" style="z-index: 99999"><div class="modal-dialog"><div class="modal-content"><div class="modal-header">@@ -542,7 +496,7 @@ can be found in the LICENSE file.</div></div>-<div id="confirmDialog" class="modal">+<div id="confirmDialog" class="modal" style="z-index: 99999"><div class="modal-dialog"><div class="modal-content"><div class="modal-header">diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 93c70e688..cd95302c8 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -102,6 +102,21 @@ define(function(require, exports, module) {$( '#dialogEditTag' ).modal({show: true});};+ var showOptionsDialog = function() {+ require([+ "text!templates/OptionsDialog.html",+ "tsoptions",+ ], function(uiTPL, options) {+ if($("#dialogOptions").length < 1) {+ var uiTemplate = Handlebars.compile( uiTPL );+ $('body').append(uiTemplate());+ options.initUI();+ }+ options.reInitUI();+ $('#dialogOptions').modal('show');+ });+ };+var initUI = function() {$("#appVersion").text(TSCORE.Config.DefaultSettings["appVersion"]+"beta");$("#appVersion").attr("title","["+TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"]+"]");@@ -242,57 +257,8 @@ define(function(require, exports, module) {// Open Options Dialog$( "#openOptions" ).click(function() {- require(['tsoptions'], function () {- $('#dialogOptions').modal('show');- });- });-- // Advanced Settings- $( "#advancedSettings" ).click(function() {- $('#dialogOptions').modal('hide');- require([- 'ext/editorText/codemirror/codemirror.js',- 'css!ext/editorText/codemirror/codemirror.css',- 'css!ext/editorText/extension.css',- ], function() {- require([- 'ext/editorText/codemirror/mode/javascript/javascript.js',- ], function() {- jsonEditor = CodeMirror(document.getElementById("settingsJSON"), {- fixedGutter: false,- mode: "javascript",- lineNumbers: true,- lineWrapping: true,- tabSize: 2,- collapseRange: true,- matchBrackets: true,- readOnly: false,- });- //jsonEditor.setSize("100%","100%");- jsonEditor.setValue(JSON.stringify(TSCORE.Config.Settings));- //jsonEditor.autoFormatRange();- $('#dialogAdvancedSetting').modal('show');- });- });- });-- $( "#defaultSettingsButton" ).click(function() {- TSCORE.showConfirmDialog(- "Warning",- "Are you sure you want to restore the default application settings?\n"+- "All manually made changes such as tags and taggroups will be lost.",- function() {- TSCORE.Config.loadDefaultSettings();- }- );- });-- $( "#saveSettingsButton" ).click(function() {- TSCORE.Config.Settings = jsonEditor.getValue();- TSCORE.Config.saveSettings();- TSCORE.reloadUI();+ showOptionsDialog();});- // End Advanced Settings// File Menu$( "#fileMenuAddTag" ).click( function() {diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex 5218f410c..a05c408e5 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -428,7 +428,6 @@ define(function(require, exports, module) {});$( "#deleteLocationButton" ).on("click", function() {- $("#dialogLocationEdit").modal("hide");showDeleteFolderConnectionDialog();});}diff --git a/data/js/options.ui.js b/data/js/options.ui.jsindex b2846d52e..f47100619 100644--- a/data/js/options.ui.js+++ b/data/js/options.ui.js@@ -57,26 +57,6 @@ define(function(require, exports, module) {}function initUI() {- $("#extensionsPathInput").val(TSCORE.Config.getExtensionPath());- $("#showHiddenFilesCheckbox").attr("checked",TSCORE.Config.getShowUnixHiddenEntries());- $("#checkforUpdatesCheckbox").attr("checked",TSCORE.Config.getCheckForUpdates());-- TSCORE.Config.getPerspectives().forEach(function (value, index) {- addPerspective($('#perspectiveList'), value.id);- });-- $( "#perspectiveList" ).sortable();-- TSCORE.Config.getSupportedFileTypes().forEach(function (value, index) {- addFileType($('#fileTypesList'), value.type, value.viewer, value.editor);- });-- $('#saveSettingsCloseButton').click(function() {- updateSettings();- $('#dialogOptions').modal("hide");- //TSCORE.reloadUI();- });-$('#addFileTypeButton').click(function(e) {// Fixes reloading of the application by clicke.preventDefault();@@ -89,8 +69,58 @@ define(function(require, exports, module) {e.preventDefault();addPerspective($('#perspectiveList'), "");- });+ });++ $('#saveSettingsCloseButton').click(function() {+ updateSettings();+ $('#dialogOptions').modal("hide");+ //TSCORE.reloadUI();+ });++ $( "#defaultSettingsButton" ).click(function() {+ TSCORE.showConfirmDialog(+ "Warning",+ "By restoring the defalt setting, all locations, tags and taggroups will be lost."++ " Are you sure you want to continue?",+ function() {+ TSCORE.Config.loadDefaultSettings();+ }+ );+ });+}++ function reInitUI() {+ $("#extensionsPathInput").val(TSCORE.Config.getExtensionPath());+ $("#showHiddenFilesCheckbox").attr("checked",TSCORE.Config.getShowUnixHiddenEntries());+ $("#checkforUpdatesCheckbox").attr("checked",TSCORE.Config.getCheckForUpdates());+ $("#calculateTagsCheckbox").attr("checked",TSCORE.Config.getCalculateTags());+++ $('#perspectiveList').empty();+ TSCORE.Config.getPerspectives().forEach(function (value, index) {+ addPerspective($('#perspectiveList'), value.id);+ });++ $('#fileTypesList').empty();+ TSCORE.Config.getSupportedFileTypes().forEach(function (value, index) {+ addFileType($('#fileTypesList'), value.type, value.viewer, value.editor);+ });++ $('#dialogOptions a:first').tab('show');+ }++ function updateSettings() {+// TSCORE.Config.setExtensionPath($("#extensionsPathInput").val());+ TSCORE.Config.setShowUnixHiddenEntries($('#showHiddenFilesCheckbox').is(":checked"));+ TSCORE.Config.setCheckForUpdates($('#checkforUpdatesCheckbox').is(":checked"));+ TSCORE.Config.setCalculateTags($('#calculateTagsCheckbox').is(":checked"));++ TSCORE.Config.setPerspectives(collectPerspectivesData());+ TSCORE.Config.setSupportedFileTypes(collectSupportedFileTypesData());++ TSCORE.Config.saveSettings();+ }function collectPerspectivesData() {var data = new Array();@@ -118,16 +148,9 @@ define(function(require, exports, module) {return data;}- function updateSettings() {-// TSCORE.Config.setExtensionPath($("#extensionsPathInput").val());- TSCORE.Config.setShowUnixHiddenEntries($('#showHiddenFilesCheckbox').is(":checked"));- TSCORE.Config.setCheckForUpdates($('#checkforUpdatesCheckbox').is(":checked"));-- TSCORE.Config.setPerspectives(collectPerspectivesData());- TSCORE.Config.setSupportedFileTypes(collectSupportedFileTypesData());-- TSCORE.Config.saveSettings();- }- initUI();+ // Public Methods+ exports.initUI = initUI;+ exports.reInitUI = reInitUI;+});\ No newline at end of filediff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.jsindex 90cedbbfe..bc7c5c804 100644--- a/data/js/perspective.manager.js+++ b/data/js/perspective.manager.js@@ -241,7 +241,7 @@ var changePerspective = function (viewType) {}// Clear the list with the selected files- TSCORE.PerspectiveManager.clearSelectedFiles();+ exports.clearSelectedFiles();TSCORE.hideLoadingAnimation();};@@ -253,7 +253,7 @@ var clearSelectedFiles = function () {try {perspectives[i].clearSelectedFiles();} catch(e) {- console.log("Error while executing 'clearSelectedFiles' on "+perspectives[i].ID);+ console.log("Error while executing 'clearSelectedFiles' on "+perspectives[i].ID+" - "+e);}}};diff --git a/data/js/settings.api.js b/data/js/settings.api.jsindex d54cbb6c2..3145fd6c4 100644--- a/data/js/settings.api.js+++ b/data/js/settings.api.js@@ -210,12 +210,17 @@ define(function(require, exports, module) {}if(oldBuildNumber <= 1700) {- addTagGroup({ "title": "Tags in Perspective", "key": "CTG", "expanded": true,"children": []});+ //addTagGroup({ "title": "Tags in Perspective", "key": "CTG", "expanded": true,"children": []});+ setPrefixTagContainer("");+ setTagDelimiter(" ");+ setCalculateTags(false);}saveSettings();}};++ //////////////////// Settings upgrade methods ///////////////////var addTagGroup = function(newTagGroup) {var tagGroupExist = false;@@ -273,6 +278,8 @@ define(function(require, exports, module) {});}};++ //////////////////// getter and setter methods ///////////////////var getPerspectiveExtensions = function() {if(exports.Settings["ootbPerspectives"] == null) {@@ -346,6 +353,39 @@ define(function(require, exports, module) {exports.Settings["checkForUpdates"] = value;};+ var getPrefixTagContainer = function() {+ if(exports.Settings["prefixTagContainer"] == null) {+ exports.Settings["prefixTagContainer"] = exports.DefaultSettings["prefixTagContainer"];+ }+ return exports.Settings["prefixTagContainer"];+ };++ var setPrefixTagContainer = function(value) {+ exports.Settings["prefixTagContainer"] = value;+ };++ var getTagDelimiter = function() {+ if(exports.Settings["tagDelimiter"] == null) {+ exports.Settings["tagDelimiter"] = exports.DefaultSettings["tagDelimiter"];+ }+ return exports.Settings["tagDelimiter"];+ };++ var setTagDelimiter = function(value) {+ exports.Settings["tagDelimiter"] = value;+ };++ var getCalculateTags = function() {+ if(exports.Settings["calculateTags"] == null) {+ exports.Settings["calculateTags"] = exports.DefaultSettings["calculateTags"];+ }+ return exports.Settings["calculateTags"];+ };++ var setCalculateTags = function(value) {+ exports.Settings["calculateTags"] = value;+ };+var getSupportedFileTypes = function() {if(exports.Settings["supportedFileTypes"] == null) {exports.Settings["supportedFileTypes"] = exports.DefaultSettings["supportedFileTypes"];@@ -369,6 +409,8 @@ define(function(require, exports, module) {return exports.Settings["newMDFileContent"];};+ //////////////////// API methods ///////////////////+var getFileTypeEditor = function(fileTypeExt) {for(var i=0; i < exports.Settings["supportedFileTypes"].length; i++) {if(exports.Settings["supportedFileTypes"][i].type == fileTypeExt) {@@ -723,6 +765,12 @@ define(function(require, exports, module) {exports.setCheckForUpdates = setCheckForUpdates;exports.getSupportedFileTypes = getSupportedFileTypes;exports.setSupportedFileTypes = setSupportedFileTypes;+ exports.setPrefixTagContainer = setPrefixTagContainer;+ exports.getPrefixTagContainer = getPrefixTagContainer;+ exports.getTagDelimiter = getTagDelimiter;+ exports.setTagDelimiter = setTagDelimiter;+ exports.getCalculateTags = getCalculateTags;+ exports.setCalculateTags = setCalculateTags;exports.getPerspectiveExtensions = getPerspectiveExtensions;exports.getActivatedPerspectiveExtensions = getActivatedPerspectiveExtensions;diff --git a/data/js/settings.default.js b/data/js/settings.default.jsindex ffb3a05bd..874e4e17f 100644--- a/data/js/settings.default.js+++ b/data/js/settings.default.js@@ -7,7 +7,7 @@ define(function(require, exports, module) {exports.defaultSettings = {"appName": "TagSpaces","appVersion": "1.7",- "appBuild": "1767",+ "appBuild": "1774","settingsVersion": 2,"newTextFileContent": "Text file created with TagSpaces!","newHTMLFileContent": "<html><head><title>Created with TagSpaces!</title></head><body>Feel free to change this text...</body></html>",@@ -17,6 +17,9 @@ exports.defaultSettings = {"lastOpenedDirectory": "","tagspacesList": [],"extensionsPath": "ext",+ "prefixTagContainer": "",+ "tagDelimiter": " ",+ "calculateTags": false,"ootbPerspectives": [ 'perspectiveList', 'perspectiveGrid', 'perspectiveGraph' ],"ootbViewers": [ "viewerBrowser", "viewerMD", "viewerImage", "viewerPDF", "editorText", "viewerText" ],"ootbEditors": [ "editorHTML", "editorText" ],diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex a0121e18e..99416c6d5 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -10,8 +10,6 @@ define(function(require, exports, module) {var BEGIN_TAG_CONTAINER = "[",END_TAG_CONTAINER = "]",- TAG_DELIMITER = " ",- PREFIX_TAG_CONTAINER = " - ",DIR_SEPARATOR = isWindows() ? "\\" : "/";function isWindows() {@@ -158,7 +156,7 @@ define(function(require, exports, module) {var cleanedTags = [];var tagContainer = fileName.slice(beginTagContainer+1,endTagContainer).trim();- tags = tagContainer.split(TAG_DELIMITER);+ tags = tagContainer.split(TSCORE.Config.getTagDelimiter());for (var i=0; i < tags.length; i++) {// Min tag length set to 1 character@@ -239,7 +237,7 @@ define(function(require, exports, module) {newFileName = fileName +tagsString;} else {// File has an extension- newFileName = fileName.substring(0,lastDotPosition)+PREFIX_TAG_CONTAINER+tagsString+"."+fileExt;+ newFileName = fileName.substring(0,lastDotPosition)+TSCORE.Config.getPrefixTagContainer()+tagsString+"."+fileExt;}} else {// File does not have an extension@@ -389,8 +387,7 @@ define(function(require, exports, module) {exports.DIR_SEPARATOR = DIR_SEPARATOR;exports.beginTagContainer = BEGIN_TAG_CONTAINER;exports.endTagContainer = END_TAG_CONTAINER;- exports.tagDelimiter = TAG_DELIMITER;- exports.isWindows = isWindows;+exports.extractFileName = extractFileName;exports.extractFileNameWithoutExt = extractFileNameWithoutExt;exports.extractContainingDirectoryPath = extractContainingDirectoryPath;diff --git a/data/templates/OptionsDialog.html b/data/templates/OptionsDialog.htmlnew file mode 100644index 000000000..1a0530be9--- /dev/null+++ b/data/templates/OptionsDialog.html@@ -0,0 +1,74 @@+<div id="dialogOptions" class="modal" tabindex="-1" role="dialog" aria-hidden="true">+ <div class="modal-dialog">+ <div class="modal-content">+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Options</h4>+ </div>+ <div class="modal-body form" style="height: 420px;" id="optionsAccordion">+ <ul class="nav nav-tabs">+ <li><a href="#general" data-toggle="tab" class="optionsTitle">General</a></li>+ <li><a href="#perspectives" data-toggle="tab" class="optionsTitle">Perspectives</a></li>+ <li><a href="#filetypes" data-toggle="tab" class="optionsTitle">File Types</a></li>+ <li><a href="#experimental" data-toggle="tab" class="optionsTitle">Experimental</a></li>+ </ul>+ <div class="tab-content">+ <div class="tab-pane active" id="general" style="overflow-y: auto;">+ <div class='form-group'>+ <label class="checkbox">+ <input type='checkbox' id='showHiddenFilesCheckbox' >+ Show files/directories with a dot(.) in front of the name (unix/linux/osx hidden files)+ </label>+ </div>+ <div class='form-group'>+ <label class="checkbox">+ <input type='checkbox' id='checkforUpdatesCheckbox' >+ Check for new version on startup+ </label>+ </div>+ </div>++ <div class="tab-pane" id="perspectives">+ <h6>The changes made in this tab will take effect after restarting of the application.</h6>+ <div id='perspectiveList'></div>+ <button class='btn btn-default' style="margin-top: 10px" id='addPerspectiveButton'>+ <i class='fa fa-plus' data-i18n="app.addNewPerspective"> Add new perspective</i>+ </button>+ </div>++ <div class="tab-pane" id="filetypes" style="height: 370px; padding-top: 10px; overflow-y: auto;">+ <div id='fileTypesList'></div>+ <button class='btn btn-default' style="margin-top: 10px" id='addFileTypeButton'>+ <i class='fa fa-plus' data-i18n="app.addNewFileExtension"> Add new file extension</i>+ </button>+ </div>++ <div class="tab-pane" id="experimental">+ <h6>Be carefull changing setting in this setting.</h6>+ <div class='form-group'>+ <label for='extensionsPathInput' data-i18n="app.extensionsFolder">Extensions folder</label>+ <input type='text' class='form-control' id='extensionsPathInput'+ data-i18n="[placeholder]app" placeholder='file:///c:\\tagspaces-extensions'+ data-i18n="[title]app" title='Path to your tagspaces extensions'>+ </div>+ <!--button class="btn btn-default" style="margin-bottom: 10px" id="switchLang" data-i18n="[title]app.switchLanguageTooltip;">+ <i class="fa fa-asterisk"> Test Change Language</i>+ </button-->+ <div class='form-group'>+ <label class="checkbox">+ <input type='checkbox' id='calculateTagsCheckbox' >+ Calculate tags from the current search results (reduces the performance while browsing directories)+ </label>+ </div>+ </div>++ </div>+ </div>+ <div class="modal-footer">+ <button class="btn btn-danger pull-left" id="defaultSettingsButton" title="Restore Default Settings" aria-hidden="true">Default Settings</button>+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button class="btn btn-primary" id="saveSettingsCloseButton">Save</button>+ </div>+ </div><!-- /.modal-content -->+ </div><!-- /.modal-dialog -->+</div><!-- /.modal -->\ No newline at end of filediff --git a/default.settings.tmpl.js b/default.settings.tmpl.jsindex d88bddfc9..dfe9678fa 100644--- a/default.settings.tmpl.js+++ b/default.settings.tmpl.js@@ -17,6 +17,9 @@ exports.defaultSettings = {"lastOpenedDirectory": "","tagspacesList": [@DEFAULTLOCATIONS@],"extensionsPath": "ext",+ "prefixTagContainer": "",+ "tagDelimiter": " ",+ "calculateTags": false,"ootbPerspectives": [ 'perspectiveList', 'perspectiveGrid', 'perspectiveGraph' ],"ootbViewers": [ "viewerBrowser", "viewerMD", "viewerImage", "viewerPDF", "editorText", "viewerText" ],"ootbEditors": [ "editorHTML", "editorText" ],