You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 01-12-2013 19:24:18

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

[RESOLVED] Bug with margin-left of content after using sidebars

Problem mentioned in this topic is comming back sad.

If different sidebars has different width calculated in inc/sidebar.php and/or (both are true) if in one of them full_height=true and in the other full_height=false problem with setting propper #content margin-left occures.

To see problem:
1. go to this page,
2. then click Gallery at the top,
3. open any tile from this group.
It looks even worse if you enter one of galleries neutral.

Problem is in inc/sidebar.php but I have problem with solving this problem neutral.

There is a way to bypass it by:
-setting pos to left,
-size to 0,
-full_height to false,
-and adding as many <br>'s as required in the beginning of subpage
but it shouldn't be like that.

In this file there is a code for declared sidebars and here is my current code of inc/sidebar.php.

Any idea how to solve this problem?

PS. There is one more bug. If on subpage there is sidepanel which openes subpanel where there is another sidepanel min-height of sidebar in sidepanel is set wrong - value that is set is the height of sidepanel on subpage and not the height of sidebar in sidepanel. Problem is in file inc/sidebar.php line 96

$('#contentWrapper, .sidebar').css("min-height",sbDown+20+"px");

). I repaired this problem by adding in line 87 .children('.sidebar-<?php echo $name;?>'). This change is not mentioned in file above.

Last edited by chrismaliszewski (02-12-2013 21:56:26)

Offline

#2 01-12-2013 20:09:12

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: [RESOLVED] Bug with margin-left of content after using sidebars

Ok... In my case I solved the problem for now.
Problem was in line

$("#content").css("margin-left",$(".sidebar").css("width"));

in inc/sidebar.php.
If full_height=true then width equals 100% and this value is set as #content margin-left.

I changed this line to:

margin_left = $(".sidebar").css("width");
if(margin_left == "100%")	{
	margin_left = 0;
}
$("#content").css("margin-left",margin-left);

and it worked.

I left previous version of my website so you still can search for other errors and solutions with sidebars. Tomorrow I'll put current version on server.

Last edited by chrismaliszewski (01-12-2013 20:14:33)

Offline

#3 01-12-2013 20:18:29

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: [RESOLVED] Bug with margin-left of content after using sidebars

Below I place a code mentioned in PS in first post of this topic which solves the problem of wrong min-height:

/* Fix height of sidebar for layout */
sbDown = 0;
$("#content, #panelContent").children('.sidebar-<?php echo $name;?>').children(".tile").each(function(){	
	if(typeof $(this).attr("href") != "undefined"){
		$(this).attr("href",$(this).attr("href").replace("?p=","#!/"));
	}	
	var thisDown= parseInt($(this).css("margin-top"))+$(this).height();
	if(thisDown>sbDown){
		sbDown=thisDown;
	}	
});
$('#contentWrapper, .sidebar-<?php echo $name;?>').css("min-height",sbDown+20+"px");

There is small BUT to this code. This code after opening subpanel changes min-height of #contentWrapper in subpage to min-height of subpanel! I'll try to find a way to bypass this issue, but it's still better than wrong margin of text in subpanel with sidebar IMO.

Last edited by chrismaliszewski (01-12-2013 20:21:30)

Offline

#4 02-12-2013 21:56:02

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: [RESOLVED] Bug with margin-left of content after using sidebars

Ok... Found solution.

It requires small changes in js/main.js by adding additional code at the beginning of success function so it'll look like:

$.ajax("pages/"+url+(typeof $hashed.get[1] != "undefined" ? "?"+$hashed.get[1] : "")).success(function(newContent,textStatus){	
//adding class to content, class name tells which page is currently opened
$("#contentWrapper").removeClass().addClass(url.slice(0,-4));
$content.removeClass().addClass(url.slice(0, -4));
...(rest stays as it is)

and in inc/sidebar.php in lines between /* Fix height of sidebar for layout */ and /* Responsive sidebar position */, by replacing them with code below:

sbDown = 0;
$("#content, #panelContent").children('.sidebar-<?php echo $name;?>').children(".tile").each(function(){
if(typeof $(this).attr("href") != "undefined"){
	$(this).attr("href",$(this).attr("href").replace("?p=","#!/"));
}	
var thisDown= parseInt($(this).css("margin-top"))+$(this).height();
if(thisDown>sbDown){
	sbDown=thisDown;
});
$('#contentWrapper, .<?php echo $name;?>').css("min-height",sbDown+20+"px");
$('#panel, .sidebar-<?php echo $name;?>').css("min-height",sbDown+20+"px");

After those changes everything works for me - I mean min-height for subpage and for panel are correct, see results here by opening 3. tile on the left side.

I think this code should work with 2 panels working at the same time on single page.

Hope it'll help someone with same problems as I had.

Offline

Board footer

Powered by FluxBB