| 65 | | |
| 66 | | |
| 67 | | <script type="text/javascript" charset="utf-8"> |
| 68 | | function updateBlog(event) |
| 69 | | { |
| 70 | | if(event.target.name == 'select-<?php echo $form['categories_list']->renderName() ?>[]' && |
| 71 | | event.target.options[0].selected == true) |
| 72 | | { |
| 73 | | |
| 74 | | } |
| 75 | | else if(event.target.name == 'add-text') {} |
| 76 | | else |
| 77 | | { |
| 78 | | updateBlogForm('<?php echo url_for('a_blog_admin_update', $a_blog_post) ?>', event); |
| 79 | | } |
| 80 | | } |
| 81 | | |
| 82 | | $(document).ready(function(){ |
| 83 | | |
| 84 | | // Title Interface |
| 85 | | // ============================================= |
| 86 | | var titleInterface = $('#a_blog_post_title_interface'); |
| 87 | | var titlePlaceholder = $('#a-blog-post-title-placeholder'); |
| 88 | | var originalTitle = "<?php echo $a_blog_post->title ?>"; |
| 89 | | |
| 90 | | <?php if ($a_blog_post->title == 'untitled'): ?> |
| 91 | | titleInterface.focus(); // The blog post is 'Untitled' -- Focus the input |
| 92 | | <?php endif ?> |
| 93 | | |
| 94 | | // Title: On Change Compare |
| 95 | | titleInterface.change(function(){ |
| 96 | | if ($(this).val() != '') { // If the input is not empty |
| 97 | | $('#a_blog_post_title').val($(this).val()); // Pass the value to the admin form and update |
| 98 | | updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); |
| 99 | | }; |
| 100 | | }); |
| 101 | | |
| 102 | | titleInterface.blur(function(){ |
| 103 | | // Check for Empty Title Field |
| 104 | | if ($(this).val() == '') |
| 105 | | { |
| 106 | | $(this).next().show(); |
| 107 | | } |
| 108 | | }); |
| 109 | | |
| 110 | | titleInterface.focus(function(){ |
| 111 | | // Always hide the placeholder on focus |
| 112 | | $(this).next().hide(); |
| 113 | | }); |
| 114 | | |
| 115 | | titlePlaceholder.mousedown(function(){ |
| 116 | | // If you click the placeholder text |
| 117 | | // focus the input (Mousedown is faster than click here) |
| 118 | | titleInterface.focus(); |
| 119 | | }).hide(); |
| 120 | | |
| 121 | | // Permalink Interface |
| 122 | | // ============================================= |
| 123 | | var permalinkInterface = $('#a-blog-post-permalink-interface'); |
| 124 | | var pInput = permalinkInterface.find('input'); |
| 125 | | var pControls = permalinkInterface.find('ul.a-controls'); |
| 126 | | var originalSlug = '<?php echo $a_blog_post->slug ?>'; |
| 127 | | |
| 128 | | // Permalink: On Focus Listen for Changes |
| 129 | | pInput.focus(function(){ |
| 130 | | $(this).select(); |
| 131 | | $(this).keyup(function(){ |
| 132 | | if ($(this).val().trim() != originalSlug) |
| 133 | | { |
| 134 | | permalinkInterface.addClass('has-changes'); |
| 135 | | pControls.fadeIn(); |
| 136 | | } |
| 137 | | }); |
| 138 | | }); |
| 139 | | |
| 140 | | // Permalink Interface Controls: Save | Cancel |
| 141 | | // ============================================= |
| 142 | | pControls.click(function(event){ |
| 143 | | event.preventDefault(); |
| 144 | | $target = $(event.target); |
| 145 | | |
| 146 | | if ($target.hasClass('a-save')) |
| 147 | | { |
| 148 | | if (pInput.val() == '') { |
| 149 | | pInput.val(originalSlug); |
| 150 | | pControls.hide(); |
| 151 | | } |
| 152 | | if ((pInput.val() != '') && (pInput.val().trim() != originalSlug)) { |
| 153 | | $('#a_blog_post_slug').val(pInput.val()); // Pass the value to the admin form and update |
| 154 | | updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); |
| 155 | | } |
| 156 | | } |
| 157 | | |
| 158 | | if ($target.hasClass('a-cancel')) |
| 159 | | { |
| 160 | | pInput.val(originalSlug); |
| 161 | | pControls.hide(); |
| 162 | | } |
| 163 | | }); |
| 164 | | |
| 165 | | // Comments Toggle |
| 166 | | // ============================================= |
| 167 | | $('.section.comments a.allow_comments_toggle').click(function(event){ |
| 168 | | event.preventDefault(); |
| 169 | | toggleCheckbox($('#a_blog_post_allow_comments')); |
| 170 | | updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); |
| 171 | | }); |
| 172 | | |
| 173 | | }); |
| 174 | | </script> |