PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.3.3
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.3.3
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / assets / js / builder-mobile-tabs.js

builder-mobile-tabs.js in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.3.3, at assets/js/builder-mobile-tabs.js

61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Mobile-only tabs: Editor vs Preview on invoice/quote builders (lg+ shows both).
3 */
4 (function ($) {
5 'use strict';
6
7 function mqLarge() {
8 return window.matchMedia('(min-width: 1024px)').matches;
9 }
10
11 function applyLayout() {
12 var $e = $('#ei-builder-editor');
13 var $p = $('#ei-builder-preview');
14 if (!$e.length || !$p.length) {
15 return;
16 }
17 if (mqLarge()) {
18 $e.removeClass('hidden');
19 $p.removeClass('hidden');
20 return;
21 }
22 var tab = window.sessionStorage.getItem('ei_builder_tab') || 'editor';
23 if (tab === 'preview') {
24 $e.addClass('hidden');
25 $p.removeClass('hidden');
26 } else {
27 $e.removeClass('hidden');
28 $p.addClass('hidden');
29 }
30 }
31
32 function setActiveTab(which) {
33 $('.ei-builder-tab').each(function () {
34 var isSel = $(this).data('tab') === which;
35 $(this).attr('aria-selected', isSel ? 'true' : 'false');
36 $(this).toggleClass('bg-white shadow-sm text-indigo-700', isSel);
37 $(this).toggleClass('text-gray-600 hover:text-gray-800', !isSel);
38 });
39 }
40
41 $(document).on('click', '.ei-builder-tab', function () {
42 var which = $(this).data('tab');
43 if (!which) {
44 return;
45 }
46 window.sessionStorage.setItem('ei_builder_tab', which);
47 setActiveTab(which);
48 applyLayout();
49 });
50
51 $(window).on('resize', function () {
52 applyLayout();
53 });
54
55 $(function () {
56 var initial = window.sessionStorage.getItem('ei_builder_tab') || 'editor';
57 setActiveTab(initial);
58 applyLayout();
59 });
60 })(jQuery);
61