Changeset 694544
- Timestamp:
- 04/09/2013 02:17:25 PM (13 years ago)
- Location:
- contact-form-7-datepicker/trunk
- Files:
-
- 15 added
- 5 edited
-
admin.php (modified) (6 diffs)
-
contact-form-7-datepicker.php (modified) (3 diffs)
-
date-module.php (modified) (3 diffs)
-
datepicker.php (modified) (5 diffs)
-
js (added)
-
js/jquery.ui.effect-blind.min.js (added)
-
js/jquery.ui.effect-bounce.min.js (added)
-
js/jquery.ui.effect-clip.min.js (added)
-
js/jquery.ui.effect-drop.min.js (added)
-
js/jquery.ui.effect-explode.min.js (added)
-
js/jquery.ui.effect-fade.min.js (added)
-
js/jquery.ui.effect-fold.min.js (added)
-
js/jquery.ui.effect-highlight.min.js (added)
-
js/jquery.ui.effect-pulsate.min.js (added)
-
js/jquery.ui.effect-scale.min.js (added)
-
js/jquery.ui.effect-shake.min.js (added)
-
js/jquery.ui.effect-slide.min.js (added)
-
js/jquery.ui.effect-transfer.min.js (added)
-
js/jquery.ui.effect.min.js (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
contact-form-7-datepicker/trunk/admin.php
r633957 r694544 3 3 class ContactForm7Datepicker_Admin { 4 4 5 public static function init() {6 add_action('admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets'));7 add_action('wpcf7_admin_after_general_settings', array( __CLASS__, 'add_meta_box'));8 add_action('admin_footer', array( __CLASS__, 'theme_js'));9 add_action('wp_ajax_cf7dp_save_settings', array( __CLASS__, 'ajax_save_settings'));5 function __construct() { 6 add_action('admin_enqueue_scripts', array($this, 'enqueue_assets')); 7 add_action('wpcf7_admin_after_general_settings', array($this, 'add_meta_box')); 8 add_action('admin_footer', array($this, 'theme_js')); 9 add_action('wp_ajax_cf7dp_save_settings', array($this, 'ajax_save_settings')); 10 10 } 11 11 12 public staticfunction enqueue_assets() {12 function enqueue_assets() { 13 13 if (is_admin() && ! self::is_wpcf7_page()) 14 14 return; 15 16 wp_enqueue_script('jquery-ui-datepicker'); 15 17 16 18 ContactForm7Datepicker::enqueue_js(); … … 18 20 } 19 21 20 public staticfunction add_meta_box() {22 function add_meta_box() { 21 23 if (! current_user_can('publish_pages')) 22 24 return; … … 34 36 } 35 37 36 public staticfunction theme_metabox() {38 function theme_metabox() { 37 39 ?> 38 40 … … 50 52 } 51 53 52 public static functiontheme_js() {54 function theme_js() { 53 55 if (! self::is_wpcf7_page()) 54 56 return; 55 57 ?> 56 <script type="text/javascript">57 jQuery(function($){58 var $spinner = $(new Image()).attr('src', '<?php echo admin_url('images/wpspin_light.gif'); ?>');59 var old_href = '';58 <script type="text/javascript"> 59 jQuery(function($){ 60 var $spinner = $(new Image()).attr('src', '<?php echo admin_url('images/wpspin_light.gif'); ?>'); 61 var old_href = ''; 60 62 61 $('#jquery-ui-theme').change(function(){62 var style = $(this).val();63 $('#jquery-ui-theme').change(function(){ 64 var style = $(this).val(); 63 65 64 var $link = $('#jquery-ui-theme-css');65 var href = $link.attr('href');66 var $link = $('#jquery-ui-theme-css'); 67 var href = $link.attr('href'); 66 68 67 if (style == 'disabled') {68 old_href = href;69 $link.attr('href', '');69 if (style == 'disabled') { 70 old_href = href; 71 $link.attr('href', ''); 70 72 71 return;72 } else if (href === '') {73 href = old_href;74 }73 return; 74 } else if (href === '') { 75 href = old_href; 76 } 75 77 76 href = href.replace(/\/themes\/[-a-z]+\//g, '/themes/' + style + '/'); 77 $link.attr('href', href); 78 }); 79 80 $('#save-ui-theme').click(function(){ 81 var data = { 82 action: 'cf7dp_save_settings', 83 ui_theme: $('#jquery-ui-theme').val() 84 }; 85 86 var $this_spinner = $spinner.clone(); 87 88 $(this).after($this_spinner.show()); 89 90 $.post(ajaxurl, data, function(response) { 91 var $prev = $( '.wrap > .updated, .wrap > .error' ); 92 var $msg = $(response).hide().insertAfter($('.wrap h2')); 93 if ($prev.length > 0) 94 $prev.fadeOut('slow', function(){ 95 $msg.fadeIn('slow'); 96 }); 97 else 98 $msg.fadeIn('slow'); 99 100 $this_spinner.hide(); 78 href = href.replace(/\/themes\/[-a-z]+\//g, '/themes/' + style + '/'); 79 $link.attr('href', href); 101 80 }); 102 81 103 return false; 82 $('#save-ui-theme').click(function(){ 83 var data = { 84 action: 'cf7dp_save_settings', 85 ui_theme: $('#jquery-ui-theme').val() 86 }; 87 88 var $this_spinner = $spinner.clone(); 89 90 $(this).after($this_spinner.show()); 91 92 $.post(ajaxurl, data, function(response) { 93 var $prev = $( '.wrap > .updated, .wrap > .error' ); 94 var $msg = $(response).hide().insertAfter($('.wrap h2')); 95 if ($prev.length > 0) 96 $prev.fadeOut('slow', function(){ 97 $msg.fadeIn('slow'); 98 }); 99 else 100 $msg.fadeIn('slow'); 101 102 $this_spinner.hide(); 103 }); 104 105 return false; 106 }); 104 107 }); 105 }); 106 </script> 108 </script> 107 109 <?php 108 110 } 109 111 110 public staticfunction ajax_save_settings() {112 function ajax_save_settings() { 111 113 $successmsg = '<div id="message" class="updated fade"><p><strong>' . __('Options saved.') . '</strong></p></div>'; 112 114 $errormsg = '<div id="message" class="error fade"><p><strong>' . __('Options could not be saved.') . '</strong></p></div>'; … … 123 125 die($errormsg); 124 126 125 if (! update_option('cf7dp_ui_theme', $theme)) 126 die($errormsg); 127 if (get_option('cf7dp_ui_theme') !== $theme) 128 if (! update_option('cf7dp_ui_theme', $theme)) 129 die($errormsg); 127 130 128 131 die($successmsg); … … 181 184 } 182 185 } 186 187 new ContactForm7Datepicker_Admin; -
contact-form-7-datepicker/trunk/contact-form-7-datepicker.php
r662953 r694544 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. 2.17 Version: 2.3 8 8 Author URI: https://github.com/relu/ 9 9 */ … … 29 29 class ContactForm7Datepicker { 30 30 31 public static function init() { 32 add_action('plugins_loaded', array(__CLASS__, 'load_date_module'), 10); 31 const JQUERYUI_VERSION = '1.9.2'; 33 32 34 add_action('wpcf7_enqueue_scripts', array(__CLASS__, 'enqueue_js'));35 add_action(' wpcf7_enqueue_styles', array(__CLASS__, 'enqueue_css'));33 function __construct() { 34 add_action('plugins_loaded', array($this, 'load_date_module'), 10); 36 35 37 register_activation_hook(__FILE__, array(__CLASS__, 'activate')); 36 add_action('wpcf7_enqueue_scripts', array($this, 'enqueue_js')); 37 add_action('wpcf7_enqueue_styles', array($this, 'enqueue_css')); 38 39 register_activation_hook(__FILE__, array($this, 'activate')); 38 40 39 41 if (is_admin()) { 40 42 require_once dirname(__FILE__) . '/admin.php'; 41 ContactForm7Datepicker_Admin::init();42 43 } 43 44 } 44 45 45 public staticfunction load_date_module() {46 function load_date_module() { 46 47 require_once dirname(__FILE__) . '/date-module.php'; 47 48 ContactForm7Datepicker_Date::register(); 48 49 } 49 50 50 public staticfunction activate() {51 function activate() { 51 52 if (! get_option('cf7dp_ui_theme')) 52 53 add_option('cf7dp_ui_theme', 'base'); 53 54 } 54 55 55 public static function enqueue_js() { 56 wp_enqueue_script('jquery-ui-datepicker', null, null, null, true); 56 function enqueue_js() { 57 $regional = CF7_DatePicker::get_regional_match(); 58 $proto = is_ssl() ? 'https' : 'http'; 57 59 58 $regional = CF7_DatePicker::get_regional_match(); 60 if (! empty($regional)) { 61 wp_enqueue_script( 62 'jquery-ui-' . $regional, 63 $proto . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::JQUERYUI_VERSION . '/i18n/jquery.ui.datepicker-' . $regional . '.min.js', 64 array('jquery-ui-datepicker'), 65 self::JQUERYUI_VERSION, 66 true 67 ); 68 } 59 69 60 if (! $regional) 61 return; 70 wp_enqueue_script('jquery-ui-datepicker'); 62 71 63 wp_ enqueue_script(64 'jquery-ui- ' . $regional,65 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-' . $regional . '.min.js',72 wp_register_script( 73 'jquery-ui-effect-core', 74 plugins_url('js/jquery.ui.effect.min.js', __FILE__), 66 75 array('jquery-ui-datepicker'), 67 null,76 self::JQUERYUI_VERSION, 68 77 true 69 78 ); 79 80 foreach (CF7_DatePicker::$effects as $effect) { 81 wp_register_script( 82 'jquery-ui-effect-' . $effect, 83 plugins_url('js/jquery.ui.effect-' . $effect . '.min.js', __FILE__), 84 array('jquery-ui-effect-core'), 85 self::JQUERYUI_VERSION, 86 true 87 ); 88 } 70 89 } 71 90 72 public staticfunction enqueue_css() {91 function enqueue_css() { 73 92 $theme = get_option('cf7dp_ui_theme'); 74 93 … … 76 95 return; 77 96 78 wp_enqueue_style('jquery-ui-theme', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/' . $theme . '/jquery-ui.css', array(), ''); 97 $proto = is_ssl() ? 'https' : 'http'; 98 99 wp_enqueue_style( 100 'jquery-ui-theme', 101 $proto . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::JQUERYUI_VERSION . '/themes/' . $theme . '/jquery-ui.css', 102 '', 103 self::JQUERYUI_VERSION, 104 'all' 105 ); 79 106 } 80 107 } 81 108 82 ContactForm7Datepicker::init();109 new ContactForm7Datepicker; -
contact-form-7-datepicker/trunk/date-module.php
r645880 r694544 5 5 public static function register() { 6 6 require_once dirname(__FILE__) . '/datepicker.php'; 7 8 // Remove Contact Form 7's date module 9 remove_action('init', 'wpcf7_add_shortcode_date', 5); 10 remove_filter('wpcf7_validate_date', 'wpcf7_date_validation_filter', 10); 11 remove_filter('wpcf7_validate_date*', 'wpcf7_date_validation_filter', 10); 12 remove_filter('wpcf7_messages', 'wpcf7_date_messages'); 7 13 8 14 // Register shortcodes … … 71 77 } elseif (preg_match('%^change-year$%i', $option, $matches)) { 72 78 $dpOptions['changeYear'] = true; 73 } elseif (preg_match('%^year-range:( \d+)-?(\d+)?$%', $option, $matches)) {74 $dpOptions['yearRange'] = $matches[1] . ':' . @$matches[2];79 } elseif (preg_match('%^year-range:([-+\d]+)[:-]?([-+\d]+)?$%', $option, $matches)) { 80 $dpOptions['yearRange'] = $matches[1]; 75 81 } elseif (preg_match('%^months:(\d+)$%', $option, $matches)) { 76 82 $dpOptions['numberOfMonths'] = (int) $matches[1]; … … 190 196 191 197 private static function animate_dropdown() { 192 $effects = array(193 'show' => __('Show'),194 'blind' => __('Blind'),195 'clip' => __('Clip'),196 'drop' => __('Drop'),197 'explode' => __('Explode'),198 'fade' => __('Fade'),199 'fold' => __('Fold'),200 'puff' => __('Puff'),201 'slide' => __('Slide'),202 'scale' => __('Scale')203 );204 205 $effects = apply_filters('cf7dp_effects', $effects);206 207 198 $html = "<select id=\"animate\">\n"; 208 foreach ($effects as $key => $val) { 209 $html .= "\t<option value=\"{$key}\">{$val}</option>\n"; 199 200 foreach (CF7_DatePicker::$effects as $val) { 201 $html .= '<option value="' . esc_attr($val) . '">' . ucfirst($val) . '</option>'; 210 202 } 211 203 -
contact-form-7-datepicker/trunk/datepicker.php
r662953 r694544 2 2 3 3 class CF7_DatePicker { 4 4 5 private $input_name; 5 6 … … 18 19 ); 19 20 20 protected static $regionals = array( 21 'af' =>'Afrikaans', 22 'sq' =>'Albanian', 23 'ar-DZ' =>'Algerian Arabic', 24 'ar' =>'Arabic', 25 'hy' =>'Armenian', 26 'az' =>'Azerbaijani', 27 'eu' =>'Basque', 28 'bs' =>'Bosnian', 29 'bg' =>'Bulgarian', 30 'ca' =>'Catalan', 31 'zh-HK' =>'Chinese Hong Kong', 32 'zh-CN' =>'Chinese Simplified', 33 'zh-TW' =>'Chinese Traditional', 34 'hr' =>'Croatian', 35 'cs' =>'Czech', 36 'da' =>'Danish', 37 'nl-BE' =>'Dutch', 38 'nl' =>'Dutch', 39 'en-AU' =>'English/Australia', 40 'en-NZ' =>'English/New Zealand', 41 'en-GB' =>'English/UK', 42 'eo' =>'Esperanto', 43 'et' =>'Estonian', 44 'fo' =>'Faroese', 45 'fa' =>'Farsi/Persian', 46 'fi' =>'Finnish', 47 'fr' =>'French', 48 'fr-CH' =>'French/Swiss', 49 'gl' =>'Galician', 50 'de' =>'German', 51 'el' =>'Greek', 52 'he' =>'Hebrew', 53 'hu' =>'Hungarian', 54 'is' =>'Icelandic', 55 'id' =>'Indonesian', 56 'it' =>'Italian', 57 'ja' =>'Japanese', 58 'kk' =>'Kazakhstan', 59 'ko' =>'Korean', 60 'lv' =>'Latvian', 61 'lt' =>'Lithuanian', 62 'lb' =>'Luxembourgish', 63 'mk' =>'Macedonian', 64 'ml' =>'Malayalam', 65 'ms' =>'Malaysian', 66 'no' =>'Norwegian', 67 'pl' =>'Polish', 68 'pt' =>'Portuguese', 69 'pt-BR' =>'Portuguese/Brazilian', 70 'rm' =>'Rhaeto-Romanic', 71 'ro' =>'Romanian', 72 'ru' =>'Russian', 73 'sr' =>'Serbian', 74 'sr-SR' =>'Serbian', 75 'sk' =>'Slovak', 76 'sl' =>'Slovenian', 77 'es' =>'Spanish', 78 'sv' =>'Swedish', 79 'ta' =>'Tamil', 80 'th' =>'Thai', 81 'tj' =>'Tajikistan', 82 'tr' =>'Turkish', 83 'uk' =>'Ukranian', 84 'vi' =>'Vietnamese', 85 'cy-GB' =>'Welsh/UK', 21 private static $regionals = array( 22 'af' => 'Afrikaans', 23 'sq' => 'Albanian', 24 'ar-DZ' => 'Algerian Arabic', 25 'ar' => 'Arabic', 26 'hy' => 'Armenian', 27 'az' => 'Azerbaijani', 28 'eu' => 'Basque', 29 'bs' => 'Bosnian', 30 'bg' => 'Bulgarian', 31 'ca' => 'Catalan', 32 'zh-HK' => 'Chinese Hong Kong', 33 'zh-CN' => 'Chinese Simplified', 34 'zh-TW' => 'Chinese Traditional', 35 'hr' => 'Croatian', 36 'cs' => 'Czech', 37 'da' => 'Danish', 38 'nl-BE' => 'Dutch', 39 'nl' => 'Dutch', 40 'en-AU' => 'English/Australia', 41 'en-NZ' => 'English/New Zealand', 42 'en-GB' => 'English/UK', 43 'eo' => 'Esperanto', 44 'et' => 'Estonian', 45 'fo' => 'Faroese', 46 'fa' => 'Farsi/Persian', 47 'fi' => 'Finnish', 48 'fr' => 'French', 49 'fr-CH' => 'French/Swiss', 50 'gl' => 'Galician', 51 'de' => 'German', 52 'el' => 'Greek', 53 'he' => 'Hebrew', 54 'hu' => 'Hungarian', 55 'is' => 'Icelandic', 56 'id' => 'Indonesian', 57 'it' => 'Italian', 58 'ja' => 'Japanese', 59 'kk' => 'Kazakhstan', 60 'ko' => 'Korean', 61 'lv' => 'Latvian', 62 'lt' => 'Lithuanian', 63 'lb' => 'Luxembourgish', 64 'mk' => 'Macedonian', 65 'ml' => 'Malayalam', 66 'ms' => 'Malaysian', 67 'no' => 'Norwegian', 68 'pl' => 'Polish', 69 'pt' => 'Portuguese', 70 'pt-BR' => 'Portuguese/Brazilian', 71 'rm' => 'Rhaeto-Romanic', 72 'ro' => 'Romanian', 73 'ru' => 'Russian', 74 'sr' => 'Serbian', 75 'sr-SR' => 'Serbian', 76 'sk' => 'Slovak', 77 'sl' => 'Slovenian', 78 'es' => 'Spanish', 79 'sv' => 'Swedish', 80 'ta' => 'Tamil', 81 'th' => 'Thai', 82 'tj' => 'Tajikistan', 83 'tr' => 'Turkish', 84 'uk' => 'Ukranian', 85 'vi' => 'Vietnamese', 86 'cy-GB' => 'Welsh/UK', 87 ); 88 89 public static $effects = array( 90 'show', 91 'blind', 92 'clip', 93 'drop', 94 'explode', 95 'fade', 96 'fold', 97 'highlight', 98 'puff', 99 'pulsate', 100 'slide', 101 'scale', 102 'shake', 103 'transfer', 86 104 ); 87 105 … … 93 111 $this->options = wp_parse_args((array)$options, $this->options); 94 112 $this->options = apply_filters('cf7_datepicker_options', $this->options); 113 114 if ('' !== $this->showAnim) { 115 add_action('wp_footer', array($this, 'enqueue_effect')); 116 } 95 117 } 96 118 … … 116 138 117 139 // Remove watermark class onSelect 118 $out .= ".datepicker('option', 'onSelect', function(){ $(this).removeClass('watermark') ; });\n";140 $out .= ".datepicker('option', 'onSelect', function(){ $(this).removeClass('watermark').trigger('change'); });\n"; 119 141 120 142 $out = "jQuery(function($){ $out });"; … … 161 183 return null; 162 184 } 185 186 public function enqueue_effect() { 187 wp_enqueue_script('jquery-ui-effect-' . $this->showAnim); 188 } 189 163 190 } -
contact-form-7-datepicker/trunk/readme.txt
r662953 r694544 3 3 Tags: wordpress, datepicker, calendar, contact form 7, forms, jqueryui 4 4 Requires at least: 2.9 5 Tested up to: 3.5 6 Stable tag: 2. 2.15 Tested up to: 3.5.1 6 Stable tag: 2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 35 35 == Changelog == 36 37 = 2.3 = 38 * Made it work with CF7 3.4 39 * Use full jquery-ui version on asset paths 40 * Add Date Range feature (thanks @dollardad) 36 41 37 42 = 2.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.