PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.3
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.3
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 8.0.3, at libraries/cmb2-tabs/js/tabs.js

75 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 var tabs_speed = tabs.data('speed');
24
25 // Hide current active tab fields
26 form.find(tabs.find('.cmb-tab.active').data('fields')).fadeOut(tabs_speed, function() {
27 $(this).removeClass('cmb-tab-active-item');
28
29 form.find(tab.data('fields')).fadeIn(tabs_speed, function() {
30 $(this).addClass('cmb-tab-active-item');
31
32 // Support for groups and repeatable fields
33 $(this).find('.cmb-repeat-table .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
34 });
35 });
36
37 // Update tab active class
38 tabs.find('.cmb-tab.active').removeClass('active');
39 tab.addClass('active');
40 }
41 });
42
43 // Adding a new group element needs to get the active class also
44 $('body').on('click', '.cmb-add-group-row', function() {
45 $(this).closest('.cmb-repeatable-group').find('.cmb-row').addClass('cmb-tab-active-item');
46 });
47
48 // Adding a new repeatable element needs to get the active class also
49 $('body').on('click', '.cmb-add-row-button', function() {
50 $(this).closest('.cmb-repeat').find('.cmb-row').addClass('cmb-tab-active-item');
51 });
52
53 // Initialize on widgets area
54 $(document).on('widget-updated widget-added', function(e, widget) {
55
56 if( widget.find('.cmb-tabs').length ) {
57
58 widget.find('.cmb-tabs').each(function() {
59 // Activate first tab
60 if( ! $(this).find('.cmb-tab.active').length ) {
61 $(this).find('.cmb-tab').first().addClass('active');
62
63 $($(this).find('.cmb-tab').first().data('fields')).addClass('cmb-tab-active-item');
64
65 // Support for groups and repeatable fields
66 $($(this).find('.cmb-tab').first().data('fields')).find('.cmb-repeat .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
67 }
68 });
69
70 }
71
72 });
73
74 })(jQuery);
75