sr-npm 1.2.13 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/backend/consts.js CHANGED
@@ -72,9 +72,6 @@ const TASKS = {
72
72
  }
73
73
  }
74
74
 
75
-
76
-
77
-
78
75
  const TASK_TYPE = {
79
76
  SCHEDULED: 'scheduled',
80
77
  EVENT: 'event',
@@ -92,10 +89,6 @@ const supportTeamsPageIds={
92
89
  VIDEO_TITLE: "#videoTitle",
93
90
  VIDEO_PLAYER: "#videoPlayer",
94
91
 
95
-
96
-
97
-
98
-
99
92
  RECENTLEY_ADDED_JOBS_ITEM: "#recentleyAddedJobsItem",
100
93
  JOB_LOCATION: "#jobLocation",
101
94
  JOB_TITLE: "#jobTitle",
@@ -137,12 +130,13 @@ const supportTeamsPageSections={
137
130
  VIDEO: "video",
138
131
  }
139
132
 
140
- module.exports = {
141
- TASKS_NAMES,
142
- TASK_TYPE,
143
- TASKS,
144
- QUERY_MAX_LIMIT,
145
- supportTeamsPageIds,
146
- LINKS,
147
- supportTeamsPageSections,
133
+
134
+ module.exports = {
135
+ TASKS_NAMES,
136
+ TASK_TYPE,
137
+ TASKS,
138
+ QUERY_MAX_LIMIT,
139
+ supportTeamsPageIds,
140
+ LINKS,
141
+ supportTeamsPageSections,
148
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,17 +23,22 @@ const pagination = {
23
23
  };
24
24
  async function careersMultiBoxesPageOnReady(_$w,urlParams) {
25
25
  await loadData(_$w);
26
- // loadJobsRepeater(_$w);
27
- // loadPrimarySearchRepeater(_$w);
28
- // await loadFilters(_$w);
29
- // loadSelectedValuesRepeater(_$w);
30
- // bindSearchInput(_$w);
31
- // loadPaginationButtons(_$w);
26
+ loadJobsRepeater(_$w);
27
+ loadPrimarySearchRepeater(_$w);
28
+ await loadFilters(_$w);
29
+ loadSelectedValuesRepeater(_$w);
30
+ bindSearchInput(_$w);
31
+ loadPaginationButtons(_$w);
32
+
33
+ if (await window.formFactor() === "Mobile") {
34
+ handleFilterInMobile(_$w);
35
+ }
32
36
 
33
- // await handleUrlParams(_$w, urlParams);
34
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
35
- // await clearAll(_$w);
36
- // });
37
+ await handleUrlParams(_$w, urlParams);
38
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
39
+ await clearAll(_$w);
40
+ });
41
+
37
42
  }
38
43
 
39
44
  async function clearAll(_$w) {
@@ -51,6 +56,41 @@ async function clearAll(_$w) {
51
56
  }
52
57
  }
53
58
 
59
+ function handleFilterInMobile(_$w) {
60
+ const searchResultsSelectors = [
61
+ CAREERS_PAGE_SELECTORS.RESULT_BOX,
62
+ CAREERS_PAGE_SELECTORS.PAGINATION_BTN,
63
+ CAREERS_PAGE_SELECTORS.HEAD_BTNS,
64
+ CAREERS_PAGE_SELECTORS.SELECTED_VALUES_REPEATER,
65
+ CAREERS_PAGE_SELECTORS.BUTTOM_TXT,
66
+ CAREERS_PAGE_SELECTORS.SECTION_24,
67
+ CAREERS_PAGE_SELECTORS.SECTION_3,
68
+ CAREERS_PAGE_SELECTORS.LINE_3,
69
+ CAREERS_PAGE_SELECTORS.FILTER_ICON];
70
+
71
+ _$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).onClick(()=>{
72
+ _$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).expand();
73
+ searchResultsSelectors.forEach(selector => {
74
+ _$w(selector).collapse();
75
+ });
76
+ });
77
+
78
+ const exitFilterBox = () => {
79
+ _$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).collapse();
80
+ searchResultsSelectors.forEach(selector => {
81
+ _$w(selector).expand();
82
+ });
83
+ }
84
+
85
+ _$w(CAREERS_PAGE_SELECTORS.EXIT_BUTTON).onClick(()=>{
86
+ exitFilterBox();
87
+ });
88
+
89
+ _$w(CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON).onClick(()=>{
90
+ exitFilterBox();
91
+ });
92
+ }
93
+
54
94
 
55
95
  async function handleUrlParams(_$w,urlParams) {
56
96
  try {
@@ -193,7 +233,6 @@ async function loadData() {
193
233
  console.error('Failed to load data:', error);
194
234
  }
195
235
  }
196
-
197
236
  async function loadJobsRepeater(_$w) {
198
237
  try {
199
238
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).onItemReady(($item, itemData) => {
@@ -225,7 +264,7 @@ async function loadJobsRepeater(_$w) {
225
264
  async function loadFilters(_$w) {
226
265
  try {
227
266
  // 1) Load all categories (fields)
228
- const cities = await getAllRecords(COLLECTIONS.CITIES);
267
+ const cities=await getAllRecords(COLLECTIONS.CITIES);
229
268
  for(const city of cities) {
230
269
  valueToJobs[city._id]=city.jobIds;
231
270
  }
@@ -260,24 +299,27 @@ async function loadJobsRepeater(_$w) {
260
299
  updateOptionsUI(_$w,field.title, field._id, ''); // no search query
261
300
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
262
301
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
263
- dontUpdateThisCheckBox=field._id;
264
- const selected = ev.target.value; // array of selected value IDs
265
- console.log("ev: ",ev)
266
- console.log("ev.target: ",ev.target)
267
- if (selected && selected.length) {
268
- selectedByField.set(field._id, selected);
269
- } else {
270
- selectedByField.delete(field._id);
271
- }
272
- await updateJobsAndNumbersAndFilters(_$w);
273
- });
274
-
275
- const runFilter = debounce(() => {
276
- const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
277
- updateOptionsUI(_$w, field.title, field._id, query);
278
-
302
+ console.log("i am here !!!!!")
303
+ console.log("field.title: ",field.title)
304
+ console.log("value: ",value)
305
+ dontUpdateThisCheckBox=field._id;
306
+ const selected = ev.target.value; // array of selected value IDs
307
+ console.log("ev: ",ev)
308
+ console.log("ev.target: ",ev.target)
309
+ if (selected && selected.length) {
310
+ selectedByField.set(field._id, selected);
311
+ } else {
312
+ selectedByField.delete(field._id);
313
+ }
314
+ await updateJobsAndNumbersAndFilters(_$w);
315
+
316
+ });
317
+ const runFilter = debounce(() => {
318
+ const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
319
+ updateOptionsUI(_$w, field.title, field._id, query);
279
320
  }, 150);
280
321
  _$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
322
+
281
323
  }
282
324
  await refreshFacetCounts(_$w);
283
325
 
@@ -5,12 +5,10 @@ const { query,queryParams,onChange} = require("wix-location-frontend");
5
5
  const { location } = require("@wix/site-location");
6
6
  const { COLLECTIONS } = require('../backend/collectionConsts');
7
7
  const { careersMultiBoxesPageOnReady } = require('./careersMultiBoxesPage');
8
-
9
- const {
10
- debounce,
11
- getFilter,
12
- } = require('../public/filterUtils');
8
+ const { debounce, getFilter} = require('../public/filterUtils');
9
+ const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS } = require('../public/selectors');
13
10
  const { filterBrokenMarkers } = require('../public/utils');
11
+
14
12
  let currentLoadedItems =100;
15
13
  const itemsPerPage = 100;
16
14
  let allJobs=[]
@@ -45,22 +43,25 @@ async function careersPageOnReady(_$w,thisObject=null,queryParams=null) {
45
43
  queryJobTypeVar=jobType;
46
44
  queryBrandVar=brand;
47
45
  thisObjectVar=thisObject;
48
- allJobs=await getAllPositions();
46
+ allJobs = await getAllPositions();
47
+
49
48
  activateAutoLoad(_$w);
50
49
  await bind(_$w);
51
50
  init(_$w);
52
51
  await handleBrandDropdown(_$w);
53
52
  await handleUrlParams(_$w);
53
+
54
54
  }
55
- }
56
55
 
56
+
57
+ }
57
58
 
58
59
  function activateAutoLoad(_$w)
59
60
  {
60
- _$w("#jobsDataset").onReady(() => {
61
+ _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).onReady(() => {
61
62
  updateCount(_$w);
62
- _$w("#section2").onViewportEnter(() => {
63
- if (currentLoadedItems<_$w("#jobsDataset").getTotalCount()) {
63
+ _$w(CAREERS_PAGE_SELECTORS.FOOTER).onViewportEnter(() => {
64
+ if (currentLoadedItems<_$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount()) {
64
65
  loadMoreJobs(_$w);
65
66
  }
66
67
  else {
@@ -80,10 +81,12 @@ async function loadMoreJobs(_$w) {
80
81
  pageParamSet = Number(pageParamSet) + 1;
81
82
  }
82
83
  if (shouldLoad) {
83
- _$w("#jobsDataset").loadMore();
84
+ _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).loadMore();
84
85
  console.log("loading more jobs");
86
+
85
87
  currentLoadedItems = currentLoadedItems + itemsPerPage;
86
- const data = _$w("#positionsRepeater").data;
88
+ const data = _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).data;
89
+
87
90
  console.log("data length is : ", data.length);
88
91
  setPageParamInUrl();
89
92
  }
@@ -106,26 +109,26 @@ async function handleUrlParams(_$w) {
106
109
  if (queryKeyWordVar) {
107
110
  await handleKeyWordParam(_$w,queryKeyWordVar);
108
111
  }
109
- if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
112
+ if (queryBrandVar && _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).isVisible) { //if it is not visible, ignore it
110
113
  await handleBrandParam(_$w,queryBrandVar);
111
114
  }
112
- if (queryPageVar) {
113
- await handlePageParam(_$w);
114
- }
115
- if (queryDepartmentVar) {
116
- await handleDepartmentParam(_$w,queryDepartmentVar);
117
- }
118
- if (queryLocationVar) {
119
- await handleLocationParam(_$w,queryLocationVar);
120
- }
121
- if (queryJobTypeVar) {
122
- await handleJobTypeParam(_$w,queryJobTypeVar);
123
- }
115
+ if (queryPageVar) {
116
+ await handlePageParam(_$w);
117
+ }
118
+ if (queryDepartmentVar) {
119
+ await handleDepartmentParam(_$w,queryDepartmentVar);
120
+ }
121
+ if (queryLocationVar) {
122
+ await handleLocationParam(_$w,queryLocationVar);
123
+ }
124
+ if (queryJobTypeVar) {
125
+ await handleJobTypeParam(_$w,queryJobTypeVar);
126
+ }
124
127
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
125
128
  }
126
129
 
127
130
  async function handleKeyWordParam(_$w,keyWord) {
128
- _$w('#searchInput').value = keyWord;
131
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value = keyWord;
129
132
  // Use applyFilters to maintain consistency instead of directly setting filter
130
133
  }
131
134
 
@@ -145,18 +148,18 @@ async function handlePageParam(_$w) {
145
148
  //scrolls a bit to load the dataset data
146
149
  await window.scrollTo(0, 200,{scrollAnimation:false});
147
150
  for (let i = 2; i <= queryPageVar; i++) {
148
- await _$w("#jobsDataset").loadMore();
151
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).loadMore();
149
152
  currentLoadedItems=currentLoadedItems+itemsPerPage
150
153
  }
151
154
  // the timeout is to wait for the repeater to render, then scroll to the last item.
152
155
  setTimeout(() => {
153
- const data = _$w("#positionsRepeater").data;
156
+ const data = _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).data;
154
157
  if (data && data.length > 0) {
155
158
  //the dataset each time it loads 100 items
156
159
  const lastIndex = data.length - itemsPerPage;
157
- _$w("#positionsRepeater").forEachItem(async ($item, itemData, index) => {
160
+ _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).forEachItem(async ($item, itemData, index) => {
158
161
  if (index === lastIndex) {
159
- await $item("#positionItem").scrollTo();
162
+ await $item(CAREERS_PAGE_SELECTORS.POSITION_ITEM).scrollTo();
160
163
  console.log("finishied scrolling inside handlePageParam")
161
164
  }
162
165
  });
@@ -167,40 +170,40 @@ async function handlePageParam(_$w) {
167
170
  }
168
171
 
169
172
  async function bind(_$w) {
170
- await _$w('#jobsDataset').onReady(async () => {
173
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).onReady(async () => {
171
174
  await updateCount(_$w);
172
175
  await updateMapMarkers(_$w);
173
176
 
174
177
  });
175
178
 
176
179
  if (await window.formFactor() === "Mobile") {
177
- _$w('#dropdownsContainer').collapse();
180
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER).collapse();
178
181
  }
179
182
 
180
183
  }
181
184
 
182
185
  function init(_$w) {
183
186
  const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
184
- _$w('#searchInput').onInput(debouncedSearch);
185
- _$w('#searchInput').onBlur(()=>{
186
- if(searchInputBlurredFirstTime && _$w('#searchInput').value.trim() !== '')
187
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).onInput(debouncedSearch);
188
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).onBlur(()=>{
189
+ if(searchInputBlurredFirstTime && _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value.trim() !== '')
187
190
  {
188
- _$w('#searchInput').focus();
189
- searchInputBlurredFirstTime=false;
191
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).focus();
192
+ searchInputBlurredFirstTime=false;
190
193
  }
191
194
  });
192
- _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType, #dropdownBrand').onChange(()=>{
195
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
193
196
  console.log("dropdown onChange is triggered");
194
197
  applyFilters(_$w);
195
198
  });
196
- _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
199
+ _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON, CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
197
200
 
198
- _$w('#openFiltersButton').onClick(()=>{
199
- _$w('#dropdownsContainer, #closeFiltersButton').expand();
201
+ _$w(CAREERS_PAGE_SELECTORS.OPEN_FILTERS_BUTTON).onClick(()=>{
202
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
200
203
  });
201
204
 
202
- _$w('#closeFiltersButton').onClick(()=>{
203
- _$w('#dropdownsContainer, #closeFiltersButton').collapse();
205
+ _$w(CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).onClick(()=>{
206
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
204
207
  });
205
208
 
206
209
  //URL onChange
@@ -219,7 +222,7 @@ async function handleBackAndForth(_$w){
219
222
  else{
220
223
  queryDepartmentVar=undefined;
221
224
  deletedParam=true;
222
- _$w('#dropdownDepartment').value = '';
225
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value = '';
223
226
  }
224
227
  if(newQueryParams.location){
225
228
  queryLocationVar=newQueryParams.location;
@@ -227,7 +230,7 @@ async function handleBackAndForth(_$w){
227
230
  else{
228
231
  queryLocationVar=undefined;
229
232
  deletedParam=true
230
- _$w('#dropdownLocation').value = '';
233
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value = '';
231
234
  }
232
235
  if(newQueryParams.keyWord){
233
236
  queryKeyWordVar=newQueryParams.keyWord;
@@ -235,7 +238,7 @@ async function handleBackAndForth(_$w){
235
238
  else{
236
239
  queryKeyWordVar=undefined;
237
240
  deletedParam=true;
238
- _$w('#searchInput').value = '';
241
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value = '';
239
242
  }
240
243
  if(newQueryParams.jobType){
241
244
  queryJobTypeVar=newQueryParams.jobType;
@@ -243,16 +246,16 @@ async function handleBackAndForth(_$w){
243
246
  else{
244
247
  queryJobTypeVar=undefined;
245
248
  deletedParam=true;
246
- _$w('#dropdownJobType').value = '';
249
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value = '';
247
250
  }
248
- if(_$w('#dropdownBrand').isVisible){
251
+ if(_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).isVisible){
249
252
  if(newQueryParams.brand){
250
253
  queryBrandVar=newQueryParams.brand;
251
254
  }
252
255
  else{
253
256
  queryBrandVar=undefined;
254
257
  deletedParam=true;
255
- _$w('#dropdownBrand').value = '';
258
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
256
259
  }
257
260
  }
258
261
  await handleUrlParams(_$w);
@@ -262,11 +265,11 @@ async function handleBackAndForth(_$w){
262
265
  async function applyFilters(_$w, skipUrlUpdate = false) {
263
266
  console.log("applying filters");
264
267
  const dropdownFiltersMapping = [
265
- { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value },
266
- { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value },
267
- { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value},
268
- { elementId: '#dropdownBrand', field: 'brand', value: _$w('#dropdownBrand').value},
269
- { elementId: '#searchInput', field: 'title', value: _$w('#searchInput').value }
268
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, field: 'department', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value },
269
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, field: 'cityText', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value },
270
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, field: 'remote', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value},
271
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND, field: 'brand', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value},
272
+ { elementId: CAREERS_PAGE_SELECTORS.SEARCH_INPUT, field: 'title', value: _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value }
270
273
  ];
271
274
  console.log("dropdownFiltersMapping: ", dropdownFiltersMapping);
272
275
 
@@ -285,16 +288,16 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
285
288
  // build filters
286
289
  if (filter.value && filter.value.trim() !== '') {
287
290
  if (!skipUrlUpdate) {
288
- if(filter.field === 'title'){
291
+ if(filter.field === FILTER_FIELDS.SEARCH){
289
292
  queryParams.add({ keyWord: filter.value });
290
293
  }
291
- if(filter.field === 'department'){
294
+ if(filter.field === FILTER_FIELDS.DEPARTMENT){
292
295
  queryParams.add({ department: encodeURIComponent(filter.value) });
293
296
  }
294
- if(filter.field === 'cityText'){
297
+ if(filter.field === FILTER_FIELDS.LOCATION){
295
298
  queryParams.add({ location: encodeURIComponent(filter.value) });
296
299
  }
297
- if(filter.field === 'remote'){
300
+ if(filter.field === FILTER_FIELDS.JOB_TYPE){
298
301
  if(filter.value === 'true'){
299
302
  queryParams.add({ jobType: encodeURIComponent("remote") });
300
303
  }
@@ -302,11 +305,11 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
302
305
  queryParams.add({ jobType: encodeURIComponent("onsite") });
303
306
  }
304
307
  }
305
- if(filter.field === 'brand'){
308
+ if(filter.field === FILTER_FIELDS.BRAND){
306
309
  queryParams.add({ brand: encodeURIComponent(filter.value) });
307
310
  }
308
311
  }
309
- if(filter.field === 'remote') {
312
+ if(filter.field === FILTER_FIELDS.JOB_TYPE) {
310
313
  value = filter.value === 'true';
311
314
  } else {
312
315
  value = filter.value;
@@ -315,22 +318,22 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
315
318
  }
316
319
  else{
317
320
  if (!skipUrlUpdate) {
318
- if(filter.field === 'title'){
321
+ if(filter.field === FILTER_FIELDS.SEARCH){
319
322
  queryParams.remove(["keyWord" ]);
320
323
  }
321
- if(filter.field === 'department'){
324
+ if(filter.field === FILTER_FIELDS.DEPARTMENT){
322
325
  console.log("removing department from url")
323
326
  queryParams.remove(["department" ]);
324
327
  }
325
- if(filter.field === 'cityText'){
328
+ if(filter.field === FILTER_FIELDS.LOCATION){
326
329
  console.log("removing location from url")
327
330
  queryParams.remove(["location" ]);
328
331
  }
329
- if(filter.field === 'remote'){
332
+ if(filter.field === FILTER_FIELDS.JOB_TYPE){
330
333
  console.log("removing jobType from url")
331
334
  queryParams.remove(["jobType" ]);
332
335
  }
333
- if(filter.field === 'brand'){
336
+ if(filter.field === FILTER_FIELDS.BRAND){
334
337
  console.log("removing brand from url")
335
338
  queryParams.remove(["brand" ]);
336
339
  }
@@ -339,32 +342,32 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
339
342
  });
340
343
 
341
344
  const filter = await getFilter(filters, 'and');
342
- await _$w('#jobsDataset').setFilter(filter);
343
- await _$w('#jobsDataset').refresh();
345
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).setFilter(filter);
346
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).refresh();
344
347
 
345
348
  const count = await updateCount(_$w);
346
349
  console.log("updating map markers");
347
350
  await updateMapMarkers(_$w);
348
351
  console.log("updating map markers completed");
349
- count ? _$w('#resultsMultiState').changeState('results') : _$w('#resultsMultiState').changeState('noResults');
352
+ count ? _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results') : _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('noResults');
350
353
 
351
354
 
352
355
  // Update reset button state
353
356
  const hasActiveFilters = filters.length > 0;
354
- hasActiveFilters? _$w('#resetFiltersButton').enable() : _$w('#resetFiltersButton').disable();
357
+ hasActiveFilters? _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).enable() : _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).disable();
355
358
 
356
359
 
357
360
  }
358
361
 
359
362
  async function resetFilters(_$w) {
360
- _$w('#searchInput, #dropdownDepartment, #dropdownLocation, #dropdownJobType, #dropdownBrand').value = '';
363
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT, CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
361
364
 
362
- await _$w('#jobsDataset').setFilter(wixData.filter());
363
- await _$w('#jobsDataset').refresh();
365
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).setFilter(wixData.filter());
366
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).refresh();
364
367
 
365
- _$w('#resultsMultiState').changeState('results');
368
+ _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results');
366
369
 
367
- _$w('#resetFiltersButton').disable();
370
+ _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).disable();
368
371
 
369
372
  queryParams.remove(["keyWord", "department","page","location","jobType","brand"]);
370
373
 
@@ -376,7 +379,7 @@ async function resetFilters(_$w) {
376
379
  }
377
380
 
378
381
  async function updateCount(_$w) {
379
- const count = await _$w('#jobsDataset').getTotalCount();
382
+ const count = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount();
380
383
  _$w('#numOfPositionText').text = `Showing ${count} Open Positions`;
381
384
 
382
385
  return count;
@@ -387,19 +390,19 @@ async function handleDepartmentParam(_$w,department) {
387
390
 
388
391
 
389
392
 
390
- let dropdownOptions = _$w('#dropdownDepartment').options;
393
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).options;
391
394
  console.log("dropdown options:", dropdownOptions);
392
395
  const optionsFromCMS=await wixData.query("AmountOfJobsPerDepartment").find();
393
396
  //+1 because of the "All" option
394
397
 
395
398
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
396
- fixDropdownOptions('#dropdownDepartment',optionsFromCMS, _$w);
399
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT,optionsFromCMS, _$w);
397
400
  }
398
401
 
399
- if (_$w('#dropdownDepartment').options.find(option => option.value === departmentValue))
402
+ if (_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).options.find(option => option.value === departmentValue))
400
403
  {
401
404
  console.log("department value found in dropdown options ",departmentValue);
402
- _$w('#dropdownDepartment').value = departmentValue;
405
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value = departmentValue;
403
406
  }
404
407
  else{
405
408
  console.warn("department value not found in dropdown options");
@@ -428,18 +431,18 @@ function fixDropdownOptions(dropdown,optionsFromCMS, _$w){
428
431
 
429
432
  async function handleLocationParam(_$w,location) {
430
433
  const locationValue = decodeURIComponent(location);
431
- let dropdownOptions = _$w('#dropdownLocation').options;
434
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).options;
432
435
  console.log("location dropdown options:", dropdownOptions);
433
436
  const optionsFromCMS=await wixData.query("cities").find();
434
437
  //+1 because of the "All" option
435
438
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
436
- fixDropdownOptions('#dropdownLocation',optionsFromCMS, _$w);
439
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION,optionsFromCMS, _$w);
437
440
  }
438
441
 
439
- const option=_$w('#dropdownLocation').options.find(option => option.value.toLowerCase() === locationValue.toLowerCase())
442
+ const option=_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).options.find(option => option.value.toLowerCase() === locationValue.toLowerCase())
440
443
 
441
444
  if(option){
442
- _$w('#dropdownLocation').value = option.value;
445
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value = option.value;
443
446
  }
444
447
  else{
445
448
  console.warn("location value not found in dropdown options");
@@ -450,15 +453,15 @@ async function handleLocationParam(_$w,location) {
450
453
 
451
454
  async function handleBrandParam(_$w,brand){
452
455
  const brandValue = decodeURIComponent(brand);
453
- let dropdownOptions = _$w('#dropdownBrand').options;
456
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).options;
454
457
  console.log("brand dropdown options:", dropdownOptions);
455
458
  const optionsFromCMS=await wixData.query(COLLECTIONS.BRANDS).find();
456
459
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
457
- fixDropdownOptions('#dropdownBrand',optionsFromCMS, _$w);
460
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND,optionsFromCMS, _$w);
458
461
  }
459
- const option=_$w('#dropdownBrand').options.find(option => option.value.toLowerCase() === brandValue.toLowerCase())
462
+ const option=_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).options.find(option => option.value.toLowerCase() === brandValue.toLowerCase())
460
463
  if(option){
461
- _$w('#dropdownBrand').value = option.value;
464
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = option.value;
462
465
  }
463
466
  else{
464
467
  console.warn("brand value not found in dropdown options");
@@ -468,7 +471,7 @@ async function handleBrandParam(_$w,brand){
468
471
 
469
472
  async function handleJobTypeParam(_$w,jobType) {
470
473
  const jobTypeValue = decodeURIComponent(jobType);
471
- let dropdownOptions = _$w('#dropdownJobType').options;
474
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).options;
472
475
  console.log("jobType dropdown options:", dropdownOptions);
473
476
  let option;
474
477
  if(jobTypeValue.toLowerCase()==="remote"){
@@ -478,7 +481,7 @@ async function handleJobTypeParam(_$w,jobType) {
478
481
  option="false";
479
482
  }
480
483
  if(option){
481
- _$w('#dropdownJobType').value = option;
484
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value = option;
482
485
  }
483
486
  else{
484
487
  console.warn("jobType value not found in dropdown options");
@@ -487,8 +490,8 @@ async function handleJobTypeParam(_$w,jobType) {
487
490
  }
488
491
 
489
492
  async function updateMapMarkers(_$w){
490
- const numOfItems = await _$w('#jobsDataset').getTotalCount();
491
- const items = await _$w('#jobsDataset').getItems(0, numOfItems);
493
+ const numOfItems = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount();
494
+ const items = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getItems(0, numOfItems);
492
495
  const markers = filterBrokenMarkers(items.items).map(item => {
493
496
  const location = item.locationAddress.location;
494
497
  return {
@@ -501,21 +504,21 @@ async function updateMapMarkers(_$w){
501
504
  };
502
505
  });
503
506
  //@ts-ignore
504
- _$w('#googleMaps').setMarkers(markers);
507
+ _$w(CAREERS_PAGE_SELECTORS.GOOGLE_MAPS).setMarkers(markers);
505
508
 
506
509
  }
507
510
 
508
511
  async function handleBrandDropdown(_$w){
509
512
  if(siteconfig.disableMultiBrand==="false"){
510
- const brands=await wixData.query(COLLECTIONS.BRANDS).find();
511
- if(brands.items.length>1){
512
- console.log("showing brand dropdown");
513
- _$w('#dropdownBrand').show();
513
+ const brands=await wixData.query(COLLECTIONS.BRANDS).find();
514
+ if(brands.items.length>1){
515
+ console.log("showing brand dropdown");
516
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).show();
517
+ }
518
+ }
519
+ else{
520
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).hide();
514
521
  }
515
- }
516
- else{
517
- _$w('#dropdownBrand').hide();
518
- }
519
522
  }
520
523
  module.exports = {
521
524
  careersPageOnReady,
@@ -0,0 +1,53 @@
1
+ const CAREERS_PAGE_SELECTORS = {
2
+ FILTER_ICON: '#filterIcon',
3
+ FILTER_BOX: '#filterBox',
4
+ RESULT_BOX: '#resultBox',
5
+ PAGINATION_BTN: '#paginationBtn',
6
+ HEAD_BTNS: '#headBtns',
7
+ SELECTED_VALUES_REPEATER: '#selectedValuesReapter',
8
+ BUTTOM_TXT: '#buttomTxt',
9
+ SECTION_24: '#section24',
10
+ SECTION_3: '#section3',
11
+ LINE_3: '#line3',
12
+ EXIT_BUTTON: '#exitBtn',
13
+ REFINE_SEARCH_BUTTON: '#refineSearchBtn',
14
+
15
+ POSITIONS_REPEATER: '#positionsRepeater',
16
+ POSITION_ITEM: '#positionItem',
17
+ SEARCH_INPUT: '#searchInput',
18
+ CLEAR_SEARCH: '#clearSearch',
19
+
20
+ DROPDOWN_BRAND: '#dropdownBrand',
21
+ DROPDOWN_CONTAINER: '#dropdownsContainer',
22
+ DROPDOWN_DEPARTMENT: '#dropdownDepartment',
23
+ DROPDOWN_LOCATION: '#dropdownLocation',
24
+ DROPDOWN_JOB_TYPE: '#dropdownJobType',
25
+
26
+ OPEN_FILTERS_BUTTON: '#openFiltersButton',
27
+ CLOSE_FILTERS_BUTTON: '#closeFiltersButton',
28
+ RESET_FILTERS_BUTTON: '#resetFiltersButton',
29
+ RESET_FILTERS_BUTTON: '#resetFiltersButton',
30
+
31
+ RESULTS_MULTI_STATE: '#resultsMultiState',
32
+ BRANDS_DATASET: '#brandsDataset',
33
+ DEPARTMENTS_DATASET: '#departmentsDataset',
34
+ LOCATIONS_DATASET: '#locationsDataset',
35
+ JOB_TYPES_DATASET: '#jobTypesDataset',
36
+ JOBS_DATASET: '#jobsDataset',
37
+
38
+ GOOGLE_MAPS: '#googleMaps',
39
+ FOOTER: '#footer',
40
+ }
41
+
42
+ const FILTER_FIELDS = {
43
+ DEPARTMENT: 'department',
44
+ LOCATION: 'cityText',
45
+ JOB_TYPE: 'remote',
46
+ BRAND: 'brand',
47
+ SEARCH: 'title',
48
+ }
49
+
50
+ module.exports = {
51
+ CAREERS_PAGE_SELECTORS,
52
+ FILTER_FIELDS,
53
+ }