Permalink
Browse files

Merge branch 'MDL-59407-folder-remember-view-mode' of https://github.…

  • Loading branch information...
dmonllao committed Jul 18, 2017
2 parents f510788 + 0398bbe commit ed539f8233fb743507d4cacb0e8cf5f4c4c9d7ac
Showing with 28 additions and 4 deletions.
  1. +24 −4 lib/form/filemanager.js
  2. +4 −0 lib/form/filemanager.php
@@ -30,6 +30,7 @@
* this.filemanager, contains reference to filemanager Node
* this.selectnode, contains referenct to select-file Node
* this.selectui, M.core.dialogue to select the file
* this.viewmode, contains current view mode - icons, tree or details
*
* FileManager options:
* =====
@@ -70,6 +71,7 @@ M.form_filemanager.init = function(Y, options) {
this.maxfiles = options.maxfiles;
this.maxbytes = options.maxbytes;
this.areamaxbytes = options.areamaxbytes;
this.userprefs = options.userprefs;
this.emptycallback = null; // Used by drag and drop upload
this.filepicker_options = options.filepicker?options.filepicker:{};
@@ -126,9 +128,13 @@ M.form_filemanager.init = function(Y, options) {
// set event handler for lazy loading of thumbnails
this.filemanager.one('.fp-content').on(['scroll','resize'], this.content_scrolled, this);
// display files
this.viewmode = 1; // TODO take from cookies?
this.filemanager.all('.fp-vb-icons,.fp-vb-tree,.fp-vb-details').removeClass('checked')
this.filemanager.all('.fp-vb-icons').addClass('checked')
this.viewmode = this.get_preference("recentviewmode");
if (this.viewmode != 2 && this.viewmode != 3) {
this.viewmode = 1;
}
var viewmodeselectors = {'1': '.fp-vb-icons', '2': '.fp-vb-tree', '3': '.fp-vb-details'};
this.filemanager.all('.fp-vb-icons,.fp-vb-tree,.fp-vb-details').removeClass('checked');
this.filemanager.all(viewmodeselectors[this.viewmode]).addClass('checked');
this.refresh(this.currentpath); // MDL-31113 get latest list from server
},
@@ -414,6 +420,7 @@ M.form_filemanager.init = function(Y, options) {
this.render();
this.filemanager.one('.fp-content').setAttribute('tabIndex', '0');
this.filemanager.one('.fp-content').focus();
this.set_preference('recentviewmode', this.viewmode);
}
}, this);
},
@@ -1051,7 +1058,20 @@ M.form_filemanager.init = function(Y, options) {
}
}
return false;
}
},
get_preference: function(name) {
if (this.userprefs[name]) {
return this.userprefs[name];
} else {
return false;
}
},
set_preference: function(name, value) {
if (this.userprefs[name] != value) {
M.util.set_user_preference('filemanager_' + name, value);
this.userprefs[name] = value;
}
},
});
// finally init everything needed
@@ -405,6 +405,10 @@ public function __construct(stdClass $options) {
}
$this->options->maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursebytes, $maxbytes);
$this->options->userprefs = array();
$this->options->userprefs['recentviewmode'] = get_user_preferences('filemanager_recentviewmode', '');
user_preference_allow_ajax_update('filemanager_recentviewmode', PARAM_INT);
// building file picker options
$params = new stdClass();
$params->accepted_types = $options->accepted_types;

0 comments on commit ed539f8

Please sign in to comment.