Dotclear

source: admin/js/_post.js @ 2614:db6f6a1f4f25

Revision 2614:db6f6a1f4f25, 4.8 KB checked in by Nicolas <nikrou77@…>, 12 years ago (diff)

Move legacy editor to a plugin. First step for alternate editors.
Addresses #1896

Line 
1dotclear.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     // Post preview
54     $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40);
55
56     // Tabs events
57     $('#edit-entry').onetabload(function() {
58          dotclear.hideLockable();
59
60          // Add date picker
61          var post_dtPick = new datePicker($('#post_dt').get(0));
62          post_dtPick.img_top = '1.5em';
63          post_dtPick.draw();
64
65          // Confirm post deletion
66          $('input[name="delete"]').click(function() {
67               return window.confirm(dotclear.msg.confirm_delete_post);
68          });
69
70          // Hide some fields
71          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{
72               user_pref: 'dcx_post_notes',
73               legend_click:true,
74               hide: $('#post_notes').val() == ''
75          });
76          $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{
77               user_pref: 'dcx_post_lang',
78               legend_click: true
79          });
80          $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{
81               user_pref: 'dcx_post_password',
82               legend_click: true,
83               hide: $('#post_password').val() == ''
84          });
85          $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{
86               user_pref: 'dcx_post_status',
87               legend_click: true
88          });
89          $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{
90               user_pref: 'dcx_post_dt',
91               legend_click: true
92          });
93          $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{
94               user_pref: 'dcx_post_format',
95               legend_click: true
96          });
97          $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{
98               user_pref: 'dcx_cat_id',
99               legend_click: true
100          });
101          $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{
102               // no cookie on new category as we don't use this every day
103               legend_click: true
104          });
105          $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{
106               user_pref: 'dcx_comment_tb',
107               legend_click: true
108          });
109          $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{
110               user_pref: 'post_url',
111               legend_click: true
112          });
113          // We load toolbar on excerpt only when it's ready
114          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{
115               user_pref: 'dcx_post_excerpt',
116               legend_click: true,
117               hide: $('#post_excerpt').val() == ''
118          });
119
120          // Replace attachment remove links by a POST form submit
121          $('a.attachment-remove').click(function() {
122               this.href = '';
123               var m_name = $(this).parents('ul').find('li:first>a').attr('title');
124               if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) {
125                    var f = $('#attachment-remove-hide').get(0);
126                    f.elements['media_id'].value = this.id.substring(11);
127                    f.submit();
128               }
129               return false;
130          });
131     });
132
133     $('#comments').onetabload(function() {
134          $.expandContent({
135               lines:$('#form-comments .comments-list tr.line'),
136               callback:dotclear.viewCommentContent
137          });
138          $('#form-comments .checkboxes-helpers').each(function() {
139               dotclear.checkboxesHelpers(this);
140          });
141
142          dotclear.commentsActionsHelper();
143     });
144
145     $('#trackbacks').onetabload(function() {
146          $.expandContent({
147               lines:$('#form-trackbacks .comments-list tr.line'),
148               callback:dotclear.viewCommentContent
149          });
150          $('#form-trackbacks .checkboxes-helpers').each(function() {
151               dotclear.checkboxesHelpers(this);
152          });
153
154          dotclear.commentsActionsHelper();
155     });
156
157     $('#add-comment').onetabload(function() {
158          commentTb.draw('xhtml');
159     });
160});
Note: See TracBrowser for help on using the repository browser.

Sites map