-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mickaelvieira/0.0.5
0.1.0
- Loading branch information
Showing
10 changed files
with
300 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"use strict"; | ||
|
||
const wrap = DOMElementWrapper.wrap; | ||
|
||
function form_example() { | ||
const form = wrap("form", { | ||
id: "my-form", | ||
action: "https://example.local", | ||
method: "POST", | ||
className: "form" | ||
}) | ||
.addEventListener("submit", function(event) { | ||
event.preventDefault(); | ||
console.log(event); | ||
}) | ||
.appendWrappers( | ||
wrap("div", { className: "form-group" }).appendWrappers( | ||
wrap("input", { | ||
type: "text", | ||
id: "username", | ||
name: "username", | ||
className: "form-control" | ||
}) | ||
), | ||
wrap("div", { className: "form-group" }).appendWrappers( | ||
wrap("input", { | ||
type: "text", | ||
id: "password", | ||
name: "password", | ||
className: "form-control" | ||
}) | ||
), | ||
wrap("div", { className: "form-group" }).appendWrappers( | ||
wrap("input", { | ||
type: "submit", | ||
id: "username", | ||
name: "username", | ||
className: "btn btn-secondary", | ||
value: "Click me" | ||
}) | ||
) | ||
) | ||
.unwrap(); | ||
|
||
const container = document.querySelector(".form-example"); | ||
container.appendChild(form); | ||
} | ||
|
||
function list_example() { | ||
const wrap = DOMElementWrapper.wrap; | ||
|
||
const items = ["Cat", "Dog", "Wolf"].map(name => wrap("li").appendText(name)); | ||
|
||
const element = wrap("div") | ||
.setAttribute("id", "element-id") | ||
.appendWrappers( | ||
wrap("div").appendWrappers(wrap("h2").appendText("Animals")), | ||
wrap("ul").appendWrappers(...items) | ||
) | ||
.unwrap(); | ||
|
||
let container = document.querySelector(".list-example"); | ||
container.appendChild(element); | ||
} | ||
|
||
window.addEventListener("DOMContentLoaded", function() { | ||
form_example(); | ||
list_example(); | ||
}); |
Oops, something went wrong.