]> git.mjollnir.org Git - moodle.git/commitdiff
Split up the Javascript stuff into static and non-static.
authormoodler <moodler>
Sun, 9 Jan 2005 15:10:12 +0000 (15:10 +0000)
committermoodler <moodler>
Sun, 9 Jan 2005 15:10:12 +0000 (15:10 +0000)
This will reduce the size of each page somewhat.

lib/javascript-static.js [new file with mode: 0644]
lib/javascript.php

diff --git a/lib/javascript-static.js b/lib/javascript-static.js
new file mode 100644 (file)
index 0000000..1e7a97e
--- /dev/null
@@ -0,0 +1,51 @@
+function popUpProperties(inobj) {
+  op = window.open();
+  op.document.open('text/plain');
+  for (objprop in inobj) {
+    op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
+  }
+  op.document.close();
+}
+
+function fillmessagebox(text) {
+  document.form.message.value = text;
+}
+
+function copyrichtext(textname) {
+/// Legacy stub for old editor - to be removed soon
+  return true;
+}
+
+function checkall() {
+  void(d=document);
+  void(el=d.getElementsByTagName('INPUT'));
+  for(i=0;i<el.length;i++)
+    void(el[i].checked=1)
+}
+
+function lockoptions(form, master, subitems) {
+  // subitems is an array of names of sub items
+  // requires that each item in subitems has a
+  // companion hidden item in the form with the
+  // same name but prefixed by "h"
+  if (eval("document."+form+"."+master+".checked")) {
+    for (i=0; i<subitems.length; i++) {
+      unlockoption(form, subitems[i]);
+    }
+  } else {
+    for (i=0; i<subitems.length; i++) {
+      lockoption(form, subitems[i]);
+    }
+  }
+  return(true);
+}
+
+function lockoption(form,item) {
+  eval("document."+form+"."+item+".disabled=true");/* IE thing */
+  eval("document."+form+".h"+item+".value=1");
+}
+
+function unlockoption(form,item) {
+  eval("document."+form+"."+item+".disabled=false");/* IE thing */
+  eval("document."+form+".h"+item+".value=0");
+}
index f22d1d2c98293d7fd5d7e8a1c33380444545c7e2..7bf4a83c831f5b6cce9bbf19a1eef25ae5beb995 100644 (file)
@@ -1,30 +1,19 @@
-<?php defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.'); ?>
+<?php  /// $Id$
+       /// Load up any required Javascript libraries
 
-<script language="JavaScript" type="text/javascript"
+    if (!defined('MOODLE_INTERNAL')) {
+        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
+    }
 
-        src="<?php echo "$CFG->wwwroot/lib/overlib.js" ?>"></script>
-<?php
-    // Enable global access to spelling feature.
-    if(!empty($CFG->aspellpath)) {
-        echo "<script src=\"".$CFG->wwwroot."/lib/speller/spellChecker.js\"></script>\n";
+    if(!empty($CFG->aspellpath)) {      // Enable global access to spelling feature.
+        echo '<script src="'.$CFG->wwwroot.'/lib/speller/spellChecker.js"></script>\n';
     }
 ?>
+<script language="JavaScript" type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/overlib.js"></script>
+<script language="JavaScript" type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/javascript-static.js"></script>
 <script language="JavaScript" type="text/javascript">
 
-<!-- //hide
-
-function popUpProperties(inobj) {
-  op = window.open();
-  op.document.open('text/plain');
-  for (objprop in inobj) {
-    op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
-  }
-  op.document.close();
-}
-
-function fillmessagebox(text) {
-  document.form.message.value = text;
-}
+<!-- // Non-Static Javascript functions
 
 function openpopup(url,name,options,fullscreen) {
   fullurl = "<?php echo $CFG->wwwroot ?>" + url;
@@ -37,18 +26,6 @@ function openpopup(url,name,options,fullscreen) {
   return false;
 }
 
-function copyrichtext(textname) {
-/// Legacy stub for old editor - to be removed soon
-  return true;
-}
-
-function checkall() {
-  void(d=document);
-  void(el=d.getElementsByTagName('INPUT'));
-  for(i=0;i<el.length;i++)
-    void(el[i].checked=1)
-}
-
 function inserttext(text) {
 <?php
     if (!empty($SESSION->inserttextform)) {
@@ -67,35 +44,7 @@ function inserttext(text) {
 ?>
 }
 
-function lockoptions(form, master, subitems) {
-  // subitems is an array of names of sub items
-  // requires that each item in subitems has a
-  // companion hidden item in the form with the
-  // same name but prefixed by "h"
-  if (eval("document."+form+"."+master+".checked")) {
-    for (i=0; i<subitems.length; i++) {
-      unlockoption(form, subitems[i]);
-    }
-  } else {
-    for (i=0; i<subitems.length; i++) {
-      lockoption(form, subitems[i]);
-    }
-  }
-  return(true);
-}
-
-function lockoption(form,item) {
-  eval("document."+form+"."+item+".disabled=true");/* IE thing */
-  eval("document."+form+".h"+item+".value=1");
-}
-
-function unlockoption(form,item) {
-  eval("document."+form+"."+item+".disabled=false");/* IE thing */
-  eval("document."+form+".h"+item+".value=0");
-}
-
 <?php if (!empty($focus)) { echo "function setfocus() { document.$focus.focus() }\n"; } ?>
 
 // done hiding -->
-
 </script>