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

RevLine 
[2527]1dotclear.viewCommentContent = function(line,action) {
2     var commentId = $(line).attr('id').substr(1);
[0]3     var tr = document.getElementById('ce'+commentId);
[1525]4
[0]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);
[1525]12
[0]13          // Get comment content
14          $.get('services.php',{f:'getCommentById',id: commentId},function(data) {
15               var rsp = $(data).children('rsp')[0];
[1525]16
[0]17               if (rsp.attributes[0].value == 'ok') {
18                    var comment = $(rsp).find('comment_display_content').text();
[1525]19
[0]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();
[1525]26
[0]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          });
[1525]36
[0]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);
[1525]55
[0]56     // Tabs events
57     $('#edit-entry').onetabload(function() {
58          dotclear.hideLockable();
[1525]59
[0]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();
[1525]64
[0]65          // Confirm post deletion
66          $('input[name="delete"]').click(function() {
[1606]67               return window.confirm(dotclear.msg.confirm_delete_post);
[0]68          });
[1525]69
[0]70          // Hide some fields
71          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{
[1699]72               user_pref: 'dcx_post_notes',
[1606]73               legend_click:true,
[1562]74               hide: $('#post_notes').val() == ''
[0]75          });
[1606]76          $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{
[1699]77               user_pref: 'dcx_post_lang',
[1606]78               legend_click: true
79          });
80          $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{
[1699]81               user_pref: 'dcx_post_password',
[1606]82               legend_click: true,
[1562]83               hide: $('#post_password').val() == ''
[0]84          });
[1606]85          $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{
[1699]86               user_pref: 'dcx_post_status',
[1606]87               legend_click: true
[1392]88          });
[1606]89          $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{
[1699]90               user_pref: 'dcx_post_dt',
[1606]91               legend_click: true
[1392]92          });
[1619]93          $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{
[1699]94               user_pref: 'dcx_post_format',
[1606]95               legend_click: true
[1392]96          });
[1935]97          $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{
98               user_pref: 'dcx_cat_id',
[1606]99               legend_click: true
[1392]100          });
[1936]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          });
[1711]105          $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{
[1717]106               user_pref: 'dcx_comment_tb',
[1711]107               legend_click: true
108          });
[1606]109          $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{
[1699]110               user_pref: 'post_url',
[1606]111               legend_click: true
[1392]112          });
[0]113          // We load toolbar on excerpt only when it's ready
114          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{
[1699]115               user_pref: 'dcx_post_excerpt',
[1638]116               legend_click: true,
[0]117               hide: $('#post_excerpt').val() == ''
118          });
[1525]119
[0]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     });
[1525]132
[0]133     $('#comments').onetabload(function() {
[2531]134          $.expandContent({
135               lines:$('#form-comments .comments-list tr.line'),
136               callback:dotclear.viewCommentContent
[0]137          });
[2089]138          $('#form-comments .checkboxes-helpers').each(function() {
139               dotclear.checkboxesHelpers(this);
140          });
141
142          dotclear.commentsActionsHelper();
143     });
144
145     $('#trackbacks').onetabload(function() {
[2531]146          $.expandContent({
147               lines:$('#form-trackbacks .comments-list tr.line'),
148               callback:dotclear.viewCommentContent
[2089]149          });
150          $('#form-trackbacks .checkboxes-helpers').each(function() {
[0]151               dotclear.checkboxesHelpers(this);
152          });
[1525]153
[0]154          dotclear.commentsActionsHelper();
155     });
[1525]156
[0]157     $('#add-comment').onetabload(function() {
158          commentTb.draw('xhtml');
159     });
160});
Note: See TracBrowser for help on using the repository browser.

Sites map