Replace Permalink options Javascript with easily understood jQuery version
git-svn-id: http://svn.automattic.com/wordpress/trunk@15279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fc03d8c030
commit
81f81a4f6f
|
@ -35,48 +35,19 @@ add_contextual_help($current_screen,
|
||||||
* @subpackage Permalink_Settings_Panel
|
* @subpackage Permalink_Settings_Panel
|
||||||
*/
|
*/
|
||||||
function add_js() {
|
function add_js() {
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
function GetElementsWithClassName(elementName, className) {
|
jQuery(document).ready(function() {
|
||||||
var allElements = document.getElementsByTagName(elementName);
|
jQuery('input:radio.tog').change(function() {
|
||||||
var elemColl = new Array();
|
if ( 'custom' == this.value )
|
||||||
for (i = 0; i < allElements.length; i++) {
|
return;
|
||||||
if (allElements[i].className == className) {
|
jQuery('#permalink_structure').val( this.value );
|
||||||
elemColl[elemColl.length] = allElements[i];
|
});
|
||||||
}
|
jQuery('#permalink_structure').focus(function() {
|
||||||
}
|
jQuery("#custom_selection").attr('checked', 'checked');
|
||||||
return elemColl;
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
function upit() {
|
|
||||||
var inputColl = GetElementsWithClassName('input', 'tog');
|
|
||||||
var structure = document.getElementById('permalink_structure');
|
|
||||||
var inputs = '';
|
|
||||||
for (i = 0; i < inputColl.length; i++) {
|
|
||||||
if ( inputColl[i].checked && inputColl[i].value != '') {
|
|
||||||
inputs += inputColl[i].value + ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inputs = inputs.substr(0,inputs.length - 1);
|
|
||||||
if ( 'custom' != inputs )
|
|
||||||
structure.value = inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
function blurry() {
|
|
||||||
if (!document.getElementById) return;
|
|
||||||
|
|
||||||
var structure = document.getElementById('permalink_structure');
|
|
||||||
structure.onfocus = function () { document.getElementById('custom_selection').checked = 'checked'; }
|
|
||||||
|
|
||||||
var aInputs = document.getElementsByTagName('input');
|
|
||||||
|
|
||||||
for (var i = 0; i < aInputs.length; i++) {
|
|
||||||
aInputs[i].onclick = aInputs[i].onkeyup = upit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = blurry;
|
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue