diff --git a/apps/files/js/app.js b/apps/files/js/app.js index f7863de09bea3..6961d05084b17 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -14,14 +14,6 @@ /* global dragOptions, folderDropOptions, OC */ (function() { - if (!OCA.Files) { - /** - * Namespace for the files app - * @namespace OCA.Files - */ - OCA.Files = {}; - } - /** * @namespace OCA.Files.App */ @@ -136,7 +128,10 @@ // refer to the one of the "files" view window.FileList = this.fileList; - OC.Plugins.attach('OCA.Files.App', this); + let selfApp = this + window.addEventListener('DOMContentLoaded', function() { + OC.Plugins.attach('OCA.Files.App', selfApp) + }) this._setupEvents(); // trigger URL change event handlers @@ -398,10 +393,4 @@ }; })(); -window.addEventListener('DOMContentLoaded', function() { - // wait for other apps/extensions to register their event handlers and file actions - // in the "ready" clause - _.defer(function() { - OCA.Files.App.initialize(); - }); -}); +OCA.Files.App.initialize(); diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js index 8a5d42bd975fa..741dd423f1509 100644 --- a/apps/files/js/breadcrumb.js +++ b/apps/files/js/breadcrumb.js @@ -20,6 +20,13 @@ */ (function() { + if (!OCA.Files) { + /** + * Namespace for the files app + * @namespace OCA.Files + */ + OCA.Files = {}; + } /** * @class BreadCrumb * @memberof OCA.Files diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index facbbf09e0e76..71b8b5d930bec 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -9,7 +9,6 @@ */ (function() { - /** * @class OCA.Files.FileList * @classdesc @@ -28,9 +27,24 @@ * @param {boolean} [options.enableUpload=false] whether to enable uploader * @param {OC.Files.Client} [options.filesClient] files client to use */ - var FileList = function($el, options) { + function FileList($el, options) { this.initialize($el, options); - }; + let filelist = this + + window.addEventListener('DOMContentLoaded', function() { + // FIXME: unused ? + this.useUndo = (window.onbeforeunload)?true:false; + $(window).on('beforeunload', function () { + if (this.lastAction) { + this.lastAction(); + } + }); + if (this._updateDetailsViewTmpFileName && this._updateDetailsViewTmpShow) { + filelist.updateDetailsView(this._updateDetailsViewTmpFileName, this._updateDetailsViewTmpShow) + } + }); + } + /** * @memberof OCA.Files */ @@ -460,11 +474,14 @@ } this.triedActionOnce = false; - OC.Plugins.attach('OCA.Files.FileList', this); + window.addEventListener('DOMContentLoaded', function() { + console.debug('Attaching OCA.Files.FileList', self) + OC.Plugins.attach('OCA.Files.FileList', self); + self.initHeadersAndFooters() + OCA.Files.App && OCA.Files.App.updateCurrentFileList(self); + }) OCA.Files.App && OCA.Files.App.updateCurrentFileList(this); - - this.initHeadersAndFooters() }, initHeadersAndFooters: function() { @@ -667,6 +684,13 @@ } }, + _updateDetailsViewTmpFileName: null, + _updateDetailsViewTmpShow: null, + + updateDetailsView: function(fileName, show) { + this._updateDetailsView(fileName, show) + }, + /** * Update the details view to display the given file * @@ -675,7 +699,8 @@ */ _updateDetailsView: function(fileName, show) { if (!(OCA.Files && OCA.Files.Sidebar)) { - console.error('No sidebar available'); + this._updateDetailsViewTmpFileName = fileName + this._updateDetailsViewTmpShow = show return; } @@ -4009,16 +4034,7 @@ */ OCA.Files.FileInfo = OC.Files.FileInfo; + FileList.prototype.constructor = FileList + OCA.Files.FileList = FileList; })(); - -window.addEventListener('DOMContentLoaded', function() { - // FIXME: unused ? - OCA.Files.FileList.useUndo = (window.onbeforeunload)?true:false; - $(window).on('beforeunload', function () { - if (OCA.Files.FileList.lastAction) { - OCA.Files.FileList.lastAction(); - } - }); - -}); diff --git a/apps/files/js/merged-index.json b/apps/files/js/merged-index.json index 478db35f6fb4c..3ce39c7aa09cf 100644 --- a/apps/files/js/merged-index.json +++ b/apps/files/js/merged-index.json @@ -1,5 +1,4 @@ [ - "app.js", "breadcrumb.js", "detailfileinfoview.js", "detailsview.js", @@ -28,5 +27,6 @@ "sidebarpreviewmanager.js", "sidebarpreviewtext.js", "tagsplugin.js", - "templates.js" + "templates.js", + "app.js" ] diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js index faebc305c6db9..bb7852e5803b5 100644 --- a/apps/files/js/newfilemenu.js +++ b/apps/files/js/newfilemenu.js @@ -56,7 +56,10 @@ } }]; - OC.Plugins.attach('OCA.Files.NewFileMenu', this); + let selfNewFileMenu = this + window.addEventListener('DOMContentLoaded', function() { + OC.Plugins.attach('OCA.Files.NewFileMenu', selfNewFileMenu); + }) }, template: function(data) { diff --git a/apps/files/js/sidebarpreviewmanager.js b/apps/files/js/sidebarpreviewmanager.js index cb5a7ee9960f8..4ee3ab3af6bfc 100644 --- a/apps/files/js/sidebarpreviewmanager.js +++ b/apps/files/js/sidebarpreviewmanager.js @@ -12,7 +12,10 @@ var SidebarPreviewManager = function (fileList) { this._fileList = fileList; this._previewHandlers = {}; - OC.Plugins.attach('OCA.Files.SidebarPreviewManager', this); + let selfSidebarPreview = this + window.addEventListener('DOMContentLoaded', function() { + OC.Plugins.attach('OCA.Files.SidebarPreviewManager', selfSidebarPreview); + }) }; SidebarPreviewManager.prototype = {