Dotclear

source: admin/js/_post.js @ 3241:5ea4e5d537c8

Revision 3241:5ea4e5d537c8, 5.4 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Fix mixed-content preview

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

Sites map