Changeset 636357
- Timestamp:
- 12/10/2012 01:35:51 AM (13 years ago)
- Location:
- contact-form-7-datepicker/trunk
- Files:
-
- 5 edited
-
contact-form-7-datepicker.php (modified) (1 diff)
-
date-module.php (modified) (3 diffs)
-
date-tag-generator.php (modified) (7 diffs)
-
datepicker.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
contact-form-7-datepicker/trunk/contact-form-7-datepicker.php
r633957 r636357 5 5 Description: Easily add a date field using jQuery UI's datepicker to your CF7 forms. This plugin depends on Contact Form 7. 6 6 Author: Aurel Canciu 7 Version: 2. 07 Version: 2.1 8 8 Author URI: https://github.com/relu/ 9 9 */ -
contact-form-7-datepicker/trunk/date-module.php
r633957 r636357 43 43 $class_att .= ' wpcf7-not-valid'; 44 44 45 $inline = false; 46 45 47 $dpOptions = array(); 46 48 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)) { 48 50 $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)) { 50 52 $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)) { 52 54 $size_att = (int) $matches[1]; 53 55 $maxlen_att = (int) $matches[2]; 54 56 } elseif (preg_match('%^tabindex:(\d+)$%i', $option, $matches)) { 55 57 $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)) { 57 59 $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)) { 59 61 $dpOptions[$matches[1] . 'Date'] = $matches[2]; 60 62 } elseif (preg_match('%^first-day:(\d)$%', $option, $matches)) { 61 63 $dpOptions['firstDay'] = (int) $matches[1]; 62 } elseif (preg_match('%^animate:( [a-z]+)$%i', $option, $matches)) {64 } elseif (preg_match('%^animate:(\w+)$%i', $option, $matches)) { 63 65 $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)) { 69 71 $dpOptions['yearRange'] = "{$matches[1]}:{$matches[2]}"; 70 } elseif (preg_match('%^months:( [\d]+)$%', $option, $matches)) {72 } elseif (preg_match('%^months:(\d+)$%', $option, $matches)) { 71 73 $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"; 74 79 } 75 80 76 do_action ('cf7_datepicker_attr_match', $dpOptions, $option);81 do_action_ref_array('cf7_datepicker_attr_match', array($dpOptions), $option); 77 82 } 78 83 … … 108 113 $atts .= ' title="' . trim(esc_attr($title_att)) . '"'; 109 114 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, 111 120 esc_attr($name), 112 121 esc_attr($value), 113 $ atts122 $input_atts 114 123 ); 115 124 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); 117 131 118 132 return sprintf('<span class="wpcf7-form-control-wrap %s">%s %s</span>%s', … … 120 134 $input, 121 135 $validation_error, 122 $dp->generate_code( )136 $dp->generate_code($inline) 123 137 ); 124 138 } -
contact-form-7-datepicker/trunk/date-tag-generator.php
r633957 r636357 60 60 <td> 61 61 <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 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> 67 68 </td> 68 69 <td> … … 75 76 <tr> 76 77 <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> 83 79 </td> 84 80 </tr> … … 86 82 <tr> 87 83 <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> 94 85 </td> 95 86 <td> 96 87 <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" /> 100 91 </td> 101 92 </tr> … … 104 95 <td> 105 96 <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"/> 107 98 </td> 108 99 <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> 115 107 </td> 116 108 </tr> … … 135 127 <script type="text/javascript"> 136 128 jQuery(function($){ 137 $( 'select').change(function(){129 $(document).on('change', 'select', function(){ 138 130 var $this = $(this), 139 131 value = $this.val(); … … 142 134 return; 143 135 144 $('input[name="'+$this.attr('id')+'"]').val(value) ;136 $('input[name="'+$this.attr('id')+'"]').val(value).trigger('change'); 145 137 }); 146 138 147 $( 'input[name="year-range-start"], input[name="year-range-end"]').change(function(){139 $(document).on('keyup', '.year-range', function(){ 148 140 var value = $('input[name="year-range-start"]').val() + '-' + $('input[name="year-range-end"]').val(); 149 141 … … 151 143 return; 152 144 153 $(' input[name="year-range"]').val(value);145 $('#year-range').val(value); 154 146 }); 155 147 }); -
contact-form-7-datepicker/trunk/datepicker.php
r633957 r636357 111 111 $selector = ($inline) ? "$('$this->input_name')" : "$('input[name=\"{$this->input_name}\"]')"; 112 112 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"; 115 115 116 116 $out = "jQuery(function($){ $out });"; -
contact-form-7-datepicker/trunk/readme.txt
r633957 r636357 1 1 === Plugin Name === 2 2 Contributors: shockware 3 Donate link:4 3 Tags: 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 4 Requires at least: 2.9 5 Tested up to: 3.5 6 Stable tag: 2.1 7 License: GPLv2 or later 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 9 9 10 Easily add a date field using jQuery UI's datepicker to your CF7 forms. … … 33 34 34 35 == Changelog == 36 37 = 2.1 = 38 * Added inline option 39 * Fixed tag generator 40 * Fixed date format when localized 35 41 36 42 = 2.0 =
Note: See TracChangeset
for help on using the changeset viewer.