1 | dotclear.viewCommentContent = function(line,action) { |
---|
2 | var commentId = $(line).attr('id').substr(1); |
---|
3 | var tr = document.getElementById('ce'+commentId); |
---|
4 | |
---|
5 | if (!tr) { |
---|
6 | tr = document.createElement('tr'); |
---|
7 | tr.id = 'ce'+commentId; |
---|
8 | var td = document.createElement('td'); |
---|
9 | td.colSpan = 6; |
---|
10 | td.className = 'expand'; |
---|
11 | tr.appendChild(td); |
---|
12 | |
---|
13 | // Get comment content |
---|
14 | $.get('services.php',{f:'getCommentById',id: commentId},function(data) { |
---|
15 | var rsp = $(data).children('rsp')[0]; |
---|
16 | |
---|
17 | if (rsp.attributes[0].value == 'ok') { |
---|
18 | var comment = $(rsp).find('comment_display_content').text(); |
---|
19 | |
---|
20 | if (comment) { |
---|
21 | $(td).append(comment); |
---|
22 | var comment_email = $(rsp).find('comment_email').text(); |
---|
23 | var comment_site = $(rsp).find('comment_site').text(); |
---|
24 | var comment_ip = $(rsp).find('comment_ip').text(); |
---|
25 | var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); |
---|
26 | |
---|
27 | $(td).append('<p><strong>' + dotclear.msg.website + |
---|
28 | '</strong> ' + comment_site + '<br />' + |
---|
29 | '<strong>' + dotclear.msg.email + '</strong> ' + |
---|
30 | comment_email + '<br />' + comment_spam_disp + '</p>'); |
---|
31 | } |
---|
32 | } else { |
---|
33 | alert($(rsp).find('message').text()); |
---|
34 | } |
---|
35 | }); |
---|
36 | |
---|
37 | $(line).toggleClass('expand'); |
---|
38 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
39 | } |
---|
40 | else if (tr.style.display == 'none') |
---|
41 | { |
---|
42 | $(tr).toggle(); |
---|
43 | $(line).toggleClass('expand'); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | $(tr).toggle(); |
---|
48 | $(line).toggleClass('expand'); |
---|
49 | } |
---|
50 | }; |
---|
51 | |
---|
52 | $(function() { |
---|
53 | if (!document.getElementById) { return; } |
---|
54 | |
---|
55 | if (document.getElementById('edit-entry')) |
---|
56 | { |
---|
57 | // Get document format and prepare toolbars |
---|
58 | var formatField = $('#post_format').get(0); |
---|
59 | var last_post_format = $(formatField).val(); |
---|
60 | $(formatField).change(function() { |
---|
61 | // Confirm post format change |
---|
62 | if(window.confirm(dotclear.msg.confirm_change_post_format_noconvert)){ |
---|
63 | excerptTb.switchMode(this.value); |
---|
64 | contentTb.switchMode(this.value); |
---|
65 | last_post_format = $(this).val(); |
---|
66 | }else{ |
---|
67 | // Restore last format if change cancelled |
---|
68 | $(this).val(last_post_format); |
---|
69 | } |
---|
70 | |
---|
71 | $('.format_control > *').addClass('hide'); |
---|
72 | $('.format_control:not(.control_no_'+$(this).val()+') > *').removeClass('hide'); |
---|
73 | }); |
---|
74 | |
---|
75 | var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); |
---|
76 | var contentTb = new jsToolBar(document.getElementById('post_content')); |
---|
77 | excerptTb.context = contentTb.context = 'post'; |
---|
78 | } |
---|
79 | |
---|
80 | if (document.getElementById('comment_content')) { |
---|
81 | var commentTb = new jsToolBar(document.getElementById('comment_content')); |
---|
82 | commentTb.draw('xhtml'); |
---|
83 | } |
---|
84 | |
---|
85 | // Post preview |
---|
86 | $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); |
---|
87 | |
---|
88 | // Tabs events |
---|
89 | $('#edit-entry').onetabload(function() { |
---|
90 | dotclear.hideLockable(); |
---|
91 | |
---|
92 | // Add date picker |
---|
93 | var post_dtPick = new datePicker($('#post_dt').get(0)); |
---|
94 | post_dtPick.img_top = '1.5em'; |
---|
95 | post_dtPick.draw(); |
---|
96 | |
---|
97 | // Confirm post deletion |
---|
98 | $('input[name="delete"]').click(function() { |
---|
99 | return window.confirm(dotclear.msg.confirm_delete_post); |
---|
100 | }); |
---|
101 | |
---|
102 | // Markup validator |
---|
103 | var v = $('<div class="format_control"><p><a id="a-validator"></a></p><div/>').get(0); |
---|
104 | $('.format_control').before(v); |
---|
105 | var a = $('#a-validator').get(0); |
---|
106 | a.href = '#'; |
---|
107 | a.className = 'button '; |
---|
108 | $(a).click(function() { |
---|
109 | |
---|
110 | excerpt_content = $('#post_excerpt').css('display') != 'none' ? $('#post_excerpt').val() : $('#excerpt-area iframe').contents().find('body').html(); |
---|
111 | post_content = $('#post_content').css('display') != 'none' ? $('#post_content').val() : $('#content-area iframe').contents().find('body').html(); |
---|
112 | |
---|
113 | var params = { |
---|
114 | xd_check: dotclear.nonce, |
---|
115 | f: 'validatePostMarkup', |
---|
116 | excerpt: excerpt_content, |
---|
117 | content: post_content, |
---|
118 | format: $('#post_format').get(0).value, |
---|
119 | lang: $('#post_lang').get(0).value |
---|
120 | }; |
---|
121 | |
---|
122 | $.post('services.php',params,function(data) { |
---|
123 | if ($(data).find('rsp').attr('status') != 'ok') { |
---|
124 | alert($(data).find('rsp message').text()); |
---|
125 | return false; |
---|
126 | } |
---|
127 | |
---|
128 | $('.message, .success, .error, .warning-msg').remove(); |
---|
129 | |
---|
130 | if ($(data).find('valid').text() == 1) { |
---|
131 | var p = document.createElement('p'); |
---|
132 | p.id = 'markup-validator'; |
---|
133 | |
---|
134 | $(p).addClass('success'); |
---|
135 | $(p).text(dotclear.msg.xhtml_valid); |
---|
136 | $('#entry-content h3').after(p); |
---|
137 | $(p).backgroundFade({sColor: dotclear.fadeColor.beginValidatorMsg, eColor: dotclear.fadeColor.endValidatorMsg, steps: 50},function() { |
---|
138 | $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorMsg, eColor: dotclear.fadeColor.beginValidatorMsg}); |
---|
139 | }); |
---|
140 | } else { |
---|
141 | var div = document.createElement('div'); |
---|
142 | div.id = 'markup-validator'; |
---|
143 | |
---|
144 | $(div).addClass('error'); |
---|
145 | $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); |
---|
146 | $('#entry-content h3').after(div); |
---|
147 | $(div).backgroundFade({sColor: dotclear.fadeColor.beginValidatorErr,eColor: dotclear.fadeColor.endValidatorErr, steps: 50},function() { |
---|
148 | $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorErr, eColor: dotclear.fadeColor.beginValidatorErr}); |
---|
149 | }); |
---|
150 | } |
---|
151 | |
---|
152 | if ( $('#post_excerpt').text() != excerpt_content || $('#post_content').text() != post_content ) { |
---|
153 | var pn = document.createElement('p'); |
---|
154 | $(pn).addClass('warning-msg'); |
---|
155 | $(pn).text(dotclear.msg.warning_validate_no_save_content); |
---|
156 | $('#entry-content h3').after(pn); |
---|
157 | } |
---|
158 | |
---|
159 | return false; |
---|
160 | }); |
---|
161 | |
---|
162 | return false; |
---|
163 | }); |
---|
164 | |
---|
165 | a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); |
---|
166 | |
---|
167 | $('.format_control > *').addClass('hide'); |
---|
168 | $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); |
---|
169 | |
---|
170 | // Hide some fields |
---|
171 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
---|
172 | user_pref: 'dcx_post_notes', |
---|
173 | legend_click:true, |
---|
174 | hide: $('#post_notes').val() == '' |
---|
175 | }); |
---|
176 | $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ |
---|
177 | user_pref: 'dcx_post_lang', |
---|
178 | legend_click: true |
---|
179 | }); |
---|
180 | $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ |
---|
181 | user_pref: 'dcx_post_password', |
---|
182 | legend_click: true, |
---|
183 | hide: $('#post_password').val() == '' |
---|
184 | }); |
---|
185 | $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ |
---|
186 | user_pref: 'dcx_post_status', |
---|
187 | legend_click: true |
---|
188 | }); |
---|
189 | $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ |
---|
190 | user_pref: 'dcx_post_dt', |
---|
191 | legend_click: true |
---|
192 | }); |
---|
193 | $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ |
---|
194 | user_pref: 'dcx_post_format', |
---|
195 | legend_click: true |
---|
196 | }); |
---|
197 | $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ |
---|
198 | user_pref: 'dcx_cat_id', |
---|
199 | legend_click: true |
---|
200 | }); |
---|
201 | $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ |
---|
202 | // no cookie on new category as we don't use this every day |
---|
203 | legend_click: true |
---|
204 | }); |
---|
205 | $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ |
---|
206 | user_pref: 'dcx_comment_tb', |
---|
207 | legend_click: true |
---|
208 | }); |
---|
209 | $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ |
---|
210 | user_pref: 'post_url', |
---|
211 | legend_click: true |
---|
212 | }); |
---|
213 | // We load toolbar on excerpt only when it's ready |
---|
214 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
---|
215 | user_pref: 'dcx_post_excerpt', |
---|
216 | legend_click: true, |
---|
217 | hide: $('#post_excerpt').val() == '' |
---|
218 | }); |
---|
219 | |
---|
220 | // Load toolbars |
---|
221 | contentTb.switchMode(formatField.value); |
---|
222 | excerptTb.switchMode(formatField.value); |
---|
223 | |
---|
224 | // Replace attachment remove links by a POST form submit |
---|
225 | $('a.attachment-remove').click(function() { |
---|
226 | this.href = ''; |
---|
227 | var m_name = $(this).parents('ul').find('li:first>a').attr('title'); |
---|
228 | if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { |
---|
229 | var f = $('#attachment-remove-hide').get(0); |
---|
230 | f.elements['media_id'].value = this.id.substring(11); |
---|
231 | f.submit(); |
---|
232 | } |
---|
233 | return false; |
---|
234 | }); |
---|
235 | |
---|
236 | // Check unsaved changes before XHTML conversion |
---|
237 | var excerpt = $('#post_excerpt').val(); |
---|
238 | var content = $('#post_content').val(); |
---|
239 | $('#convert-xhtml').click(function() { |
---|
240 | if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { |
---|
241 | return window.confirm(dotclear.msg.confirm_change_post_format); |
---|
242 | } |
---|
243 | }); |
---|
244 | }); |
---|
245 | |
---|
246 | $('#comments').onetabload(function() { |
---|
247 | $.expandContent({ |
---|
248 | lines:$('#form-comments .comments-list tr.line'), |
---|
249 | callback:dotclear.viewCommentContent |
---|
250 | }); |
---|
251 | $('#form-comments .checkboxes-helpers').each(function() { |
---|
252 | dotclear.checkboxesHelpers(this); |
---|
253 | }); |
---|
254 | |
---|
255 | dotclear.commentsActionsHelper(); |
---|
256 | }); |
---|
257 | |
---|
258 | $('#trackbacks').onetabload(function() { |
---|
259 | $.expandContent({ |
---|
260 | lines:$('#form-trackbacks .comments-list tr.line'), |
---|
261 | callback:dotclear.viewCommentContent |
---|
262 | }); |
---|
263 | $('#form-trackbacks .checkboxes-helpers').each(function() { |
---|
264 | dotclear.checkboxesHelpers(this); |
---|
265 | }); |
---|
266 | |
---|
267 | dotclear.commentsActionsHelper(); |
---|
268 | }); |
---|
269 | |
---|
270 | $('#add-comment').onetabload(function() { |
---|
271 | commentTb.draw('xhtml'); |
---|
272 | }); |
---|
273 | }); |
---|