<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13984] trunk: Convert xfn.js to jQuery.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13984">13984</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-04 03:53:14 +0000 (Sun, 04 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Convert xfn.js to jQuery. Make the calculated field readonly if js. props rmccue. fixes <a href="http://trac.wordpress.org/ticket/12551">#12551</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjsxfndevjs">trunk/wp-admin/js/xfn.dev.js</a></li>
<li><a href="#trunkwpadminjsxfnjs">trunk/wp-admin/js/xfn.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjsxfndevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/xfn.dev.js (13983 => 13984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/xfn.dev.js        2010-04-04 03:07:14 UTC (rev 13983)
+++ trunk/wp-admin/js/xfn.dev.js        2010-04-04 03:53:14 UTC (rev 13984)
</span><span class="lines">@@ -1,41 +1,16 @@
</span><del>-function GetElementsWithClassName(elementName, className) {
-        var allElements = document.getElementsByTagName(elementName), elemColl = new Array(), i;
-        for (i = 0; i < allElements.length; i++) {
-                if (allElements[i].className == className) {
-                        elemColl[elemColl.length] = allElements[i];
-                }
-        }
-        return elemColl;
-}
-
-function meChecked() {
-        var undefined, eMe = document.getElementById('me');
-        if (eMe == undefined) return false;
-        else return eMe.checked;
-}
-
-function upit() {
-        var isMe = meChecked(), inputColl = GetElementsWithClassName('input', 'valinp'), results = document.getElementById('link_rel'), inputs = '', i;
-        for (i = 0; i < inputColl.length; i++) {
-                 inputColl[i].disabled = isMe;
-                 inputColl[i].parentNode.className = isMe ? 'disabled' : '';
-                 if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
-                        inputs += inputColl[i].value + ' ';
-                                }
-                 }
-        inputs = inputs.substr(0,inputs.length - 1);
-        if (isMe) inputs='me';
-        results.value = inputs;
-        }
-
-function blurry() {
-        if (!document.getElementById) return;
-
-        var aInputs = document.getElementsByTagName('input'), i;
-
-        for ( i = 0; i < aInputs.length; i++) {
-                 aInputs[i].onclick = aInputs[i].onkeyup = upit;
-        }
-}
-
-addLoadEvent(blurry);
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(document).ready( function($) {
+        $('#link_rel').attr('readonly', 'readonly');
+        $('#linkxfndiv input').bind('click keyup', function() {
+                var isMe = $('#me').is(':checked'), inputs = '';
+                $('input.valinp').each( function() {
+                        if (isMe) {
+                                $(this).attr('disabled', 'disabled').parent().addClass('disabled');
+                        } else {
+                                $(this).removeAttr('disabled').parent().removeClass('disabled');
+                                if ( $(this).is(':checked') && $(this).val() != '')
+                                        inputs += $(this).val() + ' ';
+                        }
+                });
+                $('#link_rel').val( (isMe) ? 'me' : inputs.substr(0,inputs.length - 1) );
+        });
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsxfnjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/xfn.js (13983 => 13984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/xfn.js        2010-04-04 03:07:14 UTC (rev 13983)
+++ trunk/wp-admin/js/xfn.js        2010-04-04 03:53:14 UTC (rev 13984)
</span><span class="lines">@@ -1 +1 @@
</span><del>-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);
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(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))})});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (13983 => 13984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-04-04 03:07:14 UTC (rev 13983)
+++ trunk/wp-includes/script-loader.php        2010-04-04 03:53:14 UTC (rev 13984)
</span><span class="lines">@@ -274,7 +274,8 @@
</span><span class="cx">                         'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
</span><span class="cx">                 ) );
</span><span class="cx">
</span><del>-                $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' );
</del><ins>+                $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );
+                $scripts->add_data( 'xfn', 'group', 1 );
</ins><span class="cx">
</span><span class="cx">                 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
</span><span class="cx">                 $scripts->add_data( 'postbox', 'group', 1 );
</span></span></pre>
</div>
</div>
</body>
</html>