| 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() + '" tabindex="3" />'); |
|---|
| 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 | } |
|---|
| 37 | |
|---|
| 38 | $('p.qinfo',f).remove(); |
|---|
| 39 | |
|---|
| 40 | $.post('services.php',params,function(data) { |
|---|
| 41 | if ($('rsp[status=failed]',data).length > 0) { |
|---|
| 42 | var msg = '<p class="qinfo"><strong>' + dotclear.msg.error + |
|---|
| 43 | '</strong> ' + $('rsp',data).text() + '</p>'; |
|---|
| 44 | } else { |
|---|
| 45 | var msg = '<p class="qinfo">' + dotclear.msg.entry_created + |
|---|
| 46 | ' - <a href="post.php?id=' + $('rsp>post',data).attr('id') + '">' + |
|---|
| 47 | dotclear.msg.edit_entry + '</a>'; |
|---|
| 48 | if ($('rsp>post',data).attr('post_status') == 1) { |
|---|
| 49 | msg += ' - <a href="' + $('rsp>post',data).attr('post_url') + '">' + |
|---|
| 50 | dotclear.msg.view_entry + '</a>'; |
|---|
| 51 | } |
|---|
| 52 | msg += '</p>'; |
|---|
| 53 | $('#post_title',f).val(''); |
|---|
| 54 | $('#post_content',f).val(''); |
|---|
| 55 | if (contentTb.getMode() == 'wysiwyg') { |
|---|
| 56 | contentTb.syncContents('textarea'); |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | $('fieldset',f).prepend(msg); |
|---|
| 61 | }); |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | // allow to hide quick entry div, and remember choice |
|---|
| 66 | $('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{ |
|---|
| 67 | cookie: 'dcx_quick_entry', |
|---|
| 68 | }); |
|---|
| 69 | }); |
|---|