The Accordion can be used anywhere in the web page mainly (but not only) for:
... or anything else the talented web designers can invent and produce.
All panels are draggable and once undocked also resizable by default. You can try it by dragging a panel out of the Accordion dock. If you do not want this feature you can turn it off.
You can drag undocked panels back to the Accordion dock.
There are many configuration options to customize look and functionality for your needs, e.g. shadows, show pin, animation, various modes (undockable, independent) to name a few.
You can switch on/off some of them in the above toolbar.
Panels and dock can also keep their states (size, position, expanded, etc.) between page reloads.
I have developed the Accordion because I needed it for my main project and not for profit. Only then I decided to share it with the community.
However, the developing and maintaining of this component takes time and effort so if you find it useful please donate to make future development possible.
This page is about the InfoPanel and Accordion javascript classes and its purpose is to allow the potential users to get the feel-and-touch of the user interface they provide. It contains also step by step instructions on how to integrate the Accordion to a web page.
The Ext JS is the javascript library and it is used as a foundation for InfoPanel, Accordion and this example to work. For more information see Ext JS - JavaScript Library
These classes and example are discussed in details in this Ext JS Forum thread.
The version 1.0 class names were Ext.InfoPanel and Ext.Accordion what was directly under the root name of the Ext JS Library: Ext. This might cause name conflicts in the future. After discussion with author of Ext JS Library Jack Slocum I have decided to put them in the separate name space Ext.ux. ux was recommended by Jack and stands for user extensions.
New names of classes are now Ext.ux.InfoPanel and Ext.ux.Accordion and new file names are Ext.ux.InfoPanel.js and Ext.ux.Accordion.js.
Users upgrading from version 1.0 will have to change include links in the heads of pages to read:
<script type="text/javascript" src="Ext.ux.InfoPanel.js"></script> <script type="text/javascript" src="Ext.ux.Accordion.js"></script>
However, they do not need to rewrite the code of their applications but they can add next lines at the beginning of their code as there is no namespace conflict yet:
Ext.InfoPanel = Ext.ux.InfoPanel; Ext.Accordion = Ext.ux.Accordion; Ext.AccordionStateManager = Ext.ux.AccordionStateManager;
These lines are not required for new users who have not written their applications yet.
This howto is for those of you who would like to use the Accordion in their page. I'll write it as for beginners; I believe the old Ext-ers will forgive me if I'll stress the basics here. And you, eager beginners, be prepared to explore the new worlds of web design you maybe haven't even dreamed could exist.
Here we go:
For this, navigate to Download Ext JS Library page and download the Ext 1.0.1a or 1.1 Beta 1 version.
To do this step navigate to Introduction to Ext and execute steps you find there up to the "Congratulations!" message box. I would strongly advice to read this tutorial fully but, for the impatient, it's enough to know that Ext is installed correctly in this step.
Install Ext to extjs/ directory under your server root directory
For this, download the following files:
Place Accordion files into accordion/ directory and icons files in an any directory under your server root directory. Then edit accordion.js file and set variable iconPath to the directory where you have installed icons. Do not forget trailing slash.
Remove please the line from the bottom of the html page as it is only for statistical purposes and it has nothing to do with InfoPanel/Accordion. Remove this line:
<?@require("stats.php")?>
That's all folks!
Now it's time to put the Accordion to your page taking this running example as a model. You can also see this Ext JS Forum thread to see the discussion on the Accordion and to find out the outstanding issues/bugs and/or future plans.
Last but not least: If you find this component useful, donate please to make the future development of the Accordion possible. The amount is up to you. Thank you.
Happy coding!
Download the Ext JS library and unzip it somewhere
under the directory of your server root. I will assume that Ext JS is under
the extjs/ directory in this howto.
Locate the <head> section of your page and add the following links into it:
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css"> <link rel="stylesheet" type="text/css" href="./accordion.css"> <script type="text/javascript" src="../extjs/adapter/yui/yui-utilities.js"></script> <script type="text/javascript" src="../extjs/adapter/yui/ext-yui-adapter.js"></script> <script type="text/javascript" src="../extjs/ext-all.js"></script>
Note: In this howto, I will assume that your page is one directory under
your server root (let it be accordion/ here.) If your page is somewhere
else you need to adjust relative paths above. For example, if your page is directly
under the server root then replace two dots above with one dot. If it is deeper than one
directory then your links should read: src="../../../extjs/.....".
accordion.js in the accordion/ directory. The content
of file should be:
// Ext Accordion Application
Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';
Ext.onReady(function() {
alert("Ext installed successfully");
});
// end of file
Add the following line just before the </body> tag:
<script type="text/javascript" src="accordion.js"></script>
Navigate your browser to http://yourdomain.com/accordion/yourpage.html.
You should get alert with text "Ext installed successfully". If you don't the most
probable reason is that paths in the above links are wrong especially if you installed
Ext in a different directory. Adjust links and try again. If that doesn't help then
follow instruction in Introduction to Ext.
Download following files from this page and copy them to the accordion/
directory:
Add the following lines just before the </head> tag:
<link rel="stylesheet" type="text/css" href="accordion.css"> <script type="text/javascript" src="Ext.ux.InfoPanel.js"></script> <script type="text/javascript" src="Ext.ux.Accordion.js"></script>
Adjust the accordion.js file to read the following:
// Ext Accordion Application
Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';
Ext.onReady(function() {
var a = new Ext.ux.Accordion({autoCreate:true});
var p = new Ext.ux.InfoPanel({autoCreate:true});
if(a && p) {
alert("Accordion installed successfully");
}
});
// end of file
Navigate your browser to http://yourdomain.com/accordion/yourpage.html.
You should get alert with text "Accordion installed successfully".
Locate a place in your page where you want to put the Accordion and write there the following HTML markup:
<div id="acc-ct" style="width:200px;height:300px">
<div id="panel-1">
<div>My first panel</div>
<div>
<div class="text-content">My first panel content</div>
</div>
</div>
<div id="panel-2">
<div>My second panel</div>
<div>
<div class="text-content">My second panel content</div>
</div>
</div>
</div>
Adjust the accordion.js file to read the following:
// Ext Accordion Application
Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';
Ext.onReady(function() {
// create accordion
var acc = new Ext.ux.Accordion('acc-ct', {
fitHeight: true
})
// create panel 1
var panel1 = acc.add(new Ext.ux.InfoPanel('panel-1', {
}));
// create panel 2
var panel2 = acc.add(new Ext.ux.InfoPanel('panel-2', {
}));
});
// end of file
Navigate your browser to your page. You should see your first Accordion with two panels and you should be able to expand/collapse the panels.
Now that you have your Accordion with two panels it's good time to add there your content, add more panels, add icons to panel titles, and so on. Accordion and InfoPanel have many configuration options so it's worth to study them as then you can adjust Accordion and Panels to your liking.
Just to help beginners here is the HTML markup with no content but Accordion and
accordion.js file that I used while writing this tutorial to check
that I'was writing true.
HTML markup:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ext Accordion Howto</title>
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="./accordion.css">
<script type="text/javascript" src="../extjs/adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="../extjs/adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="../extjs/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="accordion.css">
<script type="text/javascript" src="Ext.ux.InfoPanel.js"></script>
<script type="text/javascript" src="Ext.ux.Accordion.js"></script>
</head>
<body>
<div id="acc-ct" style="width:200px;height:300px;border:1px solid silver">
<div id="panel-1">
<div>My first panel</div>
<div>
<div class="text-content">My first panel content</div>
</div>
</div>
<div id="panel-2">
<div>My second panel</div>
<div>
<div class="text-content">My second panel content</div>
</div>
</div>
</div>
<script type="text/javascript" src="accordion.js"></script>
</body>
</html>
accordion.js:
// Ext Accordion Application
Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';
Ext.onReady(function() {
// create accordion
var acc = new Ext.ux.Accordion('acc-ct', {
fitHeight: true
})
// create panel 1
var panel1 = acc.add(new Ext.ux.InfoPanel('panel-1', {
}));
// create panel 2
var panel2 = acc.add(new Ext.ux.InfoPanel('panel-2', {
}));
});
// end of file
Contact: If you want to contact me the best way is on the Ext JS Forums or via the Forum Private Messaging.
This is the example of the fixed height Accordion. Panels undocked from this Accordion are local to the tab "Accordions"; they hide when you change the tab. Left-hand panels are global to the page; they stay visible when you change the tab.
The Accordion is resizable down and right.
<div id="acc2-ct"> <div id="acc2-wrap"> <div id="acc2-body"> </div> </div> </div>
acc2-ct is outermost container div that should have size and it is the div which is resized. Its id is used in new Ext.ux.Accordion('acc2-ct', {...});
acc2-wrap is div that will be wrapped with nice surrounding. This div should have a border if you want one and its id is passed as wrapEl:'acc2-wrap' to the Accordion configuration.
acc2-body should not have any border nor margin and it is passed as body:'acc2-body' to the Accordion configuration. Panels are direct children of this division.
This page shows independent panels, panels without an Accordion, and various methods of panel creation. The creation method of each panel is explained in its body. Panel that comes last in the DOM is always the topmost panel. Show panel with grid.
Markup:
<div>5. Panel</div> <div> <div class="text-content"> This text. </div> </div>
Code:
new Ext.ux.InfoPanel('ipanel-5', {
useShadow: true
, draggable: true
, duration: 1.0
});
Markup:
<div id="ipanel-7-body"> <div class="text-content"> <h3>7. Auto-created...</h3> <p> </p> <p>Markup:</p> ... </div> </div>
Code:
new Ext.ux.InfoPanel({
title: '7. Auto-created...'
, id: 'ipanel-7'
, desktop: 'panels-tab'
, bodyEl: 'ipanel-7-body'
, autoCreate: true
, draggable: true
, useShadow: true
, resizable: true
});
You are visitor number 10667 since 19 Jul 08.