Mar 28, 2011

jQuery Google Charting easy charting plugin

The Google Chart functionality can easily be added to a division with appropriate default settings. Google Chart generates a chart as an image in response to a HTTP request with parameters defining the content and appearance. This plugin hides all of that behind a JavaScript interface.

Usage:

1. Include the jQuery library in the head section of your page.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
2. Download and include the jQuery Google Charting JavaScript in the head section of your page.
<script type="text/javascript" src="jquery.gchart.js"></script>
3. Alternately, you can use the packed version jquery.gchart.pack.js (18.1K vs 62.0K), or the minified version jquery.gchart.min.js (22.4K, 7.6K when zipped).
Connect the Google charting functionality to your divisions.
$(selector).gchart({series: [$.gchart.series([20, 50, 30])]});


VIEW DEMO
DOWNLOAD

Mar 13, 2011

Simplest Accordion jquery independent of your HTML

Sample HTML That you can write (optional you can write your own):
Just follow the structure.

<div class="prod_cat"><span class="icon">Surgical</span>
<ul class="cat_list">
<li>Jaconet Sheeting</li>
<li>Shishumat</li>
<li>Shishu Suvidha</li>
<li>Elastic Sheets</li>
<li>Impression & Anti Static</li>
<li>SheetsVishranti - P.S.P. Waterbed</li>
</ul>
</div>
<div class="prod_cat"><span class="icon">Commercial</span>
<ul class="cat_list">
<li>Jaconet Sheeting</li>
<li>Shishumat</li>
<li>Shishu Suvidha</li>
<li>Elastic Sheets</li>
<li>Impression & Anti Static</li>
<li>SheetsVishranti - P.S.P. Waterbed</li>
</ul>
</div>
<div class="prod_cat"><span class="icon">Technical Fabrics and Rubber Sheets</span>
<ul class="cat_list">
<li>Jaconet Sheeting</li>
<li>Shishumat</li>
<li>Shishu Suvidha</li>
<li>Elastic Sheets</li>
<li>Impression & Anti Static</li>
<li>SheetsVishranti - P.S.P. Waterbed</li>
</ul>
</div>

JQuery You need to Write in your <head> Section:

<script type="text/javascript">
$(document).ready(function() { 
  $('.prod_cat').click(function() {
    if($(this).children('ul.cat_list').is(":visible"))
{
$('ul.cat_list').slideUp('fast');
}
else
{
$('ul.cat_list').slideUp('fast');
$(this).children('ul.cat_list').slideDown('fast');
}
  });
});
</script>


Well you can always change the classes and call the custom selectors from JS.

Mar 10, 2011

Structural Tags in HTML5

The HTML5 specification has added quite a few interesting and useful tags for structuring your markup. For a majority of everyday uses, these tags will replace many of our typical div entries from our code. So let's dig in.

Defining Structure
<section>
A section is a thematic grouping of content, typically preceded by header, possibly with a footer after. sections can be nested inside of each other, if needed, and can hold any amount of typical markup.

<header>
The header of a section, typically a headline or grouping of headlines, but may also contain supplemental information about the section.


<footer>
A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.


<nav>
Defines the navigation area, typically a list of links. The nav should be a sibling of the main section, header, and footer.


<article>
An independent entry in a blog, magazine, compendium, and so on.


<aside>
An aside indicates content that is tangentially related to the content around it.


Pull it together.

<!DOCTYPE html>
<html>
  <head>
    <title>Standard Blog</title>
  </head>
  <body>
    <header>
      <h1><a href="#">Standard Blog</a></h1>
    </header>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Archives</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
    <section>
      <article>
        <header>
          <h1><a href="#">Title</a></h1>
        </header>
        <section>
          <p>Lorem ipsum...</p>
        </section>
      </article>
      <article>
        <header>
          <h1><a href="#">Title</a></h1>
        </header>
        <section>
          <p>Lorem ipsum...</p>
        </section>
      </article>
      <article>
        <header>
          <h1><a href="#">Title</a></h1>
        </header>
        <section>
          <p>Lorem ipsum...</p>
        </section>
      </article>
    </section>
    <footer>
      <p>Copyright © 2008 All Rights</p>
    </footer>
  </body>
</html>



Note: This example is a little verbose in markup for the simplicity of the content, but I wanted to exaggerate for emphasis.

As you can see, the tags themselves are much more descriptive than simply providing an id attribute to a div. This also gives the added benefit of a descriptive closing tag, as </article> is much more understandable that wondering which <div id="something"> goes with a given </div>.

So, I can use this now?

Actually, yes, with a few extra steps. And it will work in all modern browsers. It can even work in IE6. There are only a few little quirks we need to get past if we’re going to start using this today.

First, because most browsers don’t understand the new HTML5 doctype, they don’t know about these new tags in HTML5. Fortunately, due to the flexibility of browsers, they deal well with unknown tags. The only issue here is unknown tags have no default style, and are treated as inline tags. These new HTML5 tags are structural, and should obviously be block level elements. So, when we style them with CSS, we need to be sure to include display:block; in our attribute/value pairs.

Include this simple extra piece of CSS, and these new tags are immediately usable. Starting today. And of course, once HTML5 is more widely supported, the superfluous display:block; can be removed, as it will be included in the browser default styles.

Supporting IE

There is one more issue if you require IE support. Turns out that the IE rendering engine will work with the new tags, but will not recognize any CSS applied to them. Well, that’s no good. Fortunately, IE just needs a good swift kick with the help of a very simple bit of JavaScript. All we need to do to kick start IE is to create a DOM node with JavaScript for each of the new tags, and suddenly IE will apply styles to the new tags with no problem. The code will look something like this, and can be placed directly in the head of our document, or the contents of the script tag placed into an external file and included.


<script>
  document.createElement('header');
  document.createElement('footer');
  document.createElement('section');
  document.createElement('aside');
  document.createElement('nav');
  document.createElement('article');
</script>


Before we leave this code, there’s one thing to mention about the script tag in HTML5. HTML5 will assumetype="text/javascript" on any script element, so it need not be included. Once again, making things simple.


Structuring page with HTML 5 and CSS3

1.HTML5
HTML 5 is the next major version of HTML. It introduces a bunch of new elements that will make our pages more semantic. This will make it a lot easier for search engines and screenreaders to navigate our pages, and improve the web experience for everyone. In addition, HTML 5 will also include fancy APIs for drawing graphics on screen, storing data offline, dragging and dropping, and a lot more. Let’s get started marking up the blog page.


2.BASIC STRUCTURE

In HTML 5 there are specific tags meant for marking up the header, navigation, sidebar and footer. First, take a look at the markup and I’ll explain afterwards:
  1. <!doctype html>  
  2. <html>  
  3. <head>  
  4.     <title>Page title</title>  
  5. </head>  
  6. <body>  
  7.     <header>  
  8.         <h1>Page title</h1>  
  9.     </header>  
  10.     <nav>  
  11.         <!-- Navigation -->  
  12.     </nav>  
  13.     <section id="intro">  
  14.         <!-- Introduction -->  
  15.     </section>  
  16.     <section>  
  17.         <!-- Main content area -->  
  18.     </section>  
  19.     <aside>  
  20.         <!-- Sidebar -->  
  21.     </aside>  
  22.     <footer>  
  23.         <!-- Footer -->  
  24.     </footer>  
  25.   
  26. </body>  
  27. </html>  
It still looks like HTML markup, but there are a few things to note:
  • In HTML 5, there is only one doctype. It is declared in the beginning of the page by <!doctype html>. It simply tells the browser that it’s dealing with an HTML-document.
  • The new tag header is wrapped around introductory elements, such as the page title or a logo. It could also contain a table of contents or a search form. Every header typically contains a heading tag from <h1> to <h6>. In this case the header is used to introduce the whole page, but we’ll use it to introduce a section of the page a little later.
  • The nav-tag is used to contain navigational elements, such as the main navigation on a site or more specialized navigation like next/previous-links.
  • The section-tag is used to denote a section in the document. It can contain all kinds of markup and multiple sections can be nested inside each other.
  • aside is used to wrap around content related to the main content of the page that could still stand on it’s own and make sense. In this case we’re using it for the sidebar.
  • The footer-tag should contain additional information about the main content, such as info about who wrote it, copyright information, links to related documents and so on.
Instead of using divs to contain different sections of the page we are now using appropriate, semantic tags. They will make it a lot easier for search engines and screen readers to figure out what’s what in a page.

3.NAVIGATION
  1. <nav>  
  2.     <ul>  
  3.         <li><a href="#">Blog</a></li>  
  4.         <li><a href="#">About</a></li>  
  5.         <li><a href="#">Archives</a></li>  
  6.         <li><a href="#">Contact</a></li>  
  7.         <li class="subscribe"><a href="#">Subscribe via. RSS</a></li>  
  8.     </ul>  
  9. </nav>  


4.INTRODUCTION
  1. <section id="intro">  
  2.     <header>  
  3.         <h2>Do you love flowers as much as we do?</h2>  
  4.     </header>  
  5.     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>  
  6. </section>  
5.STYLING
  1. /* Makeshift CSS Reset */  
  2.  
  3.     margin: 0;  
  4.     padding: 0;  
  5. }  
  6.   
  7. /* Tell the browser to render HTML 5 elements as block */  
  8. header, footer, aside, nav, article {  
  9.     displayblock;  
  10.  
  11.   
  12. body {  
  13.     margin: 0 auto 
  14.     width940px;  
  15.     font13px/22px HelveticaArialsans-serif 
  16.     background#f0f0f0;  
  17. }  
  18.   
  19. h2 {  
  20.     font-size28px;  
  21.     line-height44px;  
  22.     padding22px 0;  
  23. }  
  24.   
  25. h3 {  
  26.     font-size18px;  
  27.     line-height22px;  
  28.     padding11px 0;  
  29. }  
  30.   
  31. p {  
  32.     padding-bottom22px 
  33. }  
6.STYLING NAVIGATION
  1. nav {  
  2.     positionabsolute;  
  3.     left: 0;  
  4.     width: 100%;  
  5.     backgroundurl("nav_background");  
  6. }  
  1. nav ul {  
  2.     margin: 0 auto;  
  3.     width940px;  
  4.     list-stylenone;  
  5. }  
  1. nav ul li {  
  2.     floatleft;  
  3. }  
  4.   
  5.     nav ul li a {  
  6.         displayblock;  
  7.         margin-right20px;  
  8.         width140px;  
  9.         font-size14px;  
  10.         line-height44px;  
  11.         text-aligncenter;  
  12.         text-decorationnone;  
  13.         color#777;  
  14.     }  
  15.   
  16.         nav ul li a:hover {  
  17.             color#fff;  
  18.         }  
  19.   
  20.         nav ul li.selected a {  
  21.             color#fff;  
  22.         }  
  23.   
  24.         nav ul li.subscribe a {  
  25.             margin-left22px;  
  26.             padding-left33px;  
  27.             text-alignleft;  
  28.             backgroundurl("rss.png"left center no-repeat;  
  29.         }  

7.STYLING INTRODUCTION

  1. #intro {  
  2.     margin-top66px;  
  3.     padding44px;  
  4.     background#467612 url("intro_background.png"repeat-x;  
  5.     background-size: 100%;  
  6.     border-radius: 22px;  
  7. }  
  1. #intro {  
  2.     ...  
  3.     /* Background-size not implemented yet */  
  4.     -webkit-background-size: 100%;  
  5.     -o-background-size: 100%;  
  6.     -khtml-background-size: 100%;  
  7.   
  8.     /* Border-radius not implemented yet */  
  9.     -moz-border-radius: 22px;  
  10.     -webkit-border-radius: 22px;  
  11. }  
  1. #intro h2, #intro p¬†{  
  2.     width336px;  
  3. }  
  4.   
  5. #intro h2 {  
  6.     padding: 0 0 22px 0;  
  7.     font-weightnormal  
  8.     color#fff;  
  9. }  
  10.   
  11. #intro p {  
  12.     padding: 0;  
  13.     color#d9f499;  
  14. }  
  1. #intro {  
  2.     ...  
  3.     background#467612 url("intro_background.png"top left (287px 100%) repeat-x,  
  4.             url("intro_flower.png"top rightright (653px 100%) no-repeat;  
  5.     ...  
  6. }  

Test post after a long time

i want to see the post