Skip to content

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

Disabling edit button by unknown filetype Adding domReady.js for improving startup issues Correcting a issue preventing showing the title in the file opener

uggrock0bae5aa81a2a
diff --git a/build.number b/build.number
index 64f5b1ee5..405652aad 100644
--- a/build.number
+++ b/build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Wed Mar 27 22:26:25 CET 2013
-build.number=1280
+#Thu Mar 28 09:07:12 CET 2013
+build.number=1282
diff --git a/data/ext/perspectiveBasic/extension.js b/data/ext/perspectiveBasic/extension.js
index 545d7837b..8fb2bfb6f 100644
--- a/data/ext/perspectiveBasic/extension.js
+++ b/data/ext/perspectiveBasic/extension.js
@@ -240,7 +240,7 @@ define(function(require, exports, module) {
console.debug("Opening file...");
var rowData = fileTable.fnGetData( this );
- TSCORE.openFile(TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+rowData[0]);
+ TSCORE.FileOpener.openFile(TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+rowData[0]);
} );
fileTable.$('.fileButton')
diff --git a/data/ext/perspectiveGraph/extension.js b/data/ext/perspectiveGraph/extension.js
index 6a0d3541f..3ff5f01d1 100644
--- a/data/ext/perspectiveGraph/extension.js
+++ b/data/ext/perspectiveGraph/extension.js
@@ -514,7 +514,7 @@ define(function(require, exports, module) {
var commandName = ui.item.attr( "action" );
switch (commandName) {
case "openFile":
- TSCORE.openFile(TSCORE.selectedFiles[0]);
+ TSCORE.FileOpener.openFile(TSCORE.selectedFiles[0]);
break;
case "addTag":
console.debug("Adding tag...");
diff --git a/data/ext/perspectiveSearch/extension.js b/data/ext/perspectiveSearch/extension.js
index fecc18e18..b24cf1f22 100644
--- a/data/ext/perspectiveSearch/extension.js
+++ b/data/ext/perspectiveSearch/extension.js
@@ -227,7 +227,7 @@ define(function(require, exports, module) {
console.debug("Opening file...");
var rowData = fileTable.fnGetData( this );
- TSCORE.openFile(rowData[4]); // 4 is the filePath
+ TSCORE.FileOpener.openFile(rowData[4]); // 4 is the filePath
} );
fileTable.$('.fileTitleButton')
diff --git a/data/ext/perspectiveThumb/extension.js b/data/ext/perspectiveThumb/extension.js
index c03a479e0..7d2a37a64 100644
--- a/data/ext/perspectiveThumb/extension.js
+++ b/data/ext/perspectiveThumb/extension.js
@@ -56,7 +56,7 @@ define(function(require, exports, module) {
// On selecting only one file opens it in the viewer
if(TSCORE.selectedFiles.length == 1) {
- TSCORE.openFile(TSCORE.selectedFiles[0]);
+ TSCORE.FileOpener.openFile(TSCORE.selectedFiles[0]);
}
}
});
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 656cd6fcc..9b769a9ff 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -24,9 +24,6 @@ define(function(require, exports, module) {
// Current selected files
var selectedFiles = [];
- // True if a file is opened in the viewer
- var isFileOpened = false;
-
// Current directory list of files
var fileList = [];
@@ -128,18 +125,11 @@ define(function(require, exports, module) {
location.reload();
}
- function openFile(filePath) {
- // console.debug("Opening file...");
- tsFileOpener.openFile(filePath);
- }
-
function openFileViewer() {
- isFileOpened = true;
layoutContainer.open("east");
}
function closeFileViewer() {
- isFileOpened = false;
layoutContainer.close("east");
}
@@ -258,7 +248,6 @@ define(function(require, exports, module) {
exports.hideLoadingAnimation = hideLoadingAnimation;
exports.fileExists = fileExists;
exports.reloadUI = reloadUI;
- exports.openFile = openFile;
exports.openFileViewer = openFileViewer;
exports.closeFileViewer = closeFileViewer;
exports.toggleLeftPanel = toggleLeftPanel;
@@ -277,7 +266,6 @@ define(function(require, exports, module) {
exports.currentPath = currentPath;
exports.currentView = currentView;
exports.selectedFiles = selectedFiles;
- exports.isFileOpened = isFileOpened;
exports.fileList = fileList;
exports.selectedTag = selectedTag;
exports.selectedTagData = selectedTagData;
diff --git a/data/js/fileopener.js b/data/js/fileopener.js
index b878e49f8..cf3311428 100644
--- a/data/js/fileopener.js
+++ b/data/js/fileopener.js
@@ -8,13 +8,34 @@ define(function(require, exports, module) {
var TSCORE = require("tscore");
+ var _openedFilePath = undefined;
+
+ var _isFileOpened = false;
+
+ var _tsEditor = undefined;
+
+ // If a file is currently opened for editing, this var should be true
+ var _isEditMode = false;
+
+ function isFileOpened() {
+ return _isFileOpened;
+ }
+
+ function setFileOpened(fileOpened) {
+ _isFileOpened = fileOpened;
+ }
+
+ function getOpenedFilePath() {
+ return _openedFilePath;
+ }
+
function openFile(filePath) {
console.debug("Opening file: "+filePath);
- isEditMode = false;
+ _isEditMode = false;
- var openedFilePath = filePath;
- $("#selectedFilePath").val(openedFilePath.replace("\\\\","\\"));
+ _openedFilePath = filePath;
+ $("#selectedFilePath").val(_openedFilePath.replace("\\\\","\\"));
var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
@@ -24,8 +45,6 @@ define(function(require, exports, module) {
var viewerExt = TSCORE.Config.getFileTypeViewer(fileExt);
console.debug("File Viewer: "+viewerExt);
- TSCORE.openFileViewer();
-
initTagSuggestionMenu(filePath);
$( "#viewer" ).empty();
@@ -40,21 +59,18 @@ define(function(require, exports, module) {
}));
} else {
require([TSCORE.Config.getExtensionPath()+"/"+viewerExt+"/"+"extension.js"], function(viewer) {
- tsEditor = viewer;
- tsEditor.init(filePath, "viewer");
- tsEditor.viewerMode(true);
+ _tsEditor = viewer;
+ _tsEditor.init(filePath, "viewer");
+ _tsEditor.viewerMode(true);
});
- }
+ }
+ TSCORE.FileOpener.setFileOpened(true);
+ TSCORE.openFileViewer();
}
- var tsEditor = undefined;
-
- // If a file is currently opened for editing, this var should be true
- var isEditMode = false;
-
function updateEditorContent(fileContent) {
console.debug("Updating editor"); // with data: "+fileContent);
- tsEditor.setContent(fileContent);
+ _tsEditor.setContent(fileContent);
}
// Should return false if no editor found
@@ -79,10 +95,10 @@ define(function(require, exports, module) {
} else {
try {
require([TSCORE.Config.getExtensionPath()+"/"+editorExt+"/extension.js"], function(editr) {
- tsEditor = editr;
- tsEditor.init(filePath, "viewer");
+ _tsEditor = editr;
+ _tsEditor.init(filePath, "viewer");
});
- isEditMode = true;
+ _isEditMode = true;
} catch(ex) {
console.error("Loading editing extension failed: "+ex);
}
@@ -91,15 +107,17 @@ define(function(require, exports, module) {
function saveFile(filePath) {
console.debug("Save current file: "+filePath);
- var content = tsEditor.getContent();
+ var content = _tsEditor.getContent();
TSCORE.IO.saveTextFile(filePath, content);
}
function constructFileViewerUI(filePath) {
// Adding tag buttons to the filetoolbox
var tags = TSCORE.TagUtils.extractTags(filePath);
+
+ var title = TSCORE.TagUtils.extractTitle(filePath);
- $( "#fileTitle" ).text();
+ $( "#fileTitle" ).text(title);
// Generate tag buttons
$( "#fileTags" ).empty();
@@ -185,9 +203,9 @@ define(function(require, exports, module) {
}
function addTagSuggestionButton(container) {
- $( ""+container ).append('<button id="openTagSuggestionMenu">Tag</button>');
+ $( ""+container ).append('<button id="openTagSuggestionMenu" title="Tag Suggestions">Tag</button>');
$( "#openTagSuggestionMenu" ).button({
- text: false,
+ text: false,
icons: {
primary: "ui-icon-tag"
},
@@ -198,7 +216,7 @@ define(function(require, exports, module) {
function addEditButton(container, filePath) {
var buttonDisabled = false;
// If no editor found, disabling the button
- if(getFileEditor(filePath) === false) {
+ if(getFileEditor(filePath) === "false") {
buttonDisabled = true;
}
var options;
@@ -231,7 +249,7 @@ define(function(require, exports, module) {
}
};
saveFile(filePath);
- TSCORE.openFile(filePath);
+ openFile(filePath);
}
}
$( this ).button( "option", options );
@@ -262,19 +280,20 @@ define(function(require, exports, module) {
disabled: false
})
.click(function() {
- if(isEditMode) {
+ if(_isEditMode) {
if(confirm("If you confirm, all made changes will be lost.")){
// Cleaning the viewer/editor
document.getElementById("viewer").innerHTML = "";
+ TSCORE.FileOpener.setFileOpened(false);
TSCORE.closeFileViewer();
- isEditMode = false;
+ _isEditMode = false;
}
} else {
// Cleaning the viewer/editor
document.getElementById("viewer").innerHTML = "";
- TSCORE.isFileOpened = false;
+ TSCORE.FileOpener.setFileOpened(false);
TSCORE.closeFileViewer();
- isEditMode = false;
+ _isEditMode = false;
}
});
}
@@ -302,12 +321,11 @@ define(function(require, exports, module) {
});
}
-// Vars
- exports.tsEditor = tsEditor;
- exports.isEditMode = isEditMode;
-
// Methods
- exports.openFile = openFile;
+ exports.openFile = openFile;
+ exports.isFileOpened = isFileOpened;
+ exports.setFileOpened = setFileOpened;
+ exports.getOpenedFilePath = getOpenedFilePath;
exports.updateEditorContent = updateEditorContent;
});
\ No newline at end of file
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.js
index 67f7bdf37..d8d595431 100644
--- a/data/js/ioapi.chrome.js
+++ b/data/js/ioapi.chrome.js
@@ -76,8 +76,8 @@ define(function(require, exports, module) {
plugin.saveBinaryFile(newFilePath,plugin.getBinaryFile(filePath));
plugin.removeFile(filePath);
- if(TSCORE.isFileOpened) {
- TSCORE.openFile(newFilePath);
+ if(TSCORE.FileOpener.isFileOpened) {
+ TSCORE.FileOpener.openFile(newFilePath);
}
TSCORE.ViewManager.refreshFileListContainer();
diff --git a/data/js/ioapi.mozilla.receiver.js b/data/js/ioapi.mozilla.receiver.js
index caab2241f..fcb926648 100644
--- a/data/js/ioapi.mozilla.receiver.js
+++ b/data/js/ioapi.mozilla.receiver.js
@@ -41,10 +41,11 @@ console.debug("Loading messaging.mozilla.js..");
if(message.success){
TSCORE.updateLogger("Rename success");
// message.content contains the name of the file after the rename
- TSCORE.selectedFiles[0] = message.content;
- if(TSCORE.isFileOpened) {
- TSCORE.openFile(TSCORE.selectedFiles[0]);
+ if(TSCORE.FileOpener.isFileOpened) {
+ TSCORE.FileOpener.openFile(message.content);
}
+ // TODO to be replaced with a function which replaced the
+ // renamed file in the model of the perspective
TSCORE.ViewManager.refreshFileListContainer();
} else {
TSCORE.updateLogger("Rename failed");
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 2a495e380..a76240ce0 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -182,7 +182,7 @@ define(function(require, exports, module) {
return exports.Settings["supportedFileTypes"][i].editor;
}
}
- return false;
+ return "false";
}
var getFileTypeViewer = function(fileTypeExt) {
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index 07539fa83..45ff3bd9c 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -112,7 +112,7 @@ define(function(require, exports, module) {
break;
case "openFile":
console.debug("Opening file...");
- TSCORE.openFile(TSCORE.selectedFiles[0]);
+ TSCORE.FileOpener.openFile(TSCORE.selectedFiles[0]);
break;
case "openDirectory":
console.debug("Opening parent directory...");
diff --git a/data/libs/requirejs/domReady.js b/data/libs/requirejs/domReady.js
new file mode 100644
index 000000000..2b5412209
--- /dev/null
+++ b/data/libs/requirejs/domReady.js
@@ -0,0 +1,129 @@
+/**
+ * @license RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/requirejs/domReady for details
+ */
+/*jslint */
+/*global require: false, define: false, requirejs: false,
+ window: false, clearInterval: false, document: false,
+ self: false, setInterval: false */
+
+
+define(function () {
+ 'use strict';
+
+ var isTop, testDiv, scrollIntervalId,
+ isBrowser = typeof window !== "undefined" && window.document,
+ isPageLoaded = !isBrowser,
+ doc = isBrowser ? document : null,
+ readyCalls = [];
+
+ function runCallbacks(callbacks) {
+ var i;
+ for (i = 0; i < callbacks.length; i += 1) {
+ callbacks[i](doc);
+ }
+ }
+
+ function callReady() {
+ var callbacks = readyCalls;
+
+ if (isPageLoaded) {
+ //Call the DOM ready callbacks
+ if (callbacks.length) {
+ readyCalls = [];
+ runCallbacks(callbacks);
+ }
+ }
+ }
+
+ /**
+ * Sets the page as loaded.
+ */
+ function pageLoaded() {
+ if (!isPageLoaded) {
+ isPageLoaded = true;
+ if (scrollIntervalId) {
+ clearInterval(scrollIntervalId);
+ }
+
+ callReady();
+ }
+ }
+
+ if (isBrowser) {
+ if (document.addEventListener) {
+ //Standards. Hooray! Assumption here that if standards based,
+ //it knows about DOMContentLoaded.
+ document.addEventListener("DOMContentLoaded", pageLoaded, false);
+ window.addEventListener("load", pageLoaded, false);
+ } else if (window.attachEvent) {
+ window.attachEvent("onload", pageLoaded);
+
+ testDiv = document.createElement('div');
+ try {
+ isTop = window.frameElement === null;
+ } catch (e) {}
+
+ //DOMContentLoaded approximation that uses a doScroll, as found by
+ //Diego Perini: http://javascript.nwbox.com/IEContentLoaded/,
+ //but modified by other contributors, including jdalton
+ if (testDiv.doScroll && isTop && window.external) {
+ scrollIntervalId = setInterval(function () {
+ try {
+ testDiv.doScroll();
+ pageLoaded();
+ } catch (e) {}
+ }, 30);
+ }
+ }
+
+ //Check if document already complete, and if so, just trigger page load
+ //listeners. Latest webkit browsers also use "interactive", and
+ //will fire the onDOMContentLoaded before "interactive" but not after
+ //entering "interactive" or "complete". More details:
+ //http://dev.w3.org/html5/spec/the-end.html#the-end
+ //http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded
+ //Hmm, this is more complicated on further use, see "firing too early"
+ //bug: https://github.com/requirejs/domReady/issues/1
+ //so removing the || document.readyState === "interactive" test.
+ //There is still a window.onload binding that should get fired if
+ //DOMContentLoaded is missed.
+ if (document.readyState === "complete") {
+ pageLoaded();
+ }
+ }
+
+ /** START OF PUBLIC API **/
+
+ /**
+ * Registers a callback for DOM ready. If DOM is already ready, the
+ * callback is called immediately.
+ * @param {Function} callback
+ */
+ function domReady(callback) {
+ if (isPageLoaded) {
+ callback(doc);
+ } else {
+ readyCalls.push(callback);
+ }
+ return domReady;
+ }
+
+ domReady.version = '2.0.1';
+
+ /**
+ * Loader Plugin API method
+ */
+ domReady.load = function (name, req, onLoad, config) {
+ if (config.isBuild) {
+ onLoad(null);
+ } else {
+ domReady(onLoad);
+ }
+ };
+
+ /** END OF PUBLIC API **/
+
+ return domReady;
+});
diff --git a/data/loader.js b/data/loader.js
index 0301c9cf2..6a6538276 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -166,9 +166,10 @@ define(function (require, exports, module) {
var TSCORE = require("tscore");
- function onReady() {
+ require(['libs/requirejs/domReady!'], function (docu) {
+ //This function is called once the DOM is ready,
+ //the value for 'domReady!' is the current document.
TSCORE.initApp();
- }
-
- $(window.document).ready(onReady);
+ });
+
});
\ No newline at end of file
diff --git a/data/manifest.json b/data/manifest.json
index ef8c3a79f..404ccf552 100644
--- a/data/manifest.json
+++ b/data/manifest.json
@@ -1,6 +1,6 @@
{
"name": "TagSpaces",
- "version": "1.3.1278",
+ "version": "1.3.1280",
"manifest_version": 2,
"description": "TagSpaces Explorer",
"icons": {
diff --git a/package.json b/package.json
index 817197a27..f30bc4f4b 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "tagspaces",
"license": "AGPL 3.0",
"author": "Ugg Rock",
- "version": "1.3.1278",
+ "version": "1.3.1280",
"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 2b014e2c7..edb45087c 100644
--- a/update.rdf
+++ b/update.rdf
@@ -7,13 +7,13 @@
<r:Seq>
<r:li>
<r:Description>
- <version>1.3.1278</version>
+ <version>1.3.1280</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.1278.xpi</updateLink>
+ <updateLink>http://tagspaces.com/releases/1.3/tagspaces.1.3.1280.xpi</updateLink>
<updateInfoURL>http://tagspaces.com/releases/1.3/updateInfo.xml</updateInfoURL>
</r:Description>
</targetApplication>