Dotclear

source: admin/js/_post.js @ 3368:bb25979b0371

Revision 3368:bb25979b0371, 5.5 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Replace old jQuery modal js code by the Magnific-Popup responsive jQuery plugin ( http://dimsemenov.com/plugins/magnific-popup/, MIT Licence)

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

Sites map