Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

Monday, 19 July 2010

Adding counter to sequential list using Jquery

In my design work ,I have to create sequential lists ,for example ,a list of blog comments ,lists of users ... adding counter to these lists will make it look better but sometime it's hard to do manually . I find out a solution from webdesignerwall.com ,using jquery to add numbers to the list .





Live Demo 
Here is detail instruction :
1,First,we need CSS code to decorating numbers 
/* number style */
#commentlist {
margin: 10px 0 40px;
padding: 0;
}
#commentlist li {
padding: 10px 0 20px;
list-style: none;
border-top: solid 1px #ccc;
position: relative;
}
#commentlist cite {
font: bold 140%/110% Arial, Helvetica, sans-serif;
color: #666;
}
#commentlist .time {
color: #ccc;
margin: 0 0 10px;
}
#commentlist .commentnumber {
position: absolute;
right: 0;
top: 8px;
font: normal 200%/100% Georgia, "Times New Roman", Times, serif;
color: #ccc;
2,Add this Jquery code anywhere in template or HTML file :
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){

  $("#commentlist li").each(function (i) {
    i = i+1;
    $(this).prepend('<span class="commentnumber"> #' i '</span>');
   });

});
</script>
This code will find all <li> elements covered under element which has  id="commentlist" , and insert <span class="commentnumber"> #' i '</span> into each <li>.......</li>
so we get the result after adding code:
here is original HTML code 
<ol id="commentlist">

    <li>
        ............
    </li>
    <li>
        ...................
    </li>
    <li>
        .................
    </li>
</ol>
and here is the code after adding numbers
<ol id="commentlist">

    <li>
<span class="commentnumber"> #1</span>
        ............
    </li>
    <li>
<span class="commentnumber"> #2</span>
        ...................
    </li>
    <li>
<span class="commentnumber"> #3</span>
        .................
    </li>
................
</ol>
That's all . Thanks for reading and I hope you find it useful

Wednesday, 14 April 2010

Nivo Slider - an awesome jquery slider with 9 unique transition effects

Inspired by Ronny Dee 's comment in my blog ,I want to introduce Nivo Slider jquery to you . It's an awesome Jquery plugin for slider with 9 unique transition effects ,and it look very professional like any Flash slide show .One of the most impressive slider I've seen .



you can see Live Demo here
 How about the effects? Cool? This plugin has been tested for most of popular browsers such as IE 7.0+ ,FireFox v3+ ,Chrome,Opera ,Safari ...so I don't think you will get trouble with browser when using this plugin .
Here is steps for install and use this plugin for your Blogger .

1, Download Nivoslider plugin from this site . Or you can download directly from this link .If you download this plugin from website ,you will see two version : production and development . Production is the version in which the code is encrypted for copyright protection . And the development is not encrypted . You can download both of them ,but development version is better .

2,Upload file nivo-slider.css and jquery.nivo.slider.js to a host . I recommend Google code for a speed and reliable hosting .

3,Create a HTML/Javascript widget in your Blogger blog .

4,Paste this code into widget content :
<link rel="stylesheet" href="your host .../nivo-slider.css" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="your host .../jquery.nivo.slider.pack.js" type="text/javascript"></script> 
The code above include Jquery framework and nivoslider plugin to your site .

5,Paste this code right after the code in step 3 :

<style>
#slider {
    position:relative;
    -moz-box-shadow:0px 0px 10px #333;
    -webkit-box-shadow:0px 0px 10px #333;
    box-shadow:0px 0px 10px #333;
}
#slider img {
    position:absolute;
    top:0px;
    left:0px;
}
#slider a {
    border:0;
}
.nivo-controlNav {
    position:absolute;
    left:47%;
    bottom:-30px;
}
.nivo-controlNav a {
    display:block;
    width:10px;
    height:10px;
    background:url(http://nivo.dev7studios.com/images/bullets.png) no-repeat;
    text-indent:-9999px;
    border:0;
    margin-right:3px;
    float:left;
}
.nivo-controlNav a.active {
    background-position:-10px 0;
}

.nivo-directionNav a {
    display:block;
    width:32px;
    height:34px;
    background:url(http://nivo.dev7studios.com/images/arrows.png) no-repeat;
    text-indent:-9999px;
    border:0;
}
a.nivo-nextNav {
    background-position:-32px 0;
    right:10px;
}
a.nivo-prevNav {
    left:10px;
}
</style>
This CSS code will add arrows and bullets icons for navigation in NivoSlider . It also stop flashing images before this plugin loads .

6,The code of slider content.Paste it after the code in step 5
<div id="slider">
    <img src="images/slide1.jpg" alt="" />
    <a href="http://simplexdesign.blogspot.com"><img src="images/slide2.jpg" alt="" /></a>
    <img src="images/slide3.jpg" alt="" title="This is an example of a caption" />
    <img src="images/slide4.jpg" alt="" />
...............
</div>
As you see ,in slider content ,you can add links and caption to images .Modify them and add more if you want .

7,Make this plugin work by adding an initial code :

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider();
});
</script>
The initial code above is a simple one . Nivo slider has many options ,and here is the initial code with full option (and description for each option )
<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'random',
        slices:15,
        animSpeed:500,
        pauseTime:3000,
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){} //Triggers after all slides have been shown
    });
});
</script>
each line is an option ,and you can add ,modify value or remove for adding or removing option . For example ,the line "keyboardNav:true, //Use left & right arrows" mean it allow using right-left arrow button on keyboard for slider navigation . If you don't allow using keyboard ,set the value to "false" . 

8,Save the widget and see what we have ^^


A note for you : Size of displaying slider depend on size of "#slider" element and images in slider . For example : to make a slider which has width : 700px , you have to set the width of slider element to 700px  ; like this
#slider {
width:700px;
}
and use images which have the width :700px for fullfill the slider element . If you use a smaller image ,you will see the slider with smaller size .
That's all . I hope you will find something interesting with this plugin .
Here is list of showcase for this plugin ,you can take a look for inspiration ^^




Supporters:
Check out Hosting Observer – your guide to finding more
reliable web hosting plans
online.

Wednesday, 17 March 2010

Expanding or Shrinking an area in website like Youtube

As an user Youtube is a great video sharing service .As a web developer ,Youtube like any web 2.0 service ,comes with many effects . One of them is changing the size of video are ,expanding or shrinking with a click .

when you click on "wide" button ,video area expand to a larger size ,sidebar goes down and content in video area stretch fully . When you click on 'normal' ,video area shrink to normal size and sidebar goes up .

Live Demo

In this post ,I want to introduce to you how we can make this trick . It's easy to do and won't take you a lot of time and effort .
This trick is related to a Jquery's API name ToggleClass ,which is a part of Jquery framework .ToggleClass can add or remove one or more classes from each element in the set of matched elements ,for example ,we get an element like this
<div class="tumble">Some text.</div>
if we apply this statement $('div.tumble').toggleClass('bounce') ,it mean : find all div elements which has class "tumble" and add one more class"bounce" to these div elements . And the result we get here
<div class="tumble bounce">Some text.</div>
But if we apply $('div.tumble').toggleClass('bounce') again ,the div element above return to "tumble" class only ,"bounce" is removed . So the result after second time is <div class="tumble">Some text.</div>
Base on what ToggleClass can do ,to expand or shrink an element , we can make an element with initial size for example 600px width .When user click on wide button ,we use ToggleClass to add a class "wide" to this element . The "wide" class will re-define width to 900px . And when user click on Normal button , we will apply ToggleClass again for removing "wide" class .The width of element back to 600px .

So ,we got the idea .Here is an example .
In this example ,we create a web page with five elements like this :
<div id="header"></div>
<div id="main">
    <div id="content"></div>
    <div id="sidebar"></div>
    <div id="comments"></div>
</div>
<div id="footer"></div>
Now ,the CSS
#header, #content, #comments, #sidebar, #footer { margin:10px 0px; padding:30px;}
#header { width:900px; margin:0px auto;}
#main {width:960px; margin:0px auto; overflow:hidden;}
#content { width:540px; float:left;}
#comments { width:540px; float:left;}
#sidebar { width:280px; margin-left:20px; float:right;}
#footer { width:900px; margin:0px auto;}

#content.wide { width:900px;}
float attribute of sidebar element must be right for it can goes up and down .If you set this attribute to left ,it may ruin your design .

In the website ,create a link for switch between expanding and collapsing mode . A link like this :
<a id="wideView" href="#">Change View</a>
Elements are ready ,to make it work ,we need to add a script :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#wideView").click(function() {
                $("#content").toggleClass("wide");
                $(this).toggleClass("wide");
            });
        });
    </script>
In the script above :
The first line : <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
for loading Jquery Framework so we can use jquery statements .
The following code :
$(document).ready(function() mean we only run this script when page are loaded fully .
$("#wideView").click(function() mean this function is only executed when user click on element which has id "wideView"
  $("#content").toggleClass("wide"); as I said on ToggleClass above ,this line will add a class 'wide' to element which has id="content" ,so re-define width of content from 540px to 900px
  $("#content").toggleClass("wide"); execute this line when user click element "wideView" again .This statement will remove the class 'wide' from element which id="content" ,so size of content element back to 540px;

Ok ,you are done .
Save webpage and see the result .
This trick can apply in websites and of course ,it work with Blogger . In this post ,I want to explain how it work to you and I hope you can apply it creatively ,unlike other posts, just show you a code and copy paste instruction .This can be used in video website like what youtube did ,or further ,changing web layout ...

Sunday, 14 March 2010

Displaying Twitter Followers as Text

Image representing Twitter as depicted in Crun...

You can show number of Twitter Followers using third-party services ,but in some cases ,showing a gadget from third-party service may break your web / blog design . So ,it's a time for us to look for a solution to display number of followers as text and ,of course ,we can format this number with CSS for blending with our design .
In this post ,I will show you how we can display the number of Twitter followers as text using Twitter api and a bit of Jquery .

Steps  for making this :
1,In Page elements ,create an HTML/Javascript widget  . As I said in many posts ,you can paste the code direct to template file but it's hard to find and remove when error. So it's better if we use a widget .
2,Paste this code to widget content :
<style>
        body { font-family: Arial, Helvetica, sans-serif; }
        a { color: #0066cc; text-decoration: none; }
        a:hover { text-decoration: underline; }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
       
        beforecounter = " [<b>";
        aftercounter = "</b>]";

        $.getJSON('http://api.twitter.com/1/users/show/YOUR_TWITTER_ACCOUNT.json?&callback=?',
            function(data) {
                $('#twitter').append(beforecounter + data.followers_count + aftercounter);
        });

    })
    </script>
<h2>Followers</h2>
<ul>
    <li><a href="http://twitter.com/" id="twitter">Twitter</a></li>
</ul>
in the code above ,please change "YOUR_TWITTER_ACCOUNT" to your account name .
the result of will be show in this line
<ul>
    <li><a href="http://twitter.com/" id="twitter">Twitter</a></li>
</ul> 

You can format this code by adding more CSS for displaying as you want . Adding a Twitter icon , make a round border for this element ... sound fun ,right :))
I hope this post helpful to you .

Wednesday, 10 March 2010

JonDesign's Smooth Gallery - An awesome Gallery in Mootool

I'm familiar with Jquery ,but I find out that Mootool also has some good plugins ,and their effect are very impress . JonDesign's Smooth Gallery (JdGallery) is one of them .It's not only a good slider and carousel for website but also a complete gallery .
In this post , I want to introduce this Mootool's plugin to you all .With this plugin ,you can set up a complete gallery without using Flash as before .
See it screenshot :






And see it in action in the live demo 
Images is organized in Categories ,name of categories are displayed in the top-right of the gallery .When you click on the name of a category ,it goes down and show you images contain in . You can browse and choose the image you want to show .Or you can do nothing and let images auto slide ...
Now ,I will show you how we can apply this script to our site or blogger to make a gallery :
1,Download this script here
2,Unzip and you will see 3 folders and some html file for demo .Name of 3 folders are : CSS,images and scripts .Upload all files in Script folder and file jd.gallery.css in CSS folder to a host . The best is Google code
3,You can insert the code bellow direct to Blogger template file ,but it's easier if you insert in a HTML/Javascript widget . I heard people complaint it's hard to find and edit in Blogger template file (xml format) so it will be easy if you just work with a widget .
So,Adding a HTML/Javascript widget and paste this code into widget content first :

<link rel="stylesheet" href="url..../jd.gallery.css" type="text/css" media="screen" charset="utf-8" />
        <script src="url.../mootools-1.2.1-core-yc.js" type="text/javascript"></script>
        <script src="url..../mootools-1.2-more.js" type="text/javascript"></script>
        <script src="url..../jd.gallery.js" type="text/javascript"></script>
<script src="url..../jd.gallery.set.js" type="text/javascript"></script>
<script src="url..../jd.gallery.transitions.js" type="text/javascript"></script>


Ok,those are basic javascript file for JdGallery plugins .Other files will be added for special function ,for example : image zoom ,or Forward/Back navigation ...
4,Adding images to gallery as structure bellow

<div id="myGallerySet">
  <div id="gallery1" class="galleryElement">
    <h2>Category 1</h2>
    <div class="imageElement">
      <h3>Item 1 Title</h3>
      <p>Item 1 Description</p>
      <a href="#" title="open image" class="open"></a>
      <img src="link to image 1" class="full" />
      <img src="link to image 1 in thumbnail" class="thumbnail" />
    </div>
    <div class="imageElement">
      <h3>Item 2 Title</h3>
      <p>Item 2 Description</p>
      <a href="#" title="open image" class="open"></a>
      <img src="link to image 2" class="full" />
      <img src="link to image 2 in thumbnail" class="thumbnail" />
    </div>
  </div>
  <div id="gallery1" class="galleryElement">
    <h2>Category 1</h2>
    <div class="imageElement">
      <h3>Item 1 Title</h3>
      <p>Item 1 Description</p>
      <a href="#" title="open image" class="open"></a>
      <img src="link to image 1" class="full" />
      <img src="link to image 1 in thumbnail" class="thumbnail" />
    </div>
    <div class="imageElement">
      <h3>Item 2 Title</h3>
      <p>Item 2 Description</p>
      <a href="#" title="open image" class="open"></a>
      <img src="link to image 2" class="full" />
      <img src="link to image 2 in thumbnail" class="thumbnail" />
    </div>
  </div>
......................... 

</div>

In the code above,each image is covered by the code :
<div class="imageElement">
      <h3>Item Title</h3>
      <p>Item Description</p>
      <a href="#" title="open image" class="open"></a>
      <img src="link to image" class="full" />
      <img src="link to image in thumbnail" class="thumbnail" />
    </div>
link to image and link to image in thumbnail can be the same if you don't want resize image to thumbnail .
Image elements above are covered in category as structure :
<div id="gallery" class="galleryElement">
    <h2>Category name</h2>
    <div class="imageElement">
     ......................
    </div>
    <div class="imageElement">
      ...................
    </div>

  </div>
And categories are covered in an element with id=myGalleryset as bellow :

<div id="myGallerySet">
  <div id="gallery1" class="galleryElement">
   
.....................
  </div>
  <div id="gallery2" class="galleryElement">
   ................
   </div>
......................... 

</div>
Very straight and easy . You can add more element for images and categories as you want like the structure I showed above .
6,To make it work ,we must add this code  at the end of widget content :

<script type="text/javascript">
function startGallery() {
var myGallerySet = new gallerySet($('myGallerySet'), {
timed: true
});
}
window.addEvent('domready', startGallery);
</script>
Save widget and see the result .
This post is very simple . I just want to introduce to you a Mootool's plugin and the basic to set-up a gallery . This plugin has many options and I can't write all here because it will be so long .If you want to know more ,you can see in this site
I hope you like it  !

Wednesday, 30 December 2009

The last collection of Jquery plugins in Simplex Design blog in 2009

jQuery has been one of the more popular JavaScript Framework . I love its structure and plugins ,very interesting for web designer for making interactive website . It's fast and easy to use .
jQuery released version 1.3 in January 2009 and more plugins have been appearing online as well.
Here is the last collection of jQuery plugins in 2009 that shown on my blog .Check it out my friend .
http://img.viralpatel.net/2009/05/jquery-thumb.jpg


Page Slide
This plugin allow web designer adding more content in space of web interface . One page is shown and one page is hidden . When click event is invoked , the slide is animated and the hidden page is shown .
I think it's the best for adding information for a page in  website .For example ,you have a text in one page and you can add some notes or explanations in the hidden page which only show when mouse click .
Page Slide
Lazyload
This plugin is very useful for long web pages . With this plugin ,all images which are out of viewport ( the view of browser window) will not be loaded until you scroll to them .So it make the page loading become faster .
Lazy Load
Rotateimage
I think it's a cool plugin .I've never use it ^^ But anyway ,it look good .
Rotate Image
Tokenizing Autocomplete
This plugin allows users to select multiple items from a predefined list, using auto-completion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on facebook.

Auto Complete

Markitup
It is a very lightweight, customizable and flexible editor engine made to meet the developer's needs in their content management system, blogs, forums or websites.
Markitup
Password Strength
This plugin shows the strength of you passwords by telling you how long time it would take to brute force them. Very popular in websites or forum registrations .
Password Strength
Before After
This plugin helps to show the difference between 2 images, that let user to drag a slider over the images, which were sandwiched with one on top of the other, so that you could easily see how dramatic the changes were.
I think it's very good for website on photoshop or anything like that .Showing the differences of picture before and after re-touching . A good application ,right?
Before After
Ajax Fancy Captcha jQuery Plugin
A new way captcha . Instead of completing textbox with the given words ,with this method,we drag and drop icons .
Ajax Fancy Captcha
Roundabout
This plugin helps you convert a structure of static HTML elements into a highly customizable turntable-like interactive area. And now, It's not just turntables, but many other shapes!
Round About


Merrkat
It can create a frame in your site for ads ,announcements ...like ifFrame ...but better
Meerkat


Text Resizer
This plugin attempts to solve one problem: that of resizing text on demand by the user, where the user is given the option to enlarge or decrease the size of the website’s text.
Text Resizer
Threedots
This plugin is used in many scenarios in the display of online text where shortened, truncated representations are best used.A kind of "readmore" in many blogs .
Three Dots
Live Preview
Great plugin I found . You can see its application in some website such as W3school.org



Endless Scroll
This plugin makes the page keeps loading with new items attached at the end, instead of paging through items using the traditional pagination technique.
Endless Scroll
jParallax
This is a proof of  what Jquery can do . You can take a look at this plugin and you will find out that it can replace Flash . Awesome !
jParallax



We are at the end of 2009 and now is the time for waiting better plugins which will be released in 2010 ! This list is the latest collection of jquery plugins in 2009 in Simplex Design blog ,I hope you enjoy it .

huy signature