geico-design-kit 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of geico-design-kit might be problematic. Click here for more details.
- package/.babelrc +5 -0
- package/LICENSE +0 -0
- package/dist/analytics.js +119 -0
- package/dist/appState.js +56 -0
- package/dist/baseComponent.js +110 -0
- package/dist/components/Accordion.js +312 -0
- package/dist/components/AddressAutoComplete.js +220 -0
- package/dist/components/Alert.js +145 -0
- package/dist/components/BackgroundPattern.js +99 -0
- package/dist/components/BackgroundPatternPortfolio.js +242 -0
- package/dist/components/ButtonSwitch.js +236 -0
- package/dist/components/CardSelections.js +230 -0
- package/dist/components/CommonQuestionsSquares.js +169 -0
- package/dist/components/Confirmation.js +156 -0
- package/dist/components/ConsolidatedSummary.js +489 -0
- package/dist/components/CoverageGraph.js +201 -0
- package/dist/components/CreditCard.js +591 -0
- package/dist/components/CurrencyInput.js +302 -0
- package/dist/components/DatePicker.js +468 -0
- package/dist/components/DockedMessage.js +146 -0
- package/dist/components/DotNavigation.js +200 -0
- package/dist/components/EditComponent.js +128 -0
- package/dist/components/EditableTable.js +113 -0
- package/dist/components/InPageNavigation.js +360 -0
- package/dist/components/Loader.js +232 -0
- package/dist/components/MakePayment.js +361 -0
- package/dist/components/Modal.js +254 -0
- package/dist/components/MoreInfoButton.js +227 -0
- package/dist/components/MultipleSelectBox.js +217 -0
- package/dist/components/NavigationalBox.js +161 -0
- package/dist/components/Navigator.js +294 -0
- package/dist/components/PasswordMeter.js +201 -0
- package/dist/components/PayPlans.js +534 -0
- package/dist/components/SegmentedControl.js +327 -0
- package/dist/components/SortableTable.js +166 -0
- package/dist/components/Tabs.js +1 -0
- package/dist/components/TextAreaCountdown.js +219 -0
- package/dist/components/Timeline.js +498 -0
- package/dist/components/TimelineFilter.js +492 -0
- package/dist/components/ToTopArrow.js +153 -0
- package/dist/components/Tooltip.js +329 -0
- package/dist/components/Upsell.js +168 -0
- package/dist/components/VIN.js +271 -0
- package/dist/components/ValidateForm.js +938 -0
- package/dist/components/ViewMoreLess.js +191 -0
- package/dist/components/ZipCode.js +191 -0
- package/dist/components/portfolio.js +99 -0
- package/dist/geico-design-kit.js +141 -0
- package/dist/global/components.js +98 -0
- package/dist/global/footer.js +26 -0
- package/dist/global/nav.js +1257 -0
- package/dist/services/CharacterTypeService.js +106 -0
- package/dist/services/UserAgentService.js +73 -0
- package/dist/utils.js +79 -0
- package/package.json +32 -0
- package/src/analytics.js +82 -0
- package/src/appState.js +56 -0
- package/src/baseComponent.js +156 -0
- package/src/components/Accordion.js +336 -0
- package/src/components/AddressAutoComplete.js +236 -0
- package/src/components/Alert.js +135 -0
- package/src/components/BackgroundPattern.js +96 -0
- package/src/components/BackgroundPatternPortfolio.js +284 -0
- package/src/components/ButtonSwitch.js +241 -0
- package/src/components/CardSelections.js +240 -0
- package/src/components/CommonQuestionsSquares.js +179 -0
- package/src/components/Confirmation.js +160 -0
- package/src/components/ConsolidatedSummary.js +505 -0
- package/src/components/CoverageGraph.js +203 -0
- package/src/components/CreditCard.js +595 -0
- package/src/components/CurrencyInput.js +321 -0
- package/src/components/DatePicker.js +487 -0
- package/src/components/DockedMessage.js +142 -0
- package/src/components/DotNavigation.js +206 -0
- package/src/components/EditComponent.js +130 -0
- package/src/components/EditableTable.js +106 -0
- package/src/components/InPageNavigation.js +391 -0
- package/src/components/Loader.js +272 -0
- package/src/components/MakePayment.js +397 -0
- package/src/components/Modal.js +279 -0
- package/src/components/MoreInfoButton.js +243 -0
- package/src/components/MultipleSelectBox.js +211 -0
- package/src/components/NavigationalBox.js +163 -0
- package/src/components/Navigator.js +338 -0
- package/src/components/PasswordMeter.js +209 -0
- package/src/components/PayPlans.js +604 -0
- package/src/components/SegmentedControl.js +365 -0
- package/src/components/SortableTable.js +176 -0
- package/src/components/Tabs.js +0 -0
- package/src/components/TextAreaCountdown.js +231 -0
- package/src/components/Timeline.js +532 -0
- package/src/components/TimelineFilter.js +533 -0
- package/src/components/ToTopArrow.js +153 -0
- package/src/components/Tooltip.js +344 -0
- package/src/components/Upsell.js +196 -0
- package/src/components/VIN.js +289 -0
- package/src/components/ValidateForm.js +1030 -0
- package/src/components/ViewMoreLess.js +193 -0
- package/src/components/ZipCode.js +193 -0
- package/src/components/portfolio.js +106 -0
- package/src/geico-design-kit.js +144 -0
- package/src/global/components.js +92 -0
- package/src/global/footer.js +25 -0
- package/src/global/nav.js +1457 -0
- package/src/services/CharacterTypeService.js +107 -0
- package/src/services/UserAgentService.js +59 -0
- package/src/utils.js +82 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import baseComponent from '../../src/baseComponent';
|
|
2
|
+
|
|
3
|
+
const validateSettings = [{
|
|
4
|
+
setting: 'content',
|
|
5
|
+
isRequired: true,
|
|
6
|
+
validate: 'type',
|
|
7
|
+
possibleValues: ['string', 'object'],
|
|
8
|
+
errorMessage: ['GDK Alert : Content must be defined and set to a DOM selector or Node']
|
|
9
|
+
}];
|
|
10
|
+
|
|
11
|
+
class Alert {
|
|
12
|
+
/**
|
|
13
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
14
|
+
* @param {string|Object} content
|
|
15
|
+
* A reference to the html alert node
|
|
16
|
+
*/
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this._internalVars = {
|
|
19
|
+
node: null, //used for current node
|
|
20
|
+
alertContentClass: "alert-content",
|
|
21
|
+
alertContent: null,
|
|
22
|
+
alertCloseBtnClass: "icon-close-20",
|
|
23
|
+
alertCloseBtn: null
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//options with defaults set
|
|
27
|
+
this._defaults = {};
|
|
28
|
+
|
|
29
|
+
// Create options by extending defaults with the passed in arugments
|
|
30
|
+
if (options && typeof options === "object") {
|
|
31
|
+
this._options = baseComponent.extendDefaults(this._defaults, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//if the required options are valid set up the environment
|
|
35
|
+
if (baseComponent.validateSettings(this._options, validateSettings)) {
|
|
36
|
+
this._internalVars.contentType = baseComponent.getContentType(this);
|
|
37
|
+
setLocalVars.call(this);
|
|
38
|
+
setEvents.call(this);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//Public Methods
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* removes the node from the dom and any events attached
|
|
46
|
+
*/
|
|
47
|
+
destroy(){
|
|
48
|
+
removeEvents.call(this);
|
|
49
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
50
|
+
|
|
51
|
+
//a little garbage collection
|
|
52
|
+
for (var variableKey in this){
|
|
53
|
+
if (this.hasOwnProperty(variableKey)){
|
|
54
|
+
delete this[variableKey];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Private Methods
|
|
61
|
+
function setLocalVars() {
|
|
62
|
+
if(this._internalVars.contentType === 'string') {
|
|
63
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
64
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
65
|
+
this._internalVars.node = this._options.content;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this._internalVars.alertCloseBtn = this._internalVars.node.querySelectorAll('button.' + this._internalVars.alertCloseBtnClass);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* setEvents()
|
|
73
|
+
* Sets all the events needed for the component
|
|
74
|
+
*/
|
|
75
|
+
function setEvents() {
|
|
76
|
+
for(let i=0;i<this._internalVars.alertCloseBtn.length;i++){
|
|
77
|
+
this._internalVars.alertCloseBtn[i].addEventListener("click", removeAlert.bind(this, this._internalVars.alertCloseBtn[i]));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function removeEvents(){
|
|
82
|
+
for(let i=0;i<this._internalVars.alertCloseBtn.length;i++){
|
|
83
|
+
this._internalVars.alertCloseBtn[i].removeEventListener("click", removeAlert.bind(this, this._internalVars.alertCloseBtn[i]));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* removeAlert()
|
|
90
|
+
* checks to remove Alert appropriately
|
|
91
|
+
*/
|
|
92
|
+
function removeAlert(e) {
|
|
93
|
+
if (this._internalVars.node.children.length==1&&e.parentNode.parentNode.children.length==1) {
|
|
94
|
+
fadeAndRemove(this._internalVars.node);
|
|
95
|
+
}
|
|
96
|
+
if (e.parentNode.parentNode.children.length==1) {
|
|
97
|
+
fadeAndRemove(e.parentNode.parentNode.parentNode);
|
|
98
|
+
}
|
|
99
|
+
fadeAndRemove(e.parentNode);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* fade()
|
|
104
|
+
* fade effect
|
|
105
|
+
*/
|
|
106
|
+
function fadeOutEffect(e) {
|
|
107
|
+
let op = 1; // initial opacity
|
|
108
|
+
let timer = setInterval(function () {
|
|
109
|
+
if (op <= 0.01){
|
|
110
|
+
clearInterval(timer);
|
|
111
|
+
}
|
|
112
|
+
e.style.opacity = op;
|
|
113
|
+
e.style.filter = 'alpha(opacity=' + op * 100 + ")";
|
|
114
|
+
op -= op * 0.1;
|
|
115
|
+
}, 15);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* removeChildCall
|
|
120
|
+
* Instantiate removal of child element
|
|
121
|
+
*/
|
|
122
|
+
function removeChildCall(e) {
|
|
123
|
+
e.parentNode.removeChild(e);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* fadeAndRemove()
|
|
128
|
+
* Combine fade effect with delayed removal of element
|
|
129
|
+
*/
|
|
130
|
+
function fadeAndRemove(e){
|
|
131
|
+
fadeOutEffect(e);
|
|
132
|
+
setTimeout(removeChildCall, 500, e);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default Alert;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var Trianglify = require('trianglify');
|
|
2
|
+
|
|
3
|
+
import baseComponent from '../../src/baseComponent';
|
|
4
|
+
|
|
5
|
+
const validateSettings = [
|
|
6
|
+
{
|
|
7
|
+
setting: "content",
|
|
8
|
+
isRequired: true,
|
|
9
|
+
validate: "type",
|
|
10
|
+
possibleValues: ["string", "object"],
|
|
11
|
+
errorMessage: ["GDK BackgroundPattern : Content must be defined and set to a DOM selector or Node"]
|
|
12
|
+
}
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
class BackgroundPattern {
|
|
16
|
+
/**
|
|
17
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
18
|
+
* @param {string|Object} content
|
|
19
|
+
* A reference to the html More Background Pattern node
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
|
|
23
|
+
console.log('BackgroundPattern initialized');
|
|
24
|
+
|
|
25
|
+
//SM=75 MED=125 LG=175
|
|
26
|
+
|
|
27
|
+
this._internalVars = {
|
|
28
|
+
node: null //used for current node
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//options with defaults set
|
|
32
|
+
this._defaults = {};
|
|
33
|
+
|
|
34
|
+
// Create options by extending defaults with the passed in arugments
|
|
35
|
+
if (options && typeof options === "object") {
|
|
36
|
+
this._options = baseComponent.extendDefaults(this._defaults, options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
//if the required options are valid set up the environment
|
|
41
|
+
if( baseComponent.validateSettings(this._options, validateSettings) ){
|
|
42
|
+
this._internalVars.contentType = baseComponent.getContentType(this);
|
|
43
|
+
setLocalVars.call(this);
|
|
44
|
+
init.call(this);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* destroy()
|
|
50
|
+
* removes the node from the dom and any events attached
|
|
51
|
+
*/
|
|
52
|
+
destroy(){
|
|
53
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
54
|
+
|
|
55
|
+
//a little garbage collection
|
|
56
|
+
for (var variableKey in this){
|
|
57
|
+
if (this.hasOwnProperty(variableKey)){
|
|
58
|
+
delete this[variableKey];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Private Methods
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* init()
|
|
69
|
+
* Initializes the Trianglify pattern
|
|
70
|
+
*/
|
|
71
|
+
function init() {
|
|
72
|
+
|
|
73
|
+
var pattern = Trianglify({
|
|
74
|
+
variance: "0.7",
|
|
75
|
+
cell_size: 175,
|
|
76
|
+
x_colors: ["#ffffff","#dcdcdc", "#e6e6e6","#ffffff", "e8e8e8","f0f0f0", "#dcdcdc","#ffffff", "#f5f5f5","e8e8e8", "#ffffff", "#e6e6e6","#f5f5f5","#fafafa", "#ffffff"],
|
|
77
|
+
width: 3000,
|
|
78
|
+
height: 800
|
|
79
|
+
});
|
|
80
|
+
this._internalVars.node.appendChild(pattern.canvas());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* setLocalVars()
|
|
86
|
+
* set local vars to the ones passed in options
|
|
87
|
+
*/
|
|
88
|
+
function setLocalVars() {
|
|
89
|
+
if(this._internalVars.contentType === 'string') {
|
|
90
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
91
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
92
|
+
this._internalVars.node = this._options.content;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default BackgroundPattern;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
var Trianglify = require('trianglify');
|
|
2
|
+
|
|
3
|
+
import baseComponent from '../../src/baseComponent';
|
|
4
|
+
|
|
5
|
+
const validateSettings = [
|
|
6
|
+
{
|
|
7
|
+
setting: "content",
|
|
8
|
+
isRequired: true,
|
|
9
|
+
validate: "type",
|
|
10
|
+
possibleValues: ["string", "object"],
|
|
11
|
+
errorMessage: ["GDK BackgroundPatternPortfolioPage : Content must be defined and set to a DOM selector or Node"]
|
|
12
|
+
}
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
class BackgroundPatternPortfolioPage {
|
|
16
|
+
|
|
17
|
+
constructor(options) {
|
|
18
|
+
|
|
19
|
+
console.log('BackgroundPatternPortfolioPage initialized');
|
|
20
|
+
|
|
21
|
+
//SM=75 MED=125 LG=175
|
|
22
|
+
|
|
23
|
+
this._internalVars = {
|
|
24
|
+
node: null //used for current node
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//options with defaults set
|
|
28
|
+
this._defaults = {};
|
|
29
|
+
|
|
30
|
+
// Create options by extending defaults with the passed in arugments
|
|
31
|
+
if (options && typeof options === "object") {
|
|
32
|
+
this._options = baseComponent.extendDefaults(this._defaults, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//if the required options are valid set up the environment
|
|
37
|
+
if( baseComponent.validateSettings(this._options, validateSettings) ){
|
|
38
|
+
this._internalVars.contentType = baseComponent.getContentType(this);
|
|
39
|
+
setLocalVars.call(this);
|
|
40
|
+
setEvents.call(this);
|
|
41
|
+
init.call(this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* destroy()
|
|
47
|
+
* removes the node from the dom and any events attached
|
|
48
|
+
*/
|
|
49
|
+
destroy(){
|
|
50
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
51
|
+
|
|
52
|
+
//a little garbage collection
|
|
53
|
+
for (var variableKey in this){
|
|
54
|
+
if (this.hasOwnProperty(variableKey)){
|
|
55
|
+
delete this[variableKey];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Private Methods
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* init()
|
|
66
|
+
* Initializes the Trianglify pattern
|
|
67
|
+
*/
|
|
68
|
+
function init() {
|
|
69
|
+
|
|
70
|
+
if(this._internalVars.alertVerificationItems.length === 0) {
|
|
71
|
+
alertHeight.call(this);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
initialAlertDisplay.call(this);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function trianglify() {
|
|
80
|
+
console.log(this._internalVars.canvasHeight);
|
|
81
|
+
var pattern = Trianglify({
|
|
82
|
+
variance: "0.7",
|
|
83
|
+
cell_size: 175,
|
|
84
|
+
x_colors: ["#ffffff","#dcdcdc", "#e6e6e6","#ffffff", "e8e8e8","f0f0f0", "#dcdcdc","#ffffff", "#f5f5f5","e8e8e8", "#ffffff", "#e6e6e6","#f5f5f5","#fafafa", "#ffffff"],
|
|
85
|
+
width: 3000,
|
|
86
|
+
height: this._internalVars.canvasHeight
|
|
87
|
+
});
|
|
88
|
+
this._internalVars.node.appendChild(pattern.canvas());
|
|
89
|
+
var canvas = document.getElementsByTagName('canvas');
|
|
90
|
+
console.log(canvas);
|
|
91
|
+
canvas[0].setAttribute('id', 'portfolioBackground');
|
|
92
|
+
if (canvas[1]) {
|
|
93
|
+
canvas[1].parentElement.removeChild(canvas[1]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function setCanvasHeight() {
|
|
98
|
+
if(this._internalVars.alertVerificationItems.length === 0) {
|
|
99
|
+
this._internalVars.canvasHeight = 220;
|
|
100
|
+
}
|
|
101
|
+
if(document.getElementById(this._internalVars.canvasID) === null) {
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
document.getElementById(this._internalVars.canvasID).parentNode.removeChild(document.getElementById(this._internalVars.canvasID));
|
|
106
|
+
}
|
|
107
|
+
this._internalVars.backgroundPatternHeightObject.style.height = this._internalVars.canvasHeight + "px";
|
|
108
|
+
trianglify.call(this);
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function initialAlertDisplay() {
|
|
113
|
+
this._internalVars.alertActive = 0;
|
|
114
|
+
this._internalVars.alertItems[this._internalVars.alertActive].classList.add('alert-active');
|
|
115
|
+
if(this._internalVars.alertItems.length > 1) {
|
|
116
|
+
this._internalVars.alertTotalObject.innerHTML = this._internalVars.alertItems.length;
|
|
117
|
+
currentAlertState.call(this);
|
|
118
|
+
} else {
|
|
119
|
+
//hide carousel
|
|
120
|
+
this._internalVars.carouselObject.style.display = 'none';
|
|
121
|
+
}
|
|
122
|
+
alertHeight.call(this);
|
|
123
|
+
chevronState.call(this);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function chevronState () {
|
|
127
|
+
let currentAlert = this._internalVars.alertActive + 1;
|
|
128
|
+
|
|
129
|
+
if(currentAlert === 1) {
|
|
130
|
+
//disable left arrow
|
|
131
|
+
this._internalVars.arrowLeft.setAttribute('disabled', 'disabled');
|
|
132
|
+
this._internalVars.arrowLeft.parentNode.classList.add('disabled');
|
|
133
|
+
if (this._internalVars.alertItems.length === 2) {
|
|
134
|
+
this._internalVars.arrowRight.removeAttribute('disabled');
|
|
135
|
+
this._internalVars.arrowRight.parentNode.classList.remove('disabled');
|
|
136
|
+
}
|
|
137
|
+
} else if(currentAlert === this._internalVars.alertItems.length) {
|
|
138
|
+
//disable right arrow
|
|
139
|
+
if (this._internalVars.alertItems.length === 2) {
|
|
140
|
+
this._internalVars.arrowLeft.removeAttribute('disabled');
|
|
141
|
+
this._internalVars.arrowLeft.parentNode.classList.remove('disabled');
|
|
142
|
+
}
|
|
143
|
+
this._internalVars.arrowRight.setAttribute('disabled', 'disabled');
|
|
144
|
+
this._internalVars.arrowRight.parentNode.classList.add('disabled');
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
//remove disabled classes/attributes
|
|
148
|
+
this._internalVars.arrowLeft.removeAttribute('disabled');
|
|
149
|
+
this._internalVars.arrowLeft.parentNode.classList.remove('disabled');
|
|
150
|
+
this._internalVars.arrowRight.removeAttribute('disabled');
|
|
151
|
+
this._internalVars.arrowRight.parentNode.classList.remove('disabled');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function currentAlertState() {
|
|
156
|
+
this._internalVars.alertCurrentObject.innerHTML = this._internalVars.alertActive + 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function alertHeight() {
|
|
160
|
+
this._internalVars.canvasHeight = this._internalVars.backgroundPatternHeightObject.querySelector('.container').clientHeight;
|
|
161
|
+
setCanvasHeight.call(this);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function setEvents() {
|
|
165
|
+
this._internalVars.arrowRight.addEventListener("click", carouselSelection.bind(this));
|
|
166
|
+
this._internalVars.arrowLeft.addEventListener("click", carouselSelection.bind(this));
|
|
167
|
+
|
|
168
|
+
for(let i=0;i<this._internalVars.closeButtonObject.length;i++){
|
|
169
|
+
this._internalVars.closeButtonObject[i].addEventListener("click", closeButton.bind(this, this._internalVars.closeButtonObject[i]));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
window.addEventListener('resize', alertHeight.bind(this));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function closeButton() {
|
|
176
|
+
let nextAlert = null,
|
|
177
|
+
currentAlert = this._internalVars.alertActive + 1;
|
|
178
|
+
|
|
179
|
+
if(currentAlert === this._internalVars.alertItems.length) {
|
|
180
|
+
nextAlert = this._internalVars.alertActive - 1;
|
|
181
|
+
} else {
|
|
182
|
+
nextAlert = this._internalVars.alertActive;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-active');
|
|
186
|
+
this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-importance');
|
|
187
|
+
this._internalVars.alertItems = document.querySelectorAll('.' + this._internalVars.alertItemsClass);
|
|
188
|
+
|
|
189
|
+
if(this._internalVars.alertItems.length > 0) {
|
|
190
|
+
this._internalVars.alertItems[nextAlert].classList.add('alert-active');
|
|
191
|
+
this._internalVars.alertActive = [].indexOf.call(this._internalVars.alertItems, document.querySelector('.' + this._internalVars.currentAlertClass));
|
|
192
|
+
|
|
193
|
+
if(this._internalVars.alertItems.length === 1) {
|
|
194
|
+
this._internalVars.carouselObject.style.display = 'none';
|
|
195
|
+
} else {
|
|
196
|
+
this._internalVars.alertTotalObject.innerHTML = this._internalVars.alertItems.length;
|
|
197
|
+
chevronState.call(this);
|
|
198
|
+
currentAlertState.call(this);
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
this._internalVars.alertVerificationItems[0].classList.remove('portfolio-alerts');
|
|
202
|
+
}
|
|
203
|
+
alertHeight.call(this);
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function carouselSelection(e) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
|
|
210
|
+
let nextAlert = null;
|
|
211
|
+
|
|
212
|
+
this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-active');
|
|
213
|
+
|
|
214
|
+
if(e.target.id === 'arrow-right') {
|
|
215
|
+
nextAlert = this._internalVars.alertActive + 1;
|
|
216
|
+
this._internalVars.alertActive = nextAlert;
|
|
217
|
+
}
|
|
218
|
+
else{
|
|
219
|
+
nextAlert = this._internalVars.alertActive - 1;
|
|
220
|
+
this._internalVars.alertActive = nextAlert;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this._internalVars.alertItems[this._internalVars.alertActive].classList.add('alert-active');
|
|
224
|
+
|
|
225
|
+
alertHeight.call(this);
|
|
226
|
+
chevronState.call(this);
|
|
227
|
+
currentAlertState.call(this);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* setLocalVars()
|
|
233
|
+
* set local vars to the ones passed in options
|
|
234
|
+
*/
|
|
235
|
+
function setLocalVars() {
|
|
236
|
+
if(this._internalVars.contentType === 'string') {
|
|
237
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
238
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
239
|
+
this._internalVars.node = this._options.content;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this._internalVars.alertVerificationClass = 'portfolio-alerts';
|
|
243
|
+
this._internalVars.alertVerificationItems = document.getElementsByClassName(this._internalVars.alertVerificationClass);
|
|
244
|
+
|
|
245
|
+
this._internalVars.backgroundPatternHeightID = "background-pattern-portfolio-page";
|
|
246
|
+
this._internalVars.backgroundPatternHeightObject = document.getElementById(this._internalVars.backgroundPatternHeightID);
|
|
247
|
+
this._internalVars.canvasHeight = null;
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
this._internalVars.alertContainerID = 'portfolio-alert-container';
|
|
251
|
+
this._internalVars.alertContainerObject = document.getElementById(this._internalVars.alertContainerID);
|
|
252
|
+
|
|
253
|
+
this._internalVars.alertItemsClass = 'alert-importance';
|
|
254
|
+
this._internalVars.alertItems = document.querySelectorAll('.' + this._internalVars.alertItemsClass);
|
|
255
|
+
|
|
256
|
+
this._internalVars.currentAlertClass = 'alert-active';
|
|
257
|
+
this._internalVars.currentAlertObject = document.querySelector('.' + this._internalVars.currentAlertClass);
|
|
258
|
+
|
|
259
|
+
this._internalVars.alertActive = null;
|
|
260
|
+
|
|
261
|
+
this._internalVars.alertCurrentID = 'alert-current';
|
|
262
|
+
this._internalVars.alertTotalID = 'alert-total';
|
|
263
|
+
this._internalVars.alertCurrentObject = document.getElementById(this._internalVars.alertCurrentID);
|
|
264
|
+
this._internalVars.alertTotalObject = document.getElementById(this._internalVars.alertTotalID);
|
|
265
|
+
|
|
266
|
+
this._internalVars.arrowRightID = 'arrow-right';
|
|
267
|
+
this._internalVars.arrowRight = document.getElementById(this._internalVars.arrowRightID);
|
|
268
|
+
|
|
269
|
+
this._internalVars.arrowLeftID = 'arrow-left';
|
|
270
|
+
this._internalVars.arrowLeft = document.getElementById(this._internalVars.arrowLeftID);
|
|
271
|
+
|
|
272
|
+
this._internalVars.carouselClass = 'carousel';
|
|
273
|
+
this._internalVars.carouselObject = document.querySelector('.' + this._internalVars.carouselClass);
|
|
274
|
+
|
|
275
|
+
this._internalVars.closeButtonClass = 'icon-close-20';
|
|
276
|
+
|
|
277
|
+
this._internalVars.alertContainerID = 'portfolio-alert-container';
|
|
278
|
+
this._internalVars.alertContainerObject = document.getElementById(this._internalVars.alertContainerID);
|
|
279
|
+
this._internalVars.closeButtonObject = this._internalVars.alertContainerObject.querySelectorAll('.'+this._internalVars.closeButtonClass);
|
|
280
|
+
|
|
281
|
+
this._internalVars.canvasID = 'portfolioBackground';
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export default BackgroundPatternPortfolioPage;
|