-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
242 lines (205 loc) · 7.53 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* =========================================================================================
Summary
=========================================================================================
Container properties:
Flex-direction
Justify-content
Align-items
Align-content
Flex-wrap
Multi Flex
Content properties:
Align-self
Flex-grow
Flex-shrink
Order
*/
// TODO: refactor
/* =========================================================================================
Container properties
========================================================================================= */
/* Flex Direction */
function flexDir(option) {
let flexDirectionStyle = document.getElementById("flex-direction-container").style;
flexDirectionStyle.flexDirection = option;
}
/* Justify Content */
function justifyContent(option) {
let justifyContentStyle = document.getElementById("justify-content-container").style;
justifyContentStyle.justifyContent = option;
}
/* Align Items*/
function alignItems(option) {
let alignItemsStyle = document.getElementById("align-items-container").style;
alignItemsStyle.alignItems = option; /* Container need height */
}
/* Align Content */
function alignContent(option) {
let alignContentStyle = document.getElementById("align-content-container").style;
alignContentStyle.alignContent = option; /* Container need height */
}
/* Flex Wrap */
function flexWrap(option) {
let flexWrapStyle = document.getElementById("flex-wrap-container").style;
flexWrapStyle.flexWrap = option;
}
function itemSize(value) {
console.log("item width: " + value + "rem")
let itemSize = document.getElementsByClassName('fw');
for (let i = 0; i < itemSize.length; i++) {
itemSize[i].style.width = value + "rem";
}
}
function containerWidth(value) {
console.log("container width: " + value + "%")
let flexWrapStyle = document.getElementById("flex-wrap-container").style;
flexWrapStyle.width = value + "%";
}
/* ============================================================================
MULTIFLEX
============================================================================ */
/* Flex Direction */
function multiFlexDir(option) {
let flexDirectionStyle = document.getElementById("multiflex-container").style;
flexDirectionStyle.flexDirection = option;
console.log(option);
}
/* Justify Content */
function multiJustifyContent(option) {
let justifyContentStyle = document.getElementById("multiflex-container").style;
justifyContentStyle.justifyContent = option;
}
/* Align Items*/
function multiAlignItems(option) {
let alignItemsStyle = document.getElementById("multiflex-container").style;
alignItemsStyle.alignItems = option; /* Container need size */
}
/* Align Content */
function multiAlignContent(option) {
let alignContentStyle = document.getElementById("multiflex-container").style;
alignContentStyle.alignContent = option; /* Container need size */
}
/* Flex Wrap */
function multiFlexWrap(option) {
let flexWrapStyle = document.getElementById("multiflex-container").style;
flexWrapStyle.flexWrap = option;
}
// TODO: add option overflow hidden/visible
/* Item dimensions */
/* Item width */
function multiItemWidth(value) {
console.log("item width: " + value + "rem")
let itemSize = document.getElementsByClassName('multiflexitem');
for (let i = 0; i < itemSize.length; i++) {
itemSize[i].style.width = value + "rem";
}
}
/* Item height */
function multiItemHeight(value) {
console.log("item width: " + value + "rem")
let itemSize = document.getElementsByClassName('multiflexitem');
for (let i = 0; i < itemSize.length; i++) {
itemSize[i].style.height = value + "rem";
}
}
/* Container dimensions */
/* Container width */
function multiContainerWidth(value) {
console.log("container width: " + value + "%")
let flexWrapStyle = document.getElementById("multiflex-container").style;
flexWrapStyle.width = value + "vw";
}
/* Container height */
function multiContainerHeight(value) {
console.log("container width: " + value + "%")
let flexWrapStyle = document.getElementById("multiflex-container").style;
flexWrapStyle.height = value + "vh";
}
/* Item Quantity */
function multiItemQuantity(value) {
let multiContainer = document.getElementById("multiflex-container");
let itemQuantity = document.getElementsByClassName("multiflexitem").length;
// Delete all the existing items
while(multiContainer.firstChild) {
multiContainer.removeChild(multiContainer.firstChild);
}
// Create as many items as input value
for (let i = 0; i < value; i++) {
let item = document.createElement("div");
item.className = "multiflexitem";
multiContainer.appendChild(item);
}
console.log("item Quantity: " + itemQuantity);
console.log("input value: " + value);
}
/* ============================================================================
Content properties
============================================================================ */
/* Align self */
function alignSelf(option) {
let alignSelfStyle = document.getElementById("align_self_item3").style;
alignSelfStyle.alignSelf = option;
}
/* Flex grow */
function flexGrow1(option) {
let flexGrowStyle = document.getElementById("flex-grow-item1").style;
flexGrowStyle.flexGrow = option;
}
function flexGrow2(option) {
let flexGrowStyle = document.getElementById("flex-grow-item2").style;
flexGrowStyle.flexGrow = option;
}
function flexGrow3(option) {
let flexGrowStyle = document.getElementById("flex-grow-item3").style;
flexGrowStyle.flexGrow = option;
}
function flexGrow4(option) {
let flexGrowStyle = document.getElementById("flex-grow-item4").style;
flexGrowStyle.flexGrow = option;
}
function flexGrow5(option) {
let flexGrowStyle = document.getElementById("flex-grow-item5").style;
flexGrowStyle.flexGrow = option;
}
/* Flex shrink */
function flexShrink1(option) {
let flexShrinkStyle = document.getElementById("flex-shrink-item1").style;
flexShrinkStyle.flexShrink = option; // Total items widths must exceed containers width
}
function flexShrink2(option) {
let flexShrinkStyle = document.getElementById("flex-shrink-item2").style;
flexShrinkStyle.flexShrink = option;
}
function flexShrink3(option) {
let flexShrinkStyle = document.getElementById("flex-shrink-item3").style;
flexShrinkStyle.flexShrink = option;
}
function flexShrink4(option) {
let flexShrinkStyle = document.getElementById("flex-shrink-item4").style;
flexShrinkStyle.flexShrink = option;
}
function flexShrink5(option) {
let flexShrinkStyle = document.getElementById("flex-shrink-item5").style;
flexShrinkStyle.flexShrink = option;
}
/* Order */
function flexOrder1(option) {
let flexOrderStyle = document.getElementById("flex-order-item1").style;
flexOrderStyle.order = option;
}
function flexOrder2(option) {
let flexOrderStyle = document.getElementById("flex-order-item2").style;
flexOrderStyle.order = option;
}
function flexOrder3(option) {
let flexOrderStyle = document.getElementById("flex-order-item3").style;
flexOrderStyle.order = option;
}
function flexOrder4(option) {
let flexOrderStyle = document.getElementById("flex-order-item4").style;
flexOrderStyle.order = option;
}
function flexOrder5(option) {
let flexOrderStyle = document.getElementById("flex-order-item5").style;
flexOrderStyle.order = option;
}