From 296af14b195f625c71068e6c1305ed58722eceaf Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 14 Aug 2015 14:47:08 +0800 Subject: [PATCH] MDL-51117 JavaScript: Convert alert to M.core.alert in dndupload This also updates a language string to use string params instead of hard-prefixing. --- course/dndupload.js | 10 +++++----- course/dnduploadlib.php | 2 +- lang/en/deprecated.txt | 1 + lang/en/moodle.php | 5 ++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/course/dndupload.js b/course/dndupload.js index 1a1d4343a26..eb759d84738 100644 --- a/course/dndupload.js +++ b/course/dndupload.js @@ -743,7 +743,7 @@ M.course_dndupload = { var self = this; if (file.size > this.maxbytes) { - alert("'"+file.name+"' "+M.util.get_string('filetoolarge', 'moodle')); + new M.core.alert({message: M.util.get_string('namedfiletoolarge', 'moodle', {filename: file.name})}); return; } @@ -777,11 +777,11 @@ M.course_dndupload = { } else { // Error - remove the dummy element resel.parent.removeChild(resel.li); - alert(result.error); + new M.core.alert({message: result.error}); } } } else { - alert(M.util.get_string('servererror', 'moodle')); + new M.core.alert({message: M.util.get_string('servererror', 'moodle')}); } } }; @@ -1002,11 +1002,11 @@ M.course_dndupload = { } else { // Error - remove the dummy element resel.parent.removeChild(resel.li); - alert(result.error); + new M.core.alert({message: result.error}); } } } else { - alert(M.util.get_string('servererror', 'moodle')); + new M.core.alert({message: M.util.get_string('servererror', 'moodle')}); } } }; diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index e4917188680..843ea9a9fe0 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -61,7 +61,7 @@ function dndupload_add_to_course($course, $modnames) { array('dndworkingtextlink', 'moodle'), array('dndworkingtext', 'moodle'), array('dndworkinglink', 'moodle'), - array('filetoolarge', 'moodle'), + array('namedfiletoolarge', 'moodle'), array('actionchoice', 'moodle'), array('servererror', 'moodle'), array('upload', 'moodle'), diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 4cb19ced201..ada31e611e0 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -27,3 +27,4 @@ othertags,core_tag tagtype,core_tag manageofficialtags,core_tag settypeofficial,core_tag +filetoolarge,core diff --git a/lang/en/moodle.php b/lang/en/moodle.php index b126d794963..5eac5967afe 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -775,7 +775,6 @@ $string['feedback'] = 'Feedback'; $string['file'] = 'File'; $string['fileexists'] = 'There is already a file called {$a}'; $string['filemissing'] = '{$a} is missing'; -$string['filetoolarge'] = 'is too large to upload'; $string['files'] = 'Files'; $string['filesanduploads'] = 'Files and uploads'; $string['filesfolders'] = 'Files/folders'; @@ -1226,6 +1225,7 @@ $string['myhome'] = 'Dashboard'; $string['mymoodledashboard'] = 'My Moodle dashboard'; $string['myprofile'] = 'My profile'; $string['name'] = 'Name'; +$string['namedfiletoolarge'] = 'The file \'{$a->filename}\' is too large and cannot be uploaded'; $string['nameforlink'] = 'What do you want to call this link?'; $string['nameforpage'] = 'Name'; $string['navigation'] = 'Navigation'; @@ -2052,3 +2052,6 @@ $string['yourself'] = 'yourself'; $string['yourteacher'] = 'your {$a}'; $string['yourwordforx'] = 'Your word for \'{$a}\''; $string['zippingbackup'] = 'Zipping backup'; + +// Deprecated since Moodle 3.1. +$string['filetoolarge'] = 'is too large to upload';