[ Index ] |
|
Code source de Serendipity 1.2 |
1 function toggle_extended(setCookie) { 2 var textarea = document.getElementById('serendipity[extended]'); 3 var button = document.getElementById('option_extended'); 4 var tools = document.getElementById('tools_extended'); 5 if ( textarea.style.display == 'none' ) { 6 textarea.style.display = ''; 7 tools.style.display = ''; 8 button.src = minus_img; 9 if (setCookie == true) { 10 document.cookie = 'serendipity[toggle_extended]=true;'; 11 } 12 } else { 13 textarea.style.display = 'none'; 14 tools.style.display = 'none'; 15 button.src = plus_img; 16 if (setCookie == true) { 17 document.cookie = 'serendipity[toggle_extended]=;'; 18 } 19 } 20 } 21 22 function showItem(id) { 23 var selected = 0; 24 if (typeof(id) == 'undefined' || typeof(id) == 'object') { 25 id = 'categoryselector'; 26 } 27 28 if (document.getElementById) { 29 el = document.getElementById(id); 30 if (selector_toggle[id] && selector_toggle[id] == 'off') { 31 selector_restore[id] = new Array(); 32 selector_toggle[id] = 'on'; 33 34 /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */ 35 last = 0; 36 37 for (i=0; i < el.options.length; i++) { 38 if (el.options[i].selected == true) { 39 selected++; 40 last = i; 41 selector_restore[id][last] = 'on'; 42 } 43 44 if (selected > 1) { 45 /* If there is more than one selected, we reset all those to false 46 This is because otherwise the label will say 'No Category', but the categories will still be selected */ 47 for (j=0; j < el.options.length; j++) { 48 /* Save selection in array to later restore them */ 49 if (el.options[j].selected == true) { 50 el.options[j].selected = false; 51 selector_restore[id][j] = 'on'; 52 last = j; 53 } else { 54 selector_restore[id][j] = false; 55 } 56 } 57 break; 58 } 59 } 60 61 el.selectedIndex = null; 62 if (last > 0) { 63 el.selectedIndex = last; 64 } 65 66 el.size = 1; 67 68 /* Show a normal dropdown */ 69 if (el.multiple) { 70 el.multiple = false; 71 } 72 73 document.getElementById('option_' + id).src = plus_img; 74 } else { 75 selector_store[id] = el.size; 76 if (selector_store[id] == 0) { 77 selector_store[id] = 5; 78 } 79 80 last = 0; 81 if (el.selectedIndex > 0) { 82 if (!selector_restore[id]) { 83 selector_restore[id] = new Array(); 84 } 85 86 for (j=0; j < el.options.length; j++) { 87 /* Save selection in array to later restore them */ 88 if (el.options[j].selected == true) { 89 selector_restore[id][j] = 'on'; 90 last = j; 91 } 92 } 93 } 94 el.selectedIndex = -1; 95 el.size = cat_count; 96 selector_toggle[id] = 'off'; 97 98 /* Show multiple items */ 99 el.multiple = true; 100 101 /* Restore previously selected items? */ 102 last = 0; 103 for (i = 0; i < el.options.length; i++) { 104 if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') { 105 val = el.options[i].value; 106 if (el.options[i].selected != true) { 107 el.options[i].selected = true; 108 last = i; 109 // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this: 110 // alert('it doesnt matter what, just the alert is important'); 111 } 112 } 113 } 114 115 document.getElementById('option_' + id).src = minus_img; 116 } 117 } 118 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |