Commit d14ca296 authored by Romain Loth's avatar Romain Loth

Add a setting for the width of the sidecolumn + simplify resize handler...

Add a setting for the width of the sidecolumn + simplify resize handler sigmaLimits() (remove jquery, simplify visible height tests)
parent 05a5cf1c
...@@ -23,10 +23,7 @@ ...@@ -23,10 +23,7 @@
margin-bottom:1px; margin-bottom:1px;
} }
#defaultop{ #defaultop{ }
min-height: 5%;
max-height: 10%;
}
#sigma-example { #sigma-example {
width: 100%; width: 100%;
......
...@@ -23,12 +23,13 @@ box-shadow: 0px 0px 3px 0px #888888; ...@@ -23,12 +23,13 @@ box-shadow: 0px 0px 3px 0px #888888;
#leftcolumn { #leftcolumn {
overflow-y: scroll; overflow-y: scroll;
margin-right: -300px;
margin-left: 0px;
padding-bottom: 10px; padding-bottom: 10px;
padding-left: 5px; padding-left: 5px;
right: 300px; right: 0px;
width: 300px; /* this width one is just a first guess...
/* (it will be changed in main.js to sidecolumnSize param)
*/
width: 25em;
position: fixed; position: fixed;
height: 100%; height: 100%;
border: 1px #888888 solid; border: 1px #888888 solid;
......
...@@ -32,6 +32,9 @@ var mainfile = ["db.json"]; ...@@ -32,6 +32,9 @@ var mainfile = ["db.json"];
var tagcloud_limit = 50; var tagcloud_limit = 50;
// for the css of leftcolumn and canvasLimits size
var sidecolumnSize = "24em"
var current_url = window.location.origin+window.location.pathname+window.location.search var current_url = window.location.origin+window.location.pathname+window.location.search
getUrlParam.file = current_url.replace(/projects/g, "api/projects") getUrlParam.file = current_url.replace(/projects/g, "api/projects")
......
...@@ -22,45 +22,27 @@ ...@@ -22,45 +22,27 @@
/[$\w]+/g /[$\w]+/g
); );
$.fn.visibleHeight = function() { // on window resize
console.log('FUN t.TinawebJS:visibleHeight') // @param canvasdiv: id of the div (without '#')
var elBottom, elTop, scrollBot, scrollTop, visibleBottom, visibleTop; function sigmaLimits( canvasdiv ) {
scrollTop = $(window).scrollTop(); console.log('FUN t.TinawebJS:sigmaLimits') ;
scrollBot = scrollTop + $(window).height(); var canvas = document.getElementById(canvasdiv) ;
elTop = this.offset().top; var sidecolumn = document.getElementById('leftcolumn') ;
elBottom = elTop + this.outerHeight(); var ancho_total = window.innerWidth - sidecolumn.offsetWidth ;
visibleTop = elTop < scrollTop ? scrollTop : elTop; var alto_total = window.innerHeight - sidecolumn.offsetTop ;
visibleBottom = elBottom > scrollBot ? scrollBot : elBottom;
return visibleBottom - visibleTop // setting new size
} canvas.style.width = ancho_total - 5 ;
canvas.style.height = alto_total - 5 ;
// for new SigmaUtils
function sigmaLimits( sigmacanvas ) { // fyi result
console.log('FUN t.TinawebJS:sigmaLimits') var pw=canvas.offsetWidth;
pw=$( sigmacanvas ).width(); var ph=canvas.offsetHeight;
ph=$( sigmacanvas ).height();
// $("body").css("padding-top",0) console.log("new canvas! w:"+pw+" , h:"+ph) ;
// var footer = ( $("footer").length>0) ? ($('#leftcolumn').position().top -$("footer").height()) : $('#leftcolumn').position().top*2;
var ancho_total = $( window ).width() - $('#leftcolumn').width() ;
var alto_total = $('#leftcolumn').visibleHeight() ;
// console.log("")
// console.log(footer)
// console.log(ancho_total)
// console.log(alto_total)
// console.log("")
sidebar=$('#leftcolumn').width();
anchototal=$('#dafixedtop').width();
$( sigmacanvas ).width(ancho_total);
$( sigmacanvas ).height( alto_total );
pw=$( sigmacanvas ).width();
ph=$( sigmacanvas ).height();
return "new canvas! w:"+pw+" , h:"+ph;
} }
SelectionEngine = function() { SelectionEngine = function() {
console.log('FUN t.TinawebJS:SelectionEngine:new') console.log('FUN t.TinawebJS:SelectionEngine:new')
// Selection Engine!! finally... // Selection Engine!! finally...
...@@ -381,6 +363,8 @@ SelectionEngine = function() { ...@@ -381,6 +363,8 @@ SelectionEngine = function() {
TinaWebJS = function ( sigmacanvas ) { TinaWebJS = function ( sigmacanvas ) {
console.log('FUN t.TinawebJS:TinaWebJS:new') console.log('FUN t.TinawebJS:TinaWebJS:new')
// '#canvasid'
this.sigmacanvas = sigmacanvas; this.sigmacanvas = sigmacanvas;
this.init = function () { this.init = function () {
...@@ -392,11 +376,11 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -392,11 +376,11 @@ TinaWebJS = function ( sigmacanvas ) {
return this.sigmacanvas; return this.sigmacanvas;
} }
this.AdjustSigmaCanvas = function ( sigmacanvas ) { this.AdjustSigmaCanvas = function ( canvasdiv ) {
console.log('FUN t.TinawebJS:AdjustSigmaCanvas') console.log('FUN t.TinawebJS:AdjustSigmaCanvas')
var canvasdiv = ""; if (! canvasdiv)
if( sigmacanvas ) canvasdiv = sigmacanvas; // '#canvasid' => 'canvasid'
else canvasdiv = this.sigmacanvas; canvasdiv = sigmacanvas.substring(1);
return sigmaLimits( canvasdiv ); return sigmaLimits( canvasdiv );
} }
......
...@@ -178,7 +178,7 @@ function MainFunction( RES ) { ...@@ -178,7 +178,7 @@ function MainFunction( RES ) {
// [ Initiating Sigma-Canvas ] // [ Initiating Sigma-Canvas ]
var twjs_ = new TinaWebJS('#sigma-example'); var twjs_ = new TinaWebJS('#sigma-example');
print( twjs_.AdjustSigmaCanvas() ); print( twjs_.AdjustSigmaCanvas() );
$( window ).resize(function() { print(twjs_.AdjustSigmaCanvas()) }); window.onresize = function(){twjs_.AdjustSigmaCanvas()} // TODO: debounce?
// [ / Initiating Sigma-Canvas ] // [ / Initiating Sigma-Canvas ]
print("categories: "+categories) print("categories: "+categories)
...@@ -357,6 +357,9 @@ function MainFunction( RES ) { ...@@ -357,6 +357,9 @@ function MainFunction( RES ) {
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
}, fa2seconds*1000); }, fa2seconds*1000);
// apply width from settings on left column
document.getElementById('leftcolumn').style.width = sidecolumnSize ;
} }
......
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