This is a plugin for JQUery, which will helps you to arrange the layout of a web page with ease. It is very easy to use and configure.
Features of this plugin are:
A common design layout for a web application will be like this
* Right section may not be there sometimes.
This is a general design layout, so every time when create an application similar to this you may have to write the same CSS and JavaScript again and again or more. If you haven’t written the script and CSS without thinking about extensibility in mind, then in future modifying width/height of a section will be very difficult.
To make this designing very easily, here I have used the DOCK concept, this will be familiar to those who works in Windows form based application, where every control will have Dock property (TOP, LEFT, FILL, RIGHT, BOTTOM and NONE). So the controls position and size is decided by the Dock property relative to the parent container.
This is basic building block for the layout.
Consider, you have an HTML file like this…
<html> <head> </head> <body> <div id="main"> <div id="top">Top</div> <div id="left">Left</div> <div id="fill">Fill</div> <div id="right">Right</div> <div id="bottom">Bottom</div> </div> </body> </html>
And you want change this plain HTML into a layout like below
(Background colors are added for visibility)
To do this, first you have to create a JSON object similar to this
var layoutSettings =
{
Name : "Main",
Dock : $.layoutEngine.DOCK.FILL,
EleID : "main",
Children: [
{
Name : "Top",
Dock : $.layoutEngine.DOCK.TOP,
EleID : "top",
Height : 125
},
{
Name : "Left",
Dock : $.layoutEngine.DOCK.LEFT,
EleID : "left",
Width : 300
},
{
Name : "Fill",
Dock : $.layoutEngine.DOCK.FILL,
EleID : "fill"
},
{
Name : "Right",
Dock : $.layoutEngine.DOCK.RIGHT,
EleID : "right",
Width : 200
},
{
Name : "Bottom",
Dock : $.layoutEngine.DOCK.BOTTOM,
EleID : "bottom",
Height : 125
}
]
};
This represents a DockableItem object, a DockableItem object has properties like
Properties except Dock are self explanatory, so I will explain more about the Dock property.
Dock property can have six different values;
$.layoutEngine.DOCK.FILL – In this mode the element will occupy entire area available in the parent container. So even if you specify the Height and Width, it is ignored.
$.layoutEngine.DOCK.TOP – In the mode the element will occupy the entire width available in the parent container and it is aligned to top; but you have explicitly specify the Height in this case.
$.layoutEngine.DOCK.LEFT – In this mode the element will occupy the entire height available in the parent container and the element will aligned to left side of the container; here you need to explicitly specify the Width.
$.layoutEngine.DOCK.RIGHT – In this mode the element will occupy the entire height available in the parent container and the element will align to right side of the container; here you need to explicitly specify the Width.
$.layoutEngine.DOCK.BOTTOM – In the mode the element will occupy the entire width available in the parent container and it is aligned to bottom; but you have explicitly specify the Height in this case.
$.layoutEngine.DOCK.NONE- Kept it for future version.
$(document).ready(function(){
var layoutSettings =
{
........... ...........
};
$.layoutEngine(layoutSettings);
});
View the HTML source of these pages to get more idea about creating the Dockable Item object.
Please feel free to ask questions and doubts, I am happy to help you out.