"MDL-16597, improve maxfile handling, and position creating folder dialog by PageX and PageY"
This commit is contained in:
+25
-11
@@ -29,7 +29,7 @@ function filemanager_callback(obj) {
|
||||
refresh_filemanager(obj.filepath, fm_cfg[obj.client_id]);
|
||||
fm_cfg[obj.client_id].currentfiles++;
|
||||
|
||||
if (fm_cfg[obj.client_id].currentfiles>=fm_cfg[obj.client_id].maxfiles) {
|
||||
if (fm_cfg[obj.client_id].currentfiles>=fm_cfg[obj.client_id].maxfiles && fm_cfg[client_id].maxfiles!=-1) {
|
||||
var btn = document.getElementById('btnadd-'+obj.client_id);
|
||||
btn.style.display = 'none';
|
||||
}
|
||||
@@ -55,7 +55,7 @@ function fm_launch_filepicker(el_id, options) {
|
||||
}
|
||||
|
||||
// create a new folder in draft area
|
||||
function mkdir(client_id, itemid) {
|
||||
function mkdir(e, client_id, itemid) {
|
||||
var mkdir_cb = {
|
||||
success: function(o) {
|
||||
var result = json_decode(o.responseText);
|
||||
@@ -82,10 +82,13 @@ function mkdir(client_id, itemid) {
|
||||
el.id = 'fm-mkdir-dlg';
|
||||
el.innerHTML = '<div class="hd">'+mstr.repository.entername+'</div><div class="bd"><input type="text" id="fm-newname" /></div>';
|
||||
document.body.appendChild(el);
|
||||
var x = YAHOO.util.Event.getPageX(e);
|
||||
var y = YAHOO.util.Event.getPageY(e);
|
||||
fm_mkdir_dlg = new YAHOO.widget.Dialog("fm-mkdir-dlg", {
|
||||
width: "300px",
|
||||
fixedcenter: true,
|
||||
visible: true,
|
||||
x:y,
|
||||
y:y,
|
||||
constraintoviewport : true
|
||||
});
|
||||
|
||||
@@ -112,6 +115,13 @@ function html_compiler(client_id, options) {
|
||||
breadcrumb.innerHTML = '';
|
||||
var count = 0;
|
||||
for(var p in options.path) {
|
||||
var sep = document.createElement('SPAN');
|
||||
sep.innerHTML = ' ▶ ';
|
||||
if (count==0) {
|
||||
sep.innerHTML = 'Path: ';
|
||||
} else {
|
||||
sep.innerHTML = ' ▶ ';
|
||||
}
|
||||
count++;
|
||||
var pathid = 'fm-path-node-'+client_id;
|
||||
pathid += ('-'+count);
|
||||
@@ -120,8 +130,6 @@ function html_compiler(client_id, options) {
|
||||
el.id = pathid;
|
||||
el.innerHTML = options.path[p].name;
|
||||
el.href = '###';
|
||||
var sep = document.createElement('SPAN');
|
||||
sep.innerHTML = ' ▶ ';
|
||||
breadcrumb.appendChild(sep);
|
||||
breadcrumb.appendChild(el);
|
||||
|
||||
@@ -650,14 +658,20 @@ function setup_buttons(client_id, options) {
|
||||
|
||||
fm_move_dlg.render();
|
||||
|
||||
fileadd.onclick = function(e) {
|
||||
this.options.savepath = this.options.currentpath;
|
||||
fm_launch_filepicker(this.options.target, this.options);
|
||||
// if maxfiles == -1, the no limit
|
||||
if (fm_cfg[client_id].filecount >= fm_cfg[client_id].maxfiles && fm_cfg[client_id].maxfiles!=-1) {
|
||||
fileadd.style.display = 'none';
|
||||
} else {
|
||||
fm_cfg[client_id].currentfiles = fm_cfg[client_id].filecount;
|
||||
fileadd.onclick = function(e) {
|
||||
this.options.savepath = this.options.currentpath;
|
||||
fm_launch_filepicker(this.options.target, this.options);
|
||||
}
|
||||
fileadd.options = fm_cfg[client_id];
|
||||
}
|
||||
fileadd.options = fm_cfg[client_id];
|
||||
if (fm_cfg[client_id].subdirs) {
|
||||
foldercreate.onclick = function() {
|
||||
mkdir(this.options.client_id, this.options.itemid);
|
||||
foldercreate.onclick = function(e) {
|
||||
mkdir(e, this.options.client_id, this.options.itemid);
|
||||
}
|
||||
foldercreate.options = fm_cfg[client_id];
|
||||
} else {
|
||||
|
||||
@@ -178,6 +178,9 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
$draftitemid = $this->getValue();
|
||||
}
|
||||
|
||||
$draftareainfo = file_get_draft_area_info($draftitemid);
|
||||
$filecount = $draftareainfo['filecount'];
|
||||
|
||||
if ($COURSE->id == SITEID) {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
} else {
|
||||
@@ -195,6 +198,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
$options->maxbytes = $this->getMaxbytes();
|
||||
$options->maxfiles = $this->getMaxfiles();
|
||||
$options->client_id = $client_id;
|
||||
$options->filecount = $filecount;
|
||||
$options->itemid = $draftitemid;
|
||||
$options->subdirs = $this->_options['subdirs'];
|
||||
$options->target = $id;
|
||||
|
||||
Reference in New Issue
Block a user