Skip to content

Commit

Permalink
Merge branch 'MDL-35664-master' of git://github.com/FMCorz/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Oct 16, 2012
2 parents 0651778 + 7dab27b commit a7aa82b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions repository/filepicker.js
Expand Up @@ -16,6 +16,7 @@
* this.viewmode, store current view mode
* this.pathbar, reference to the Node with path bar
* this.pathnode, a Node element representing one folder in a path bar (not attached anywhere, just used for template)
* this.currentpath, the current path in the repository (or last requested path)
*
* Filepicker options:
* =====
Expand All @@ -39,7 +40,7 @@
* this.filelist, cached filelist
* this.pages
* this.page
* this.filepath, current path
* this.filepath, current path (each element of the array is a part of the breadcrumb)
* this.logindata, cached login form
*/

Expand Down Expand Up @@ -932,6 +933,7 @@ M.core_filepicker.init = function(Y, options) {
// save current path and filelist (in case we want to jump to other viewmode)
this.filepath = e.node.origpath;
this.filelist = e.node.origlist;
this.currentpath = e.node.path;
this.print_path();
this.content_scrolled();
}
Expand Down Expand Up @@ -967,7 +969,6 @@ M.core_filepicker.init = function(Y, options) {
if (this.active_repo.dynload) {
this.list({'path':node.path});
} else {
this.filepath = node.path;
this.filelist = node.children;
this.view_files();
}
Expand Down Expand Up @@ -1002,7 +1003,6 @@ M.core_filepicker.init = function(Y, options) {
if (this.active_repo.dynload) {
this.list({'path':node.path});
} else {
this.filepath = node.path;
this.filelist = node.children;
this.view_files();
}
Expand All @@ -1022,20 +1022,34 @@ M.core_filepicker.init = function(Y, options) {
}
this.active_repo.nextpagerequested = true;
var nextpage = this.active_repo.page+1;
var args = {page:nextpage, repo_id:this.active_repo.id, path:this.active_repo.path};
var args = {
page: nextpage,
repo_id: this.active_repo.id,
};
var action = this.active_repo.issearchresult ? 'search' : 'list';
this.request({
path: this.currentpath,
scope: this,
action: action,
client_id: this.options.client_id,
repository_id: args.repo_id,
params: args,
callback: function(id, obj, args) {
var scope = args.scope;
// check that we are still in the same repository and are expecting this page
// Check that we are still in the same repository and are expecting this page. We have no way
// to compare the requested page and the one returned, so we assume that if the last chunk
// of the breadcrumb is similar, then we probably are on the same page.
var samepage = true;
if (obj.path && scope.filepath) {
var pathbefore = scope.filepath[scope.filepath.length-1];
var pathafter = obj.path[obj.path.length-1];
if (pathbefore.path != pathafter.path) {
samepage = false;
}
}
if (scope.active_repo.hasmorepages && obj.list && obj.page &&
obj.repo_id == scope.active_repo.id &&
obj.page == scope.active_repo.page+1 && obj.path == scope.path) {
obj.page == scope.active_repo.page+1 && samepage) {
scope.parse_repository_options(obj, true);
scope.view_files(obj.list)
}
Expand Down Expand Up @@ -1564,6 +1578,10 @@ M.core_filepicker.init = function(Y, options) {
if (!args.repo_id) {
args.repo_id = this.active_repo.id;
}
if (!args.path) {
args.path = '';
}
this.currentpath = args.path;
this.request({
action: 'list',
client_id: this.options.client_id,
Expand Down Expand Up @@ -1707,7 +1725,7 @@ M.core_filepicker.init = function(Y, options) {
toolbar.one('.fp-tb-refresh').one('a,button').on('click', function(e) {
e.preventDefault();
if (!this.active_repo.norefresh) {
this.list();
this.list({ path: this.currentpath });
}
}, this);
toolbar.one('.fp-tb-search form').
Expand Down

0 comments on commit a7aa82b

Please sign in to comment.