-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyleScript.js
More file actions
90 lines (76 loc) · 2.93 KB
/
Copy pathstyleScript.js
File metadata and controls
90 lines (76 loc) · 2.93 KB
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
let decorationSpans = document.querySelectorAll(".bui span");
let alignmentSpans = document.querySelectorAll(".alignment span");
let colorSpans = document.querySelectorAll(".colors span");
let font_family = document.querySelector("#cell-font-family");
let increase = document.querySelector(".increase");
let decrease = document.querySelector(".decrease");
let currentSize = document.querySelector(".current");
decorationSpans[0].addEventListener("click", (e) => {
oldCell.style.fontWeight = "bold";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].fontWeight = "bold";
});
decorationSpans[1].addEventListener("click", (e) => {
oldCell.style.fontStyle = "Italic";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].italics = "italic";
});
decorationSpans[2].addEventListener("click", (e) => {
oldCell.style.textDecoration = "underline";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].underline = "underline";
});
alignmentSpans[0].addEventListener("click", (e) => {
oldCell.style.textAlign = "left";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].textAlign = "left";
});
alignmentSpans[1].addEventListener("click", (e) => {
oldCell.style.textAlign = "center";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].textAlign = "center";
});
alignmentSpans[2].addEventListener("click", (e) => {
oldCell.style.textAlign = "right";
let cellAdress = oldCell.getAttribute("data-address");
dataObj[cellAdress].textAlign = "right";
});
colorSpans[0].addEventListener("click", function () {
let colorPicker = document.createElement("input");
colorPicker.type = "color";
colorPicker.addEventListener("change", function (e) {
oldCell.style.color = e.currentTarget.value;
let address = oldCell.getAttribute("data-address");
dataObj[address].fontColor = e.currentTarget.value;
});
colorPicker.click();
});
colorSpans[1].addEventListener("click", function () {
let colorPicker = document.createElement("input");
colorPicker.type = "color";
colorPicker.addEventListener("change", function (e) {
oldCell.style.backgroundColor = e.currentTarget.value;
let address = oldCell.getAttribute("data-address");
dataObj[address].backgroundColor = e.currentTarget.value;
});
colorPicker.click();
});
font_family.addEventListener("click", (e) => {
oldCell.style.fontFamily = e.currentTarget.value;
let address = oldCell.getAttribute("data-address");
dataObj[address].fontFamily = e.currentTarget.value;
});
increase.addEventListener("click", (e) => {
let curr = Number(currentSize.innerText);
if (curr < 50) {
currentSize.innerText = curr + 1;
oldCell.style.fontSize = `${curr + 1}px`;
}
});
decrease.addEventListener("click", (e) => {
let curr = Number(currentSize.innerText);
if (curr > 0) {
currentSize.innerText = curr - 1;
oldCell.style.fontSize = `${curr - 1}px`;
}
});