Plugin Directory

Changeset 1749332


Ignore:
Timestamp:
10/19/2017 04:09:53 PM (8 years ago)
Author:
Moisture
Message:

Add onChange listeners to flatpickr

Location:
am-events/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • am-events/trunk/readme.txt

    r1397487 r1749332  
    1212== Description ==
    1313
    14 The plugin adds a custom event post type with two taxonomies: event category and venue. 
     14The plugin adds a custom event post type with two taxonomies: event category and venue.
    1515
    1616Allows the user to add new events just like normal posts with added fields for start time, end time, category and venue. You can also easily create weekly or biweekly recurring events.
     
    2626If you think something critical is missing, feel free to send me a request. I'm using this on some of my clients' sites so I'll certainly be improving/fixing it for upcoming WordPress versions.
    2727
    28 The plugin is available in the following languages (pot-file included for additional translations): 
     28The plugin is available in the following languages (pot-file included for additional translations):
    2929
    3030* English
     
    5656== Changelog ==
    5757
     58= 1.13.0 =
     59* Replace jQuery datetimepicker with flatpickr
     60
    5861= 1.12.0 =
    5962* Updated jQuery UI date/time picker
     
    9699
    97100= 1.8.0 =
    98 * Added conditional tags for the widget 
     101* Added conditional tags for the widget
    99102
    100103= 1.7.1 =
     
    247250 * [permalink]
    248251 * [meta]
    249  
     252
    250253Conditional shortcodes:
    251254
     
    266269
    267270You can use any shortcode as many times as needed in a single template. To separate date and time of start date for example you could write:
    268    
    269     [start-date format='d.m.Y'] 
     271
     272    [start-date format='d.m.Y']
    270273    <span>divider</span>
    271274    [start-date format='H:i']
    272    
     275
    273276Example usage of conditional shortcode:
    274277
    275     [start-date format='D d.m.Y H:s'] 
     278    [start-date format='D d.m.Y H:s']
    276279    [if cond='startdate-not-enddate']
    277      - [end-date format='D d.m.Y H:s'] 
     280     - [end-date format='D d.m.Y H:s']
    278281    [/if]
    279282
     
    287290    am_the_enddate($format = 'Y-m-d H:i:s', $before = '', $after = '', $echo = true)
    288291    am_get_the_enddate( $format = 'Y-m-d H:i:s', $post = 0 )
    289    
     292
    290293    // Template tags for getting and displaying event venues
    291294    am_get_the_venue( $id = false )
     
    301304
    302305Example of displaying the first category of the current event post:
    303    
     306
    304307    $categoryArray = am_get_the_event_category();
    305308    echo $categoryArray[0]->name;
  • am-events/trunk/script/admin-post.js

    r1749320 r1749332  
    6868        minuteIncrement: parseInt(event_data.minuteStep)
    6969    };
    70    
    71     var startPicker = $('#am_startdate').flatpickr(flatpickrOptions);
    72     var endPicker = $('#am_enddate').flatpickr(flatpickrOptions);
    73    
     70
     71    var startPicker = $('#am_startdate').flatpickr(Object.assign(flatpickrOptions, {
     72        onChange: function(selectedDates, dateStr, instance) {
     73            if (selectedDates[0] != null && (endPicker.selectedDates[0] == null || endPicker.selectedDates[0] < selectedDates[0])) {
     74                endPicker.setDate(selectedDates[0]);
     75            }
     76      }
     77    }));
     78
     79    var endPicker = $('#am_enddate').flatpickr(Object.assign(flatpickrOptions, {
     80        onChange: function(selectedDates, dateStr, instance) {
     81            if (selectedDates[0] != null && (startPicker.selectedDates[0] == null || selectedDates[0] < startPicker.selectedDates[0])) {
     82                startPicker.setDate(selectedDates[0]);
     83            }
     84      }
     85    }));
     86
    7487    startPicker.setDate(event_data.startDate);
    7588    endPicker.setDate(event_data.endDate);
    76        
    77 });
     89
     90    startPicker.set();
    7891
    7992
    80 
    81 
     93});
Note: See TracChangeset for help on using the changeset viewer.