Merge branch 'wip-MDL-31838-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Aparup Banerjee
2012-03-13 16:10:19 +08:00
2 changed files with 16 additions and 3 deletions
+15 -3
View File
@@ -72,6 +72,7 @@ M.core_filepicker.init = function(Y, options) {
Y.extend(FilePickerHelper, Y.Base, {
api: M.cfg.wwwroot+'/repository/repository_ajax.php',
cached_responses: {},
initializer: function(options) {
this.options = options;
@@ -163,6 +164,11 @@ M.core_filepicker.init = function(Y, options) {
if (data.msg) {
scope.print_msg(data.msg, 'info');
}
// cache result if applicable
if (args.action != 'upload' && data.allowcaching) {
scope.cached_responses[params] = data;
}
// invoke callback
args.callback(id,data,p);
}
}
@@ -179,9 +185,15 @@ M.core_filepicker.init = function(Y, options) {
if (args.form) {
cfg.form = args.form;
}
Y.io(api, cfg);
if (redraw) {
this.wait('load');
// check if result of the same request has been already cached. If not, request it
// (never applicable in case of form submission and/or upload action):
if (!args.form && args.action != 'upload' && scope.cached_responses[params]) {
args.callback(null, scope.cached_responses[params], {scope: scope})
} else {
Y.io(api, cfg);
if (redraw) {
this.wait('load');
}
}
},
process_existing_file: function(data) {
+1
View File
@@ -223,6 +223,7 @@ class repository_upload extends repository {
$ret['list'] = array();
$ret['dynload'] = false;
$ret['upload'] = array('label'=>get_string('attachment', 'repository'), 'id'=>'repo-form');
$ret['allowcaching'] = true; // indicates that result of get_listing() can be cached in filepicker.js
return $ret;
}