WordPress.org

Plugin Directory

Changeset 1698242


Ignore:
Timestamp:
07/18/17 15:11:12 (5 weeks ago)
Author:
bastho
Message:

Bulk edit: show markers in selector

Location:
event-post/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • event-post/trunk/eventpost.php

    r1698200 r1698242  
    9595        add_action( 'wp_ajax_inline-save', array(&$this, 'inline_save'), 1 ); 
    9696    add_action( 'wp_ajax_eventpost_save_bulk', array(&$this, 'save_bulkdatas') ); 
    97         add_filter( 'eventpost_inline_field', array(&$this, 'inline_field_color'), 10, 2); 
     97        add_filter( 'eventpost_inline_field', array(&$this, 'inline_field_color'), 10, 3); 
    9898 
    9999        $inc_path = plugin_dir_path(__FILE__).'inc/'; 
     
    16241624                        <span class="title"><?php echo $fieldlabel; ?></span> 
    16251625                        <span class="input-text-wrap"> 
    1626                             <?php echo $this->inline_field($fieldname); ?> 
     1626                            <?php echo $this->inline_field($fieldname, $bulk); ?> 
    16271627                        </span> 
    16281628                    </label> 
     
    16401640     * @return type 
    16411641     */ 
    1642     function inline_field($fieldname){ 
    1643         return apply_filters('eventpost_inline_field', '<input name="'.$fieldname.'" class="eventpost-inline-'.$fieldname.'" value="" type="text">', $fieldname); 
    1644     } 
    1645  
    1646     function inline_field_color($html, $fieldname){ 
     1642    function inline_field($fieldname, $bulk){ 
     1643        return apply_filters('eventpost_inline_field', '<input name="'.$fieldname.'" class="eventpost-inline-'.$fieldname.'" value="" type="text">', $fieldname, $bulk); 
     1644    } 
     1645 
     1646    function inline_field_color($html, $fieldname, $bulk){ 
    16471647        if($fieldname==$this->META_COLOR){ 
    16481648            $colors = $this->get_colors(); 
    1649             $html = '<select name="'.$fieldname.'" class="eventpost-inline-colorpicker eventpost-inline-'.$fieldname.'" >'; 
     1649            $html=''; 
     1650            if($bulk){ 
     1651                $html.= '<span class="eventpost-bulk-colorpicker-button link">'.__('No Change', 'event-post').'</span>'; 
     1652            } 
     1653            $html .= '<select name="'.$fieldname.'" class="eventpost-inline-colorpicker eventpost-inline-'.$fieldname.' '.($bulk?'is-bulk':'no-bulk').'" >'; 
     1654            if($bulk){ 
     1655                $html.='<option value="false">— '.__('No Change', 'event-post').' —</option>'; 
     1656            } 
    16501657            foreach ($colors as $color=>$image_path){ 
    16511658                $html.='<option value="'.$color.'" data-path="'.$image_path.'">'.$color.'</option>'; 
     
    17281735                foreach ($this->bulk_edit_fields as $sets) { 
    17291736                    foreach ($sets as $fieldname => $fieldlabel) { 
    1730                         if ((false !== $value = filter_input(INPUT_POST, $fieldname))) { 
     1737                        if ((false != $value = filter_input(INPUT_POST, $fieldname))) { 
    17311738                            foreach ($post_ids as $post_id) { 
    17321739                                update_post_meta($post_id, $fieldname, $value); 
  • event-post/trunk/js/inline-edit.js

    r1698200 r1698242  
    3838    }; 
    3939    function eventpost_inline_colorpick(target){ 
    40             var eventpost_inline_colorpicker_html=$('<span class="eventpost-inline-colorpicker-list"></span>'); 
    41             $('option', target).each(function(){ 
     40        console.log(target); 
     41        if(target.hasClass('is-bulk')){ 
     42            target.val('false').trigger('change'); 
     43        } 
     44        if(target && target.next('.eventpost-inline-colorpicker-list').length){ 
     45            return; 
     46        } 
     47        var eventpost_inline_colorpicker_html=$('<span class="eventpost-inline-colorpicker-list"></span>'); 
     48        $('option', target).each(function(){ 
     49            if($(this).attr('value')!=='false'){ 
    4250                color_item = $('<img src="'+$(this).data('path')+'" alt="'+$(this).attr('value')+'" class="ep-i-c-'+$(this).attr('value')+'"/>').click(function(){ 
    4351                    $(this).parent().prev('.eventpost-inline-colorpicker').val($(this).attr('alt')).trigger('change'); 
    4452                }); 
    4553                eventpost_inline_colorpicker_html.append(color_item); 
    46             }); 
    47             target.after(eventpost_inline_colorpicker_html).hide().live('change', function(){ 
    48                 value = $(this).val(); 
    49                 $('img', $(this).next('.eventpost-inline-colorpicker-list')).attr('style', '').filter('.ep-i-c-'+value).css({border: '#000 1px solid', padding: '3px'}); 
    50             }); 
    51             target.trigger('change'); 
     54            } 
     55        }); 
     56        target.after(eventpost_inline_colorpicker_html).hide().unbind('change').on('change', function(){ 
     57            value = $(this).val(); 
     58            console.log(value); 
     59            $('img', $(this).next('.eventpost-inline-colorpicker-list')).attr('style', '').filter('.ep-i-c-'+value).css({border: '#000 1px solid', padding: '3px'}); 
     60        }); 
     61        target.trigger('change'); 
    5262    } 
    5363 
     
    8090        for(field_group in attrs){ 
    8191            for(key in attrs[field_group]){ 
    82                 datas[key] = $( '#eventpost-inline-'+key+'' ).val(); 
     92                if($( '#posts-filter .eventpost-inline-'+key+'' ).val() !== 'false'){ 
     93                    datas[key] = $( '#posts-filter .eventpost-inline-'+key+'' ).val(); 
     94                } 
    8395            } 
    8496        } 
     
    93105        }); 
    94106    } 
     107    $('.eventpost-bulk-colorpicker-button').click(function(){ 
     108       eventpost_inline_colorpick($(this).next('.eventpost-inline-event_color')); 
     109    }).next('.eventpost-inline-event_color').hide(); 
    95110    $('#bulk_edit').live('click', function () { 
    96111        eventpost_bulk_send(); 
Note: See TracChangeset for help on using the changeset viewer.