Dotclear

source: admin/js/_index.js @ 1500:555ae7c1320a

Revision 1500:555ae7c1320a, 2.3 KB checked in by Denis Jean-Christian <contact@…>, 12 years ago (diff)

Add missing javascript for new category on quickpost, fixes #1569

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

Sites map