TagSpaces is an offline, open source, document manager with tagging support
redesigning file dropping
uggrock0545c221f7f7
diff --git a/data/assets/general.css b/data/assets/general.cssindex 2ccd2b7f1..9a1e74d93 100644--- a/data/assets/general.css+++ b/data/assets/general.css@@ -109,6 +109,25 @@ html, body {text-align: center;}+#fileDropArea {+ width: 100%;+ height: 100%;+ background-color: rgba(29, 209, 159, 0.72);+ z-index: 1001;+ position: absolute;+ top: 80px;+ left: 0;+}++#fileDropExplanation {+ top:45%;+ width: 100%;+ text-align: center;+ position:absolute;+ color: white;+ font-size: 20px;+}+#iframeViewer {width: 100%;border-width: 0;diff --git a/data/assets/layout.css b/data/assets/layout.cssindex f2d33117a..6c1efc1e8 100644--- a/data/assets/layout.css+++ b/data/assets/layout.css@@ -36,7 +36,7 @@}.extMainMenu {- z-index: 1040;+ z-index: 1000;position: absolute;right: 15px;bottom: 15px;@@ -148,7 +148,7 @@height: 100%;min-width: 300px;box-shadow: 2px 0px 3px -1px rgba(0,0,0,0.2);- z-index: 1001;+ z-index: 1010;}.col1 .row1 {diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 8f9265659..f103ed735 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -10,697 +10,718 @@ define(function(require, exports, module) {var TSCORE = require('tscore');var TSPOSTIO = require("tspostioapi");+var fileContent;var fileType;var waitingDialogTimeoutID;+ var addFileInputName;- 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);+ var fileDropTemplate = Handlebars.compile(+ '<div id="fileDropArea">' ++ '<div id="fileDropExplanation"><i class="fa fa-2x fa-mail-forward"></i><br>' ++ '<span>Drop files here in order to be copied or moved in the current folder</span></div>' ++ '</div>'+ );- waitingDialogTimeoutID = window.setTimeout(function() {- waitingModal.modal({- backdrop: 'static',- show: true- });- }, 500);+ function initUI() {+ $('#appVersion').text(TSCORE.Config.DefaultSettings.appVersion + '.' + TSCORE.Config.DefaultSettings.appBuild);+ $('#appVersion').attr('title', 'BuildID: ' + TSCORE.Config.DefaultSettings.appVersion + '.' + TSCORE.Config.DefaultSettings.appBuild + '.' + TSCORE.Config.DefaultSettings.appBuildID);- waitingModal.draggable({- handle: ".modal-header"+ // prevent default behavior from changing page on dropped file+ $(document).on('drop dragend dragenter dragover', function(event) { // dragleave+ // dragstart drag+ event.preventDefault();});- }-- function hideWaitingDialog(message, title) {- window.clearTimeout(waitingDialogTimeoutID);- $('#waitingDialog').modal('hide');- }- function showSuccessDialog(message) {- if (!message) {- return;+ // Managing droping of files in the perspectives+ if (isNode || isElectron) {+ $('#viewContainers').on('dragenter', function(event) {+ event.preventDefault();+ showFileDropArea();+ });+ $('#viewContainers').on('drop', function(event) {+ //event.preventDefault();+ if (event.originalEvent.dataTransfer !== undefined) {+ var files = event.originalEvent.dataTransfer.files;+ TSCORE.IO.focusWindow();+ hideFileDropArea();+ TSCORE.PerspectiveManager.clearSelectedFiles();+ var filePath;+ if (files !== undefined && files.length > 0) {+ for (var i = 0; i < files.length; i++) {+ // file[i] -> {"webkitRelativePath":"","path":"/home/na/Desktop/Kola2","lastModifiedDate":"2014-07-11T16:40:52.000Z","name":"Kola2","type":"","size":4096}+ filePath = files[i].path;+ if (filePath.length > 1) {+ TSCORE.selectedFiles.push(filePath);+ }+ }+ }+ if (TSCORE.selectedFiles.length > 0) {+ showMoveCopyFilesDialog();+ }+ }+ });}- 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'],++ $('#addFileInput').on('change', function(selection) {+ //console.log("Selected File: "+$("#addFileInput").val());+ var file = selection.currentTarget.files[0];+ //console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));+ addFileInputName = decodeURIComponent(file.name);+ var reader = new FileReader();+ reader.onload = onFileReadComplete;+ reader.readAsArrayBuffer(file);});- }- 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'],+ $('#openLeftPanel').click(function() {+ TSCORE.openLeftPanel();});- /*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');++ $('#closeLeftPanel').click(function() {+ TSCORE.closeLeftPanel();});- // Focusing the ok button by default- alertModal.off('shown.bs.modal');- alertModal.on('shown.bs.modal', function() {- alertModal.find('#okButton').focus();++ $('#txtFileTypeButton').click(function(e) {+ // Fixes reloading of the application by click+ e.preventDefault();+ fileContent = TSCORE.Config.getNewTextFileContent();+ fileType = 'txt';});- 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');+ $('#htmlFileTypeButton').click(function(e) {+ // Fixes reloading of the application by click+ e.preventDefault();+ fileContent = TSCORE.Config.getNewHTMLFileContent();+ fileType = 'html';});- // Focusing the confirm button by default- confirmModal.off('shown.bs.modal');- confirmModal.on('shown.bs.modal', function() {- confirmModal.find('#confirmButton').focus();++ $('#mdFileTypeButton').click(function(e) {+ // Fixes reloading of the application by click+ e.preventDefault();+ fileContent = TSCORE.Config.getNewMDFileContent();+ fileType = 'md';});- confirmModal.find('#cancelButton').off('click').click(function() {- if (cancelCallback !== undefined) {- cancelCallback();++ $('#fileCreateConfirmButton').click(function() {+ var fileTags = '';+ var rawTags = $('#newFileNameTags').val().split(',');+ rawTags.forEach(function(value, index) {+ if (index === 0) {+ fileTags = value;+ } else {+ fileTags = fileTags + TSCORE.Config.getTagDelimiter() + value;+ }+ });+ if ($('#tagWithCurrentDate').prop('checked')) {+ if (fileTags.length < 1) {+ fileTags = TSCORE.TagUtils.formatDateTime4Tag(new Date());+ } else {+ fileTags = fileTags + TSCORE.Config.getTagDelimiter() + TSCORE.TagUtils.formatDateTime4Tag(new Date());+ }}- confirmModal.modal('hide');+ if (fileTags.length > 0) {+ fileTags = TSCORE.TagUtils.beginTagContainer + fileTags + TSCORE.TagUtils.endTagContainer;+ }+ var filePath = TSCORE.currentPath + TSCORE.dirSeparator + $('#newFileName').val() + fileTags + '.' + fileType;+ TSCORE.IO.saveFilePromise(filePath, fileContent).then(function() {+ TSPOSTIO.saveTextFile(filePath, isNewFile);+ }, function(error) {+ TSCORE.hideLoadingAnimation();+ TSCORE.showAlertDialog("Saving " + filePath + " failed.");+ console.error("Save to file " + filePath + " failed " + error);+ });});- confirmModal.modal({- backdrop: 'static',- show: true++ $('#renameFileButton').click(function() {+ var initialFilePath = $('#renamedFileName').attr('filepath');+ var containingDir = TSCORE.TagUtils.extractContainingDirectoryPath(initialFilePath);+ var newFilePath = containingDir + TSCORE.dirSeparator + $('#renamedFileName').val();+ TSCORE.IO.renameFilePromise(initialFilePath, newFilePath).then(function(success) {+ TSCORE.hideWaitingDialog();+ TSPOSTIO.renameFile(initialFilePath, newFilePath);+ }, function(err) {+ TSCORE.hideWaitingDialog();+ TSCORE.showAlertDialog(err);+ });});- confirmModal.draggable({- handle: ".modal-header"++ // Edit Tag Dialog+ $('#plainTagTypeButton').click(function(e) {+ // Fixes reloading of the application by click+ e.preventDefault();+ TSCORE.selectedTag, $('#newTagName').datepicker('destroy').val('');});- }- 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+ $('#dateTagTypeButton').click(function(e) {+ // Fixes reloading of the application by click+ e.preventDefault();+ TSCORE.selectedTag, $('#newTagName').datepicker({+ showWeek: true,+ firstDay: 1,+ dateFormat: 'yymmdd'+ });});- $('#newFileName').val('');- $('#tagWithCurrentDate').prop('checked', false);- $('#txtFileTypeButton').button('toggle');- $('#formFileCreate').validator();- $('#formFileCreate').submit(function(e) {++ $('#currencyTagTypeButton').click(function(e) {+ // Fixes reloading of the application by clicke.preventDefault();+ TSCORE.selectedTag, $('#newTagName').datepicker('destroy').val('XEUR');});- $('#formFileCreate').on('invalid.bs.validator', function() {- $('#fileCreateConfirmButton').prop('disabled', true);++ $('#editTagButton').click(function() {+ TSCORE.TagUtils.renameTag(TSCORE.selectedFiles[0], TSCORE.selectedTag, $('#newTagName').val());});- $('#formFileCreate').on('valid.bs.validator', function() {- $('#fileCreateConfirmButton').prop('disabled', false);++ // End Edit Tag Dialog+ $('#startNewInstanceBack').click(function() {+ if (!isCordova) {+ window.open(window.location.href, '_blank');+ }});- $('#dialogFileCreate').on('shown.bs.modal', function() {- $('#newFileName').select2().focus();++ $('#aboutDialogBack').click(function() {+ if (TSCORE.PRO) {+ $('#aboutIframe').attr('src', 'pro/about.html');+ } else {+ $('#aboutIframe').attr('src', 'about.html');+ }});- $('#dialogFileCreate').modal({- backdrop: 'static',- show: true++ // Open About Dialog+ $('#openAboutBox').click(function() {+ $('#dialogAbout').modal({+ backdrop: 'static',+ show: true+ });+ $('#dialogAbout').draggable({+ handle: ".modal-header"+ });});- $('#dialogFileCreate').draggable({- handle: ".modal-header"++ // Open Options Dialog+ $('#openOptions').click(function() {+ showOptionsDialog();});- }- function showFileRenameDialog(filePath) {- $('#renamedFileName').attr('filepath', filePath);- $('#renamedFileName').val(TSCORE.TagUtils.extractFileName(filePath));+ // File Menu+ $('#fileMenuAddTag').click(function() {+ TSCORE.showAddTagsDialog();+ });- $('#formFileRename').validator();- $('#formFileRename').submit(function(e) {- e.preventDefault();- if ($('#renameFileButton').prop('disabled') === false) {- $('#renameFileButton').click();- }+ $('#fileMenuOpenFile').click(function() {+ TSCORE.FileOpener.openFile(TSCORE.selectedFiles[0]);});- $('#formFileRename').on('invalid.bs.validator', function() {- $('#renameFileButton').prop('disabled', true);++ $('#fileMenuOpenNatively').click(function() {+ TSCORE.IO.openFile(TSCORE.selectedFiles[0]);});- $('#formFileRename').on('valid.bs.validator', function() {- $('#renameFileButton').prop('disabled', false);++ $('#fileMenuSendTo').click(function() {+ TSCORE.IO.sendFile(TSCORE.selectedFiles[0]);});- $('#dialogFileRename').on('shown.bs.modal', function() {- $('#renamedFileName').focus();++ $('#fileMenuOpenDirectory').click(function() {+ var dirPath = TSCORE.Utils.dirName(TSCORE.selectedFiles[0]);+ TSCORE.IO.openDirectory(dirPath);});- $('#dialogFileRename').modal({- backdrop: 'static',- show: true++ $('#fileMenuRenameFile').click(function() {+ TSCORE.showFileRenameDialog(TSCORE.selectedFiles[0]);});- $('#dialogFileRename').draggable({- handle: ".modal-header"++ $('#fileMenuMoveCopyFile').click(function() {+ TSCORE.showMoveCopyFilesDialog();});- }- function showFileDeleteDialog(filePath) {- console.log('Deleting file...');- var dlgConfirmMsgId = 'ns.dialogs:fileDeleteContentConfirm';- if (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);- }- );+ $('#fileMenuDeleteFile').click(function() {+ TSCORE.showFileDeleteDialog(TSCORE.selectedFiles[0]);});- }- function showTagEditDialog() {- $('#newTagName').val(TSCORE.selectedTag);- $('#formEditTag').validator();- $('#formEditTag').submit(function(e) {+ $('#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();- if ($('#editTagButton').prop('disabled') === false) {- $('#editTagButton').click();- }+ TSCORE.IO.openFile($(this).attr('href'));});- $('#formEditTag').on('invalid.bs.validator', function() {- $('#editTagButton').prop('disabled', true);+ $contactUsContent.on('click', '#openGooglePlay', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));});- $('#formEditTag').on('valid.bs.validator', function() {- $('#editTagButton').prop('disabled', false);+ $contactUsContent.on('click', '#openAppleAppStore', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));});- $('#dialogEditTag').on('shown.bs.modal', function() {- $('#newTagName').focus();+ $contactUsContent.on('click', '#openWhatsnew', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));});- $('#dialogEditTag').modal({- backdrop: 'static',- show: true+ $contactUsContent.on('click', '#openGitHubIssues', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));});- $('#dialogEditTag').draggable({- handle: ".modal-header"+ $contactUsContent.on('click', '#helpUsTranslate', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(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);+ $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'));});- }- 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}));+ $('#newVersionMenu').on('click', '.whatsNewLink', function(e) {+ e.preventDefault();+ TSCORE.IO.openFile($(this).attr('href'));+ });- controller.initUI();- }- $('#dialogOptions').i18n();- controller.reInitUI();+ // Hide drop downs by click and drag+ $(document).click(function() {+ TSCORE.hideAllDropDownMenus();});++ platformTuning();}- function showWelcomeDialog() { startGettingStartedTour(); }+ function showFileDropArea() {+ if($('#fileDropArea').length < 1) {+ $('#viewContainers').append(fileDropTemplate({}));+ $('#fileDropArea').on('dragleave', function(event) {+ event.preventDefault();+ hideFileDropArea();+ });+ } else {+ $('#fileDropArea').show();+ }+ }- function startGettingStartedTour() {- var tsGettingStarted = require('tsgettingstarted');- tsGettingStarted.startTour();+ function hideFileDropArea() {+ $('#fileDropArea').hide();}- function showMoveCopyFilesDialog() {- require(['text!templates/MoveCopyFilesDialog.html'], function(uiTPL) {- if ($('#dialogMoveCopyFiles').length < 1) {- var uiTemplate = Handlebars.compile(uiTPL);- $('body').append(uiTemplate());+ 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;- $('#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");- });- });+ // TODO event.currentTarget.result is ArrayBuffer+ // Sample call from PRO version using content = TSCORE.Utils.base64ToArrayBuffer(baseString);- $('#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({+ 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});- $('#dialogMoveCopyFiles').draggable({- handle: ".modal-header"- });- console.log('Selected files: ' + TSCORE.selectedFiles);- });- }+ }, 500);- function showAboutDialog() {- $('#dialogAboutTS').modal({- backdrop: 'static',- show: true- });- $('#dialogAboutTS').draggable({+ waitingModal.draggable({handle: ".modal-header"});}- function initUI() {- if (TSCORE.PRO) {- //TSCORE.PRO.sayHi();- }+ function hideWaitingDialog(message, title) {+ window.clearTimeout(waitingDialogTimeoutID);+ $('#waitingDialog').modal('hide');+ }- $('#appVersion').text(TSCORE.Config.DefaultSettings.appVersion + '.' + TSCORE.Config.DefaultSettings.appBuild);- $('#appVersion').attr('title', 'BuildID: ' + TSCORE.Config.DefaultSettings.appVersion + '.' + TSCORE.Config.DefaultSettings.appBuild + '.' + TSCORE.Config.DefaultSettings.appBuildID);- // prevent default behavior from changing page on dropped file- $(document).on('drop dragend dragenter dragleave dragover', function(event) {- // dragstart drag- event.preventDefault();- });- // Managing droping of files in the perspectives- if (isNode || isElectron) {- $('#viewContainers').on('dragenter', function(event) {- event.preventDefault();- $('#viewContainers').attr('style', 'border:2px dashed #098ddf');- });- $('#viewContainers').on('dragleave', function(event) {- event.preventDefault();- $('#viewContainers').attr('style', 'border:0px');- });- $('#viewContainers').on('drop', function(event) {- //event.preventDefault();- if (event.originalEvent.dataTransfer !== undefined) {- var files = event.originalEvent.dataTransfer.files;- TSCORE.IO.focusWindow();- $('#viewContainers').attr('style', 'border:0px');- TSCORE.PerspectiveManager.clearSelectedFiles();- var filePath;- if (files !== undefined && files.length > 0) {- for (var i = 0; i < files.length; i++) {- filePath = files[i].path;- if (filePath.length > 1) {- //console.log("Selecting files: "+JSON.stringify(files[i]));- TSCORE.selectedFiles.push(filePath); //{"webkitRelativePath":"","path\":"/home/na/Desktop/Kola2","lastModifiedDate":"2014-07-11T16:40:52.000Z","name":"Kola2","type":"","size":4096}- }- }- }- if (TSCORE.selectedFiles.length > 0) {- showMoveCopyFilesDialog();- }- }- });+ function showSuccessDialog(message) {+ if (!message) {+ return;}-- platformTuning();-- var addFileInputName;- $('#addFileInput').on('change', function(selection) {- //console.log("Selected File: "+$("#addFileInput").val());- var file = selection.currentTarget.files[0];- //console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));- addFileInputName = decodeURIComponent(file.name);- var reader = new FileReader();- reader.onload = onFileReadComplete;- reader.readAsArrayBuffer(file);+ 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 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 showAlertDialog(message, title) {+ if (!title) {+ title = $.i18n.t('ns.dialogs:titleAlert');}-- $('#openLeftPanel').click(function() {- TSCORE.openLeftPanel();+ 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'],});-- $('#closeLeftPanel').click(function() {- TSCORE.closeLeftPanel();+ /*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');});-- $('#txtFileTypeButton').click(function(e) {- // Fixes reloading of the application by click- e.preventDefault();- fileContent = TSCORE.Config.getNewTextFileContent();- fileType = 'txt';+ // 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+ });*/+ }- $('#htmlFileTypeButton').click(function(e) {- // Fixes reloading of the application by click- e.preventDefault();- fileContent = TSCORE.Config.getNewHTMLFileContent();- fileType = 'html';+ 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');});- $('#mdFileTypeButton').click(function(e) {- // Fixes reloading of the application by click- e.preventDefault();- fileContent = TSCORE.Config.getNewMDFileContent();- fileType = 'md';+ // Focusing the confirm button by default+ confirmModal.off('shown.bs.modal');+ confirmModal.on('shown.bs.modal', function() {+ confirmModal.find('#confirmButton').focus();});-- $('#fileCreateConfirmButton').click(function() {- var fileTags = '';- var rawTags = $('#newFileNameTags').val().split(',');- rawTags.forEach(function(value, index) {- if (index === 0) {- fileTags = value;- } else {- fileTags = fileTags + TSCORE.Config.getTagDelimiter() + value;- }- });- if ($('#tagWithCurrentDate').prop('checked')) {- if (fileTags.length < 1) {- fileTags = TSCORE.TagUtils.formatDateTime4Tag(new Date());- } else {- fileTags = fileTags + TSCORE.Config.getTagDelimiter() + TSCORE.TagUtils.formatDateTime4Tag(new Date());- }- }- if (fileTags.length > 0) {- fileTags = TSCORE.TagUtils.beginTagContainer + fileTags + TSCORE.TagUtils.endTagContainer;+ confirmModal.find('#cancelButton').off('click').click(function() {+ if (cancelCallback !== undefined) {+ cancelCallback();}- var filePath = TSCORE.currentPath + TSCORE.dirSeparator + $('#newFileName').val() + fileTags + '.' + fileType;- TSCORE.IO.saveFilePromise(filePath, fileContent).then(function() {- TSPOSTIO.saveTextFile(filePath, isNewFile);- }, function(error) {- TSCORE.hideLoadingAnimation();- TSCORE.showAlertDialog("Saving " + filePath + " failed.");- console.error("Save to file " + filePath + " failed " + error);- });+ confirmModal.modal('hide');});-- $('#renameFileButton').click(function() {- var initialFilePath = $('#renamedFileName').attr('filepath');- var containingDir = TSCORE.TagUtils.extractContainingDirectoryPath(initialFilePath);- var newFilePath = containingDir + TSCORE.dirSeparator + $('#renamedFileName').val();- TSCORE.IO.renameFilePromise(initialFilePath, newFilePath).then(function(success) {- TSCORE.hideWaitingDialog();- TSPOSTIO.renameFile(initialFilePath, newFilePath);- }, function(err) {- TSCORE.hideWaitingDialog();- TSCORE.showAlertDialog(err);- });+ confirmModal.modal({+ backdrop: 'static',+ show: true});-- // Edit Tag Dialog- $('#plainTagTypeButton').click(function(e) {- // Fixes reloading of the application by click- e.preventDefault();- TSCORE.selectedTag, $('#newTagName').datepicker('destroy').val('');+ confirmModal.draggable({+ handle: ".modal-header"});+ }- $('#dateTagTypeButton').click(function(e) {- // Fixes reloading of the application by click- e.preventDefault();- TSCORE.selectedTag, $('#newTagName').datepicker({- showWeek: true,- firstDay: 1,- dateFormat: 'yymmdd'- });+ 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});-- $('#currencyTagTypeButton').click(function(e) {- // Fixes reloading of the application by click+ $('#newFileName').val('');+ $('#tagWithCurrentDate').prop('checked', false);+ $('#txtFileTypeButton').button('toggle');+ $('#formFileCreate').validator();+ $('#formFileCreate').submit(function(e) {e.preventDefault();- TSCORE.selectedTag, $('#newTagName').datepicker('destroy').val('XEUR');- });-- $('#editTagButton').click(function() {- TSCORE.TagUtils.renameTag(TSCORE.selectedFiles[0], TSCORE.selectedTag, $('#newTagName').val());});-- // End Edit Tag Dialog- $('#startNewInstanceBack').click(function() {- if (!isCordova) {- window.open(window.location.href, '_blank');- }- });-- $('#aboutDialogBack').click(function() {- if (TSCORE.PRO) {- $('#aboutIframe').attr('src', 'pro/about.html');- } else {- $('#aboutIframe').attr('src', 'about.html');- }- });-- // Open About Dialog- $('#openAboutBox').click(function() {- $('#dialogAbout').modal({- backdrop: 'static',- show: true- });- $('#dialogAbout').draggable({- handle: ".modal-header"- });+ $('#formFileCreate').on('invalid.bs.validator', function() {+ $('#fileCreateConfirmButton').prop('disabled', true);});-- // Open Options Dialog- $('#openOptions').click(function() {- showOptionsDialog();+ $('#formFileCreate').on('valid.bs.validator', function() {+ $('#fileCreateConfirmButton').prop('disabled', false);});-- // File Menu- $('#fileMenuAddTag').click(function() {- TSCORE.showAddTagsDialog();+ $('#dialogFileCreate').on('shown.bs.modal', function() {+ $('#newFileName').select2().focus();});-- $('#fileMenuOpenFile').click(function() {- TSCORE.FileOpener.openFile(TSCORE.selectedFiles[0]);+ $('#dialogFileCreate').modal({+ backdrop: 'static',+ show: true});-- $('#fileMenuOpenNatively').click(function() {- TSCORE.IO.openFile(TSCORE.selectedFiles[0]);+ $('#dialogFileCreate').draggable({+ handle: ".modal-header"});+ }- $('#fileMenuSendTo').click(function() {- TSCORE.IO.sendFile(TSCORE.selectedFiles[0]);- });+ function showFileRenameDialog(filePath) {+ $('#renamedFileName').attr('filepath', filePath);+ $('#renamedFileName').val(TSCORE.TagUtils.extractFileName(filePath));- $('#fileMenuOpenDirectory').click(function() {- var dirPath = TSCORE.Utils.dirName(TSCORE.selectedFiles[0]);- TSCORE.IO.openDirectory(dirPath);+ $('#formFileRename').validator();+ $('#formFileRename').submit(function(e) {+ e.preventDefault();+ if ($('#renameFileButton').prop('disabled') === false) {+ $('#renameFileButton').click();+ }});-- $('#fileMenuRenameFile').click(function() {- TSCORE.showFileRenameDialog(TSCORE.selectedFiles[0]);+ $('#formFileRename').on('invalid.bs.validator', function() {+ $('#renameFileButton').prop('disabled', true);});-- $('#fileMenuMoveCopyFile').click(function() {- TSCORE.showMoveCopyFilesDialog();+ $('#formFileRename').on('valid.bs.validator', function() {+ $('#renameFileButton').prop('disabled', false);});-- $('#fileMenuDeleteFile').click(function() {- TSCORE.showFileDeleteDialog(TSCORE.selectedFiles[0]);+ $('#dialogFileRename').on('shown.bs.modal', function() {+ $('#renamedFileName').focus();});-- $('#fileOpenProperties').click(function() {});- // End File Menu- $('#showLocations').click(function() {- showLocationsPanel();+ $('#dialogFileRename').modal({+ backdrop: 'static',+ show: true});-- $('#showTagGroups').click(function() {- showTagsPanel();+ $('#dialogFileRename').draggable({+ handle: ".modal-header"});+ }- $('#contactUs').click(function() {- showContactUsPanel();+ function showFileDeleteDialog(filePath) {+ console.log('Deleting file...');+ var dlgConfirmMsgId = 'ns.dialogs:fileDeleteContentConfirm';+ if (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);+ }+ );});+ }- // 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) {+ function showTagEditDialog() {+ $('#newTagName').val(TSCORE.selectedTag);+ $('#formEditTag').validator();+ $('#formEditTag').submit(function(e) {e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ if ($('#editTagButton').prop('disabled') === false) {+ $('#editTagButton').click();+ }});- $contactUsContent.on('click', '#openGitHubIssues', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ $('#formEditTag').on('invalid.bs.validator', function() {+ $('#editTagButton').prop('disabled', true);});- $contactUsContent.on('click', '#helpUsTranslate', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ $('#formEditTag').on('valid.bs.validator', function() {+ $('#editTagButton').prop('disabled', false);});- $contactUsContent.on('click', '#openTwitter', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ $('#dialogEditTag').on('shown.bs.modal', function() {+ $('#newTagName').focus();});- $contactUsContent.on('click', '#openTwitter2', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ $('#dialogEditTag').modal({+ backdrop: 'static',+ show: true});- $contactUsContent.on('click', '#openGooglePlus', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ $('#dialogEditTag').draggable({+ handle: ".modal-header"});- $contactUsContent.on('click', '#openFacebook', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(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);});- $contactUsContent.on('click', '#openSupportUs', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ }++ 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();});- $('#newVersionMenu').on('click', '.whatsNewLink', function(e) {- e.preventDefault();- TSCORE.IO.openFile($(this).attr('href'));+ }++ function showWelcomeDialog() { startGettingStartedTour(); }++ function startGettingStartedTour() {+ var tsGettingStarted = require('tsgettingstarted');+ tsGettingStarted.startTour();+ }++ 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);});+ }- // Hide drop downs by click and drag- $(document).click(function() {- TSCORE.hideAllDropDownMenus();+ function showAboutDialog() {+ $('#dialogAboutTS').modal({+ backdrop: 'static',+ show: true+ });+ $('#dialogAboutTS').draggable({+ handle: ".modal-header"});}