Skip to content

Commit

Permalink
MDL-31114 Alert when max files reached
Browse files Browse the repository at this point in the history
  • Loading branch information
davosmith committed Feb 14, 2012
1 parent aad69d8 commit 36dc503
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lang/en/moodle.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
8 changes: 6 additions & 2 deletions lib/form/dndupload.js
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/outputrequirementslib.php
Expand Up @@ -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;
}

Expand Down

0 comments on commit 36dc503

Please sign in to comment.