[0] | 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()); |
---|
[234] | 6 | |
---|
[0] | 7 | $('input[name=save]',f).click(function() { |
---|
| 8 | quickPost(f,-2); |
---|
| 9 | return false; |
---|
| 10 | }); |
---|
[234] | 11 | |
---|
[0] | 12 | if ($('input[name=save-publish]',f).length > 0) { |
---|
[454] | 13 | var btn = $('<input type="submit" value="' + $('input[name=save-publish]',f).val() + '" />'); |
---|
[0] | 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 | } |
---|
[234] | 21 | |
---|
[0] | 22 | function quickPost(f,status) { |
---|
| 23 | if (contentTb.getMode() == 'wysiwyg') { |
---|
| 24 | contentTb.syncContents('iframe'); |
---|
| 25 | } |
---|
[234] | 26 | |
---|
[0] | 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(), |
---|
[1500] | 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() |
---|
[0] | 38 | } |
---|
[234] | 39 | |
---|
[0] | 40 | $('p.qinfo',f).remove(); |
---|
[234] | 41 | |
---|
[0] | 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 | } |
---|
[1500] | 60 | $('#cat_id',f).val('0'); |
---|
| 61 | $('#new_cat_title',f).val(''); |
---|
| 62 | $('#new_cat_parent',f).val('0'); |
---|
[0] | 63 | } |
---|
[234] | 64 | |
---|
[0] | 65 | $('fieldset',f).prepend(msg); |
---|
| 66 | }); |
---|
| 67 | } |
---|
[1418] | 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 | ); |
---|
[0] | 72 | } |
---|
[234] | 73 | |
---|
[0] | 74 | // allow to hide quick entry div, and remember choice |
---|
| 75 | $('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{ |
---|
[314] | 76 | cookie: 'dcx_quick_entry' |
---|
[1140] | 77 | }); |
---|
[234] | 78 | }); |
---|