| 1 |
import categoryGrid from '../utils/categoryGrid' |
| 2 |
|
| 3 |
(function ($) { |
| 4 |
$(document).ready(function () { |
| 5 |
document.querySelectorAll('.betterdocs-category-grid-inner-wrapper.masonry').forEach(grid => { |
| 6 |
categoryGrid(grid.parentElement, $); |
| 7 |
}); |
| 8 |
|
| 9 |
if( betterdocsCategoryGridConfig?.is_betterdocs_templates != 1 ) { //run this script only from outside betterdocs templates only, this script is made to determine set the kb and its value on cookie |
| 10 |
$('.betterdocs-category-grid-inner-wrapper .betterdocs-single-category-wrapper .betterdocs-category-link-btn').on('click', function(e){ //this is triggerd when clicked on explore more on category grid |
| 11 |
let secondTopLayer = $($($($(this)?.parent())?.parent())?.parent())?.parent(); |
| 12 |
let topLayerMkbAttribute = $(secondTopLayer).attr('data-mkb-slug'); |
| 13 |
if( topLayerMkbAttribute?.length > 0 ) { |
| 14 |
var expiryDate = new Date(); |
| 15 |
var timeStamp = expiryDate.setDate(expiryDate.getDate() + 30).toString(); |
| 16 |
document.cookie = `last_knowledge_base=${topLayerMkbAttribute}; expires=${timeStamp}; path=/;` ; |
| 17 |
} |
| 18 |
}); |
| 19 |
|
| 20 |
$('.betterdocs-category-grid-inner-wrapper .betterdocs-single-category-wrapper .betterdocs-body .betterdocs-articles-list li a').on('click', function(e) { //this is triggerd when clicked on single doc list |
| 21 |
let secondTopLayer = $($($($($($(this).parent()).parent()).parent()).parent()).parent()).parent(); |
| 22 |
let topLayerMkbAttribute = $(secondTopLayer).attr('data-mkb-slug'); |
| 23 |
if( topLayerMkbAttribute?.length > 0 ) { |
| 24 |
var expiryDate = new Date(); |
| 25 |
var timeStamp = expiryDate.setDate(expiryDate.getDate() + 30).toString(); |
| 26 |
document.cookie = `last_knowledge_base=${topLayerMkbAttribute}; expires=${timeStamp}; path=/;` ; |
| 27 |
} |
| 28 |
}) |
| 29 |
} |
| 30 |
}); |
| 31 |
})(jQuery); |
| 32 |
|