- tagCloud.init();
-
- // close postboxes that should be closed
- jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
-
- // postboxes
- postboxes.add_postbox_toggles('post');
-
- // Editable slugs
- make_slugedit_clickable();
-
- jQuery('#tags-input').hide();
- tag_update_quickclicks();
- // add the quickadd form
- jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
- jQuery('#tagadd').click( tag_flush_to_text );
- jQuery('#newtag').focus(function() {
- if ( this.value == postL10n.addTag )
- jQuery(this).val( '' ).removeClass( 'form-input-tip' );
- });
- jQuery('#newtag').blur(function() {
- if ( this.value == '' )
- jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
- });
-
- // auto-save tags on post save/publish
- jQuery('#publish').click( tag_save_on_publish );
- jQuery('#save-post').click( tag_save_on_publish );
-
- jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
-
- // auto-suggest stuff
- jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
- jQuery('#newtag').keypress( tag_press_key );
-
- // category tabs
- var categoryTabs =jQuery('#category-tabs').tabs();
-
- // Ajax Cat
- var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
- jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
- var newCatParent = false;
- var newCatParentOption = false;
- var noSyncChecks = false; // prophylactic. necessary?
- var syncChecks = function() {
- if ( noSyncChecks )
- return;
- noSyncChecks = true;
- var th = jQuery(this);
- var c = th.is(':checked');
- var id = th.val().toString();
- jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
- noSyncChecks = false;
- };
- var popularCats = jQuery('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(',');
- var catAddBefore = function( s ) {
- s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize();
- return s;
- };
- var catAddAfter = function( r, s ) {
- if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
- if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
- jQuery(s.what + ' response_data', r).each( function() {
- var t = jQuery(jQuery(this).text());
- t.find( 'label' ).each( function() {
- var th = jQuery(this);
- var val = th.find('input').val();
- var id = th.find('input')[0].id
- jQuery('#' + id).change( syncChecks ).change();
- if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
- return;
- var name = jQuery.trim( th.text() );
- var o = jQuery( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
- newCatParent.prepend( o );
- } );
- newCatParentOption.attr( 'selected', true );
- } );
- };
- jQuery('#categorychecklist').wpList( {
- alt: '',
- response: 'category-ajax-response',
- addBefore: catAddBefore,
- addAfter: catAddAfter
- } );
- jQuery('#category-add-toggle').click( function() {
- jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
- // categoryTabs.tabs( 'select', '#categories-all' ); // this is broken (in the UI beta?)
- categoryTabs.find( 'a[href="#categories-all"]' ).click();
- jQuery('#newcat').focus();
- return false;
- } );
-
- $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
- $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
- if ( 'pop' == getUserSetting('cats') )
- $('a[href="#categories-pop"]').click();
-
- jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
- var stamp = $('#timestamp').html();
- var visibility = $('#post-visibility-display').html();
- var sticky = '';
-
- function updateVisibility() {
- if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
- $('#sticky').attr('checked', false);
- $('#sticky-span').hide();
- } else {
- $('#sticky-span').show();
- }
- if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
- $('#password-span').hide();
- } else {
- $('#password-span').show();
- }