WordPress.org

Make WordPress Core

Changeset 13984


Ignore:
Timestamp:
04/04/2010 03:53:14 AM (12 years ago)
Author:
nacin
Message:

Convert xfn.js to jQuery. Make the calculated field readonly if js. props rmccue. fixes #12551

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/xfn.dev.js

    r10291 r13984  
    1 function GetElementsWithClassName(elementName, className) {
    2     var allElements = document.getElementsByTagName(elementName), elemColl = new Array(), i;
    3     for (i = 0; i < allElements.length; i++) {
    4         if (allElements[i].className == className) {
    5             elemColl[elemColl.length] = allElements[i];
    6         }
    7     }
    8     return elemColl;
    9 }
    10 
    11 function meChecked() {
    12     var undefined, eMe = document.getElementById('me');
    13     if (eMe == undefined) return false;
    14     else return eMe.checked;
    15 }
    16 
    17 function upit() {
    18     var isMe = meChecked(), inputColl = GetElementsWithClassName('input', 'valinp'), results = document.getElementById('link_rel'), inputs = '', i;
    19     for (i = 0; i < inputColl.length; i++) {
    20          inputColl[i].disabled = isMe;
    21          inputColl[i].parentNode.className = isMe ? 'disabled' : '';
    22          if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
    23             inputs += inputColl[i].value + ' ';
    24                 }
    25          }
    26     inputs = inputs.substr(0,inputs.length - 1);
    27     if (isMe) inputs='me';
    28     results.value = inputs;
    29     }
    30 
    31 function blurry() {
    32     if (!document.getElementById) return;
    33 
    34     var aInputs = document.getElementsByTagName('input'), i;
    35 
    36     for ( i = 0; i < aInputs.length; i++) {
    37          aInputs[i].onclick = aInputs[i].onkeyup = upit;
    38     }
    39 }
    40 
    41 addLoadEvent(blurry);
     1jQuery(document).ready( function($) {
     2    $('#link_rel').attr('readonly', 'readonly');
     3    $('#linkxfndiv input').bind('click keyup', function() {
     4        var isMe = $('#me').is(':checked'), inputs = '';
     5        $('input.valinp').each( function() {
     6            if (isMe) {
     7                $(this).attr('disabled', 'disabled').parent().addClass('disabled');
     8            } else {
     9                $(this).removeAttr('disabled').parent().removeClass('disabled');
     10                if ( $(this).is(':checked') && $(this).val() != '')
     11                    inputs += $(this).val() + ' ';
     12            }
     13        });
     14        $('#link_rel').val( (isMe) ? 'me' : inputs.substr(0,inputs.length - 1) );
     15    });
     16});
  • trunk/wp-admin/js/xfn.js

    r10291 r13984  
    1 function GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;b<d.length;b++){if(d[b].className==c){e[e.length]=d[b]}}return e}function meChecked(){var b,a=document.getElementById("me");if(a==b){return false}else{return a.checked}}function upit(){var b=meChecked(),e=GetElementsWithClassName("input","valinp"),d=document.getElementById("link_rel"),a="",c;for(c=0;c<e.length;c++){e[c].disabled=b;e[c].parentNode.className=b?"disabled":"";if(!b&&e[c].checked&&e[c].value!=""){a+=e[c].value+" "}}a=a.substr(0,a.length-1);if(b){a="me"}d.value=a}function blurry(){if(!document.getElementById){return}var b=document.getElementsByTagName("input"),a;for(a=0;a<b.length;a++){b[a].onclick=b[a].onkeyup=upit}}addLoadEvent(blurry);
     1jQuery(document).ready(function(a){a("#link_rel").attr("readonly","readonly");a("#linkxfndiv input").bind("click keyup",function(){var c=a("#me").is(":checked"),b="";a("input.valinp").each(function(){if(c){a(this).attr("disabled","disabled").parent().addClass("disabled")}else{a(this).removeAttr("disabled").parent().removeClass("disabled");if(a(this).is(":checked")&&a(this).val()!=""){b+=a(this).val()+" "}}});a("#link_rel").val((c)?"me":b.substr(0,b.length-1))})});
  • trunk/wp-includes/script-loader.php

    r13981 r13984  
    275275        ) );
    276276
    277         $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' );
     277        $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );
     278        $scripts->add_data( 'xfn', 'group', 1 );
    278279
    279280        $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
Note: See TracChangeset for help on using the changeset viewer.