From efb7a033071270f4217ee7171b8792b6848b0f0e Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Thu, 18 Aug 2005 13:57:00 +0000 Subject: [PATCH] Be nicer to Opera. --- docs/NEWS | 4 ++++ include/functions_entries.inc.php | 12 ++++++++---- serendipity_admin.php | 13 +++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 3332c3b..d106b90 100644 --- 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 diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 789385d..14e059e 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -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'] = ''; - showItem('categoryselector'); + addLoadEvent(showItem); diff --git a/serendipity_admin.php b/serendipity_admin.php index 19235b2..3ccbbe2 100644 --- a/serendipity_admin.php +++ b/serendipity_admin.php @@ -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(); + } + } + } + -- 2.39.5