]> git.mjollnir.org Git - s9y.git/commitdiff
rewrite of multi-category selector.
authorgarvinhicking <garvinhicking>
Tue, 21 Jun 2005 09:59:23 +0000 (09:59 +0000)
committergarvinhicking <garvinhicking>
Tue, 21 Jun 2005 09:59:23 +0000 (09:59 +0000)
Should now work in IE, Firefox and Konqueror.
Please test :D

docs/NEWS
include/functions_entries.inc.php

index 2476768720df21feb496132e450957415cb9be67..dd6474f15389fee93fa19b96600de90a17de0383 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,8 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * Fix multi-category selector for Konqueror (garvinhicking)
+
     * Support use of Boolean search mode in MySQL. Is activated when using
       special characters like "()~*+-<>. Syntax see 
       http://dev.mysql.com/doc/mysql/en/fulltext-boolean.html.
index ce98731a66245fa7f644d788ef456e85c5727ab4..9723245e0b333b7d2d7070bc5905b58549d0141c 100644 (file)
@@ -1342,23 +1342,17 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
                             el = document.getElementById(id);
                             if (selector_toggle[id] && selector_toggle[id] == 'off') {
                                 selector_restore[id] = new Array();
-                                if (selector_store[id] > 0) {
-                                    el.size = selector_store[id];
-                                } else {
-                                    el.size = 1
-                                }
-
-                                selector_toggle[id] = 'on';
-
-                                /* Show a normal dropdown */
-                                if (el.multiple) {
-                                    el.multiple = false;
-                                }
+                                selector_toggle[id]  = 'on';
 
                                 /* 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++) {
-                                    if (el.options[i].selected == true) selected++;
+                                    if (el.options[i].selected == true) {
+                                        selected++;
+                                        last = i;
+                                        selector_restore[id][last] = 'on';
+                                    }
 
                                     if (selected > 1) {
                                         /* If there is more than one selected, we reset all those to false
@@ -1373,17 +1367,44 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
                                                 selector_restore[id][j] = false;
                                             }
                                         }
-
-                                        el.selectedIndex = last;
                                         break;
                                     }
                                 }
+                                
+                                el.selectedIndex = 0;
+                                if (last > 0) {
+                                    el.selectedIndex = last;
+                                }
+
+                                el.size = 1;
 
-                                if (el.selectedIndex == -1) el.selectedIndex = 0;
+                                /* Show a normal dropdown */
+                                if (el.multiple) {
+                                    el.multiple = false;
+                                }
 
                                 document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>';
                             } else {
                                 selector_store[id] = el.size;
+                                if (selector_store[id] == 0) {
+                                    selector_store[id] = 5;
+                                }
+
+                                last = 0;
+                                if (el.selectedIndex > 0) {
+                                    if (!selector_restore[id]) {
+                                        selector_restore[id] = new Array();
+                                    }
+
+                                    for (j=0; j < el.options.length; j++) {
+                                        /* Save selection in array to later restore them */
+                                        if (el.options[j].selected == true) {
+                                            selector_restore[id][j] = 'on';
+                                            last = j;
+                                        }
+                                    }
+                                }
+                                el.selectedIndex = -1;
                                 el.size = <?php echo count($cats)+1; ?>;
                                 selector_toggle[id] = 'off';
 
@@ -1391,11 +1412,13 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
                                 el.multiple = true;
 
                                 /* Restore previously selected items? */
+                                last = 0;
                                 for (i = 0; i < el.options.length; i++) {
                                     if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') {
                                         val = el.options[i].value;
                                         if (el.options[i].selected != true) {
                                             el.options[i].selected = true;
+                                            last = i;
                                             // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this:
                                             // alert('it doesnt matter what, just the alert is important');
                                         }