TagSpaces is an offline, open source, document manager with tagging support
merging develop
uggrocka533ba817370
diff --cc data/js/core.ui.jsindex fb266f376,47e7436d7..fa2c0b41e--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@@ -630,196 -229,524 +229,537 @@@ define(function(require, exports, modulTSCORE.showFileRenameDialog(TSCORE.selectedFiles[0]);});- $('#fileMenuMoveCopyFile').click(function() {- TSCORE.showMoveCopyFilesDialog();- });+ $('#fileMenuMoveCopyFile').click(function() {+ TSCORE.showMoveCopyFilesDialog();+ });++ $('#fileMenuDeleteFile').click(function() {+ TSCORE.showFileDeleteDialog(TSCORE.selectedFiles[0]);+ });++ $('#fileOpenProperties').click(function() {});+ // End File Menu++ $('#showLocations').click(function() {+ showLocationsPanel();+ });++ $('#showTagGroups').click(function() {+ showTagsPanel();+ });++ $('#contactUs').click(function() {+ showContactUsPanel();+ });++ // Hide the tagGroupsContent or locationContent by default+ $('#locationContent').hide();++ $('#perspectiveSwitcherButton').prop('disabled', true);+ var $contactUsContent = $('#contactUsContent');+ $contactUsContent.on('click', '#openHints', showWelcomeDialog);+ $contactUsContent.on('click', '#openUservoice', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openGooglePlay', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openAppleAppStore', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openWhatsnew', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openGitHubIssues', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#helpUsTranslate', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openTwitter', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openTwitter2', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openGooglePlus', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openFacebook', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });+ $contactUsContent.on('click', '#openSupportUs', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });++ $('#newVersionMenu').on('click', '.whatsNewLink', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });++ // Hide drop downs by click and drag+ $(document).click(function() {+ TSCORE.hideAllDropDownMenus();+ });++ platformTuning();+ }++ function showFileDropArea() {+ if ($('#fileDropArea').length < 1) {+ $('#viewContainers').append(fileDropTemplate({}));+ $('#fileDropArea').on('dragleave', function(event) {+ event.preventDefault();+ hideFileDropArea();+ });+ } else {+ $('#fileDropArea').show();+ }+ }++ function hideFileDropArea() {+ $('#fileDropArea').hide();+ }++ function onFileReadComplete(event) {+ console.log('Content on file read complete: ' + JSON.stringify(event));+ //change name for ios fakepath+ if (isCordovaiOS) {+ var fileExt = TSCORE.TagUtils.extractFileExtension(addFileInputName);+ addFileInputName = TSCORE.TagUtils.beginTagContainer + TSCORE.TagUtils.formatDateTime4Tag(new Date(), true) + TSCORE.TagUtils.endTagContainer + fileExt;+ }+ var filePath = TSCORE.currentPath + TSCORE.dirSeparator + addFileInputName;++ // TODO event.currentTarget.result is ArrayBuffer+ // Sample call from PRO version using content = TSCORE.Utils.base64ToArrayBuffer(baseString);++ TSCORE.IO.saveBinaryFilePromise(filePath, event.currentTarget.result).then(function() {+ TSCORE.showSuccessDialog("File saved successfully.");+ TSCORE.PerspectiveManager.refreshFileListContainer();+ }, function(error) {+ TSCORE.hideLoadingAnimation();+ TSCORE.showAlertDialog("Saving " + filePath + " failed.");+ console.error("Save to file " + filePath + " failed " + error);+ });+ addFileInputName = undefined;+ }++ function showWaitingDialog(message, title) {+ if (!title) {+ title = $.i18n.t('ns.dialogs:titleWaiting');+ }+ if (!message) {+ message = 'No Message to Display.';+ }+ var waitingModal = $('#waitingDialog');+ waitingModal.find('#waitingHeader').text(title);+ waitingModal.find('#waitingMessage').text(message);++ waitingDialogTimeoutID = window.setTimeout(function() {+ waitingModal.modal({+ backdrop: 'static',+ show: true+ });+ }, 500);++ waitingModal.draggable({+ handle: ".modal-header"+ });+ }++ function hideWaitingDialog(message, title) {+ window.clearTimeout(waitingDialogTimeoutID);+ $('#waitingDialog').modal('hide');+ }++ function showSuccessDialog(message) {+ if (!message) {+ return;+ }+ var n = noty({+ text: message,+ //dismissQueue: false,+ layout: 'bottomCenter',+ theme: 'relax',+ type: 'success',+ animation: {+ open: 'animated fadeIn',+ close: 'animated fadeOut',+ easing: 'swing',+ speed: 500+ },+ timeout: 4000,+ maxVisible: 1,+ closeWith: ['button', 'click'],+ });+ }++ function showAlertDialog(message, title) {+ if (!title) {+ title = $.i18n.t('ns.dialogs:titleAlert');+ }+ if (!message) {+ message = 'No Message to Display.';+ }+ var n = noty({+ text: "<strong>" + title + "</strong><br>" + message,+ layout: 'bottomCenter',+ theme: 'relax',+ type: 'warning',+ animation: {+ open: 'animated fadeIn',+ close: 'animated fadeOut',+ easing: 'swing',+ speed: 500+ },+ timeout: 6000,+ maxVisible: 4,+ closeWith: ['button', 'click'],+ });+ /*var alertModal = $('#alertDialog');+ alertModal.find('h4').text(title);+ alertModal.find('.modal-body').empty();+ alertModal.find('.modal-body').text(message);+ alertModal.find('#okButton').off('click').click(function() {+ alertModal.modal('hide');+ });+ // Focusing the ok button by default+ alertModal.off('shown.bs.modal');+ alertModal.on('shown.bs.modal', function() {+ alertModal.find('#okButton').focus();+ });+ alertModal.modal({+ backdrop: 'static',+ show: true+ });*/+ }++ function showConfirmDialog(title, message, okCallback, cancelCallback, confirmShowNextTime) {+ if (!title) {+ title = $.i18n.t('ns.dialogs:titleConfirm');+ }+ if (!message) {+ message = 'No Message to Display.';+ }+ var confirmModal = $('#confirmDialog');+ if (confirmShowNextTime) {+ confirmModal.find('#showThisDialogAgain').prop('checked', true);+ } else {+ confirmModal.find('#showThisDialogAgainContainer').hide();+ }+ confirmModal.find('h4').text(title);+ confirmModal.find('#dialogContent').text(message);+ confirmModal.find('#confirmButton').off('click').click(function() {+ okCallback(confirmModal.find('#showThisDialogAgain').prop('checked'));+ confirmModal.modal('hide');+ });+ // Focusing the confirm button by default+ confirmModal.off('shown.bs.modal');+ confirmModal.on('shown.bs.modal', function() {+ confirmModal.find('#confirmButton').focus();+ });+ confirmModal.find('#cancelButton').off('click').click(function() {+ if (cancelCallback !== undefined) {+ cancelCallback();+ }+ confirmModal.modal('hide');+ });+ confirmModal.modal({+ backdrop: 'static',+ show: true+ });+ confirmModal.draggable({+ handle: ".modal-header"+ });+ }++ function showFileCreateDialog() {+ fileContent = TSCORE.Config.getNewTextFileContent();+ // Default new file in text file+ fileType = 'txt';+ $('#newFileNameTags').select2('data', null);+ $('#newFileNameTags').select2({+ multiple: true,+ tags: TSCORE.Config.getAllTags(),+ tokenSeparators: [+ ',',+ ' '+ ],+ minimumInputLength: 2,+ selectOnBlur: true+ });+ $('#newFileName').val('');+ $('#tagWithCurrentDate').prop('checked', false);+ $('#txtFileTypeButton').button('toggle');+ $('#formFileCreate').validator();+ $('#formFileCreate').submit(function(e) {+ e.preventDefault();+ });+ $('#formFileCreate').on('invalid.bs.validator', function() {+ $('#fileCreateConfirmButton').prop('disabled', true);+ });+ $('#formFileCreate').on('valid.bs.validator', function() {+ $('#fileCreateConfirmButton').prop('disabled', false);+ });+ $('#dialogFileCreate').on('shown.bs.modal', function() {+ $('#newFileName').select2().focus();+ });+ $('#dialogFileCreate').modal({+ backdrop: 'static',+ show: true+ });+ $('#dialogFileCreate').draggable({+ handle: ".modal-header"+ });+ }++ function showFileRenameDialog(filePath) {+ $('#renamedFileName').attr('filepath', filePath);+ $('#renamedFileName').val(TSCORE.TagUtils.extractFileName(filePath));- $('#fileMenuDeleteFile').click(function() {- TSCORE.showFileDeleteDialog(TSCORE.selectedFiles[0]);+ $('#formFileRename').validator();+ $('#formFileRename').submit(function(e) {+ e.preventDefault();+ if ($('#renameFileButton').prop('disabled') === false) {+ $('#renameFileButton').click();+ }});-- $('#fileOpenProperties').click(function() {});- // End File Menu- $('#showLocations').click(function() {- showLocationsPanel();+ $('#formFileRename').on('invalid.bs.validator', function() {+ $('#renameFileButton').prop('disabled', true);});-- $('#showTagGroups').click(function() {- showTagsPanel();+ $('#formFileRename').on('valid.bs.validator', function() {+ $('#renameFileButton').prop('disabled', false);});-- $('#contactUs').click(function() {- showContactUsPanel();+ $('#dialogFileRename').on('shown.bs.modal', function() {+ $('#renamedFileName').focus();});-- // Hide the tagGroupsContent or locationContent by default- $('#locationContent').hide();-- // Search UI- $('#searchToolbar').on('click', '#closeSearchOptionButton', function() {- $('#searchOptions').hide();+ $('#dialogFileRename').modal({+ backdrop: 'static',+ show: true});-- $('#searchOptions').on('click', '.close', function() {- $('#searchOptions').hide();+ $('#dialogFileRename').draggable({+ handle: ".modal-header"});+ }- $('#searchToolbar').on('click', '#includeSubfoldersOption', function() {- var searchQuery = $('#searchBox').val();- if (searchQuery.indexOf('?') === 0) {- $('#includeSubfoldersOption i').removeClass('fa-toggle-on').addClass('fa-toggle-off');- $('#searchBox').val(searchQuery.substring(1, searchQuery.length));- } else {- $('#includeSubfoldersOption i').removeClass('fa-toggle-off').addClass('fa-toggle-on');- $('#searchBox').val('?' + searchQuery);- }+ function showFileDeleteDialog(filePath) {+ console.log('Deleting file...');+ var dlgConfirmMsgId = 'ns.dialogs:fileDeleteContentConfirm';+ if (TSCORE.PRO && TSCORE.Config.getUseTrashCan()) {+ dlgConfirmMsgId = 'ns.pro:trashDeleteContentConfirm';+ }+ TSCORE.showConfirmDialog($.i18n.t('ns.dialogs:fileDeleteTitleConfirm'), $.i18n.t(dlgConfirmMsgId, {+ filePath: filePath+ }), function() {+ TSCORE.IO.deleteFilePromise(filePath).then(function() {+ TSPOSTIO.deleteElement(filePath);+ },+ function(error) {+ TSCORE.hideLoadingAnimation();+ TSCORE.showAlertDialog("Deleting file " + filePath + " failed.");+ console.error("Deleting file " + filePath + " failed " + error);+ }+ );});+ }- /*$('#searchBox').on('show.bs.popover', function() {- var searchQuery = $('#searchBox').val();- if (searchQuery.indexOf('?') === 0) {- $('#includeSubfoldersOption i').removeClass('fa-toggle-off').addClass('fa-toggle-on');- } else {- $('#includeSubfoldersOption i').removeClass('fa-toggle-on').addClass('fa-toggle-off');- }- });*/-- $('#searchBox').prop('disabled', true)- .focus(function() {- if (!TSCORE.FileOpener.isFileOpened()) {- $("#searchOptions").show();- }- })- .keyup(function(e) {- // On enter fire the search- if (e.keyCode === 13) {- $('#clearFilterButton').addClass('filterOn');- TSCORE.PerspectiveManager.redrawCurrentPerspective();- $('#searchOptions').hide();- $('#searchButton').focus();- } else if (e.keyCode == 27) {- cancelSearch();- } else {- TSCORE.Search.nextQuery = this.value;- }- if (this.value.length === 0) {- TSCORE.Search.nextQuery = this.value;- $('#clearFilterButton').removeClass('filterOn');- TSCORE.PerspectiveManager.redrawCurrentPerspective();- }- }).blur(function() {- if (this.value.length === 0) {- $('#clearFilterButton').removeClass('filterOn');- TSCORE.PerspectiveManager.redrawCurrentPerspective();- }- });+ function showDeleteFilesDialog() {+ console.log('Deleting files...');+ var selFiles = " ";- $('#showSearchButton').on('click', function() {- TSCORE.showSearchArea();+ TSCORE.Utils.getUniqueSelectedFiles().forEach(function(file) {+ selFiles += " " + TSCORE.Utils.baseName(file) + " ,";});- $('#searchButton').prop('disabled', true).click(function(evt) {- evt.preventDefault();- $('#clearFilterButton').addClass('filterOn');- $('#searchOptions').hide();- TSCORE.PerspectiveManager.redrawCurrentPerspective();- });+ selFiles = selFiles.substring(0, selFiles.length - 1);+ var dlgConfirmMsgId = 'ns.dialogs:selectedFilesDeleteContentConfirm';- $('#clearFilterButton').prop('disabled', true).click(function(e) {- e.preventDefault();- cancelSearch();- });- // Search UI END+ if (TSCORE.PRO && TSCORE.Config.getUseTrashCan()) {+ dlgConfirmMsgId = 'ns.pro:trashFilesDeleteContentConfirm';+ }- $('#perspectiveSwitcherButton').prop('disabled', true);- var $contactUsContent = $('#contactUsContent');- $contactUsContent.on('click', '#openHints', showWelcomeDialog);- $contactUsContent.on('click', '#openUservoice', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));- });- $contactUsContent.on('click', '#openGooglePlay', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));- });- $contactUsContent.on('click', '#openAppleAppStore', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));- });- $contactUsContent.on('click', '#openWhatsnew', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));- });- $contactUsContent.on('click', '#openGitHubIssues', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));- });- $contactUsContent.on('click', '#helpUsTranslate', function(e) {+ TSCORE.showConfirmDialog(+ $.i18n.t('ns.dialogs:fileDeleteTitleConfirm'),+ $.i18n.t(dlgConfirmMsgId, {selectedFiles: selFiles}),+ function() {+ TSCORE.IOUtils.deleteFiles(TSCORE.Utils.getUniqueSelectedFiles());+ }+ );+ }++ function showTagEditDialog() {+ $('#newTagName').val(TSCORE.selectedTag);+ $('#formEditTag').validator();+ $('#formEditTag').submit(function(e) {e.preventDefault();- openLinkExternally($(this).attr('href'));+ if ($('#editTagButton').prop('disabled') === false) {+ $('#editTagButton').click();+ }});- $contactUsContent.on('click', '#openTwitter', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ $('#formEditTag').on('invalid.bs.validator', function() {+ $('#editTagButton').prop('disabled', true);});- $contactUsContent.on('click', '#openTwitter2', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ $('#formEditTag').on('valid.bs.validator', function() {+ $('#editTagButton').prop('disabled', false);});- $contactUsContent.on('click', '#openGooglePlus', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ $('#dialogEditTag').on('shown.bs.modal', function() {+ $('#newTagName').focus();});- $contactUsContent.on('click', '#openFacebook', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ $('#dialogEditTag').modal({+ backdrop: 'static',+ show: true});- $contactUsContent.on('click', '#openSupportUs', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ $('#dialogEditTag').draggable({+ handle: ".modal-header"});- $('#newVersionMenu').on('click', '.whatsNewLink', function(e) {- e.preventDefault();- openLinkExternally($(this).attr('href'));+ }++ function showDirectoryBrowserDialog(path) {+ require([+ 'text!templates/DirectoryBrowserDialog.html',+ 'tsdirectorybrowser'+ ], function(uiTPL, controller) {+ TSCORE.directoryBrowser = controller;+ if ($('#directoryBrowserDialog').length < 1) {+ var uiTemplate = Handlebars.compile(uiTPL);+ $('body').append(uiTemplate());+ TSCORE.directoryBrowser.initUI();+ }+ $('#directoryBrowserDialog').i18n();+ TSCORE.IOUtils.listSubDirectories(path);});+ }- // Hide drop downs by click and drag- $(document).click(function() {- TSCORE.hideAllDropDownMenus();+ function showOptionsDialog() {+ require([+ 'text!templates/OptionsDialog.html',+ 'tsoptions'+ ], function(uiTPL, controller) {+ if ($('#dialogOptions').length < 1) {+ var uiTemplate = Handlebars.compile(uiTPL);+ $('body').append(uiTemplate({isProVersion: TSCORE.PRO ? true : false}));++ controller.initUI();+ }+ $('#dialogOptions').i18n();+ controller.reInitUI();});- };+ }- function cancelSearch() {- clearSearchFilter();- $('#searchToolbar').hide();- $('#showSearchButton').show();- // Restoring initial dir listing without subdirectories- TSCORE.IO.listDirectoryPromise(TSCORE.currentPath).then(- function(entries) {- TSPOSTIO.listDirectory(entries);+ function showWelcomeDialog() { startGettingStartedTour(); }+++ function showKeysDialog() {++ $('#dialogShortcuts').modal({++ backdrop: 'static',++ show: true,++ open: function() {++ $('.modal-body').val(TSCORE.Config.getSelectAllKeyBinding());+ }- ).catch(function(err) {- TSPOSTIO.errorOpeningPath(TSCORE.currentPath);- console.warn("Error listing directory" + err);++ });++ $('#dialogShortcuts').draggable({++ handle: ".modal-header"+ });+ }+- function showSearchArea() {- $('#showSearchButton').hide();- $('#searchToolbar').show();- $('#searchBox').focus();+ function startGettingStartedTour() {+ var tsGettingStarted = require('tsgettingstarted');+ tsGettingStarted.startTour();}- // Handle external links- function openLinkExternally(url) {- TSCORE.IO.openFile(url);+ function showMoveCopyFilesDialog() {+ require(['text!templates/MoveCopyFilesDialog.html'], function(uiTPL) {+ if ($('#dialogMoveCopyFiles').length < 1) {+ var uiTemplate = Handlebars.compile(uiTPL);+ $('body').append(uiTemplate());++ $('#moveFilesButton').click(function(e) {+ e.preventDefault();+ // TODO move to ioutils+ TSCORE.showWaitingDialog('Please wait, while files are being renamed.');+ var newFilePath, filePath;+ var fileOperations = [];+ for (var i = 0; i < TSCORE.selectedFiles.length; i++) {+ newFilePath = $('#moveCopyDirectoryPath').val() + TSCORE.dirSeparator + TSCORE.TagUtils.extractFileName(TSCORE.selectedFiles[i]);+ filePath = TSCORE.selectedFiles[i];+ fileOperations.push(TSCORE.IO.renameFilePromise(filePath, newFilePath));+ }+ Promise.all(fileOperations).then(function(success) {+ // TODO handle moving sidecar files+ TSCORE.hideWaitingDialog();+ TSCORE.navigateToDirectory(TSCORE.currentPath);+ TSCORE.showSuccessDialog("Files successfully moved");+ }, function(err) {+ TSCORE.hideWaitingDialog();+ TSCORE.showAlertDialog("Renaming files failed");+ });+ });++ $('#copyFilesButton').click(function(e) {+ e.preventDefault();+ TSCORE.showWaitingDialog('Please wait, while files are being copied.');+ var newFilePath, filePath;+ var fileOperations = [];+ for (var i = 0; i < TSCORE.selectedFiles.length; i++) {+ var newFilePath = $('#moveCopyDirectoryPath').val() + TSCORE.dirSeparator + TSCORE.TagUtils.extractFileName(TSCORE.selectedFiles[i]);+ var filePath = TSCORE.selectedFiles[i];+ fileOperations.push(TSCORE.IO.copyFilePromise(filePath, newFilePath));+ }+ Promise.all(fileOperations).then(function(success) {+ // TODO handle copying sidecar files+ TSCORE.hideWaitingDialog();+ TSCORE.navigateToDirectory(TSCORE.currentPath);+ TSCORE.showSuccessDialog("Files successfully copied");+ }, function(err) {+ TSCORE.hideWaitingDialog();+ TSCORE.showAlertDialog("Copying files failed");+ });+ });+ $('#selectDirectoryMoveCopyDialog').click(function(e) {+ e.preventDefault();+ TSCORE.IO.selectDirectory();+ });+ }+ $('#moveCopyDirectoryPath').val(TSCORE.currentPath);+ $('#moveCopyFileList').children().remove();+ for (var i = 0; i < TSCORE.selectedFiles.length; i++) {+ $('#moveCopyFileList').append($('<p>', {+ text: TSCORE.selectedFiles[i]+ }));+ }+ $('#dialogMoveCopyFiles').i18n();+ $('#dialogMoveCopyFiles').draggable({+ handle: '.modal-header'+ });+ $('#dialogMoveCopyFiles').modal({+ backdrop: 'static',+ show: true+ });+ $('#dialogMoveCopyFiles').draggable({+ handle: ".modal-header"+ });+ console.log('Selected files: ' + TSCORE.selectedFiles);+ });}- function clearSearchFilter() {- $('#searchOptions').hide();- $('#searchBox').val('');- $('#clearFilterButton').removeClass('filterOn');- TSCORE.Search.nextQuery = '';+ function showAboutDialog() {+ $('#dialogAboutTS').modal({+ backdrop: 'static',+ show: true+ });+ $('#dialogAboutTS').draggable({+ handle: ".modal-header"+ });}function disableTopToolbar() {@@@ -987,7 -898,8 +911,9 @@@exports.showFileRenameDialog = showFileRenameDialog;exports.showFileCreateDialog = showFileCreateDialog;exports.showFileDeleteDialog = showFileDeleteDialog;+ exports.showDeleteFilesDialog = showDeleteFilesDialog;exports.showWelcomeDialog = showWelcomeDialog;++ exports.showKeysDialog = showKeysDialog;exports.startGettingStartedTour = startGettingStartedTour;exports.showTagEditDialog = showTagEditDialog;exports.showOptionsDialog = showOptionsDialog;@@@ -1002,5 -913,4 +927,4 @@@exports.createHTMLFile = createHTMLFile;exports.createMDFile = createMDFile;exports.createTXTFile = createTXTFile;- exports.showSearchArea = showSearchArea;--});++});