]> git.mjollnir.org Git - moodle.git/commitdiff
user MDL-16706 Elimate inline scripts, replaced with PAGE methods, created user.js
authorsamhemelryk <samhemelryk>
Thu, 2 Jul 2009 04:02:40 +0000 (04:02 +0000)
committersamhemelryk <samhemelryk>
Thu, 2 Jul 2009 04:02:40 +0000 (04:02 +0000)
user/index.php
user/user.js [new file with mode: 0644]

index 051ceb0ed77920f20d14bcae7afd8d242dee75e2..8f3a58954938c2d3ce820ba4cb8dca64a0103026 100644 (file)
 
 
     if ($bulkoperations) {
-        echo '
-        <script type="text/javascript">
-        //<![CDATA[
-        function checksubmit(form) {
-            var destination = form.formaction.options[form.formaction.selectedIndex].value;
-            if (destination == "" || !checkchecked(form)) {
-                form.formaction.selectedIndex = 0;
-                return false;
-            } else {
-                return true;
-            }
-        }
-
-        function checkchecked(form) {
-            var inputs = document.getElementsByTagName(\'INPUT\');
-            var checked = false;
-            inputs = filterByParent(inputs, function() {return form;});
-            for(var i = 0; i < inputs.length; ++i) {
-                if (inputs[i].type == \'checkbox\' && inputs[i].checked) {
-                    checked = true;
-                }
-            }
-            return checked;
-        }
-        //]]>
-        </script>
-            ';
+        $PAGE->requires->js('user/user.js');
         echo '<form action="action_redir.php" method="post" id="participantsform" onsubmit="return checksubmit(this);">';
         echo '<div>';
         echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
         echo '<input type="hidden" name="id" value="'.$course->id.'" />';
         echo '<div id="noscriptparticipantsform" style="display: inline;">';
         echo '<input type="submit" value="'.get_string('ok').'" /></div>';
-        echo '<script type="text/javascript">'.
-               "\n//<![CDATA[\n".
-               'document.getElementById("noscriptparticipantsform").style.display = "none";'.
-               "\n//]]>\n".'</script>';
+        $PAGE->requires->js_function_call('hide_item', Array('noscriptparticipantsform'));
         echo '</div>';
         echo '</div>';
         echo '</form>';
diff --git a/user/user.js b/user/user.js
new file mode 100644 (file)
index 0000000..423199e
--- /dev/null
@@ -0,0 +1,21 @@
+function checksubmit(form) {
+    var destination = form.formaction.options[form.formaction.selectedIndex].value;
+    if (destination == "" || !checkchecked(form)) {
+        form.formaction.selectedIndex = 0;
+        return false;
+    } else {
+        return true;
+    }
+}
+
+function checkchecked(form) {
+    var inputs = document.getElementsByTagName(\'INPUT\');
+    var checked = false;
+    inputs = filterByParent(inputs, function() {return form;});
+    for(var i = 0; i < inputs.length; ++i) {
+        if (inputs[i].type == \'checkbox\' && inputs[i].checked) {
+            checked = true;
+        }
+    }
+    return checked;
+}
\ No newline at end of file