MDL-67384 tool_policy: Upgrade jQuery EU Cookie Law popups to 1.1.3

This commit is contained in:
Shamim Rezaie 2019-12-10 18:02:02 +11:00
parent 8cf4c97217
commit d2dcb0d082
5 changed files with 19 additions and 11 deletions

View File

@ -1,2 +1,2 @@
define ("tool_policy/jquery-eu-cookie-law-popup",["jquery"],function(a){if(!window.console)window.console={};if(!window.console.log)window.console.log=function(){};a.fn.euCookieLawPopup=function(){var b=this;b.params={cookiePolicyUrl:"/?cookie-policy",popupPosition:"top",colorStyle:"default",compactStyle:!1,popupTitle:"This website is using cookies",popupText:"We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on this website.",buttonContinueTitle:"Continue",buttonLearnmoreTitle:"Learn&nbsp;more",buttonLearnmoreOpenInNewWindow:!0,agreementExpiresInDays:30,autoAcceptCookiePolicy:!1,htmlMarkup:null};b.vars={INITIALISED:!1,HTML_MARKUP:null,COOKIE_NAME:"EU_COOKIE_LAW_CONSENT"};var c=function(c,d,e){if(c){var f=a(c).attr("class")?a(c).attr("class"):"";if(-1<f.indexOf("eupopup-top")){b.params.popupPosition="top"}else if(-1<f.indexOf("eupopup-fixedtop")){b.params.popupPosition="fixedtop"}else if(-1<f.indexOf("eupopup-bottomright")){b.params.popupPosition="bottomright"}else if(-1<f.indexOf("eupopup-bottomleft")){b.params.popupPosition="bottomleft"}else if(-1<f.indexOf("eupopup-bottom")){b.params.popupPosition="bottom"}else if(-1<f.indexOf("eupopup-block")){b.params.popupPosition="block"}if(-1<f.indexOf("eupopup-color-default")){b.params.colorStyle="default"}else if(-1<f.indexOf("eupopup-color-inverse")){b.params.colorStyle="inverse"}if(-1<f.indexOf("eupopup-style-compact")){b.params.compactStyle=!0}}if(d){b.params.htmlMarkup=d}if(e){if("undefined"!=typeof e.cookiePolicyUrl){b.params.cookiePolicyUrl=e.cookiePolicyUrl}if("undefined"!=typeof e.popupPosition){b.params.popupPosition=e.popupPosition}if("undefined"!=typeof e.colorStyle){b.params.colorStyle=e.colorStyle}if("undefined"!=typeof e.popupTitle){b.params.popupTitle=e.popupTitle}if("undefined"!=typeof e.popupText){b.params.popupText=e.popupText}if("undefined"!=typeof e.buttonContinueTitle){b.params.buttonContinueTitle=e.buttonContinueTitle}if("undefined"!=typeof e.buttonLearnmoreTitle){b.params.buttonLearnmoreTitle=e.buttonLearnmoreTitle}if("undefined"!=typeof e.buttonLearnmoreOpenInNewWindow){b.params.buttonLearnmoreOpenInNewWindow=e.buttonLearnmoreOpenInNewWindow}if("undefined"!=typeof e.agreementExpiresInDays){b.params.agreementExpiresInDays=e.agreementExpiresInDays}if("undefined"!=typeof e.autoAcceptCookiePolicy){b.params.autoAcceptCookiePolicy=e.autoAcceptCookiePolicy}if("undefined"!=typeof e.htmlMarkup){b.params.htmlMarkup=e.htmlMarkup}}},d=function(){if(b.params.htmlMarkup){return b.params.htmlMarkup}var a="<div class=\"eupopup-container eupopup-container-"+b.params.popupPosition+(b.params.compactStyle?" eupopup-style-compact":"")+" eupopup-color-"+b.params.colorStyle+"\"><div class=\"eupopup-head\">"+b.params.popupTitle+"</div><div class=\"eupopup-body\">"+b.params.popupText+"</div><div class=\"eupopup-buttons\"><a href=\"#\" class=\"eupopup-button eupopup-button_1\">"+b.params.buttonContinueTitle+"</a><a href=\""+b.params.cookiePolicyUrl+"\""+(b.params.buttonLearnmoreOpenInNewWindow?" target=_blank ":"")+" class=\"eupopup-button eupopup-button_2\">"+b.params.buttonLearnmoreTitle+"</a><div class=\"clearfix\"></div></div><a href=\"#\" class=\"eupopup-closebutton\">x</a></div>";return a},e=function(c){var e=new Date,d=1e3*(60*(60*(24*b.params.agreementExpiresInDays)));e.setTime(e.getTime()+d);var f="expires="+e.toGMTString();document.cookie=b.vars.COOKIE_NAME+"="+c+"; "+f+";path=/";a(document).trigger("user_cookie_consent_changed",{consent:c})},f=function(){for(var a=!1,d=document.cookie.split(";"),e=0,f;e<d.length;e++){f=d[e].trim();if(0==f.indexOf(b.vars.COOKIE_NAME)){a=f.substring(b.vars.COOKIE_NAME.length+1,f.length)}}return a},g=function(){a(".eupopup-container").animate({opacity:0,height:0},200,function(){a(".eupopup-container").hide(0)})};return{init:function init(h){c(a(".eupopup").first(),a(".eupopup-markup").html(),h);if(f()){a(document).trigger("user_cookie_already_accepted",{consent:!0});return}if(b.vars.INITIALISED){return}b.vars.INITIALISED=!0;b.vars.HTML_MARKUP=d();if(0<a(".eupopup-block").length){a(".eupopup-block").append(b.vars.HTML_MARKUP)}else{a("BODY").append(b.vars.HTML_MARKUP)}a(".eupopup-button_1").click(function(){e(!0);g();return!1});a(".eupopup-closebutton").click(function(){e(!0);g();return!1});a(".eupopup-container").show();if(b.params.autoAcceptCookiePolicy){e(!0)}}}}});
define ("tool_policy/jquery-eu-cookie-law-popup",["jquery"],function(a){if(!window.console)window.console={};if(!window.console.log)window.console.log=function(){};a.fn.euCookieLawPopup=function(){var b=this;b.params={cookiePolicyUrl:"/?cookie-policy",popupPosition:"top",colorStyle:"default",compactStyle:!1,popupTitle:"This website is using cookies",popupText:"We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on this website.",buttonContinueTitle:"Continue",buttonLearnmoreTitle:"Learn&nbsp;more",buttonLearnmoreOpenInNewWindow:!0,agreementExpiresInDays:30,autoAcceptCookiePolicy:!1,htmlMarkup:null};b.vars={INITIALISED:!1,HTML_MARKUP:null,COOKIE_NAME:"EU_COOKIE_LAW_CONSENT"};var c=function(c,d,e){if(c){var f=a(c).attr("class")?a(c).attr("class"):"";if(-1<f.indexOf("eupopup-top")){b.params.popupPosition="top"}else if(-1<f.indexOf("eupopup-fixedtop")){b.params.popupPosition="fixedtop"}else if(-1<f.indexOf("eupopup-bottomright")){b.params.popupPosition="bottomright"}else if(-1<f.indexOf("eupopup-bottomleft")){b.params.popupPosition="bottomleft"}else if(-1<f.indexOf("eupopup-bottom")){b.params.popupPosition="bottom"}else if(-1<f.indexOf("eupopup-block")){b.params.popupPosition="block"}if(-1<f.indexOf("eupopup-color-default")){b.params.colorStyle="default"}else if(-1<f.indexOf("eupopup-color-inverse")){b.params.colorStyle="inverse"}if(-1<f.indexOf("eupopup-style-compact")){b.params.compactStyle=!0}}if(d){b.params.htmlMarkup=d}if(e){if("undefined"!=typeof e.cookiePolicyUrl){b.params.cookiePolicyUrl=e.cookiePolicyUrl}if("undefined"!=typeof e.popupPosition){b.params.popupPosition=e.popupPosition}if("undefined"!=typeof e.colorStyle){b.params.colorStyle=e.colorStyle}if("undefined"!=typeof e.popupTitle){b.params.popupTitle=e.popupTitle}if("undefined"!=typeof e.popupText){b.params.popupText=e.popupText}if("undefined"!=typeof e.buttonContinueTitle){b.params.buttonContinueTitle=e.buttonContinueTitle}if("undefined"!=typeof e.buttonLearnmoreTitle){b.params.buttonLearnmoreTitle=e.buttonLearnmoreTitle}if("undefined"!=typeof e.buttonLearnmoreOpenInNewWindow){b.params.buttonLearnmoreOpenInNewWindow=e.buttonLearnmoreOpenInNewWindow}if("undefined"!=typeof e.agreementExpiresInDays){b.params.agreementExpiresInDays=e.agreementExpiresInDays}if("undefined"!=typeof e.autoAcceptCookiePolicy){b.params.autoAcceptCookiePolicy=e.autoAcceptCookiePolicy}if("undefined"!=typeof e.htmlMarkup){b.params.htmlMarkup=e.htmlMarkup}}},d=function(){if(b.params.htmlMarkup){return b.params.htmlMarkup}var a="<div class=\"eupopup-container eupopup-container-"+b.params.popupPosition+(b.params.compactStyle?" eupopup-style-compact":"")+" eupopup-color-"+b.params.colorStyle+"\"><div class=\"eupopup-head\">"+b.params.popupTitle+"</div><div class=\"eupopup-body\">"+b.params.popupText+"</div><div class=\"eupopup-buttons\"><a href=\"#\" class=\"eupopup-button eupopup-button_1\">"+b.params.buttonContinueTitle+"</a><a href=\""+b.params.cookiePolicyUrl+"\""+(b.params.buttonLearnmoreOpenInNewWindow?" target=_blank ":"")+" class=\"eupopup-button eupopup-button_2\">"+b.params.buttonLearnmoreTitle+"</a><div class=\"clearfix\"></div></div><a href=\"#\" class=\"eupopup-closebutton\">x</a></div>";return a},e=function(c){var e=new Date,d=1e3*(60*(60*(24*b.params.agreementExpiresInDays)));e.setTime(e.getTime()+d);var f="expires="+e.toGMTString();document.cookie=b.vars.COOKIE_NAME+"="+c+"; "+f+";path=/";a(document).trigger("user_cookie_consent_changed",{consent:c})},f=function(){for(var a=!1,d=document.cookie.split(";"),e=0,f;e<d.length;e++){f=d[e].trim();if(-1!==f.indexOf(b.vars.COOKIE_NAME)){a=f.substring(b.vars.COOKIE_NAME.length+1,f.length)}}return a},g=function(){a(".eupopup-container").animate({opacity:0,height:0},200,function(){a(".eupopup-container").hide(0)})};return{init:function init(h){c(a(".eupopup").first(),a(".eupopup-markup").html(),h);if(f()){a(document).trigger("user_cookie_already_accepted",{consent:!0});return}if(b.vars.INITIALISED){return}b.vars.INITIALISED=!0;b.vars.HTML_MARKUP=d();if(0<a(".eupopup-block").length){a(".eupopup-block").append(b.vars.HTML_MARKUP)}else{a("BODY").append(b.vars.HTML_MARKUP)}a(".eupopup-button_1").click(function(){e(!0);g();return!1});a(".eupopup-closebutton").click(function(){e(!0);g();return!1});a(".eupopup-container").show();if(b.params.autoAcceptCookiePolicy){e(!0)}}}}});
//# sourceMappingURL=jquery-eu-cookie-law-popup.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,7 @@
* http://www.wimagguc.com/
*
*/
define(['jquery'], function($) {
// for ie9 doesn't support debug console >>>
@ -171,7 +172,7 @@ $.fn.euCookieLawPopup = (function() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var c = cookies[i].trim();
if (c.indexOf(_self.vars.COOKIE_NAME) == 0) {
if (c.indexOf(_self.vars.COOKIE_NAME) !== -1) {
userAcceptedCookies = c.substring(_self.vars.COOKIE_NAME.length + 1, c.length);
}
}

View File

@ -1,22 +1,19 @@
jQuery EU Cookie Law popups 1.1.2
jQuery EU Cookie Law popups 1.1.3
-------------
https://github.com/wimagguc/jquery-eu-cookie-law-popup
Instructions to import 'jQuery EU Cookie Law popups' into Moodle:
1. Download the latest release from https://github.com/wimagguc/jquery-eu-cookie-law-popup
1. Download the latest release from https://github.com/wimagguc/jquery-eu-cookie-law-popup/releases
2. Copy 'js/jquery-eu-cookie-law-popup.js' into 'amd/src/jquery-eu-cookie-law-popup.js':
2.a. Replace jquery reference
------------------
(function($) {
------------------
to
with
------------------
define(
['jquery'],
function($) {
define(['jquery'],function($) {
------------------
2.b. Remove initialisation code. It will be added and configured only in the pages where is needed
@ -29,6 +26,7 @@ $(document).ready( function() {
'popupText' : 'We use them to give you the best experience. If you continue using our website, we\'ll assume that you are happy to receive all cookies on this website.'
});
}
});
------------------
2.c. Remove code
@ -36,9 +34,16 @@ $(document).ready( function() {
$(document).bind("user_cookie_consent_changed", function(event, object) {
console.log("User cookie consent changed: " + $(object).attr('consent') );
});
------------------
2.d. Replace
------------------
}(jQuery));
------------------
with
------------------
});
------------------
3. Copy the following styles from 'css/jquery-eu-cookie-law-popup.css' into the
"jquery-eu-cookie-law-popup styles" section in 'styles.css':
@ -54,3 +59,5 @@ $(document).bind("user_cookie_consent_changed", function(event, object) {
4. Execute grunt to compile js
grunt amd
5. Update version number in admin/tool/policy/thirdpartylibs.xml

View File

@ -4,7 +4,7 @@
<location>amd/src/jquery-eu-cookie-law-popup.js</location>
<name>jQuery EU Cookie Law popups</name>
<license>MIT</license>
<version>1.1.2</version>
<version>1.1.3</version>
<licenseversion></licenseversion>
</library>
</libraries>