1.0.0 • Published 2 years ago

smalljs v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
2 years ago

Smalljs

Smalljs is inspired by the many libraries that demonstrate jQuery is no longer necessary. Right now, this means targeting IE9+.

Smalljs is the primary/sole javascript library behind the Blogful, Thinkful and Shopful projects.

Build

npm install
node_modules/gulp/bin/gulp.js

AJAX

Support not provided. Zepto's AJAX module is one option, but we decided instead to go with the Reqwest library for better AMD support.

Examples

The code is pretty simple intent-wise. Here are a few examples.

find

u.find("body").style.backgroundColor = "#fff";

u.find("div#my-div").find("p").onclick = myAction;

findAll

u.findAll("div").toArray().forEach(function(div) {
    div.style.height = "200px";

    div.findAll("p").toArray().forEach(function(p) {
        p.innerHTML = "Text";
    });
});

make

var div = u.make("div");
u.find("body").appendChild(div);

hasClass

u.find(".my-class").hasClass("my-class") === true;

addClass

u.find("#sidebar").addClass("hidden");

removeClass

u.find("#sidebar").removeClass("hidden");

toggleClass

u.find("#sidebar").toggleClass("hidden");

serialize

u.find("form#my-form").serialize().forEach(function(field) {
    console.log(field.name, field.value);
});

toArray

u.findAll("div").toArray().forEach(function(div) {
    div.onclick = myAction;
});

getParameter

// Get query parameter.
u.getParameter("q");

Users

Further reading

http://perfectionkills.com/whats-wrong-with-extending-the-dom/

1.0.0

2 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago