Changeset 938796
- Timestamp:
- 06/25/2014 11:41:56 PM (12 years ago)
- Location:
- foodlist/trunk
- Files:
-
- 4 added
- 11 edited
-
assets/css/admin.css (modified) (1 diff)
-
assets/js/admin.js (modified) (3 diffs)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Base.php (modified) (2 diffs)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Menu.php (modified) (1 diff)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Section.php (modified) (1 diff)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Menu/SectionManager.php (modified) (2 diffs)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Metabox/Menu (added)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Metabox/Menu/SectionsMetabox.php (added)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Metabox/MenuSection (added)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Metabox/MenuSection/ItemsMetabox.php (added)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Controller/AdminController.php (modified) (1 diff)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuPostType.php (modified) (2 diffs)
-
lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuSectionPostType.php (modified) (2 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
foodlist/trunk/assets/css/admin.css
r792818 r938796 152 152 line-height: 25px; 153 153 } 154 155 .fl-menu-sortable-item-remove { 156 color: #a00; 157 cursor: pointer; 158 position: absolute; 159 right: 5px; 160 top: 13px; 161 } 162 163 .fl-menu-sortable-item-remove:hover { 164 color: red; 165 } 166 167 #fl-menu-sortable-list .fl-menu-sortable-item { 168 position: relative; 169 } -
foodlist/trunk/assets/js/admin.js
r792818 r938796 10 10 api.prepareTextareas(); 11 11 api.handleSettingsForm(); 12 api.prepareSortables(); 12 13 13 14 // upload progress variant … … 150 151 }; 151 152 152 $('#fl-menu-item-tags-select').width('95%'); 153 $('#fl-menu-item-tags-select').select2({ 153 $('#fl-menu-item-tags-select').width('95%').select2({ 154 154 formatResult: format, 155 155 formatSelection: format, 156 156 escapeMarkup: function(m) { return m; } 157 }); 157 }); 158 159 var el = $('#metabox-sortable-dropdown'); 160 var list = $('#fl-menu-sortable-list'); 161 var tpl = list.data('template'); 162 var context = list.data('context'); 163 var nonce = list.data('nonce'); 164 el.data('placeholder', el.attr('placeholder')); 165 el.width('88%').select2({ 166 //minimumInputLength: 1, 167 placeholder: el.attr('placeholder'), 168 ajax: { 169 url: ajaxurl, 170 type: 'POST', 171 data: function(term, page) { 172 return { 173 action: context === 'items' ? 'foodlist_section' : 'foodlist_menu', 174 method: 'Get' + context.charAt(0).toUpperCase() + context.slice(1), 175 args: { 176 nonce: $('input[name="'+nonce+'"]').val(), 177 term: term, 178 page: page, 179 page_limit: 10 180 } 181 } 182 }, 183 results: function (data, page) { 184 var more = (page * 10) < data.total; // whether or not there are more results available 185 186 // notice we return the value of more so Select2 knows if more results can be loaded 187 return {results: data.posts, more: more}; 188 } 189 } 190 }).on('change', function(e){ 191 //e.added.id 192 var html = tpl.replace('__title__', e.added.text).replace('__id__', e.added.id); 193 $('#fl-menu-sortable-list').append($(html)); 194 195 $(this).select2( 196 'val', null 197 ); 198 }); 199 200 list.on('click', '.fl-menu-sortable-item-remove', (function(){ 201 $(this).parent().fadeOut(500, function(){ 202 $(this).remove(); 203 }); 204 })); 158 205 }, 159 206 … … 177 224 }); 178 225 }, 179 226 227 prepareSortables: function() { 228 $('ul#fl-menu-sortable-list').sortable(); 229 }, 230 180 231 handleSettingsForm: function() { 181 232 $('#fl-delete-demo-data').click(function(){ -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Base.php
r792818 r938796 52 52 $items[$this->getArg('post_id')][$this->getArg('multi_number')] = '1'; 53 53 } 54 54 55 55 // if not delete, then it is add 56 56 if (!$this->getArg('delete_widget')) { … … 63 63 $multi_number = $this->getArg('multi_number')+1; 64 64 } 65 65 66 66 update_post_meta($this->getArg('post_id'), $this->getMetaKey('multi_number'), $multi_number); 67 67 } 68 68 69 69 update_post_meta($this->getArg('item'), $this->getMetaKey('items'), $items); 70 70 die('1'); 71 71 } 72 73 72 73 74 protected function getPagedPosts($type) 75 { 76 $total = 0; 77 if (!$this->getArg('page') || !$this->getArg('page_limit')) { 78 $result = array(); 79 } else { 80 $result = array(); 81 82 $limit = $this->getArg('page_limit'); 83 if ($limit > 100 || $limit < 1) { 84 $limit = 10; 85 } 86 87 $page = $this->getArg('page'); 88 89 // The Query 90 $query = new \WP_Query(array( 91 'post_type' => $type, 92 'post_status' => array('draft', 'publish'), 93 'posts_per_page' => $limit, 94 'paged' => $page, 95 'order' => 'ASC', 96 'orderby' => 'title', 97 's' => $this->getArg('term') 98 )); 99 100 if ($query->have_posts()) { 101 global $post; 102 $total = $query->max_num_pages; 103 while ($query->have_posts()) { 104 $query->the_post(); 105 106 $result[] = array( 107 'id' => $post->ID, 108 'text' => get_the_title($post), 109 ); 110 } 111 } 112 wp_reset_postdata(); 113 } 114 115 echo json_encode(array( 116 'posts' => $result, 117 'total' => $total, 118 )); 119 die(); 120 } 74 121 } -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Menu.php
r792818 r938796 16 16 return 'save-menu-sections'; 17 17 } 18 19 public function ajaxGetSections() 20 { 21 $this->getPagedPosts('fl-menu-section'); 22 } 18 23 } -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Section.php
r792818 r938796 16 16 return 'save-section-items'; 17 17 } 18 18 19 public function ajaxGetItems() 20 { 21 $this->getPagedPosts('fl-menu-item'); 22 } 19 23 } -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Menu/SectionManager.php
r792818 r938796 160 160 { 161 161 $result = ''; 162 //$items = get_post_meta($sectionId, '_fl_menu_items', true);163 162 $order = get_post_meta($sectionId, '_fl_menu_items_order', true); 164 163 165 164 if (empty($order)) { 166 return ;165 return $result; 167 166 } 168 167 … … 189 188 } 190 189 191 //var_dump($items);192 190 return $result; 193 191 } -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Controller/AdminController.php
r792818 r938796 92 92 ) 93 93 */ 94 || ((($screen = get_current_screen()) !== null) && ($screen->id == 'fl-menu-item')) 94 || ((($screen = get_current_screen()) !== null) 95 && 96 ($screen->id == 'fl-menu-item' || $screen->id == 'fl-menu' || $screen->id == 'fl-menu-section')) 95 97 ) { 96 98 if(function_exists('wp_enqueue_media')){ -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuPostType.php
r792818 r938796 9 9 10 10 use Artprima\WordPress\API\Wrapper\Generic\CustomPost; 11 12 use Foodlist\Project\WordPress\Plugin\Foodlist\Admin\Metabox; 11 13 12 14 class MenuPostType extends CustomPost … … 48 50 'supports' => array( 'title', 'thumbnail', 'excerpt' ) 49 51 ); 50 52 53 // metaboxes 54 $metabox = new Metabox\Menu\SectionsMetabox(); 55 $metabox->init(); 56 51 57 $this->registerColumns(); 52 58 } -
foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuSectionPostType.php
r792818 r938796 9 9 10 10 use Artprima\WordPress\API\Wrapper\Generic\CustomPost; 11 12 use Foodlist\Project\WordPress\Plugin\Foodlist\Admin\Metabox; 11 13 12 14 class MenuSectionPostType extends CustomPost … … 48 50 'supports' => array( 'title', 'thumbnail', 'excerpt' ) 49 51 ); 52 53 // metaboxes 54 $metabox = new Metabox\MenuSection\ItemsMetabox(); 55 $metabox->init(); 50 56 51 57 $this->registerColumns(); -
foodlist/trunk/plugin.php
r815673 r938796 12 12 Author: Artprima 13 13 Author URI: http://artprima.eu/ 14 Version: 1. 314 Version: 1.4 15 15 */ 16 16 17 define('FOODLIST_VERSION', '1. 3');17 define('FOODLIST_VERSION', '1.4'); 18 18 define('FOODLIST_MIN_PHP_VERSION', '5.3.0'); 19 19 define('FOODLIST_MIN_WP_VERSION', '3.4.0'); -
foodlist/trunk/readme.txt
r815673 r938796 3 3 Tags: restaurant menu, café menu, restaurant, eatery, menus, bar, list 4 4 Requires at least: 3.4 5 Tested up to: 3. 75 Tested up to: 3.9.1 6 6 Stable tag: trunk 7 7 … … 47 47 == ChangeLog == 48 48 49 = Version 1.4 = 50 51 * New metaboxes when creating/editing Sections and Menus. It is now possible to build the list of sections within the menu and the list of items within the section editing screens. 52 49 53 = Version 1.3 = 50 54
Note: See TracChangeset
for help on using the changeset viewer.