simple-ui-builder
Advanced tools
Comparing version 1.0.1 to 1.0.4
{ | ||
"name": "simple-ui-builder", | ||
"version": "1.0.1", | ||
"version": "1.0.4", | ||
"description": "Build user interface like Lego bricks. UI.input(), UI.button(cb), UI.select(arr) etc. For lazy guys as I am.", | ||
@@ -5,0 +5,0 @@ "main": "ui.js", |
31
ui.js
@@ -121,2 +121,27 @@ /** | ||
UI.br = function(params) { | ||
params = params || {}; | ||
if (typeof params == "string") { | ||
params = { | ||
parent: document.querySelector(params) | ||
}; | ||
} else if (params instanceof HTMLElement) { | ||
params = { | ||
parent: params | ||
}; | ||
} | ||
if (typeof params.parent == "string") params.parent = document.querySelector(params.parent); | ||
else params.parent = params.parent || document.body; | ||
params.id = params.id || "br"; | ||
var br = document.createElement("br"); | ||
br.id = params.id; | ||
params.parent.appendChild(br); | ||
}; | ||
UI.radio = function(arr, params, cb) { | ||
@@ -139,3 +164,3 @@ | ||
if (typeof params == "string") params = { | ||
parent: params | ||
parent: document.querySelector(params) | ||
}; | ||
@@ -203,3 +228,3 @@ | ||
checkbox.onclick = function() { | ||
cb(checkbox.id); | ||
cb(checkbox.checked); | ||
}; | ||
@@ -265,3 +290,3 @@ params.parent.appendChild(checkbox); | ||
if(typeof str == "object") str = JSON.stringify(str); | ||
if(typeof str == "object") str = JSON.stringify(str, null, "\t"); | ||
@@ -268,0 +293,0 @@ params.id = params.id || params.name || "download-link"; |
16981
399