Commit 2f648c49 authored by o.tarasiuk@internetdevels.com's avatar o.tarasiuk@internetdevels.com
Browse files

last commit

parent 5e680980
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
This diff is collapsed.
popup_enabled: true
popup_title: Title
popup_info:
value: "<img alt=\"wsdfdf\" data-align=\"center\" data-entity-type=\"file\" data-entity-uuid=\"2e4431b9-7570-4d8d-84e0-3c294265e162\" height=\"178\" src=\"/sites/default/files/inline-images/photo_2018-10-16_13-15-54.jpg\" width=\"316\" />\r\n<p>Please regist</p>\r\n"
format: full_html
popup_text_hex: ffffff
popup_width: 100%
value: 'Please regist'
format: restricted_html
popup_text_hex: '454545'
popup_width: 400px
popup_agree_button_message: OK
popup_disagree_button_message: 'Don''t show again'
link_to: 'Label link'
popup_link: '<front>'
popup_bg_hex: 0779bf
popup_bg_hex: '888888'
bg_blur: true
popup_delay: 1000
popup_delay: 10
cookie_name: ''
cookie_lifetime: 3600
cookie_lifetime: 7
exclude_paths: '/user/*/*'
_core:
default_config_hash: HRxNlGsU38q7VCCFZGThsVuiwtp6Zea35GX3N50Vf94
default_config_hash: ifgqxod5R3TqlNwQE_oywRDWW8IgorXB38i-PIk15XQ
change bg, color,width for popup
validate HEX color in form
fix some bugs
delete comments, clear code
Remove scrolling when popup open with blur
No preview for this file type
......@@ -4,15 +4,15 @@ popup_title:
popup_info:
value: 'Please regist'
format: 'restricted_html'
popup_text_hex: 'ffffff'
popup_width: '100%'
popup_text_hex: '000000'
popup_width: '400px'
popup_agree_button_message: 'OK'
popup_disagree_button_message: "Don't show again"
link_to: 'Label link'
popup_link: '<front>'
popup_bg_hex: '0779bf'
popup_bg_hex: '999999'
bg_blur: true
popup_delay: 10
cookie_name: ''
cookie_lifetime: 3600
cookie_lifetime: 7
exclude_paths: '/user/*/*'
......@@ -15,9 +15,20 @@
border-radius: 10px;
}
.popup-more-link {
text-decoration: none;
border: 1px solid white;
padding: 15px 10px;
background: #999999;
border-radius: 5px;
margin: 10px;
}
.popup-test-text {
margin-bottom: 15px;
}
.buttons-container {
margin: 15px;
margin: 10px;
}
#popup-test-bg {
position: absolute;
......@@ -26,11 +37,24 @@
width: 100%;
background: rgba(200, 200, 200, 0.7);
filter: blur(5px);
}
.overflow {
max-height: 100vh;
overflow: hidden;
}
.popup-button {
padding: 10px;
border-radius: 5px;
border: 1px solid white;
}
.popup-agree-button {
background: #008800;
}
.popup-disagree-button {
background: #ee0000;
opacity: 0.8;
}
\ No newline at end of file
......@@ -11,9 +11,9 @@
Drupal.behaviors.PopupTestControle = {
attach: function (context) {
$('body').once('popup_test').each(function () {
if (!Drupal.popup_test.getCookieOpenTime() && !Drupal.popup_test.getCookieLater()) {
Drupal.popup_test.create();
}
if (!Drupal.popup_test.getCookieOpenTime() && !Drupal.popup_test.getCookieLater()) {
Drupal.popup_test.create();
}
}, 5000);
}
};
......@@ -23,11 +23,10 @@
Drupal.popup_test.create = function () {
if (drupalSettings.popup_test.popup_enabled && drupalSettings.popup_test.popup_html_info) {
let cook = Drupal.popup_test.getCookieLater();
var popup = $('<div></div>').html(drupalSettings.popup_test.popup_html_info);
popup.attr('id', 'popup-test');
popup.appendTo('body');
//todo add if is 'bg_blur' config
Drupal.popup_test.addStyle(popup);
if (drupalSettings.popup_test.bg_blur) {
Drupal.popup_test.createBg();
}
......@@ -35,15 +34,24 @@
};
Drupal.popup_test.addStyle = function (popup) {
$('.popup-test-container').css('width', drupalSettings.popup_test.popup_width);
popup.css('color', '#' + drupalSettings.popup_test.popup_text_hex);
$('.popup-test-container').css('background', '#' + drupalSettings.popup_test.popup_bg_hex);
};
Drupal.popup_test.createBg = function () {
var popup_bg = $('<div></div>');
popup_bg.attr('id', 'popup-test-bg');
$('body').addClass('overflow');
popup_bg.prependTo('body');
};
Drupal.popup_test.unsetBg = function() {
Drupal.popup_test.unsetBg = function () {
if (drupalSettings.popup_test.bg_blur) {
$('#popup-test-bg').trigger('popup_close').remove();
$('body').removeClass('overflow');
}
};
......@@ -62,13 +70,11 @@
Drupal.popup_test.getCookieLater = function () {
let cookieName = (drupalSettings.popup_test.cookie_name === '') ? 'please-later' : drupalSettings.popup_test.cookie_name;
let cookieName = (drupalSettings.popup_test.cookie_name === '') ? 'please-later' : drupalSettings.popup_test.cookie_name;
let value = $.cookie(cookieName);
if (isNaN(value)) {
value = false;
console.log (1);
}
console.log(2);
return value;
};
......@@ -83,12 +89,11 @@
Drupal.popup_test.setCookieOpenTime = function () {
var livetime = parseInt(drupalSettings.popup_test.popup_delay);
if (livetime !== '') {
if (livetime !== 0) {
let date = new Date();
date.setDate(date.getDate() + livetime/(24 * 3600));
date.setDate(date.getDate() + livetime / (24 * 3600));
console.log(date);
$.cookie('open-after-time', '1', {expires: date});
console.log(10);
$.cookie('open-after-time', '1', {path: drupalSettings.path.baseUrl, expires: date});
}
};
......@@ -97,12 +102,12 @@
var lifetime = parseInt(drupalSettings.popup_test.cookie_lifetime);
date.setDate(date.getDate() + lifetime);
console.log(date);
$.cookie('please-later', '1', { expires: date });
$.cookie('please-later', '1', {path: drupalSettings.path.baseUrl, expires: date});
};
Drupal.behaviors.readonle = {
attach: function() {
Drupal.behaviors.agreeHiden = {
attach: function () {
$('.popup-disagree-button').on("click", (function () {
Drupal.popup_test.agree();
}));
......@@ -111,8 +116,8 @@
};
Drupal.behaviors.leterShow = {
attach: function() {
$('.popup-agree-button').on("click", (function (e) {
attach: function () {
$('.popup-agree-button').on("click", (function () {
Drupal.popup_test.later();
}));
......
......@@ -5,5 +5,3 @@ package: User interface
configure: popup_test.settings
version: '8.x-1.0'
core: '8.x'
......@@ -28,12 +28,13 @@ function popup_test_page_attachments(array &$attachments) {
'popup_agreed_enabled' => $config->get('popup_agreed_enabled'),
'popup_html_info' => $config->get('popup_enabled') ? $result : FALSE,
'popup_width' => !empty($config->get('popup_width')) ? $config->get('popup_width') : '100%',
'popup_text_hex' => !empty($config->get('popup_text_hex')) ? $config->get('popup_text_hex') : '#999999',
'popup_bg_hex' => !empty($config->get('popup_bg_hex')) ? $config->get('popup_bg_hex') : '#000',
'popup_link' => '/',
'cookie_name' => !empty($config->get('cookie_name')) ? $config->get('cookie_name') : '',
'popup_delay' => $config->get('popup_delay'),
'bg_blur' => $config->get('bg_blur'),
'cookie_lifetime' => $config->get('cookie_lifetime'),
'cookie_session' => $config->get('cookie_session'),
'cookie_lifetime' => $config->get('cookie_lifetime'),
'popup_disagree_button_message' => !empty($config->get('popup_disagree_button_message')) ? $config->get('popup_disagree_button_message') : FALSE,
];
$attachments['#attached']['drupalSettings']['popup_test'] = $data['variables'];
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Core\Cache\Cache;
/**
* Provides settings for eu_cookie_compliance module.
......@@ -113,11 +113,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['popup_message']['popup_link'] = [
'#type' => 'textfield',
'#title' => $this->t('Privacy policy link'),
'#title' => $this->t('Link popup'),
'#default_value' => $config->get('popup_link'),
'#maxlength' => 1024,
'#required' => TRUE,
'#description' => $this->t('Enter link to your privacy policy or other page that will explain cookies to your users, external links should start with http:// or https://.'),
'#description' => $this->t('Enter your link'),
'#element_validate' => [[$this, 'validatePopupLink']],
];
......@@ -138,20 +138,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#title' => $this->t('Text color'),
'#default_value' => $config->get('popup_text_hex'),
'#description' => $this->t('Change the text color of the banner. Provide HEX value without the #.'),
// '#element_validate' => ['color_hex'],
'#states' => [
'visible' => [
"input[name='use_bare_css']" => ['checked' => FALSE],
],
],
];
$form['appearance']['popup_bg_hex'] = [
'#type' => 'textfield',
'#title' => $this->t('Background color'),
'#default_value' => $config->get('popup_bg_hex'),
'#description' => $this->t('Change the background color of the banner. Provide HEX value without the #.'),
// '#element_validate' => ['color_hex'],
'#element_validate' => [[$this, 'popup_test_validate_hex']],
'#states' => [
'visible' => [
"input[name='use_bare_css']" => ['checked' => FALSE],
......@@ -164,7 +151,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#title' => $this->t('Background color'),
'#default_value' => $config->get('popup_bg_hex'),
'#description' => $this->t('Change the background color of the banner. Provide HEX value without the #.'),
// '#element_validate' => ['color_hex'],
'#element_validate' => [[$this, 'popup_test_validate_hex']],
'#states' => [
'visible' => [
"input[name='use_bare_css']" => ['checked' => FALSE],
......@@ -205,7 +192,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['advanced']['popup_delay'] = [
'#type' => 'number',
'#title' => $this->t('Banner sliding animation time'),
'#title' => $this->t('Banner open again after this time'),
'#default_value' => $config->get('popup_delay'),
'#field_suffix' => $this->t('s'),
'#size' => 5,
......@@ -282,6 +269,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
drupal_set_message($this->t('u use lint to front page. This is the default value after installation.'), 'warning');
}
// Clear cached javascript.
Cache::invalidateTags(['library_info']);
// Save settings.
$this->config('popup_test.settings')
......@@ -346,4 +335,11 @@ public function validatePopupLink(array $element, FormStateInterface &$form_stat
}
}
}
public function popup_test_validate_hex(array $element, FormStateInterface &$form_state) {
$preg = preg_match('/^[0-9a-fA-F]{3}$/', $element['#value']) || preg_match('/^[0-9a-fA-F]{6}$/', $element['#value']);
if (!empty($element['#value']) && !$preg) {
$form_state->setError($element, t('%name must be a HEX value (without leading #) or empty.', ['%name' => $element['#title']]));
}
}
}
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment