MDL-31114 Alert when max files reached

This commit is contained in:
Davo Smith 2012-02-14 09:49:49 +00:00
parent aad69d8b1a
commit 36dc50336e
3 changed files with 9 additions and 3 deletions

View File

@ -464,6 +464,7 @@ $string['downloadfile'] = 'Download file';
$string['downloadods'] = 'Download in ODS format';
$string['downloadtext'] = 'Download in text format';
$string['doyouagree'] = 'Have you read these conditions and understood them?';
$string['droptoupload'] = 'Drop files here to upload';
$string['duplicate'] = 'Duplicate';
$string['duplicateconfirm'] = 'Are you sure you want to duplicate {$a->modtype} \'{$a->modname}\' ?';
$string['duplicatecontcourse'] = 'Return to the course';
@ -969,6 +970,7 @@ $string['manageroles'] = 'Roles and permissions';
$string['markedthistopic'] = 'This topic is highlighted as the current topic';
$string['markthistopic'] = 'Highlight this topic as the current topic';
$string['matchingsearchandrole'] = 'Matching \'{$a->search}\' and {$a->role}';
$string['maxfilesreached'] = 'You are allowed to attach a maximum of {$a} file(s) to this item';
$string['maximumgrade'] = 'Maximum grade';
$string['maximumgradex'] = 'Maximum grade: {$a}';
$string['maximumchars'] = 'Maximum of {$a} characters';

View File

@ -161,7 +161,7 @@ M.form_dndupload.init = function(Y, options) {
* @param e event object
* @return boolean true if a valid file drag event
*/
check_drag: function(e) {
check_drag: function(e, maxfilesalert) {
if (!this.has_files(e)) {
return false;
}
@ -170,6 +170,9 @@ M.form_dndupload.init = function(Y, options) {
e.stopPropagation();
if (this.reached_maxfiles()) {
if (typeof(maxfilesalert) != 'undefined' && maxfilesalert) {
alert(M.util.get_string('maxfilesreached', 'moodle', this.maxfiles));
}
return false;
}
@ -231,7 +234,7 @@ M.form_dndupload.init = function(Y, options) {
* of the files (until we reach the file limit, or run out of files)
*/
drop: function(e) {
if (!this.check_drag(e)) {
if (!this.check_drag(e, true)) {
return true;
}
@ -244,6 +247,7 @@ M.form_dndupload.init = function(Y, options) {
var currentfilecount = this.filemanager.filecount;
for (var i=0, f; f=files[i]; i++) {
if (currentfilecount >= this.maxfiles && this.maxfiles != -1) {
alert(M.util.get_string('maxfilesreached', 'moodle', this.maxfiles));
break;
}
if (this.upload_file(f)) {

View File

@ -468,7 +468,7 @@ class page_requirements_manager {
$module = array('name' => 'core_dndupload',
'fullpath' => '/lib/form/dndupload.js',
'requires' => array('node', 'event', 'json'),
'strings' => array(array('uploadformlimit', 'moodle')));
'strings' => array(array('uploadformlimit', 'moodle'), array('droptoupload', 'moodle'), array('maxfilesreached', 'moodle')));
break;
}