PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / libraries / cmb2-tabs / js / tabs.js

tabs.js in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, 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