Set eol-style
git-svn-id: http://svn.automattic.com/wordpress/trunk@10054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2654405a3b
commit
10fef332d6
|
@ -1,147 +1,147 @@
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
inlineEditTax = {
|
inlineEditTax = {
|
||||||
|
|
||||||
init : function() {
|
init : function() {
|
||||||
var t = this, row = $('#inline-edit');
|
var t = this, row = $('#inline-edit');
|
||||||
|
|
||||||
t.type = $('#the-list').attr('className').substr(5);
|
t.type = $('#the-list').attr('className').substr(5);
|
||||||
t.what = '#'+t.type+'-';
|
t.what = '#'+t.type+'-';
|
||||||
|
|
||||||
// get all editable rows
|
// get all editable rows
|
||||||
t.rows = $('tr.iedit');
|
t.rows = $('tr.iedit');
|
||||||
|
|
||||||
// prepare the edit row
|
// prepare the edit row
|
||||||
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
|
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
|
||||||
|
|
||||||
$('a.cancel', row).click(function() { return inlineEditTax.revert(); });
|
$('a.cancel', row).click(function() { return inlineEditTax.revert(); });
|
||||||
$('a.save', row).click(function() { return inlineEditTax.save(this); });
|
$('a.save', row).click(function() { return inlineEditTax.save(this); });
|
||||||
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
|
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
|
||||||
|
|
||||||
// add events
|
// add events
|
||||||
t.addEvents(t.rows);
|
t.addEvents(t.rows);
|
||||||
|
|
||||||
$('#posts-filter input[type="submit"]').click(function(e){
|
$('#posts-filter input[type="submit"]').click(function(e){
|
||||||
if ( $('form#posts-filter tr.inline-editor').length > 0 )
|
if ( $('form#posts-filter tr.inline-editor').length > 0 )
|
||||||
t.revert();
|
t.revert();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle : function(el) {
|
toggle : function(el) {
|
||||||
var t = this;
|
var t = this;
|
||||||
|
|
||||||
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
|
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
addEvents : function(r) {
|
addEvents : function(r) {
|
||||||
r.each(function() {
|
r.each(function() {
|
||||||
$(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
|
$(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
|
||||||
$(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
|
$(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
edit : function(id) {
|
edit : function(id) {
|
||||||
var t = this;
|
var t = this;
|
||||||
t.revert();
|
t.revert();
|
||||||
|
|
||||||
if ( typeof(id) == 'object' )
|
if ( typeof(id) == 'object' )
|
||||||
id = t.getId(id);
|
id = t.getId(id);
|
||||||
|
|
||||||
var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
|
var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
|
||||||
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
|
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
|
||||||
|
|
||||||
if ( $(t.what+id).hasClass('alternate') )
|
if ( $(t.what+id).hasClass('alternate') )
|
||||||
$(editRow).addClass('alternate');
|
$(editRow).addClass('alternate');
|
||||||
|
|
||||||
$(t.what+id).hide().after(editRow);
|
$(t.what+id).hide().after(editRow);
|
||||||
|
|
||||||
$(':input[name="name"]', editRow).val( $('.name', rowData).text() );
|
$(':input[name="name"]', editRow).val( $('.name', rowData).text() );
|
||||||
$(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
|
$(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
|
||||||
|
|
||||||
// cat parents
|
// cat parents
|
||||||
var cat_parent = $('.cat_parent', rowData).text();
|
var cat_parent = $('.cat_parent', rowData).text();
|
||||||
if ( cat_parent != '0' )
|
if ( cat_parent != '0' )
|
||||||
$('select[name="parent"]', editRow).val(cat_parent);
|
$('select[name="parent"]', editRow).val(cat_parent);
|
||||||
|
|
||||||
// remove the current parent and children from the parent dropdown
|
// remove the current parent and children from the parent dropdown
|
||||||
var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
|
var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
|
||||||
if ( pageOpt.length > 0 ) {
|
if ( pageOpt.length > 0 ) {
|
||||||
var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
|
var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
|
||||||
while ( pageLoop ) {
|
while ( pageLoop ) {
|
||||||
var nextPage = nextPage.next('option');
|
var nextPage = nextPage.next('option');
|
||||||
if (nextPage.length == 0) break;
|
if (nextPage.length == 0) break;
|
||||||
var nextLevel = nextPage[0].className.split('-')[1];
|
var nextLevel = nextPage[0].className.split('-')[1];
|
||||||
if ( nextLevel <= pageLevel ) {
|
if ( nextLevel <= pageLevel ) {
|
||||||
pageLoop = false;
|
pageLoop = false;
|
||||||
} else {
|
} else {
|
||||||
nextPage.remove();
|
nextPage.remove();
|
||||||
nextPage = pageOpt;
|
nextPage = pageOpt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageOpt.remove();
|
pageOpt.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
|
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
|
||||||
$('.ptitle', editRow).eq(0).focus();
|
$('.ptitle', editRow).eq(0).focus();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
save : function(id) {
|
save : function(id) {
|
||||||
if( typeof(id) == 'object' )
|
if( typeof(id) == 'object' )
|
||||||
id = this.getId(id);
|
id = this.getId(id);
|
||||||
|
|
||||||
$('table.widefat .inline-edit-save .waiting').show();
|
$('table.widefat .inline-edit-save .waiting').show();
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
action: 'inline-save-tax',
|
action: 'inline-save-tax',
|
||||||
tax_type: this.type,
|
tax_type: this.type,
|
||||||
tax_ID: id
|
tax_ID: id
|
||||||
};
|
};
|
||||||
|
|
||||||
var fields = $('#edit-'+id+' :input').fieldSerialize();
|
var fields = $('#edit-'+id+' :input').fieldSerialize();
|
||||||
params = fields + '&' + $.param(params);
|
params = fields + '&' + $.param(params);
|
||||||
|
|
||||||
// make ajax request
|
// make ajax request
|
||||||
$.post('admin-ajax.php', params,
|
$.post('admin-ajax.php', params,
|
||||||
function(r) {
|
function(r) {
|
||||||
var row = $(inlineEditTax.what+id);
|
var row = $(inlineEditTax.what+id);
|
||||||
$('table.widefat .inline-edit-save .waiting').hide();
|
$('table.widefat .inline-edit-save .waiting').hide();
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
if ( -1 != r.indexOf('<tr') ) {
|
if ( -1 != r.indexOf('<tr') ) {
|
||||||
$('#edit-'+id).remove();
|
$('#edit-'+id).remove();
|
||||||
r = r.replace(/hide-if-no-js/, '');
|
r = r.replace(/hide-if-no-js/, '');
|
||||||
row.html($(r).html()).fadeIn();
|
row.html($(r).html()).fadeIn();
|
||||||
inlineEditTax.addEvents(row);
|
inlineEditTax.addEvents(row);
|
||||||
} else
|
} else
|
||||||
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
|
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
|
||||||
} else
|
} else
|
||||||
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
|
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
revert : function() {
|
revert : function() {
|
||||||
var id = $('table.widefat tr.inline-editor').attr('id');
|
var id = $('table.widefat tr.inline-editor').attr('id');
|
||||||
|
|
||||||
if ( id ) {
|
if ( id ) {
|
||||||
$('table.widefat .inline-edit-save .waiting').hide();
|
$('table.widefat .inline-edit-save .waiting').hide();
|
||||||
$('#'+id).remove();
|
$('#'+id).remove();
|
||||||
id = id.substr( id.lastIndexOf('-') + 1 );
|
id = id.substr( id.lastIndexOf('-') + 1 );
|
||||||
$(this.what+id).show();
|
$(this.what+id).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getId : function(o) {
|
getId : function(o) {
|
||||||
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
|
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
|
||||||
var parts = id.split('-');
|
var parts = id.split('-');
|
||||||
return parts[parts.length - 1];
|
return parts[parts.length - 1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function(){inlineEditTax.init();});
|
$(document).ready(function(){inlineEditTax.init();});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
Loading…
Reference in New Issue