MDL-51117 JavaScript: Convert alert to M.core.alert in dndupload
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 14 Aug 2015 06:47:08 +0000 (14:47 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 11 Feb 2016 00:43:27 +0000 (08:43 +0800)
This also updates a language string to use string params instead of
hard-prefixing.

course/dndupload.js
course/dnduploadlib.php
lang/en/deprecated.txt
lang/en/moodle.php

index 1a1d434..eb759d8 100644 (file)
@@ -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')});
                 }
             }
         };
index e491718..843ea9a 100644 (file)
@@ -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'),
index 4cb19ce..ada31e6 100644 (file)
@@ -27,3 +27,4 @@ othertags,core_tag
 tagtype,core_tag
 manageofficialtags,core_tag
 settypeofficial,core_tag
+filetoolarge,core
index b126d79..5eac596 100644 (file)
@@ -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';