PageSourceSearch

https://www.unavarra.es/js/cookies/jquery.cookiecuttr.js

js unavarra.es collected 2026-09-24 08:52:03 UTC 16,146 bytes, 290 lines download raw bytes

1/**
2 * Copyright (C) 2012 Chris Wharton ([email protected])
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 * 
9 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
10 * HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
11 * INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR
12 * FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE
13 * OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
14 * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT
15 * BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL
16 * DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
17 * 
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://gnu.org/licenses/>.
20 
21 Documentation available at http://cookiecuttr.com
22 
23 */
24(function ($) {
25    $.cookieCuttr = function (options) {
26        var defaults = {
27            cookieCutter: false, // you'd like to enable the div/section/span etc. hide feature? change this to true
28            cookieCutterDeclineOnly: false, // you'd like the CookieCutter to only hide when someone has clicked declined set this to true
29            cookieAnalytics: true, // just using a simple analytics package? change this to true
30            cookieDeclineButton: false, // this will disable non essential cookies
31            cookieAcceptButton: true, // this will disable non essential cookies
32            cookieResetButton: false,
33            cookieOverlayEnabled: false, // don't want a discreet toolbar? Fine, set this to true
34            cookiePolicyLink: '/privacy-policy/', // if applicable, enter the link to your privacy policy here...
35            cookieMessage: 'We use cookies on this website, you can <a href="{{cookiePolicyLink}}" title="read about our cookies">read about them here</a>. To use the website as intended please...',
36            cookieAnalyticsMessage: 'We use cookies, just to track visits to our website, we store no personal details.',
37            cookieErrorMessage: "We\'re sorry, this feature places cookies in your browser and has been disabled. <br>To continue using this functionality, please",
38           // cookieWhatAreTheyLink: "http://www.allaboutcookies.org/",
39            cookieDisable: '',
40            cookieExpires: 365,
41            cookieAcceptButtonText: "ACCEPT COOKIES",
42            cookieDeclineButtonText: "DECLINE COOKIES",
43            cookieResetButtonText: "RESET COOKIES FOR THIS WEBSITE",
44            cookieWhatAreLinkText: "What are cookies?",
45            cookieNotificationLocationBottom: false, // top or bottom - they are your only options, so true for bottom, false for top            
46            cookiePolicyPage: false,
47            cookiePolicyPageMessage: 'Please read the information below and then choose from the following options',
48            cookieDiscreetLink: false,
49            cookieDiscreetReset: false,
50            cookieDiscreetLinkText: "Cookies?",
51            cookieDiscreetPosition: "topleft", //options: topleft, topright, bottomleft, bottomright         
52            cookieNoMessage: false, // change to true hide message from all pages apart from your policy page
53            cookieDomain: ""
54        };
55        var options = $.extend(defaults, options);
56        var message = defaults.cookieMessage.replace('{{cookiePolicyLink}}', defaults.cookiePolicyLink);
57        defaults.cookieMessage = 'We use cookies on this website, you can <a href="' + defaults.cookiePolicyLink + '" title="read about our cookies">read about them here</a>. To use the website as intended please...';
58        //convert options
59        var cookiePolicyLinkIn = options.cookiePolicyLink;
60        var cookieCutter = options.cookieCutter;
61        var cookieCutterDeclineOnly = options.cookieCutterDeclineOnly;
62        var cookieAnalytics = options.cookieAnalytics;
63        var cookieDeclineButton = options.cookieDeclineButton;
64        var cookieAcceptButton = options.cookieAcceptButton;
65        var cookieResetButton = options.cookieResetButton;
66        var cookieOverlayEnabled = options.cookieOverlayEnabled;
67        var cookiePolicyLink = options.cookiePolicyLink;
68        var cookieMessage = message;
69        var cookieAnalyticsMessage = options.cookieAnalyticsMessage;
70        var cookieErrorMessage = options.cookieErrorMessage;
71        var cookieDisable = options.cookieDisable;
72        var cookieWhatAreTheyLink = options.cookieWhatAreTheyLink;
73        var cookieExpires = options.cookieExpires;
74        var cookieAcceptButtonText = options.cookieAcceptButtonText;
75        var cookieDeclineButtonText = options.cookieDeclineButtonText;
76        var cookieResetButtonText = options.cookieResetButtonText;
77        var cookieWhatAreLinkText = options.cookieWhatAreLinkText;
78        var cookieNotificationLocationBottom = options.cookieNotificationLocationBottom;
79        var cookiePolicyPage = options.cookiePolicyPage;
80        var cookiePolicyPageMessage = options.cookiePolicyPageMessage;
81        var cookieDiscreetLink = options.cookieDiscreetLink;
82        var cookieDiscreetReset = options.cookieDiscreetReset;
83        var cookieDiscreetLinkText = options.cookieDiscreetLinkText;
84        var cookieDiscreetPosition = options.cookieDiscreetPosition;
85        var cookieNoMessage = options.cookieNoMessage;
86        // cookie identifier
87        var $cookieAccepted = $.cookie('cc_cookie_accept') == "cc_cookie_accept";
88        $.cookieAccepted = function () {
89            return $cookieAccepted;
90        };
91        var $cookieDeclined = $.cookie('cc_cookie_decline') == "cc_cookie_decline";
92        $.cookieDeclined = function () {
93            return $cookieDeclined;
94        };
95        // write cookie accept button
96        if (cookieAcceptButton) {
97            var cookieAccept = ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ';
98        } else {
99            var cookieAccept = "";
100        }
101        // write cookie decline button
102        if (cookieDeclineButton) {
103            var cookieDecline = ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> ';
104        } else {
105            var cookieDecline = "";
106        }
107        // write extra class for overlay
108        if (cookieOverlayEnabled) {
109            var cookieOverlay = 'cc-overlay';
110        } else {
111            var cookieOverlay = "";
112        }
113        // to prepend or append, that is the question?
114        if ((cookieNotificationLocationBottom) || (cookieDiscreetPosition == "bottomright") || (cookieDiscreetPosition == "bottomleft")) {
115            var appOrPre = true;
116        } else {
117            var appOrPre = false;
118        }
119        if (($cookieAccepted) || ($cookieDeclined)) {
120            // write cookie reset button
121            if ((cookieResetButton) && (cookieDiscreetReset)) {
122                if (appOrPre) {
123                    $('body').append('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="' + cookieResetButtonText + '">' + cookieResetButtonText + '</a></div>');
124                } else {
125                    $('body').prepend('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="' + cookieResetButtonText + '">' + cookieResetButtonText + '</a></div>');
126                }
127                //add appropriate CSS depending on position chosen
128                if (cookieDiscreetPosition == "topleft") {
129                    $('div.cc-cookies').css("top", "0");
130                    $('div.cc-cookies').css("left", "0");
131                }
132                if (cookieDiscreetPosition == "topright") {
133                    $('div.cc-cookies').css("top", "0");
134                    $('div.cc-cookies').css("right", "0");
135                }
136                if (cookieDiscreetPosition == "bottomleft") {
137                    $('div.cc-cookies').css("bottom", "0");
138                    $('div.cc-cookies').css("left", "0");
139                }
140                if (cookieDiscreetPosition == "bottomright") {
141                    $('div.cc-cookies').css("bottom", "0");
142                    $('div.cc-cookies').css("right", "0");
143                }
144            } else if (cookieResetButton) {
145                if (appOrPre) {
146                    $('body').append('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">' + cookieResetButtonText + '</a></div>');
147                } else {
148                    $('body').prepend('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">' + cookieResetButtonText + '</a></div>');
149                }
150            } else {
151                var cookieResetButton = "";
152            }
153        } else {
154            // add message to just after opening body tag
155            if ((cookieNoMessage) && (!cookiePolicyPage)) {
156                // show no link on any pages APART from the policy page
157            } else if ((cookieDiscreetLink) && (!cookiePolicyPage)) { // show discreet link
158                if (appOrPre) {
159                    $('body').append('<div class="cc-cookies cc-discreet">
159<a href="' + cookiePolicyLinkIn + '" title="' + cookieDiscreetLinkText + '">' + cookieDiscreetLinkText + '</a></div>');
160                } else {
161                    $('body').prepend('<div class="cc-cookies cc-discreet"><a href="' + cookiePolicyLinkIn + '" title="' + cookieDiscreetLinkText + '">' + cookieDiscreetLinkText + '</a></div>');
162                }
163                //add appropriate CSS depending on position chosen
164                if (cookieDiscreetPosition == "topleft") {
165                    $('div.cc-cookies').css("top", "0");
166                    $('div.cc-cookies').css("left", "0");
167                }
168                if (cookieDiscreetPosition == "topright") {
169                    $('div.cc-cookies').css("top", "0");
170                    $('div.cc-cookies').css("right", "0");
171                }
172                if (cookieDiscreetPosition == "bottomleft") {
173                    $('div.cc-cookies').css("bottom", "0");
174                    $('div.cc-cookies').css("left", "0");
175                }
176                if (cookieDiscreetPosition == "bottomright") {
177                    $('div.cc-cookies').css("bottom", "0");
178                    $('div.cc-cookies').css("right", "0");
179                }
180            } else if (cookieAnalytics) { // show analytics overlay
181                if (appOrPre) {
182                    $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookieAnalyticsMessage + cookieAccept + cookieDecline +  '</div>'); } 
183                else {
184                    $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookieAnalyticsMessage + cookieAccept + cookieDecline + '</div>');
185                }
186            }
187            if (cookiePolicyPage) { // show policy page overlay
188                if (appOrPre) {
189                    $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookiePolicyPageMessage + " " + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> ' + '</div>');
190                } else {
191                    $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookiePolicyPageMessage + " " + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> ' + '</div>');
192                }
193            } else if ((!cookieAnalytics) && (!cookieDiscreetLink)) { // show privacy policy option
194                if (appOrPre) {
195                    $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookieMessage + cookieAccept + cookieDecline + '</div>');
196                } else {
197                    $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookieMessage + cookieAccept + cookieDecline + '</div>');
198                }
199            }
200        }
201        if ((cookieCutter) && (!cookieCutterDeclineOnly) && (($cookieDeclined) || (!$cookieAccepted))) {
202            $(cookieDisable).html('<div class="cc-cookies-error">' + cookieErrorMessage + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + '</div>');
203        }
204        if ((cookieCutter) && (cookieCutterDeclineOnly) && ($cookieDeclined)) {
205            $(cookieDisable).html('<div class="cc-cookies-error">' + cookieErrorMessage + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + '</div>');
206        }
207        // if bottom is true, switch div to bottom if not in discreet mode
208        if ((cookieNotificationLocationBottom) && (!cookieDiscreetLink)) {
209            $('div.cc-cookies').css("top", "auto");
210            $('div.cc-cookies').css("bottom", "0");
211        }
212        if ((cookieNotificationLocationBottom) && (cookieDiscreetLink) && (cookiePolicyPage)) {
213            $('div.cc-cookies').css("top", "auto");
214            $('div.cc-cookies').css("bottom", "0");
215        }
216        // setting the cookies
217
218        // for top bar
219        $('.cc-cookie-accept, .cc-cookie-decline').click(function (e) {
220            e.preventDefault();
221            if ($(this).is('[href$=#decline]')) {
222                $.cookie("cc_cookie_accept", null, {
223                    path: '/'
224                });
225                $.cookie("cc_cookie_decline", "cc_cookie_decline", {
226                    expires: cookieExpires,
227                    path: '/'
228                });
229                if (options.cookieDomain) {
230                    // kill google analytics cookies
231                    $.cookie("__utma", null, {
232                        domain: '.' + options.cookieDomain,
233                        path: '/'
234                    });
235                    $.cookie("__utmb", null, {
236                        domain: '.' + options.cookieDomain,
237                        path: '/'
238                    });
239                    $.cookie("__utmc", null, {
240                        domain: '.' + options.cookieDomain,
241                        path: '/'
242                    });
243                    $.cookie("__utmz", null, {
244                        domain: '.' + options.cookieDomain,
245                        path: '/'
246                    });
247                }
248            } else {
249                $.cookie("cc_cookie_decline", null, {
250                    path: '/'
251                });
252                $.cookie("cc_cookie_accept", "cc_cookie_accept", {
253                    expires: cookieExpires,
254                    path: '/'
255                });
256            }
257            $(".cc-cookies").fadeOut(function () {
258                // reload page to activate cookies
259                location.reload();
260            });
261        });
262        //reset cookies
263        $('a.cc-cookie-reset').click(function (f) {
264            f.preventDefault();
265            $.cookie("cc_cookie_accept", null, {
266                path: '/'
267            });
268            $.cookie("cc_cookie_decline", null, {
269                path: '/'
270            });
271            $(".cc-cookies").fadeOut(function () {
272                // reload page to activate cookies
273                location.reload();
274            });
275        });
276        //cookie error accept
277        $('.cc-cookies-error a.cc-cookie-accept').click(function (g) {
278            g.preventDefault();
279            $.cookie("cc_cookie_accept", "cc_cookie_accept", {
280                expires: cookieExpires,
281                path: '/'
282            });
283            $.cookie("cc_cookie_decline", null, {
284                path: '/'
285            });
286            // reload page to activate cookies
287            location.reload();
288        });
289    };
290})(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.