WordPress.org

Make WordPress Core

Changeset 15279


Ignore:
Timestamp:
06/19/2010 05:40:43 AM (8 years ago)
Author:
dd32
Message:

Replace Permalink options Javascript with easily understood jQuery version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r15233 r15279  
    3636 */
    3737function add_js() {
    38 ?>
     38    ?>
    3939<script type="text/javascript">
    4040//<![CDATA[
    41 function GetElementsWithClassName(elementName, className) {
    42 var allElements = document.getElementsByTagName(elementName);
    43 var elemColl = new Array();
    44 for (i = 0; i < allElements.length; i++) {
    45 if (allElements[i].className == className) {
    46 elemColl[elemColl.length] = allElements[i];
    47 }
    48 }
    49 return elemColl;
    50 }
    51 
    52 function upit() {
    53 var inputColl = GetElementsWithClassName('input', 'tog');
    54 var structure = document.getElementById('permalink_structure');
    55 var inputs = '';
    56 for (i = 0; i < inputColl.length; i++) {
    57 if ( inputColl[i].checked && inputColl[i].value != '') {
    58 inputs += inputColl[i].value + ' ';
    59 }
    60 }
    61 inputs = inputs.substr(0,inputs.length - 1);
    62 if ( 'custom' != inputs )
    63 structure.value = inputs;
    64 }
    65 
    66 function blurry() {
    67 if (!document.getElementById) return;
    68 
    69 var structure = document.getElementById('permalink_structure');
    70 structure.onfocus = function () { document.getElementById('custom_selection').checked = 'checked'; }
    71 
    72 var aInputs = document.getElementsByTagName('input');
    73 
    74 for (var i = 0; i < aInputs.length; i++) {
    75 aInputs[i].onclick = aInputs[i].onkeyup = upit;
    76 }
    77 }
    78 
    79 window.onload = blurry;
     41jQuery(document).ready(function() {
     42    jQuery('input:radio.tog').change(function() {
     43        if ( 'custom' == this.value )
     44            return;
     45        jQuery('#permalink_structure').val( this.value );
     46    });
     47    jQuery('#permalink_structure').focus(function() {
     48        jQuery("#custom_selection").attr('checked', 'checked');
     49    });
     50});
    8051//]]>
    8152</script>
Note: See TracChangeset for help on using the changeset viewer.