Dotclear

source: admin/js/_post.js @ 3139:e5870553f829

Revision 3139:e5870553f829, 5.3 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Avoid mixed content (http vs https) for post/page preview: will open preview in another window if blog uri use  http:// protocol and admin uri use  https:// protocol

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

Sites map