JEMA API
by hansenmc
HTML
<div id="header">
<h1>Header goes here</h1>
</div>
<div class="colmask leftmenu">
<div class="colleft">
<div class="main">
<p>Select a model on the left</p>
</div>
<div class="nav">
</div>
</div>
</div>
<div id="footer">
Footer content goes here
</div>
CSS
body {
margin:0;
padding:0;
border:0; /* This removes the border around the viewport in old versions of IE */
width:100%;
background:#fff;
min-width:600px; /* Minimum width of layout - remove line if not required */
/* The min-width property does not work in old versions of Internet Explorer */
font-size:90%;
}
a {
color:#369;
}
a:hover {
color:#fff;
background:#369;
text-decoration:none;
}
h1, h2, h3 {
margin:.8em 0 .2em 0;
padding:0;
}
p {
margin:.4em 0 .8em 0;
padding:0;
}
img {
margin:10px 0 5px;
}
#ads img {
display:block;
padding-top:10px;
}
/* Header styles */
#header {
clear:both;
float:left;
width:100%;
}
#header {
border-bottom:1px solid #000;
}
#header p,
#header h1,
#header h2 {
padding:.4em 15px 0 15px;
margin:0;
}
#header ul {
clear:left;
float:left;
width:100%;
list-style:none;
margin:10px 0 0 0;
padding:0;
}
#header ul li {
display:inline;
list-style:none;
margin:0;
padding:0;
}
#header ul li a {
display:block;
float:left;
margin:0 0 0 1px;
padding:3px 10px;
text-align:center;
background:#eee;
color:#000;
text-decoration:none;
position:relative;
left:15px;
line-height:1.3em;
}
#header ul li a:hover {
background:#369;
color:#fff;
}
#header ul li a.active,
#header ul li a.active:hover {
color:#fff;
background:#000;
font-weight:bold;
}
#header ul li a span {
display:block;
}
/* 'widths' sub menu */
#layoutdims {
clear:both;
background:#eee;
border-top:4px solid #000;
margin:0;
padding:6px 15px !important;
text-align:right;
}
/* column container */
.colmask {
position:relative; /* This fixes the IE7 overflow hidden bug */
clear:both;
float:left;
width:100%; /* width of whole page */
overflow:hidden; /* This chops off any overhanging divs */
}
/* common column settings */
.colright,
.colmid,
.colleft {
float:left;
width:100%;
position:relative;
}
.nav,
.main,
.col3 {
float:left;
position:relative;
padding:0 0 1em 0;
overflow:hidden;
}
/* 2 Column (left menu) settings...
JavaScript
var log = function(msg) {
$('#log').append('<li>' + msg + '</li>');
};
var JEMA = (function (window, document, $, JEMA) {
JEMA.init = function( models ) {
JEMA.models.init(models);
var modelSearch = '<div><form><input type="text"></form></div>';
var modelList = '<ul>';
$.each(JEMA.models, function(index, model) {
modelList += '<li><a href="#">' + model.name + '</a></li>';
});
modelList += '</ul>';
$('.nav').append(modelSearch + modelList);
$('.nav').find('li').click(function(event){
event.preventDefault();
var listIndex = $(this).index();
var model = JEMA.models[listIndex];
log("You clicked on model "+model.name + ' : ' + model.desc);
});
};
return JEMA;
})(window, document, jQuery, JEMA || {});
//============================================================
// JavaScript Module code (that could go into a separate JS file)
//============================================================
JEMA.jobs = (function (window, document, $, JEMA) {
var jobCount = 0;
var jobs = [];
jobs.getTotalJobsCreated = function(){
return jobCount;
};
jobs.createJob = function(model) {
jobCount+=1;
jobs.push({ id:Date.now(), model: model });
};
return jobs;
})(window, document, jQuery, JEMA || {});
//------------------------------------------------------------
//============================================================
// Models module
//============================================================
JEMA.models = (function (window, document, $, JEMA) {
var models = JEMA.models = JEMA.models || [];
function Model(modelArgs){
this.id='';
this.name='';
this.desc='';
for (var name in arguments[0]) { this[name] = arguments[0][name]; }
}
var modelCount = models.length;
models.init = function(modelsConfig){
models.clear();
//Put the default...