Edit File by line
/home/barbar84/www/wp-admin/js
File: link.js
/**
[0] Fix | Delete
* @output wp-admin/js/link.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
[4] Fix | Delete
[5] Fix | Delete
jQuery(document).ready( function($) {
[6] Fix | Delete
[7] Fix | Delete
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
[8] Fix | Delete
[9] Fix | Delete
$('#link_name').trigger( 'focus' );
[10] Fix | Delete
// Postboxes.
[11] Fix | Delete
postboxes.add_postbox_toggles('link');
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Adds event that opens a particular category tab.
[15] Fix | Delete
*
[16] Fix | Delete
* @ignore
[17] Fix | Delete
*
[18] Fix | Delete
* @return {boolean} Always returns false to prevent the default behavior.
[19] Fix | Delete
*/
[20] Fix | Delete
$('#category-tabs a').on( 'click', function(){
[21] Fix | Delete
var t = $(this).attr('href');
[22] Fix | Delete
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
[23] Fix | Delete
$('.tabs-panel').hide();
[24] Fix | Delete
$(t).show();
[25] Fix | Delete
if ( '#categories-all' == t )
[26] Fix | Delete
deleteUserSetting('cats');
[27] Fix | Delete
else
[28] Fix | Delete
setUserSetting('cats','pop');
[29] Fix | Delete
return false;
[30] Fix | Delete
});
[31] Fix | Delete
if ( getUserSetting('cats') )
[32] Fix | Delete
$('#category-tabs a[href="#categories-pop"]').trigger( 'click' );
[33] Fix | Delete
[34] Fix | Delete
// Ajax Cat.
[35] Fix | Delete
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* After adding a new category, focus on the category add input field.
[39] Fix | Delete
*
[40] Fix | Delete
* @return {void}
[41] Fix | Delete
*/
[42] Fix | Delete
$('#link-category-add-submit').on( 'click', function() { newCat.focus(); } );
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Synchronize category checkboxes.
[46] Fix | Delete
*
[47] Fix | Delete
* This function makes sure that the checkboxes are synced between the all
[48] Fix | Delete
* categories tab and the most used categories tab.
[49] Fix | Delete
*
[50] Fix | Delete
* @since 2.5.0
[51] Fix | Delete
*
[52] Fix | Delete
* @return {void}
[53] Fix | Delete
*/
[54] Fix | Delete
syncChecks = function() {
[55] Fix | Delete
if ( noSyncChecks )
[56] Fix | Delete
return;
[57] Fix | Delete
noSyncChecks = true;
[58] Fix | Delete
var th = $(this), c = th.is(':checked'), id = th.val().toString();
[59] Fix | Delete
$('#in-link-category-' + id + ', #in-popular-link_category-' + id).prop( 'checked', c );
[60] Fix | Delete
noSyncChecks = false;
[61] Fix | Delete
};
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Adds event listeners to an added category.
[65] Fix | Delete
*
[66] Fix | Delete
* This is run on the addAfter event to make sure the correct event listeners
[67] Fix | Delete
* are bound to the DOM elements.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 2.5.0
[70] Fix | Delete
*
[71] Fix | Delete
* @param {string} r Raw XML response returned from the server after adding a
[72] Fix | Delete
* category.
[73] Fix | Delete
* @param {Object} s List manager configuration object; settings for the Ajax
[74] Fix | Delete
* request.
[75] Fix | Delete
*
[76] Fix | Delete
* @return {void}
[77] Fix | Delete
*/
[78] Fix | Delete
catAddAfter = function( r, s ) {
[79] Fix | Delete
$(s.what + ' response_data', r).each( function() {
[80] Fix | Delete
var t = $($(this).text());
[81] Fix | Delete
t.find( 'label' ).each( function() {
[82] Fix | Delete
var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
[83] Fix | Delete
$('#' + id).on( 'change', syncChecks );
[84] Fix | Delete
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
[85] Fix | Delete
} );
[86] Fix | Delete
} );
[87] Fix | Delete
};
[88] Fix | Delete
[89] Fix | Delete
/*
[90] Fix | Delete
* Instantiates the list manager.
[91] Fix | Delete
*
[92] Fix | Delete
* @see js/_enqueues/lib/lists.js
[93] Fix | Delete
*/
[94] Fix | Delete
$('#categorychecklist').wpList( {
[95] Fix | Delete
// CSS class name for alternate styling.
[96] Fix | Delete
alt: '',
[97] Fix | Delete
[98] Fix | Delete
// The type of list.
[99] Fix | Delete
what: 'link-category',
[100] Fix | Delete
[101] Fix | Delete
// ID of the element the parsed Ajax response will be stored in.
[102] Fix | Delete
response: 'category-ajax-response',
[103] Fix | Delete
[104] Fix | Delete
// Callback that's run after an item got added to the list.
[105] Fix | Delete
addAfter: catAddAfter
[106] Fix | Delete
} );
[107] Fix | Delete
[108] Fix | Delete
// All categories is the default tab, so we delete the user setting.
[109] Fix | Delete
$('a[href="#categories-all"]').on( 'click', function(){deleteUserSetting('cats');});
[110] Fix | Delete
[111] Fix | Delete
// Set a preference for the popular categories to cookies.
[112] Fix | Delete
$('a[href="#categories-pop"]').on( 'click', function(){setUserSetting('cats','pop');});
[113] Fix | Delete
[114] Fix | Delete
if ( 'pop' == getUserSetting('cats') )
[115] Fix | Delete
$('a[href="#categories-pop"]').trigger( 'click' );
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Adds event handler that shows the interface controls to add a new category.
[119] Fix | Delete
*
[120] Fix | Delete
* @ignore
[121] Fix | Delete
*
[122] Fix | Delete
* @param {Event} event The event object.
[123] Fix | Delete
* @return {boolean} Always returns false to prevent regular link
[124] Fix | Delete
* functionality.
[125] Fix | Delete
*/
[126] Fix | Delete
$('#category-add-toggle').on( 'click', function() {
[127] Fix | Delete
$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
[128] Fix | Delete
$('#category-tabs a[href="#categories-all"]').trigger( 'click' );
[129] Fix | Delete
$('#newcategory').trigger( 'focus' );
[130] Fix | Delete
return false;
[131] Fix | Delete
} );
[132] Fix | Delete
[133] Fix | Delete
$('.categorychecklist :checkbox').on( 'change', syncChecks ).filter( ':checked' ).trigger( 'change' );
[134] Fix | Delete
});
[135] Fix | Delete
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function