Changeset 802789
- Timestamp:
- 11/11/2013 10:40:49 PM (12 years ago)
- Location:
- tailored-tools
- Files:
-
- 68 added
- 5 edited
-
tags/1.7.2 (added)
-
tags/1.7.2/embed-js.php (added)
-
tags/1.7.2/form.contact.php (added)
-
tags/1.7.2/form.sample.php (added)
-
tags/1.7.2/googlemaps.php (added)
-
tags/1.7.2/js (added)
-
tags/1.7.2/js/chosen.jquery.min.js (added)
-
tags/1.7.2/js/jquery.timepicker.js (added)
-
tags/1.7.2/js/loader.js (added)
-
tags/1.7.2/js/tinymce.js.php (added)
-
tags/1.7.2/lib (added)
-
tags/1.7.2/lib/class.akismet.php (added)
-
tags/1.7.2/lib/class.ayah.php (added)
-
tags/1.7.2/lib/class.forms.php (added)
-
tags/1.7.2/lib/class.recaptcha.php (added)
-
tags/1.7.2/lib/countries.php (added)
-
tags/1.7.2/lib/json.php (added)
-
tags/1.7.2/lib/lib.ayah.php (added)
-
tags/1.7.2/lib/recaptchalib.php (added)
-
tags/1.7.2/lib/tinymce.php (added)
-
tags/1.7.2/readme.txt (added)
-
tags/1.7.2/resource (added)
-
tags/1.7.2/resource/admin.css (added)
-
tags/1.7.2/resource/calendar.png (added)
-
tags/1.7.2/resource/chosen-sprite.png (added)
-
tags/1.7.2/resource/chosen-sprite@2x.png (added)
-
tags/1.7.2/resource/chosen.css (added)
-
tags/1.7.2/resource/custom.css (added)
-
tags/1.7.2/resource/exclaim.gif (added)
-
tags/1.7.2/resource/icons.png (added)
-
tags/1.7.2/resource/mce-icon.gif (added)
-
tags/1.7.2/resource/time.png (added)
-
tags/1.7.2/shortcodes.php (added)
-
tags/1.7.2/tools.php (added)
-
tags/1.7.3 (added)
-
tags/1.7.3/embed-js.php (added)
-
tags/1.7.3/form.contact.php (added)
-
tags/1.7.3/form.sample.php (added)
-
tags/1.7.3/googlemaps.php (added)
-
tags/1.7.3/js (added)
-
tags/1.7.3/js/chosen.jquery.min.js (added)
-
tags/1.7.3/js/jquery.timepicker.js (added)
-
tags/1.7.3/js/loader.js (added)
-
tags/1.7.3/js/tinymce.js.php (added)
-
tags/1.7.3/lib (added)
-
tags/1.7.3/lib/class.akismet.php (added)
-
tags/1.7.3/lib/class.ayah.php (added)
-
tags/1.7.3/lib/class.forms.php (added)
-
tags/1.7.3/lib/class.recaptcha.php (added)
-
tags/1.7.3/lib/countries.php (added)
-
tags/1.7.3/lib/json.php (added)
-
tags/1.7.3/lib/lib.ayah.php (added)
-
tags/1.7.3/lib/recaptchalib.php (added)
-
tags/1.7.3/lib/tinymce.php (added)
-
tags/1.7.3/readme.txt (added)
-
tags/1.7.3/resource (added)
-
tags/1.7.3/resource/admin.css (added)
-
tags/1.7.3/resource/calendar.png (added)
-
tags/1.7.3/resource/chosen-sprite.png (added)
-
tags/1.7.3/resource/chosen-sprite@2x.png (added)
-
tags/1.7.3/resource/chosen.css (added)
-
tags/1.7.3/resource/custom.css (added)
-
tags/1.7.3/resource/exclaim.gif (added)
-
tags/1.7.3/resource/icons.png (added)
-
tags/1.7.3/resource/mce-icon.gif (added)
-
tags/1.7.3/resource/time.png (added)
-
tags/1.7.3/shortcodes.php (added)
-
tags/1.7.3/tools.php (added)
-
trunk/js/loader.js (modified) (2 diffs)
-
trunk/lib/class.forms.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shortcodes.php (modified) (2 diffs)
-
trunk/tools.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tailored-tools/trunk/js/loader.js
r726509 r802789 112 112 /** 113 113 * Launch jQuery UI Tabs for .ui_tabs sections 114 * Revised to handle different HTML format, to handle <h2 id="something"> 114 115 */ 115 116 var tab_counter = 0; … … 119 120 $('.ui_tabs').each(function(i, tabset) { 120 121 var ul = $( document.createElement('ul') ); 121 //var ul = $('ul');122 122 $(tabset).find('.tab_panel').each(function() { 123 123 tab_counter++; 124 label = $(this).find('h2:first').text(); 124 tab_id = 'tab-'+tab_counter; 125 label = $(this).prev('h2').text(); 126 hid = $(this).prev('h2').attr('id'); 127 if (typeof hid !== 'undefined' && hid !== false) { 128 tab_id = hid; 129 } 130 $(this).prev('h2').prependTo( $(this) ).removeAttr('id'); 125 131 if (label == '') label = 'TAB_TITLE_MISSING'; 126 $(ul).append('<li><a href="#tab-' + tab_counter + '"><span>' + label + '</span></a></li>'); 127 $(this).attr( 'id', 'tab-'+tab_counter ); 132 $(ul).append('<li><a href="#' + tab_id + '"><span>' + label + '</span></a></li>'); 133 $(this).attr( 'id', tab_id ); 134 // Now set up triggers for <a href="#something"> matching our tab_ids 135 var $this = $(this); 136 $("a[href$='#"+tab_id+"']").click(function(e) { 137 hash = $(this).attr('href').substr($(this).attr('href').indexOf('#')+1); 138 $('.ui-tabs a[href=#'+hash+']').click(); 139 $('html,body').animate({ scrollTop:$('.ui-tabs a[href=#'+tab_id+']').offset().top-30 },500); 140 e.preventDefault; 141 return false; 142 }); 128 143 }); 129 144 $(ul).prependTo( $(tabset) ); 145 // alert( $(tabset).html() ); 130 146 $(tabset).tabs(); 147 131 148 }); 149 // alert('done'); 150 $('.ui-tabs').tabs('load', 2); 132 151 }); 133 152 153 -
tailored-tools/trunk/lib/class.forms.php
r795003 r802789 121 121 $insertID = wp_insert_post(array( 122 122 'post_title' => '', 123 'post_content' => serialize($data),123 'post_content' => json_encode($data), 124 124 'post_status' => 'private', 125 125 'post_type' => $this->log_type, … … 904 904 * Helper to fix the "Error at offset" issue 905 905 */ 906 function __unserialize($sObject) { 907 $__ret =preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $sObject ); 908 return unserialize($__ret); 906 function __unserialize($data) { 907 // First attempt json_decode 908 $decoded = json_decode($data); 909 if ($decoded) return (array) $decoded; 910 // If not, go ahead with unseralize 911 $data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data ); 912 return unserialize($data); 909 913 } 910 914 -
tailored-tools/trunk/readme.txt
r798391 r802789 4 4 Requires at least: 3.0 5 5 Tested up to: 3.7 6 Stable tag: 1.7. 16 Stable tag: 1.7.3 7 7 8 8 Contains some helper classes to help you build custom forms. … … 54 54 55 55 == Changelog == 56 57 = 1.7.3 = 58 * Update how the [tabs] shortcode is parsed & handled to allow for <h2 class="something"> attributes 59 * Update the related JS to handle new format, and to allow for <a href="#something"> triggers 60 61 = 1.7.2 = 62 * Now using json_encode() instead of serialize() when saving arrays to database 63 * Maintaining backwards compat so that old logged records still readable 64 56 65 = 1.7.1 = 57 66 * Fix a stylesheet problem with jquery-chosen -
tailored-tools/trunk/shortcodes.php
r752666 r802789 42 42 * Shortcode: [tabs] for jQuery UI Tabs 43 43 * Javascript does the heavy lifting 44 * Revised this to use DOMDocument instead of str_replace, to allow for <h2 id="something"> 44 45 */ 45 46 function shortcode_ui_tabs($atts=false, $content=null) { … … 48 49 if (substr($content, -3, 3)=='<p>') $content = substr($content, 0, -3); 49 50 $content = trim($content); 50 // Apply a wrapper for each panel 51 $content = str_replace('<h2>', '</div><div class="tab_panel"><h2>', $content); 52 // Fix start and end <div> panels to avoid broken HTML 53 if (substr($content, 0, 6)=='</div>') $content = substr($content, 6); 54 $content .= '</div>'."\n"; 55 // Using do_shortcode() to apply shortcodes inside the tabs 56 $content = '<div class="ui_tabs">'."\n".do_shortcode($content)."\n".'</div>'."\n"; 57 // Add JS 51 52 $dom = new DOMDocument(); 53 $dom->loadHTML( $content ); 54 // Loop H2 and wrap 55 $nodes = $dom->getElementsByTagName('h2'); 56 foreach ($nodes as $i => $h) { 57 $div = $dom->createElement('div'); 58 $div->setAttribute('class', 'tab_panel'); 59 while ($h->nextSibling && $h->nextSibling->localName != 'h2') { 60 $div->appendChild( $h->nextSibling ); 61 } 62 if ($h->nextSibling) { 63 $h->parentNode->insertBefore($div, $h->nextSibling); 64 } else { 65 $h->parentNode->appendChild($div); 66 } 67 } 68 // Now go through and remove empty tags 69 $xp = new DOMXPath($dom); 70 foreach($xp->query('//*[not(node() or self::br) or normalize-space() = ""]') as $node) { 71 $node->parentNode->removeChild($node); 72 } 73 74 $output = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $dom->saveHTML()); 75 $output = '<div class="ui_tabs">'."\n".do_shortcode($output)."\n".'</div>'."\n"; 76 // Fix some strange HTML 77 $output = str_replace('<p><form', '<form', $output); 78 $output = str_replace('</form></p>', '</form>', $output); 79 $output = str_replace("</form>\n</p>", '</form>', $output); 80 58 81 wp_enqueue_script('jquery-ui-tabs'); 59 // Return 60 return $content; 82 return $output; 61 83 } 62 84 -
tailored-tools/trunk/tools.php
r798391 r802789 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.7. 15 Version: 1.7.3 6 6 Author: Tailored Web Services 7 7 Author URI: http://www.tailored.com.au
Note: See TracChangeset
for help on using the changeset viewer.