定制 omatech/oma-cookies 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

omatech/oma-cookies

Composer 安装命令:

composer require omatech/oma-cookies

包简介

Cookie consent manager

README 文档

README


Omatech Logo

Oma-cookies

Built-in solution that allows the control of cookies,
enabling GDPR compliance for Omatech internal projects.

Table of contents

Installation

Install the package

npm i @omatech/oma-cookies

JavaScript import

Import the main js file into your project:

require('@omatech/oma-cookies/dist/js/omacookies.min');

Optionally you can copy into a public folder the JS file located inside the /node_modules/@omatech/oma-cookies/dist/js folder and link it in your HTML layout

<script src="/path_to_copied_file/omacookies.min.js"></script>

CSS/SASS import

There are 2 approaches depending on your styling method:

A) If you are ONLY overriding CSS classes => Import the compiled CSS file

@import "~@omatech/oma-cookies/dist/css/omacookies.min.css"

Optionally you can copy into a public folder the CSS file located inside the /node_modules/@omatech/oma-cookies/dist/css folder and link it in your HTML layout

<link href="/path_to_copied_file/omacookies.min.css" rel="stylesheet">

B) If you want to override the variables and CSS classes => Import all the separated files

@import "~@omatech/oma-cookies/dist/scss/base"
@import "~@omatech/oma-cookies/dist/scss/variables"
//Your own SCSS file overriding the variables from the file above
@import "variables"
@import "~@omatech/oma-cookies/dist/scss/styles"

Regardless of what option you choose, make sure this line is in your HTML layout so the responsive works properly.

<meta name="viewport" content="width=device-width, initial-scale=1">

Implementation

To start things up, you must add this somewhere in your HTML layout (preferably at the end)

<body>
...
<div id="omacookies"></div>
</body>

Iframes

Every iframe must have the attribute data-omacookies-consent which has 2 possible values marketing or statistics. This specitfy when the content will be un/blocked

YouTube videos

The attribute data-omacookies-yt-video-id is the ID found at the end of every YouTube video URL. In /watch?v=uu5k19UaCT0 the ID would be uu5k19UaCT0

<div
    class="omac-iframe-youtube"
    data-omacookies-consent="marketing"
    data-omacookies-yt-video-id="uu5k19UaCT0"
></div>

Generic iframe

The attribute data-omacookies-src would work as the normal iframe src attribute

You can add any attribute to the rendered iframe using the attribute data-omacookies-xxx. Simply change xxx for any other attribute. See the attribute width shown in the example.

<div
    class="omac-iframe"
    data-omacookies-consent="statistics"
    data-omacookies-src="https://example.com/"
    data-omacookies-width="720"
></div>

Scripts

It is required to add the type="text/plain" attribute.

  • For file JavaScript scripts
<script
    class="omac-script"
    type="text/plain"
    data-omacookies-consent="statistics"
    src="https://example.com/"
></script>
  • For inline JavaScript code
<script
    class="omac-script"
    type="text/plain"
    data-omacookies-consent="statistics"
>
    console.log("Hello World!");
</script>

↑ Back to top

Methods

Open cookies consent selection modal

window.OMAC.SelectionModal.open();

↑ Back to top

Configuration

Somewhere after the import of the omacookies JS file we will override attributes from the main object.

Override language strings

We can set a new value for any language string with the following declaration:

window.OMAC.available_languages.es.select_box_title = 'Personalizar Cookies';

Adding a new language

We can add as many languages as we want, we just need to follow the same object structure we already have for ES and EN.

You can copy the structure from /node_modules/@omatech/oma-cookies/src/lang/en.json

For example, we will add German language:

window.OMAC.available_languages.de = {
    "constent_box_title": "Diese Website verwendet Cookies",
    ...
};

Setting the default language

Make sure to set the language after you make any modifications to the available_languages object.

window.OMAC.setLang("en");

Read more link

Here we will add the website link where the user will be redirected to read the cookie policy.

window.OMAC.readMoreLink = "https://omatech.com/cookies.html";

Format

Here we can set the appearance of the initial cookie dialog. The allowed values are modal (default) or banner.

window.OMAC.format = "banner";

Enable/disable quick link

The quick link is enabled by default. Disable it setting the following:

window.OMAC.enableQuickLink = false;

To open the cookies selection modal when disabled, use the this method

Quick link position

Here we can configure in which corner of the screen will the quick link be located, using the values top-right , top-left, bottom-right or bottom-left. The quick link will appear on the bottom-right by default.

window.OMAC.quickLinkPosition = "bottom-left";

↑ Back to top

License

This project has MIT license. For further information, read the LICENSE file.

↑ Back to top

Contact

↑ Back to top

omatech/oma-cookies 适用场景与选型建议

omatech/oma-cookies 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 omatech/oma-cookies 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 omatech/oma-cookies 我们能提供哪些服务?
定制开发 / 二次开发

基于 omatech/oma-cookies 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-09