Initial checkin
This commit is contained in:
2377
js/bootstrap.js
vendored
Normal file
2377
js/bootstrap.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
js/bootstrap.min.js
vendored
Normal file
7
js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4608
js/handlebars-v4.0.5.js
Normal file
4608
js/handlebars-v4.0.5.js
Normal file
File diff suppressed because one or more lines are too long
38
js/helpers.js
Normal file
38
js/helpers.js
Normal 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
|
||||
};
|
||||
|
||||
}());
|
||||
56
js/main.js
Normal file
56
js/main.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/*globals $,window,document,Handlebars*/
|
||||
|
||||
var ibuyproperties=(function(){
|
||||
"use strict";
|
||||
|
||||
var isDebugMode = false;
|
||||
|
||||
function navShow(cls,ele){
|
||||
$("."+cls).addClass('hide');
|
||||
$("#pnl_"+ele).removeClass('hide');
|
||||
$(".topNav"+cls).removeClass('active');
|
||||
$(".topNav"+ele).addClass('active');
|
||||
}
|
||||
|
||||
function toggleButton(elEnable,elDisable){
|
||||
elEnable.addClass('active btn-warning');
|
||||
elDisable.removeClass('active btn-warning');
|
||||
elDisable.addClass('btn-default');
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
if (window.location.search.match(/[?&]debug=true/)) {
|
||||
console.log("Enabling Debugging Mode");
|
||||
ibuyproperties.isDebugMode=true;
|
||||
} else {
|
||||
ibuyproperties.isDebugMode=false;
|
||||
}
|
||||
|
||||
ibuyproperties.templateHelper.load(ibuyproperties.templates.getAll()).done(function(){
|
||||
if (ibuyproperties.isDebugMode) { console.log("All Templates Loaded."); }
|
||||
$.each(ibuyproperties.templates.getType("partials"),function(index,thePartial){
|
||||
if (ibuyproperties.isDebugMode){ console.log("Load Partial",thePartial);}
|
||||
Handlebars.registerPartial(thePartial,ibuyproperties.templateHelper.get(thePartial)());
|
||||
});
|
||||
$("body").prepend(ibuyproperties.templateHelper.get("nav")({}));
|
||||
$("body").append(ibuyproperties.templateHelper.get("impressum")({}));
|
||||
$("body").append(ibuyproperties.templateHelper.get("about")({}));
|
||||
if (ibuyproperties.isDebugMode) {
|
||||
$("body").append(ibuyproperties.templateHelper.get("debug")({}));
|
||||
}
|
||||
ibuyproperties.router.route();
|
||||
$(window).on('hashchange', ibuyproperties.router.route);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
navShow: navShow,
|
||||
toggleButton: toggleButton,
|
||||
isDebugMode:isDebugMode
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
13
js/npm.js
Normal file
13
js/npm.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
|
||||
require('../../js/transition.js')
|
||||
require('../../js/alert.js')
|
||||
require('../../js/button.js')
|
||||
require('../../js/carousel.js')
|
||||
require('../../js/collapse.js')
|
||||
require('../../js/dropdown.js')
|
||||
require('../../js/modal.js')
|
||||
require('../../js/tooltip.js')
|
||||
require('../../js/popover.js')
|
||||
require('../../js/scrollspy.js')
|
||||
require('../../js/tab.js')
|
||||
require('../../js/affix.js')
|
||||
56
js/router.js
Normal file
56
js/router.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/*globals $,ibuyproperties,window*/
|
||||
|
||||
ibuyproperties.router=(function(){
|
||||
var allRoutes=[];
|
||||
|
||||
function route() {
|
||||
var hash = window.location.hash;
|
||||
var lastLocation = null;
|
||||
|
||||
if (!hash) {
|
||||
window.location.hash = "#Home";
|
||||
}
|
||||
|
||||
if (lastLocation != hash) {
|
||||
this.lastLocation=hash;
|
||||
|
||||
// Generic routing based on template names
|
||||
$.each(ibuyproperties.templates.getType("mainPages"),function(pos,name){
|
||||
var re=new RegExp("^#" + name + "[/]*");
|
||||
if (ibuyproperties.isDebugMode) { console.log("Generic Router - test ",name);}
|
||||
// debugger;
|
||||
if (hash.match(re)) {
|
||||
if (ibuyproperties.isDebugMode) { console.log("Generic Router - match ",name);}
|
||||
if ($("#pnl_" +name).length === 0) {
|
||||
$("#content").empty().append(ibuyproperties.templateHelper.get(name)({templateName:name}));
|
||||
}
|
||||
ibuyproperties.navShow('mainScreen',name);
|
||||
$('.in,.open').removeClass('in open');
|
||||
}
|
||||
});
|
||||
|
||||
// Dynamic route handling
|
||||
$.each(allRoutes,function(pos,theRoute){
|
||||
if (ibuyproperties.isDebugMode) { console.log("Dynamic Router - test ",hash ,theRoute);}
|
||||
|
||||
var re=new RegExp(theRoute.re);
|
||||
if (hash.match(re)) {
|
||||
if (ibuyproperties.isDebugMode) { console.log("Dynamic Router - match ",hash,theRoute);}
|
||||
theRoute.cb.call();
|
||||
return false; // exit the loop
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function addRoute(re, callBack){
|
||||
var theRoute={re:re,cb:callBack};
|
||||
allRoutes.push(theRoute);
|
||||
|
||||
}
|
||||
return {
|
||||
route:route,
|
||||
addRoute:addRoute
|
||||
};
|
||||
}());
|
||||
58
js/sellForm.js
Normal file
58
js/sellForm.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/*globals $,ibuyproperties,window*/
|
||||
|
||||
ibuyproperties.sellForm = (function(){
|
||||
"use strict";
|
||||
|
||||
function init(){
|
||||
if (ibuyproperties.isDebugMode) { console.log("Form-Init"); }
|
||||
|
||||
//open page1 if no page is given
|
||||
if (window.location.hash.match(new RegExp("^#Sell[/]*$"))) {window.location+="/page1/";}
|
||||
|
||||
ibuyproperties.router.addRoute("^#Sell/page1",function(){
|
||||
ibuyproperties.navShow('pnl_sell','sell_userInfo');
|
||||
});
|
||||
|
||||
ibuyproperties.router.addRoute("^#Sell/page2",function(){
|
||||
ibuyproperties.navShow('pnl_sell','sell_propAddress');
|
||||
});
|
||||
|
||||
ibuyproperties.router.addRoute("^#Sell/page3",function(){
|
||||
ibuyproperties.navShow('pnl_sell','sell_propInfo');
|
||||
});
|
||||
|
||||
ibuyproperties.router.addRoute("^#Sell/thanks",function(){
|
||||
ibuyproperties.navShow('pnl_sell','sell_thanks');
|
||||
});
|
||||
|
||||
ibuyproperties.router.addRoute("^#Sell/sendError",function(){
|
||||
ibuyproperties.navShow('pnl_sell','sell_sendError');
|
||||
});
|
||||
}
|
||||
|
||||
function sendForm(){
|
||||
if (ibuyproperties.isDebugMode) { console.log("Sending Form"); }
|
||||
var formInfo=ibuyproperties.helpers.toJSO($("#pnl_Sell"));
|
||||
if (ibuyproperties.isDebugMode) { console.log("Form-data",formInfo); }
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"/postForward.php",
|
||||
dataType:"json",
|
||||
contentType:"application/json",
|
||||
data: JSON.stringify(formInfo),
|
||||
success:function(msg,jqXHR,status) {
|
||||
console.log("send-success method",msg,jqXHR,status);
|
||||
window.location="#Sell/thanks";
|
||||
},
|
||||
error:function(jqXHR,status,error){
|
||||
console.log("send-error method",jqXHR,status,error);
|
||||
window.location="#Sell/sendError";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
init:init,
|
||||
sendForm:sendForm
|
||||
};
|
||||
}());
|
||||
42
js/templateHelper.js
Normal file
42
js/templateHelper.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/* globals $,ibuyproperties,Handlebars*/
|
||||
|
||||
ibuyproperties.templateHelper = (function () {
|
||||
"use strict";
|
||||
|
||||
var templates = {},
|
||||
|
||||
load = function (allTemplates) {
|
||||
var deferreds = [];
|
||||
|
||||
$.each(allTemplates, function (index, tpl) {
|
||||
deferreds.push(
|
||||
$.get("templates/" + tpl + ".html")
|
||||
.then(function (text) {
|
||||
if (ibuyproperties.isDebugMode) { console.log("Loading Template",tpl,ibuyproperties.isDebugMode); }
|
||||
templates[tpl] = Handlebars.compile(text);
|
||||
}, 'html').fail(function(result){
|
||||
console.error("Failed Loading Template",tpl,result);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return $.when.apply(null, deferreds);
|
||||
},
|
||||
|
||||
get = function (name) {
|
||||
if (templates[name]) {
|
||||
if (ibuyproperties.isDebugMode) { console.log("Requested template",name); }
|
||||
return templates[name];
|
||||
} else {
|
||||
console.error("Requested unknown template",name);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// The public API
|
||||
return {
|
||||
load: load,
|
||||
get: get
|
||||
};
|
||||
|
||||
}());
|
||||
26
js/templates.js
Normal file
26
js/templates.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/*globals ibuyproperties*/
|
||||
|
||||
ibuyproperties.templates=(function(){
|
||||
|
||||
var allTemplates={
|
||||
navigation:["nav"],
|
||||
mainPages:["Home","Sell"],
|
||||
misc:["impressum","about","debug"],
|
||||
partials:["sell_userInfo","sell_propInfo","sell_propAddress","sell_thanks","sell_sendError"]
|
||||
};
|
||||
|
||||
function getAll(){
|
||||
var outArr=[];
|
||||
|
||||
return outArr.concat(allTemplates.mainPages,allTemplates.navigation,allTemplates.misc,allTemplates.partials);
|
||||
}
|
||||
|
||||
function getType(type){
|
||||
return allTemplates[type];
|
||||
}
|
||||
|
||||
return {
|
||||
getAll:getAll,
|
||||
getType:getType
|
||||
};
|
||||
}());
|
||||
Reference in New Issue
Block a user