Changeset 3135 for trunk/wp-admin/admin-header.php
- Timestamp:
- 11/17/2005 10:23:35 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-header.php
r3112 r3135 111 111 112 112 <?php if ( current_user_can('manage_categories') ) : ?> 113 <style type="text/css"> 114 #newcat { width: 120px; margin-right: 5px; } 115 input#catadd { background: #a4a4a4; 116 border-bottom: 1px solid #898989; 117 border-left: 1px solid #bcbcbc; 118 border-right: 1px solid #898989; 119 border-top: 1px solid #bcbcbc; 120 color: #fff; 121 font-size: 10px; 122 padding: 0; 123 margin: 0; 124 font-weight: bold; 125 height: 20px; 126 margin-bottom: 2px; 127 text-align: center; 128 width: 37px; } 129 #howto { 130 font-size: 11px; 131 margin: 0 5px; 132 display: block; 133 } 134 #jaxcat { 135 margin: 0; 136 padding: 0; 137 } 138 </style> 113 139 <script type="text/javascript"> 114 140 var ajaxCat = new sack(); … … 130 156 newcatSub.type = 'button'; 131 157 newcatSub.name = 'Button'; 132 newcatSub.value = '+'; 133 newcat.onkeypress = ajaxNewCatKeyPress; 158 newcatSub.id = 'catadd'; 159 newcatSub.value = '<?php _e('Add'); ?>'; 160 newcatSub.onclick = ajaxNewCat; 134 161 135 162 ajaxcat.appendChild(newcat); 136 163 ajaxcat.appendChild(newcatSub); 137 document.getElementById('categorychecklist').parentNode.appendChild(ajaxcat); 164 document.getElementById('jaxcat').appendChild(ajaxcat); 165 166 howto = document.createElement('span'); 167 howto.innerHTML = '<?php _e('Separate multiple categories with commas.'); ?>'; 168 howto.id = 'howto'; 169 ajaxcat.appendChild(howto); 138 170 } 139 171 … … 144 176 if (!p) { 145 177 p = document.createElement('p'); 146 document.getElementById(' categorydiv').appendChild(p);178 document.getElementById('jaxcat').appendChild(p); 147 179 p.id = 'ajaxcatresponse'; 148 180 } … … 162 194 function newCatInteractive() { 163 195 var p = getResponseElement(); 164 p.innerHTML = 'Processing Data...';196 p.innerHTML = 'Processing Request...'; 165 197 } 166 198 167 199 function newCatCompletion() { 168 200 var p = getResponseElement(); 169 var id = parseInt(ajaxCat.response, 10); 170 if ( id == '-1' ) { 171 p.innerHTML = "You don't have permission to do that."; 172 return; 173 } 174 if ( id == '0' ) { 175 p.innerHTML = "That category name is invalid. Try something else."; 176 return; 201 // alert(ajaxCat.response); 202 var id = 0; 203 var ids = new Array(); 204 var names = new Array(); 205 206 ids = myPload( ajaxCat.response ); 207 names = myPload( newcat.value ); 208 209 for ( i = 0; i < ids.length; i++ ) { 210 id = ids[i]; 211 // alert(id); 212 if ( id == '-1' ) { 213 p.innerHTML = "You don't have permission to do that."; 214 return; 215 } 216 if ( id == '0' ) { 217 p.innerHTML = "That category name is invalid. Try something else."; 218 return; 219 } 220 221 var exists = document.getElementById('category-' + id); 222 223 if (exists) { 224 var moveIt = exists.parentNode; 225 var container = moveIt.parentNode; 226 container.removeChild(moveIt); 227 container.insertBefore(moveIt, container.firstChild); 228 moveIt.id = 'new-category-' + id; 229 exists.checked = 'checked'; 230 var nowClass = moveIt.className; 231 moveIt.className = nowClass + ' fade'; 232 Fat.fade_all(); 233 moveIt.className = nowClass; 234 } else { 235 var catDiv = document.getElementById('categorychecklist'); 236 var newLabel = document.createElement('label'); 237 newLabel.setAttribute('for', 'category-' + id); 238 newLabel.id = 'new-category-' + id; 239 newLabel.className = 'selectit fade'; 240 241 var newCheck = document.createElement('input'); 242 newCheck.type = 'checkbox'; 243 newCheck.value = id; 244 newCheck.name = 'post_category[]'; 245 newCheck.id = 'category-' + id; 246 newLabel.appendChild(newCheck); 247 248 var newLabelText = document.createTextNode(' ' + names[i]); 249 newLabel.appendChild(newLabelText); 250 251 catDiv.insertBefore(newLabel, catDiv.firstChild); 252 newCheck.checked = 'checked'; 253 254 Fat.fade_all(); 255 newLabel.className = 'selectit'; 256 } 257 newcat.value = ''; 177 258 } 178 259 p.parentNode.removeChild(p); 179 var exists = document.getElementById('category-' + id); 180 if (exists) { 181 var moveIt = exists.parentNode; 182 var container = moveIt.parentNode; 183 container.removeChild(moveIt); 184 container.insertBefore(moveIt, container.firstChild); 185 moveIt.id = 'new-category-' + id; 186 exists.checked = 'checked'; 187 var nowClass = moveIt.className; 188 moveIt.className = nowClass + ' fade'; 189 Fat.fade_all(); 190 moveIt.className = nowClass; 191 } else { 192 var catDiv = document.getElementById('categorychecklist'); 193 var newLabel = document.createElement('label'); 194 newLabel.setAttribute('for', 'category-' + id); 195 newLabel.id = 'new-category-' + id; 196 newLabel.className = 'selectit fade'; 197 198 var newCheck = document.createElement('input'); 199 newCheck.type = 'checkbox'; 200 newCheck.value = id; 201 newCheck.name = 'post_category[]'; 202 newCheck.id = 'category-' + id; 203 newLabel.appendChild(newCheck); 204 205 var newLabelText = document.createTextNode(' ' + newcat.value); 206 newLabel.appendChild(newLabelText); 207 208 catDiv.insertBefore(newLabel, catDiv.firstChild); 209 newCheck.checked = 'checked'; 210 211 Fat.fade_all(); 212 newLabel.className = 'selectit'; 213 } 214 newcat.value = ''; 260 // var id = parseInt(ajaxCat.response, 10); 261 262 215 263 } 216 264 … … 233 281 function ajaxNewCat() { 234 282 var newcat = document.getElementById('newcat'); 235 var catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value); 283 var split_cats = new Array(1); 284 var catString = ''; 285 286 catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value); 236 287 ajaxCat.requestFile = 'edit-form-ajax-cat.php'; 237 288 ajaxCat.method = 'GET'; … … 242 293 ajaxCat.runAJAX(catString); 243 294 } 295 296 function myPload( str ) { 297 var fixedExplode = new Array(); 298 var comma = new String(','); 299 var count = 0; 300 var currentElement = ''; 301 302 for( x=0; x < str.length; x++) { 303 andy = str.charAt(x); 304 if ( comma.indexOf(andy) != -1 ) { 305 fixedExplode[count] = currentElement; 306 currentElement = ""; 307 count++; 308 } else { 309 if ( ' ' != andy ) 310 currentElement += andy; 311 } 312 } 313 314 if ( currentElement != "" ) 315 fixedExplode[count] = currentElement; 316 return fixedExplode; 317 } 318 244 319 </script> 245 320 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.