Skip to content
Browse files

MDL-31114 Alert when max files reached

  • Loading branch information...
1 parent aad69d8 commit 36dc50336e4385eaa5e214d92e7f4c18dc621d87 @davosmith davosmith committed Feb 14, 2012
Showing with 9 additions and 3 deletions.
  1. +2 −0 lang/en/moodle.php
  2. +6 −2 lib/form/dndupload.js
  3. +1 −1 lib/outputrequirementslib.php
View
2 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';
View
8 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)) {
View
2 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;
}

0 comments on commit 36dc503

Please sign in to comment.
Something went wrong with that request. Please try again.