geico-design-kit 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
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,203 @@
|
|
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 CoverageGraph {
|
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 coverage graph node
|
16
|
+
*/
|
17
|
+
constructor(options) {
|
18
|
+
this._internalVars = {
|
19
|
+
node: null, //used for current node
|
20
|
+
breakdownNode: null,
|
21
|
+
legendNode: null,
|
22
|
+
labelArray: null,
|
23
|
+
costArray: null,
|
24
|
+
percentArray: [],
|
25
|
+
totalSum: 0,
|
26
|
+
percentSum: 0,
|
27
|
+
centerCircle: null
|
28
|
+
};
|
29
|
+
|
30
|
+
//options with defaults set
|
31
|
+
this._defaults = {};
|
32
|
+
|
33
|
+
// Create options by extending defaults with the passed in arugments
|
34
|
+
if (options && typeof options === "object") {
|
35
|
+
this._options = baseComponent.extendDefaults(this._defaults, options);
|
36
|
+
}
|
37
|
+
|
38
|
+
//if the required options are valid set up the environment
|
39
|
+
if (baseComponent.validateSettings(this._options, validateSettings)) {
|
40
|
+
this._internalVars.contentType = baseComponent.getContentType(this);
|
41
|
+
setLocalVars.call(this);
|
42
|
+
setEvents.call(this);
|
43
|
+
appendCenterCost.call(this);
|
44
|
+
createSlices.call(this);
|
45
|
+
createLegend.call(this);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
//Public Methods
|
51
|
+
|
52
|
+
/**
|
53
|
+
* destroy()
|
54
|
+
* removes the node from the dom and any events attached
|
55
|
+
*/
|
56
|
+
destroy(){
|
57
|
+
$(this._internalVars.node).datepicker("destroy");
|
58
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
59
|
+
|
60
|
+
//a little garbage collection
|
61
|
+
for (var variableKey in this){
|
62
|
+
if (this.hasOwnProperty(variableKey)){
|
63
|
+
delete this[variableKey];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
// Private Methods
|
70
|
+
function setLocalVars() {
|
71
|
+
if(this._internalVars.contentType === 'string') {
|
72
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
73
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
74
|
+
this._internalVars.node = this._options.content;
|
75
|
+
}
|
76
|
+
|
77
|
+
this._internalVars.breakdownNode = this._internalVars.node.querySelector('.coverage-graph-breakdown');
|
78
|
+
if(this._internalVars.breakdownNode.dataset !== undefined){
|
79
|
+
this._internalVars.costArray = this._internalVars.breakdownNode.dataset.costbreakdown.split(" ");
|
80
|
+
this._internalVars.labelArray = this._internalVars.breakdownNode.dataset.labels.split(",");
|
81
|
+
}else{
|
82
|
+
this._internalVars.labelArray = this._internalVars.breakdownNode.getAttribute('data-labels').split(",");
|
83
|
+
this._internalVars.costArray = this._internalVars.breakdownNode.getAttribute('data-costbreakdown').split(" ");
|
84
|
+
}
|
85
|
+
this._internalVars.centerCircle = this._internalVars.breakdownNode.querySelector('.circle');
|
86
|
+
this._internalVars.legendNode = this._internalVars.node.querySelector('.legend');
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* setEvents()
|
92
|
+
* Sets all the events needed for the component
|
93
|
+
*/
|
94
|
+
function setEvents() {
|
95
|
+
|
96
|
+
}
|
97
|
+
|
98
|
+
function appendCenterCost(){
|
99
|
+
var monetary = this._internalVars.centerCircle.querySelector('.monetary');
|
100
|
+
var sumText = getCostSum.call(this);
|
101
|
+
var costBreakdownArray = sumText.toString().split(".");
|
102
|
+
var textNodeSum = document.createTextNode(costBreakdownArray[0]);
|
103
|
+
monetary.appendChild(textNodeSum);
|
104
|
+
var supElement = document.createElement('SUP');
|
105
|
+
var textNodeSumDecimal = document.createTextNode("."+costBreakdownArray[1]);
|
106
|
+
supElement.appendChild(textNodeSumDecimal);
|
107
|
+
monetary.appendChild(supElement);
|
108
|
+
}
|
109
|
+
|
110
|
+
function createSlices(){
|
111
|
+
var percentarray = createPercentageArray.call(this);
|
112
|
+
var sheet = (function(){
|
113
|
+
var style = document.createElement('STYLE');
|
114
|
+
style.appendChild(document.createTextNode(""));
|
115
|
+
document.head.appendChild(style);
|
116
|
+
return style.sheet;
|
117
|
+
})();
|
118
|
+
for(var j=0; j<percentarray.length;j++){
|
119
|
+
var newDiv = document.createElement('DIV');
|
120
|
+
this._internalVars.breakdownNode.appendChild(newDiv);
|
121
|
+
if (percentarray[j]>=180) {
|
122
|
+
newDiv.setAttribute('class', 'pie big');
|
123
|
+
}
|
124
|
+
else{
|
125
|
+
newDiv.setAttribute('class', 'pie');}
|
126
|
+
newDiv.setAttribute('data-start', this._internalVars.percentSum.toFixed(1));
|
127
|
+
if (j!==0) {
|
128
|
+
setPrefixes(newDiv, "Transform", "rotate("+this._internalVars.percentSum+"deg)");
|
129
|
+
sheet.insertRule(insertDataStartCSS(this._internalVars.percentSum), 0);
|
130
|
+
}
|
131
|
+
this._internalVars.percentSum += parseFloat(percentarray[j]);
|
132
|
+
newDiv.setAttribute('data-value', percentarray[j]);
|
133
|
+
sheet.insertRule(insertDataValueCSS(percentarray[j], percentarray.length, j), 0);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
function insertDataValueCSS(degree, length, index){
|
138
|
+
degree=parseFloat(degree);
|
139
|
+
var degree1 = degree;
|
140
|
+
if(index!=length-1){
|
141
|
+
degree1 = parseFloat(degree+1);
|
142
|
+
}
|
143
|
+
var cssString = ".pie[data-value='"+degree+"']:BEFORE { -moz-transform: rotate("+degree1+"deg); -ms-transform: rotate("+degree1+"deg); -webkit-transform: rotate("+degree1+"deg); -o-transform: rotate("+degree1+"deg); transform:rotate("+degree1+"deg);}";
|
144
|
+
return cssString;
|
145
|
+
}
|
146
|
+
|
147
|
+
function insertDataStartCSS(degree){
|
148
|
+
degree = parseFloat(degree).toFixed(1);
|
149
|
+
var cssString = ".pie[data-start='"+degree+"'] { -moz-transform: rotate("+degree+"deg); /* Firefox */ -ms-transform: rotate("+degree+"deg); /* IE */ -webkit-transform: rotate("+degree+"deg); /* Safari and Chrome */ -o-transform: rotate("+degree+"deg); /* Opera */transform:rotate("+degree+"deg);}";
|
150
|
+
return cssString;
|
151
|
+
}
|
152
|
+
|
153
|
+
function setPrefixes(element, property, value) {
|
154
|
+
element.style["webkit" + property] = value;
|
155
|
+
element.style["moz" + property] = value;
|
156
|
+
element.style["ms" + property] = value;
|
157
|
+
element.style["o" + property] = value;
|
158
|
+
}
|
159
|
+
|
160
|
+
function getCostSum(){
|
161
|
+
var costArray = this._internalVars.costArray;
|
162
|
+
var sum = this._internalVars.totalSum;
|
163
|
+
for(var i=0;i<costArray.length;i++){
|
164
|
+
sum += parseFloat(costArray[i]);
|
165
|
+
}
|
166
|
+
sum = sum.toFixed(2);
|
167
|
+
return sum;
|
168
|
+
}
|
169
|
+
|
170
|
+
function createLegend(){
|
171
|
+
var costArray = this._internalVars.costArray;
|
172
|
+
var labelArray = this._internalVars.labelArray;
|
173
|
+
for(var i=0;i<costArray.length;i++){
|
174
|
+
this._internalVars.legendNode.querySelector('ul').appendChild(createLi(labelArray[i], parseFloat(costArray[i])));
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
function createPercentageArray(){
|
179
|
+
var costArray = this._internalVars.costArray;
|
180
|
+
var costSum = getCostSum.call(this);
|
181
|
+
for(var j=0;j<costArray.length;j++){
|
182
|
+
this._internalVars.percentArray.push(costToPercentage(costArray[j], costSum));
|
183
|
+
}
|
184
|
+
return this._internalVars.percentArray;
|
185
|
+
}
|
186
|
+
|
187
|
+
function costToPercentage(cost, sum){
|
188
|
+
var percent = (((cost/sum))*360);
|
189
|
+
return percent;
|
190
|
+
}
|
191
|
+
|
192
|
+
function createLi(item, cost){
|
193
|
+
var liEl = document.createElement("LI");
|
194
|
+
var divEl = document.createElement("DIV");
|
195
|
+
divEl.setAttribute('class', 'legend-item');
|
196
|
+
liEl.appendChild(divEl);
|
197
|
+
var labelString = item + " ($" + cost.toFixed(2) + ")";
|
198
|
+
var hello = document.createTextNode(labelString);
|
199
|
+
liEl.appendChild(hello);
|
200
|
+
return liEl;
|
201
|
+
}
|
202
|
+
|
203
|
+
export default CoverageGraph;
|