TagSpaces is an offline, open source, document manager with tagging support
Refactoring
uggrock4ae73a926504
diff --git a/data/js/core.api.js b/data/js/core.api.jsindex bd02871f3..766f3077b 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -6,7 +6,7 @@ define(['exports','module',],function(require, exports, module) {-//"use strict";+"use strict";console.debug("Loading core.api.js ...");@@ -14,7 +14,11 @@ var UIAPI = (typeof UIAPI == 'object' && UIAPI != null) ? UIAPI : {};var TSSETTINGS = require("tssetting");+var layoutContainer = undefined;+UIAPI.updateSubDirs = undefined;+UIAPI.initFavorites = undefined;+UIAPI.generateTagGroups = undefined;UIAPI.initApp = function() {console.debug("InitApplication");@@ -49,8 +53,10 @@ UIAPI.initApp = function() {tsDirectoriesUI.initButtons();tsDirectoriesUI.initContextMenus();- // Proxying directoriesUI+ // Proxying directoriesUI and tagsUIUIAPI.updateSubDirs = tsDirectoriesUI.updateSubDirs;+ UIAPI.initFavorites = tsDirectoriesUI.initFavorites;+ UIAPI.generateTagGroups = tsTagsUI.generateTagGroups;TSSETTINGS.loadSettingsLocalStorage();diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex 9a4ee5542..cf700f51c 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -6,459 +6,462 @@ define(['exports','module',],function(require, exports, module) {-//"use strict";--console.debug("Loading DirectoriesUI...");--var DirectoriesUI = (typeof DirectoriesUI == 'object' && DirectoriesUI != null) ? DirectoriesUI : {};--DirectoriesUI.directoryHistory = [];--DirectoriesUI.openFavorite = function(path, title) {- console.debug("Opening favorite in : "+path+" title: "+title);-- document.title = title + " | " + TSSETTINGS.DefaultSettings.appName;-- $( "#reloadTagSpace" ).button({- label: title- });- $( "#reloadTagSpace" ).attr("title",path);-- // Clears the directory history- DirectoriesUI.directoryHistory = new Array();- DirectoriesUI.navigateToDirectory(path);-}--// Updates the directory subtree-DirectoriesUI.updateSubDirs = function(dirList) {- console.debug("Updating subdirs(UIAPI)..."+JSON.stringify(dirList));-- // Sort the dirList alphabetically- dirList.sort(function(a,b) { return a.title.localeCompare(b.title); });-- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- if(DirectoriesUI.directoryHistory[i].key == UIAPI.currentPath) {- DirectoriesUI.directoryHistory[i]["children"] = new Array();- for(var j=0; j < dirList.length; j++) {- DirectoriesUI.directoryHistory[i]["children"].push(dirList[j]);- }- }- }-- DirectoriesUI.generateDirPath();- DirectoriesUI.handleDirCollapsion();-}--DirectoriesUI.dir4ContextMenu = null;--DirectoriesUI.generateDirPath = function() {- console.debug("Generating Directory Path...");- $("#dirTree").empty();-- // Code based on http://jsbin.com/eqape/1/edit- $("#dirTree").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- $("#dirTree").append($("<h3>", {- class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"- })- .hover(function() { $(this).toggleClass("ui-state-hover"); })- // Add plus button to h3- .append($("<span>", {- class: "ui-icon ui-icon-triangle-1-e",- style: "position:relative!important; display:inline-block;",- })- .click(function() {- $(this)-// .toggleClass("ui-icon-triangle-1-s")- .parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()- .parent().next().toggleClass("ui-accordion-content-active").toggle();- return false;- })- )- // Add directory button to h3- .append($("<button>", {- class: "dirButton",- key: DirectoriesUI.directoryHistory[i].key,- title: DirectoriesUI.directoryHistory[i].key,- text: DirectoriesUI.directoryHistory[i].title,- })- .droppable({- accept: '.fileTitleButton,.fileButton',- hoverClass: "dirButtonActive",- drop: function( event, ui ) {- var filePath = ui.draggable.attr("filepath");- var fileName = UIAPI.TagUtils.extractFileName(filePath);- var targetDir = $(this).attr("key");- console.log("Moving file: "+filePath+" to "+targetDir);- IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);- }- })- .click(function() {- DirectoriesUI.navigateToDirectory($(this).attr("key"));- })- )- // Add settings button to h3- .append($("<span>", {- class: "ui-icon ui-icon-gear",- key: DirectoriesUI.directoryHistory[i].key,- title: "Directorys options",- style: "float: right!important; position:relative!important; vertical-align: middle; display:inline-block;",- })- .dropdown( 'attach' , '#directoryMenu' )- .click( function(event) {- DirectoriesUI.dir4ContextMenu = $(this).attr("key");- })- )- );-- var dirButtons = $("<div>").appendTo( "#dirTree" );- dirButtons.attr("style","margin: 0px; padding: 5px;");- dirButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")- dirButtons.hide();- if(DirectoriesUI.directoryHistory[i]["children"].length <= 0) {- dirButtons.append("No subfolders found.");- } else {- for(var j=0; j < DirectoriesUI.directoryHistory[i]["children"].length; j++) {- dirButtons.append($("<button>", {- class: "dirButton",- key: DirectoriesUI.directoryHistory[i]["children"][j].key,- title: DirectoriesUI.directoryHistory[i]["children"][j].key,- text: DirectoriesUI.directoryHistory[i]["children"][j].title,- })- .droppable({- accept: ".fileTitleButton,.fileButton",- hoverClass: "dirButtonActive",- drop: function( event, ui ) {- var filePath = ui.draggable.attr("filepath");- var fileName = UIAPI.TagUtils.extractFileName(filePath);- var targetDir = $(this).attr("key");- console.log("Moving file: "+filePath+" to "+targetDir);- IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);- }- })- .click( function() {- DirectoriesUI.navigateToDirectory($(this).attr("key"));- })- );- }- }- }-}--DirectoriesUI.handleDirCollapsion = function() {- $("#dirTree").find("h3").each(function(index) {- console.log("Entered h3 "+$(this).next().text());- var key = $(this).find("button").attr("key");- if(!DirectoriesUI.getDirectoryCollapsed(key)) {- $(this).toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end();- $(this).next().toggleClass("ui-accordion-content-active").toggle();- }- });-}--DirectoriesUI.getDirectoryCollapsed = function(directoryPath) {- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- if(DirectoriesUI.directoryHistory[i].key == directoryPath) {- return DirectoriesUI.directoryHistory[i].collapsed;- }- }-}--DirectoriesUI.setDirectoryCollapse = function(directoryPath, collapsed) {- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- if(DirectoriesUI.directoryHistory[i].key == directoryPath) {- DirectoriesUI.directoryHistory[i].collapsed = collapsed;- }- }-}--DirectoriesUI.navigateToDirectory = function(directoryPath) {- console.log("Navigating to directory: "+directoryPath);-- // Cleaning the directory path from \\ \ and /- if( (directoryPath.lastIndexOf('/')+1 == directoryPath.length) || (directoryPath.lastIndexOf('\\')+1 == directoryPath.length)) {- directoryPath = directoryPath.substring(0,directoryPath.length-1);+"use strict";++ console.debug("Loading DirectoriesUI...");++ var directoryHistory = [];++ var dir4ContextMenu = null;++ var nameCurrentFavorite = undefined;++ function openFavorite(path, title) {+ console.debug("Opening favorite in : "+path+" title: "+title);++ document.title = title + " | " + TSSETTINGS.DefaultSettings.appName;++ $( "#reloadTagSpace" ).button({+ label: title+ });+ $( "#reloadTagSpace" ).attr("title",path);++ // Clears the directory history+ directoryHistory = new Array();+ navigateToDirectory(path);+ }++ // Updates the directory subtree+ function updateSubDirs(dirList) {+ console.debug("Updating subdirs(UIAPI)..."+JSON.stringify(dirList));++ // Sort the dirList alphabetically+ dirList.sort(function(a,b) { return a.title.localeCompare(b.title); });++ for(var i=0; i < directoryHistory.length; i++) {+ if(directoryHistory[i].key == UIAPI.currentPath) {+ directoryHistory[i]["children"] = new Array();+ for(var j=0; j < dirList.length; j++) {+ directoryHistory[i]["children"].push(dirList[j]);+ }+ }+ }++ generateDirPath();+ handleDirCollapsion();}- if( (directoryPath.lastIndexOf('\\\\')+1 == directoryPath.length)) {- directoryPath = directoryPath.substring(0,directoryPath.length-2);++ function generateDirPath() {+ console.debug("Generating Directory Path...");+ $("#dirTree").empty();++ // Code based on http://jsbin.com/eqape/1/edit+ $("#dirTree").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")+ for(var i=0; i < directoryHistory.length; i++) {+ $("#dirTree").append($("<h3>", {+ class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"+ })+ .hover(function() { $(this).toggleClass("ui-state-hover"); })+ // Add plus button to h3+ .append($("<span>", {+ class: "ui-icon ui-icon-triangle-1-e",+ style: "position:relative!important; display:inline-block;",+ })+ .click(function() {+ $(this)+ // .toggleClass("ui-icon-triangle-1-s")+ .parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()+ .parent().next().toggleClass("ui-accordion-content-active").toggle();+ return false;+ })+ )+ // Add directory button to h3+ .append($("<button>", {+ class: "dirButton",+ key: directoryHistory[i].key,+ title: directoryHistory[i].key,+ text: directoryHistory[i].title,+ })+ .droppable({+ accept: '.fileTitleButton,.fileButton',+ hoverClass: "dirButtonActive",+ drop: function( event, ui ) {+ var filePath = ui.draggable.attr("filepath");+ var fileName = UIAPI.TagUtils.extractFileName(filePath);+ var targetDir = $(this).attr("key");+ console.log("Moving file: "+filePath+" to "+targetDir);+ IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);+ }+ })+ .click(function() {+ navigateToDirectory($(this).attr("key"));+ })+ )+ // Add settings button to h3+ .append($("<span>", {+ class: "ui-icon ui-icon-gear",+ key: directoryHistory[i].key,+ title: "Directorys options",+ style: "float: right!important; position:relative!important; vertical-align: middle; display:inline-block;",+ })+ .dropdown( 'attach' , '#directoryMenu' )+ .click( function(event) {+ dir4ContextMenu = $(this).attr("key");+ })+ )+ );++ var dirButtons = $("<div>").appendTo( "#dirTree" );+ dirButtons.attr("style","margin: 0px; padding: 5px;");+ dirButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")+ dirButtons.hide();+ if(directoryHistory[i]["children"].length <= 0) {+ dirButtons.append("No subfolders found.");+ } else {+ for(var j=0; j < directoryHistory[i]["children"].length; j++) {+ dirButtons.append($("<button>", {+ class: "dirButton",+ key: directoryHistory[i]["children"][j].key,+ title: directoryHistory[i]["children"][j].key,+ text: directoryHistory[i]["children"][j].title,+ })+ .droppable({+ accept: ".fileTitleButton,.fileButton",+ hoverClass: "dirButtonActive",+ drop: function( event, ui ) {+ var filePath = ui.draggable.attr("filepath");+ var fileName = UIAPI.TagUtils.extractFileName(filePath);+ var targetDir = $(this).attr("key");+ console.log("Moving file: "+filePath+" to "+targetDir);+ IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);+ }+ })+ .click( function() {+ navigateToDirectory($(this).attr("key"));+ })+ );+ }+ }+ }}-- var directoryFoundOn = -1;- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- if(DirectoriesUI.directoryHistory[i].key == directoryPath) {- DirectoriesUI.directoryHistory[i].collapsed = false;- directoryFoundOn = i;- } else {- DirectoriesUI.directoryHistory[i].collapsed = true;- }- }-- // Removes the history only if it is a completely new path- if(directoryFoundOn >= 0) {- var diff = DirectoriesUI.directoryHistory.length - (directoryFoundOn+1);- if(diff > 0) {- DirectoriesUI.directoryHistory.splice(directoryFoundOn+1, diff);- }- }-- // If directory path not in history then add it to the history- if(directoryFoundOn < 0) {- var parentLocation = directoryPath.substring(0, directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR));- var parentFound = -1;- for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {- if(DirectoriesUI.directoryHistory[i].key == parentLocation) {- parentFound = i;- }- }- if(parentFound >= 0) {- var diff = DirectoriesUI.directoryHistory.length - (parentFound+1);++ function handleDirCollapsion() {+ $("#dirTree").find("h3").each(function(index) {+ console.log("Entered h3 "+$(this).next().text());+ var key = $(this).find("button").attr("key");+ if(!getDirectoryCollapsed(key)) {+ $(this).toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end();+ $(this).next().toggleClass("ui-accordion-content-active").toggle();+ }+ });+ }++ function getDirectoryCollapsed(directoryPath) {+ for(var i=0; i < directoryHistory.length; i++) {+ if(directoryHistory[i].key == directoryPath) {+ return directoryHistory[i].collapsed;+ }+ }+ }++ function setDirectoryCollapse(directoryPath, collapsed) {+ for(var i=0; i < directoryHistory.length; i++) {+ if(directoryHistory[i].key == directoryPath) {+ directoryHistory[i].collapsed = collapsed;+ }+ }+ }++ function navigateToDirectory(directoryPath) {+ console.log("Navigating to directory: "+directoryPath);++ // Cleaning the directory path from \\ \ and /+ if( (directoryPath.lastIndexOf('/')+1 == directoryPath.length) || (directoryPath.lastIndexOf('\\')+1 == directoryPath.length)) {+ directoryPath = directoryPath.substring(0,directoryPath.length-1);+ }+ if( (directoryPath.lastIndexOf('\\\\')+1 == directoryPath.length)) {+ directoryPath = directoryPath.substring(0,directoryPath.length-2);+ }++ var directoryFoundOn = -1;+ for(var i=0; i < directoryHistory.length; i++) {+ if(directoryHistory[i].key == directoryPath) {+ directoryHistory[i].collapsed = false;+ directoryFoundOn = i;+ } else {+ directoryHistory[i].collapsed = true;+ }+ }++ // Removes the history only if it is a completely new path+ if(directoryFoundOn >= 0) {+ var diff = directoryHistory.length - (directoryFoundOn+1);if(diff > 0) {- DirectoriesUI.directoryHistory.splice(parentFound+1, diff);+ directoryHistory.splice(directoryFoundOn+1, diff);}- }-- var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR)+1,directoryPath.length);- DirectoriesUI.directoryHistory.push({- "title": locationTitle,- "key" : directoryPath,- "collapsed" : false,- });- }-- UIAPI.currentPath = directoryPath;- IOAPI.getSubdirs(directoryPath);- IOAPI.listDirectory(directoryPath);-}--DirectoriesUI.initButtons = function() {- $( "#reloadTagSpace" )- .button()- .click(function() {- $( "#selectTagSpace" ).tooltip( "disable" );- $("#favoritesList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());- $("#favoritesList").show().position({- my: "left top",- at: "left bottom",- of: $( "#reloadTagSpace" )- });- $( document ).one( "click", function() {- $("#favoritesList").hide();- });- return false;- })- .next()- .button({- text: false,- icons: {- primary: "ui-icon-triangle-1-s"- }- })- .click(function() {- $("#favoritesList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());- $("#favoritesList").show().position({- my: "left top",- at: "left bottom",- of: $( "#reloadTagSpace" )- });- $( document ).one( "click", function() {- $("#favoritesList").hide();- });- return false;- })- .parent()- .buttonset()- .next()- .hide()- .menu();-- $( "#selectTagSpace" ).tooltip();-- $( "#selectLocalDirectory" )- .button({- text: false,- icons: {- primary: "ui-icon-folder-open"- }- })- .click(function() {- IOAPI.selectDirectory();- return false;- })-}--DirectoriesUI.initContextMenus = function() {- // Context menu for the tags in the file table and the file viewer- $( "#directoryMenu" ).menu({- select: function( event, ui ) {- console.debug("Tag menu action: "+ui.item.attr( "action" ));- switch (ui.item.attr( "action" )) {- case "reloadDirectory":- DirectoriesUI.navigateToDirectory(DirectoriesUI.dir4ContextMenu);- break;- case "createDirectory":- $( "#dialog-dircreate" ).dialog("open");- break;- case "openDirectory":- IOAPI.openDirectory(DirectoriesUI.dir4ContextMenu);- break;- }- }- });-}--DirectoriesUI.initDialogs = function() {- var newDirName = $( "#dirname" );-- // 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;- }- }-- $( "#dialog-dircreate" ).dialog({- autoOpen: false,- height: 200,- width: 350,- modal: true,- buttons: {- "Create": function() {- var bValid = true;- allFields.removeClass( "ui-state-error" );-- bValid = bValid && checkLength( newDirName, "directory name", 3, 100 );-- bValid = bValid && checkRegexp( newDirName, /^[a-z]([0-9a-z_])+$/i, "Directory name may consist of a-z, 0-9, underscores, begin with a letter." );- // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/- // bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. [email protected]" );- // bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );- if ( bValid ) {- IOAPI.createDirectory(DirectoriesUI.dir4ContextMenu+UIAPI.TagUtils.DIR_SEPARATOR+newDirName.val());- DirectoriesUI.navigateToDirectory(DirectoriesUI.dir4ContextMenu);- $( this ).dialog( "close" );- }- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- close: function() {- allFields.val( "" ).removeClass( "ui-state-error" );- }- });-- $( "#dialog-confirmfavoritedelete" ).dialog({- autoOpen: false,- resizable: false,- height:140,- modal: true,- buttons: {- "Delete": function() {- TSSETTINGS.deleteFavorite(nameCurrentFavorite);- DirectoriesUI.initFavorites();- DirectoriesUI.openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialogFavoriteCreate" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Create": function() {- TSSETTINGS.createFavorite($("#favoriteName").val(), $("#favoriteLocation").val());- DirectoriesUI.initFavorites();- DirectoriesUI.openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-}--var nameCurrentFavorite = undefined;--DirectoriesUI.initFavorites = function() {- console.debug("Creating location menu...");-- $( "#favoritesList" ).menu();- $( "#favoritesList" ).menu("disable");- $( "#favoritesList" ).empty();-- var favoritesList = TSSETTINGS.Settings["tagspacesList"]- for (var i=0; i < favoritesList.length; i++) {- $( "#favoritesList" ).append(- $('<li>', { title: favoritesList[i].path, name: favoritesList[i].name}).append(- $('<a>', { href: "javascript:void(0);", text: favoritesList[i].name} )));- };- $( "#favoritesList" ).append('<li><hr></li>');- $( "#favoritesList" ).append('<li name="createFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-document"></span>New Location</a></li>');- // $( "#favoritesList" ).append('<li name="editFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-pencil"></span>Edit Location</a></li>');- $( "#favoritesList" ).append('<li name="deleteFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-trash"></span>Remove Location</a></li>');-- $( "#favoritesList" ).menu("destroy").menu({- select: function( event, ui ) {- var commandName = ui.item.attr( "name" );- switch (commandName) {- case "createFavorite":- $("#favoriteName").val("");- $("#favoriteLocation").val("");- $("#dialogFavoriteCreate").dialog("open");- break;- case "editFavorite":- console.debug("Editing fav... under dev...");- $("#dialogFavoriteEdit").dialog("open");- break;- case "deleteFavorite":- $( "#dialog-confirmfavoritedelete" ).dialog("open");- break;- default:- nameCurrentFavorite = ui.item.attr( "name" );- DirectoriesUI.openFavorite(ui.item.attr( "title" ), ui.item.attr( "name" ));- $( "#favoritesList" ).hide();- break;- }- }- });- $( "#favoritesList" ).hide();-}--return DirectoriesUI;+ }++ // If directory path not in history then add it to the history+ if(directoryFoundOn < 0) {+ var parentLocation = directoryPath.substring(0, directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR));+ var parentFound = -1;+ for(var i=0; i < directoryHistory.length; i++) {+ if(directoryHistory[i].key == parentLocation) {+ parentFound = i;+ }+ }+ if(parentFound >= 0) {+ var diff = directoryHistory.length - (parentFound+1);+ if(diff > 0) {+ directoryHistory.splice(parentFound+1, diff);+ }+ }++ var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR)+1,directoryPath.length);+ directoryHistory.push({+ "title": locationTitle,+ "key" : directoryPath,+ "collapsed" : false,+ });+ }++ UIAPI.currentPath = directoryPath;+ IOAPI.getSubdirs(directoryPath);+ IOAPI.listDirectory(directoryPath);+ }++ function initButtons() {+ $( "#reloadTagSpace" )+ .button()+ .click(function() {+ $( "#selectTagSpace" ).tooltip( "disable" );+ $("#favoritesList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());+ $("#favoritesList").show().position({+ my: "left top",+ at: "left bottom",+ of: $( "#reloadTagSpace" )+ });+ $( document ).one( "click", function() {+ $("#favoritesList").hide();+ });+ return false;+ })+ .next()+ .button({+ text: false,+ icons: {+ primary: "ui-icon-triangle-1-s"+ }+ })+ .click(function() {+ $("#favoritesList").width($( "#reloadTagSpace" ).width()+$("#selectTagSpace").width());+ $("#favoritesList").show().position({+ my: "left top",+ at: "left bottom",+ of: $( "#reloadTagSpace" )+ });+ $( document ).one( "click", function() {+ $("#favoritesList").hide();+ });+ return false;+ })+ .parent()+ .buttonset()+ .next()+ .hide()+ .menu();++ $( "#selectTagSpace" ).tooltip();++ $( "#selectLocalDirectory" )+ .button({+ text: false,+ icons: {+ primary: "ui-icon-folder-open"+ }+ })+ .click(function() {+ IOAPI.selectDirectory();+ return false;+ })+ }++ function initContextMenus() {+ // Context menu for the tags in the file table and the file viewer+ $( "#directoryMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag menu action: "+ui.item.attr( "action" ));+ switch (ui.item.attr( "action" )) {+ case "reloadDirectory":+ navigateToDirectory(dir4ContextMenu);+ break;+ case "createDirectory":+ $( "#dialog-dircreate" ).dialog("open");+ break;+ case "openDirectory":+ IOAPI.openDirectory(dir4ContextMenu);+ break;+ }+ }+ });+ }++ function initDialogs() {+ var newDirName = $( "#dirname" );++ // 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;+ }+ }++ $( "#dialog-dircreate" ).dialog({+ autoOpen: false,+ height: 200,+ width: 350,+ modal: true,+ buttons: {+ "Create": function() {+ var bValid = true;+ allFields.removeClass( "ui-state-error" );++ bValid = bValid && checkLength( newDirName, "directory name", 3, 100 );++ bValid = bValid && checkRegexp( newDirName, /^[a-z]([0-9a-z_])+$/i, "Directory name may consist of a-z, 0-9, underscores, begin with a letter." );+ // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/+ // bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. [email protected]" );+ // bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );+ if ( bValid ) {+ IOAPI.createDirectory(dir4ContextMenu+UIAPI.TagUtils.DIR_SEPARATOR+newDirName.val());+ navigateToDirectory(dir4ContextMenu);+ $( this ).dialog( "close" );+ }+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ },+ close: function() {+ allFields.val( "" ).removeClass( "ui-state-error" );+ }+ });++ $( "#dialog-confirmfavoritedelete" ).dialog({+ autoOpen: false,+ resizable: false,+ height:140,+ modal: true,+ buttons: {+ "Delete": function() {+ TSSETTINGS.deleteFavorite(nameCurrentFavorite);+ initFavorites();+ openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialogFavoriteCreate" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Create": function() {+ TSSETTINGS.createFavorite($("#favoriteName").val(), $("#favoriteLocation").val());+ initFavorites();+ openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });+ }++ function initFavorites() {+ console.debug("Creating location menu...");++ $( "#favoritesList" ).menu();+ $( "#favoritesList" ).menu("disable");+ $( "#favoritesList" ).empty();++ var favoritesList = TSSETTINGS.Settings["tagspacesList"]+ for (var i=0; i < favoritesList.length; i++) {+ $( "#favoritesList" ).append(+ $('<li>', { title: favoritesList[i].path, name: favoritesList[i].name}).append(+ $('<a>', { href: "javascript:void(0);", text: favoritesList[i].name} )));+ };+ $( "#favoritesList" ).append('<li><hr></li>');+ $( "#favoritesList" ).append('<li name="createFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-document"></span>New Location</a></li>');+ // $( "#favoritesList" ).append('<li name="editFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-pencil"></span>Edit Location</a></li>');+ $( "#favoritesList" ).append('<li name="deleteFavorite"><a href="javascript:void(0);"><span class="ui-icon ui-icon-trash"></span>Remove Location</a></li>');++ $( "#favoritesList" ).menu("destroy").menu({+ select: function( event, ui ) {+ var commandName = ui.item.attr( "name" );+ switch (commandName) {+ case "createFavorite":+ $("#favoriteName").val("");+ $("#favoriteLocation").val("");+ $("#dialogFavoriteCreate").dialog("open");+ break;+ case "editFavorite":+ console.debug("Editing fav... under dev...");+ $("#dialogFavoriteEdit").dialog("open");+ break;+ case "deleteFavorite":+ $( "#dialog-confirmfavoritedelete" ).dialog("open");+ break;+ default:+ nameCurrentFavorite = ui.item.attr( "name" );+ openFavorite(ui.item.attr( "title" ), ui.item.attr( "name" ));+ $( "#favoritesList" ).hide();+ break;+ }+ }+ });+ $( "#favoritesList" ).hide();+ }+ // Public API definition+ exports.openFavorite = openFavorite;+ exports.updateSubDirs = updateSubDirs;+ exports.initDialogs = initDialogs;+ exports.initButtons = initButtons;+ exports.initContextMenus = initContextMenus;+ exports.initFavorites = initFavorites;});\ No newline at end of filediff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.jsindex 399a418a1..e7c8f22ae 100644--- a/data/js/ioapi.chrome.js+++ b/data/js/ioapi.chrome.js@@ -129,7 +129,7 @@ IOAPI.getSubdirs = function(dirPath) {}}// TODO JSON functions are a workarround for a bug....- DirectoriesUI.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));+ UIAPI.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));} catch(ex) {console.error("Directory listing failed "+ex);}diff --git a/data/js/ioapi.cordova.js b/data/js/ioapi.cordova.jsindex 093c5a8a2..91653f8ef 100644--- a/data/js/ioapi.cordova.js+++ b/data/js/ioapi.cordova.js@@ -124,7 +124,7 @@ IOAPI.getSubdirs = function(dirPath) {}}// TODO JSON functions are a workarround for a bug....- DirectoriesUI.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));+ UIAPI.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));} catch(ex) {console.error("Directory listing failed "+ex);}diff --git a/data/js/messaging.mozilla.js b/data/js/messaging.mozilla.jsindex b74ed3705..5862b8ab8 100644--- a/data/js/messaging.mozilla.js+++ b/data/js/messaging.mozilla.js@@ -17,8 +17,8 @@ document.documentElement.addEventListener("addon-message1", function(event) {console.debug("Loading settings...: "+JSON.stringify(message.content));TSSETTINGS.updateSettingMozillaPreferences(message.content);- DirectoriesUI.initFavorites();- TagsUI.generateTagGroups();+ UIAPI.initFavorites();+ UIAPI.generateTagGroups();} catch (ex) {console.debug("Exception while getting setting from firefox failed "+ex)@@ -62,7 +62,7 @@ document.documentElement.addEventListener("addon-message1", function(event) {case "createDirectory":if(message.success){UIAPI.updateLogger("Create dir success");- DirectoriesUI.openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);+ UIAPI.openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);} else {UIAPI.updateLogger("Create dir failed");}diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.jsindex c3f30f909..f8dca60a2 100644--- a/data/js/perspective.manager.js+++ b/data/js/perspective.manager.js@@ -7,7 +7,7 @@ define(['module','tscore'],function(require, exports, module) {-//"use strict";+"use strict";console.debug("Loading view.manager.js");diff --git a/data/js/settings.api.js b/data/js/settings.api.jsindex e71a28d1a..d01f5662b 100644--- a/data/js/settings.api.js+++ b/data/js/settings.api.js@@ -8,7 +8,7 @@ define([],function(require, exports, module) {"use strict";-console.debug("Loading SettingsAPI.js..");+console.debug("Loading settings.api.js..");var TSSETTINGS = (typeof TSSETTINGS == "object" && TSSETTINGS != null) ? TSSETTINGS : {};diff --git a/data/js/tags.ui.js b/data/js/tags.ui.jsindex 20d6036c1..92038648e 100644--- a/data/js/tags.ui.js+++ b/data/js/tags.ui.js@@ -10,483 +10,486 @@ define([console.debug("Loading TagsUI...");-var TagsUI = (typeof TagsUI == 'object' && TagsUI != null) ? TagsUI : {};+ function initContextMenus() {+ $( "#tagSuggestionsMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag suggestion "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ }+ });++ $( "#extensionMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ switch (ui.item.attr( "action" )) {+ case "addTagAsFilter":+ $( this ).hide();+ $("#filterBox").val(UIAPI.selectedTag);+ UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);+ break;+ }+ }+ });++ // Context menu for the tags in the file table and the file viewer+ $( "#tagMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ switch (ui.item.attr( "action" )) {+ case "addTagAsFilter":+ $( this ).hide();+ $("#filterBox").val(UIAPI.selectedTag);+ UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);+ break;+ case "addTagInTagGroup":+ $( this ).hide();+ // TODO Finish add tag in group+ break;+ case "editTag":+ $( this ).hide();+ $( "#newTag" ).val(UIAPI.selectedTag);+ $( "#dialogEditTag" ).dialog( "open" );+ break;+ case "removeTag":+ $( this ).hide();+ UIAPI.TagUtils.removeTag(UIAPI.selectedFiles[0],UIAPI.selectedTag);+ break;+ }+ }+ });++ // Context menu for the tags in the tag tree+ $( "#tagTreeMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ switch (ui.item.attr( "action" )) {+ case "addTagToFile":+ UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [UIAPI.selectedTag]);+ break;+ case "addTagAsFilter":+ $("#filterBox").val(UIAPI.selectedTag);+ UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);+ break;+ case "editTag":+ $( "#tagName" ).val(UIAPI.selectedTag);+ $( "#dialog-tagedit" ).dialog( "open" );+ break;+ case "deleteTag":+ $( "#dialog-confirmtagdelete" ).dialog( "open" );+ break;+ }+ }+ });++ // Context menu for the tags groups+ $( "#tagGroupMenu" ).menu({+ select: function( event, ui ) {+ console.debug("TagGroup menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ switch (ui.item.attr( "action" )) {+ case "createNewTag":+ $( "#newTagName" ).val("");+ $( "#dialog-tagcreate" ).dialog( "open" );+ break;+ case "deleteTagGroup":+ $( "#dialog-confirmtaggroupdelete" ).dialog( "open" );+ break;+ case "duplicateTagGroup":+ $( "#dialog-taggroupDupicate" ).dialog( "open" );+ break;+ case "editTagGroup":+ $( "#tagGroupName" ).val(UIAPI.selectedTagData.title);+ $( "#dialog-taggroupEdit" ).dialog( "open" );+ break;+ }+ }+ });++ $( "#fileMenu" ).menu({+ select: function( event, ui ) {+ var commandName = ui.item.attr( "action" );+ switch (commandName) {+ case "addTag":+ console.debug("Adding tag...");+ $("#tags").val("");+ $( "#dialogAddTags" ).dialog( "open" );+ break;+ case "openFile":+ console.debug("Opening file...");+ UIAPI.openFile(UIAPI.selectedFiles[0]);+ break;+ case "openDirectory":+ console.debug("Opening parent directory...");+ IOAPI.openDirectory(UIAPI.currentPath);+ break;+ case "renameFile":+ console.debug("Renaming file...");+ $( "#dialog-filerename" ).dialog( "open" );+ break;+ case "deleteFile":+ console.debug("Deleting file...");+ $( "#dialog-confirmdelete" ).dialog( "open" );+ break;+ default:+ break;+ }+ }+ });+ }++ function initDialogs() {+ var newDirName = $( "#dirname" );++ var newFileName = $( "#newFileName" );++ var renamedFileName = $( "#renamedFileName" );++ var smartTag = $( "#smartTagName" );++ // 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;+ }+ }++ $( "#dialog-smarttag" ).dialog({+ autoOpen: false,+ height: 220,+ width: 450,+ modal: true,+ buttons: {+ "Add smart tag": function() {+ var bValid = true;+ allFields.removeClass( "ui-state-error" );++ bValid = bValid && checkLength( smartTag, "tagname", 2, 40 );+ if ( bValid ) {+ for (var i=0; i < UIAPI.selectedFiles.length; i++) {+ UIAPI.TagUtils.writeTagsToFile(UIAPI.selectedFiles[i], [smartTag.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]);+ }+ });++ /* Currently not used+ $( "#dialog-confirmtagremove" ).dialog({+ autoOpen: false,+ resizable: false,+ height:140,+ modal: true,+ buttons: {+ "Remove": function() {+ UIAPI.TagUtils.removeTag(UIAPI.selectedTag);+ $( this ).dialog( "close" );+ IOAPI.listDirectory(UIAPI.currentPath);+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ }); */++ $( "#dialog-confirmtagdelete" ).dialog({+ autoOpen: false,+ resizable: false,+ height:140,+ modal: true,+ buttons: {+ "Delete": function() {+ TSSETTINGS.deleteTag(UIAPI.selectedTagData);+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialog-confirmtaggroupdelete" ).dialog({+ autoOpen: false,+ resizable: false,+ height:140,+ modal: true,+ buttons: {+ "Delete": function() {+ TSSETTINGS.deleteTagGroup(UIAPI.selectedTagData);+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialog-tagedit" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Save": function() {+ TSSETTINGS.editTag(UIAPI.selectedTagData, $( "#tagName" ).val() )+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialog-tagcreate" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Create Tag": function() {+ TSSETTINGS.createTag(UIAPI.selectedTagData, $( "#newTagName" ).val() )+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialog-taggroupDupicate" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Duplicate Taggroup": function() {+ TSSETTINGS.duplicateTagGroup(UIAPI.selectedTagData, $( "#newTagGroupName" ).val(), $( "#newTagGroupKey" ).val() )+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });++ $( "#dialog-taggroupEdit" ).dialog({+ autoOpen: false,+ resizable: false,+ height:240,+ modal: true,+ buttons: {+ "Save": function() {+ TSSETTINGS.editTagGroup(UIAPI.selectedTagData, $( "#tagGroupName" ).val() )+ TagsUI.generateTagGroups();+ $( this ).dialog( "close" );+ },+ Cancel: function() {+ $( this ).dialog( "close" );+ }+ }+ });+ }++ function generateTagGroups() {+ console.debug("Generating TagGroups...");+ $("#tagGroups").empty();+ $("#tagGroups").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")+ for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {+ // Code based on http://jsbin.com/eqape/1/edit+ $("#tagGroups").append($("<h3>", {+ class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"+ })+ /* .droppable({+ accept: ".tagButton",+ hoverClass: "activeRow",+ drop: function( event, ui ) {+ var tagName = ui.draggable.attr("tag");+ TSSETTINGS.createTag(UIAPI.selectedTagData, tagName );+ TSSETTINGS.deleteTag(UIAPI.selectedTagData);+ TagsUI.generateTagGroups();+ }+ }) */+ .hover(function() { $(this).toggleClass("ui-state-hover"); })+ .append($("<span>", {+ class: "tagGroupTitle",+ text: TSSETTINGS.Settings["tagGroups"][i].title,+ })+ .click(function() {+ $(this)+ .parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()+ .parent().next().toggleClass("ui-accordion-content-active").toggle();+ return false;+ })+ )+ .append($("<span>", {+ class: "ui-icon ui-icon-gear",+ style: "float: right!important; position:relative!important; vertical-align: middle; display:inline-block;",+ tag: TSSETTINGS.Settings["tagGroups"][i].title,+ key: TSSETTINGS.Settings["tagGroups"][i].key,+ title: "Taggroup options",+ })+ .dropdown( 'attach' , '#tagGroupMenu' )+ .click( function(event) {+ //console.debug("Clicked in taggroup setting");+ UIAPI.selectedTag = $(this).attr("tag");+ UIAPI.selectedTagData = TSSETTINGS.getTagGroupData($(this).attr("key"));+ UIAPI.selectedTagData.parentKey = undefined;+ })+ )+ );++ var tagButtons = $("<div>").appendTo( "#tagGroups" );+ tagButtons.attr("style","margin: 0px; padding: 5px;");+ tagButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")+ tagButtons.hide();+ for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {+ tagButtons.append($("<button>", {+ class: "tagButton",+ tag: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,+ parentKey: TSSETTINGS.Settings["tagGroups"][i].key,+ title: "Opens context menu for "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,+ text: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,+ })+ .draggable({+ cancel:false,+ appendTo: "body",+ helper: "clone",+ revert: true,+ })+ .click( function() {+ UIAPI.selectedTag = $(this).attr("tag");+ UIAPI.selectedTagData = TSSETTINGS.getTagData($(this).attr("tag"), $(this).attr("parentKey"));+ UIAPI.selectedTagData.parentKey = $(this).attr("parentKey");+ })+ .dropdown( 'attach' , '#tagTreeMenu' )+ );+ }+ }++ //Opens all taggroups by default+ $("#tagGroups").find("h3").each(function(index) {+ //console.log("Entered h3 "+$(this).next().text());+ $(this).toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()+ $(this).next().toggleClass("ui-accordion-content-active").toggle();+ });+ }++ function openTagMenu(tagButton, tag, filePath) {+ UIAPI.selectedFiles.push(filePath);+ UIAPI.selectedTag = tag;+ }++ // Helper function user by basic and search views+ function generateTagButtons(commaSeparatedTags, fileExtension, fileName, filePath) {+ console.debug("Creating tags...");+ var tagString = ""+commaSeparatedTags;+ var wrapper = $('<span>');+ if(filePath == undefined) {+ filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;+ }+ if(fileExtension.length > 0) {+ wrapper.append($('<button>', {+ title: "Opens context menu for "+fileExtension,+ tag: fileExtension,+ filename: fileName,+ filepath: filePath,+ class: "extTagButton",+ text: fileExtension+ }));+ }+ if(tagString.length > 0) {+ var tags = tagString.split(",");+ for (var i=0; i < tags.length; i++) {+ wrapper.append($('<button>', {+ title: "Opens context menu for "+tags[i],+ tag: tags[i],+ filename: fileName,+ filepath: filePath,+ class: "tagButton",+ text: tags[i]+ }));+ }+ }+ return wrapper.html();+ }++ // Helper function user by basic and search views+ function buttonizeTitle(title, fileName, filePath) {+ if(title.length < 1) {+ title = "n/a";+ }+ if(filePath == undefined) {+ filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;+ }+ return $('<span>').append($('<button>', {+ title: fileName,+ filepath: filePath,+ class: 'fileTitleButton',+ text: title+ })).html();+ }++ // Helper function user by basic and search views+ function buttonizeFileName(fileName, filePath) {+ if(filePath == undefined) {+ filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;+ }+ return $('<span>').append($('<button>', {+ title: fileName,+ filepath: filePath,+ class: 'fileButton',+ text: fileName+ })).html();+ }-TagsUI.initContextMenus = function() {-- $( "#tagSuggestionsMenu" ).menu({- select: function( event, ui ) {- console.debug("Tag suggestion "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);- }- });-- $( "#extensionMenu" ).menu({- select: function( event, ui ) {- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);- switch (ui.item.attr( "action" )) {- case "addTagAsFilter":- $( this ).hide();- $("#filterBox").val(UIAPI.selectedTag);- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);- break;- }- }- });-- // Context menu for the tags in the file table and the file viewer- $( "#tagMenu" ).menu({- select: function( event, ui ) {- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);- switch (ui.item.attr( "action" )) {- case "addTagAsFilter":- $( this ).hide();- $("#filterBox").val(UIAPI.selectedTag);- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);- break;- case "addTagInTagGroup":- $( this ).hide();- // TODO Finish add tag in group- break;- case "editTag":- $( this ).hide();- $( "#newTag" ).val(UIAPI.selectedTag);- $( "#dialogEditTag" ).dialog( "open" );- break;- case "removeTag":- $( this ).hide();- UIAPI.TagUtils.removeTag(UIAPI.selectedFiles[0],UIAPI.selectedTag);- break;- }- }- });-- // Context menu for the tags in the tag tree- $( "#tagTreeMenu" ).menu({- select: function( event, ui ) {- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);- switch (ui.item.attr( "action" )) {- case "addTagToFile":- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [UIAPI.selectedTag]);- break;- case "addTagAsFilter":- $("#filterBox").val(UIAPI.selectedTag);- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);- break;- case "editTag":- $( "#tagName" ).val(UIAPI.selectedTag);- $( "#dialog-tagedit" ).dialog( "open" );- break;- case "deleteTag":- $( "#dialog-confirmtagdelete" ).dialog( "open" );- break;- }- }- });-- // Context menu for the tags groups- $( "#tagGroupMenu" ).menu({- select: function( event, ui ) {- console.debug("TagGroup menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);- switch (ui.item.attr( "action" )) {- case "createNewTag":- $( "#newTagName" ).val("");- $( "#dialog-tagcreate" ).dialog( "open" );- break;- case "deleteTagGroup":- $( "#dialog-confirmtaggroupdelete" ).dialog( "open" );- break;- case "duplicateTagGroup":- $( "#dialog-taggroupDupicate" ).dialog( "open" );- break;- case "editTagGroup":- $( "#tagGroupName" ).val(UIAPI.selectedTagData.title);- $( "#dialog-taggroupEdit" ).dialog( "open" );- break;- }- }- });-- $( "#fileMenu" ).menu({- select: function( event, ui ) {- var commandName = ui.item.attr( "action" );- switch (commandName) {- case "addTag":- console.debug("Adding tag...");- $("#tags").val("");- $( "#dialogAddTags" ).dialog( "open" );- break;- case "openFile":- console.debug("Opening file...");- UIAPI.openFile(UIAPI.selectedFiles[0]);- break;- case "openDirectory":- console.debug("Opening parent directory...");- IOAPI.openDirectory(UIAPI.currentPath);- break;- case "renameFile":- console.debug("Renaming file...");- $( "#dialog-filerename" ).dialog( "open" );- break;- case "deleteFile":- console.debug("Deleting file...");- $( "#dialog-confirmdelete" ).dialog( "open" );- break;- default:- break;- }- }- });-}--TagsUI.initDialogs = function() {-- var newDirName = $( "#dirname" );-- var newFileName = $( "#newFileName" );-- var renamedFileName = $( "#renamedFileName" );-- var smartTag = $( "#smartTagName" );-- // 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;- }- }-- $( "#dialog-smarttag" ).dialog({- autoOpen: false,- height: 220,- width: 450,- modal: true,- buttons: {- "Add smart tag": function() {- var bValid = true;- allFields.removeClass( "ui-state-error" );-- bValid = bValid && checkLength( smartTag, "tagname", 2, 40 );- if ( bValid ) {- for (var i=0; i < UIAPI.selectedFiles.length; i++) {- UIAPI.TagUtils.writeTagsToFile(UIAPI.selectedFiles[i], [smartTag.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]);- }- });-- /* Currently not used- $( "#dialog-confirmtagremove" ).dialog({- autoOpen: false,- resizable: false,- height:140,- modal: true,- buttons: {- "Remove": function() {- UIAPI.TagUtils.removeTag(UIAPI.selectedTag);- $( this ).dialog( "close" );- IOAPI.listDirectory(UIAPI.currentPath);- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- }); */-- $( "#dialog-confirmtagdelete" ).dialog({- autoOpen: false,- resizable: false,- height:140,- modal: true,- buttons: {- "Delete": function() {- TSSETTINGS.deleteTag(UIAPI.selectedTagData);- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-confirmtaggroupdelete" ).dialog({- autoOpen: false,- resizable: false,- height:140,- modal: true,- buttons: {- "Delete": function() {- TSSETTINGS.deleteTagGroup(UIAPI.selectedTagData);- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-tagedit" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Save": function() {- TSSETTINGS.editTag(UIAPI.selectedTagData, $( "#tagName" ).val() )- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-tagcreate" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Create Tag": function() {- TSSETTINGS.createTag(UIAPI.selectedTagData, $( "#newTagName" ).val() )- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-taggroupDupicate" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Duplicate Taggroup": function() {- TSSETTINGS.duplicateTagGroup(UIAPI.selectedTagData, $( "#newTagGroupName" ).val(), $( "#newTagGroupKey" ).val() )- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-taggroupEdit" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Save": function() {- TSSETTINGS.editTagGroup(UIAPI.selectedTagData, $( "#tagGroupName" ).val() )- TagsUI.generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-}--TagsUI.generateTagGroups = function() {- console.debug("Generating TagGroups...");- $("#tagGroups").empty();- $("#tagGroups").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {- // Code based on http://jsbin.com/eqape/1/edit- $("#tagGroups").append($("<h3>", {- class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"- })- /* .droppable({- accept: ".tagButton",- hoverClass: "activeRow",- drop: function( event, ui ) {- var tagName = ui.draggable.attr("tag");- TSSETTINGS.createTag(UIAPI.selectedTagData, tagName );- TSSETTINGS.deleteTag(UIAPI.selectedTagData);- TagsUI.generateTagGroups();- }- }) */- .hover(function() { $(this).toggleClass("ui-state-hover"); })- .append($("<span>", {- class: "tagGroupTitle",- text: TSSETTINGS.Settings["tagGroups"][i].title,- })- .click(function() {- $(this)- .parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()- .parent().next().toggleClass("ui-accordion-content-active").toggle();- return false;- })- )- .append($("<span>", {- class: "ui-icon ui-icon-gear",- style: "float: right!important; position:relative!important; vertical-align: middle; display:inline-block;",- tag: TSSETTINGS.Settings["tagGroups"][i].title,- key: TSSETTINGS.Settings["tagGroups"][i].key,- title: "Taggroup options",- })- .dropdown( 'attach' , '#tagGroupMenu' )- .click( function(event) {- //console.debug("Clicked in taggroup setting");- UIAPI.selectedTag = $(this).attr("tag");- UIAPI.selectedTagData = TSSETTINGS.getTagGroupData($(this).attr("key"));- UIAPI.selectedTagData.parentKey = undefined;- })- )- );-- var tagButtons = $("<div>").appendTo( "#tagGroups" );- tagButtons.attr("style","margin: 0px; padding: 5px;");- tagButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")- tagButtons.hide();- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {- tagButtons.append($("<button>", {- class: "tagButton",- tag: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,- parentKey: TSSETTINGS.Settings["tagGroups"][i].key,- title: "Opens context menu for "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,- text: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,- })- .draggable({- cancel:false,- appendTo: "body",- helper: "clone",- revert: true,- })- .click( function() {- UIAPI.selectedTag = $(this).attr("tag");- UIAPI.selectedTagData = TSSETTINGS.getTagData($(this).attr("tag"), $(this).attr("parentKey"));- UIAPI.selectedTagData.parentKey = $(this).attr("parentKey");- })- .dropdown( 'attach' , '#tagTreeMenu' )- );- }- }-- //Opens all taggroups by default- $("#tagGroups").find("h3").each(function(index) {- //console.log("Entered h3 "+$(this).next().text());- $(this).toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()- $(this).next().toggleClass("ui-accordion-content-active").toggle();- });-}--TagsUI.openTagMenu = function(tagButton, tag, filePath) {- UIAPI.selectedFiles.push(filePath);- UIAPI.selectedTag = tag;-}--// Helper function user by basic and search views-TagsUI.generateTagButtons = function(commaSeparatedTags, fileExtension, fileName, filePath) {- console.debug("Creating tags...");- var tagString = ""+commaSeparatedTags;- var wrapper = $('<span>');- if(filePath == undefined) {- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;- }- if(fileExtension.length > 0) {- wrapper.append($('<button>', {- title: "Opens context menu for "+fileExtension,- tag: fileExtension,- filename: fileName,- filepath: filePath,- class: "extTagButton",- text: fileExtension- }));- }- if(tagString.length > 0) {- var tags = tagString.split(",");- for (var i=0; i < tags.length; i++) {- wrapper.append($('<button>', {- title: "Opens context menu for "+tags[i],- tag: tags[i],- filename: fileName,- filepath: filePath,- class: "tagButton",- text: tags[i]- }));- }- }- return wrapper.html();-}--// Helper function user by basic and search views-TagsUI.buttonizeTitle = function(title, fileName, filePath) {- if(title.length < 1) {- title = "n/a";- }- if(filePath == undefined) {- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;- }- return $('<span>').append($('<button>', {- title: fileName,- filepath: filePath,- class: 'fileTitleButton',- text: title- })).html();-}--// Helper function user by basic and search views-TagsUI.buttonizeFileName = function(fileName, filePath) {- if(filePath == undefined) {- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;- }- return $('<span>').append($('<button>', {- title: fileName,- filepath: filePath,- class: 'fileButton',- text: fileName- })).html();-}--return TagsUI;+ // Public API definition+ exports.initContextMenus = initContextMenus;+ exports.initDialogs = initDialogs;+ exports.generateTagGroups = generateTagGroups;+ exports.openTagMenu = openTagMenu;+ exports.generateTagButtons = generateTagButtons;+ exports.buttonizeTitle = buttonizeTitle;+ exports.buttonizeFileName = buttonizeFileName;});\ No newline at end of filediff --git a/data/loader.js b/data/loader.jsindex 3491d4492..db2a66e34 100644--- a/data/loader.js+++ b/data/loader.js@@ -149,8 +149,6 @@ require([function() {console.debug("Loading Application...");- var layoutContainer = undefined;-UIAPI = undefined;TSSETTINGS = undefined;