1$(document).ready(function () { 2 var settings = {}; 3 var runFlags = {}; 4 var $cookieBarFlag = $('#cookie-bar-flag'); 5 var $cookieBar = $('#cookie-bar'); 6 var $cookieBarCheckboxes = $cookieBar.find('.cookie-bar-checkbox'); 7 var $cookieModal = $('#cookie-modal'); 8 var $cookieModalCheckboxes = $cookieModal.find('.cookie-modal-checkbox'); 9 10 // Cookie bar flag 11 $cookieBarFlag.hover( 12 function () { 13 $(this).find('span').stop().show(200, function () { 14 $(this).css('width', 'auto'); 15 }); 16 }, 17 function () { 18 $(this).find('span').stop().hide(200); 19 } 20 ); 21 $cookieBarFlag.click(function () { 22 showCookieBar(); 23 }); 24 25 // Cookie bar 26 updateSettings(); 27 $cookieBarCheckboxes.each(function () { 28 var checkboxId = $(this).attr("id"); 29 runScript(checkboxId); 30 }); 31 $cookieBarCheckboxes.change(function () { 32 var checkboxId = $(this).attr("id"); 33 $cookieModalCheckboxes.filter('#modal-checkbox-' + checkboxId).prop('checked', $(this).prop('checked')); 34 }); 35 $cookieBar.find('.details').click(function () { 36 $cookieModal.show(); 37 });
38 $cookieBar.find('.save').click(function () { 39 saveSettings(); 40 }); 41 42 function updateSettings() { 43 var cookieSettings = getSettingsFromCookie(); 44 var defaultSettings = getDefaultSettings(); 45 46 settings = $.extend({}, defaultSettings, cookieSettings); 47 48 $cookieBarCheckboxes.each(function () { 49 var checkboxId = $(this).attr("id"); 50 var updatedAt = $(this).data('updated'); 51 52 if (cookieSettings[checkboxId] !== undefined) { 53 var acceptedDate = cookieSettings[checkboxId].acceptedDate; 54 if (acceptedDate < updatedAt) { 55 settings[checkboxId] = defaultSettings[checkboxId]; 56 $.each([$(this), $cookieModalCheckboxes.filter('#modal-checkbox-' + checkboxId)], function () { 57 $(this) 58 .parent() 59 .addClass('highlight') 60 .attr('data-original-title', TRANS.DATA_PROCESSING_ACTIVITY_MODIFIED); 61 }); 62 showCookieBar(); 63 } 64 } else { 65 showCookieBar(); 66 } 67 var isChecked = settings[checkboxId].enabled; 68 $(this).prop('checked', isChecked); 69 $cookieModalCheckboxes.filter('#modal-checkbox-' + checkboxId).prop('checked', isChecked); 70 }); 71 } 72 73 function runScript(checkboxId) { 74 if (settings[checkboxId] !== undefined && settings[checkboxId].enabled) { 75 var isFirstRun = false; 76 if (runFlags[checkboxId] === undefined) { 77 runFlags[checkboxId] = true; 78 isFirstRun = true; 79 } 80 initializeScripts[checkboxId].call(window, isFirstRun); 81 } else { 82 terminateScripts[checkboxId].call(window); 83 } 84 } 85 86 function saveSettings() { 87 $cookieBarCheckboxes.each(function () { 88 var checkboxId = $(this).attr("id"); 89 var enabled = $(this).is(":checked"); 90 var hasChanged = settings[checkboxId].enabled !== enabled; 91 settings[checkboxId] = { 92 'enabled': enabled, 93 'acceptedDate': Math.floor(Date.now() / 1000) 94 }; 95 if (hasChanged) { 96 runScript(checkboxId); 97 } 98 }); 99 Cookies.set(CONSENT_MANAGER_COOKIE_KEY, settings, { expires: 2 * 365 }); 100 hideCookieBar(); 101 } 102 103 function getSettingsFromCookie() { 104 if (Cookies.get(CONSENT_MANAGER_COOKIE_KEY) !== undefined) { 105 return JSON.parse(Cookies.get(CONSENT_MANAGER_COOKIE_KEY)); 106 } 107 return {}; 108 } 109 110 function getDefaultSettings() { 111 var defaultSettings = {}; 112 $cookieBarCheckboxes.each(function () { 113 var checkboxId = $(this).attr("id"); 114 var enabled = $(this).is(":checked"); 115 defaultSettings[checkboxId] = { 116 'enabled': enabled, 117 'acceptedDate': null 118 }; 119 }); 120 return defaultSettings; 121 } 122 123 function hideCookieBar() { 124 $cookieBar.slideUp(); 125 $cookieModal.hide(); 126 $cookieBarFlag.show(); 127 } 128 129 function showCookieBar() { 130 $cookieBar.slideDown(); 131 $cookieBarFlag.hide(); 132 } 133 134 // Cookie modal 135 var $tabs = $cookieModal.find('.tabs'); 136 var $tabNavItems = $tabs.find('ul').find('li'); 137 var $tabContents = $('.tab-contents'); 138 var $closeButtons = $cookieModal.find('.close-modal'); 139 var $saveButtons = $cookieModal.find('.save'); 140 $cookieModalCheckboxes.change(function () { 141 var checkboxId = $(this).data("id"); 142 $('#' + checkboxId).prop('checked', $(this).prop('checked')); 143 }); 144 $closeButtons.click(function () { 145 $cookieModal.hide(); 146 }); 147 $saveButtons.click(function () { 148 saveSettings(); 149 }); 150 $tabNavItems.click(function () { 151 var currentTabId = $(this).attr('id'); 152 $tabNavItems.removeClass('active'); 153 $(this).addClass('active'); 154 $tabContents.find('.description').children('div').hide(); 155 $tabContents.find('#desc-' + currentTabId).show(); 156 }); 157 $tabNavItems.first().click(); 158});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.