]> matita.cs.unibo.it Git - helm.git/blob - matitaB/matita/html/layout.js
Matitaweb:
[helm.git] / matitaB / matita / html / layout.js
1 function resizeItem(item,w,h){  
2   item.style.height = h + "px";
3 //  item.style.minHeight = h + "px";
4 //  item.style.maxHeight = h + "px";
5   item.style.width = w + "px";
6 //  item.style.minWidth = w + "px";
7 //  item.style.maxWidth = w + "px";
8 }
9
10 function int_of_px(px) {
11   if(px.length > 2 && px.substr(px.length-2) == "px") {
12     return parseInt(px.substr(0,px.length-2));
13   } else { return px; }
14 }
15
16 function initializeLayout() {
17
18         apparea.resize = function(w,h) {
19                 workarea.resize(w,h);
20                 resizeItem(apparea,w,h);
21         }
22
23         workarea.resize = function(w,h) {
24                 // proper height = window - (title + top)
25                 var myh = int_of_px(window.getComputedStyle(apparea,null).height) - 
26                         (titlebar.offsetHeight + toparea.offsetHeight);
27                 scriptcell.resize(w,myh);
28                 sidearea.resize(w,myh);
29                 resizeItem(workarea,w,myh);
30         }
31
32         scriptcell.resize = function(w,h) {
33                 if (matita.proofMode || matita.disambMode) {
34                         resizeItem(scriptcell,(w*2)/3,h);
35                 } else {
36                         resizeItem(scriptcell,w,h);
37                 }
38         }
39         
40         sidearea.resize = function(w,h) {
41                 disambcell.resize(w/3,h);
42                 goalcell.resize(w/3,h);
43                 resizeItem(sidearea,w/3,h);
44         }
45
46         disambcell.resize = function(w,h) {
47                 if (matita.proofMode) {
48                         resizeItem(disambcell,w,h/2);
49                 } else {
50                         resizeItem(disambcell,w,h);
51                 }
52         }
53
54         goalcell.resize = function(w,h) {
55                 if (matita.disambMode) {
56                         resizeItem(goalcell,w,h/2);
57                 } else {
58                         resizeItem(goalcell,w,h);
59                 }
60         }
61
62         $(window).bind("resize", resize);
63
64         // resize();
65
66 }
67
68 function resize() {
69         // var htmlheight = int_of_px(window.getComputedStyle(body.parentNode,null).height);  
70         // var htmlwidth = int_of_px(window.getComputedStyle(body.parentNode,null).width);
71         // apparea.resize(htmlwidth,htmlheight);
72         apparea.resize($(window).width(),$(window).height());
73 }
74
75 function updateSide() {
76         scriptcell.resize(workarea.clientWidth,workarea.clientHeight);
77         sidearea.resize(workarea.clientWidth,workarea.clientHeight);
78         updateDisamb();
79         updateGoal();
80         if (matita.proofMode || matita.disambMode) {
81                 sidearea.style.display = "inline-block";
82         } else {
83                 sidearea.style.display = "none";
84         }
85 }
86
87 function updateDisamb() {
88         if (matita.disambMode) {
89                 disambcell.style.display = "inline-block";
90         } else {
91                 disambcell.style.display = "none";
92         }
93 }
94
95 function updateGoal() {
96         if (matita.proofMode) {
97                 goalcell.style.display = "inline-block";
98         } else {
99                 goalcell.style.display = "none";
100         }
101 }