1 2/* MilkyCMS 3.1 */ 3/* Datensatzoptionen ein- und ausblenden */ 4/* Checkboxen markieren */ 5/* 2010-05-31 Dialoge bestätigen */ 6 7 8 function options( id, set_to ) { 9 10 var record; 11 var top; 12 var bottom; 13 14 record ='ec_record'+id; 15 top ='ec_record'+id+'top'; 16 bottom ='ec_record'+id+'bottom'; 17 18 if( set_to!='block' && set_to!='none' ) { 19 set_to ='none'; 20 } 21 22 if( document.getElementById( top ) ) { 23 document.getElementById( top ).style.display =set_to; 24 } 25 26 if( document.getElementById( bottom ) ) { 27 document.getElementById( bottom ).style.display =set_to; 28 } 29 30 31 if( document.getElementById( record ) ) { 32 divs =document.getElementById( record ).getElementsByTagName( 'div' ); 33 for( var i=0; i<divs.length; i++ ) { 34 if( divs[i].className=='ec_layout_info_long' || 35 divs[i].className=='ec_layout_info_short' ) { 36 divs[i].style.display =set_to; 37 } 38 } 39 } 40 41 return; 42 } 43 44 45 46 47 48 49 function check_all( formID ) { 50 51 var i=0; 52 while( document.getElementById( formID ).elements[i] ) { 53 if (document.getElementById( formID ).elements[i].type == "checkbox") { 54 document.getElementById( formID ).elements[i].checked = true; 55 } 56 i++; 57 } 58 59 return; 60 } 61 62 63 64 65 66 67 function confirm_delete( label, URL ) { 68 69 if( confirm( label )) { 70 document.location.href=URL; 71 } 72 73 return; 74 } 75 76 77 78 79 80 81 82 83/** 84 * Convert a single file-input element into a 'multiple' input list 85 * 86 * Usage: 87 * 88 * 1. Create a file input element (no name) 89 * eg. <input type="file" id="first_file_element"> 90 * 91 * 2. Create a DIV for the output to be written to 92 * eg. <div id="files_list"></div> 93 * 94 * 3. Instantiate a MultiSelector object, passing in the DIV and an (optional) maximum number of files 95 * eg. var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 ); 96 * 97 * 4. Add the first element 98 * eg. multi_selector.addElement( document.getElementById( 'first_file_element' ) ); 99 * 100 * 5. That's it. 101 * 102 * You might (will) want to play around with the addListRow() method to make the output prettier. 103 * 104 * You might also want to change the line 105 * element.name = 'file_' + this.count; 106 * ...to a naming convention that makes more sense to you. 107 * 108 * Licence: 109 * Use this however/wherever you like, just don't blame me if it breaks anything. 110 * 111 * Credit: 112 * If you're nice, you'll leave this bit: 113 * 114 * Class by Stickman -- http://www.the-stickman.com 115 * with thanks to: 116 * [for Safari fixes] 117 * Luis Torrefranca -- http://www.law.pitt.edu 118 * and 119 * Shawn Parker & John Pennypacker -- http://www.fuzzycoconut.com 120 * [for duplicate name bug] 121 * 'neal' 122 */ 123function MultiSelector( list_target, max ){ 124 125 126 // Where to write the list 127 this.list_target = list_target; 128 // How many elements? 129 this.count = 0; 130 // How many elements? 131 this.id = 0; 132 // Is there a maximum? 133 if( max ){ 134 this.max = max; 135 } else { 136 this.max = -1; 137 }; 138 139 140 /** 141 * Add a new file input element 142 */ 143 this.addElement = function( element ){ 144 145 // Make sure it's a file input element 146 if( element.tagName == 'INPUT' && element.type == 'file' ){ 147 148 // Element name -- what number am I? 149 element.name = 'file_' + this.id++; 150 151 // Add reference to this object 152 element.multi_selector = this; 153 154 // What to do when a file is selected 155 element.onchange = function(){ 156 157 // New file input 158 var new_element = document.createElement( 'input' ); 159 new_element.type = 'file'; 160 161 // Add new element 162 this.parentNode.insertBefore( new_element, this ); 163 164 // Apply 'update' to element 165 this.multi_selector.addElement( new_element ); 166 167 // Update list 168 this.multi_selector.addListRow( this ); 169 170 // Hide this: we can't use display:none because Safari doesn't like it 171 this.style.position = 'absolute'; 172 this.style.left = '-1000px'; 173 174 }; 175 // If we've reached maximum number, disable input element 176 if( this.max != -1 && this.count >= this.max ){ 177 element.disabled = true; 178 }; 179 180 // File element counter 181 this.count++; 182 // Most recent element 183 this.current_element = element; 184 185 } else { 186 // This can only be applied to file input elements! 187 alert( 'Error: not a file input element' ); 188 }; 189 190 }; 191 192 /** 193 * Add a new row to the list of files 194 */ 195 this.addListRow = function( element ){ 196 197 // Row div 198 var new_row = document.createElement( 'li' ); 199 200 // Delete button 201 var new_row_button = document.createElement( 'input' ); 202 new_row_button.type = 'button'; 203 new_row_button.value = 'Delete'; 204 205 // References 206 new_row.element = element; 207 208 // Delete function 209 new_row_button.onclick= function(){ 210 211 // Remove element from form 212 this.parentNode.element.parentNode.removeChild( this.parentNode.element ); 213 214 // Remove this row from the list 215 this.parentNode.parentNode.removeChild( this.parentNode ); 216 217 // Decrement counter 218 this.parentNode.element.multi_selector.count--; 219 220 // Re-enable input element (if it's disabled) 221 this.parentNode.element.multi_selector.current_element.disabled = false;
222 223 // Appease Safari 224 // without it Safari wants to reload the browser window 225 // which nixes your already queued uploads 226 return false; 227 }; 228 229 // Set row value 230 new_row.innerHTML = element.value; 231 232 // Add button 233 new_row.appendChild( new_row_button ); 234 235 // Add it to the list 236 this.list_target.appendChild( new_row ); 237 238 }; 239 240};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.