PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 5.8.6
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v5.8.6
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / libraries / cmb2-tabs / js / tabs.js

tabs.js in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 5.8.6, at libraries/cmb2-tabs/js/tabs.js

74 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 // Initial check
3 if( $('.cmb-tabs').length ) {
4 $('.cmb-tabs').each(function() {
5 // Activate first tab
6 if( ! $(this).find('.cmb-tab.active').length ) {
7 $(this).find('.cmb-tab').first().addClass('active');
8
9 $($(this).find('.cmb-tab').first().data('fields')).addClass('cmb-tab-active-item');
10
11 // Support for groups and repeatable fields
12 $($(this).find('.cmb-tab').first().data('fields')).find('.cmb-repeat .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
13 }
14 });
15 }
16
17 $('body').on('click.cmbTabs', '.cmb-tabs .cmb-tab', function(e) {
18 var tab = $(this);
19
20 if( ! tab.hasClass('active') ) {
21 var tabs = tab.closest('.cmb-tabs');
22 var form = tabs.next('.cmb2-wrap');
23
24 // Hide current active tab fields
25 form.find(tabs.find('.cmb-tab.active').data('fields')).fadeOut('fast', function() {
26 $(this).removeClass('cmb-tab-active-item');
27
28 form.find(tab.data('fields')).fadeIn('fast', function() {
29 $(this).addClass('cmb-tab-active-item');
30
31 // Support for groups and repeatable fields
32 $(this).find('.cmb-repeat-table .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
33 });
34 });
35
36 // Update tab active class
37 tabs.find('.cmb-tab.active').removeClass('active');
38 tab.addClass('active');
39 }
40 });
41
42 // Adding a new group element needs to get the active class also
43 $('body').on('click', '.cmb-add-group-row', function() {
44 $(this).closest('.cmb-repeatable-group').find('.cmb-row').addClass('cmb-tab-active-item');
45 });
46
47 // Adding a new repeatable element needs to get the active class also
48 $('body').on('click', '.cmb-add-row-button', function() {
49 $(this).closest('.cmb-repeat').find('.cmb-row').addClass('cmb-tab-active-item');
50 });
51
52 // Initialize on widgets area
53 $(document).on('widget-updated widget-added', function(e, widget) {
54
55 if( widget.find('.cmb-tabs').length ) {
56
57 widget.find('.cmb-tabs').each(function() {
58 // Activate first tab
59 if( ! $(this).find('.cmb-tab.active').length ) {
60 $(this).find('.cmb-tab').first().addClass('active');
61
62 $($(this).find('.cmb-tab').first().data('fields')).addClass('cmb-tab-active-item');
63
64 // Support for groups and repeatable fields
65 $($(this).find('.cmb-tab').first().data('fields')).find('.cmb-repeat .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
66 }
67 });
68
69 }
70
71 });
72
73 })(jQuery);
74