Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Finishing refactoring for requirejs

uggrocke8703b43b0ae
diff --git a/build.number b/build.number
index 7c6731ad6..918051b92 100644
--- a/build.number
+++ b/build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Fri Mar 08 14:57:43 CET 2013
-build.number=1258
+#Thu Mar 21 10:56:19 CET 2013
+build.number=1260
diff --git a/build.xml b/build.xml
index 663c179c9..666a3e7ba 100644
--- a/build.xml
+++ b/build.xml
@@ -40,9 +40,15 @@ found in the LICENSE file.
<copy file="data/index.html" todir="${buildFirefoxExt.dir}/data" />
<copy file="data/about.html" todir="${buildFirefoxExt.dir}/data" />
<copy file="data/loader.js" todir="${buildFirefoxExt.dir}/data" />
- <copy todir="${buildFirefoxExt.dir}/lib" >
+ <replace file="${buildFirefoxExt.dir}/data/loader.js" >
+ <replacefilter token="@PRODUCTION@" value="true" />
+ </replace>
+ <copy todir="${buildFirefoxExt.dir}/lib" >
<fileset dir="lib" includes="**/*"/>
- </copy>
+ </copy>
+ <replace file="${buildFirefoxExt.dir}/lib/main.js" >
+ <replacefilter token="@PRODUCTION@" value="true" />
+ </replace>
<copy todir="${buildFirefoxExt.dir}/data/libs" >
<fileset dir="data/libs">
<include name="**/*"/>
@@ -104,7 +110,10 @@ found in the LICENSE file.
<copy file="data/index.html" todir="${buildChrome.dir}" />
<copy file="data/about.html" todir="${buildChrome.dir}" />
<copy file="data/loader.js" todir="${buildChrome.dir}" />
- <copy todir="${buildChrome.dir}/chrome" >
+ <replace file="${buildChrome.dir}/loader.js" >
+ <replacefilter token="@PRODUCTION@" value="true" />
+ </replace>
+ <copy todir="${buildChrome.dir}/chrome" >
<fileset dir="data/chrome" includes="**/*"/>
</copy>
<copy todir="${buildFirefoxExt.dir}/data/ext" >
diff --git a/data/ext/perspectiveThumb/extension.js b/data/ext/perspectiveThumb/extension.js
index 3a2abfd52..c03a479e0 100644
--- a/data/ext/perspectiveThumb/extension.js
+++ b/data/ext/perspectiveThumb/extension.js
@@ -12,6 +12,8 @@ define(function(require, exports, module) {
exports.Type = "view";
exports.Icon = "ui-icon-image";
+ var TSCORE = require("tscore");
+
var viewContainer = undefined;
var viewToolbar = undefined;
var viewFooter = undefined;
diff --git a/data/js/core.api.js b/data/js/core.api.js
index a9c028332..0c620d868 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -2,13 +2,12 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
-"use strict";
+//"use strict";
console.debug("Loading core.api.js ...");
- var TSSETTINGS = require("tssetting");
- var IOAPI = require("tsioapi");
-
+ var tsSettings = require("tssetting");
+ var tsIOApi = require("tsioapi");
var tsPersManager = require("tspersmanager");
var tsTagUtils = require("tstagutils");
var tsFileOpener = require("tsfileopener");
@@ -18,10 +17,6 @@ define(function(require, exports, module) {
var layoutContainer = undefined;
- exports.updateSubDirs = undefined;
- exports.initFavorites = undefined;
- exports.generateTagGroups = undefined;
-
var currentPath = "";
var currentView = undefined;
@@ -41,20 +36,8 @@ define(function(require, exports, module) {
var selectedTagData = "";
function initApp() {
- console.debug("Init application");
+ console.debug("Init application");
- exports.ViewManager = tsPersManager;
- exports.TagUtils = tsTagUtils;
- exports.FileOpener = tsFileOpener;
-
- exports.Config = TSSETTINGS;
- exports.IO = IOAPI;
-
- // Proxy for tsTagsUI
- exports.generateTagButtons = tsTagsUI.generateTagButtons
- exports.buttonizeTitle = tsTagsUI.buttonizeTitle
- exports.openTagMenu = tsTagsUI.openTagMenu
-
tsCoreUI.initButtons();
tsCoreUI.initDialogs();
@@ -65,32 +48,27 @@ define(function(require, exports, module) {
tsDirectoriesUI.initButtons();
tsDirectoriesUI.initContextMenus();
- // Proxying directoriesUI and tagsUI
- exports.updateSubDirs = tsDirectoriesUI.updateSubDirs;
- exports.initFavorites = tsDirectoriesUI.initFavorites;
- exports.generateTagGroups = tsTagsUI.generateTagGroups;
-
- TSSETTINGS.loadSettingsLocalStorage();
+ tsSettings.loadSettingsLocalStorage();
// In firefox, by empty local storage trying to load the settings from mozilla preferences
- if(TSSETTINGS.Settings == undefined && $.browser.mozilla) {
- window.setTimeout(IOAPI.loadSettings, 1000); // executes initUI and updateSettingMozillaPreferences by success
+ if(tsSettings.Settings == undefined && $.browser.mozilla) {
+ window.setTimeout(tsIOApi.loadSettings, 1000); // executes initUI and updateSettingMozillaPreferences by success
console.debug("Loading setting with from mozilla pref execured with delay...");
}
// If still nothing found, loading the default setting from the application's javascript
// This is usually the case by a new installation
- if(TSSETTINGS.Settings == undefined) {
- TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
+ if(tsSettings.Settings == undefined) {
+ tsSettings.Settings = tsSettings.DefaultSettings;
}
- TSSETTINGS.upgradeSettings();
+ tsSettings.upgradeSettings();
// Init views
- exports.ViewManager.initViews();
+ tsPersManager.initViews();
- $("#appVersion").text("["+TSSETTINGS.DefaultSettings["appVersion"]+"]");
- $("#appVersion").attr("title","["+TSSETTINGS.DefaultSettings["appBuild"]+"]");
+ $("#appVersion").text("["+tsSettings.DefaultSettings["appVersion"]+"]");
+ $("#appVersion").attr("title","["+tsSettings.DefaultSettings["appBuild"]+"]");
tsDirectoriesUI.initFavorites();
@@ -101,10 +79,10 @@ define(function(require, exports, module) {
hideLoadingAnimation();
// TODO check if document.ready is really needed
- $(document).ready(function() {
+// $(document).ready(function() {
initLayout();
- console.debug("Layout initialized");
- });
+// console.debug("Layout initialized");
+// });
// Show start hint
$( "#selectTagSpace" ).tooltip( "open" );
@@ -115,7 +93,7 @@ define(function(require, exports, module) {
currentPath = path;
// List preselected dir automatically
- IOAPI.listDirectory(currentPath);
+ tsIOApi.listDirectory(currentPath);
}
function updateLogger(message) {
@@ -140,96 +118,15 @@ define(function(require, exports, module) {
}
}
return false;
- }
-
- function refreshFileListContainer() {
- // TODO what happens with search view
- IOAPI.listDirectory(currentPath);
- }
-
- function updateFileBrowserData(dirList) {
- console.debug("Updating the file browser data...");
-
- fileList = [];
- var tags = undefined;
- var ext = undefined;
- var title = undefined;
- var fileSize = undefined;
- var fileLMDT = undefined;
- var path = undefined;
- // Sort the dir list alphabetically before displaying
- // TODO sorting files not working correctly
- dirList.sort(function(a,b) { return a.name.localeCompare(b.name); });
- for (var i=0; i < dirList.length; i++) {
- if (dirList[i].type == "file"){
- // Considering Unix HiddenEntries (. in the beginning)
- if (TSSETTINGS.Settings["showUnixHiddenEntries"] ||
- (!TSSETTINGS.Settings["showUnixHiddenEntries"] && (dirList[i].name.indexOf(".") != 0))) {
- path = currentPath + exports.TagUtils.DIR_SEPARATOR + dirList[i].name;
- tags = exports.TagUtils.extractTags(path);
- title = exports.TagUtils.extractTitle(path);
- if(dirList[i].name.lastIndexOf(".") > 0) {
- ext = dirList[i].name.substring(dirList[i].name.lastIndexOf(".")+1,dirList[i].name.length);
- } else {
- ext = "";
- }
- fileSize = dirList[i].size;
- fileLMDT = dirList[i].lmdt;
- if(fileSize == undefined) fileSize = "";
- if(fileLMDT == undefined) fileLMDT = "";
- var entry = [dirList[i].name,fileSize,fileLMDT,title,tags,ext];
- fileList.push(entry);
- }
- }
- }
-
- exports.ViewManager.changeView(currentView);
- }
-
- /** Depricated
- // ONE_DIR_UP
- var parentDir = "..";
+ }
- function changeDirectory(newDir) {
- console.debug("Change direcotory to: "+newDir);
- var newPath = currentPath;
- if(exports.TagUtils.isWindows()) {
- // Cutting trailig \\ or \\\\ .
- if(currentPath.lastIndexOf("\\")+1 == currentPath.length) {
- newPath = currentPath.substring(0,currentPath.length-1);
- } else if(currentPath.lastIndexOf("\\\\")+2 == currentPath.length) {
- newPath = currentPath.substring(0,currentPath.length-2);
- }
- if(newDir == parentDir) {
- newPath = newPath.substring(0,newPath.lastIndexOf("\\"));
- currentPath = newPath;
- } else if(newDir.length > 0) {
- currentPath = newPath+"\\"+newDir+"\\";
- }
- } else {
- // Cutting trailing /
- if(currentPath.lastIndexOf("/")+1 == currentPath.length) {
- newPath = currentPath.substring(0,currentPath.length-1);
- }
- if(newDir == parentDir) {
- newPath = newPath.substring(0,newPath.lastIndexOf("/"));
- currentPath = newPath;
- } else if(newDir.length > 0) {
- currentPath = newPath+"/"+newDir+"/";
- }
- }
- console.debug("New path: "+currentPath);
- IOAPI.listDirectory(currentPath);
- selectedTag = "";
- } */
-
function reloadUI() {
location.reload();
}
function openFile(filePath) {
// console.debug("Opening file...");
- exports.FileOpener.openFile(filePath);
+ tsFileOpener.openFile(filePath);
}
function openFileViewer() {
@@ -342,7 +239,14 @@ define(function(require, exports, module) {
// Closes the viewer area by init
layoutContainer.close("east");
}
-
+
+ // Proxying applications parts
+ exports.Config = tsSettings;
+ exports.IO = tsIOApi;
+ exports.ViewManager = tsPersManager;
+ exports.TagUtils = tsTagUtils;
+ exports.FileOpener = tsFileOpener;
+
// Public API definition
exports.initApp = initApp;
exports.setCurrentPath = setCurrentPath;
@@ -350,20 +254,28 @@ define(function(require, exports, module) {
exports.showLoadingAnimation = showLoadingAnimation;
exports.hideLoadingAnimation = hideLoadingAnimation;
exports.fileExists = fileExists;
- exports.refreshFileListContainer = refreshFileListContainer;
- exports.updateFileBrowserData = updateFileBrowserData;
exports.reloadUI = reloadUI;
exports.openFile = openFile;
exports.openFileViewer = openFileViewer;
exports.closeFileViewer = closeFileViewer;
exports.toggleLeftPanel = toggleLeftPanel;
+ // Proxying functions from tsTagsUI
+ exports.generateTagButtons = tsTagsUI.generateTagButtons
+ exports.buttonizeTitle = tsTagsUI.buttonizeTitle
+ exports.buttonizeFileName = tsTagsUI.buttonizeFileName
+ exports.openTagMenu = tsTagsUI.openTagMenu
+
+ // Proxying functions from directoriesUI
+ exports.updateSubDirs = tsDirectoriesUI.updateSubDirs;
+ exports.initFavorites = tsDirectoriesUI.initFavorites;
+
+ // Public variables definition
exports.currentPath = currentPath;
exports.currentView = currentView;
exports.selectedFiles = selectedFiles;
exports.isFileOpened = isFileOpened;
exports.fileList = fileList;
exports.selectedTag = selectedTag;
- exports.selectedTagData = selectedTagData;
-
+ exports.selectedTagData = selectedTagData;
});
\ No newline at end of file
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.js
index 5847b93fe..21533a4bb 100644
--- a/data/js/ioapi.chrome.js
+++ b/data/js/ioapi.chrome.js
@@ -36,10 +36,8 @@ define(function(require, exports, module) {
plugin.style.position = "absolute";
plugin.style.left = "-9999px";
- // Add plugin to document if the browser is chrome or chromium
- if(navigator.userAgent.indexOf("Chrom") > 0) {
- document.documentElement.appendChild(plugin);
- }
+ // Add plugin to document
+ document.documentElement.appendChild(plugin);
// Determine the directory separator
exports.pathSeparator = plugin.getPlatform() == 'windows' ? "\\" : '/';
@@ -83,7 +81,7 @@ define(function(require, exports, module) {
if(TSCORE.isFileOpened) {
TSCORE.openFile(newFilePath);
}
- TSCORE.refreshFileListContainer();
+ TSCORE.ViewManager.refreshFileListContainer();
console.debug("File renamed to: "+newFilePath);
} else {
@@ -106,7 +104,7 @@ define(function(require, exports, module) {
try {
var dirList = plugin.listFiles(dirPath);
console.debug("Dir content: "+JSON.stringify(dirList));
- TSCORE.updateFileBrowserData(dirList);
+ TSCORE.ViewManager.updateFileBrowserData(dirList);
} catch(ex) {
console.error("Directory listing failed "+ex);
}
@@ -143,6 +141,7 @@ define(function(require, exports, module) {
exports.deleteElement = function(path) {
console.debug("Deleting: "+path);
+ TSCORE.ViewManager.refreshFileListContainer();
plugin.removeFile(path)
}
diff --git a/data/js/ioapi.cordova.js b/data/js/ioapi.cordova.js
index 91653f8ef..a76629abb 100644
--- a/data/js/ioapi.cordova.js
+++ b/data/js/ioapi.cordova.js
@@ -98,7 +98,7 @@ IOAPI.listDirectory = function(dirPath) {
try {
var dirList = IOAPI.plugin.listFiles(dirPath);
console.debug("Dir content: "+JSON.stringify(dirList));
- UIAPI.updateFileBrowserData(dirList);
+ UIAPI.ViewManager.updateFileBrowserData(dirList);
} catch(ex) {
console.error("Directory listing failed "+ex);
}
diff --git a/data/js/ioapi.mozilla.receiver.js b/data/js/ioapi.mozilla.receiver.js
index eb19bc0d4..b349cedf6 100644
--- a/data/js/ioapi.mozilla.receiver.js
+++ b/data/js/ioapi.mozilla.receiver.js
@@ -50,7 +50,7 @@ console.debug("Loading messaging.mozilla.js..");
if(TSCORE.isFileOpened) {
TSCORE.openFile(TSCORE.selectedFiles[0]);
}
- TSCORE.refreshFileListContainer();
+ TSCORE.ViewManager.refreshFileListContainer();
} else {
TSCORE.updateLogger("Rename failed");
}
@@ -79,7 +79,7 @@ console.debug("Loading messaging.mozilla.js..");
break;
case "listDirectory":
if(message.success){
- TSCORE.updateFileBrowserData(message.content);
+ TSCORE.ViewManager.updateFileBrowserData(message.content);
} else {
TSCORE.updateLogger("List directory failed");
}
@@ -114,7 +114,8 @@ console.debug("Loading messaging.mozilla.js..");
break;
case "delete":
if(message.success){
- TSCORE.updateLogger("Delete success");
+ TSCORE.updateLogger("Delete success");
+ TSCORE.ViewManager.refreshFileListContainer();
} else {
TSCORE.updateLogger("Delete failed");
}
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index 2803d8d2f..3d3d7d6ee 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -129,6 +129,49 @@ exports.updateTreeData = function updateTreeData(treeData) {
}
}
+exports.updateFileBrowserData = function(dirList) {
+ console.debug("Updating the file browser data...");
+
+ TSCORE.fileList = [];
+ var tags = undefined;
+ var ext = undefined;
+ var title = undefined;
+ var fileSize = undefined;
+ var fileLMDT = undefined;
+ var path = undefined;
+ // Sort the dir list alphabetically before displaying
+ // TODO sorting files not working correctly
+ dirList.sort(function(a,b) { return a.name.localeCompare(b.name); });
+ for (var i=0; i < dirList.length; i++) {
+ if (dirList[i].type == "file"){
+ // Considering Unix HiddenEntries (. in the beginning)
+ if (TSCORE.Config.Settings["showUnixHiddenEntries"] ||
+ (!TSCORE.Config.Settings["showUnixHiddenEntries"] && (dirList[i].name.indexOf(".") != 0))) {
+ path = TSCORE.currentPath + TSCORE.TagUtils.DIR_SEPARATOR + dirList[i].name;
+ tags = TSCORE.TagUtils.extractTags(path);
+ title = TSCORE.TagUtils.extractTitle(path);
+ if(dirList[i].name.lastIndexOf(".") > 0) {
+ ext = dirList[i].name.substring(dirList[i].name.lastIndexOf(".")+1,dirList[i].name.length);
+ } else {
+ ext = "";
+ }
+ fileSize = dirList[i].size;
+ fileLMDT = dirList[i].lmdt;
+ if(fileSize == undefined) fileSize = "";
+ if(fileLMDT == undefined) fileLMDT = "";
+ var entry = [dirList[i].name,fileSize,fileLMDT,title,tags,ext];
+ TSCORE.fileList.push(entry);
+ }
+ }
+ }
+ exports.changeView(TSCORE.currentView);
+}
+
+exports.refreshFileListContainer = function() {
+ // TODO consider search view
+ TSCORE.IO.listDirectory(TSCORE.currentPath);
+}
+
exports.changeView = function changeView(viewType) {
console.debug("Change to "+viewType+" view.");
TSCORE.showLoadingAnimation();
@@ -147,7 +190,7 @@ exports.changeView = function changeView(viewType) {
try {
views[i].load();
} catch(e) {
- console.debug("Error while executing 'load' on "+views[i].ID+" "+e);
+ console.error("Error while executing 'load' on "+views[i].ID+" "+e);
}
$( "#"+views[i].ID+"Container" ).show();
$( "#"+views[i].ID+"Toolbar" ).show();
diff --git a/data/loader.js b/data/loader.js
index 0fb66306a..0301c9cf2 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -3,7 +3,8 @@
* can be found in the LICENSE file. */
//var LOG = debug ? console.log : function () {};
-var PRODUCTION = "@PRODUCTION@";// "true" | "@PRODUCTION@"
+// the value of this var is replaced to "true" by the build script
+var PRODUCTION = "@PRODUCTION@";
// Disabling all output to console in production mode
if (PRODUCTION == "true") {
@@ -146,9 +147,7 @@ require.config({
});
define(function (require, exports, module) {
-"use strict";
-
- console.debug("Loading Application...");
+//"use strict";
// Load dependent non-module scripts
require("jquery");
@@ -160,10 +159,11 @@ define(function (require, exports, module) {
require("jqueryuitooltips");
require("jqueryuidroppable");
require("less");
+
if( isFirefox ) {
require("tsiomozrec");
}
-
+
var TSCORE = require("tscore");
function onReady() {
diff --git a/data/manifest.json b/data/manifest.json
index 75fd96b1a..2bfcaafc1 100644
--- a/data/manifest.json
+++ b/data/manifest.json
@@ -1,6 +1,6 @@
{
"name": "TagSpaces",
- "version": "1.3.1256",
+ "version": "1.3.1259",
"manifest_version": 2,
"description": "TagSpaces Explorer",
"icons": {
diff --git a/lib/main.js b/lib/main.js
index 89c4c056e..72353f896 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -2,9 +2,11 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-var DEBUG_MODE_ON = true;
+// the value of this var is replaced to "true" by the build script
+var PRODUCTION = "@PRODUCTION@";
-if (!DEBUG_MODE_ON) {
+// Disabling all output to console in production mode
+if (PRODUCTION == "true") {
console = console || {};
console.log = function(){};
console.error = function(){};
diff --git a/package.json b/package.json
index 10c981739..112d2fec9 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "tagspaces",
"license": "AGPL 3.0",
"author": "Ugg Rock",
- "version": "1.3.1256",
+ "version": "1.3.1258",
"fullName": "TagSpaces",
"id": "jid1-FBaMKxTifTSahQ",
"description": "TagSpaces is a firefox addon, which allows you to browse your local file system and add tags to your files.",
diff --git a/update.rdf b/update.rdf
index 32f22ebaa..3fddb3222 100644
--- a/update.rdf
+++ b/update.rdf
@@ -7,13 +7,13 @@
<r:Seq>
<r:li>
<r:Description>
- <version>1.3.1256</version>
+ <version>1.3.1258</version>
<targetApplication>
<r:Description>
<id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
<minVersion>16.0</minVersion>
<maxVersion>*</maxVersion>
- <updateLink>http://tagspaces.com/releases/1.3/tagspaces.1.3.1256.xpi</updateLink>
+ <updateLink>http://tagspaces.com/releases/1.3/tagspaces.1.3.1258.xpi</updateLink>
<updateInfoURL>http://tagspaces.com/releases/1.3/updateInfo.xml</updateInfoURL>
</r:Description>
</targetApplication>