Plugin Directory

Changeset 938796


Ignore:
Timestamp:
06/25/2014 11:41:56 PM (12 years ago)
Author:
v-media
Message:

Version 1.4

Location:
foodlist/trunk
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • foodlist/trunk/assets/css/admin.css

    r792818 r938796  
    152152    line-height: 25px;
    153153}
     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  
    1010            api.prepareTextareas();
    1111            api.handleSettingsForm();
     12            api.prepareSortables();
    1213           
    1314            // upload progress variant
     
    150151            };
    151152           
    152             $('#fl-menu-item-tags-select').width('95%');
    153             $('#fl-menu-item-tags-select').select2({
     153            $('#fl-menu-item-tags-select').width('95%').select2({
    154154                formatResult: format,
    155155                formatSelection: format,
    156156                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            }));
    158205        },
    159206       
     
    177224            });
    178225        },
    179        
     226
     227        prepareSortables: function() {
     228            $('ul#fl-menu-sortable-list').sortable();
     229        },
     230
    180231        handleSettingsForm: function() {
    181232            $('#fl-delete-demo-data').click(function(){
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Base.php

    r792818 r938796  
    5252            $items[$this->getArg('post_id')][$this->getArg('multi_number')] = '1';
    5353        }
    54        
     54
    5555        // if not delete, then it is add
    5656        if (!$this->getArg('delete_widget')) {
     
    6363                $multi_number = $this->getArg('multi_number')+1;
    6464            }
    65            
     65
    6666            update_post_meta($this->getArg('post_id'), $this->getMetaKey('multi_number'), $multi_number);
    6767        }
    68        
     68
    6969        update_post_meta($this->getArg('item'), $this->getMetaKey('items'), $items);
    7070        die('1');
    7171    }
    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    }
    74121}
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Menu.php

    r792818 r938796  
    1616        return 'save-menu-sections';
    1717    }
     18
     19    public function ajaxGetSections()
     20    {
     21        $this->getPagedPosts('fl-menu-section');
     22    }
    1823}
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Ajax/Manager/Section.php

    r792818 r938796  
    1616        return 'save-section-items';
    1717    }
    18    
     18
     19    public function ajaxGetItems()
     20    {
     21        $this->getPagedPosts('fl-menu-item');
     22    }
    1923}
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Admin/Menu/SectionManager.php

    r792818 r938796  
    160160    {
    161161        $result = '';
    162         //$items = get_post_meta($sectionId, '_fl_menu_items', true);
    163162        $order = get_post_meta($sectionId, '_fl_menu_items_order', true);
    164163       
    165164        if (empty($order)) {
    166             return;
     165            return $result;
    167166        }
    168167
     
    189188        }
    190189       
    191         //var_dump($items);
    192190        return $result;
    193191    }
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Controller/AdminController.php

    r792818 r938796  
    9292                )
    9393                 */
    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'))
    9597            ) {
    9698                if(function_exists('wp_enqueue_media')){
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuPostType.php

    r792818 r938796  
    99
    1010use Artprima\WordPress\API\Wrapper\Generic\CustomPost;
     11
     12use Foodlist\Project\WordPress\Plugin\Foodlist\Admin\Metabox;
    1113
    1214class MenuPostType extends CustomPost
     
    4850            'supports' => array( 'title', 'thumbnail', 'excerpt' )
    4951        );
    50        
     52
     53        // metaboxes
     54        $metabox = new Metabox\Menu\SectionsMetabox();
     55        $metabox->init();
     56
    5157        $this->registerColumns();
    5258    }
  • foodlist/trunk/lib/Foodlist/Project/WordPress/Plugin/Foodlist/Generic/PostType/MenuSectionPostType.php

    r792818 r938796  
    99
    1010use Artprima\WordPress\API\Wrapper\Generic\CustomPost;
     11
     12use Foodlist\Project\WordPress\Plugin\Foodlist\Admin\Metabox;
    1113
    1214class MenuSectionPostType extends CustomPost
     
    4850            'supports' => array( 'title', 'thumbnail', 'excerpt' )
    4951        );
     52
     53        // metaboxes
     54        $metabox = new Metabox\MenuSection\ItemsMetabox();
     55        $metabox->init();
    5056
    5157        $this->registerColumns();
  • foodlist/trunk/plugin.php

    r815673 r938796  
    1212Author: Artprima
    1313Author URI: http://artprima.eu/
    14 Version: 1.3
     14Version: 1.4
    1515*/
    1616
    17 define('FOODLIST_VERSION', '1.3');
     17define('FOODLIST_VERSION', '1.4');
    1818define('FOODLIST_MIN_PHP_VERSION', '5.3.0');
    1919define('FOODLIST_MIN_WP_VERSION', '3.4.0');
  • foodlist/trunk/readme.txt

    r815673 r938796  
    33Tags: restaurant menu, café menu, restaurant, eatery, menus, bar, list
    44Requires at least: 3.4
    5 Tested up to: 3.7
     5Tested up to: 3.9.1
    66Stable tag: trunk
    77
     
    4747== ChangeLog ==
    4848
     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
    4953= Version 1.3 =
    5054
Note: See TracChangeset for help on using the changeset viewer.