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";
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));
16 function initializeLayout() {
18 apparea.resize = function(w,h) {
20 resizeItem(apparea,w,h);
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);
32 scriptcell.resize = function(w,h) {
33 if (matita.proofMode || matita.disambMode) {
34 resizeItem(scriptcell,(w*2)/3,h);
36 resizeItem(scriptcell,w,h);
40 sidearea.resize = function(w,h) {
41 disambcell.resize(w/3,h);
42 goalcell.resize(w/3,h);
43 resizeItem(sidearea,w/3,h);
47 disambcell.resizeAll = function() {
48 var w = int_of_px(this.parentElement.style.width);
49 var h = int_of_px(this.parentElement.style.height);
50 // resize only, no show/hide
52 if (matita.disambMode) {
53 disambcell.style.display = "inline-block";
55 disambcell.style.display = "none";
58 if (matita.proofMode) {
59 resizeItem(disambcell,w-4,(h/2)-4);
61 resizeItem(disambcell,w-4,h-4);
65 goalcell.resizeAll = function() {
66 var w = int_of_px(this.parentElement.style.width);
67 var h = int_of_px(this.parentElement.style.height);
68 // resize only, no show/hide
70 if (matita.proofMode) {
71 goalcell.style.display = "inline-block";
73 goalcell.style.display = "none";
76 if (matita.disambMode) {
77 resizeItem(goalcell,w-4,(h/2)-4);
79 resizeItem(goalcell,w-4,h-4);
84 $(window).bind("resize", resize);
92 // var htmlheight = int_of_px(window.getComputedStyle(body.parentNode,null).height);
93 // var htmlwidth = int_of_px(window.getComputedStyle(body.parentNode,null).width);
94 // apparea.resize(htmlwidth,htmlheight);
95 apparea.resize($(window).width(),$(window).height());
98 function resizeSide() {
99 disambcell.resizeAll();
100 goalcell.resizeAll();
103 function updateSide() {
104 if (matita.proofMode || matita.disambMode) {
105 matitaLayout.show("east");
109 matitaLayout.hide("east");
113 function updateDisamb() {
114 if (matita.disambMode) {
115 disambcell.style.display = "inline-block";
117 disambcell.style.display = "none";
121 function updateGoal() {
122 if (matita.proofMode) {
123 goalcell.style.display = "inline-block";
125 goalcell.style.display = "none";
129 function abortLog() {
130 matitaLayout.hide("south");
133 // a more beautiful procedure to scroll the script to the beginning of unlocked
134 // only when needed, and showing it at about one third of the height of the
136 function smartScroll() {
137 var element = $("#unlocked");
138 var container = element.parent().parent();
139 var containerTop = container.scrollTop();
140 var containerBottom = containerTop + container.height();
141 var elemTop = element.get(0).offsetTop;
142 if (elemTop < containerTop || elemTop > containerBottom) {
143 container.scrollTop(elemTop - container.height()/4);