Skip to content

Commit

Permalink
Options for the wrapper are now accessible under a single global vari…
Browse files Browse the repository at this point in the history
…able `window.cc_wrapper_config` instead of multiple smaller variables
  • Loading branch information
tg666 committed Dec 28, 2021
1 parent 38dd31d commit 6cdf982
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 345 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Options for the wrapper are now accessible under a single global variable `window.cc_wrapper_config` instead of multiple smaller variables (GTM template must be updated).
- Modified regex validation rule for GTM field `Package version`. The regex now allows beta and alpha versions.

## [0.2.7] - 2021-12-22
Expand Down
346 changes: 33 additions & 313 deletions gtm_template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ for (translationKey in translationsData) {
translations[translation.locale][translation.key] = translation.value;
}

// set plugin options
// create plugin options
const pluginOptions = {
force_consent: data.force_consent,
autorun: data.autorun,
Expand All @@ -1309,46 +1309,39 @@ if (data.hasOwnProperty('script_selector')) {
pluginOptions.script_selector = data.script_selector;
}

setInWindow('cc_plugin_options', pluginOptions, true);

// set consent modal options
setInWindow('cc_consent_modal_options', {
layout: data.consent_modal_layout,
position: data.consent_modal_position,
transition: data.consent_modal_transition,
primary_button_role: data.consent_modal_primary_button_role,
secondary_button_role: data.consent_modal_secondary_button_role,
swap_buttons: 'secondary_primary' === data.consent_modal_buttons_order
}, true);

// set settigns modal options
setInWindow('cc_settings_modal_options', {
layout: data.settings_modal_layout,
position: data.settings_modal_position,
transition: data.settings_modal_transition
}, true);

// set ui options
setInWindow('cc_ui_options', {
include_default_stylesheets: data.include_default_stylesheets,
external_stylesheets: data.external_stylesheets || [],
internal_stylesheets: data.hasOwnProperty('internal_stylesheets') ? [data.internal_stylesheets] : [],
modal_trigger_selector: data.modal_trigger_selector || undefined
// setup wrapper config
setInWindow('cc_wrapper_config', {
plugin_options: pluginOptions,
consent_modal_options: {
layout: data.consent_modal_layout,
position: data.consent_modal_position,
transition: data.consent_modal_transition,
primary_button_role: data.consent_modal_primary_button_role,
secondary_button_role: data.consent_modal_secondary_button_role,
swap_buttons: 'secondary_primary' === data.consent_modal_buttons_order
},

settings_modal_options: {
layout: data.settings_modal_layout,
position: data.settings_modal_position,
transition: data.settings_modal_transition
},

ui_options: {
include_default_stylesheets: data.include_default_stylesheets,
external_stylesheets: data.external_stylesheets || [],
internal_stylesheets: data.hasOwnProperty('internal_stylesheets') ? [data.internal_stylesheets] : [],
modal_trigger_selector: data.modal_trigger_selector || undefined
},

storage_pool: Object.values(storagePool),
event_triggers: Object.values(eventTriggers),
locales: data.locales,
translations: translations
}, true);

// set storage pool
setInWindow('cc_storage_pool', Object.values(storagePool), true);

// set event triggers
setInWindow('cc_event_triggers', Object.values(eventTriggers), true);

// set locales
setInWindow('cc_locales', data.locales, true);

// set rewritten translations
setInWindow('cc_translations', translations, true);

// inject cookie manager wrapper
// inject cookie consent wrapper
const packageVersion = 'latest' === data.package_version ? '' : '@' + data.package_version;
const cookieConsentWrapper = 'https://unpkg.com/68publishers-cookie-consent' + packageVersion + '/dist/cookie-consent.min.js';

Expand Down Expand Up @@ -1732,280 +1725,7 @@ ___WEB_PERMISSIONS___
"mapValue": [
{
"type": 1,
"string": "cc_plugin_options"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_storage_pool"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_locales"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_consent_modal_options"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_settings_modal_options"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_translations"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_ui_options"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "cc_event_triggers"
"string": "cc_wrapper_config"
},
{
"type": 8,
Expand Down
Loading

0 comments on commit 6cdf982

Please sign in to comment.