Commit 0cca95c684afd77124d9ff19d3c6c92ba764f676
1 parent
36b239fd91
Exists in
master
keep selected tab after page refresh
Showing 1 changed file with 36 additions and 4 deletions Side-by-side Diff
resources/views/info_company_new.blade.php
... | ... | @@ -58,10 +58,8 @@ |
58 | 58 | }); |
59 | 59 | |
60 | 60 | $("#list_button").on('click', function () { |
61 | - $('#flot').removeClass('active'); | |
62 | - $('#flot_list').removeClass('showed'); | |
63 | - $('#vacancy').addClass('active'); | |
64 | - $('#vacancy_list').addClass('showed'); | |
61 | + activateTab('vacancy'); | |
62 | + history.pushState({}, '', '#vacancy'); | |
65 | 63 | }) |
66 | 64 | |
67 | 65 | $(document).on('click', '#send_message_to_employer', function() { |
... | ... | @@ -72,6 +70,40 @@ |
72 | 70 | $('#worker_to_user_id').val(this_.attr('data-tuid')); |
73 | 71 | $('#worker_vacancy').val(this_.attr('data-vacancy')); |
74 | 72 | }); |
73 | + | |
74 | + function activateTab(tab) { | |
75 | + if (tab === 'vacancy') { | |
76 | + document.getElementById('flot').classList.remove('active'); | |
77 | + document.getElementById('flot_list').classList.remove('showed'); | |
78 | + document.getElementById('vacancy').classList.add('active'); | |
79 | + document.getElementById('vacancy_list').classList.add('showed'); | |
80 | + } else { | |
81 | + document.getElementById('vacancy').classList.remove('active'); | |
82 | + document.getElementById('vacancy_list').classList.remove('showed'); | |
83 | + document.getElementById('flot').classList.add('active'); | |
84 | + document.getElementById('flot_list').classList.add('showed'); | |
85 | + } | |
86 | + } | |
87 | + | |
88 | + document.addEventListener('DOMContentLoaded', function () { | |
89 | + const hash = window.location.hash; | |
90 | + if (hash === '#vacancy') { | |
91 | + activateTab('vacancy'); | |
92 | + } else { | |
93 | + activateTab('flot'); | |
94 | + } | |
95 | + | |
96 | + document.getElementById('flot').addEventListener('click', function () { | |
97 | + activateTab('flot'); | |
98 | + history.pushState({}, '', '#flot'); | |
99 | + }); | |
100 | + | |
101 | + document.getElementById('vacancy').addEventListener('click', function () { | |
102 | + activateTab('vacancy'); | |
103 | + history.pushState({}, '', '#vacancy'); | |
104 | + }); | |
105 | + | |
106 | + }); | |
75 | 107 | </script> |
76 | 108 | |
77 | 109 | @include('js.favorite-vacancy-45') |