Changeset 1109
- Timestamp:
- 04/30/10 16:15:13 (22 months ago)
- Location:
- plugins/apostropheBlogPlugin/trunk
- Files:
-
- 3 modified
-
modules/aBlogAdmin/templates/_form.php (modified) (2 diffs)
-
modules/aBlogAdmin/templates/editSuccess.php (modified) (1 diff)
-
web/js/aBlog.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostropheBlogPlugin/trunk/modules/aBlogAdmin/templates/_form.php
r1097 r1109 43 43 ?> 44 44 <ul class="a-controls published_at"> 45 <li><a href="#" onclick="checkAndSetPublish('<?php echo $ blog_post_url?>'); return false;" class="a-btn a-save"><?php echo __('Save', array(), 'apostrophe_blog') ?></a></li>46 <li><a href="#" onclick="checkAndSetPublish('<?php echo $ blog_post_url?>'); return false;" class="a-btn a-cancel"><?php echo __('Cancel', array(), 'apostrophe_blog') ?></a></li>45 <li><a href="#" onclick="checkAndSetPublish('<?php echo $a_blog_post->status ?>','<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); return false;" class="a-btn a-save"><?php echo __('Save', array(), 'apostrophe_blog') ?></a></li> 46 <li><a href="#" onclick="checkAndSetPublish('<?php echo $a_blog_post->status ?>','<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); return false;" class="a-btn a-cancel"><?php echo __('Cancel', array(), 'apostrophe_blog') ?></a></li> 47 47 </ul> 48 48 </div> … … 144 144 145 145 <script type="text/javascript" charset="utf-8"> 146 function updateBlogMulti() 147 { 148 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 149 } 146 147 function updateBlogMulti() { updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); } 150 148 151 $(document).ready(function(){ 152 153 $('#a-admin-form').change(function(event) { 154 updateBlog(event); 155 }); 149 $(document).ready(function(){ 150 151 $('#a-admin-form').change(function(event) { 152 if (!( event.target.className == 'a-multiple-select-input' && event.target.options[0].selected == true || event.target.name == 'add-text' )) 153 { 154 updateBlogForm('<?php echo url_for('a_blog_admin_update', $a_blog_post) ?>', event); 155 } 156 }); 156 157 157 checkAndSetPublish('<?php echo $a_blog_post->status ?>','<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 158 // Sidebar Toggle 159 // ============================================= 160 $('.a-sidebar-toggle').click(function(){ 161 $(this).toggleClass('open').next().toggle(); 162 }) 158 163 159 $('.a-sidebar-toggle').click(function(){ 160 $(this).toggleClass('open').next().toggle(); 161 }) 164 // Comments Toggle 165 // ============================================= 166 $('.section.comments a.allow_comments_toggle').click(function(event){ 167 event.preventDefault(); 168 toggleCheckbox($('#a_blog_post_allow_comments')); 169 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 170 }); 162 171 163 aMultipleSelect('#categories-section', { 'choose-one': '<?php echo __('Choose Categories', array(), 'apostrophe_blog') ?>', 'add': '<?php echo __('+ New Category', array(), 'apostrophe_blog') ?>', 'onChange': updateBlogMulti}); 164 aMultipleSelect('#editors-section', { 'choose-one': '<?php echo __('Choose Editors', array(), 'apostrophe_blog') ?>','onChange': updateBlogMulti }); 172 initTitle('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 173 initPermalink('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 174 checkAndSetPublish('<?php echo $a_blog_post->status ?>','<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 175 aMultipleSelect('#categories-section', { 'choose-one': '<?php echo __('Choose Categories', array(), 'apostrophe_blog') ?>', 'add': '<?php echo __('+ New Category', array(), 'apostrophe_blog') ?>', 'onChange': updateBlogMulti }); 176 aMultipleSelect('#editors-section', { 'choose-one': '<?php echo __('Choose Editors', array(), 'apostrophe_blog') ?>','onChange': updateBlogMulti }); 165 177 166 }); 178 }); 179 167 180 </script> -
plugins/apostropheBlogPlugin/trunk/modules/aBlogAdmin/templates/editSuccess.php
r1108 r1109 63 63 <?php //include_partial('aBlogAdmin/form_actions', array('a_blog_post' => $a_blog_post, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?> 64 64 </div> 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 else77 {78 updateBlogForm('<?php echo url_for('a_blog_admin_update', $a_blog_post) ?>', event);79 }80 }81 82 $(document).ready(function(){83 84 // Title Interface85 // =============================================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 input92 <?php endif ?>93 94 // Title: On Change Compare95 titleInterface.change(function(){96 if ($(this).val() != '') { // If the input is not empty97 $('#a_blog_post_title').val($(this).val()); // Pass the value to the admin form and update98 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>');99 };100 });101 102 titleInterface.blur(function(){103 // Check for Empty Title Field104 if ($(this).val() == '')105 {106 $(this).next().show();107 }108 });109 110 titleInterface.focus(function(){111 // Always hide the placeholder on focus112 $(this).next().hide();113 });114 115 titlePlaceholder.mousedown(function(){116 // If you click the placeholder text117 // focus the input (Mousedown is faster than click here)118 titleInterface.focus();119 }).hide();120 121 // Permalink Interface122 // =============================================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 Changes129 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 | Cancel141 // =============================================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 update154 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 Toggle166 // =============================================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> -
plugins/apostropheBlogPlugin/trunk/web/js/aBlog.js
r1096 r1109 1 // Publish / Unpublish Button2 1 function checkAndSetPublish(status, slug_url) 3 2 { … … 15 14 $(this).blur(); 16 15 17 if (status == 'draft') { 16 if (status == 'draft') 17 { 18 18 postStatus.val('published'); 19 19 publishButton.addClass('published'); … … 26 26 27 27 // If slug_url 28 if (typeof slug_url != 'undefined') { 28 if (typeof slug_url != 'undefined') 29 { 29 30 updateBlogForm(slug_url); 30 31 }; … … 32 33 }); 33 34 } 35 36 function initTitle(slug_url) 37 { 38 // Title Interface 39 // ============================================= 40 var titleInterface = $('#a_blog_post_title_interface'); 41 var titlePlaceholder = $('#a-blog-post-title-placeholder'); 42 var originalTitle = titleInterface.val(); 43 44 if (originalTitle == 'untitled') 45 { // The blog post is 'Untitled' -- Focus the input 46 titleInterface.focus(); 47 }; 48 49 // Title: On Change Compare 50 titleInterface.change(function(){ 51 if ($(this).val() != '') 52 { // If the input is not empty 53 // Pass the value to the admin form and update 54 $('#a_blog_post_title').val($(this).val()); 55 updateBlogForm(slug_url); 56 }; 57 }); 58 59 titleInterface.blur(function() 60 { // Check for Empty Title Field 61 if ($(this).val() == '') 62 { 63 $(this).next().show(); 64 } 65 }); 66 67 titleInterface.focus(function() 68 { // Always hide the placeholder on focus 69 $(this).next().hide(); 70 }); 71 72 titlePlaceholder.mousedown(function() 73 { // If you click the placeholder text 74 // focus the input (Mousedown is faster than click here) 75 titleInterface.focus(); 76 }).hide(); 77 } 78 79 function initPermalink(slug_url) 80 { 81 // Permalink Interface 82 // ============================================= 83 var permalinkInterface = $('#a-blog-post-permalink-interface'); 84 var pInput = permalinkInterface.find('input'); 85 var pControls = permalinkInterface.find('ul.a-controls'); 86 var originalSlug = pInput.val(); 87 88 // Permalink: On Focus Listen for Changes 89 pInput.focus(function(){ 90 $(this).select(); 91 $(this).keyup(function(){ 92 if ($(this).val().trim() != originalSlug) 93 { 94 permalinkInterface.addClass('has-changes'); 95 pControls.fadeIn(); 96 } 97 }); 98 }); 99 100 // Permalink Interface Controls: Save | Cancel 101 // ============================================= 102 pControls.click(function(event) 103 { 104 event.preventDefault(); 105 $target = $(event.target); 106 107 if ($target.hasClass('a-save')) 108 { 109 if (pInput.val() == '') 110 { 111 pInput.val(originalSlug); 112 pControls.hide(); 113 } 114 if ((pInput.val() != '') && (pInput.val().trim() != originalSlug)) 115 { 116 $('#a_blog_post_slug').val(pInput.val()); // Pass the value to the admin form and update 117 updateBlogForm(slug_url); 118 } 119 } 120 121 if ($target.hasClass('a-cancel')) 122 { 123 pInput.val(originalSlug); 124 pControls.hide(); 125 } 126 }); 127 } 128 34 129 35 130 // Ajax Update Blog Form … … 79 174 } 80 175 81 // Update Title Function for Ajax calls when it is returned clean from Apostrophe 176 82 177 function updateTitle(title, feedback) 83 { 84 var titleInput = $('#a_blog_post_title_interface'); 85 86 if (title != null) 87 { 88 titleInput.val(title); 89 }; 90 91 // sendUserMessage(feedback); // See sendUserMessage function below 92 } 93 94 // Update Slug Function for Ajax calls when it is returned clean from Apostrophe 178 { // Update Title Function for Ajax calls when it is returned clean from Apostrophe 179 var titleInput = $('#a_blog_post_title_interface'); 180 181 if (title != null) 182 { 183 titleInput.val(title); 184 }; 185 } 186 187 95 188 function updateSlug(slug, feedback) 96 { 97 var permalinkInput = $('#a_blog_post_permalink_interface'); 98 var slugInput = $('#a_blog_post_slug'); 99 if (slug != null) 100 { 101 permalinkInput.val(slug); 102 slugInput.val(slug); 103 }; 104 105 // sendUserMessage(feedback); // See sendUserMessage function below 106 } 107 108 // Update TitleAndSlug Function to save u time :D ! 189 { // Update Slug Function for Ajax calls when it is returned clean from Apostrophe 190 var permalinkInput = $('#a_blog_post_permalink_interface'); 191 var slugInput = $('#a_blog_post_slug'); 192 193 if (slug != null) 194 { 195 permalinkInput.val(slug); 196 slugInput.val(slug); 197 }; 198 199 // sendUserMessage(feedback); // See sendUserMessage function below 200 } 201 202 109 203 function updateTitleAndSlug(title, slug) 110 { 204 { // Update TitleAndSlug Function to save u time :D ! 111 205 updateTitle(title); 112 206 updateSlug(slug); 113 207 } 114 208 115 // Toggle any checkbox you want with this one 209 116 210 function toggleCheckbox(checkbox) 117 { 211 { // Toggle any checkbox you want with this one 118 212 checkbox.attr('checked', !checkbox.attr('checked')); 119 213 }

