Loading Accordion Live Demo...
Ext Accordion Widget Example, Ver.: 1.0.1 (1.1-beta2)
1. Introduction
The Accordion widget and its InfoPanel are components that can be used in the JavaScript enabled popular browsers: Firefox, Opera and Internet Explorer.
2. Ext JS Library
These components are not standalone but they require Ext JS Library to run. For more details see Ext JS - JavaScript Library. This library contains also many other useful components and provides a developer's framework.
3. Usage

The Accordion can be used anywhere in the web page mainly (but not only) for:

  • Page navigation
  • Tools windows
  • Hidable details
  • Login forms
  • Options dialogs
  • Sticky notes

... or anything else the talented web designers can invent and produce.

4. Drag & Drop

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.

5. Configuration options

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.

7. Theme selector
Select the theme you like:
8. Donate

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.

 

AddThis Social Bookmark Button

Introduction

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.

If you've already been here Ctrl+Click the browser's Reload/Refresh button.

When I update sources sometimes I have to hard-refresh several times!

Visit also Accordion Preview Page, there are nice new features there and Saki's Extensions, Plugins and Know-How page.

Changes from version 1.0 to 1.0.1

1. Namespace change

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.

2. Example directory change

To make upgrades of Ext JS easier I have removed the accordion from the Ext JS tree and I have put it to the separate directory accordion just under the server root. The new link to this example is now http://aariadne.com/accordion/accordion.html. Should you ever need version 1.0 you can find it at http://aariadne.com/accordion-1.0/accordion.html. If you navigate to the old link your browser will be redirected here.

3. Code changes

  • Fixed bug in InfoPanel that prevented grid to show.
  • New InfoPanel destroy method and destroy event
Software on this page is provided as is in the hope that it will be useful with no direct or implied warranty whatsoever. You can use it, modify it, copy it or do anything else with it. If you use it, I appreciate if you donate. Contact

How to start with Ext Accordion

Step by step instructions

The latest stable version of Accordion is 1.0.1

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:

1. Download and install Ext JS Library

For this, navigate to Download Ext JS Library page and download the Ext 1.0.1a or 1.1 Beta 1 version.

2. Install Ext JS Library on your server

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

3. Make this example working on your server (unchanged)

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")?>

4. Navigate to http://yourdomain.com/accordion/accordion.html

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!

 

How to integrate Ext Accordion to a page

1. Install the Ext JS - Javascript Library

1.1 Download and unzip Ext JS

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.

1.2 Add links to the head

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/.....".

1.3 Create file accordion.js

Create file 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

1.4 Include accordion.js

Add the following line just before the </body> tag:

<script type="text/javascript" src="accordion.js"></script>

1.5 Verify Ext installation

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.

2. Install Accordion files

2.1 Download and copy files

Download following files from this page and copy them to the accordion/ directory:

  • Ext.ux.InfoPanel.js
  • Ext.ux.Accordion.js
  • accordion.css

2.2 Add links to the head

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>

2.3 Add testing lines to the accordion.js

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

2.4 Verify the Accordion installation

Navigate your browser to http://yourdomain.com/accordion/yourpage.html. You should get alert with text "Accordion installed successfully".

3. Create Accordion with two panels

3.1 Write html markup

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>

3.2 Create Accordion

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

3.3 Verify the Accordion

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.

4. Congratulations!

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.

This example also shows how to use the wrapped Accordion. The html markup consists of three nested divisions each with its purpose.
<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.

Panel 2-1
Morbi eros nunc, adipiscing vitae, adipiscing quis, feugiat ac, erat. Pellentesque auctor, ligula quis commodo egestas, urna risus luctus ante, nec rutrum tortor ante eget erat. Donec venenatis elit sed justo.
Panel 2-2
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce pellentesque. Duis fermentum metus nec nisl. Suspendisse potenti. Vivamus id nibh ut neque sollicitudin ullamcorper. Vivamus quis augue.
Panel 2-3
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce pellentesque. Duis fermentum metus nec nisl. Suspendisse potenti. Vivamus id nibh ut neque sollicitudin ullamcorper. Vivamus quis augue.
Panel 2-4
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce pellentesque. Duis fermentum metus nec nisl. Suspendisse potenti. Vivamus id nibh ut neque sollicitudin ullamcorper. Vivamus quis augue.
Panel 2-5
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce pellentesque. Duis fermentum metus nec nisl. Suspendisse potenti. Vivamus id nibh ut neque sollicitudin ullamcorper. Vivamus quis augue.

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.

These are independent panels placed in the plain div. They are neither draggable nor resizable and there is no Accordion used here.
1. Panel - expanded by default
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce pellentesque. Duis fermentum metus nec nisl. Suspendisse potenti. Vivamus id nibh ut neque sollicitudin ullamcorper. Vivamus quis augue. Nulla quis ante ut nunc scelerisque interdum. Phasellus sit amet eros. Aenean sodales nulla vel sem. Quisque posuere.
2. Panel - animation disabled
Nam venenatis nonummy quam. Integer semper. Ut eget dolor sed nunc ornare egestas. Donec eget quam eget ipsum semper tincidunt. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec sodales velit ac dolor. Fusce et odio in massa ultricies vehicula. Donec dui. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
3. Panel - only button expands
Ut placerat. Aenean quis erat. Suspendisse pede turpis, cursus at, dignissim eget, vulputate nec, turpis. Nunc ut nibh consectetuer nunc accumsan consequat. Quisque id purus. Mauris a lacus placerat libero dictum eleifend. Aenean sit amet pede vitae lectus egestas convallis. Phasellus vel quam vitae leo lobortis aliquet. Etiam imperdiet augue in orci. Aliquam vitae risus et lorem rutrum tincidunt. Ut ut dolor ac nisi eleifend pretium. Cras feugiat, erat a ornare vulputate, nisi ligula consequat odio, at lacinia nisl eros in libero. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla velit mauris, tempor nec, viverra porttitor, vestibulum posuere, tortor. Pellentesque facilisis. Vestibulum rutrum velit at lectus. Praesent leo.
5. Title and body from markup

Panel created from html markup

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
});

7. Auto-created, body from markup

 

Markup:

<div id="ipanel-7-body">
<div class="text-content">
	<h3>7. Auto-created...</h3>
<p>&nbsp;</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
});
Advertise on this site

 

You are visitor number 1523838 since 25 Jul 10.