From 2581314a9522e8a6466e1394db2867907b33770e Mon Sep 17 00:00:00 2001 From: nacin Date: Sun, 4 Apr 2010 03:53:14 +0000 Subject: [PATCH] Convert xfn.js to jQuery. Make the calculated field readonly if js. props rmccue. fixes #12551 git-svn-id: http://svn.automattic.com/wordpress/trunk@13984 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/xfn.dev.js | 57 ++++++++++------------------------- wp-admin/js/xfn.js | 2 +- wp-includes/script-loader.php | 3 +- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/wp-admin/js/xfn.dev.js b/wp-admin/js/xfn.dev.js index fdb5969726..053ae7eb50 100644 --- a/wp-admin/js/xfn.dev.js +++ b/wp-admin/js/xfn.dev.js @@ -1,41 +1,16 @@ -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); \ No newline at end of file +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) ); + }); +}); \ No newline at end of file diff --git a/wp-admin/js/xfn.js b/wp-admin/js/xfn.js index d37a80af91..c243a9fdfb 100644 --- a/wp-admin/js/xfn.js +++ b/wp-admin/js/xfn.js @@ -1 +1 @@ -function GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;b isset($_GET['hotkeys_highlight_last']) ) ); - $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' ); + $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' ); + $scripts->add_data( 'xfn', 'group', 1 ); $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' ); $scripts->add_data( 'postbox', 'group', 1 );