Commit 321ea28f authored by Téo Vasseur's avatar Téo Vasseur

js : views array, selectedView var, setView(), .selectView(), setMenuOptions(), setOverlays()

parent aa84ec18
var views = [];
var selectedView;
function View(id, parentId, classes) {
this.parentId = parentId;
this.id = id;
views.push(this);
var parent = document.getElementById(parentId);
......@@ -9,7 +13,7 @@ function View(id, parentId, classes) {
node.textContent = id;
this.node = node;
// parent.appendChild(view);
// parent.appendChild(node);
}
function Flex(id, parentId) {
......@@ -24,13 +28,55 @@ function Solid2(id, parentId) {
View.call(this, id, parentId, "solid2");
}
function setViews(dic) {
for (var panId in dic) {
var panel = document.getElementById(panId);
for (var i in dic[panId]) panel.appendChild(dic[panId][i].node);
function setView(view, parentId) {
document.getElementById(parentId).appendChild(view.node);
}
function selectView(view) {
var f = function () {
$(".overlay").show();
selectedView = view;
}
return f;
}
function setMenuOptions() {
var menu = document.getElementById("menu");
var div;
for (var i in views) {
div = document.createElement('div');
div.textContent = views[i].id;
// div.onclick = viewSetter(views[i], 'A');
div.onclick = selectView(views[i]);
menu.appendChild(div);
}
}
function setOverlays() {
div = document.createElement('div');
div.className = "overlay";
div.onclick = function () {
$(".overlay").hide();
setView(selectedView, 'A');
}
document.getElementById('A').appendChild(div);
div = div.cloneNode();
div.onclick = function () {
$(".overlay").hide();
setView(selectedView, 'B');
}
document.getElementById('B').appendChild(div);
div = div.cloneNode();
div.onclick = function () {
$(".overlay").hide();
setView(selectedView, 'C');
}
document.getElementById('C').appendChild(div);
}
function main() {
var v1 = new Flex("v1", 'A');
......@@ -41,12 +87,8 @@ function main() {
var v5 = new Solid1("v5", 'A');
var v6 = new Solid2("v6", 'B');
setViews({
"A" : [v1, v5],
"B" : [v3, v6],
"C" : [v4]
})
setMenuOptions();
setOverlays();
}
main();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment