Ajax Updates

Ajax Updates


SerialScroll with Jquery

Posted: 28 Aug 2009 08:45 AM PDT

This plugin allows you to easily animate any series of elements, by sequentially scrolling them. It uses jQuery.ScrollTo to achieve the scrolling animation. It is a very unrestricted plugin, that lets you customize pretty much everything from outside. You can use horizontal or vertical scroll, also combined.

What’s it for ?

jQuery.SerialScroll doesn’t have one definite purpose. It’s generic and adaptable. You can certainly use it as a screen slider. That is, to sequentially navigate a group of screens.
This plugin can also animate a text scroller in no time.
It can definitely handle slideshows, the high customizability of the scrolling effect lets you create beautiful animations.
You can even build an automatic news ticker!
Three of these uses are exemplified in the demo.
Remember, it’s not restricted to these situations. It will take care of any collection of html elements that you want to scroll consecutively.

Settings and customization

jQuery.SerialScroll gives you access to a lot of options.
These are:


  • target
    The element to scroll, it’s relative to the matched element.
    If you don’t specify this option, the scrolled element is the one you called serialScroll on.

  • event
    on which event to react (click by default).

  • start
    first element of the series (zero-based index, 0 by default).

  • step
    how many elements to scroll each time. Use a negative number to go on the other way.

  • lock
    if true(default), the plugin will ignore events if already animating. Then animations can’t be queued.

  • cycle
    if true, the first element will be shown after going over the last, and the other way around.

  • stop
    if true, the plugin will stop any previous animations of the element, to avoid queuing.

  • force
    if true, an initial scroll will be forced on start.

  • jump
    if true, the specified event can be triggered on the items, and the container will scroll to them.

  • items
    selector to the items(relative to the scrolled element).

  • prev
    (optional)selector to the ‘previous’ button.

  • next
    (optional)selector to the ‘next’ button.

  • lazy
    if true, the items are collected each time, allowing dynamic content(AJAX, AHAH, jQuery manipulation, etc).

  • interval
    If you specify a number, the plugin will add auto scrolling with that interval.

  • constant
    Should the speed remain constant, no matter how many items we scroll at once ? (true by default).

  • navigation
    Optionally, a selector to a group of elements, that allow scrolling to specific elements by index. Can be less than the amount of items.

  • excludenew
    If you want the plugin, to stop scrolling before the actual last element, set this to a number, and that amount of items is ignored counting from the end.
    This is useful if you show many items simultaneously, in that case, you probably want to set this option to the amount of visible items – 1.

  • onBefore
    A function to be called before each scrolling. It receives the following arguments: event object, targeted element, element to be scrolled, collection of items and position of the targeted element in the collection.
    The scope(this) will point to the element that got the event. If the function returns false, the event is ignored.
Also, you can use jQuery.ScrollTo’s settings!
The option ‘target’
This option is a new addition, included since 1.2.0.
Before, you needed to call the plugin once for each scrolled element.
When this option is specified, the matched elements are no longer the scrolled elements, but a container.
In this case, the selectors of prev, next, navigation and target will be relative to this container, allowing you to call SerialScroll on many elements at once.

External manipulation, event triggering

jQuery.SerialScroll automatically binds 3 events to the containers.
These are:


  • prev.serialScroll
    Scrolls to the previous element.

  • next.serialScroll
    Scrolls to the next element.

  • goto.serialScroll
    Scrolls to the specified index, starts with 0.

  • start.serialScroll
    (Re)starts autoscrolling.

  • stop.serialScroll
    Stops the autoscrolling.

  • notify.serialScroll
    Updates the active item.
This looks confusing, but it’s not. You use it like this:
 Javascript |  copy code |? 
01
$(container).trigger( 'prev' ); 
02
 
03
$(container).trigger( 'next' ); 
04
 
05
$(container).trigger( 'goto', [ 3 ] ); 
06
 
07
$(container).trigger( 'start' ); 
08
 
09
$(container).trigger( 'stop' ); 
10
 
11
$(container).trigger( 'notify', [ 4 ] );

Demo: http://demos.flesler.com/jquery/scrollTo/
Download:http://flesler-plugins.googlecode.com/files/jquery.serialScroll-1.2.2.zip
Source: http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
tafbutton blue16 SerialScroll with Jquery

Related Listings:

  1. jQuery.LocalScroll This plugin will animate a regular anchor navigation [1] [2].It...
  2. jCarouselLite Plugin for JQuery jCarousel Lite is a jQuery plugin that carries you...
  3. jScroller jQuery Plugin This Autoscroller is Crossbrowser compatible and also w3c compatible, because...

Tabbed Searchbar

Posted: 28 Aug 2009 08:00 AM PDT

Some lines of JavaScript code can help you to add nice effects to improve some features of your websites.

This tutorial explains how to implement a simple tabbed search bar using CSS and a javascript function which set “active” the selected tab and changes the value of an hidden element to set search options and execute your search only for all items related to the selected topic (for example: web, images, videos…).
searchbar Tabbed Searchbar

HTML code for tabs
I used a < ul > list with < li > element to implement tabs
 HTML |  copy code |? 
1
<ul class="search-options"> 
2
<li id="tab1" class="selected"><a href="#" onclick="javascript:setSearchOptions(1);">Web</a></li> 
3
<li id="tab2"><a href="#" onclick="javascript:setSearchOptions(2);">Images</a></li> 
4
<li id="tab3"><a href="#" onclick="javascript:setSearchOptions(3);">Videos</a></li> 
5
</ul>
You can add other tabs simply adding new
  • elements using a progressive number for ID attribute (tab4, tab5, teab6...). Each tab call a javascript function setSearchOption() which set "active" the selected tab and set the value of the following hidden field to enable search options:

     HTML |  copy code |? 
    1
    <input type="hidden" name="searchopt" id="searchopt" />

    When you submit the form (using PHP or another server side language), if is set the post variable related to this hidden field ($_POST['searchop'] for example) and this variable is equal to some value (an integer or a string), then you can execute a query instead of another one. For example if you select image tab, your query will execute the search only for images.

    Javascript setSearchOptions() function
    This is the function which set the active tab and change the value of the hidden input element:

     Javascript |  copy code |? 
    01
    function setSearchOptions(idElement){ 
    02
    /* Total Tabs above the input field (in this case there are 3 tabs: web, images, videos) */ 
    03
    tot_tab = 3; 
    04
    tab = document.getElementById('tab'+idElement); 
    05
    search_option = document.getElementById('searchopt'); 
    06
    for(i=1; i< =3; i++){ 
    07
    if(i==idElement){ 
    08
    /*set class for active tab */ 
    09
    tab.setAttribute("class","selected"); 
    10
    /*set value for the hidden input element */ 
    11
    search_option.value = idElement; 
    12
    } else { 
    13
    /*unset class for non active tabs */ 
    14
    document.getElementById('tab'+i).setAttribute("class",""); 
    15
    } 
    16
    } 
    17
    } 
    18


    Demo: http://woork.bravehost.com/searchbar.html
    Download: http://www.box.net/shared/p9plmj70os
    Source: http://woork.blogspot.com/2008/01/tabbed-search-bar-using-css-and.html
  • tafbutton blue16 Tabbed Searchbar

    Related Listings:

    1. Tabbed search bar using CSS and Javascript This tutorial explains how to implement a simple tabbed search...
    2. jQuery Tabbed Interface Script Nowadays, a lot of websites are using tab based content...
    3. Control.Tabs Script Control.Tabs attaches creates a tabbed interface from an unordered list...

    Digg Like Css Vertical menu

    Posted: 28 Aug 2009 07:33 AM PDT

    Do you like Digg.com webdesign? I like much its menu, simple and clean.

    This tutorial explains how to implement a simple vertical menu digg-like using CSS and javascript to show/hide sub-menu. The result is like this:
    menu1 Digg Like Css Vertical menu
    menu2 Digg Like Css Vertical menu
    Step 1: HTML code
    HTML structure is very simple and contains two
      tags (menu and sub-menu):
      structure Digg Like Css Vertical menu

      Copy and paste the following code in a new html page:

       HTML |  copy code |? 
      1
      <div id="middlebar"> 
      2
      <ul class="menu"> 
      3
      <li><a href="#" onclick="javascript:showlayer('sm_1')"> Profile</a></li> 
      4
      </ul><ul class="submenu" id="sm_1"> 
      5
      <li><a href="p1.html">Profile</a></li> 
      6
      <li><a href="p2.hmtl">Inbox </a></li> 
      7
      <li><a href="p3.hmtl">Log-out</a></li> 
      8
      </ul> 
      9
      </div>


    Step 2: CSS code
    Copy and paste this code to define menu button:

     CSS |  copy code |? 
    01
    ul, li{margin:0; border:0; padding:0; list-style:none;} 
    02
    #middlebar{ 
    03
    font-size:11px; 
    04
    color:#3b5d14; 
    05
    background:#90b557; 
    06
    font-weight:bold; 
    07
    padding:4px; 
    08
    height:30px; 
    09
    } 
    10
    #middlebar .menu li { 
    11
    background:url(lm.png) left top no-repeat; 
    12
    height:30px; 
    13
    float:left; 
    14
    margin-right:10px; 
    15
    } 
    16
    #middlebar .menu li a{ 
    17
    color:#3b5d14; 
    18
    text-decoration:none; 
    19
    padding:0 10px; 
    20
    height:30px; 
    21
    line-height:30px; 
    22
    display:block; 
    23
    float:left; 
    24
    padding:0 26px 0 10px; 
    25
    background:url(rm.png) right top no-repeat; 
    26
    } 
    27
    #middlebar .menu li a:hover{ 
    28
    color:#666666; 
    29
    } 
    30

    and this is the code for the sub-menu:

     CSS |  copy code |? 
    01
    #middlebar ul .submenu { 
    02
    border:solid 1px #c9dea1; 
    03
    border-top:none; 
    04
    background:#FFFFFF; 
    05
    position:relative; 
    06
    top:4px; 
    07
    width:150px; 
    08
    padding:6px 0; 
    09
    clear:both; 
    10
    z-index:2; 
    11
    display:none; 
    12
    } 
    13
    #middlebar ul .submenu li{ 
    14
    background:none; 
    15
    display:block; 
    16
    float:none; 
    17
    margin:0 6px; 
    18
    border:0; 
    19
    height:auto; 
    20
    line-height:normal; 
    21
    border-top:solid 1px #DEDEDE; 
    22
    } 
    23
    #middlebar .submenu li a{ 
    24
    background:none; 
    25
    display:block; 
    26
    float:none; 
    27
    padding:6px 6px; 
    28
    margin:0; 
    29
    border:0; 
    30
    height:auto; 
    31
    color:#105cbe; 
    32
    line-height:normal; 
    33
    } 
    34
    #middlebar .submenu li a:hover{ 
    35
    background:#e3edef; 
    36
    }


    Step 3: Javascript to show/hide submenu
    Now, add this simple Javascript code to show/hide the sub-menu when an user clicks on a link contained into the menu.

     Javascript |  copy code |? 
    1
    function showlayer(layer){ 
    2
    var myLayer = document.getElementById(layer); 
    3
    if(myLayer.style.display=="none" || myLayer.style.display==""){ 
    4
    myLayer.style.display="block"; 
    5
    } else { 
    6
    myLayer.style.display="none"; 
    7
    } 
    8
    }

    This function get in input the parameter layer (the ID of sub-menu you want hide/display), in this case sm_1, passed from this link:

     HTML |  copy code |? 
    1
    <li><a href="#" onclick="javascript:showlayer('sm_1')"> Profile</a></li>

    Save all and try it!


    Demo: http://digg.com
    Download: http://www.box.net/shared/tkyq60ukgo
    Source: http://woork.blogspot.com/2008/01/simple-css-vertical-menu-digg-like.html
    tafbutton blue16 Digg Like Css Vertical menu

    Related Listings:

    1. Simple CSS vertical menu Step 1: HTML codeHTML structure is very simple and contains...
    2. Digg Like Menus Using CSS Navigation bar with rounded corners an sliding doors technique for...
    3. Flickr Like Horizontal Menu Script Do you like Flickr and its simple and clean interface?This...

    0 comments:

    Post a Comment

    Note: Only a member of this blog may post a comment.