diff --git a/lang/en/moodle.php b/lang/en/moodle.php index eb14f766fb330..f9371e34bb895 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -464,6 +464,7 @@ $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['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'; diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index e29e3788a8cfe..40018a3cbda54 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -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)) { diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 56fbe201187a9..2737fe5063b32 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -468,7 +468,7 @@ protected function find_module($component) { $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; }