1/*! 2 * Name: Bootstrap GDPR Cookies 3 * Description: jQuery based plugin that shows bootstrap modal with cookie info 4 * Version: v1.0 5 * 6 * Copyright (c) 2018 Aleksander Woźnica 7 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php 8 * Inspired by: https://github.com/ketanmistry/ihavecookies 9 * Cookies Create/Read/Delete from https://www.quirksmode.org/js/cookies.html 10 */ 11 12(function($) { 13 14 $.fn.bsgdprcookies = function(options, event) { 15 16 var $element = $(this); 17 //var cookieShow = ReadCookie('CookieShow'); 18 //var cookiePreferences = ReadCookie('CookiePreferences'); 19 20 21 var AnayackDirective = ReadCookie('AnayackDirective'); 22 23 24 // Set default settings 25 var settings = $.extend({ 26 id: 'bs-gdpr-cookies-modal', 27 class: '', 28 title: 'Cookies & Política de privacidad', 29 backdrop: 'static', 30 message: '...', 31 messageScrollBar: false, 32 messageMaxHeightPercent: 25, 33 delay: 1500, 34 expireDays: 30, 35 moreLinkActive: true, 36 moreLinkLabel: 'Más información.', 37 moreLinkNewTab: true, 38 moreLink: '/aviso-legal/', 39 acceptButtonLabel: 'Aceptar', 40 allowAdvancedOptions: false, 41 advancedTitle: 'Seleccione las cookies que desea aceptar', 42 advancedAutoOpenDelay: 1000, 43 advancedButtonLabel: 'Customize', 44 //src:'/cookies_policy/cookiespolicy_modal.php', 45 OnAccept: function() { 46 47 var newsletter_cookie=getCookie("newsletter"); 48 49 setTimeout(function () { 50 51 if(newsletter_cookie==null ){ 52 $("#news-modal").modal("show"); 53 } 54 55 },5000); 56 57 } 58 59 }, options); 60 61 //if(!cookieShow || !AnayackDirective || event == 'reinit') { 62 if( !AnayackDirective || event == 'reinit') { 63 // Make sure that other instances are gone 64 DisposeModal(settings.id); 65 66 var modalBody = ''; 67 var modalButtons = ''; 68 var modalBodyStyle = ''; 69 var moreLink = ''; 70 71 // Generate more link 72 if(settings.moreLinkActive == true) { 73 if(settings.moreLinkNewTab == true) { 74 moreLink = '<a href="' + settings.moreLink + '" target="_blank" rel="noopener noreferrer" id="' + settings.id + '-more-link">' + settings.moreLinkLabel + '</a>'; 75 } 76 else { 77 moreLink = '<a href="' + settings.moreLink + '" id="' + settings.id + '-more-link">' + settings.moreLinkLabel + '</a>'; 78 } 79 } 80 81 82 if(settings.allowAdvancedOptions === true) { 83 modalButtons = '<button id="' + settings.id + '-advanced-btn" type="button" class="btn btn-secondary">' + settings.advancedButtonLabel + '</button><button id="' + settings.id + '-accept-btn" type="button" class="btn btn-primary" data-dismiss="modal">' + settings.acceptButtonLabel + '</button>'; 84 85 // Generate list of available advanced settings 86 var advancedCookiesToSelectList = ''; 87 88 preferences = JSON.parse(AnayackDirective); 89 $.each(settings.advancedCookiesToSelect, function(index, field) { 90 if (field.name !== '' && field.title !== '') { 91 92 var cookieDisabledText = ''; 93 if(field.isFixed == true) { 94 cookieDisabledText = ' checked="checked" disabled="disabled"'; 95 } 96 97 var cookieDescription = ''; 98 if (field.description !== false) { 99 cookieDescription = ' title="' + field.description + '"'; 100 } 101 102 var fieldID = settings.id + '-option-' + field.name; 103 104 advancedCookiesToSelectList += '<li>
104<input type="checkbox" id="' + fieldID + '" name="bsgdpr[]" value="' + field.name + '" data-auto="on" ' + cookieDisabledText + '> <label name="bsgdpr[]" data-toggle="tooltip" data-placement="right" for="' + fieldID + '"' + cookieDescription + '>' + field.title + '</label></li>'; 105 } 106 }); 107 108 modalBody = '<div id="' + settings.id + '-message">' + settings.message + moreLink + '</div>' + '<div id="' + settings.id + '-advanced-types" style="display:none; margin-top: 10px;"><h5 id="' + settings.id + '-advanced-title">' + settings.advancedTitle + '</h5>' + advancedCookiesToSelectList + '</div>'; 109 } 110 else { 111 modalButtons = '<button id="' + settings.id + '-accept-btn" type="button" class="btn btn-primary" data-dismiss="modal">' + settings.acceptButtonLabel + '</button>'; 112 113 modalBody ='<div id="' + settings.id + '-message">' + settings.message + moreLink + '</div>'; 114 } 115 116 if(settings.messageScrollBar == true) { 117 modalBodyStyle = 'style="overflow-y: scroll; max-height: ' + settings.messageMaxHeightPercent + '%"'; 118 } 119 120 var modal = '<div class="modal fade ' + settings.class + '" id="' + settings.id + '" tabindex="-1" role="dialog" aria-labelledby="' + settings.id + '-title" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="' + settings.id + '-title">' + settings.title + '</h5></div><div id="' + settings.id + '-body" class="modal-body" ' + modalBodyStyle + '>' + modalBody + '</div><div class="modal-footer">' + modalButtons + '</div></div></div></div>'; 121 122 // Show Modal 123 setTimeout(function() { 124 $($element).append(modal); 125 126 $('#' + settings.id).modal({keyboard: false, backdrop: settings.backdrop}); 127 128 if (event === 'reinit' && settings.allowAdvancedOptions === true) { 129 130 setTimeout(function(){ 131 $('#' + settings.id + '-advanced-btn').trigger('click'); 132 $.each(preferences, function(index, field) { 133 $('#' + settings.id + '-option-' + field).prop('checked', true); 134 }); 135 }, settings.advancedAutoOpenDelay) 136 } 137 }, settings.delay); 138 139 // When user clicks accept set cookie and close modal 140 $('body').on('click','#' + settings.id + '-accept-btn', function(){ 141 142 // Set show cookie 143 CreateCookie('CookieShow', true, settings.expireDays); 144 DisposeModal(settings.id); 145 146 // If 'data-auto' is set to ON, tick all checkboxes because the user has not chosen any option 147 $('input[name="bsgdpr[]"][data-auto="on"]').prop('checked', true); 148 149 // Clear user preferences cookie 150 DeleteCookie('AnayackDirective'); 151 152 // Set user preferences cookie 153 var preferences = []; 154 $.each($('input[name="bsgdpr[]"]').serializeArray(), function(i, field){ 155 preferences.push(field.value); 156 }); 157 CreateCookie('AnayackDirective', JSON.stringify(preferences), 365); 158 159 // Run callback function 160 settings.OnAccept.call(this); 161 }); 162 163 // Show advanced options 164 $('body').on('click', '#' + settings.id + '-advanced-btn', function(){ 165 // Uncheck all checkboxes except for the disabled ones 166 $('input[name="bsgdpr[]"]:not(:disabled)').attr('data-auto', 'off').prop('checked', false); 167 168 $('label[name="bsgdpr[]"]').tooltip({offset: '0, 10'}); 169 170 // Show advanced checkboxes 171 $('#' + settings.id + '-advanced-types').slideDown('fast', function(){ 172 $('#' + settings.id + '-advanced-btn').prop('disabled', true); 173 }); 174 175 // Scroll content to bottom if scrollbar option is active 176 if(settings.messageScrollBar == true) { 177 setTimeout(function() { 178 bodyID = settings.id + '-body'; 179 var div = document.getElementById(bodyID); 180 $('#' + bodyID).animate({ 181 scrollTop: div.scrollHeight - div.clientHeight 182 }, 800); 183 }, 500); 184 } 185 }); 186 } 187 else { 188 var cookieValue = true; 189 /*if (cookieShow == 'false') { 190 cookieValue = false;
191 }*/ 192 CreateCookie('CookieShow', cookieValue, settings.expireDays); 193 DisposeModal(settings.id); 194 } 195 } 196 197 /** 198 * Returns user preferences saved in cookie 199 */ 200 $.fn.bsgdprcookies.GetUserPreferences = function() { 201 var preferences = ReadCookie('AnayackDirective'); 202 return JSON.parse(preferences); 203 }; 204 205 /** 206 * Check if user preference exists in cookie 207 * 208 * @param {string} pref Preference to check 209 */ 210 $.fn.bsgdprcookies.PreferenceExists = function(pref) { 211 var preferences = $.fn.bsgdprcookies.GetUserPreferences(); 212 213 if (ReadCookie('CookieShow') === false) { 214 return false; 215 } 216 if (preferences === false || preferences.indexOf(pref) === -1) { 217 return false; 218 } 219 220 return true; 221 }; 222 223 224 /** 225 * Hide then delete bs modal 226 * 227 * @param {string} id Modal ID without '#' 228 */ 229 function DisposeModal(id) { 230 id = '#' + id; 231 $(id).modal('hide'); 232 $(id).on('hidden.bs.modal', function (e) { 233 $(this).modal('dispose'); 234 $(id).remove(); 235 }); 236 } 237 238 /** 239 * Sets Cookie 240 * 241 * @param {string} name Name of the cookie which you want to create 242 * @param {boolean} value Value for the created cookie 243 * @param {number} days Expire days 244 */ 245 function CreateCookie(name, value, days) { 246 name='AnayackDirective'; 247 value='editorial=Anaya&lang=es'; 248 if (days) { 249 var date = new Date(); 250 date.setTime(date.getTime() + (days*24*60*60*1000)); 251 var expires = "; expires=" + date.toGMTString(); 252 } 253 else var expires = ""; 254 document.cookie = name + "=" + value + expires + "; path=/"; 255 } 256 257 258 /** 259 * Gets Cookie called 'name' 260 * 261 * @param {string} name Name of the cookie to read 262 */ 263 function ReadCookie(name) { 264 var nameEQ = name + "="; 265 var ca = document.cookie.split(';'); 266 for(var i=0; i < ca.length; i++) { 267 var c = ca[i]; 268 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 269 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 270 } 271 return null; 272 } 273 274 /** 275 * Deletes Cookie called 'name; 276 * 277 * @param {string} name Name of the cookie which you want to delete 278 */ 279 function DeleteCookie(name) { 280 CreateCookie(name, "", -1); 281 } 282 283}(jQuery)); 284 285 286function setCookie(c_name, value, exdays) { 287 var exdate = new Date(); 288 exdate.setDate(exdate.getDate() + exdays); 289 var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); 290 document.cookie = c_name + "=" + c_value; 291} 292 293function getCookie(c_name) { 294 var i, x, y, ARRcookies = document.cookie.split(";"); 295 for (i = 0; i < ARRcookies.length; i++) { 296 x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); 297 y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); 298 x = x.replace(/^\s+|\s+$/g, ""); 299 if (x == c_name) { 300 return unescape(y); 301 } 302 } 303} 304 305// var newsletter_cookie=getCookie("newsletter"); 306 307// setTimeout(function () { 308 309// if(newsletter_cookie==null ){ 310// $("#news-modal").modal("show"); 311// } 312 313// },5000); 314 315 316 317$('#btn-cerrar').click(function() { 318 //$('#modalwindow').modal('hide'); 319 setCookie("newsletter", "activado", 30); 320 //console.log("se ha generado la cookie"); 321}); 322 323$('#btn-suscripirse-newsletter').click(function() { 324 325 setCookie("newsletter", "activado", 30); 326 window.open('https://t.email.anayainfantilyjuvenil.com/lp/anaAnayaInfantilSubscriptionLanding', '_blank'); 327}); 328 329 330 331 332 333//do not include in your production env 334//for demo purpose Only 335(function($) { 336 //For demo purpose adding positions to modal for preview 337 338 $(document).on("click","[data-modal-position]",function (e) { 339 e.preventDefault(); 340 //removing previously added classes 341 $("#positionModal").removeAttr("class"); 342 // adding back modal class and the selected position 343 $("#positionModal").addClass( "modal fade " + $(this).attr('data-modal-position')); 344 //making the modal visible 345 $("#positionModal").modal("show"); 346 347 }) 348 349})(window.jQuery);
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.