Initial checkin

This commit is contained in:
Joe
2017-02-07 12:55:56 -06:00
commit b557c002ae
44 changed files with 15499 additions and 0 deletions

38
js/helpers.js Normal file
View File

@@ -0,0 +1,38 @@
/*globals $,ibuyproperties*/
ibuyproperties.helpers=(function(){
function toJSO(input) {
var obj = {};
if (ibuyproperties.isDebugMode) { console.log("Converting form data to JSON"); }
input.find("[name]").each(function (pos,theElement) {
if (ibuyproperties.isDebugMode) { console.log("Inspecting",$(theElement)); }
var name = $(theElement).attr('name');
var isButton=false;
var isCheckbox="checkbox"===$(theElement).attr('type');
var type = ["text","number"].indexOf($(theElement).attr('type') > -1)?$(theElement).attr('type'):undefined;
if (type==="button") {
isButton=true;
}
if (ibuyproperties.isDebugMode) { console.log("Element name/type/but/cbx",name,type,isButton,isCheckbox,$(theElement)); }
if (isCheckbox) {
obj[name]=$(theElement).is(':checked')?true:false;
} else if(isButton){
obj[name]=$(theElement).hasClass('active')?true:false;
} else {
obj[name]=$(theElement).val();
}
});
return obj;
}
return {
toJSO:toJSO
};
}());