]> git.mjollnir.org Git - s9y.git/commitdiff
Be nicer to Opera.
authorgarvinhicking <garvinhicking>
Thu, 18 Aug 2005 13:57:00 +0000 (13:57 +0000)
committergarvinhicking <garvinhicking>
Thu, 18 Aug 2005 13:57:00 +0000 (13:57 +0000)
docs/NEWS
include/functions_entries.inc.php
serendipity_admin.php

index 3332c3bd25ba92036c91a84c942a878c871876cf..d106b90ef7131c2ec40108fa56af180c6db58a2e 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * Make category selector be nicer to Opera. Load the handling functions
+      only after the DOM load is completed. Add new "addLoadEvent"
+      functionality for future use to stack onload events. (garvinhicking)
+
     * New Plugin API Hook "frontend_calendar" which allows to hook into
       sidebar calendar creation. Needs to be enabled in the calendar
       plugin configuration and needs a patch to the plugin_calendar.tpl
index 789385d6d5cb20aef54fd59174d68eef6e7ed99e..14e059efb802cebea3941694260fbb077fbc3cf4 100644 (file)
@@ -1381,6 +1381,10 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
 
                     function showItem(id) {
                         var selected = 0;
+                        if (typeof(id) == 'undefined' || typeof(id) == 'object') {
+                            id = 'categoryselector';
+                        }
+
                         if (document.getElementById) {
                             el = document.getElementById(id);
                             if (selector_toggle[id] && selector_toggle[id] == 'off') {
@@ -1390,7 +1394,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
                                 /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */
                                 last = 0;
                                 
-                                for (i=0; i< el.options.length; i++) {
+                                for (i=0; i < el.options.length; i++) {
                                     if (el.options[i].selected == true) {
                                         selected++;
                                         last = i;
@@ -1414,7 +1418,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
                                     }
                                 }
                                 
-                                el.selectedIndex = 0;
+                                el.selectedIndex = null;
                                 if (last > 0) {
                                     el.selectedIndex = last;
                                 }
@@ -1480,9 +1484,9 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
 ?>
                         return true;
                     }
-
+                    
                     selector_toggle['categoryselector'] = '<?php echo ($categoryselector_expanded ? 'on' : 'off'); ?>';
-                    showItem('categoryselector');
+                    addLoadEvent(showItem);
                     </script>
                     </td>
             </tr>
index 19235b2f262c767aadb1e0e097ed4d97f0df4a83..3ccbbe24192a1ee7bd3679244bd4077d28069cb3 100644 (file)
@@ -58,6 +58,19 @@ if (serendipity_is_iframe()) {
             expire.setTime(today.getTime() + (60*60*24*30));
             document.cookie = 'serendipity[' + name + ']='+escape(value) + ';expires=' + expire.toGMTString();
         }
+
+        function addLoadEvent(func) {
+          var oldonload = window.onload;
+          if (typeof window.onload != 'function') {
+            window.onload = func;
+          } else {
+            window.onload = function() {
+              oldonload();
+              func();
+            }
+          }
+        }
+
         </script>
     </head>
     <body id="serendipity_admin_page" onload="spawn()">