Plugin Directory

Changeset 636357


Ignore:
Timestamp:
12/10/2012 01:35:51 AM (13 years ago)
Author:
shockware
Message:

Merge branch 'master' into HEAD

Location:
contact-form-7-datepicker/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • contact-form-7-datepicker/trunk/contact-form-7-datepicker.php

    r633957 r636357  
    55Description: Easily add a date field using jQuery UI's datepicker to your CF7 forms. This plugin depends on Contact Form 7.
    66Author: Aurel Canciu
    7 Version: 2.0
     7Version: 2.1
    88Author URI: https://github.com/relu/
    99*/
  • contact-form-7-datepicker/trunk/date-module.php

    r633957 r636357  
    4343            $class_att .= ' wpcf7-not-valid';
    4444
     45        $inline = false;
     46
    4547        $dpOptions = array();
    4648        foreach ($options as $option) {
    47             if (preg_match('%^id:([-_0-9a-z]+)$%i', $option, $matches)) {
     49            if (preg_match('%^id:([-_\w\d]+)$%i', $option, $matches)) {
    4850                $id_att = $matches[1];
    49             } elseif (preg_match('%^class:([-_0-9a-z]+)$%i', $option, $matches)) {
     51            } elseif (preg_match('%^class:([-_\w\d]+)$%i', $option, $matches)) {
    5052                $class_att .= " $matches[1]";
    51             } elseif (preg_match('%^([0-9]*)[/x]([0-9]*)$%i', $option, $matches)) {
     53            } elseif (preg_match('%^(\d*)[/x](\d*)$%i', $option, $matches)) {
    5254                $size_att = (int) $matches[1];
    5355                $maxlen_att = (int) $matches[2];
    5456            } elseif (preg_match('%^tabindex:(\d+)$%i', $option, $matches)) {
    5557                $tabindex_att = (int) $matches[1];
    56             } elseif (preg_match('%^date-format:([-_/\.a-z0-9]+)$%i', $option, $matches)) {
     58            } elseif (preg_match('%^date-format:([-_/\.\w\d]+)$%i', $option, $matches)) {
    5759                $dpOptions['dateFormat'] = str_replace('_', ' ', $matches[1]);
    58             } elseif (preg_match('%^(min|max)-date:([-_/\., 0-9a-z]+)$%i', $option, $matches)) {
     60            } elseif (preg_match('%^(min|max)-date:([-_/\.\w\d]+)$%i', $option, $matches)) {
    5961                $dpOptions[$matches[1] . 'Date'] = $matches[2];
    6062            } elseif (preg_match('%^first-day:(\d)$%', $option, $matches)) {
    6163                $dpOptions['firstDay'] = (int) $matches[1];
    62             } elseif (preg_match('%^animate:([a-z]+)$%i', $option, $matches)) {
     64            } elseif (preg_match('%^animate:(\w+)$%i', $option, $matches)) {
    6365                $dpOptions['showAnim'] = $matches[1];
    64             } elseif (preg_match('%^change-month:(true|false)$%i', $option, $matches)) {
    65                 $dpOptions['changeMonth'] = ('true' == $matches[1]);
    66             } elseif (preg_match('%^change-year:(true|false)$%i', $option, $matches)) {
    67                 $dpOptions['changeYear'] = ('true' == $matches[1]);
    68             } elseif (preg_match('%^year-range:([\d]+)-?([\d]+)?$%', $option, $matches)) {
     66            } elseif (preg_match('%^change-month$%i', $option, $matches)) {
     67                $dpOptions['changeMonth'] = true;
     68            } elseif (preg_match('%^change-year$%i', $option, $matches)) {
     69                $dpOptions['changeYear'] = true;
     70            } elseif (preg_match('%^year-range:(\d+)-?(\d+)?$%', $option, $matches)) {
    6971                $dpOptions['yearRange'] = "{$matches[1]}:{$matches[2]}";
    70             } elseif (preg_match('%^months:([\d]+)$%', $option, $matches)) {
     72            } elseif (preg_match('%^months:(\d+)$%', $option, $matches)) {
    7173                $dpOptions['numberOfMonths'] = (int) $matches[1];
    72             } elseif (preg_match('%^buttons:(true|false)$%', $option, $matches)) {
    73                 $dpOptions['showButtonPanel'] = ('true' == $matches[1]);
     74            } elseif (preg_match('%^buttons$%', $option, $matches)) {
     75                $dpOptions['showButtonPanel'] = true;
     76            } elseif (preg_match('%inline$%', $option, $matches)) {
     77                $inline = true;
     78                $dpOptions['altField'] = "#{$name}_alt";
    7479            }
    7580
    76             do_action('cf7_datepicker_attr_match', $dpOptions, $option);
     81            do_action_ref_array('cf7_datepicker_attr_match', array($dpOptions), $option);
    7782        }
    7883
     
    108113            $atts .= ' title="' . trim(esc_attr($title_att)) . '"';
    109114
    110         $input = sprintf('<input type="text" name="%s" value="%s" %s/>',
     115        $input_type = $inline ? 'hidden' : 'text';
     116        $input_atts = $inline ? "id=\"{$name}_alt\"" : $atts;
     117
     118        $input = sprintf('<input type="%s" name="%s" value="%s" %s/>',
     119            $input_type,
    111120            esc_attr($name),
    112121            esc_attr($value),
    113             $atts
     122            $input_atts
    114123        );
    115124
    116         $dp = new CF7_DatePicker($name, $dpOptions);
     125        if ($inline)
     126            $input .= sprintf('<div id="%s_datepicker" %s></div>', $name, $atts);
     127
     128        $dp_selector = $inline ? '#' . $name . '_datepicker' : $name;
     129
     130        $dp = new CF7_DatePicker($dp_selector, $dpOptions);
    117131
    118132        return sprintf('<span class="wpcf7-form-control-wrap %s">%s %s</span>%s',
     
    120134            $input,
    121135            $validation_error,
    122             $dp->generate_code()
     136            $dp->generate_code($inline)
    123137        );
    124138    }
  • contact-form-7-datepicker/trunk/date-tag-generator.php

    r633957 r636357  
    6060                <td>
    6161                    <code>first-day</code><br />
    62                     <input type="text" name="first-day" class="option" style="display: none" />
    63                     <select id="first-day">
    64                         <option value="0" selected="selected"><?php _e('Sunday'); ?></option>
    65                         <option value="1"><?php _e('Monday'); ?></option>
    66                     </select>
     62                    <input type="checkbox" id="first-day-sunday" name="first-day:0" class="option exclusive" />
     63                    <label for="first-day-sunday"><?php _e('Sunday'); ?></label>
     64                    &nbsp;&nbsp;
     65
     66                    <input type="checkbox" value="1" id="first-day-monday" name="first-day:1" class="option exclusive" />
     67                    <label for="first-day-monday"><?php _e('Monday'); ?></label>
    6768                </td>
    6869                <td>
     
    7576            <tr>
    7677                <td>
    77                     <code>change-month</code><br />
    78                     <input type="text" name="change-month" class="option" style="display: none" />
    79                     <select id="change-month">
    80                         <option value="true"><?php _e('True'); ?></option>
    81                         <option value="false"><?php _e('False'); ?></option>
    82                     </select>
     78                    <label><code>change-month</code> <input type="checkbox" name="change-month" id="change-month" class="option" /></label>
    8379                </td>
    8480            </tr>
     
    8682            <tr>
    8783                <td>
    88                     <code>change-year</code><br />
    89                     <input type="text" name="change-year" class="option" style="display: none" />
    90                     <select id="change-year">
    91                         <option value="true"><?php _e('True'); ?></option>
    92                         <option value="false" selected="selected"><?php _e('False'); ?></option>
    93                     </select>
     84                    <label><code>change-year</code> <input type="checkbox" name="change-year" id="change-year" class="option" /></label>
    9485                </td>
    9586                <td>
    9687                    <code>year-range</code><br />
    97                     <input type="text" name="year-range" class="option" style="display: none"/>
    98                     <input size="4" type="text" name="year-range-start" class="numeric" /> -
    99                     <input size="4"type="text" name="year-range-end" class="numeric" />
     88                    <input type="text" id="year-range" name="year-range" class="option" style="display: none;" />
     89                    <input size="4" type="text" name="year-range-start" class="year-range numeric" /> -
     90                    <input size="4"type="text" name="year-range-end" class="year-range numeric" />
    10091                </td>
    10192            </tr>
     
    10495                <td>
    10596                    <code>months</code><br />
    106                     <input type="text" size="2" name="months" class="option"/>
     97                    <input type="text" size="2" name="months" class="option numeric"/>
    10798                </td>
    10899                <td>
    109                     <code>buttons</code><br />
    110                     <input type="text" name="buttons" class="option" style="display: none" />
    111                     <select id="buttons">
    112                         <option value="true"><?php _e('True'); ?></option>
    113                         <option value="false" selected="selected"><?php _e('False'); ?></option>
    114                     </select>
     100                    <label><code>buttons</code> <input type="checkbox" name="buttons" class="option" /></label>
     101                </td>
     102            </tr>
     103
     104            <tr>
     105                <td>
     106                    <label><code>inline</code> <input type="checkbox" name="inline" class="option" /></label>
    115107                </td>
    116108            </tr>
     
    135127<script type="text/javascript">
    136128jQuery(function($){
    137     $('select').change(function(){
     129    $(document).on('change', 'select', function(){
    138130        var $this = $(this),
    139131            value = $this.val();
     
    142134            return;
    143135
    144         $('input[name="'+$this.attr('id')+'"]').val(value);
     136        $('input[name="'+$this.attr('id')+'"]').val(value).trigger('change');
    145137    });
    146138
    147     $('input[name="year-range-start"], input[name="year-range-end"]').change(function(){
     139    $(document).on('keyup', '.year-range', function(){
    148140        var value = $('input[name="year-range-start"]').val() + '-' + $('input[name="year-range-end"]').val();
    149141
     
    151143            return;
    152144
    153         $('input[name="year-range"]').val(value);
     145        $('#year-range').val(value);
    154146    });
    155147});
  • contact-form-7-datepicker/trunk/datepicker.php

    r633957 r636357  
    111111        $selector = ($inline) ? "$('$this->input_name')" : "$('input[name=\"{$this->input_name}\"]')";
    112112
    113         $out  = "{$selector}.datepicker({$this->options_encode()});\n";
    114         $out .= self::_regionalize($selector);
     113        $out  = self::_regionalize($selector);
     114        $out .= "{$selector}.datepicker({$this->options_encode()});\n";
    115115
    116116        $out = "jQuery(function($){ $out });";
  • contact-form-7-datepicker/trunk/readme.txt

    r633957 r636357  
    11=== Plugin Name ===
    22Contributors: shockware
    3 Donate link:
    43Tags: wordpress, datepicker, calendar, contact form 7, forms, jqueryui
    5 Requires at least: WordPress 2.9
    6 Tested up to: WordPress 3.4.2
    7 Stable tag: 2.0
     4Requires at least: 2.9
     5Tested up to: 3.5
     6Stable tag: 2.1
     7License: GPLv2 or later
     8License URI: http://www.gnu.org/licenses/gpl-2.0.html
    89
    910Easily add a date field using jQuery UI's datepicker to your CF7 forms.
     
    3334
    3435== Changelog ==
     36
     37= 2.1 =
     38* Added inline option
     39* Fixed tag generator
     40* Fixed date format when localized
    3541
    3642= 2.0 =
Note: See TracChangeset for help on using the changeset viewer.