diff --git a/js/documents.js b/js/documents.js
index cb524131..0ad57a26 100644
--- a/js/documents.js
+++ b/js/documents.js
@@ -185,6 +185,7 @@ var documentsMain = {
loadErrorMessage : '',
loadErrorHint : '',
toolbar : '
',
+ returnToDir : null, // directory where we started from in the 'Files' app
UI : {
/* Editor wrapper HTML */
@@ -340,7 +341,12 @@ var documentsMain = {
} else {
// Does anything indicate that we need to autostart a session?
- fileId = parent.location.hash.replace(/\W*/g, '');
+ fileId = parent.location.hash.replace(/^\W*/, '');
+
+ if (fileId.indexOf('_') >= 0) {
+ documentsMain.returnToDir = unescape(fileId.replace(/^[^_]*_/, ''));
+ fileId = fileId.replace(/_.*/, '');
+ }
}
documentsMain.show();
@@ -637,7 +643,12 @@ var documentsMain = {
documentsMain.UI.hideEditor();
documentsMain.closeDocument();
$('#ocToolbar').remove();
- documentsMain.show();
+
+ if (documentsMain.returnToDir) {
+ window.location = OC.generateUrl('apps/files?dir={dir}', {dir: documentsMain.returnToDir});
+ } else {
+ documentsMain.show();
+ }
},
onTerminate: function(){
diff --git a/js/viewer/viewer.js b/js/viewer/viewer.js
index c33bc919..0c782d64 100644
--- a/js/viewer/viewer.js
+++ b/js/viewer/viewer.js
@@ -78,7 +78,13 @@ var odfViewer = {
onEdit : function(fileName, context){
var fileId = context.$file.attr('data-id');
- window.location = OC.generateUrl('apps/richdocuments/index#{file_id}', {file_id: fileId});
+ var fileDir = context.dir;
+
+ if (fileDir) {
+ window.location = OC.generateUrl('apps/richdocuments/index#{file_id}_{dir}', {file_id: fileId, dir: fileDir});
+ } else {
+ window.location = OC.generateUrl('apps/richdocuments/index#{file_id}', {file_id: fileId});
+ }
},
onView: function(filename, context) {