author | Anthony Ly <anthonyly.com@gmail.com> |
Mon, 19 Nov 2012 18:26:13 +0100 | |
changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
permissions | -rw-r--r-- |
136 | 1 |
(function($) { |
2 |
inlineEditPost = { |
|
3 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
4 |
init : function(){ |
136 | 5 |
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); |
6 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
7 |
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
8 |
t.what = '#post-'; |
136 | 9 |
|
10 |
// prepare the edit rows |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
11 |
qeRow.keyup(function(e){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
12 |
if (e.which == 27) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
13 |
return inlineEditPost.revert(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
14 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
15 |
bulkRow.keyup(function(e){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
16 |
if (e.which == 27) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
17 |
return inlineEditPost.revert(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
18 |
}); |
136 | 19 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
20 |
$('a.cancel', qeRow).click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
21 |
return inlineEditPost.revert(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
22 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
23 |
$('a.save', qeRow).click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
24 |
return inlineEditPost.save(this); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
25 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
26 |
$('td', qeRow).keydown(function(e){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
27 |
if ( e.which == 13 ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
28 |
return inlineEditPost.save(this); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
29 |
}); |
136 | 30 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
31 |
$('a.cancel', bulkRow).click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
32 |
return inlineEditPost.revert(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
33 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
34 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
35 |
$('#inline-edit .inline-edit-private input[value="private"]').click( function(){ |
136 | 36 |
var pw = $('input.inline-edit-password-input'); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
37 |
if ( $(this).prop('checked') ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
38 |
pw.val('').prop('disabled', true); |
136 | 39 |
} else { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
40 |
pw.prop('disabled', false); |
136 | 41 |
} |
42 |
}); |
|
43 |
||
44 |
// add events |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
45 |
$('a.editinline').live('click', function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
46 |
inlineEditPost.edit(this); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
47 |
return false; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
48 |
}); |
136 | 49 |
|
50 |
$('#bulk-title-div').parents('fieldset').after( |
|
51 |
$('#inline-edit fieldset.inline-edit-categories').clone() |
|
52 |
).siblings( 'fieldset:last' ).prepend( |
|
53 |
$('#inline-edit label.inline-edit-tags').clone() |
|
54 |
); |
|
55 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
56 |
// hiearchical taxonomies expandable? |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
57 |
$('span.catshow').click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
58 |
$(this).hide().next().show().parent().next().addClass("cat-hover"); |
136 | 59 |
}); |
60 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
61 |
$('span.cathide').click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
62 |
$(this).hide().prev().show().parent().next().removeClass("cat-hover"); |
136 | 63 |
}); |
64 |
||
65 |
$('select[name="_status"] option[value="future"]', bulkRow).remove(); |
|
66 |
||
67 |
$('#doaction, #doaction2').click(function(e){ |
|
68 |
var n = $(this).attr('id').substr(2); |
|
69 |
if ( $('select[name="'+n+'"]').val() == 'edit' ) { |
|
70 |
e.preventDefault(); |
|
71 |
t.setBulk(); |
|
72 |
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) { |
|
73 |
t.revert(); |
|
74 |
} |
|
75 |
}); |
|
76 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
77 |
$('#post-query-submit').mousedown(function(e){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
78 |
t.revert(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
79 |
$('select[name^="action"]').val('-1'); |
136 | 80 |
}); |
81 |
}, |
|
82 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
83 |
toggle : function(el){ |
136 | 84 |
var t = this; |
85 |
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); |
|
86 |
}, |
|
87 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
88 |
setBulk : function(){ |
136 | 89 |
var te = '', type = this.type, tax, c = true; |
90 |
this.revert(); |
|
91 |
||
92 |
$('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length); |
|
93 |
$('table.widefat tbody').prepend( $('#bulk-edit') ); |
|
94 |
$('#bulk-edit').addClass('inline-editor').show(); |
|
95 |
||
96 |
$('tbody th.check-column input[type="checkbox"]').each(function(i){ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
97 |
if ( $(this).prop('checked') ) { |
136 | 98 |
c = false; |
99 |
var id = $(this).val(), theTitle; |
|
100 |
theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle; |
|
101 |
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>'; |
|
102 |
} |
|
103 |
}); |
|
104 |
||
105 |
if ( c ) |
|
106 |
return this.revert(); |
|
107 |
||
108 |
$('#bulk-titles').html(te); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
109 |
$('#bulk-titles a').click(function(){ |
136 | 110 |
var id = $(this).attr('id').substr(1); |
111 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
112 |
$('table.widefat input[value="' + id + '"]').prop('checked', false); |
136 | 113 |
$('#ttle'+id).remove(); |
114 |
}); |
|
115 |
||
116 |
// enable autocomplete for tags |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
117 |
if ( 'post' == type ) { |
136 | 118 |
// support multi taxonomies? |
119 |
tax = 'post_tag'; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
120 |
$('tr.inline-editor textarea[name="tax_input['+tax+']"]').suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } ); |
136 | 121 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
122 |
$('html, body').animate( { scrollTop: 0 }, 'fast' ); |
136 | 123 |
}, |
124 |
||
125 |
edit : function(id) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
126 |
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f; |
136 | 127 |
t.revert(); |
128 |
||
129 |
if ( typeof(id) == 'object' ) |
|
130 |
id = t.getId(id); |
|
131 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
132 |
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
133 |
if ( t.type == 'page' ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
134 |
fields.push('post_parent', 'page_template'); |
136 | 135 |
|
136 |
// add the new blank row |
|
137 |
editRow = $('#inline-edit').clone(true); |
|
138 |
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); |
|
139 |
||
140 |
if ( $(t.what+id).hasClass('alternate') ) |
|
141 |
$(editRow).addClass('alternate'); |
|
142 |
$(t.what+id).hide().after(editRow); |
|
143 |
||
144 |
// populate the data |
|
145 |
rowData = $('#inline_'+id); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
146 |
if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) { |
136 | 147 |
// author no longer has edit caps, so we need to add them to the list of authors |
148 |
$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>'); |
|
149 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
150 |
if ( $(':input[name="post_author"] option', editRow).length == 1 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
151 |
$('label.inline-edit-author', editRow).hide(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
152 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
153 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
154 |
// hide unsupported formats, but leave the current format alone |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
155 |
cur_format = $('.post_format', rowData).text(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
156 |
$('option.unsupported', editRow).each(function() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
157 |
var $this = $(this); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
158 |
if ( $this.val() != cur_format ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
159 |
$this.remove(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
160 |
}); |
136 | 161 |
|
162 |
for ( f = 0; f < fields.length; f++ ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
163 |
$(':input[name="' + fields[f] + '"]', editRow).val( $('.'+fields[f], rowData).text() ); |
136 | 164 |
} |
165 |
||
166 |
if ( $('.comment_status', rowData).text() == 'open' ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
167 |
$('input[name="comment_status"]', editRow).prop("checked", true); |
136 | 168 |
if ( $('.ping_status', rowData).text() == 'open' ) |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
169 |
$('input[name="ping_status"]', editRow).prop("checked", true); |
136 | 170 |
if ( $('.sticky', rowData).text() == 'sticky' ) |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
171 |
$('input[name="sticky"]', editRow).prop("checked", true); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
172 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
173 |
// hierarchical taxonomies |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
174 |
$('.post_category', rowData).each(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
175 |
var term_ids = $(this).text(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
176 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
177 |
if ( term_ids ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
178 |
taxname = $(this).attr('id').replace('_'+id, ''); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
179 |
$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(',')); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
180 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
181 |
}); |
136 | 182 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
183 |
//flat taxonomies |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
184 |
$('.tags_input', rowData).each(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
185 |
var terms = $(this).text(), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
186 |
taxname = $(this).attr('id').replace('_' + id, ''), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
187 |
textarea = $('textarea.tax_input_' + taxname, editRow), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
188 |
comma = inlineEditL10n.comma; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
189 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
190 |
if ( terms ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
191 |
if ( ',' !== comma ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
192 |
terms = terms.replace(/,/g, comma); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
193 |
textarea.val(terms); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
194 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
195 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
196 |
textarea.suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
197 |
}); |
136 | 198 |
|
199 |
// handle the post status |
|
200 |
status = $('._status', rowData).text(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
201 |
if ( 'future' != status ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
202 |
$('select[name="_status"] option[value="future"]', editRow).remove(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
203 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
204 |
if ( 'private' == status ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
205 |
$('input[name="keep_private"]', editRow).prop("checked", true); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
206 |
$('input.inline-edit-password-input').val('').prop('disabled', true); |
136 | 207 |
} |
208 |
||
209 |
// remove the current page and children from the parent dropdown |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
210 |
pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow); |
136 | 211 |
if ( pageOpt.length > 0 ) { |
212 |
pageLevel = pageOpt[0].className.split('-')[1]; |
|
213 |
nextPage = pageOpt; |
|
214 |
while ( pageLoop ) { |
|
215 |
nextPage = nextPage.next('option'); |
|
216 |
if (nextPage.length == 0) break; |
|
217 |
nextLevel = nextPage[0].className.split('-')[1]; |
|
218 |
if ( nextLevel <= pageLevel ) { |
|
219 |
pageLoop = false; |
|
220 |
} else { |
|
221 |
nextPage.remove(); |
|
222 |
nextPage = pageOpt; |
|
223 |
} |
|
224 |
} |
|
225 |
pageOpt.remove(); |
|
226 |
} |
|
227 |
||
228 |
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); |
|
229 |
$('.ptitle', editRow).focus(); |
|
230 |
||
231 |
return false; |
|
232 |
}, |
|
233 |
||
234 |
save : function(id) { |
|
235 |
var params, fields, page = $('.post_status_page').val() || ''; |
|
236 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
237 |
if ( typeof(id) == 'object' ) |
136 | 238 |
id = this.getId(id); |
239 |
||
240 |
$('table.widefat .inline-edit-save .waiting').show(); |
|
241 |
||
242 |
params = { |
|
243 |
action: 'inline-save', |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
244 |
post_type: typenow, |
136 | 245 |
post_ID: id, |
246 |
edit_date: 'true', |
|
247 |
post_status: page |
|
248 |
}; |
|
249 |
||
250 |
fields = $('#edit-'+id+' :input').serialize(); |
|
251 |
params = fields + '&' + $.param(params); |
|
252 |
||
253 |
// make ajax request |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
254 |
$.post( ajaxurl, params, |
136 | 255 |
function(r) { |
256 |
$('table.widefat .inline-edit-save .waiting').hide(); |
|
257 |
||
258 |
if (r) { |
|
259 |
if ( -1 != r.indexOf('<tr') ) { |
|
260 |
$(inlineEditPost.what+id).remove(); |
|
261 |
$('#edit-'+id).before(r).remove(); |
|
262 |
$(inlineEditPost.what+id).hide().fadeIn(); |
|
263 |
} else { |
|
264 |
r = r.replace( /<.[^<>]*?>/g, '' ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
265 |
$('#edit-'+id+' .inline-edit-save .error').html(r).show(); |
136 | 266 |
} |
267 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
268 |
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); |
136 | 269 |
} |
270 |
} |
|
271 |
, 'html'); |
|
272 |
return false; |
|
273 |
}, |
|
274 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
275 |
revert : function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
276 |
var id = $('table.widefat tr.inline-editor').attr('id'); |
136 | 277 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
278 |
if ( id ) { |
136 | 279 |
$('table.widefat .inline-edit-save .waiting').hide(); |
280 |
||
281 |
if ( 'bulk-edit' == id ) { |
|
282 |
$('table.widefat #bulk-edit').removeClass('inline-editor').hide(); |
|
283 |
$('#bulk-titles').html(''); |
|
284 |
$('#inlineedit').append( $('#bulk-edit') ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
285 |
} else { |
136 | 286 |
$('#'+id).remove(); |
287 |
id = id.substr( id.lastIndexOf('-') + 1 ); |
|
288 |
$(this.what+id).show(); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
return false; |
|
293 |
}, |
|
294 |
||
295 |
getId : function(o) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
296 |
var id = $(o).closest('tr').attr('id'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
297 |
parts = id.split('-'); |
136 | 298 |
return parts[parts.length - 1]; |
299 |
} |
|
300 |
}; |
|
301 |
||
302 |
$(document).ready(function(){inlineEditPost.init();}); |
|
303 |
})(jQuery); |