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

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
[3139]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     }
[1525]69
[0]70     // Tabs events
71     $('#edit-entry').onetabload(function() {
72          dotclear.hideLockable();
[1525]73
[0]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();
[1525]78
[0]79          // Confirm post deletion
80          $('input[name="delete"]').click(function() {
[1606]81               return window.confirm(dotclear.msg.confirm_delete_post);
[0]82          });
[1525]83
[0]84          // Hide some fields
85          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{
[1699]86               user_pref: 'dcx_post_notes',
[1606]87               legend_click:true,
[1562]88               hide: $('#post_notes').val() == ''
[0]89          });
[1606]90          $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{
[1699]91               user_pref: 'dcx_post_lang',
[1606]92               legend_click: true
93          });
94          $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{
[1699]95               user_pref: 'dcx_post_password',
[1606]96               legend_click: true,
[1562]97               hide: $('#post_password').val() == ''
[0]98          });
[1606]99          $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{
[1699]100               user_pref: 'dcx_post_status',
[1606]101               legend_click: true
[1392]102          });
[1606]103          $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{
[1699]104               user_pref: 'dcx_post_dt',
[1606]105               legend_click: true
[1392]106          });
[1619]107          $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{
[1699]108               user_pref: 'dcx_post_format',
[1606]109               legend_click: true
[1392]110          });
[1935]111          $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{
112               user_pref: 'dcx_cat_id',
[1606]113               legend_click: true
[1392]114          });
[1936]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          });
[1711]119          $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{
[1717]120               user_pref: 'dcx_comment_tb',
[1711]121               legend_click: true
122          });
[1606]123          $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{
[1699]124               user_pref: 'post_url',
[1606]125               legend_click: true
[1392]126          });
[0]127          // We load toolbar on excerpt only when it's ready
128          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{
[1699]129               user_pref: 'dcx_post_excerpt',
[1638]130               legend_click: true,
[0]131               hide: $('#post_excerpt').val() == ''
132          });
[1525]133
[0]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     });
[1525]146
[0]147     $('#comments').onetabload(function() {
[2531]148          $.expandContent({
149               lines:$('#form-comments .comments-list tr.line'),
150               callback:dotclear.viewCommentContent
[0]151          });
[2089]152          $('#form-comments .checkboxes-helpers').each(function() {
153               dotclear.checkboxesHelpers(this);
154          });
155
156          dotclear.commentsActionsHelper();
157     });
158
159     $('#trackbacks').onetabload(function() {
[2531]160          $.expandContent({
161               lines:$('#form-trackbacks .comments-list tr.line'),
162               callback:dotclear.viewCommentContent
[2089]163          });
164          $('#form-trackbacks .checkboxes-helpers').each(function() {
[0]165               dotclear.checkboxesHelpers(this);
166          });
[1525]167
[0]168          dotclear.commentsActionsHelper();
169     });
[1525]170
[0]171     $('#add-comment').onetabload(function() {
172          commentTb.draw('xhtml');
173     });
174});
Note: See TracBrowser for help on using the repository browser.

Sites map