TagSpaces is an offline, open source, document manager with tagging support
Improving the file create dialog
uggrockab1e4bc78ec9
diff --git a/build.properties b/build.propertiesindex 6723058ab..1c961855c 100644--- a/build.properties+++ b/build.properties@@ -2,7 +2,7 @@ version = 1.6package = tagspacesappname = TagSpaces# Chromestore accepts descriptions no longer than 132 characters-appdescription = File manager for your local files, with support of tagging and editing.+appdescription = A offline file browser/manager for your local files, with support of tagging and editing.addonsdk.dir = ../addonsdk[1.14]backup.dir = ../backupsbuilds.dir = ../buildsdiff --git a/data/ext/editorText/extension.js b/data/ext/editorText/extension.jsindex 8d724e899..62433537f 100644--- a/data/ext/editorText/extension.js+++ b/data/ext/editorText/extension.js@@ -66,20 +66,20 @@ define(function(require, exports, module) {TSCORE.IO.loadTextFile(filePath);});});- }+ };exports.viewerMode = function(isViewerMode) {cmEditor.readOnly = isViewerMode;- }+ };exports.setContent = function(content) {// console.log("Content: "+content);cmEditor.setValue(content);- }+ };exports.getContent = function() {return cmEditor.getValue();- }+ };var filetype = new Array();filetype["h"] = "clike";diff --git a/data/ext/viewerImage/extension.js b/data/ext/viewerImage/extension.jsindex 9a40776e0..f82d6e65f 100644--- a/data/ext/viewerImage/extension.js+++ b/data/ext/viewerImage/extension.js@@ -33,19 +33,19 @@ define(function(require, exports, module) {UI.buildUI();TSCORE.hideLoadingAnimation();});- }+ };exports.viewerMode = function(isViewerMode) {console.log("viewerMode not supported on this extension");- }+ };exports.setContent = function(content) {console.log("setContent not supported on this extension");- }+ };exports.getContent = function() {console.log("getContent not supported on this extension");- }+ };// Varsexports.Title = extensionTitle;diff --git a/data/ext/viewerImage/viewerUI.js b/data/ext/viewerImage/viewerUI.jsindex 40b11f2ca..88cc9c557 100644--- a/data/ext/viewerImage/viewerUI.js+++ b/data/ext/viewerImage/viewerUI.js@@ -118,7 +118,7 @@ console.log("Loading UI for Image Viewer");*/- }+ };exports.ExtUI = ExtUI;});\ No newline at end of filediff --git a/data/index.html b/data/index.htmlindex 43904ef64..16449cbb6 100644--- a/data/index.html+++ b/data/index.html@@ -162,21 +162,41 @@</div><div class="modal-body form-horizontal"><div class="control-group">- <label class="control-label" for="fileTypeChooser">Filetype</label>+ <label class="control-label" for="fileTypeChooser">Type</label><div class="controls"><div class="btn-group" data-toggle="buttons-radio" name="fileTypeChooser">- <button id="txtFileTypeButton" title="Create a plain text file" class="btn">TXT</button>- <button id="mdFileTypeButton" title="Create a MarkDown file" class="btn">MD</button>- <button id="htmlFileTypeButton" title="Create a HTML file" class="btn">HTML</button>+ <button id="txtFileTypeButton" title="Create a TXT File" class="btn">Plain Text</button>+ <button id="htmlFileTypeButton" title="Create a HTML File" class="btn">Rich Text</button>+ <button id="mdFileTypeButton" title="Create a MarkDown File" class="btn">MarkDown</button></div></div></div><div class="control-group">- <label class="control-label" for="newFileName">Filename</label>+ <label class="control-label" for="newFileName">Title</label><div class="controls">- <input type="text" id="newFileName" id="newFileName" placeholder="Filename">+ <input type="text" id="newFileName" class="input-xlarge" placeholder="Title of the file"></div>- </div>+ </div>+ <div class="control-group">+ <label class="control-label" for="newFileNameTags">Tags</label>+ <div class="controls">+ <input type="text" id="newFileNameTags" name="newFileNameTags" autocomplete="off" class="input-xlarge" placeholder="Comma separated list of tags">+ </div>+ </div>+ <div class="control-group">+ <div class="controls">+ <label class="checkbox">+ <input type="checkbox" id="tagWithCurrentDate"> Tag with current date (e.g. 20131210 for 10th of December, 2013)+ </label>+ </div>+ </div>+ <!--div class="control-group">+ <div class="controls">+ <label class="checkbox">+ <input type="checkbox"> Creates the file in YYYYMM (e.g. 201312) subdirectory.+ </label>+ </div>+ </div--></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 64cfee9d9..2120ec530 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -11,7 +11,9 @@ define(function(require, exports, module) {var editor = undefined;var formatter = undefined;- var fileContent = undefined;+ var fileContent = undefined;+ var fileType = undefined;+var showAlertDialog = function(message, title) {if (!title) { title = 'Alert'; }@@ -68,10 +70,24 @@ define(function(require, exports, module) {var showFileCreateDialog = function() {fileContent = TSCORE.Config.getNewTextFileContent(); // Default new file in text file- $( "#newFileName" ).val(".txt");+ fileType = "txt";++ $( "#newFileNameTags" ).typeahead( {+ "source": TSCORE.Config.getAllTags()+ });+ $("#newFileNameTags").val("");+ $("#newFileName").val("");+ $("#tagWithCurrentDate").prop('checked', false);+$( '#dialogFileCreate' ).modal({show: true});$( '#txtFileTypeButton' ).button('toggle');++ $('#dialogFileCreate').on('shown', function () {+ $('#newFileName').focus();+ });};++var showFileRenameDialog = function() {$( "#renamedFileName" ).val(TSCORE.TagUtils.extractFileName(TSCORE.selectedFiles[0]));@@ -96,10 +112,8 @@ define(function(require, exports, module) {e.preventDefault();fileContent = TSCORE.Config.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");- }+ fileType = "txt";+});$( "#htmlFileTypeButton" ).click(function(e) {@@ -107,10 +121,7 @@ define(function(require, exports, module) {e.preventDefault();fileContent = TSCORE.Config.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");- }+ fileType = "html";});$( "#mdFileTypeButton" ).click(function(e) {@@ -118,25 +129,39 @@ define(function(require, exports, module) {e.preventDefault();fileContent = TSCORE.Config.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");- }+ fileType = "md";});+$( '#fileCreateConfirmButton' ).click(function() {- var bValid = true;-// bValid = bValid && checkLength( newFileName, "filename", 4, 200 );+ var fileTags = "";+ var rawTags = $( "#newFileNameTags" ).val().split(",");++ rawTags.forEach(function (value, index) {+ if(index == 0) {+ fileTags = value;+ } else {+ fileTags = fileTags + TSCORE.TagUtils.tagDelimiter + value;+ }+ });++ if($("#tagWithCurrentDate").prop("checked")) {+ if(fileTags.length < 1) {+ fileTags = TSCORE.TagUtils.formatDateTime4Tag(new Date());+ } else {+ fileTags = fileTags + TSCORE.TagUtils.tagDelimiter + TSCORE.TagUtils.formatDateTime4Tag(new Date());+ }+ }++ if(fileTags.length > 0) {+ fileTags = TSCORE.TagUtils.beginTagContainer + fileTags + TSCORE.TagUtils.endTagContainer;+ }++ var fileName = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val()+fileTags+"."+fileType;++ TSCORE.IO.saveTextFile(fileName,fileContent);+ TSCORE.IO.listDirectory(TSCORE.currentPath);-/* if(TSCORE.fileExists($( "#newFileName" ).val())) {- updateTips("File already exists.");- bValid = false;- } */- if ( bValid ) {- TSCORE.IO.saveTextFile(TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val(),fileContent);- TSCORE.startTime = new Date().getTime();- TSCORE.IO.listDirectory(TSCORE.currentPath);- }});$( '#renameFileButton' ).click(function() {diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex d1ac5d876..05f071190 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -386,6 +386,9 @@ define(function(require, exports, module) {// Public API definitionexports.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;