Skip to content

Commit 5c423ab

Browse files
authored
Merge pull request #59 from KristenEKelly/feature/issue-54-indented-lists
Feature/issue 54 indented lists
2 parents a7ee3bb + 39e0271 commit 5c423ab

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

css/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ ol {
149149
padding: 0px;
150150
}
151151

152+
.tabbed_text {
153+
text-indent: 10px;
154+
padding-left: 10px;
155+
list-style-type: circle;
156+
list-style-position: inside;
157+
}
158+
152159
input::placeholder {
153160
font-family: "Andale", monospace;
154161
}

lib/ListExtender.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,36 @@
8787
this.addListItem();
8888
});
8989

90+
function addIndent(input) {
91+
const li = input.parentElement;
92+
if (!li.classList.contains("tabbed_text")) {
93+
li.classList.add("tabbed_text");
94+
}
95+
}
96+
97+
function removeIndent(input) {
98+
const li = input.parentElement;
99+
if (li.classList.contains("tabbed_text")) {
100+
li.classList.remove("tabbed_text");
101+
}
102+
}
103+
104+
this.element.addEventListener("keydown", (event) => {
105+
if (event.key === "Tab") {
106+
event.preventDefault();
107+
const currentInput = document.activeElement;
108+
if (currentInput && currentInput.tagName === "INPUT") {
109+
if (event.shiftKey) {
110+
// Handle Shift+Tab to remove indent
111+
removeIndent(currentInput);
112+
} else {
113+
// Handle Tab to add indent
114+
addIndent(currentInput);
115+
}
116+
}
117+
}
118+
});
119+
90120
/*
91121
Following function uses external code
92122
Title: How To Build Sortable Drag & Drop With Vanilla Javascript

0 commit comments

Comments
 (0)