author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 12:35:13 -0800 | |
changeset 203 | f507feede89a |
parent 194 | 32102edaa81b |
permissions | -rw-r--r-- |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1 |
var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint; |
136 | 2 |
|
3 |
// return an array with any duplicate, whitespace or values removed |
|
4 |
function array_unique_noempty(a) { |
|
5 |
var out = []; |
|
6 |
jQuery.each( a, function(key, val) { |
|
7 |
val = jQuery.trim(val); |
|
8 |
if ( val && jQuery.inArray(val, out) == -1 ) |
|
9 |
out.push(val); |
|
10 |
} ); |
|
11 |
return out; |
|
12 |
} |
|
13 |
||
14 |
(function($){ |
|
15 |
||
16 |
tagBox = { |
|
17 |
clean : function(tags) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
18 |
var comma = postL10n.comma; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
19 |
if ( ',' !== comma ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
20 |
tags = tags.replace(new RegExp(comma, 'g'), ','); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
21 |
tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, ''); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
22 |
if ( ',' !== comma ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
23 |
tags = tags.replace(/,/g, comma); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
24 |
return tags; |
136 | 25 |
}, |
26 |
||
27 |
parseTags : function(el) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
28 |
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
29 |
thetags = taxbox.find('.the-tags'), comma = postL10n.comma, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
30 |
current_tags = thetags.val().split(comma), new_tags = []; |
136 | 31 |
delete current_tags[num]; |
32 |
||
33 |
$.each( current_tags, function(key, val) { |
|
34 |
val = $.trim(val); |
|
35 |
if ( val ) { |
|
36 |
new_tags.push(val); |
|
37 |
} |
|
38 |
}); |
|
39 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
40 |
thetags.val( this.clean( new_tags.join(comma) ) ); |
136 | 41 |
|
42 |
this.quickClicks(taxbox); |
|
43 |
return false; |
|
44 |
}, |
|
45 |
||
46 |
quickClicks : function(el) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
47 |
var thetags = $('.the-tags', el), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
48 |
tagchecklist = $('.tagchecklist', el), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
49 |
id = $(el).attr('id'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
50 |
current_tags, disabled; |
136 | 51 |
|
52 |
if ( !thetags.length ) |
|
53 |
return; |
|
54 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
55 |
disabled = thetags.prop('disabled'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
56 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
57 |
current_tags = thetags.val().split(postL10n.comma); |
136 | 58 |
tagchecklist.empty(); |
59 |
||
60 |
$.each( current_tags, function( key, val ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
61 |
var span, xbutton; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
62 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
63 |
val = $.trim( val ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
64 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
65 |
if ( ! val ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
66 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
67 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
68 |
// Create a new span, and ensure the text is properly escaped. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
69 |
span = $('<span />').text( val ); |
136 | 70 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
71 |
// If tags editing isn't disabled, create the X button. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
72 |
if ( ! disabled ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
73 |
xbutton = $( '<a id="' + id + '-check-num-' + key + '" class="ntdelbutton">X</a>' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
74 |
xbutton.click( function(){ tagBox.parseTags(this); }); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
75 |
span.prepend(' ').prepend( xbutton ); |
136 | 76 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
77 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
78 |
// Append the span to the tag list. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
79 |
tagchecklist.append( span ); |
136 | 80 |
}); |
81 |
}, |
|
82 |
||
83 |
flushTags : function(el, a, f) { |
|
84 |
a = a || false; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
85 |
var tags = $('.the-tags', el), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
86 |
newtag = $('input.newtag', el), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
87 |
comma = postL10n.comma, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
88 |
newtags, text; |
136 | 89 |
|
90 |
text = a ? $(a).text() : newtag.val(); |
|
91 |
tagsval = tags.val(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
92 |
newtags = tagsval ? tagsval + comma + text : text; |
136 | 93 |
|
94 |
newtags = this.clean( newtags ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
95 |
newtags = array_unique_noempty( newtags.split(comma) ).join(comma); |
136 | 96 |
tags.val(newtags); |
97 |
this.quickClicks(el); |
|
98 |
||
99 |
if ( !a ) |
|
100 |
newtag.val(''); |
|
101 |
if ( 'undefined' == typeof(f) ) |
|
102 |
newtag.focus(); |
|
103 |
||
104 |
return false; |
|
105 |
}, |
|
106 |
||
107 |
get : function(id) { |
|
108 |
var tax = id.substr(id.indexOf('-')+1); |
|
109 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
110 |
$.post(ajaxurl, {'action':'get-tagcloud', 'tax':tax}, function(r, stat) { |
136 | 111 |
if ( 0 == r || 'success' != stat ) |
112 |
r = wpAjax.broken; |
|
113 |
||
114 |
r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>'); |
|
115 |
$('a', r).click(function(){ |
|
116 |
tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this); |
|
117 |
return false; |
|
118 |
}); |
|
119 |
||
120 |
$('#'+id).after(r); |
|
121 |
}); |
|
122 |
}, |
|
123 |
||
124 |
init : function() { |
|
125 |
var t = this, ajaxtag = $('div.ajaxtag'); |
|
126 |
||
127 |
$('.tagsdiv').each( function() { |
|
128 |
tagBox.quickClicks(this); |
|
129 |
}); |
|
130 |
||
131 |
$('input.tagadd', ajaxtag).click(function(){ |
|
132 |
t.flushTags( $(this).closest('.tagsdiv') ); |
|
133 |
}); |
|
134 |
||
135 |
$('div.taghint', ajaxtag).click(function(){ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
136 |
$(this).css('visibility', 'hidden').parent().siblings('.newtag').focus(); |
136 | 137 |
}); |
138 |
||
139 |
$('input.newtag', ajaxtag).blur(function() { |
|
140 |
if ( this.value == '' ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
141 |
$(this).parent().siblings('.taghint').css('visibility', ''); |
136 | 142 |
}).focus(function(){ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
143 |
$(this).parent().siblings('.taghint').css('visibility', 'hidden'); |
136 | 144 |
}).keyup(function(e){ |
145 |
if ( 13 == e.which ) { |
|
146 |
tagBox.flushTags( $(this).closest('.tagsdiv') ); |
|
147 |
return false; |
|
148 |
} |
|
149 |
}).keypress(function(e){ |
|
150 |
if ( 13 == e.which ) { |
|
151 |
e.preventDefault(); |
|
152 |
return false; |
|
153 |
} |
|
154 |
}).each(function(){ |
|
155 |
var tax = $(this).closest('div.tagsdiv').attr('id'); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
156 |
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: postL10n.comma + ' ' } ); |
136 | 157 |
}); |
158 |
||
159 |
// save tags on post save/publish |
|
160 |
$('#post').submit(function(){ |
|
161 |
$('div.tagsdiv').each( function() { |
|
162 |
tagBox.flushTags(this, false, 1); |
|
163 |
}); |
|
164 |
}); |
|
165 |
||
166 |
// tag cloud |
|
167 |
$('a.tagcloud-link').click(function(){ |
|
168 |
tagBox.get( $(this).attr('id') ); |
|
169 |
$(this).unbind().click(function(){ |
|
170 |
$(this).siblings('.the-tagcloud').toggle(); |
|
171 |
return false; |
|
172 |
}); |
|
173 |
return false; |
|
174 |
}); |
|
175 |
} |
|
176 |
}; |
|
177 |
||
178 |
commentsBox = { |
|
179 |
st : 0, |
|
180 |
||
181 |
get : function(total, num) { |
|
182 |
var st = this.st, data; |
|
183 |
if ( ! num ) |
|
184 |
num = 20; |
|
185 |
||
186 |
this.st += num; |
|
187 |
this.total = total; |
|
188 |
$('#commentsdiv img.waiting').show(); |
|
189 |
||
190 |
data = { |
|
191 |
'action' : 'get-comments', |
|
192 |
'mode' : 'single', |
|
193 |
'_ajax_nonce' : $('#add_comment_nonce').val(), |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
194 |
'p' : $('#post_ID').val(), |
136 | 195 |
'start' : st, |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
196 |
'number' : num |
136 | 197 |
}; |
198 |
||
199 |
$.post(ajaxurl, data, |
|
200 |
function(r) { |
|
201 |
r = wpAjax.parseAjaxResponse(r); |
|
202 |
$('#commentsdiv .widefat').show(); |
|
203 |
$('#commentsdiv img.waiting').hide(); |
|
204 |
||
205 |
if ( 'object' == typeof r && r.responses[0] ) { |
|
206 |
$('#the-comment-list').append( r.responses[0].data ); |
|
207 |
||
208 |
theList = theExtraList = null; |
|
209 |
$("a[className*=':']").unbind(); |
|
210 |
||
211 |
if ( commentsBox.st > commentsBox.total ) |
|
212 |
$('#show-comments').hide(); |
|
213 |
else |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
214 |
$('#show-comments').show().children('a').html(postL10n.showcomm); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
215 |
|
136 | 216 |
return; |
217 |
} else if ( 1 == r ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
218 |
$('#show-comments').html(postL10n.endcomm); |
136 | 219 |
return; |
220 |
} |
|
221 |
||
222 |
$('#the-comment-list').append('<tr><td colspan="2">'+wpAjax.broken+'</td></tr>'); |
|
223 |
} |
|
224 |
); |
|
225 |
||
226 |
return false; |
|
227 |
} |
|
228 |
}; |
|
229 |
||
230 |
WPSetThumbnailHTML = function(html){ |
|
231 |
$('.inside', '#postimagediv').html(html); |
|
232 |
}; |
|
233 |
||
234 |
WPSetThumbnailID = function(id){ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
235 |
var field = $('input[value="_thumbnail_id"]', '#list-table'); |
136 | 236 |
if ( field.size() > 0 ) { |
237 |
$('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id); |
|
238 |
} |
|
239 |
}; |
|
240 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
241 |
WPRemoveThumbnail = function(nonce){ |
136 | 242 |
$.post(ajaxurl, { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
243 |
action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie) |
136 | 244 |
}, function(str){ |
245 |
if ( str == '0' ) { |
|
246 |
alert( setPostThumbnailL10n.error ); |
|
247 |
} else { |
|
248 |
WPSetThumbnailHTML(str); |
|
249 |
} |
|
250 |
} |
|
251 |
); |
|
252 |
}; |
|
253 |
||
254 |
})(jQuery); |
|
255 |
||
256 |
jQuery(document).ready( function($) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
257 |
var stamp, visibility, sticky = '', last = 0, co = $('#content'); |
136 | 258 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
259 |
postboxes.add_postbox_toggles(pagenow); |
136 | 260 |
|
261 |
// multi-taxonomies |
|
262 |
if ( $('#tagsdiv-post_tag').length ) { |
|
263 |
tagBox.init(); |
|
264 |
} else { |
|
265 |
$('#side-sortables, #normal-sortables, #advanced-sortables').children('div.postbox').each(function(){ |
|
266 |
if ( this.id.indexOf('tagsdiv-') === 0 ) { |
|
267 |
tagBox.init(); |
|
268 |
return false; |
|
269 |
} |
|
270 |
}); |
|
271 |
} |
|
272 |
||
273 |
// categories |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
274 |
$('.categorydiv').each( function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
275 |
var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, taxonomyParts, taxonomy, settingName; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
276 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
277 |
taxonomyParts = this_id.split('-'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
278 |
taxonomyParts.shift(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
279 |
taxonomy = taxonomyParts.join('-'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
280 |
settingName = taxonomy + '_tab'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
281 |
if ( taxonomy == 'category' ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
282 |
settingName = 'cats'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
283 |
|
136 | 284 |
// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.dev.js |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
285 |
$('a', '#' + taxonomy + '-tabs').click( function(){ |
136 | 286 |
var t = $(this).attr('href'); |
287 |
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs'); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
288 |
$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide(); |
136 | 289 |
$(t).show(); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
290 |
if ( '#' + taxonomy + '-all' == t ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
291 |
deleteUserSetting(settingName); |
136 | 292 |
else |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
293 |
setUserSetting(settingName, 'pop'); |
136 | 294 |
return false; |
295 |
}); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
296 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
297 |
if ( getUserSetting(settingName) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
298 |
$('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click(); |
136 | 299 |
|
300 |
// Ajax Cat |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
301 |
$('#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
302 |
$('#' + taxonomy + '-add-submit').click( function(){ $('#new' + taxonomy).focus(); }); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
303 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
304 |
syncChecks = function() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
305 |
if ( noSyncChecks ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
306 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
307 |
noSyncChecks = true; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
308 |
var th = jQuery(this), c = th.is(':checked'), id = th.val().toString(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
309 |
$('#in-' + taxonomy + '-' + id + ', #in-' + taxonomy + '-category-' + id).prop( 'checked', c ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
310 |
noSyncChecks = false; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
311 |
}; |
136 | 312 |
|
313 |
catAddBefore = function( s ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
314 |
if ( !$('#new'+taxonomy).val() ) |
136 | 315 |
return false; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
316 |
s.data += '&' + $( ':checked', '#'+taxonomy+'checklist' ).serialize(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
317 |
$( '#' + taxonomy + '-add-submit' ).prop( 'disabled', true ); |
136 | 318 |
return s; |
319 |
}; |
|
320 |
||
321 |
catAddAfter = function( r, s ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
322 |
var sup, drop = $('#new'+taxonomy+'_parent'); |
136 | 323 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
324 |
$( '#' + taxonomy + '-add-submit' ).prop( 'disabled', false ); |
136 | 325 |
if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) { |
326 |
drop.before(sup); |
|
327 |
drop.remove(); |
|
328 |
} |
|
329 |
}; |
|
330 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
331 |
$('#' + taxonomy + 'checklist').wpList({ |
136 | 332 |
alt: '', |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
333 |
response: taxonomy + '-ajax-response', |
136 | 334 |
addBefore: catAddBefore, |
335 |
addAfter: catAddAfter |
|
336 |
}); |
|
337 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
338 |
$('#' + taxonomy + '-add-toggle').click( function() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
339 |
$('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
340 |
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
341 |
$('#new'+taxonomy).focus(); |
136 | 342 |
return false; |
343 |
}); |
|
344 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
345 |
$('#' + taxonomy + 'checklist li.popular-category input[type="checkbox"], #' + taxonomy + 'checklist-pop input[type="checkbox"]').live( 'click', function(){ |
136 | 346 |
var t = $(this), c = t.is(':checked'), id = t.val(); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
347 |
if ( id && t.parents('#taxonomy-'+taxonomy).length ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
348 |
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c ); |
136 | 349 |
}); |
350 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
351 |
}); // end cats |
136 | 352 |
|
353 |
// Custom Fields |
|
354 |
if ( $('#postcustom').length ) { |
|
355 |
$('#the-list').wpList( { addAfter: function( xml, s ) { |
|
356 |
$('table#list-table').show(); |
|
357 |
}, addBefore: function( s ) { |
|
358 |
s.data += '&post_id=' + $('#post_ID').val(); |
|
359 |
return s; |
|
360 |
} |
|
361 |
}); |
|
362 |
} |
|
363 |
||
364 |
// submitdiv |
|
365 |
if ( $('#submitdiv').length ) { |
|
366 |
stamp = $('#timestamp').html(); |
|
367 |
visibility = $('#post-visibility-display').html(); |
|
368 |
||
369 |
function updateVisibility() { |
|
370 |
var pvSelect = $('#post-visibility-select'); |
|
371 |
if ( $('input:radio:checked', pvSelect).val() != 'public' ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
372 |
$('#sticky').prop('checked', false); |
136 | 373 |
$('#sticky-span').hide(); |
374 |
} else { |
|
375 |
$('#sticky-span').show(); |
|
376 |
} |
|
377 |
if ( $('input:radio:checked', pvSelect).val() != 'password' ) { |
|
378 |
$('#password-span').hide(); |
|
379 |
} else { |
|
380 |
$('#password-span').show(); |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
function updateText() { |
|
385 |
var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'), |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
386 |
optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(), |
136 | 387 |
mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); |
388 |
||
389 |
attemptedDate = new Date( aa, mm - 1, jj, hh, mn ); |
|
390 |
originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() ); |
|
391 |
currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() ); |
|
392 |
||
393 |
if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) { |
|
394 |
$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid'); |
|
395 |
return false; |
|
396 |
} else { |
|
397 |
$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid'); |
|
398 |
} |
|
399 |
||
400 |
if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { |
|
401 |
publishOn = postL10n.publishOnFuture; |
|
402 |
$('#publish').val( postL10n.schedule ); |
|
403 |
} else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { |
|
404 |
publishOn = postL10n.publishOn; |
|
405 |
$('#publish').val( postL10n.publish ); |
|
406 |
} else { |
|
407 |
publishOn = postL10n.publishOnPast; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
408 |
$('#publish').val( postL10n.update ); |
136 | 409 |
} |
410 |
if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack |
|
411 |
$('#timestamp').html(stamp); |
|
412 |
} else { |
|
413 |
$('#timestamp').html( |
|
414 |
publishOn + ' <b>' + |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
415 |
$('option[value="' + $('#mm').val() + '"]', '#mm').text() + ' ' + |
136 | 416 |
jj + ', ' + |
417 |
aa + ' @ ' + |
|
418 |
hh + ':' + |
|
419 |
mn + '</b> ' |
|
420 |
); |
|
421 |
} |
|
422 |
||
423 |
if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
424 |
$('#publish').val( postL10n.update ); |
136 | 425 |
if ( optPublish.length == 0 ) { |
426 |
postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); |
|
427 |
} else { |
|
428 |
optPublish.html( postL10n.privatelyPublished ); |
|
429 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
430 |
$('option[value="publish"]', postStatus).prop('selected', true); |
136 | 431 |
$('.edit-post-status', '#misc-publishing-actions').hide(); |
432 |
} else { |
|
433 |
if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { |
|
434 |
if ( optPublish.length ) { |
|
435 |
optPublish.remove(); |
|
436 |
postStatus.val($('#hidden_post_status').val()); |
|
437 |
} |
|
438 |
} else { |
|
439 |
optPublish.html( postL10n.published ); |
|
440 |
} |
|
441 |
if ( postStatus.is(':hidden') ) |
|
442 |
$('.edit-post-status', '#misc-publishing-actions').show(); |
|
443 |
} |
|
444 |
$('#post-status-display').html($('option:selected', postStatus).text()); |
|
445 |
if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) { |
|
446 |
$('#save-post').hide(); |
|
447 |
} else { |
|
448 |
$('#save-post').show(); |
|
449 |
if ( $('option:selected', postStatus).val() == 'pending' ) { |
|
450 |
$('#save-post').show().val( postL10n.savePending ); |
|
451 |
} else { |
|
452 |
$('#save-post').show().val( postL10n.saveDraft ); |
|
453 |
} |
|
454 |
} |
|
455 |
return true; |
|
456 |
} |
|
457 |
||
458 |
$('.edit-visibility', '#visibility').click(function () { |
|
459 |
if ($('#post-visibility-select').is(":hidden")) { |
|
460 |
updateVisibility(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
461 |
$('#post-visibility-select').slideDown('fast'); |
136 | 462 |
$(this).hide(); |
463 |
} |
|
464 |
return false; |
|
465 |
}); |
|
466 |
||
467 |
$('.cancel-post-visibility', '#post-visibility-select').click(function () { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
468 |
$('#post-visibility-select').slideUp('fast'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
469 |
$('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true); |
136 | 470 |
$('#post_password').val($('#hidden_post_password').val()); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
471 |
$('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked')); |
136 | 472 |
$('#post-visibility-display').html(visibility); |
473 |
$('.edit-visibility', '#visibility').show(); |
|
474 |
updateText(); |
|
475 |
return false; |
|
476 |
}); |
|
477 |
||
478 |
$('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels |
|
479 |
var pvSelect = $('#post-visibility-select'); |
|
480 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
481 |
pvSelect.slideUp('fast'); |
136 | 482 |
$('.edit-visibility', '#visibility').show(); |
483 |
updateText(); |
|
484 |
||
485 |
if ( $('input:radio:checked', pvSelect).val() != 'public' ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
486 |
$('#sticky').prop('checked', false); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
487 |
} // WEAPON LOCKED |
136 | 488 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
489 |
if ( true == $('#sticky').prop('checked') ) { |
136 | 490 |
sticky = 'Sticky'; |
491 |
} else { |
|
492 |
sticky = ''; |
|
493 |
} |
|
494 |
||
495 |
$('#post-visibility-display').html( postL10n[$('input:radio:checked', pvSelect).val() + sticky] ); |
|
496 |
return false; |
|
497 |
}); |
|
498 |
||
499 |
$('input:radio', '#post-visibility-select').change(function() { |
|
500 |
updateVisibility(); |
|
501 |
}); |
|
502 |
||
503 |
$('#timestampdiv').siblings('a.edit-timestamp').click(function() { |
|
504 |
if ($('#timestampdiv').is(":hidden")) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
505 |
$('#timestampdiv').slideDown('fast'); |
136 | 506 |
$(this).hide(); |
507 |
} |
|
508 |
return false; |
|
509 |
}); |
|
510 |
||
511 |
$('.cancel-timestamp', '#timestampdiv').click(function() { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
512 |
$('#timestampdiv').slideUp('fast'); |
136 | 513 |
$('#mm').val($('#hidden_mm').val()); |
514 |
$('#jj').val($('#hidden_jj').val()); |
|
515 |
$('#aa').val($('#hidden_aa').val()); |
|
516 |
$('#hh').val($('#hidden_hh').val()); |
|
517 |
$('#mn').val($('#hidden_mn').val()); |
|
518 |
$('#timestampdiv').siblings('a.edit-timestamp').show(); |
|
519 |
updateText(); |
|
520 |
return false; |
|
521 |
}); |
|
522 |
||
523 |
$('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels |
|
524 |
if ( updateText() ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
525 |
$('#timestampdiv').slideUp('fast'); |
136 | 526 |
$('#timestampdiv').siblings('a.edit-timestamp').show(); |
527 |
} |
|
528 |
return false; |
|
529 |
}); |
|
530 |
||
531 |
$('#post-status-select').siblings('a.edit-post-status').click(function() { |
|
532 |
if ($('#post-status-select').is(":hidden")) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
533 |
$('#post-status-select').slideDown('fast'); |
136 | 534 |
$(this).hide(); |
535 |
} |
|
536 |
return false; |
|
537 |
}); |
|
538 |
||
539 |
$('.save-post-status', '#post-status-select').click(function() { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
540 |
$('#post-status-select').slideUp('fast'); |
136 | 541 |
$('#post-status-select').siblings('a.edit-post-status').show(); |
542 |
updateText(); |
|
543 |
return false; |
|
544 |
}); |
|
545 |
||
546 |
$('.cancel-post-status', '#post-status-select').click(function() { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
547 |
$('#post-status-select').slideUp('fast'); |
136 | 548 |
$('#post_status').val($('#hidden_post_status').val()); |
549 |
$('#post-status-select').siblings('a.edit-post-status').show(); |
|
550 |
updateText(); |
|
551 |
return false; |
|
552 |
}); |
|
553 |
} // end submitdiv |
|
554 |
||
555 |
// permalink |
|
556 |
if ( $('#edit-slug-box').length ) { |
|
557 |
editPermalink = function(post_id) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
558 |
var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html(); |
136 | 559 |
|
560 |
$('#view-post-btn').hide(); |
|
561 |
b.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); |
|
562 |
b.children('.save').click(function() { |
|
563 |
var new_slug = e.children('input').val(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
564 |
if ( new_slug == $('#editable-post-name-full').text() ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
565 |
return $('.cancel', '#edit-slug-buttons').click(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
566 |
} |
136 | 567 |
$.post(ajaxurl, { |
568 |
action: 'sample-permalink', |
|
569 |
post_id: post_id, |
|
570 |
new_slug: new_slug, |
|
571 |
new_title: $('#title').val(), |
|
572 |
samplepermalinknonce: $('#samplepermalinknonce').val() |
|
573 |
}, function(data) { |
|
574 |
$('#edit-slug-box').html(data); |
|
575 |
b.html(revert_b); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
576 |
real_slug.val(new_slug); |
136 | 577 |
makeSlugeditClickable(); |
578 |
$('#view-post-btn').show(); |
|
579 |
}); |
|
580 |
return false; |
|
581 |
}); |
|
582 |
||
583 |
$('.cancel', '#edit-slug-buttons').click(function() { |
|
584 |
$('#view-post-btn').show(); |
|
585 |
e.html(revert_e); |
|
586 |
b.html(revert_b); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
587 |
real_slug.val(revert_slug); |
136 | 588 |
return false; |
589 |
}); |
|
590 |
||
591 |
for ( i = 0; i < full.length; ++i ) { |
|
592 |
if ( '%' == full.charAt(i) ) |
|
593 |
c++; |
|
594 |
} |
|
595 |
||
596 |
slug_value = ( c > full.length / 4 ) ? '' : full; |
|
597 |
e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){ |
|
598 |
var key = e.keyCode || 0; |
|
599 |
// on enter, just save the new slug, don't save the post |
|
600 |
if ( 13 == key ) { |
|
601 |
b.children('.save').click(); |
|
602 |
return false; |
|
603 |
} |
|
604 |
if ( 27 == key ) { |
|
605 |
b.children('.cancel').click(); |
|
606 |
return false; |
|
607 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
608 |
real_slug.val(this.value); |
136 | 609 |
}).focus(); |
610 |
} |
|
611 |
||
612 |
makeSlugeditClickable = function() { |
|
613 |
$('#editable-post-name').click(function() { |
|
614 |
$('#edit-slug-buttons').children('.edit-slug').click(); |
|
615 |
}); |
|
616 |
} |
|
617 |
makeSlugeditClickable(); |
|
618 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
619 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
620 |
// word count |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
621 |
if ( typeof(wpWordCount) != 'undefined' ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
622 |
$(document).triggerHandler('wpcountwords', [ co.val() ]); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
623 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
624 |
co.keyup( function(e) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
625 |
var k = e.keyCode || e.charCode; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
626 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
627 |
if ( k == last ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
628 |
return true; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
629 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
630 |
if ( 13 == k || 8 == last || 46 == last ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
631 |
$(document).triggerHandler('wpcountwords', [ co.val() ]); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
632 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
633 |
last = k; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
634 |
return true; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
635 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
636 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
637 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
638 |
wptitlehint = function(id) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
639 |
id = id || 'title'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
640 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
641 |
var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
642 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
643 |
if ( title.val() == '' ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
644 |
titleprompt.css('visibility', ''); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
645 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
646 |
titleprompt.click(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
647 |
$(this).css('visibility', 'hidden'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
648 |
title.focus(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
649 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
650 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
651 |
title.blur(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
652 |
if ( this.value == '' ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
653 |
titleprompt.css('visibility', ''); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
654 |
}).focus(function(){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
655 |
titleprompt.css('visibility', 'hidden'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
656 |
}).keydown(function(e){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
657 |
titleprompt.css('visibility', 'hidden'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
658 |
$(this).unbind(e); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
659 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
660 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
661 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
662 |
wptitlehint(); |
136 | 663 |
}); |