TagSpaces is an offline, open source, document manager with tagging support
Changes in connection with the views refactoring
uggrock3f84423fe570
diff --git a/data/js/main.js b/data/js/main.jsindex e55d2716d..6c3cc2837 100644--- a/data/js/main.js+++ b/data/js/main.js@@ -44,6 +44,7 @@ var initApp = function(){"js/directories.ui",],function(viewManager) {+ UIAPI.ViewManager = viewManager;TagsUI.initContextMenus();TagsUI.initDialogs();@@ -70,7 +71,7 @@ var initApp = function(){}// Init views- viewManager.initViews();+ UIAPI.ViewManager.initViews();$("#appVersion").text("["+TSSETTINGS.DefaultSettings["appVersion"]+"]");$("#appVersion").attr("title","["+TSSETTINGS.DefaultSettings["appBuild"]+"]");diff --git a/data/js/misc.ui.js b/data/js/misc.ui.jsindex 2b3917d5c..7babb3f7a 100644--- a/data/js/misc.ui.js+++ b/data/js/misc.ui.js@@ -21,7 +21,7 @@ UIAPI.parentDir = "..";UIAPI.currentPath = "";-UIAPI.currentView = "fileView"; // tagView, riverView+UIAPI.currentView = undefined;// Current selected filesUIAPI.selectedFiles = [];@@ -47,6 +47,8 @@ UIAPI.fileTable = undefined;UIAPI.htmlEditor = undefined;+UIAPI.ViewManager = undefined;+UIAPI.getDirSeparator = function() {return UIAPI.isWindows()?"\\":"/";}@@ -128,149 +130,14 @@ UIAPI.updateFileBrowserData = function(dirList) {}}- UIAPI.changeView(UIAPI.currentView);+ UIAPI.ViewManager.changeView(UIAPI.currentView);}-UIAPI.setFileSortCriteria = function(sortBy) {console.debug("Setting sort criteris: "+sortBy);UIAPI.fileSortCriteria = sortBy;}-UIAPI.initFileTagView = function(viewType) {- UIAPI.fileTable.fnClearTable();- UIAPI.fileTable.fnAddData( UIAPI.fileList );-- UIAPI.fileTable.fnSetColumnVis(0, true);- UIAPI.fileTable.fnSetColumnVis(1, true);- UIAPI.fileTable.fnSetColumnVis(2, true);- UIAPI.fileTable.fnSetColumnVis(3, true);- UIAPI.fileTable.fnSetColumnVis(4, true);-- UIAPI.fileTable.$('tr').dblclick( function() {- console.debug("Opening file...");- var rowData = UIAPI.fileTable.fnGetData( this );- $("#selectedFilePath").val(UIAPI.currentPath+UIAPI.getDirSeparator()+rowData[0]);- FileViewer.openFile(rowData[0]);- UIAPI.hideAllContextMenus();- } );-- UIAPI.fileTable.$('.fileButton')- .click( function() {- BasicViewsUI.openFileMenu(this, $(this).attr("title"));- } )- .dropdown( 'attach' , '#fileMenu' );-- UIAPI.fileTable.$('.fileTitleButton')- .click( function() {- BasicViewsUI.openFileTitleMenu(this, $(this).attr("title"));- } )- .dropdown( 'attach' , '#fileTitleMenu' );-- UIAPI.fileTable.$('.extTagButton')- .click( function() {- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filename"));- } )- .dropdown( 'attach' , '#tagMenu' );-- UIAPI.fileTable.$('.tagButton')- .click( function() {- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filename"));- } )- .dropdown( 'attach' , '#tagMenu' );-}--UIAPI.initRiverView = function(viewType) {- console.debug("River view disabled");-/*- $("#riverView").empty();- layoutContainer.close("east");- var tagsHTML = undefined;- for (var i=0; i < UIAPI.fileList.length; i++) {- if(i > 10) break;- tagsHTML = "";- var fileName = UIAPI.fileList[i][0];- var filePath = UIAPI.currentPath+UIAPI.getDirSeparator()+fileName;- tagsHTML += '<iframe id="idFrameViewer" style="width: 100%; height: 150px;" src="'+'file:///'+filePath+'" />';- $("#riverView").append(tagsHTML);- }- $("#riverView").show();*/-}--UIAPI.initThumbView = function(viewType) {- $("#selectableFiles").empty();- for (var i=0; i < UIAPI.fileList.length; i++) {- var fileName = UIAPI.fileList[i][0];- var fileExt = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length).toLowerCase();- if(TSSETTINGS.getSupportedFileExt4Thumbnailing().indexOf(fileExt) >= 0) {- var filePath = UIAPI.currentPath+UIAPI.getDirSeparator()+fileName;- $("#selectableFiles").append(- $('<li>', { title: fileName, class: 'ui-widget-content' }).append(- $('<img>', { title: fileName, class: "thumbImg", src: 'file:///'+filePath })));- } else {- $("#selectableFiles").append(- $('<li>', { title: fileName, class: 'ui-widget-content' }).append(- $('<span>', { class: "fileExtension", text: fileExt})));- }- }-}--UIAPI.changeView = function(viewType) {- console.debug("Change the view of the file browser to "+viewType);- UIAPI.showLoadingAnimation();-- //Setting the current view- UIAPI.currentView = viewType;-- $("#riverView").hide();-- $("#selectableFiles").hide();-- // Purging the thumbnail view, avoiding memory leak- document.getElementById("selectableFiles").innerHTML = "";-- UIAPI.fileTable.hide();- $("fileTable_wrapper").hide();-- // Purging file table- UIAPI.fileTable.fnClearTable();-- //TODO River View Disabled due performance- //UIAPI.initRiverView();-- // Clear the list with the selected files- UIAPI.selectedFiles = [];- UIAPI.currentFilename = "";-- if(viewType == "thumbView") {- UIAPI.initThumbView();- $("#selectableFiles").show();-// } else if(viewType == "riverView") {-// $("#riverView").show();- } else { // Fileview or Tagview- UIAPI.initFileTagView();- if(viewType == "fileView") {- console.debug("Change to FileView");- UIAPI.fileTable.fnSetColumnVis(0, true);- UIAPI.fileTable.fnSetColumnVis(1, true);- UIAPI.fileTable.fnSetColumnVis(2, true);- UIAPI.fileTable.fnSetColumnVis(3, false);- UIAPI.fileTable.fnSetColumnVis(4, false);- } else if (viewType == "tagView") {- console.debug("Change to TagView");- UIAPI.fileTable.fnSetColumnVis(0, false);- UIAPI.fileTable.fnSetColumnVis(1, false);- UIAPI.fileTable.fnSetColumnVis(2, false);- UIAPI.fileTable.fnSetColumnVis(3, true);- UIAPI.fileTable.fnSetColumnVis(4, true);- }- UIAPI.fileTable.show();- $("fileTable_wrapper").show();- }- UIAPI.handleElementActivation();- UIAPI.hideLoadingAnimation();-}-UIAPI.updateFileSelection = function() {console.debug("Updating file selection...");UIAPI.selectedFiles = [];diff --git a/data/js/settings.ui.js b/data/js/settings.ui.jsindex b0f48aacf..9fe7b6718 100644--- a/data/js/settings.ui.js+++ b/data/js/settings.ui.js@@ -57,6 +57,254 @@ SettingsUI.initButtons = function() {}SettingsUI.initDialogs = function() {+ var newDirName = $( "#dirname" );+ var newFileName = $( "#newFileName" );+ var renamedFileName = $( "#renamedFileName" );++ // TODO evtl add smarttag and the others...+ var allFields = $( [] ).add( newDirName );++ var tips = $( ".validateTips" );++ function updateTips( t ) {+ tips+ .text( t )+ .addClass( "ui-state-highlight" );+ setTimeout(function() {+ tips.removeClass( "ui-state-highlight", 1500 );+ }, 500 );+ }++ function checkLength( o, n, min, max ) {+ if ( o.val().length > max || o.val().length < min ) {+ o.addClass( "ui-state-error" );+ updateTips( "Length of " + n + " must be between " ++ min + " and " + max + "." );+ return false;+ } else {+ return true;+ }+ }++ function checkRegexp( o, regexp, n ) {+ if ( !( regexp.test( o.val() ) ) ) {+ o.addClass( "ui-state-error" );+ updateTips( n );+ return false;+ } else {+ return true;+ }+ }++ $( "#fileTypeRadio" ).buttonset();++ var fileContent = undefined;++ $( "#txtFileTypeButton" ).click(function() {+ // TODO Add to config options+ fileContent = TSSETTINGS.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");+ }+ });++ $( "#htmlFileTypeButton" ).click(function() {+ // TODO Add to config options+ fileContent = TSSETTINGS.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");+ }+ });++ $( "#mdFileTypeButton" ).click(function() {+ // TODO Add to config options+ fileContent = TSSETTINGS.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");+ }+ });++ $( "#dialog-filecreate" ).dialog({+ autoOpen: false,+ height: 250,+ width: 450,+ modal: true,+ buttons: {+ "Create": function() {+ var bValid = true;+ allFields.removeClass( "ui-state-error" );++ bValid = bValid && checkLength( newFileName, "filename", 4, 200 );+ // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );+ if(UIAPI.fileExists(newFileName.val())) {+ updateTips("File already exists.");+ bValid = false;+ }+ if ( bValid ) {+ IOAPI.saveTextFile(UIAPI.currentPath+UIAPI.getDirSeparator()+$( "#newFileName" ).val(),fileContent);+ $( this ).dialog( "close" );+ IOAPI.listDirectory(UIAPI.currentPath);+ }+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ },+ close: function() {+ allFields.val( "" ).removeClass( "ui-state-error" );+ },+ open: function() {+ fileContent = TSSETTINGS.getNewTextFileContent(); // Default new file in text file+ $( "#newFileName" ).val(".txt");+ }+ });++ $( "#dialog-filerename" ).dialog({+ autoOpen: false,+ height: 220,+ width: 450,+ modal: true,+ buttons: {+ "Rename": function() {+ var bValid = true;+ allFields.removeClass( "ui-state-error" );++ bValid = bValid && checkLength( renamedFileName, "filename", 3, 200 );+ // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );+ if ( bValid ) {+ IOAPI.renameFile(+ UIAPI.currentPath+UIAPI.getDirSeparator()+UIAPI.selectedFiles[0],+ UIAPI.currentPath+UIAPI.getDirSeparator()+renamedFileName.val()+ );+ $( this ).dialog( "close" );+ IOAPI.listDirectory(UIAPI.currentPath);+ }+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ },+ close: function() {+ allFields.val( "" ).removeClass( "ui-state-error" );+ },+ open: function() {+ $( "#renamedFileName" ).val(UIAPI.selectedFiles[0]);+ }+ });++ $( "#dialog-confirmdelete" ).dialog({+ autoOpen: false,+ resizable: false,+ height:140,+ modal: true,+ buttons: {+ "Delete all items": function() {+ IOAPI.deleteElement(UIAPI.currentPath+UIAPI.getDirSeparator()+UIAPI.selectedFiles[0]);+ $( this ).dialog( "close" );+ IOAPI.listDirectory(UIAPI.currentPath);+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialogAddTags" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Add tags": function() {+ var tags = $("#tags").val().split(",");+ TSAPI.writeTagsToFile(UIAPI.selectedFiles[0], tags);+ IOAPI.listDirectory(UIAPI.currentPath);+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ },+ open: function() {++ function split( val ) {+ return val.split( /,\s*/ );+ }+ function extractLast( term ) {+ return split( term ).pop();+ }++ $( "#tags" )+ // don't navigate away from the field on tab when selecting an item+ .bind( "keydown", function( event ) {+ if ( event.keyCode === $.ui.keyCode.TAB &&+ $( this ).data( "autocomplete" ).menu.active ) {+ event.preventDefault();+ }+ })+ .autocomplete({+ minLength: 0,+ source: function( request, response ) {+ // delegate back to autocomplete, but extract the last term+ response( $.ui.autocomplete.filter(+ TSSETTINGS.getAllTags(), extractLast( request.term ) ) );+ },+ focus: function() {+ // prevent value inserted on focus+ return false;+ },+ select: function( event, ui ) {+ var terms = split( this.value );+ // remove the current input+ terms.pop();+ // add the selected item+ terms.push( ui.item.value );+ // add placeholder to get the comma-and-space at the end+ terms.push( "" );+ this.value = terms.join( ", " );+ return false;+ }+ });+ }+ });++ $( "#tagTypeRadio" ).buttonset();++ $( "#plainTagTypeButton" ).click(function() {+ UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");+ });++ $( "#dateTagTypeButton" ).click(function() {+ UIAPI.selectedTag, $( "#newTag" ).datepicker({+ showWeek: true,+ firstDay: 1,+ dateFormat: "yymmdd"+ });+ });++ $( "#currencyTagTypeButton" ).click(function() {+ UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")+ });++ $( "#dialogEditTag" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Edit tag": function() {+ TSAPI.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());+ IOAPI.listDirectory(UIAPI.currentPath);+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });$( "#dialogAbout" ).dialog({autoOpen: false,diff --git a/data/js/viewBasic.js b/data/js/viewBasic.jsindex 9ac57da33..9a1d94b69 100644--- a/data/js/viewBasic.js+++ b/data/js/viewBasic.js@@ -11,7 +11,56 @@ define([],function(require, exports, module) {"use strict";-console.debug("Loading View: Basic");+exports.Title = "File View"+exports.ID = "viewBasic"; // ID should be equal to the directory name where the ext. is located+exports.Type = "view";+exports.Icon = "ui-icon-note"; // ui-icon-tag++console.debug("Loading viewBasic.js");++exports.init = function init() {+ console.debug("Initializing View "+exports.ID);++/*+ <table id="fileTable" cellpadding="0" cellspacing="0" border="0" style="width: 100%"></table>++ <span style="float: right; margin: 0px; padding: 0px;">+ <input id="filterBox" type="filter" value="" autocomplete="off" title="This filter applies to current directory without subdirectories." />+ </span>+ */+}++exports.load = function init() {+ console.debug("Loading View "+exports.ID);+ /*+ UIAPI.fileTable.hide();+ $("fileTable_wrapper").hide();++ // Purging file table+ UIAPI.fileTable.fnClearTable();++ UIAPI.initFileTagView();+ if(viewType == "fileView") {+ console.debug("Change to FileView");+ UIAPI.fileTable.fnSetColumnVis(0, true);+ UIAPI.fileTable.fnSetColumnVis(1, true);+ UIAPI.fileTable.fnSetColumnVis(2, true);+ UIAPI.fileTable.fnSetColumnVis(3, false);+ UIAPI.fileTable.fnSetColumnVis(4, false);+ } else if (viewType == "tagView") {+ console.debug("Change to TagView");+ UIAPI.fileTable.fnSetColumnVis(0, false);+ UIAPI.fileTable.fnSetColumnVis(1, false);+ UIAPI.fileTable.fnSetColumnVis(2, false);+ UIAPI.fileTable.fnSetColumnVis(3, true);+ UIAPI.fileTable.fnSetColumnVis(4, true);+ }+ UIAPI.fileTable.show();+ $("fileTable_wrapper").show();+ */++ UIAPI.hideLoadingAnimation();+}var BasicViewsUI = (typeof BasicViewsUI == 'object' && BasicViewsUI != null) ? BasicViewsUI : {};@@ -23,6 +72,49 @@ var BasicViewsUI = (typeof BasicViewsUI == 'object' && BasicViewsUI != null) ? BBasicViewsUI.initThumbView();*/+UIAPI.initFileTagView = function(viewType) {+ UIAPI.fileTable.fnClearTable();+ UIAPI.fileTable.fnAddData( UIAPI.fileList );++ UIAPI.fileTable.fnSetColumnVis(0, true);+ UIAPI.fileTable.fnSetColumnVis(1, true);+ UIAPI.fileTable.fnSetColumnVis(2, true);+ UIAPI.fileTable.fnSetColumnVis(3, true);+ UIAPI.fileTable.fnSetColumnVis(4, true);++ UIAPI.fileTable.$('tr').dblclick( function() {+ console.debug("Opening file...");+ var rowData = UIAPI.fileTable.fnGetData( this );+ $("#selectedFilePath").val(UIAPI.currentPath+UIAPI.getDirSeparator()+rowData[0]);+ FileViewer.openFile(rowData[0]);+ UIAPI.hideAllContextMenus();+ } );++ UIAPI.fileTable.$('.fileButton')+ .click( function() {+ BasicViewsUI.openFileMenu(this, $(this).attr("title"));+ } )+ .dropdown( 'attach' , '#fileMenu' );++ UIAPI.fileTable.$('.fileTitleButton')+ .click( function() {+ BasicViewsUI.openFileTitleMenu(this, $(this).attr("title"));+ } )+ .dropdown( 'attach' , '#fileTitleMenu' );++ UIAPI.fileTable.$('.extTagButton')+ .click( function() {+ TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filename"));+ } )+ .dropdown( 'attach' , '#tagMenu' );++ UIAPI.fileTable.$('.tagButton')+ .click( function() {+ TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filename"));+ } )+ .dropdown( 'attach' , '#tagMenu' );+}+BasicViewsUI.initFileTagViews = function() {UIAPI.fileTable = $('#fileTable').dataTable( {"bJQueryUI": false,@@ -113,6 +205,8 @@ BasicViewsUI.initFileTagViews = function() {}));}++BasicViewsUI.initThumbView = function() {// Managing the selection of files in the thumb view$( "#selectableFiles" ).selectable({@@ -395,256 +489,5 @@ BasicViewsUI.initContextMenus = function() {}-BasicViewsUI.initDialogs = function() {- var newDirName = $( "#dirname" );- var newFileName = $( "#newFileName" );- var renamedFileName = $( "#renamedFileName" );-- // TODO evtl add smarttag and the others...- var allFields = $( [] ).add( newDirName );-- var tips = $( ".validateTips" );-- function updateTips( t ) {- tips- .text( t )- .addClass( "ui-state-highlight" );- setTimeout(function() {- tips.removeClass( "ui-state-highlight", 1500 );- }, 500 );- }-- function checkLength( o, n, min, max ) {- if ( o.val().length > max || o.val().length < min ) {- o.addClass( "ui-state-error" );- updateTips( "Length of " + n + " must be between " +- min + " and " + max + "." );- return false;- } else {- return true;- }- }-- function checkRegexp( o, regexp, n ) {- if ( !( regexp.test( o.val() ) ) ) {- o.addClass( "ui-state-error" );- updateTips( n );- return false;- } else {- return true;- }- }-- $( "#fileTypeRadio" ).buttonset();-- var fileContent = undefined;-- $( "#txtFileTypeButton" ).click(function() {- // TODO Add to config options- fileContent = TSSETTINGS.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");- }- });-- $( "#htmlFileTypeButton" ).click(function() {- // TODO Add to config options- fileContent = TSSETTINGS.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");- }- });-- $( "#mdFileTypeButton" ).click(function() {- // TODO Add to config options- fileContent = TSSETTINGS.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");- }- });-- $( "#dialog-filecreate" ).dialog({- autoOpen: false,- height: 250,- width: 450,- modal: true,- buttons: {- "Create": function() {- var bValid = true;- allFields.removeClass( "ui-state-error" );-- bValid = bValid && checkLength( newFileName, "filename", 4, 200 );- // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );- if(UIAPI.fileExists(newFileName.val())) {- updateTips("File already exists.");- bValid = false;- }- if ( bValid ) {- IOAPI.saveTextFile(UIAPI.currentPath+UIAPI.getDirSeparator()+$( "#newFileName" ).val(),fileContent);- $( this ).dialog( "close" );- IOAPI.listDirectory(UIAPI.currentPath);- }- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- close: function() {- allFields.val( "" ).removeClass( "ui-state-error" );- },- open: function() {- fileContent = TSSETTINGS.getNewTextFileContent(); // Default new file in text file- $( "#newFileName" ).val(".txt");- }- });-- $( "#dialog-filerename" ).dialog({- autoOpen: false,- height: 220,- width: 450,- modal: true,- buttons: {- "Rename": function() {- var bValid = true;- allFields.removeClass( "ui-state-error" );-- bValid = bValid && checkLength( renamedFileName, "filename", 3, 200 );- // bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );- if ( bValid ) {- IOAPI.renameFile(- UIAPI.currentPath+UIAPI.getDirSeparator()+UIAPI.selectedFiles[0],- UIAPI.currentPath+UIAPI.getDirSeparator()+renamedFileName.val()- );- $( this ).dialog( "close" );- IOAPI.listDirectory(UIAPI.currentPath);- }- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- close: function() {- allFields.val( "" ).removeClass( "ui-state-error" );- },- open: function() {- $( "#renamedFileName" ).val(UIAPI.selectedFiles[0]);- }- });-- $( "#dialog-confirmdelete" ).dialog({- autoOpen: false,- resizable: false,- height:140,- modal: true,- buttons: {- "Delete all items": function() {- IOAPI.deleteElement(UIAPI.currentPath+UIAPI.getDirSeparator()+UIAPI.selectedFiles[0]);- $( this ).dialog( "close" );- IOAPI.listDirectory(UIAPI.currentPath);- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialogAddTags" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Add tags": function() {- var tags = $("#tags").val().split(",");- TSAPI.writeTagsToFile(UIAPI.selectedFiles[0], tags);- IOAPI.listDirectory(UIAPI.currentPath);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- open: function() {-- function split( val ) {- return val.split( /,\s*/ );- }- function extractLast( term ) {- return split( term ).pop();- }-- $( "#tags" )- // don't navigate away from the field on tab when selecting an item- .bind( "keydown", function( event ) {- if ( event.keyCode === $.ui.keyCode.TAB &&- $( this ).data( "autocomplete" ).menu.active ) {- event.preventDefault();- }- })- .autocomplete({- minLength: 0,- source: function( request, response ) {- // delegate back to autocomplete, but extract the last term- response( $.ui.autocomplete.filter(- TSSETTINGS.getAllTags(), extractLast( request.term ) ) );- },- focus: function() {- // prevent value inserted on focus- return false;- },- select: function( event, ui ) {- var terms = split( this.value );- // remove the current input- terms.pop();- // add the selected item- terms.push( ui.item.value );- // add placeholder to get the comma-and-space at the end- terms.push( "" );- this.value = terms.join( ", " );- return false;- }- });- }- });-- $( "#tagTypeRadio" ).buttonset();-- $( "#plainTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");- });-- $( "#dateTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker({- showWeek: true,- firstDay: 1,- dateFormat: "yymmdd"- });- });-- $( "#currencyTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")- });-- $( "#dialogEditTag" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Edit tag": function() {- TSAPI.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());- IOAPI.listDirectory(UIAPI.currentPath);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-}-//return BasicViewsUI;});\ No newline at end of filediff --git a/data/js/viewSearch.js b/data/js/viewSearch.jsindex 639c4f050..9ab8611a6 100644--- a/data/js/viewSearch.js+++ b/data/js/viewSearch.js@@ -9,10 +9,17 @@ define([],function(require, exports, module) {"use strict";-console.debug("Loading View: Search");+console.debug("Loading viewSearch.js");++exports.init = function init() {++}+var BasicViewsUI = (typeof BasicViewsUI == 'object' && BasicViewsUI != null) ? BasicViewsUI : {};++BasicViewsUI.initFileTagViews = function() {UIAPI.fileTable = $('#fileTable').dataTable( {"bJQueryUI": false,@@ -214,42 +221,7 @@ BasicViewsUI.initButtons = function() {UIAPI.layoutContainer.toggle("east");});-// Change View buttons- $( "#viewsRadio" ).buttonset();- $( "#fileViewButton" ).button({- text: true,- icons: {- primary: "ui-icon-note"- }- })- .click(function() {- UIAPI.changeView("fileView");- });-- $( "#tagViewButton" ).button({- text: true,- icons: {- primary: "ui-icon-tag"- }- })- .click(function() {- UIAPI.changeView("tagView");- });-- $( "#thumbViewButton" ).button({- text: true,- icons: {- primary: "ui-icon-image"- }- })- .click(function() {- UIAPI.changeView("thumbView");- });-- $( "#riverViewButton" ).click(function() {- UIAPI.changeView("riverView");- });// Initialize file buttons$( "#createFileButton" ).button({diff --git a/data/js/viewThumb.js b/data/js/viewThumb.jsindex ec213a977..8d4b75f01 100644--- a/data/js/viewThumb.js+++ b/data/js/viewThumb.js@@ -9,12 +9,40 @@ define([],function(require, exports, module) {"use strict";-console.debug("Loading View: Thumb");---BasicViewsUI.initThumbView = function() {- // Managing the selection of files in the thumb view- $( "#selectableFiles" ).selectable({+console.debug("Loading: viewThumb.js");++exports.Title = "Thumbs View"+exports.ID = "viewThumb"; // ID should be equal to the directory name where the ext. is located+exports.Type = "view";+exports.Icon = "ui-icon-image";++var viewContainer = undefined;+var viewToolbar = undefined;++exports.init = function init() {+ console.debug("Initializing View "+exports.ID);++ viewContainer = $("#"+exports.ID+"Container");+ viewToolbar = $("#"+exports.ID+"Toolbar");++ viewContainer.empty();+ viewToolbar.empty();++ viewToolbar.append($("<button>", {+ text: "New",+ disabled: true,+ title: "Create new file",+ id: exports.ID+"CreateFileButton",+ }));++ viewContainer.append($("<ol>", {+ style: "overflow: visible;",+ class: "selectableFiles",+ id: exports.ID+"SelectableFiles",+ text: "Empty viewer."+ }));++ $( "#"+exports.ID+"SelectableFiles" ).selectable({stop: function() {UIAPI.selectedFiles = [];$( ".ui-selected", this ).each(function() {@@ -28,48 +56,74 @@ BasicViewsUI.initThumbView = function() {FileViewer.openFile(UIAPI.selectedFiles[0]);}}- });+ });++ initButtons();+ initContextMenus();}+exports.load = function load() {+ console.debug("Showing View "+exports.ID);++ // Purging the thumbnail view, avoiding memory leak+ document.getElementById(exports.ID+"SelectableFiles").innerHTML = "";++ $("#"+exports.ID+"SelectableFiles").empty();++ for (var i=0; i < UIAPI.fileList.length; i++) {+ var fileName = UIAPI.fileList[i][0];+ var fileExt = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length).toLowerCase();+ if(TSSETTINGS.getSupportedFileExt4Thumbnailing().indexOf(fileExt) >= 0) {+ var filePath = UIAPI.currentPath+UIAPI.getDirSeparator()+fileName;+ $("#"+exports.ID+"SelectableFiles").append(+ $('<li>', { title: fileName, class: 'ui-widget-content' }).append(+ $('<img>', { title: fileName, class: "thumbImg", src: 'file:///'+filePath })));+ } else {+ $("#"+exports.ID+"SelectableFiles").append(+ $('<li>', { title: fileName, class: 'ui-widget-content' }).append(+ $('<span>', { class: "fileExtension", text: fileExt})));+ }+ }++ UIAPI.hideLoadingAnimation();+}-exports.initButtons = function initButtons() {-+/*+ // <div id="riverView" style="width: 100%"></div>+function initRiverView(viewType) {+ console.debug("River view disabled");+ $("#riverView").empty();+ layoutContainer.close("east");+ var tagsHTML = undefined;+ for (var i=0; i < UIAPI.fileList.length; i++) {+ if(i > 10) break;+ tagsHTML = "";+ var fileName = UIAPI.fileList[i][0];+ var filePath = UIAPI.currentPath+UIAPI.getDirSeparator()+fileName;+ tagsHTML += '<iframe id="idFrameViewer" style="width: 100%; height: 150px;" src="'+'file:///'+filePath+'" />';+ $("#riverView").append(tagsHTML);+ }+ $("#riverView").show();}+*/-BasicViewsUI.initButtons = function() {-// Layout Buttons- $( "#toggleLeftPanel1" ).button({- text: false,+function initButtons() {+ $( "#"+exports.ID+"CreateFileButton" ).button({+ text: true,icons: {- primary: "ui-icon-bookmark"+ primary: "ui-icon-document"}}).click(function() {- UIAPI.layoutContainer.toggle("west");+ $( "#dialog-filecreate" ).dialog( "open" );});}-BasicViewsUI.initContextMenus = function() {- $( "#fileMenu" ).menu({+function initContextMenus() {+ $( "#fileMenu1" ).menu({select: function( event, ui ) {var commandName = ui.item.attr( "action" );switch (commandName) {- case "addTag":- $( this ).hide();- console.debug("Adding tag...");- $("#tags").val("");- $( "#dialogAddTags" ).dialog( "open" );- break;- case "openFile":- $( this ).hide();- console.debug("Opening file...");- FileViewer.openFile(UIAPI.selectedFiles[0]);- break;- case "openDirectory":- $( this ).hide();- console.debug("Opening parent directory...");- IOAPI.openDirectory(UIAPI.currentPath);- break;case "renameFile":$( this ).hide();console.debug("Renaming file...");@@ -88,91 +142,7 @@ BasicViewsUI.initContextMenus = function() {}$( this ).hide();}- });----}--BasicViewsUI.initDialogs = function() {- var newDirName = $( "#dirname" );- var newFileName = $( "#newFileName" );- var renamedFileName = $( "#renamedFileName" );-- // TODO evtl add smarttag and the others...- var allFields = $( [] ).add( newDirName );-- var tips = $( ".validateTips" );-- function updateTips( t ) {- tips- .text( t )- .addClass( "ui-state-highlight" );- setTimeout(function() {- tips.removeClass( "ui-state-highlight", 1500 );- }, 500 );- }-- function checkLength( o, n, min, max ) {- if ( o.val().length > max || o.val().length < min ) {- o.addClass( "ui-state-error" );- updateTips( "Length of " + n + " must be between " +- min + " and " + max + "." );- return false;- } else {- return true;- }- }-- function checkRegexp( o, regexp, n ) {- if ( !( regexp.test( o.val() ) ) ) {- o.addClass( "ui-state-error" );- updateTips( n );- return false;- } else {- return true;- }- }-- $( "#fileTypeRadio" ).buttonset();-- var fileContent = undefined;--- $( "#tagTypeRadio" ).buttonset();-- $( "#plainTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");- });-- $( "#dateTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker({- showWeek: true,- firstDay: 1,- dateFormat: "yymmdd"- });- });-- $( "#currencyTagTypeButton" ).click(function() {- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")});-- $( "#dialogEditTag" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Edit tag": function() {- TSAPI.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());- IOAPI.listDirectory(UIAPI.currentPath);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });}});\ No newline at end of filediff --git a/data/js/viewmanager.js b/data/js/viewmanager.jsindex 19a2dd350..bb445d299 100644--- a/data/js/viewmanager.js+++ b/data/js/viewmanager.js@@ -8,63 +8,128 @@ define([],function(require, exports, module) {"use strict";-console.debug("Loading ViewManager...");-// Placeholder for the view is #middle-center-// Palcehoder for the buttons is #viewsRadio-/*- <!--table id="fileTable" cellpadding="0" cellspacing="0" border="0" style="width: 100%"></table>- <ol style="overflow: visible;" id="selectableFiles"></ol>- <div id="riverView" style="width: 100%"></div-->-- <input type="radio" id="fileViewButton" name="viewsRadio" checked="checked" /><label for="fileViewButton">Files View</label>- <input type="radio" id="tagViewButton" name="viewsRadio" /><label for="tagViewButton">Tags View</label>- <input type="radio" id="thumbViewButton" name="viewsRadio" /><label for="thumbViewButton">Thumbs View</label>- <input type="radio" id="moreViewsButton" name="viewsRadio" /><label for="moreViewsButton">...</label>- */+console.debug("Loading viewmanager.js");var views = undefined;exports.initViews = function initViews() {views = [];++ $("#viewSwitcher").empty();+ $("#viewToolbars").empty();+ $("#viewContainers").empty();+ $("#viewFooters").empty();++ var defaultViewLoaded = false;+for (var i=0; i < TSSETTINGS.Settings["extensions"].length; i++) {if(TSSETTINGS.Settings["extensions"][i].enabled&& (TSSETTINGS.Settings["extensions"][i].type == "view") ) {// require([TSSETTINGS.getExtensionPath()+UIAPI.getDirSeparator()+viewerExt+UIAPI.getDirSeparator()+"extension.js"], function(viewer) {require(["js/"+TSSETTINGS.Settings["extensions"][i].id], function(viewer) {views.push(viewer);++ initViewsUI(viewer);+viewer.init();- });++ // Loads the first view by default+ if(!defaultViewLoaded) {+ UIAPI.currentView = viewer.ID;+ viewer.load();+ $( "#"+viewer.ID+"Button" ).attr("checked","checked");+ $( "#"+viewer.ID+"Button" ).button("refresh");++ $( "#"+viewer.ID+"Container" ).show();+ $( "#"+viewer.ID+"Toolbar" ).show();+ }+ defaultViewLoaded = true;+ });}}- //initViewsRadio();++ $( "#viewSwitcher" ).buttonset();}-//exports.initViewsRadio =-function initViewsRadio() {- for (var i=0; i < views.length; i++) {- $("#viewsRadio").append($("<input>", {- class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"- }))- .append($("<label>", {- class: "tagGroupTitle",- text: TSSETTINGS.Settings["tagGroups"][i].title,- }))- }+function initViewsUI(viewer) {+ console.debug("Init UI for "+viewer.ID);++ //var radioChecked = true;+ // Only the first button from radio is checked+ //radioChecked = false;++ // Creating viewer's toolbar+ $("#viewToolbars").append($("<div>", {+ id: viewer.ID+"Toolbar",+ text: viewer.Title,+ }).hide());++ // Creating viewer's container+ $("#viewContainers").append($("<div>", {+ id: viewer.ID+"Container",+ text: viewer.Title,+ }).hide());++ $("#viewSwitcher").append($("<input>", {+ type: "radio",+ name: "viewSwitcher",+ viewid: viewer.ID,+// checked: radioChecked,+ id: viewer.ID+"Button",+ }));++ $("#viewSwitcher").append($("<label>", {+ for: viewer.ID+"Button",+ text: viewer.Title,+ }));++ // Adding event listener & icon to the radio button+ $( "#"+viewer.ID+"Button" ).button({+ text: true,+ icons: {+ primary: viewer.Icon+ }+ })+ .click(function() {+ exports.changeView($(this).attr("viewid"));+ })}+exports.changeView = function changeView(viewType) {+ console.debug("Change to "+viewType+" view.");+ UIAPI.showLoadingAnimation();++ //Setting the current view+ UIAPI.currentView = viewType;-exports.registerView = function registerView(viewName) {+ for (var i=0; i < views.length; i++) {+ $( "#"+views[i].ID+"Container" ).hide();+ $( "#"+views[i].ID+"Toolbar" ).hide();+ }+ for (var i=0; i < views.length; i++) {+ if(views[i].ID == viewType) {+ // Load the selected view+ views[i].load();+ $( "#"+views[i].ID+"Container" ).show();+ $( "#"+views[i].ID+"Toolbar" ).show();+ }+ }++ // Clear the list with the selected files+ UIAPI.selectedFiles = [];+ UIAPI.currentFilename = "";++ UIAPI.handleElementActivation();+// UIAPI.hideLoadingAnimation();}exports.clearSelectedFiles = function clearSelectedFiles() {- // Clear selected files in the model+ // Clear selected filesUIAPI.selectedFiles = [];-- // Deselect all- $(".selectedRow", $(UIAPI.fileTable)).each(function(){- $(this).toggleClass('selectedRow');- });+ for (var i=0; i < views.length; i++) {+ views[i].clearSelectedFiles();+ }}});\ No newline at end of file