Changeset 726509
- Timestamp:
- 06/14/2013 02:24:28 AM (13 years ago)
- Location:
- tailored-tools
- Files:
-
- 37 added
- 5 edited
-
tags/1.5.3 (added)
-
tags/1.5.3/embed-js.php (added)
-
tags/1.5.3/form.contact.php (added)
-
tags/1.5.3/form.sample.php (added)
-
tags/1.5.3/googlemaps.php (added)
-
tags/1.5.3/js (added)
-
tags/1.5.3/js/chosen.jquery.min.js (added)
-
tags/1.5.3/js/jquery.timepicker.js (added)
-
tags/1.5.3/js/loader.js (added)
-
tags/1.5.3/js/tinymce.js.php (added)
-
tags/1.5.3/lib (added)
-
tags/1.5.3/lib/class.akismet.php (added)
-
tags/1.5.3/lib/class.ayah.php (added)
-
tags/1.5.3/lib/class.forms.php (added)
-
tags/1.5.3/lib/class.recaptcha.php (added)
-
tags/1.5.3/lib/countries.php (added)
-
tags/1.5.3/lib/json.php (added)
-
tags/1.5.3/lib/lib.ayah.php (added)
-
tags/1.5.3/lib/recaptchalib.php (added)
-
tags/1.5.3/lib/tinymce.php (added)
-
tags/1.5.3/readme.txt (added)
-
tags/1.5.3/resource (added)
-
tags/1.5.3/resource/admin.css (added)
-
tags/1.5.3/resource/calendar.png (added)
-
tags/1.5.3/resource/chosen-sprite.png (added)
-
tags/1.5.3/resource/chosen-sprite@2x.png (added)
-
tags/1.5.3/resource/chosen.css (added)
-
tags/1.5.3/resource/custom.css (added)
-
tags/1.5.3/resource/exclaim.gif (added)
-
tags/1.5.3/resource/icons.png (added)
-
tags/1.5.3/resource/mce-icon.gif (added)
-
tags/1.5.3/resource/time.png (added)
-
tags/1.5.3/shortcodes.php (added)
-
tags/1.5.3/tools.php (added)
-
trunk/embed-js.php (added)
-
trunk/js/jquery.timepicker.js (added)
-
trunk/js/loader.js (modified) (5 diffs)
-
trunk/lib/class.forms.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/resource/custom.css (modified) (3 diffs)
-
trunk/resource/time.png (added)
-
trunk/tools.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tailored-tools/trunk/js/loader.js
r715824 r726509 1 1 2 2 3 /** 3 * Autoloader to validate any form with class 'validate' 4 * Event Tracking with Google Analytics 5 * Can put this function in your theme's custom.js if you want to apply Analytics Event Tracking to your forms 6 * 7 jQuery(document).ready(function($){ 8 // Check on Google Analytics 9 if (!window._gat || !window._gat._getTracker) return; 10 // Contact form 11 $('form.contact').submit(function(e) { 12 if ( !$(this).hasClass('validate') || ($().validate && $(this).valid()) ) { 13 _trackEvent('forms', 'submit', 'Contact form was used') 14 } 15 }); 16 }); 17 18 19 /** 20 * Autoloader validation on any form.validate elements 4 21 */ 5 22 jQuery(document).ready(function($){ 6 23 if ($('form.validate').length < 1) return; 24 if (!$().validate) return; 7 25 $('form.validate').each(function(i) { 8 26 $(this).validate(); … … 10 28 }); 11 29 30 12 31 /** 13 * Autoload datepicker fields - assumes ui-datepicker loaded32 * Autoload datepicker fields 14 33 */ 15 34 jQuery(function($) { 16 35 if ($('form .datepicker').length < 1) return; 36 if (!$().datepicker) return; 17 37 $('form input.datepicker, form p.datepicker input').datepicker({ 18 38 dateFormat: 'dd-mm-yy', … … 20 40 changeYear: true 21 41 }); 22 // Date of birth fields 42 }); 43 44 /** 45 * Autoload timepicker fields 46 */ 47 jQuery(function($) { 48 if ($('form .timepicker').length < 1) return; 49 if (!$().timepicker) return; 50 $('form input.timepicker, form p.timepicker input').timepicker({ 51 timeFormat: 'h:mm tt', 52 stepMinute: 15, 53 hourMin: 8, 54 hourMax: 17 55 }); 56 }); 57 58 /** 59 * Autoload datetimepicker fields 60 */ 61 jQuery(function($) { 62 if ($('form .datetimepicker').length < 1) return; 63 if (!$().datetimepicker) return; 64 $('form input.datetimepicker, form p.datetimepicker input').datetimepicker({ 65 changeMonth: true, 66 changeYear: true, 67 dateFormat: 'dd-mm-yy', 68 timeFormat: 'h:mm tt', 69 stepMinute: 15, 70 hourMin: 8, 71 hourMax: 17 72 }); 73 }); 74 75 /** 76 * If neccessary, can modify time options in another script to remove the hour restrictions. 77 * Like so: 78 * 79 jQuery(document).ready(function($){ 80 $('form input.datetimepicker, form input.timepicker').datetimepicker('option', 'hourMin', 0); 81 $('form input.datetimepicker, form input.timepicker').datetimepicker('option', 'hourMax', 24); 82 }); 83 84 85 /** 86 * Fix for Date Of Birth fields. Changes the Year range. 87 * Applies to both datepicker and timepicker fields. 88 */ 89 jQuery(function($) { 90 if ($('form .dob input.hasDatepicker').length < 1) return; 23 91 var d = new Date(); 24 var range = (d.getFullYear()- 60)+':'+(d.getFullYear()+1);92 var range = (d.getFullYear()-80)+':'+(d.getFullYear()+1); 25 93 $('form .dob input.hasDatepicker').datepicker('option', 'yearRange', range); 26 94 }); 95 27 96 28 97 /** … … 31 100 jQuery(function($) { 32 101 if ($('form p label select').length < 1) return; 102 if (!$().chosen) return; 33 103 $('form p label select').each(function(i) { 104 if ($(this).parent().parent().hasClass('nochosen')) return true; 34 105 if ($(this).find('option').length > 3) { 35 106 $(this).chosen(); … … 44 115 var tab_counter = 0; 45 116 jQuery(document).ready(function($) { 46 if ($('.ui_tabs').size() < 1) { return; } 117 if ($('.ui_tabs').size() < 1) return; 118 if (!$().tabs) return; 47 119 $('.ui_tabs').each(function(i, tabset) { 48 120 var ul = $( document.createElement('ul') ); -
tailored-tools/trunk/lib/class.forms.php
r715824 r726509 419 419 case 'textarea': $this->draw_textarea($key, $q); break; 420 420 case 'date': $this->draw_datepicker($key, $q); break; 421 case 'time': $this->draw_timepicker($key, $q); break; 422 case 'datetime': $this->draw_datetimepicker($key, $q); break; 421 423 default: $this->draw_input($key, $q); break; 422 424 } … … 492 494 echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n"; 493 495 echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt datepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n"; 496 } 497 498 function draw_timepicker($key, $q) { 499 echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n"; 500 echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt timepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n"; 501 wp_enqueue_script('jquery-timepicker'); 502 } 503 504 function draw_datetimepicker($key, $q) { 505 echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n"; 506 echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt datetimepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n"; 507 wp_enqueue_script('jquery-timepicker'); 494 508 } 495 509 -
tailored-tools/trunk/readme.txt
r715881 r726509 4 4 Requires at least: 3.0 5 5 Tested up to: 3.5.1 6 Stable tag: 1.5. 16 Stable tag: 1.5.3 7 7 8 8 Contains some helper classes to help you build custom forms. … … 55 55 == Changelog == 56 56 57 = 1.5.3 = 58 * Added an admin metabox to make it easier to add AdWords conversion tracking code to pages and posts. 59 60 = 1.5.2 = 61 * Introduce new input types: timepicker, datetimepicker 62 * Uses JS library: http://trentrichardson.com/examples/timepicker/ 63 * Allow a class of 'nochosen' on select elements to NOT apply the "Chosen" autoloader. 64 57 65 = 1.5.1 = 58 66 * Fix a formatting error in readme file that was really annoying … … 61 69 * Double-checked some Akismet code 62 70 * Rewrote style rules for better compatibility with Genesis responsive designs (likely have negative effect on existing sites) 63 * Improv de the Datepicker autloader, and add an icon71 * Improve the Datepicker autoloader, and add an icon 64 72 * Added jQuery Chosen and auto-apply to all select boxes (Yes can use MIT license in plugin) https://twitter.com/markjaquith/status/188108457386311681 65 73 -
tailored-tools/trunk/resource/custom.css
r715824 r726509 36 36 form.tws p label input.hasDatepicker { background-image:url(calendar.png); background-position:right 5px center; background-repeat:no-repeat; 37 37 cursor:pointer; max-width:10em; } 38 form.tws p label input.datetimepicker { max-width:14em; } 39 form.tws p label input.timepicker.hasDatepicker { background-image:url(time.png); } 40 38 41 form.tws fieldset { border:0; margin:0 0 1rem 0; padding:0; } 39 42 form.tws fieldset legend { font-weight:bold; margin:0; padding:0 0 1rem; } … … 70 73 * jQuery UI Datepicker 71 74 */ 75 .ui-datepicker { display:none; } 72 76 .ui-datepicker { background:#FFF; border:1px solid #CCC; padding:0.5em; box-shadow:2px 2px 4px #CCC; border-radius:0.3em; font-size:1rem; } 73 77 .ui-datepicker .ui-datepicker-header a { float:left; display:block; width:16px; height:16px; background:url(icons.png) top right no-repeat; text-decoration:none; cursor:pointer; } … … 86 90 .ui-datepicker .ui-datepicker-calendar a.ui-state-active { background:#c7efeb; } 87 91 92 /** 93 * jQuery Timepicker (Datepicker Add-on) 94 */ 95 .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } 96 .ui-timepicker-div dl { text-align: left; } 97 .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; } 98 .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; } 99 .ui-timepicker-div td { font-size: 90%; } 100 .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; } 101 102 .ui-timepicker-rtl{ direction: rtl; } 103 .ui-timepicker-rtl dl { text-align: right; } 104 .ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; } 105 106 .ui-timepicker-div { border-top:1px solid #CCC; margin-top:3px; padding-top:5px; } 107 .ui-timepicker-div select { color:#333; } 108 .ui-datepicker-buttonpane { text-align:center; } 109 .ui-datepicker-buttonpane button { padding:0.5em 1em; margin:0 0.3em; border-radius:0.5em; } 88 110 89 111 /** -
tailored-tools/trunk/tools.php
r715881 r726509 3 3 Plugin Name: Tailored Tools 4 4 Description: Adds some functionality to WordPress that you'll need. (Version 1.5+ has different style rules. Do not upgrade without checking these.) 5 Version: 1.5. 15 Version: 1.5.3 6 6 Author: Tailored Web Services 7 7 Author URI: http://www.tailored.com.au … … 19 19 // Javascript 20 20 wp_deregister_script('jquery-validate'); // Assume this plugin is more up-to-date than other sources. Might be bad mannered. 21 // wp_register_script('jquery-validate', '//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array('jquery'), '1.9.0', true);22 21 wp_register_script('jquery-validate', '//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js', array('jquery'), '1.11.1', true); 23 22 wp_register_script('jquery-chosen', plugins_url('js/chosen.jquery.min.js', __FILE__), array('jquery'), false, true); 24 wp_register_script('ttools-loader', plugins_url('js/loader.js', __FILE__), array('jquery-validate','jquery-ui-datepicker', 'jquery-chosen'), false, true); 23 wp_register_script('jquery-timepicker', plugins_url('js/jquery.timepicker.js', __FILE__), array('jquery'), 1.3, true); 24 wp_register_script('ttools-loader', plugins_url('js/loader.js', __FILE__), array('jquery-validate','jquery-ui-datepicker', 'jquery-timepicker', 'jquery-chosen'), false, true); 25 25 } 26 26 … … 42 42 //if (!class_exists('SampleForm') require( dirname(__FILE__).'/form.sample.php' ); 43 43 44 44 // Helper to embed JS like Adwords Conversion Code 45 if (!class_exists('ttools_embed_page_js')) require( dirname(__FILE__).'/embed-js.php' ); 45 46 46 47
Note: See TracChangeset
for help on using the changeset viewer.