https://github.com/positlabs/dominion
Makes minions from ordinary DOM elements; Good for conquering the internet. Simple selector queries, event handling, and dom manipulation.
https://github.com/positlabs/dominion
Last synced: about 2 months ago
JSON representation
Makes minions from ordinary DOM elements; Good for conquering the internet. Simple selector queries, event handling, and dom manipulation.
- Host: GitHub
- URL: https://github.com/positlabs/dominion
- Owner: positlabs
- Created: 2013-05-02T21:34:57.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-09-17T16:39:03.000Z (over 11 years ago)
- Last Synced: 2024-10-19T07:14:56.893Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.61 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Dominion
==========
Good for conquering the internet. Simple selector queries, event handling, and dom manipulation.Documentation is in-line. Look at the code for details.
dom.*
==========Various methods for dom manipulation. It's very flexible - most methods will accept selector strings, Nodes, NodeLists, or Arrays of Nodes as arguments.
```javascript
// returns div with id "hello"
dom("#hello");// makes a header tag with some text in it
var knight = dom.tag("h1", "I'm a knight!");
knight.id = "arthur"// wraps the knight in some armor
var armor = dom.tag("div", knight);// add armored knight to the battlefield (document.body)
dom.add(armor);// Running short on knights. Make a clone.
var knightClone = knight.clone();
knightClone.id = "bartholemew";// Running short on armor. Maybe two knights will fit.
dom.insert(knightClone, 1, armor);// hmm... remove one of them
dom.remove('#arthur', armor);```
Extending Elements
==========Dominion extends the Node / NodeList / Element prototypes, with dom manipulation and event handling
```javascript
// make a minion, handle click and touchstart events
var minion = dom.add("div");
minion.className = "minion";
minion.on("click touchstart", function(){console.log("hail santa!")});// add an event listener to all minions
var minions = dom(".minions");
minions.on("mousemove touchmove", petMinion);// remove petMinion listener from all minions
minions.off("mousemove touchmove", petMinion);// minions are misbehaving! confiscate their weapons
var shanks = minions.find(".weapon");
minions.remove(shanks);```
© 2013 posit labs