diff --git a/eu_cookie_compliance.admin.inc b/eu_cookie_compliance.admin.inc index 19094ae..a627a87 100644 --- a/eu_cookie_compliance.admin.inc +++ b/eu_cookie_compliance.admin.inc @@ -34,6 +34,13 @@ function eu_cookie_compliance_admin_form($form_state) { '#description' => t('By default the pop-up appears at the bottom of the website. Tick this box if you want it to appear at the top'), ); + $form['eu_cookie_compliance_' . $ln]['explicit_consent'] = array( + '#type' => 'checkbox', + '#title' => t('Require explicit consent to set cookies.'), + '#default_value' => isset($popup_settings['explicit_consent']) ? $popup_settings['explicit_consent'] : 0, + '#description' => t('By default the module regards clicking any link in the site as giving consent to set cookies. If you need explicit consent from site users, enable this option.'), + ); + $form['eu_cookie_compliance_' . $ln]['popup_info'] = array( '#type' => 'text_format', '#title' => t('Popup message - requests consent'), @@ -74,7 +81,7 @@ function eu_cookie_compliance_admin_form($form_state) { '#maxlength' => 5, '#required' => FALSE, '#description' => t('Enter an integer value for a desired height in pixels or leave empty for automatically adjusted height'), - + ); $form['eu_cookie_compliance_' . $ln]['popup_width'] = array( @@ -97,7 +104,7 @@ function eu_cookie_compliance_admin_form($form_state) { ); $form_color_picker_type = 'textfield'; - + if (module_exists('jquery_colorpicker')) { $form_color_picker_type = 'jquery_colorpicker'; } @@ -108,7 +115,7 @@ function eu_cookie_compliance_admin_form($form_state) { '#default_value' => isset($popup_settings['popup_bg_hex']) ? $popup_settings['popup_bg_hex'] : '0779BF', // Garland colors :) '#description' => t('Change the background color of the popup. Provide HEX value without the #'), ); - + $form['eu_cookie_compliance_' . $ln]['popup_text_hex'] = array( '#type' => $form_color_picker_type, '#title' => t('Text Color'), diff --git a/eu_cookie_compliance.module b/eu_cookie_compliance.module index 1df39c5..434158a 100644 --- a/eu_cookie_compliance.module +++ b/eu_cookie_compliance.module @@ -49,6 +49,7 @@ function eu_cookie_compliance_preprocess_page() { $variables = array( 'popup_enabled' => $popup_settings['popup_enabled'], 'popup_agreed_enabled' => $popup_settings['popup_agreed_enabled'], + 'explicit_consent' => !isset($popup_settings['explicit_consent']) ? 0 : $popup_settings['explicit_consent'], 'popup_html_info' => empty($html_info) ? FALSE : $html_info, 'popup_html_agreed' => empty($html_agreed) ? FALSE : $html_agreed, 'popup_height' => ($popup_settings['popup_height']) ? (int) $popup_settings['popup_height'] : 'auto', @@ -59,7 +60,6 @@ function eu_cookie_compliance_preprocess_page() { 'popup_language' => $language->language, ); - // color overrides if ($popup_settings['popup_bg_hex'] != '' and $popup_settings['popup_text_hex'] != '') { $css = "#sliding-popup.sliding-popup-bottom {background:#{$popup_settings['popup_bg_hex']};}"; diff --git a/js/eu_cookie_compliance.js b/js/eu_cookie_compliance.js index 0455faf..c6a1b5f 100644 --- a/js/eu_cookie_compliance.js +++ b/js/eu_cookie_compliance.js @@ -9,18 +9,22 @@ } if (!Drupal.eu_cookie_compliance.cookiesEnabled()) { return; - } + } var status = Drupal.eu_cookie_compliance.getCurrentStatus(); var agreed_enabled = Drupal.settings.eu_cookie_compliance.popup_agreed_enabled; if (status == 0) { var next_status = 1; - $('a, input[type=submit]').bind('click.eu_cookie_compliance', function(){ - if(!agreed_enabled) { - Drupal.eu_cookie_compliance.setStatus(1); - next_status = 2; - } - Drupal.eu_cookie_compliance.changeStatus(next_status); - }); + // If explicit consent is required do not bind to links and form + // submits. + if (!Drupal.settings.eu_cookie_compliance.explicit_consent) { + $('a, input[type=submit]').bind('click.eu_cookie_compliance', function(){ + if(!agreed_enabled) { + Drupal.eu_cookie_compliance.setStatus(1); + next_status = 2; + } + Drupal.eu_cookie_compliance.changeStatus(next_status); + }); + } $('.agree-button').click(function(){ if(!agreed_enabled) { @@ -144,14 +148,14 @@ } return false; } - + Drupal.eu_cookie_compliance.cookiesEnabled = function() { var cookieEnabled = (navigator.cookieEnabled) ? true : false; - if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { + if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { document.cookie="testcookie"; cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false; } return (cookieEnabled); } - -})(jQuery); \ No newline at end of file + +})(jQuery);