Changeset 2288475
- Timestamp:
- 04/21/2020 02:39:28 PM (6 years ago)
- Location:
- wp-studio-tabs
- Files:
-
- 26 added
- 3 edited
-
tags/1.0.4 (added)
-
tags/1.0.4/css (added)
-
tags/1.0.4/css/style.php (added)
-
tags/1.0.4/css/styles-admin-sortables.css (added)
-
tags/1.0.4/css/styles-admin-tabsets.css (added)
-
tags/1.0.4/css/styles-admin.css (added)
-
tags/1.0.4/css/styles-basic.css (added)
-
tags/1.0.4/css/styles.css (added)
-
tags/1.0.4/images (added)
-
tags/1.0.4/images/wpstudio-logo.png (added)
-
tags/1.0.4/includes (added)
-
tags/1.0.4/includes/manage-page.php (added)
-
tags/1.0.4/includes/metabox.php (added)
-
tags/1.0.4/includes/settings-page.php (added)
-
tags/1.0.4/js (added)
-
tags/1.0.4/js/responsive-tabs.js (added)
-
tags/1.0.4/js/scripts-admin.js (added)
-
tags/1.0.4/js/scripts-tabs-input.js (added)
-
tags/1.0.4/js/scripts-tabs-manager.js (added)
-
tags/1.0.4/readme.txt (added)
-
tags/1.0.4/tabs (added)
-
tags/1.0.4/tabs/css (added)
-
tags/1.0.4/tabs/css/component.css (added)
-
tags/1.0.4/tabs/js (added)
-
tags/1.0.4/tabs/js/cbpFWTabs.js (added)
-
tags/1.0.4/wpstudio-tabs.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tabs/js/cbpFWTabs.js (modified) (1 diff)
-
trunk/wpstudio-tabs.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-studio-tabs/trunk/readme.txt
r2286513 r2288475 6 6 Requires at least: 2.9 7 7 Tested up to: 5.4 8 Stable tag: 1.0. 38 Stable tag: 1.0.4 9 9 10 10 WP Studio Tabs allows you to create/manage simple animated tabs for your Wordpress website. … … 29 29 == Changelog == 30 30 31 = 1.0.4 = 32 33 * Fixed the active tab setting, which was previously not working. If the "Active?" radio button is selected for a particular tab, it will now be open immediately once the page loads. 34 31 35 = 1.0.3 = 32 36 -
wp-studio-tabs/trunk/tabs/js/cbpFWTabs.js
r2242091 r2288475 9 9 * http://www.codrops.com 10 10 */ 11 11 12 ;( function( window ) { 12 13 'use strict'; 13 14 'use strict'; 15 16 function extend( a, b ) { 17 for( var key in b ) { 18 if( b.hasOwnProperty( key ) ) { 19 a[key] = b[key]; 20 } 21 } 22 return a; 23 } 14 24 15 function extend( a, b ) { 16 for( var key in b ) { 17 if( b.hasOwnProperty( key ) ) { 18 a[key] = b[key]; 19 } 20 } 21 return a; 22 } 25 function CBPFWTabs( el, options ) { 26 this.el = el; 27 this.options = extend( {}, this.options ); 28 extend( this.options, options ); 29 this._init(); 30 } 23 31 24 function CBPFWTabs( el, options ) { 25 this.el = el; 26 this.options = extend( {}, this.options ); 27 extend( this.options, options ); 28 this._init(); 29 } 32 CBPFWTabs.prototype.options = { 33 34 //start : 1 35 }; 30 36 31 CBPFWTabs.prototype.options = { 32 start : 0 33 }; 37 CBPFWTabs.prototype._init = function() { 34 38 35 CBPFWTabs.prototype._init = function() { 36 // tabs elemes 37 this.tabs = [].slice.call( this.el.querySelectorAll( 'nav > ul > li' ) ); 38 // content items 39 this.items = [].slice.call( this.el.querySelectorAll( '.content > section' ) ); 40 // current index 41 this.current = -1; 42 // show current content item 43 this._show(); 44 // init events 45 this._initEvents(); 46 }; 39 // tabs elemes 40 this.tabs = [].slice.call( this.el.querySelectorAll( 'nav > ul > li' ) ); 47 41 48 CBPFWTabs.prototype._initEvents = function() { 49 var self = this; 50 this.tabs.forEach( function( tab, idx ) { 51 tab.addEventListener( 'click', function( ev ) { 52 ev.preventDefault(); 53 self._show( idx ); 54 } ); 55 } ); 56 }; 42 // content items 43 this.items = [].slice.call( this.el.querySelectorAll( '.content > section' ) ); 57 44 58 CBPFWTabs.prototype._show = function( idx ) { 59 if( this.current >= 0 ) { 60 this.tabs[ this.current ].className = ''; 61 this.items[ this.current ].className = ''; 62 } 63 // change current 64 this.current = idx != undefined ? idx : this.options.start >= 0 && this.options.start < this.items.length ? this.options.start : 0; 65 this.tabs[ this.current ].className = 'tab-current'; 66 this.items[ this.current ].className = 'content-current'; 67 }; 45 this.current = tabs_index 46 47 this._show(this.current); 68 48 69 // add to global namespace 70 window.CBPFWTabs = CBPFWTabs; 49 // init events 50 this._initEvents(); 51 52 53 }; 54 55 CBPFWTabs.prototype._initEvents = function() { 56 var self = this; 57 this.tabs.forEach( function( tab, idx ) { 58 tab.addEventListener( 'click', function( ev ) { 59 ev.preventDefault(); 60 self._show( idx ); 61 } ); 62 } ); 63 }; 64 65 CBPFWTabs.prototype._show = function( idx ) { 66 67 if( this.current >= 0) { 68 this.tabs[ this.current ].className = ''; 69 this.items[ this.current ].className = ''; 70 } 71 72 // change current 73 this.current = idx != undefined ? idx : this.options.start >= 0 && this.options.start < this.items.length ? this.options.start : 0; 74 75 this.tabs[ this.current ].className = 'tab-current'; 76 this.items[ this.current ].className = 'content-current'; 77 78 }; 79 80 // add to global namespace 81 window.CBPFWTabs = CBPFWTabs; 71 82 72 83 })( window ); -
wp-studio-tabs/trunk/wpstudio-tabs.php
r2286513 r2288475 5 5 * Plugin URI: http://wp-studio.net 6 6 * Description: WP Studio Tabs allows you to create/manage simple animated tabs for your Wordpress website. 7 * Version: 1.0. 37 * Version: 1.0.4 8 8 * Requires at least: 2.9 9 9 * Author: WP Studio … … 51 51 wp_enqueue_style('styles-basic', plugins_url('css/styles-basic.css',__FILE__), '', PLUGIN_VER, ''); 52 52 wp_enqueue_style('component', plugins_url('tabs/css/component.css',__FILE__), '', PLUGIN_VER, ''); 53 wp_enqueue_script('cbpFWTabs.js', plugins_url('tabs/js/cbpFWTabs.js',__FILE__), array('jquery'), PLUGIN_VER, '');54 wp_enqueue_script('responsive-tabs', plugins_url('js/responsive-tabs.js',__FILE__), array('jquery'), PLUGIN_VER, '');53 wp_enqueue_script('cbpFWTabs.js', plugins_url('tabs/js/cbpFWTabs.js',__FILE__), array('jquery'), PLUGIN_VER, false); 54 wp_enqueue_script('responsive-tabs', plugins_url('js/responsive-tabs.js',__FILE__), array('jquery'), PLUGIN_VER, false); 55 55 } 56 56 … … 62 62 wp_enqueue_script('jquery-ui-sortable'); 63 63 wp_enqueue_script('wp-color-picker'); 64 wp_enqueue_script('scripts-admin', plugins_url('js/scripts-admin.js',__FILE__), '', PLUGIN_VER, '');65 64 wp_enqueue_script('scripts-admin', plugins_url('js/scripts-admin.js',__FILE__), '', PLUGIN_VER, false); 65 66 66 //wp_enqueue_script('scripts-tabs-input', plugins_url('js/scripts-tabs-input.js',__FILE__), '', PLUGIN_VER, ''); 67 67 //wp_enqueue_script('scripts-tabs-manager', plugins_url('js/scripts-tabs-manager.js',__FILE__), '', PLUGIN_VER, ''); … … 131 131 $tabs_section_bg = get_post_meta( $post_id, 'tabs_section_bg', true ); 132 132 $tab_font_color = get_post_meta( $post_id, 'tab_font_color', true ); 133 $tab_active = get_post_meta( $post_id, 'wpst_tab_active', true); 133 134 134 135 ob_start(); ?> … … 141 142 $tabs_order = get_post_meta($post_id, 'wpst_tabs_order', true); 142 143 $tabs_order_array = explode(',', $tabs_order); 143 144 //print_r($tabs_order_array); 144 $tabs_idx = 0; 145 145 146 146 foreach ($tabs_order_array as $ordered_tab): 147 $active_idx = ($tab_active == 'wpst_tab_active_'.$ordered_tab ? $tabs_idx : 0); 147 148 $id = !empty($ordered_tab) ? $ordered_tab : 'tab-1'; 148 149 $wpst_tab_label = get_post_meta($post_id, 'wpst_tab_label_'.$id, true); 149 150 $wpst_tab_content = get_post_meta($post_id, 'wpst_tab_content_'.$id, true); 150 151 $html = ''; 151 $html .= '<li><a href="# section-1" class="icon-shop"><span>'.$wpst_tab_label.'</span></a></li>';152 $html .= '<li><a href="#"><span>'.$wpst_tab_label.'</span></a></li>'; 152 153 echo $html; 154 $tabs_idx++; 153 155 endforeach; ?> 154 156 </ul> … … 157 159 <div class="content"> 158 160 <?php 159 $i = 1; 161 162 $content_idx = 1; 160 163 foreach ($tabs_order_array as $ordered_tab): 161 164 $id = !empty($ordered_tab) ? $ordered_tab : 'tab-1'; 162 165 $wpst_tab_label = get_post_meta($post_id, 'wpst_tab_label_'.$id, true); 163 166 $wpst_tab_content = get_post_meta($post_id, 'wpst_tab_content_'.$id, true); 167 164 168 $tml = ''; 165 $tml .= '<section id="section-'.$id.'">';169 $tml .= '<section id="section-'.$id.'" class="'.(($tab_active == 'wpst_tab_active_'.$ordered_tab) ? 'admin-content-current' : '').'">'; 166 170 $tml .= '<div>'; 167 171 $tml .= '<div><p>'.esc_attr($wpst_tab_content).'</p></div>'; 168 172 $tml .= '</div>'; 169 173 $tml .= '</section>'; 170 echo $tml; $ i++;174 echo $tml; $content_idx++; 171 175 endforeach; ?> 172 176 </div><!-- .content --> 173 177 </div><!-- #tabs --> 174 <script>var tabs_id = '<?= 'tabs-'.$post_id; ?>'; new CBPFWTabs(document.getElementById(tabs_id));</script> 178 <script> 179 var tabs_id = '<?= 'tabs-'.$post_id; ?>'; 180 var tabs_index = '<?= $active_idx; ?>'; 181 var tab_current = jQuery('.tabs li'); 182 new CBPFWTabs(document.getElementById(tabs_id), tabs_index); 183 </script> 175 184 </section> 176 185
Note: See TracChangeset
for help on using the changeset viewer.