-
+ AEDFC89600E617C7D6C40D9C87492697BA06A629DF5207F95D82502908552FC3A52EE5F645B06B5974CF8A8A27B043BD54A2D4B3E5C4D684F299FA80F7DB5352mp-wp/wp-admin/js/inline-edit-post.js(0 . 0)(1 . 266)
49990
49991 (function($) {
49992 inlineEditPost = {
49993
49994 init : function() {
49995 var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
49996
49997 t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
49998 t.what = '#'+t.type+'-';
49999
50000 // get all editable rows
50001 t.rows = $('tr.iedit');
50002
50003 // prepare the edit rows
50004 qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); });
50005 bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); });
50006
50007 $('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); });
50008 $('a.save', qeRow).click(function() { return inlineEditPost.save(this); });
50009 $('input, select', qeRow).keydown(function(e) { if(e.which == 13) return inlineEditPost.save(this); });
50010
50011 $('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); });
50012
50013 $('#inline-edit .inline-edit-private input[value=private]').click( function(){
50014 var pw = $('input.inline-edit-password-input');
50015 if ( $(this).attr('checked') ) {
50016 pw.val('').attr('disabled', 'disabled');
50017 } else {
50018 pw.attr('disabled', '');
50019 }
50020 });
50021
50022 // add events
50023 t.addEvents(t.rows);
50024
50025 $('#bulk-title-div').parents('fieldset').after(
50026 $('#inline-edit fieldset.inline-edit-categories').clone()
50027 ).siblings( 'fieldset:last' ).prepend(
50028 // ).siblings( 'fieldset:last' ).after( '<fieldset class="inline-edit-col-bottom"><div class="inline-edit-col"></div></fieldset>' );
50029 // $('fieldset.inline-edit-col-bottom').prepend(
50030 $('#inline-edit label.inline-edit-tags').clone()
50031 );
50032
50033 // categories expandable?
50034 $('span.catshow').click(function() {
50035 $('.inline-editor ul.cat-checklist').addClass("cat-hover");
50036 $('.inline-editor span.cathide').show();
50037 $(this).hide();
50038 });
50039
50040 $('span.cathide').click(function() {
50041 $('.inline-editor ul.cat-checklist').removeClass("cat-hover");
50042 $('.inline-editor span.catshow').show();
50043 $(this).hide();
50044 });
50045
50046 $('select[name="_status"] option[value="future"]', bulkRow).remove();
50047
50048 $('#doaction, #doaction2').click(function(e){
50049 var n = $(this).attr('id').substr(2);
50050 if ( $('select[name="'+n+'"]').val() == 'edit' ) {
50051 e.preventDefault();
50052 t.setBulk();
50053 } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
50054 t.revert();
50055 }
50056 });
50057
50058 $('#post-query-submit').click(function(e){
50059 if ( $('form#posts-filter tr.inline-editor').length > 0 )
50060 t.revert();
50061 });
50062
50063 },
50064
50065 toggle : function(el) {
50066 var t = this;
50067
50068 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
50069 },
50070
50071 addEvents : function(r) {
50072 r.each(function() {
50073 var row = $(this);
50074 $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; });
50075 });
50076 },
50077
50078 setBulk : function() {
50079 var te = '', c = '', type = this.type;
50080 this.revert();
50081
50082 $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
50083 $('table.widefat tbody').prepend( $('#bulk-edit') );
50084 $('#bulk-edit').addClass('inline-editor').show();
50085
50086 $('tbody th.check-column input[type="checkbox"]').each(function(i){
50087 if ( $(this).attr('checked') ) {
50088 var id = $(this).val();
50089 var theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
50090 te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
50091 }
50092 });
50093
50094 $('#bulk-titles').html(te);
50095 $('#bulk-titles a').click(function() {
50096 var id = $(this).attr('id').substr(1), r = inlineEditPost.type+'-'+id;
50097
50098 $('table.widefat input[value="'+id+'"]').attr('checked', '');
50099 $('#ttle'+id).remove();
50100 });
50101
50102 // enable autocomplete for tags
50103 if ( type == 'post' )
50104 $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
50105 },
50106
50107 edit : function(id) {
50108 var t = this;
50109 t.revert();
50110
50111 if ( typeof(id) == 'object' )
50112 id = t.getId(id);
50113
50114 var fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
50115 if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
50116 if ( t.type == 'post' ) fields.push('tags_input');
50117
50118 // add the new blank row
50119 var editRow = $('#inline-edit').clone(true);
50120 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
50121
50122 if ( $(t.what+id).hasClass('alternate') )
50123 $(editRow).addClass('alternate');
50124 $(t.what+id).hide().after(editRow);
50125
50126 // populate the data
50127 var rowData = $('#inline_'+id);
50128 for ( var f = 0; f < fields.length; f++ ) {
50129 $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
50130 }
50131
50132 if ( $('.comment_status', rowData).text() == 'open' )
50133 $('input[name="comment_status"]', editRow).attr("checked", "checked");
50134 if ( $('.ping_status', rowData).text() == 'open' )
50135 $('input[name="ping_status"]', editRow).attr("checked", "checked");
50136 if ( $('.sticky', rowData).text() == 'sticky' )
50137 $('input[name="sticky"]', editRow).attr("checked", "checked");
50138
50139 // categories
50140 var cats;
50141 if ( cats = $('.post_category', rowData).text() )
50142 $('ul.cat-checklist :checkbox', editRow).val(cats.split(','));
50143
50144 // handle the post status
50145 var status = $('._status', rowData).text();
50146 if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove();
50147 if ( status == 'private' ) {
50148 $('input[name="keep_private"]', editRow).attr("checked", "checked");
50149 $('input.inline-edit-password-input').val('').attr('disabled', 'disabled');
50150 }
50151
50152 // remove the current page and children from the parent dropdown
50153 var pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow);
50154 if ( pageOpt.length > 0 ) {
50155 var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
50156 while ( pageLoop ) {
50157 var nextPage = nextPage.next('option');
50158 if (nextPage.length == 0) break;
50159 var nextLevel = nextPage[0].className.split('-')[1];
50160 if ( nextLevel <= pageLevel ) {
50161 pageLoop = false;
50162 } else {
50163 nextPage.remove();
50164 nextPage = pageOpt;
50165 }
50166 }
50167 pageOpt.remove();
50168 }
50169
50170 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
50171 $('.ptitle', editRow).focus();
50172
50173 // enable autocomplete for tags
50174 if ( t.type == 'post' )
50175 $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
50176
50177 return false;
50178 },
50179
50180 save : function(id) {
50181 if( typeof(id) == 'object' )
50182 id = this.getId(id);
50183
50184 $('table.widefat .inline-edit-save .waiting').show();
50185
50186 var params = {
50187 action: 'inline-save',
50188 post_type: this.type,
50189 post_ID: id,
50190 edit_date: 'true'
50191 };
50192
50193 var fields = $('#edit-'+id+' :input').fieldSerialize();
50194 params = fields + '&' + $.param(params);
50195
50196 // make ajax request
50197 $.post('admin-ajax.php', params,
50198 function(r) {
50199 $('table.widefat .inline-edit-save .waiting').hide();
50200
50201 if (r) {
50202 if ( -1 != r.indexOf('<tr') ) {
50203 $(inlineEditPost.what+id).remove();
50204 $('#edit-'+id).before(r).remove();
50205
50206 var row = $(inlineEditPost.what+id);
50207 row.hide();
50208
50209 if ( 'draft' == $('input[name="post_status"]').val() )
50210 row.find('td.column-comments').hide();
50211
50212 row.find('.hide-if-no-js').removeClass('hide-if-no-js');
50213 inlineEditPost.addEvents(row);
50214 row.fadeIn();
50215 } else {
50216 r = r.replace( /<.[^<>]*?>/g, '' );
50217 $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
50218 }
50219 } else {
50220 $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
50221 }
50222 }
50223 , 'html');
50224 return false;
50225 },
50226
50227 revert : function() {
50228 var id;
50229
50230 if ( id = $('table.widefat tr.inline-editor').attr('id') ) {
50231 $('table.widefat .inline-edit-save .waiting').hide();
50232
50233 if ( 'bulk-edit' == id ) {
50234 $('table.widefat #bulk-edit').removeClass('inline-editor').hide();
50235 $('#bulk-titles').html('');
50236 $('#inlineedit').append( $('#bulk-edit') );
50237 } else {
50238 $('#'+id).remove();
50239 id = id.substr( id.lastIndexOf('-') + 1 );
50240 $(this.what+id).show();
50241 }
50242 }
50243
50244 return false;
50245 },
50246
50247 getId : function(o) {
50248 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
50249 var parts = id.split('-');
50250 return parts[parts.length - 1];
50251 }
50252 };
50253
50254 $(document).ready(function(){inlineEditPost.init();});
50255 })(jQuery);