Ticket #44362: 44362.diff
File 44362.diff, 3.5 KB (added by , 7 years ago) |
---|
-
src/js/_enqueues/admin/link.js
1 1 /* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */ 2 2 3 /** 4 * Binds to the document ready event. 5 * 6 * @since 2.5.0 7 * 8 * @param {jQuery} $ The jQuery object. 9 */ 3 10 jQuery(document).ready( function($) { 4 11 5 12 var newCat, noSyncChecks = false, syncChecks, catAddAfter; … … 8 15 // postboxes 9 16 postboxes.add_postbox_toggles('link'); 10 17 11 // category tabs 18 /** 19 * Adds event that opens a particular category tab. 20 * 21 * @listens $('#category-tabs a'):click 22 * 23 * @param {Event} event The event object. 24 * @returns {Boolean} False, prevents regular link functionality. 25 */ 12 26 $('#category-tabs a').click(function(){ 13 27 var t = $(this).attr('href'); 14 28 $(this).parent().addClass('tabs').siblings('li').removeClass('tabs'); … … 25 39 26 40 // Ajax Cat 27 41 newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } ); 42 43 /** 44 * After adding a new category, focus on the category add input field. 45 * 46 * @listens $('#link-category-add-submit'):click 47 * 48 * @return {void} 49 */ 28 50 $('#link-category-add-submit').click( function() { newCat.focus(); } ); 51 52 /** 53 * Syncronize category checkboxes. 54 * 55 * @return {void} 56 */ 29 57 syncChecks = function() { 30 58 if ( noSyncChecks ) 31 59 return; … … 35 63 noSyncChecks = false; 36 64 }; 37 65 66 /** 67 * Callback that's run after an item got added to the list. 68 * 69 * @param {XML} r Raw response returned from the server. 70 * @param {Object} s List manager configuration object; settings for the Ajax request. 71 * 72 * @return {void} 73 */ 38 74 catAddAfter = function( r, s ) { 39 75 $(s.what + ' response_data', r).each( function() { 40 76 var t = $($(this).text()); … … 46 82 } ); 47 83 }; 48 84 85 /** 86 * List manager. 87 * 88 * @param {Object} List manager configuration object. 89 * 90 * @see wp-includes/js/wp-lists.js 91 * 92 * @type {wpList} 93 */ 49 94 $('#categorychecklist').wpList( { 95 // CSS class name for alternate styling. 50 96 alt: '', 97 98 // The type of list. 51 99 what: 'link-category', 100 101 // ID of the element the parsed Ajax response will be stored in. 52 102 response: 'category-ajax-response', 103 104 // Callback that's run after an item got added to the list. 53 105 addAfter: catAddAfter 54 106 } ); 55 107 108 /** 109 * Delete the user setting regarding which category tab should be shown. 110 * 111 * @listens $('a[href="#categories-all"]'):click 112 * 113 * @return {void} 114 */ 56 115 $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); 116 117 /** 118 * Set the user setting regarding which category tab should be shown to display 119 * popular categories. 120 * 121 * @listens $('a[href="#categories-pop"]'):click 122 * 123 * @return {void} 124 */ 57 125 $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); 126 58 127 if ( 'pop' == getUserSetting('cats') ) 59 128 $('a[href="#categories-pop"]').click(); 60 129 130 /** 131 * Adds event that shows the interface controls to add a new category. 132 * 133 * @listens $('#category-add-toggle'):click 134 * 135 * @param {Event} event The event object. 136 * @returns {Boolean} False, prevents regular link functionality. 137 */ 61 138 $('#category-add-toggle').click( function() { 62 139 $(this).parents('div:first').toggleClass( 'wp-hidden-children' ); 63 140 $('#category-tabs a[href="#categories-all"]').click();