Dotclear

source: admin/js/_index.js @ 2929:54d58ce46232

Revision 2929:54d58ce46232, 2.5 KB checked in by Dsls, 11 years ago (diff)

Quick entry deserves its post_format information, see #2047
Add trigger when emptying post-content (usefull for alternate editors)

Line 
1$(function() {
2     var f = $('#quick-entry');
3     if (f.length > 0) {
4          if ($.isFunction(jsToolBar)) {
5               var contentTb = new jsToolBar($('#post_content',f)[0]);
6               contentTb.switchMode($('#post_format',f).val());
7          }
8
9          $('input[name=save]',f).click(function() {
10               quickPost(f,-2);
11               return false;
12          });
13
14          if ($('input[name=save-publish]',f).length > 0) {
15               var btn = $('<input type="submit" value="' + $('input[name=save-publish]',f).val() + '" />');
16               $('input[name=save-publish]',f).remove();
17               $('input[name=save]',f).after(btn).after(' ');
18               btn.click(function() {
19                    quickPost(f,1);
20                    return false;
21               });
22          }
23
24          function quickPost(f,status) {
25               if ($.isFunction('jsToolBar') && (contentTb.getMode() == 'wysiwyg')) {
26                    contentTb.syncContents('iframe');
27               }
28
29               var params = {
30                    f: 'quickPost',
31                    xd_check: dotclear.nonce,
32                    post_title: $('#post_title',f).val(),
33                    post_content: $('#post_content',f).val(),
34                    cat_id: $('#cat_id',f).val(),
35                    post_status: status,
36                    post_format: $('#post_format',f).val(),
37                    post_lang: $('#post_lang',f).val(),
38                    new_cat_title: $('#new_cat_title',f).val(),
39                    new_cat_parent: $('#new_cat_parent',f).val()
40               }
41
42               $('p.qinfo',f).remove();
43
44               $.post('services.php',params,function(data) {
45                    if ($('rsp[status=failed]',data).length > 0) {
46                         var msg = '<p class="qinfo"><strong>' + dotclear.msg.error +
47                         '</strong> ' + $('rsp',data).text() + '</p>';
48                    } else {
49                         var msg = '<p class="qinfo">' + dotclear.msg.entry_created +
50                         ' - <a href="post.php?id=' + $('rsp>post',data).attr('id') + '">' +
51                         dotclear.msg.edit_entry + '</a>';
52                         if ($('rsp>post',data).attr('post_status') == 1) {
53                              msg += ' - <a href="' + $('rsp>post',data).attr('post_url') + '">' +
54                              dotclear.msg.view_entry + '</a>';
55                         }
56                         msg += '</p>';
57                         $('#post_title',f).val('');
58                         $('#post_content',f).val('');
59                         $('#post_content',f).change();
60                         if ($.isFunction('jsToolBar') &&  (contentTb.getMode() == 'wysiwyg')) {
61                              contentTb.syncContents('textarea');
62                         }
63                         $('#cat_id',f).val('0');
64                         $('#new_cat_title',f).val('');
65                         $('#new_cat_parent',f).val('0');
66                    }
67
68                    $('fieldset',f).prepend(msg);
69               });
70          }
71          $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), {
72               // no cookie on new category as we don't use this every day
73               legend_click: true
74          });
75     }
76
77     // allow to hide quick entry div, and remember choice
78     $('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{
79          legend_click: true,
80          user_pref: 'dcx_quick_entry'
81     });
82});
Note: See TracBrowser for help on using the repository browser.

Sites map