summaryrefslogtreecommitdiffstats
path: root/apps/files_external/js/app.js
diff options
context:
space:
mode:
authorJesús Macias <jmacias@solidgear.es>2015-11-24 08:16:14 +0100
committerJesús Macias <jmacias@solidgear.es>2015-11-24 08:16:14 +0100
commit5580b562a36c682c4baea89c7026af5596f714bc (patch)
tree459444019b8a2ba72aed611948c8f6695dbf463a /apps/files_external/js/app.js
parent31cfd43e8ad95bec0086409597c35294b7d19df6 (diff)
downloadnextcloud-server-5580b562a36c682c4baea89c7026af5596f714bc.tar.gz
nextcloud-server-5580b562a36c682c4baea89c7026af5596f714bc.zip
Fix code from PR comments
Diffstat (limited to 'apps/files_external/js/app.js')
-rw-r--r--apps/files_external/js/app.js165
1 files changed, 83 insertions, 82 deletions
diff --git a/apps/files_external/js/app.js b/apps/files_external/js/app.js
index 411d5fc3433..87507f93be3 100644
--- a/apps/files_external/js/app.js
+++ b/apps/files_external/js/app.js
@@ -9,105 +9,106 @@
*/
if (!OCA.External) {
- /**
- * @namespace
- */
- OCA.External = {};
+ /**
+ * @namespace
+ */
+ OCA.External = {};
}
/**
* @namespace
*/
OCA.External.App = {
- fileList: null,
+ fileList: null,
- initList: function($el) {
- if (this.fileList) {
- return this.fileList;
- }
+ initList: function($el) {
+ if (this.fileList) {
+ return this.fileList;
+ }
- this.fileList = new OCA.External.FileList(
- $el,
- {
- scrollContainer: $('#app-content'),
- fileActions: this._createFileActions()
- }
- );
+ this.fileList = new OCA.External.FileList(
+ $el,
+ {
+ scrollContainer: $('#app-content'),
+ fileActions: this._createFileActions()
+ }
+ );
- this._extendFileList(this.fileList);
- this.fileList.appName = t('files_external', 'External storage');
- return this.fileList;
- },
+ this._extendFileList(this.fileList);
+ this.fileList.appName = t('files_external', 'External storage');
+ return this.fileList;
+ },
- removeList: function() {
- if (this.fileList) {
- this.fileList.$fileList.empty();
- }
- },
+ removeList: function() {
+ if (this.fileList) {
+ this.fileList.$fileList.empty();
+ }
+ },
- _createFileActions: function() {
- // inherit file actions from the files app
- var fileActions = new OCA.Files.FileActions();
- fileActions.registerDefaultActions();
+ _createFileActions: function() {
+ // inherit file actions from the files app
+ var fileActions = new OCA.Files.FileActions();
+ fileActions.registerDefaultActions();
- // when the user clicks on a folder, redirect to the corresponding
- // folder in the files app instead of opening it directly
- fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
- OCA.Files.App.setActiveView('files', {silent: true});
- OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true);
- });
- fileActions.setDefault('dir', 'Open');
- return fileActions;
- },
+ // when the user clicks on a folder, redirect to the corresponding
+ // folder in the files app instead of opening it directly
+ fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
+ OCA.Files.App.setActiveView('files', {silent: true});
+ OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true);
+ });
+ fileActions.setDefault('dir', 'Open');
+ return fileActions;
+ },
- _extendFileList: function(fileList) {
- // remove size column from summary
- fileList.fileSummary.$el.find('.filesize').remove();
- }
+ _extendFileList: function(fileList) {
+ // remove size column from summary
+ fileList.fileSummary.$el.find('.filesize').remove();
+ }
};
$(document).ready(function() {
- $('#app-content-extstoragemounts').on('show', function(e) {
- OCA.External.App.initList($(e.target));
- });
- $('#app-content-extstoragemounts').on('hide', function() {
- OCA.External.App.removeList();
- });
+ $('#app-content-extstoragemounts').on('show', function(e) {
+ OCA.External.App.initList($(e.target));
+ });
+ $('#app-content-extstoragemounts').on('hide', function() {
+ OCA.External.App.removeList();
+ });
- /* Status Manager */
- if ($('#filesApp').val()) {
+ /* Status Manager */
+ if ($('#filesApp').val()) {
- $('#app-content-files')
- .add('#app-content-extstoragemounts')
- .on('changeDirectory', function(e){
- if (e.dir === '/') {
- var mount_point = e.previousDir.split('/', 2)[1];
- // make sure we have a mount point list
- OCA.External.StatusManager.getMountPointList(function() {
- OCA.External.StatusManager.recheckConnectivityForMount([mount_point], true, true);
- });
- }
- })
- .on('fileActionsReady', function(e){
- if ($.isArray(e.$files)) {
- if (OCA.External.StatusManager.mountStatus === null ||
- OCA.External.StatusManager.mountPointList === null ||
- _.size(OCA.External.StatusManager.mountStatus) !== _.size(OCA.External.StatusManager.mountPointList)) {
- // we don't have the data cached, so we'll get it one by one
- OCA.External.StatusManager.launchFullConnectivityCheckOneByOne();
- } else {
- // make sure we have a mount point list
- OCA.External.StatusManager.getMountPointList(function(){
- var fileNames = [];
- $.each(e.$files, function(key, value){
- fileNames.push(value.attr('data-file'));
- });
- OCA.External.StatusManager.recheckConnectivityForMount(fileNames, false, false);
- });
- }
- }
- });
- }
- /* End Status Manager */
+ $('#app-content-files')
+ .add('#app-content-extstoragemounts')
+ .on('changeDirectory', function(e){
+ if (e.dir === '/') {
+ var mount_point = e.previousDir.split('/', 2)[1];
+ // Every time that we return to / root folder from a mountpoint, mount_point status is rechecked
+ OCA.External.StatusManager.getMountPointList(function() {
+ OCA.External.StatusManager.recheckConnectivityForMount([mount_point], true);
+ });
+ }
+ })
+ .on('fileActionsReady', function(e){
+ if ($.isArray(e.$files)) {
+ if (OCA.External.StatusManager.mountStatus === null ||
+ OCA.External.StatusManager.mountPointList === null ||
+ _.size(OCA.External.StatusManager.mountStatus) !== _.size(OCA.External.StatusManager.mountPointList)) {
+ // Will be the very first check when the files view will be loaded
+ OCA.External.StatusManager.launchFullConnectivityCheckOneByOne();
+ } else {
+ // When we change between general files view and external files view
+ OCA.External.StatusManager.getMountPointList(function(){
+ var fileNames = [];
+ $.each(e.$files, function(key, value){
+ fileNames.push(value.attr('data-file'));
+ });
+ // Recheck if launched but work from cache
+ OCA.External.StatusManager.recheckConnectivityForMount(fileNames, false);
+ });
+ }
+ }
+ });
+ }
+ /* End Status Manager */
});