web/wp-admin/js/link.js
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
     1 jQuery(document).ready(function(c){var b,a=false,d,e;c("#link_name").focus();postboxes.add_postbox_toggles("link");c("#category-tabs a").click(function(){var f=c(this).attr("href");c(this).parent().addClass("tabs").siblings("li").removeClass("tabs");c(".tabs-panel").hide();c(f).show();if("#categories-all"==f){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){c('#category-tabs a[href="#categories-pop"]').click()}b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#link-category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var f=c(this),h=f.is(":checked"),g=f.val().toString();c("#in-link-category-"+g+", #in-popular-category-"+g).prop("checked",h);a=false};e=function(g,f){c(f.what+" response_data",g).each(function(){var h=c(c(this).text());h.find("label").each(function(){var j=c(this),l=j.find("input").val(),m=j.find("input")[0].id,i=c.trim(j.text()),k;c("#"+m).change(d);k=c('<option value="'+parseInt(l,10)+'"></option>').text(i)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:e});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");c('#category-tabs a[href="#categories-all"]').click();c("#newcategory").focus();return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});
     1 jQuery(document).ready( function($) {
       
     2 
       
     3 	var newCat, noSyncChecks = false, syncChecks, catAddAfter;
       
     4 
       
     5 	$('#link_name').focus();
       
     6 	// postboxes
       
     7 	postboxes.add_postbox_toggles('link');
       
     8 
       
     9 	// category tabs
       
    10 	$('#category-tabs a').click(function(){
       
    11 		var t = $(this).attr('href');
       
    12 		$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
       
    13 		$('.tabs-panel').hide();
       
    14 		$(t).show();
       
    15 		if ( '#categories-all' == t )
       
    16 			deleteUserSetting('cats');
       
    17 		else
       
    18 			setUserSetting('cats','pop');
       
    19 		return false;
       
    20 	});
       
    21 	if ( getUserSetting('cats') )
       
    22 		$('#category-tabs a[href="#categories-pop"]').click();
       
    23 
       
    24 	// Ajax Cat
       
    25 	newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
       
    26 	$('#link-category-add-submit').click( function() { newCat.focus(); } );
       
    27 	syncChecks = function() {
       
    28 		if ( noSyncChecks )
       
    29 			return;
       
    30 		noSyncChecks = true;
       
    31 		var th = $(this), c = th.is(':checked'), id = th.val().toString();
       
    32 		$('#in-link-category-' + id + ', #in-popular-category-' + id).prop( 'checked', c );
       
    33 		noSyncChecks = false;
       
    34 	};
       
    35 
       
    36 	catAddAfter = function( r, s ) {
       
    37 		$(s.what + ' response_data', r).each( function() {
       
    38 			var t = $($(this).text());
       
    39 			t.find( 'label' ).each( function() {
       
    40 				var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
       
    41 				$('#' + id).change( syncChecks );
       
    42 				o = $( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
       
    43 			} );
       
    44 		} );
       
    45 	};
       
    46 
       
    47 	$('#categorychecklist').wpList( {
       
    48 		alt: '',
       
    49 		what: 'link-category',
       
    50 		response: 'category-ajax-response',
       
    51 		addAfter: catAddAfter
       
    52 	} );
       
    53 
       
    54 	$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
       
    55 	$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
       
    56 	if ( 'pop' == getUserSetting('cats') )
       
    57 		$('a[href="#categories-pop"]').click();
       
    58 
       
    59 	$('#category-add-toggle').click( function() {
       
    60 		$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
       
    61 		$('#category-tabs a[href="#categories-all"]').click();
       
    62 		$('#newcategory').focus();
       
    63 		return false;
       
    64 	} );
       
    65 
       
    66 	$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
       
    67 });