From 0736bfb43a0ecc81ba1eb38c4b32fea8ed454957 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 4 Oct 2013 17:49:42 +0200 Subject: Do not call changeDirectory() when no dir set on breadcrumb Some apps like the files_trashbin app do not set a directory on its "home" breadcrumb link. This fix makes sure that the click event doesn't do anything in that case and lets the browser open the link. This fixes the "home" icon in the trashbin app which now correctly reopens the files app. --- apps/files/js/files.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 899bc6469e5..09f5d6f114c 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -701,7 +701,10 @@ function checkTrashStatus() { } function onClickBreadcrumb(e){ - var $el = $(e.target).closest('.crumb'); - e.preventDefault(); - FileList.changeDirectory(decodeURIComponent($el.data('dir'))); + var $el = $(e.target).closest('.crumb'), + $targetDir = $el.data('dir'); + if ($targetDir !== undefined){ + e.preventDefault(); + FileList.changeDirectory(decodeURIComponent($targetDir)); + } } -- cgit v1.2.3 From fab4102c51e92c5e33725c69ec984b8912a9aee1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 14 Oct 2013 17:47:38 +0200 Subject: Disabled ajax mode for public files view Ajax loading is not supported yet for public files view. This fix disabled the history API, ajax loading and ajax directory switch in public mode until it is implemented properly. --- apps/files/js/filelist.js | 44 ++++++++++++++++++++++++-------------------- apps/files/js/files.js | 4 +++- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a9297996778..ccc4b1401ad 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -677,6 +677,7 @@ var FileList={ }; $(document).ready(function(){ + var isPublic = !!$('#isPublic').val(); // handle upload events var file_upload_start = $('#file_upload_start'); @@ -924,29 +925,32 @@ $(document).ready(function(){ return (params && params.dir) || '/'; } - // fallback to hashchange when no history support - if (!window.history.pushState){ - $(window).on('hashchange', function(){ - FileList.changeDirectory(parseCurrentDirFromUrl(), false); - }); - } - window.onpopstate = function(e){ - var targetDir; - if (e.state && e.state.dir){ - targetDir = e.state.dir; - } - else{ - // read from URL - targetDir = parseCurrentDirFromUrl(); + // disable ajax/history API for public app (TODO: until it gets ported) + if (!isPublic){ + // fallback to hashchange when no history support + if (!window.history.pushState){ + $(window).on('hashchange', function(){ + FileList.changeDirectory(parseCurrentDirFromUrl(), false); + }); } - if (targetDir){ - FileList.changeDirectory(targetDir, false); + window.onpopstate = function(e){ + var targetDir; + if (e.state && e.state.dir){ + targetDir = e.state.dir; + } + else{ + // read from URL + targetDir = parseCurrentDirFromUrl(); + } + if (targetDir){ + FileList.changeDirectory(targetDir, false); + } } - } - if (parseInt($('#ajaxLoad').val(), 10) === 1){ - // need to initially switch the dir to the one from the hash (IE8) - FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); + if (parseInt($('#ajaxLoad').val(), 10) === 1){ + // need to initially switch the dir to the one from the hash (IE8) + FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); + } } FileList.createFileSummary(); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 9e7a2364b18..a35ed4add8c 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -705,7 +705,9 @@ function checkTrashStatus() { function onClickBreadcrumb(e){ var $el = $(e.target).closest('.crumb'), $targetDir = $el.data('dir'); - if ($targetDir !== undefined){ + isPublic = !!$('#isPublic').val(); + + if ($targetDir !== undefined && !isPublic){ e.preventDefault(); FileList.changeDirectory(decodeURIComponent($targetDir)); } -- cgit v1.2.3