Sunday, May 30, 2010

8 Amazing JavaScript Image Zoom Scripts

When you are building an e-commerce website, especially a showcase, a website gallery, a template selling website…, you always need many good images for using and giving your visitors/customers the detailed view of your images (or your product). These are my top 10 javascript image scripts you need to consider.

1. JQZoom

Jqzoom

JQZoom is a javascript image magnifier built at the top of the popular jQuery javascript framework.jQzoom is a great and a really easy to use script to magnify what you want. JQZoom works well in IE6+, firefox2+, google chrome, safari2+ and opera9+.

2. Nivozoom

2

Nivo zoom is an jQuery plugin that works like a lightbox plugin. The plugin has 5 different zoom types and only weighs 4kb, the plugin operated well in Internet Explorer7+, Firefox3+, Google Chrome and Safari.

3. Cloud Zoom

3
Cloud Zoom is a jQuery plugin comparable to commercial image zoom products such as Magic Zoom. Compared to the popular jQZoom plugin, Cloud Zoom is smaller, has more features and more robust compatability across browsers.

4. Image Power Zoomer

4
Some images are worth a closer look, which is why there’s Image Power Zoomer. It gives any image on your page the ability to be magnified when the mouse rolls over it. A “magnifying glass” that appears over the image lets the user zoom in on any portion of it as it follows the cursor around. Furthermore, the magnification power can be adjusted on the fly by turning the mouse wheel back or forth.

5. AnythingZoomer jQuery Plugin

5
You have a small area. You mouse over it. An area pops up giving you a zoomed in closer look. This is a AnythingZoomer jQuery Plugin that does it. I’m not going to tell you what you should use it for or elaborate use-case scenarios. Your own creativity can help you there.

6. MojoZoom

6
MojoZoom lets you see a zoomed portion of the image by moving the mouse over it, but this one puts the zoomed area in a separate box. You can either let the script create the zoom box for you (with default size and placement) or you can specify any element which will then serve as the zoom “window”.

7. Tjpzoom

7
Tjpzoom is an image magnifier. It’s a completely rewritten version of my script tjpzoom, but still is in JavaScript / DOM :). If you move your mouse over the picture, you can see a little zoom window with a magnified version of a part of the picture in it.

8. Magic Zoom

8
Magic Zoom is a JavaScript zoom tool. It’s the best way to display images in incredible detail and it’s a commercial JavaScript tool. You can see the very good demo at: http://www.magictoolbox.com

read more...

Saturday, May 29, 2010

10 jquery Menu To Stylize Your Website

jQuery Popup Menu – Stylish jQuery Drop Down Menu

Create beautiful drop down menus with visual effects!

Features:
* Unlimited menu levels
* Smooth transitions
* Works in IE 6 , 7, 8, Firefox, Safari, Opera and Chrome
* XHTML compatible
* Simple and clean interface
* Graceful degradation
* Fully accessible even when javascript is turned off, as a pure css menu
* Customizable through css


1

Demo

jQuery Multi Level Menu – Unlimited Levels FX CSS Menu

100% CSS Menu with visual effect powered by jQuery. Javascript is used for effects only. Full cross-browser compatibility including IE6. Effects: smooth fade animation on mouse over and unfold submenu appearance. Easy-to-setup: simple nested unordered list for menu items with unlimited levels. jquery


2

Demo

Accordion Menu script (v1.7.1)

Creating an Accordion Menu is trivial using Accordion Content script. It basically just comes down to styling your headers and expanding content to conform to that desired menu look. The following are Accordion Menu examples with full source code to get you started:


3

Demo

Animated jQuery Menu – Corporate Style

Multilevel jQuery Menu with fade and smooth drop-down animation on submenu appearance.


4

Demo

Animated Outline Menu

A drop down menu with a sleek “outline” animation added when it drops down, applicable to any anchor link. The menu can be set to appear either via a “click” or “mouseover” of the anchor link.

Structure wise, each animated outline menu is simply defined as regular list menus on the page, and supports an optional height setting that causes that menu to be scrollable (useful for very tall menus with lots of links). Nifty! This script is powered by the versatile jQuery library.


5

Demo

AutoAnchors

This plugin automatically creates an anchors navigation for certain elements (for example H2) inside a container element (div, body whatever …). It automatically generates the anchors and can even make them numbered. And the whole thing is of course fully styleable through CSS.

You can put more than one anchor navigation on the same page, just make sure that if you invoke them asecond time with different options, that the link titles should be different or it can result in two anchors named the same.


6

Demo

Sinlge Level Drop Down Menu

A simple single level drop down menu with a timed function that holds the menu open for specified amount of time on mouseouts.


7

Demo | Download

Jquery hypermenu

Inspired by Google Chrome bookmarks menu bar, this plugin can be used to group a long list of hyperlinks.

The menu can be made draggable and positioned either relatively or absolutly within a document, and different configuration options allow to customize the plug in as required.


8

Demo | Download

jQuery LavaLamp Menu

LavaLamp is a plugin based on previous plugins for mootools and jQuery 1.1.x respectively. Using the Sliding Doors CSS / Javascript technique, LavaLamp allows you to add a nice background hover effect to HTML link lists using the Easing library.


9

Demo | Download

mbScrollingMenu: menu with automatic scroller

mbScrollingMenu change an HTML list to a menu with automatic scroller using mouse position.

Now, create big menus, timelines or long image lists without scroll bar.


10


Demo | Download

via : blog.galaxark.com

read more...

jQuery tips & tricks: how to limit characters inside a textarea

r57rxfiq

You might have come across a problem trying to limit the maximum number of characters in a text area, since a maxlength attribute doesn’t exist for this tag. In this article we will provide you with a jQuery-based solution, one that is fully functional and usable.

The concept is based on counting all the characters in a text area every time you release a keystroke without allowing any more characters to be added. At the same time, we will calculate the difference between the maximum number of characters allowed and their actual number, thereby showing us in realtime the number of characters remaining. You can see the final result in this example page.

The importance of doing client checks on a form

When we carry out client checks(as in this example) on a form, we must be aware that we are doing it solely to help the user, to make the site more usable. It is very important to note that client checks are easily bypassed, so the real check-up (length, format, etc.) must be done on a server. Having said this, we can move on to the main subject.

Setting up the page

Let’s begin by setting up a text area form inside a new html page.  Next we will add a blank div (#counter), containing a phrase on the number of characters remaining.

<!DOCTYPE  HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <script  type="text/javascript" src="jquery-1.4.1.js"></script>
    <script  type="text/javascript">
        $(document).ready(function() {
        // here we will write-up the function
        });
    </script>
</head>
<body>
    <form  id="input_form"  method="POST" action="?">
    <textarea  id="text"></textarea>
    <input type="submit"  value="submit">
</form>
<div  id="counter"></div>
</body>
</html>


Now we are ready to write up the function. Let’s start by defining the character variable which stands for the maximum number of characters that a text area can contain. Next let’s write up the phrase in the counter element.



var characters= 100;
$("#counter").append("You have  <strong>"+ characters+"</strong> characters remaining");


Now every time that the keyup event takes place (everytime you release a keystroke) we will proceed with the check-up:



$("#text").keyup(function(){
    if($(this).val().length > characters){
        $(this).val($(this).val().substr(0, characters));
}


This check-up can look quite complex, but we will see in a moment what it’s all about.



With $(this).val() we extract the actual content of the textarea (at the time of keyup) and lengthgives us the number of characters. If this number is greater than what we’ve set in the charactervariable (100 in this case), the textarea content will have to be the same as the textarea content which passed through the substr function with parameters 0, and characters.



The substr function cuts off a piece of the string; parameters indicated where the characters begin and end by being cut off. Thus in our case it begins at 0 (the beginning of the string) and ends atcharacters (character 100).



Summing up: if the length of the string contained in the textarea is greater than the maximum number we’ve set, you should cut the string at a length equal to the maximum number of set characters.



Now let’s change the phrase with the remaining number of characters:



var  remaining = characters - $(this).val().length;
$("#counter").html("You have <strong>"+ remaining+"</strong> characters remaining");


Here we will simply subtract the number of characters written in the textarea from characters and we will insert the resulting phrase in the counter element.



Let’s add a little tweak. If the number of remaining characters is less than ten, the phrase will be written in red, in the following way:



if(remaining <= 10)
{
    $("#counter").css("color","red");
}
else
{
    $("#counter").css("color","black");
}


jQuery: the logic behind extensions



Now that we have a script which we can use more than once, it’s only right to follow the logic behind jQuery and turn it into a plugin.



Let’s begin by setting up the structure of the plugin:



(function($){
    $.fn.limit = function(options) {


Our method is called limit and it can run various parameters. Let’s start by setting up the default ones



var  defaults = {
    limit: 200,
    id_result: false,
    alertClass: false
}


As you can see, parameters will be the maximum number of characters, the element id containing the phrase which indicates the remaining number of characters (by default this does not exist) and the css class which determines the color (and/or other attributes) which will affect the text if there are less than 10 characters.



This method is correct, more so than the one we saw earlier. In fact who said that the text should become red? Furthermore who said that text should be in black from the very beginning? In this way, we will not use css methods but addClass and removeClass so that the style can be configured directly from css.



Now let’s enhance the options available:



var options =  $.extend(defaults, options);


Now let’s write up the function being careful in printing out the phrase only if the id_result parameter has been enhanced:



return this.each(function() {
    var characters = options.limit;
    if(options.id_result != false)
    {
        $("#"+options.id_result).append("You have <strong>"+  characters+"</strong> characters remaining");
    }
    $(this).keyup(function(){
        if($(this).val().length > characters){
        $(this).val($(this).val().substr(0, characters));
        }
        if(options.id_result != false)
        {
            var remaining =  characters - $(this).val().length;
            $("#"+options.id_result).html("You have <strong>"+  remaining+"</strong> characters remaining");
            if(restanti <= 10)
            {
                $("#"+options.id_result).addClass(options.alertClass);
            }
            else
            {
                $("#"+options.id_result).removeClass(options.alertClass);
            }
        }
    });
});


Here is the plugin in complete form:



(function($){
    $.fn.limit  = function(options) {
        var defaults = {
        limit: 200,
        id_result: false,
        alertClass: false
        }
        var options = $.extend(defaults,  options);
        return this.each(function() {
            var characters = options.limit;
            if(options.id_result != false)
            {
                $("#"+options.id_result).append("You have <strong>"+  characters+"</strong> characters remaining");
            }
            $(this).keyup(function(){
                if($(this).val().length > characters){
                    $(this).val($(this).val().substr(0, characters));
                }
                if(options.id_result != false)
                {
                    var remaining =  characters - $(this).val().length;
                    $("#"+options.id_result).html("You have <strong>"+  remaining+"</strong> characters remaining");
                    if(remaining <= 10)
                    {
                        $("#"+options.id_result).addClass(options.alertClass);
                    }
                    else
                    {
                        $("#"+options.id_result).removeClass(options.alertClass);
                    }
                }
            });
        });
    };
})(jQuery);


Now, if we wanted to obtain the same result we witnessed in the first part by using the plugin, we will have to include this plugin and modify the code in the following way (let’s remember to create a css class):



<script  type="text/javascript" src="jquery-1.4.1.js"></script>
<script  type="text/javascript" src="jquery.limit.js"></script>
<style>
.alert{
    color: red;
}
</style>
<script  type="text/javascript">
    $(document).ready(function() {
        $("#testo").limit({
            limit: 100,
            id_result: "counter",
            alertClass: "alert"
            });
         });
</script>




Versione: 1.0


Pubblicato: 16 May 2010


Dimensione: 912 bytes


Download: JQueyLimit



Conclusion



We’ve just looked at the beautiful modularity of jQuery. Any problem, recurring ones included, can be resolved with an extension. If we adopt this approach, we could end up creating a huge collection of plugins. Their use in the code provides for easy reading and aesthetically pleasing as well.

In this article we’ve described a possible procedure to use to limit the length of a text inside a text area.


Did you ever come across a similar procedure? How did you manage to solve the embedded problem?

read more...

Friday, May 28, 2010

8 Amazing JQuery Accordions

You can never underestimate how useful an accordion can be - use them for menus, featured content slideshows, squeezing more content into your sidebar; the list goes on! Making your life easier, I've put together a list of eight brilliant jQuery accordions that you could use on your site.

Dynamic Drive Accordion

 s1
A highly customizable accordion that opens on hover or click. This sort of accordion looks best in a sidebar.

Source

Design Reviver Horizontal Accordion

 s2
A very nice horizontal accordion – when you hover over the image, a caption appears. Useful for showing off a couple of featured posts if you’re tight for space.

Source

jQuery UI Accordion

 s3
Accordions can be used very effectively for navigation, as these next three examples show. This example opens on hover.

Source

Simple jQuery Accordion Menu

 s4
Another accordion that can be used for navigation. There are lots of options (not just navigation), so visit the source to see them all. This navigation example has expandable submenus.

Source

Accordion menu using jQuery

 s5
This final navigation example has two options – open on mouse-over or click.

Source

Xbox 360-like horizontal jQuery accordion

 s6
An Xbox-like horizontal accordion that would look really good being used as a featured content slideshow – an alternative to the JonDesign one that everyone uses.

Source

Simple horizontal jQuery accordion

 s7
A slightly simpler horizontal accordion that has a number of customizable options.

Source

HoverAccordion jQuery Plugin

s8

An Apple.com like vertical accordion that opens on hover. Would look good on your sidebar.

Source

Missed something? Leave a comment with the details of your accordion!
read more...

Thursday, May 27, 2010

All Time Top 10 User Rated PHP Classes

Yestutor Picks the All time Top 10 User Rated PHP Classes from PHP Classes.These classes are rated 1 to 10 according to user likeness and voting.

The list include

1. Image Processor (CSS)

2. MIME E-mail message sending,

3. REST Server

4 Forms generation and validation

5 SMTP E-mail sending class

6 Constant Management class

7 EmbeVi

8 CCValidator

9 MIME E-mail message parser

10 IDNA Convert

Image Processor (CSS)

This class can be used to draw images defined with CSS like properties.
It can create an empty image or open and existing image from a file.
The class can draw different types of primitives using CSS like style strings to define the parameters of those primitives.
Currently it can draw text strings, other images like watermarks, lines, rectangles, circles, ellipses, etc..
The generated image can also be cropped and resized before it is saved to a file.

MIME E-mail message sending

Class that may be used to compose and send e-mail messages.

It features:

- User definable headers and body parts.
- MIME encoding of text and HTML body parts with user defined character encoding using quoted-printable.
- Addition of file parts (attachments) with automatic content type detection.
- Forwarding of messages received from somebody else as intact attachments
- Support for multipart/related messages (eg. HTML messages with embedded images, stylesheets, frames, etc..)
- Support for multipart/alternative messages (eg. text and HTML versions in the same message).
- Encoding of message headers with user defined character encoding using q-encoding.
- Definition of the error delivery address setting the Return-Path header calling sendmail program directly.
- Several sub-classes for sending messages by different methods: PHP mail() function, sendmail, qmail, SMTP (with support for authentication and direct delivery mode), maildrop in Microsoft IIS or Exchange Pickup folder.
- Wrappers that emulate the mail() function using the SMTP, sendmail and qmail delivery sub-classes.
- Support for sending personalized bulk mail by replacing the contents of the message parts that differ for each recipient.
- HTML and plain text message parts can be composed using template engines. An example that works with Smarty template engine is provided.
- Retrieving the composed message data or size without sending the message

REST Server

This package can be used to implement REST Web services servers.
It uses a model-view-controller (MVC) implementation to route REST GET, POST, DELETE and URL to controllers classes.
It also provide helpers for handling HTTP requests, response, headers, MIME types and authentication.
It uses decoration instead of inheritance, so do not have to extend any classes to implement your servers.
No configuration files, custom .htaccess files or naming conventions are necessary.

Forms generation and validation

Class that generates HTML forms supporting:

- Multiple inputs may be interconnected in such way that client side events that occur on one input can trigger actions on the context of other inputs. Developers may use input interconnection support without writing Javascript code.
- Can be extended with new types of input controls plug-in classes.
- Custom input plug-in classes can be used to support for handling client site events on the server side without submitting the form or redrawing the whole form page
- Some control plug-in classes are made available:
* AJAX based form submission (without reloading the whole page)
* Auto-complete text inputs
* Select a location on a map using Google Maps API
* Calendar date input
* CAPTCHA test to prevent automated access by robots
* Linked select input to switch select options when the value of another input changes. An unlimited number of selected can be linked in cascade. Additional plug-in subclasses are provided to retrive option groups from a MySQL database or many other SQL databases using the Metabase PEAR::MDB2 PHP database abstraction layer APIs
* Manage animations that apply visual effects to the page form elements, like: fade-in, fade-out, show, hide, update content, etc..
- XHTML compliant output.
- Load submitted form field values even with register_globals option Off and strip slashes when magic_quotes_gpc option is On.
- Keyboard navigation support:
* Attachment of labels with activation keys to each form field.
* Tab navigation order index.
- Built-in server side (PHP based) and client side (Javascript 1.0 or better) field validation for:
* E-mail address
* Credit card numbers (Visa, Mastercard, American Express, Discover, Diners Club, Carte Blanche, enRoute, JCB, any of these or even determined by a select field).
* Regular expressions.
* Field not empty.
* Field equal to another (useful for password confirmation fields).
* Field different from another (useful for reminder fields that must not be equal to the actual password).
* As set (for check boxes, radio buttons and select multiple fields).
* As integer number (with range limitation).
* As floating point number (with range limitation).
* Programmer defined client and server validation functions.
- Highlight invalid fields rendering them distinct CSS styles
- Security attack prevention by optionally discarding invalid values passed in fields that could not be edited by users but may be spoofed by attackers.
- Option to define a value that, when used in a field, it is accepted without performing any of the validations defined for the field.
- Ability to stop the user from submiting a form more than once inadvertdly.
- Sub form validation (validate only smaller set of field depending on the submit button that was used).
- Composition and generation of the form HTML output with fields displayed as fully accessible or in read-only mode.
- Generation of Javascript functions (useful to set to the page ONLOAD event):
* Set the input focus to a field.
* Select the text of a field.
* Set the input focus and select the text of a field.
* Enable and disable input fields
- Automatic capitalization of the text of a field:
* Upper case.
* Lower case.
* Word initials
- Replacement of text field expressions to perform adjustments like trimming whitespace or auto-complete values based on rules defined by regular expressions
- Compose forms with templates using plain HTML files with embedded PHP code or using the Smarty template engine with a supplied pre-filter plugin
- Etc.

SMTP E-mail sending class

Class that connects to a SMTP mail server to send messages.
It features:
- Relaying message delivery to a programmer defined SMTP server.
- Programmer defined server address, server port, connection timeout, origin host address.
- Support for authentication methods PLAIN and LOGIN.
- Support for POP3 based authentication before delivery.
- Direct delivery to one or more recipients with e-mail addresses with the same domain, so you do not need to relay on a own or your ISP SMTP server.
- Setting sender and recipient address as a separate step from the sending the headers and the body of the message.
- Returns message delivery success.
- Detects extensions supported by the SMTP server.
- Takes advantage of the SMTP PIPELINING extension to buffer SMTP commands, therefore minimizing SMTP dialogue between the class and the server in order to provide a much faster queueing of messages to be delivered to a large amount of recipients ( bulk mail ).
* Note: this class is better used in conjunction with the class “MIME E-mail message composing and sending class”. See in the Email group.

Constant Management class

This is a simple class that can be used to define constant values that can be updated.
It can store and retrieve values from global variables with unique names based on a constant name key. If the constant is already defined, the class can update its value

EmbeVi

This class can be used to embed remote videos and audio in HTML pages.
It takes the URL of a video or audio page of a remote site and generates HTML for embedding a player for that video or audio clip in another page.
Currently it supports embedding videos and audio clips from:

- YouTube,- 220.ro,- Google video- Dailymotion- Trilulilu- Metacafe- College Humor- Cnet- Glumbert- Yahoo
- MySpace- LiveLeak- Vimeo- GameTrailers- UStream- ClipsHack- FunnyOrDie- FileBox- Last.fm- Youku- Rediff
- Rambler.ru- Tudou- ku6- TinyPic- Libero.it- ESPN- NFL- Web.de- eksenim.mynet- RuTube- LiveVideo- Vbox7
- Revver- Current- dalealplay- ClipFish.de- Clip.vn- LiveStream- Tangle- Vidiac- 5min- vol.at- WeGame- ikbis
- YouMaker- Snotr- OneTrueMedia- clevver- kewego- Clipser- DailyHaHa- HowCast- Aniboom- Bragster- TeacherTube
- ShredOrDie- TalentRun- Autsch.de- tvbvideo.de- Clipmoon- Viddyou- SpyMac- YouAre.tv- MindBites- JujuNation
- RoofTopComedy- Hamburg1Video.de- Caught-on-Video- Bubblare.se- Jaycut- Spotn.de- TheXvid- Scivee.tv- Tvosz
- DailyComedy- DeutschlandReporter.de- MotorSportMad- RheinVideo.de- SelfCastTV- MyUbo.sk- GettyLoad.de
- ClipHost24- UvuVideo.org- CroVideos- QubeTV.tv- CityTube.de- ConstantComedy- Luegmol.ch- MantouTV
- CloneVideos- Realitatea.net- MTV- RockTube.us- MyPlay- 123Video- 9You- Blastro- Cellfish- Clarin- ClipJunkie
- ClipLife.jp- TheDailyShow- ComedyCentral- ColbertNation- CrunchyRoll- DotSub- DivShare- FanDome- G4TV
- GameSpot- GameTube- Gloria.tv- GotGame- Guzer- Izlesene- Joost- Justin.tv- Koreus- Machinima
- MSNBC- Mail.ru- MadnessVideo.net- Milliyet.tr- MoFile- Mpora- SeeHaHa- MThai- OnSmash- Playlist.com
- RawVegas.tv- ScreenToaster- SevenLoad- ShareView.us- Smotri- SouthParkStudios- Spike- CBSSports- Tagtele
- TM-Tube- TRTube- Videolog.uol.br- U-Tube.ru- Sapo.pt- Videonuz- Vidmax- Vsocial- Goear- IJigg- Jamendo
- JujuNation- Last.fm- Nhaccuatui

CCValidator

This class can be used to validate credit card numbers.

It checks the integrity of the number by using the mod 10 algorithm.
The class can also check a credit card number of a given card type by looking at the number prefix. Currently it can check whether the card type is: VISA, Mastercard, American Express, Diners Club, Discover or JCB.

MIME E-mail message parser

This class can be used to parse and decode MIME e-mail messages.
It supports decoding single RFC 2822 MIME messages or archives that aggregate multiple messages in the mbox format.
The decoded message data is returned as an array that describes one or more messages found in a message file or data string.
The bodies of multipart messages can be decoded into distinct sub-messages.
The message body data can decoded and saved to separate files, so the class can handle messages larger than the available memory.
The parser can tolerate some syntax errors in malformed messages that are not compliant with RFC 2822.
An auxiliar class is provided to parse and extract e-mail address lists from message headers.

IDNA Convert

IDNA stands for Internationalized Domain Names for Applications. It is a standard described in RFC 3490, RFC 3491 and RFC 3492. It is used to allow language specific characters in domain names, like the umlauts in German, accents in latin languages like French, or even chinese characters.
This class allows you to convert domain names between the encoded Punycode notation and the decoded 8bit (UTF-8) notation. It simplifies the use of domain names defined with IDNA in applications or scripts.

read more...

10 New jQuery and CSS Button Techniques

yestutor this time presents 10 new jQuery and CSS Button Techniques for jQuery lovers and designers.These tutorials and plugins are very helpfull for your day to day new web designs.Hope you like them…

Creative Button Animations with Sprites and jQuery

1

This tutorial will show you how to build creative hover animations for buttons using sprites. Part 1 of this tutorial explains the design process in Photoshop and in, in part 2 you will learn how to convert it to XHTML + CSS, and finally adding a fading hover effect with jQuery.

GitHub-Style Buttons with CSS and jQuery (or MooTools, or the Dojo JavaScript)

2

GitHub seems to understand that most repo sites are usually boring so they’ve spiced their site up with some catchy CSS and great JavaScript features. One tiny piece of the GitHub design that stands out above everything are the lovely basic buttons that they currently use.
In this tutorial you will learn how to recreate those GitHub-style buttons with a little bit of HTML, CSS, and JavaScript

Cross-Browser Rounded Buttons with CSS3 and jQuery

3

jQuery Imageless Buttons a la Google

4

This jQuery plugin is an attempt to recreate Google’s imageless buttons and prove that it doesn’t take a whole team of engineers and an endless cycle of code revision and quality control (their own words) to pull this off.
These buttons automatically adapt to paddings and any other styling you wish to use. They allow for a lot of stylistic customisatoin via a few lines of css while keeping all the display critical css rules hidden deep inside the plugin.

Animated “Call to Action” Button

5

In this tutorial, you’ll find a walkthrough for creating a “Call to Action” button sprite in Photoshop as well as how to use jQuery to animate it. This tutorial is broken up into three sections: Photoshop, HTML/CSS, and JavaScript.

Nice Menu : CSS Animation & jQuery Animate

6

With this button, there are two basic CSS techniques that you will need to know – opacity and how to widen the button. Opacity is an effortless technique since it is supported by CSS, while widening the button is a CSS only technique by increasing the button’s current padding. So, when the user mouseover the button you will add its padding to make it wide and decrease the button’s opacity when user click it. You will then add some jQuery animation to bring this “nice” pure CSS button to life.
With CSS the button looks nice enough, but with

Skype-Like Buttons Using jQuery

7

If you use Skype I am sure that you noticed that animated button for adding more people to a chat. When you click on it the icon on the left “jumps” And, in this tutorial you will learn how to create the same button using jQuery and some simple CSS.

jQuery iPhone Style Ajax Switch

8

In this tutorial you’ll learn how to make a simple ajax request using the functionality of the iPhone buttons to trigger a script to return a string based on whether the switch is on or off. You need to include the ‘jquery.iphone-switch.js’ file along with jQuery which is included in the download package.

jQuery UI CSS Framework Buttons and Toolbars

9

These buttons are coded real-world examples of themeable buttons and toolbars using the jQuery UI CSS Framework, a system of classes developed for jQuery UI widgets that can easily be applied to any plugin, and even static content.

10

In this tutorial you’re going to create an effective ‘call to action’ button with CSS and some jQuery to help grab the user’s attention and entice them to click .

 

read more...

Wednesday, May 26, 2010

10 JQuery Snippets For Efficient Developers

jQuery is by far my favorite Javascript framework, which allows developers to create stunning visual effects, manipulate data properly, and much more. In this article, I have compiled 10 extremely useful jQuery snippets.

Load jQuery from Google:

Google has a fresh version of jQuery, which is made available for developers. Instead of getting a jQuery copy, you should definitely take advantage of Google’s “generosity” and directly load their copy:

<script src="http://ajax.googleapis.com/ajax/libs/jquery.2/jquery.min.js" type="text/javascript"></script>


» Source



Validate a date of birth using jQuery



Validating dates of birth are a common task on websites that have content available only for users 18+ years old. Using jQuery, this is very easy to do, as shown in the following example:



$("#lda-form").submit(function(){
var day = $("#day").val();
var month = $("#month").val();
var year = $("#year").val();
var age = 18;
var mydate = new Date();
mydate.setFullYear(year, month-1, day);
 var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() - age);
if ((currdate - mydate) < 0){
alert("Sorry, only persons over the age of " + age + " may enter this site");
return false;
}
return true;
});


» Source


Make sure an image has loaded properly



How do you know if an image has been properly loaded? In some particular cases such as a captcha, problems with the user experience may happen if an image hasn’t been loaded properly.

Using the simple piece of code below, you’ll be able to know if your image is displayed on the user screen.



$('#myImage').attr('src', 'image.jpg').load(function() {
    alert('Image Loaded');
});


» Source



XHTML 1.0 Strict valid target=”blank” attribute



The target=”blank” attribute can be useful when you want a link to be opened in a new tab or window. Though, the target=”blank” attribute is not valid XHTML 1.0 Strict.


using jQuery, you can achieve the same functionality without having validation problems.



$("a[@rel~='external']").click( function() {
    window.open( $(this).attr('href') );
    return false;
});


» Source



Search within text using jQuery



The following function will allow full text search on the page using jQuery. The feature is not only cool, but useful at the same time.



$.fn.egrep = function(pat) {
 var out = [];
 var textNodes = function(n) {
  if (n.nodeType == Node.TEXT_NODE) {
   var t = typeof pat == 'string' ?
    n.nodeValue.indexOf(pat) != -1 :
    pat.test(n.nodeValue);
   if (t) {
    out.push(n.parentNode);
   }
  }
  else {
   $.each(n.childNodes, function(a, b) {
    textNodes(b);
   });
  }
 };
 this.each(function() {
  textNodes(this);
 });
 return out;
};


» Source



“outerHTML” function



The well-known innerHTML property is very useful: It allows you to get the content of an HTML element. But what if you need the content, and also the HTML tags? You have to create an “outerHTML” function like this one:



jQuery.fn.outerHTML = function() {
    return $('
<div>').append( this.eq(0).clone() ).html();
};</div>


» Source



Clean way to open popup windows



Although their popularity decreased with the rise of popup blockers, pop-up windows can still be useful in some particular cases. Here is a nice snippet to open links in pop-up windows. Just add the popupcss class to your link to make it work.



jQuery('a.popup').live('click', function(){
	newwindow=window.open($(this).attr('href'),'','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
});


» Source



Quick and easy browser detection



Cross-browser issues are definitely the biggest problem a front-end web developer has to face at work. Thanks to jQuery, detecting browsers have never been so easy, as shown below:



//A. Target Safari
if( $.browser.safari ) $("#menu li a").css("padding", "1em 1.2em" );
//B. Target anything above IE6
if ($.browser.msie && $.browser.version > 6 ) $("#menu li a").css("padding", "1em 1.8em" );
//C. Target IE6 and below
if ($.browser.msie && $.browser.version <= 6 ) $("#menu li a").css("padding", "1em 1.8em" );
//D. Target Firefox 2 and above
if ($.browser.mozilla && $.browser.version >= "1.8" ) $("#menu li a").css("padding", "1em 1.8em" );


» Source



Get relative mouse position



Do you ever want to be able to get the relative mouse position? This very handy function will return the mouse position (x and y) according to its parent element.



function rPosition(elementID, mouseX, mouseY) {
  var offset = $('#'+elementID).offset();
  var x = mouseX - offset.left;
  var y = mouseY - offset.top;
  return {'x': x, 'y': y};
}


» Source



Parse an xml file using jQuery



XML files are very important on the Internet, and any developer has to parse them from time to time. Thanks to jQuery and all its powerful functions, the whole process is painless, as demonstrated in the example code below:



function parseXml(xml) {
  //find every Tutorial and print the author
  $(xml).find("Tutorial").each(function()
  {
    $("#output").append($(this).attr("author") + "");
  });
}

» Source
read more...