mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-59407-folder-remember-view-mode' of https://github.com/vvzh/moodle
This commit is contained in:
commit
ed539f8233
@ -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 @@ class form_filemanager implements renderable {
|
||||
}
|
||||
$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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user