JSFiddle - React, Tailwind, and code Playground
by Marco Iamonte
JavaScript
/*
idom javascript library
created by Iamonte Marco, 16/01/2015
Features:
-> dom elements manipulation [in progress] {
current: form manipulation...
later: something else **
}
*/
idom = (function(){
var size = {
win: {
width: screen.width | undefined,
height: screen.height | undefined
},
dom: {
width: window.innerWidth | undefined,
height: window.innerHeight | undefined
}
};
var forms = [];
var formListenersQueue = [];
return {
getScreenSize: function(req) {
if (!req) {
if (typeof(size.win.width) == undefined || typeof(size.win.height) == undefined) {
return {};
}
else {
return {
width: size.win.width,
height: size.win.height
};
}
}
else {
return req == 'width' ? size.win.width : size.win.height;
}
},
getDomSize: function(req) {
if (!req) {
if (typeof(size.dom.width) == undefined || typeof(size.dom.height) == undefined) {
return {};
}
else {
return {
width: size.dom.width,
height: size.dom.height
};
}
}
else {
return req == 'width' ? size.dom.width : size.dom.height;
}
},
createForm: function(id, method, action, AJAX) {
var newForm = document.createElement('form');
newForm.setAttribute('method',method);
newForm.setAttribute('action',action);
newForm.setAttribute('id',id);
forms.push(newForm);
return this;
},
getForm: function(id) {
for (var i = 0; i < forms.length; i++) {
if (forms[i].getAttribute('id') == id) {
return {
setProperty: function(property, value) {
forms[i].setAttribute(property, value);
},
addInput: function(id, type, value) {
var newInput = document.createElement('input');
newInput.setAttribute('type',type);
newInput.setAttribute('id',id);
newInput.setAttribute('value',value);
forms[i].appendChild(newInput);
},
listen:...