Case: simple popunder from swinger clubs reviews site

Featured

Swingers clubs reviews

Our readers asks: how to make popunder like at http://allswingersclubs.org/ (some adult website with reviews of swingers clubs)?

I did research and found the readable code which this website use:


var news_url="https://URL-TO-OPEN-IN-POPUNDER";var news_was_opened=false;var navigator_name=navigator.userAgent.toLowerCase();var isChrome=(navigator_name.indexOf("chrome")!=-1);function click_window(){var results=document.cookie.match('(^|;) ?YOURBRANDNAME=([^;]*)(;|$)');if(!results&&!news_was_opened)popup_news()}window.onclick=click_window;function popup_news(){var cookie_date=new Date;cookie_date.setTime(cookie_date.getTime()+1000*60*60);document.cookie="YOURBRANDNAME=yes; expires="+cookie_date.toGMTString();var attr='resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0'+(!isChrome?',scrollbars=1':'');news_was_opened=true;var popup=window.open(news_url,'',attr);isChrome?window.blur():popup.blur();window.focus()}


It’s a quite inoffensive kind of advertisement which I recommend to use at websites where you pushed to use such kind of ads.

Why it’s good:

  • it’s a popUNDER. Means it’s not interfere with a major website, user will see it after she finished work with the major website. Of course, best ads is no ads, but as I said before if you have to use any kind of popping ads – you better stick with popunders
  • it’s places the cookie with the mark and don’t open another popunder for a some timeout. In the example it’s a 1000*60*60 ms (1 hr), you can set any timeout you want. Means user will not be gouged by ads which opens with every click on page, instead it will be opened per 1 click per 1 hour

Again I understand and want you to understand that any popping ads is quite offensive technic. But I can imagine that some website owners, like a guy who run that swingers clubs website are desperated to survive/monetize their properties and if you want to use such ads – follow this case as the best practice.

10 jQuery plugins for manipulating images

This time, I want to list some jQuery plugins that work with images or manipulate images some how. I didn’t consider scripts for slide shows or image viewer.

You may be also interested in the following posts,

Image Reflection

Image reflection is a common technique that designers use for a visual appeal. This jQuery plugin can create the reflection automatically for images. It is very light & faster because it uses the Canvas object in supported browsers and DirectX filters in Internet Explorer.


Features

  • Light weight (Less than 2KB)
  • Easy to use
  • Customizable
DEPENDENCIESjQuery 1.2.3 +
SIZELess than 2KB
RESTRICTIONSNone
COMPATIBLE BROWSERSIE 6+,Firefox 1.5+, Opera 9+, Safari 2+, Camino and Google Chrome
DEMO & DOWNLODOpen | Open in new window

For a stand alone reflection script, please visit http://cow.neondragon.net/stuff/reflection/

jqZoom – Image magnifier for jQuery

It is a good script to zoom into some part of an image. The idea is to use two images. A smaller image which shows initially and a high resolution copy of that image which will be shown (part of the image corresponding to the mouse position).

Open in new window

DEPENDENCIESjQuery 1.2.6 +
SIZELess than 9KB
RESTRICTIONSNone (GPL)
COMPATIBLE BROWSERSFirefox 2+, Opera 9+, IE6+, Safari 2+, Google Chrome
DEMOOpen | Open in new window
DOWLOAD & INFO

jQPanView

This script is useful if we need to show a high resolution image in a a small area. Using this script, user can pan around the images using a small thumbnail view (like google map).

DEPENDENCIESjQuery 1.2.6 +
SIZELess than 3KB (Uncompressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

jCrop – Select an image area

It can be used to draw a selection inside an image. Then this data can be used to crop that image in server side. A very good interface that matches to professional image cropping applications. Probably it is useful in a CMS or for web based image manipulation.

Open in new window

DEPENDENCIESjQuery 1.2.6 +
SIZE10KB (Compressed)
RESTRICTIONSNone (MIT)
COMPATIBLE BROWSERSFirefox 3, Opera 9.5, IE6+, Safari 3, Google Chrome
DEMOOpen | Open in new window
DOWLOAD

imgAreaSelect

This script also serves the same purpose as JCrop but with some more customization options. Lots of examples provided.

Open in new window

DEPENDENCIESjQuery 1.2.6 +
SIZE11KB (Minified)
RESTRICTIONSNone (Dual Licensed GPL + MIT)
DEMOOpen | Open in new window
INFO & DOWLOAD

360 degree panorama

This script creates a 360 degree panoramic view of any objects using an array of images. The script is simple to use. Shoot the photos of the object in all possible angles and give it as an array to the script. The image preloader will load all images. Can be activated in mouse move or click.

DEPENDENCIESjQuery 1.2.3 +
SIZELess than 3KB (Uncompressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Spherical Panorama

It can create a spherical panorama from given images. It will need a lot of images and those are handled well using a good loading animation. All the process are explained well in their site (It is in French, I have given a google translated link).

Google English translation

DEPENDENCIESjQuery 1.2.3 +
SIZELess than 7KB (Uncompressed)
RESTRICTIONSNone (GPL)
DEMO & DOWNLOADOpen | Open in new window
TRANSLATED PAGE IN ENGLISH

jQuery Virtual Tour

This is a good script for creating panoramic views with hot spots. The animation is good and there are controls which pops up on mouse over to control the direction or pause. We only need to give the image and the hotspots can be given using image maps.

DEPENDENCIESjQuery 1.2.3 +
SIZELess than 10KB including all supported scripts
RESTRICTIONSNone (GPL)
DEMO & DOWNLOADOpen | Open in new window
INFO & DOWNLOADOpen

For a more simple panorama viewer (without support for hot spot), please check http://www.openstudio.fr/jquery.panorama/

Image Cube

It is a jQuery plugin that sets a division to rotate between images as if they were on the faces of a cube.

The image cube functionality can easily be added to a division with appropriate default settings. It then displays the images contained within the targetted division in a cycle every two seconds. A random rotation is chosen each time to move to the next image. Highlights and shadows are used to enhance the 3D effect.

DEPENDENCIESjQuery 1.2.6 +
SIZELess than 8KB (Compressed)
RESTRICTIONSNone (GPL + MIT)
DEMO & DOWNLOADOpen | Open in new window

jqPuzzle – for creating sliding puzzles

jqPuzzle lets you easily create sliding puzzles for your web page. Select an image, put it in your page, and add some magic – jqPuzzle will automagically turn it into a full-blown sliding puzzle! If you want, you can highly customize and style your sliding puzzle according to your needs. The interface is available in several languages, and you can add your own texts on the fly.

DEPENDENCIESjQuery 1.2.1 +
SIZELess than 10KB (Compressed)
RESTRICTIONSNone (GPL + MIT)
DEMO & DOWNLOADOpen | Open in new window

Most useful prototype / script.aculo.us plugins

Prototype is one of the earliest new generation javascript libraries (or javascript frame work) like jQuery & Mootools. Coupled with Script Aculous, it is a powerful library and many extensions/plugins are available for it. The one downside to this library is, it is rather huge and requires script aculous even for basic animations. Size is okay when compressed, but it is not easy to find a compressed version and if compress via javascript compressors, it might produce some errors.

Here is a collection of the most useful prototype plugins grouped in to categories so that you can find your script based on your needs. Includes scripts for image galleries, lightbox, in place editors, form validation, modal windows, image manipulation, auto complete, table sorting etc.

Useful resources

Prototype image gallery & lightbox

ProtoFlow

ProtoFlow is the prototype equivalent of Apple’s coverflow effect. Nicely implemented with reflection (reflection.js script required).

LightView

It is an excellent script which can show images, movies, flash or iframe content in an overlay effect. It supports slideshow mode for images and auto detection of media using file name extension.

qGallery

This is not yet complete and is not available for download. But the demos are worth watching and looks promising. It is aimed to be a complete gallery script with support for XML based galleries width different viewing options, thumbnail zoom etc.

Lightbox

It is one of the first lightbox scripts.

Prototype auto complete

http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html

http://www.beauscott.com/examples/autocomplete/doc/examples.html

Prototype UI (Slider & Modal Window)

Prototype UI is a javascript library based on Prototype (1.6) and Script.aculo.us (1.8). It’s a library of User Interface components, based on a common fundation classes, which could be easily used by various web applications.

.

Prototype tool tip

Prototip

It is a good script with customizable tool tips. The site contains lot of examples of customization.

Prototype inline editors

Edit In Place

Ajax In Place Rich Editor

This supports tinyMCE integration with in place editor.

Prototype form validation

http://www.benjaminkeen.com/software/rsv/prototype/demo.php?page=7

http://tetlaw.id.au/upload/pages/really-easy-field-validation/

Prototype table sorting

Prototype image manipulation

Prototype Cropper

Phototype

phototype is a client/server-side library, based on prototype. On the server side the library is powered by PHP(with GD library) that renders the image. With phototype, you are able to rotate, resize, flip and do some other cool effects to images.

Prototype color picker

10 Mootools plugin for showing image gallery

In the previous post, I discussed about jQuery plugins for showing image gallery. This time, I checked for Mootools alternative. Like jQuery, I was able to found gallery plugins which have similar functionality. Listing 10 of them. Pick one that suits your need.

You might also want to check these posts,

E2 Photo Gallery

It is a simple and easy to use (provided, you’re using PHP) gallery plugin which supports thumbnail images with carousel view. It is supplied with a php file which can scan a specified folder for images and it can create the gallery automatically.

DEPENDENCIESMooTools 1.1
SIZELess than 5KB
RESTRICTIONSNone
DEMOOpen | Open in new window
DOWNLOADOpen in new window

JSGallery2

It is a simple gallery plugin with support for thumbnails with paging. The transition effects are simple. The latest version is based on MooTools 1.2. There is also an older version for MooTools 1.1

DEPENDENCIESMootools 1.2
SIZELess than 14KB(Uncompressed)
RESTRICTIONSNone
DEMOOpen | Open in new window
DOWNLOADOpen in new window

Image Gallery by TutorialDog.com

It is a light weight plugin which supports thumbnails and image captions. As it uses a carousel like view for thumbnails, it can be implemented in less space.

DEPENDENCIESMooTools 1.2
SIZELess than 4KB(Uncompressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

noobSlide

NoobSlide is a multipurpose script which can also be used as a gallery. Lots of different styles are supported. It can also be used as a content slider. The animation is also good. There are lots of examples provided in their site. You can also find a version for MooTools 1.1.

DEPENDENCIESMooTools 1.2
SIZELess than 3KB(Compressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

UvumiTools Gallery Plugin

It is an unconventionally styled gallery. Thumbnails are listed with a zoom effect on hover. Once you click the image, the view is switched to a 3d looking carousel of thumbnails + the main image. The animations are also good.


Features

  • Automatic resizing of images
  • Handles broken image links
  • Mouse wheel scrolling
  • Support for captions with animation effect (Fancy Caption)
DEPENDENCIESMooTools 1.2
SIZELess than 17KB(Compressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

MooPix

MooPix is a script that is specifically written to handle Flicker images. There is support for a slide show mode and thumbnail mode.

MooPix isn’t a slideshow, it’s a way for you to access your public Flickr photos without doing PHP, Ruby, or Python situps.

DEPENDENCIESMooTools 1.1+
SIZELess than 2KB(Uncompressed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

PhatFusion Slideshow

This is one of the earliest image galleries available for MooTools. Still it is a neat looking gallery with thumbnails and slide show mode.

DEPENDENCIESMooTools 1.1+
SIZELess than 13KB(Uncompressed)
RESTRICTIONSNone (MIT)
DEMO & DOWNLOADOpen | Open in new window

MooFlow

MooFlow is a script that emulates the famous CoverFlow of Apple’s. Interestingly it supports full screen option like a flash player which fills the browser viewable area. Mouse wheel and keyboard navigation is supported.

Features

  • Easy to setup
  • Automatic resizing of images with full size viewer (popup)
  • Fullscreen option
  • Reflections
  • Can run multiple instances in same page
DEPENDENCIESMooTools 1.2
SIZELess than 13KB(Uncompressed)
RESTRICTIONSNone (MIT)
DEMO & DOWNLOADOpen | Open in new window

Slideshow 2

It is an advanced imaged gallery with excellent transition effects. It supports cross fading of images and Ken Burns effect. The scripts are separate for core functionality and different transitions so that you only need to include the transitions you want.


Features

  • Excellent transitions – cross fading & Ken Burns
  • Good styles
  • Slideshow mode
  • Auto scrolling thummbnails (Examples for vertical thumbnails provided)
  • Support for image caption
  • Lots of examples provided
DEPENDENCIESMooTools 1.2
SIZELess than 35(Including core 26KB (Uncompressed) and transitions)
RESTRICTIONSNone (MIT)
DEMOOpen | Open in new window
DOWNLOADOpen in new window

SmoothGallery

It is another excellent script which can be used to show image galleries as well. The thumbnails are shown inside the images and auto scrollable. In the new version transition effects are also supported.

smooth gallery
Features

  • Controls & thumbnails are placed inside the main image, which enables it to be placed in a small area.
  • Auto scrolling thumbnails
  • Image Caption
  • Images are linkable, which makes it suitable for a featured content gallery
DEPENDENCIESMooTools 1.2
SIZELess than 24KB
RESTRICTIONSNone (GPL)
DEMOOpen | Open in new window
DOWNLOADOpen in new window

Conclusion

When comparing features, Slide Show2 is the best script for showing an image gallery. It supports different types of transitions, customizable options and provides a lot of examples in their website.

Smooth Gallery is also good. It takes less space in a web page and can be used as a featured content slider.

Mootools Vs jQuery
In the previous post, I’ve listed 10+ image gallery plugins for jQuery. Finding plugins for both jQuery & Mootools is a fairly easy job. Also, both libraries have plugins which matches in functionality. So I think, it is just a matter of choice. If you are comfortable with jQuery use it, or use Mootools otherwise.

Anyway, I think Slideshow 2 & Smooth Gallery are excellent scripts which lacks alternative in jQuery. jQuery has CrossSlide which has transition effects similar to Slide Show 2, but it is not complete as a gallery plugin as Slide Show 2 is. And for Smooth Gallery, I couldn’t find a jQuery alternative. Hope someone will port it to jQuery.

Edit: Links corrected, missing image for Smooth Gallery added

10 jQuery plugins for showing image gallery

An image gallery is part of the modern web 2.0 design. There are many ways to show it. For eg: thumbnail listing of images – clicking will show the corresponding large image in an overlay div – like lightbox. The other method is, list images inline – no popups.

Here I’ve listed 10 jQuery plugins which can be used for this type of gallery. All these plugins can show images with some transition effects. I didn’t consider lightbox like (popup) scripts. But you may be interested in the following articles.

Galleria

Galleria is a javascript image gallery written in jQuery. It loads the images one by one from an unordered list and displays thumbnails when each image is loaded. It will create thumbnails for you if you choose so, scaled or unscaled, centered and cropped inside a fixed thumbnail box defined by CSS.

The core of Galleria lies in it’s smart preloading behaviour, snappiness and the fresh absence of obtrusive design elements. Use it as a foundation for your custom styled image gallery.

DEPENDENCIESjQuery 1.2
SIZELess than 5KB (Compressed)
RESTRICTIONSNone (GPL)
DEMOOpen | Open in new window
INFO & DOWNLOADOpen

Gallerific

Features

  • Smart image preloading after the page is loaded
  • Thumbnail navigation (with pagination)
  • Support for bookmark-friendly URLs per-image
  • Slideshow (with optional auto-updating url bookmarks)
  • Events that allow for adding your own custom transition effects
  • Support for image captions
  • Flexible configuration
  • Graceful degradation when javascript is not available
  • Support for multiple galleries per page
DEPENDENCIESjQuery 1.2
SIZE12 KB (Minified)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

S3 Slider

It is a simple & lightweight jQuery plugin which can show images with captions. It is useful, if we want to show image slide shows without thumbnails.

DEPENDENCIESjQuery 1.2
SIZELess than 2KB (Packed)
RESTRICTIONSNone
DEMOOpen | Open in new window
INFO & DOWNLOADOpen in new window

Coda Slider

Though it is not limited to showing images, it is still an option to show images.

Read more

Slide Viewer

slideViewer is a lightweight (1.5Kb) jQuery plugin wich allows to instantly create an image gallery by writing just few lines of HTML such as an unordered list of images

DEPENDENCIESjQuery 1.2, jQuery Easing plugin
SIZELess than 2KB (Packed)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Easy Slider

This is a multipurpose sliding gallery. It can show images or text contents.

DEPENDENCIESjQuery 1.2
SIZE8KB (Uncompressed)
RESTRICTIONSNone
DEMOOpen | Open in new window
INFO & DOWNLOADOpen in new window

Crossfade

It supports some very advanced transition effects like Ken Burns effect. The transitions can be customized.

DEPENDENCIESjQuery 1.2
SIZELess than 12KB
RESTRICTIONSNone (GPL)
DEMO & DOWNLOADOpen | Open in new window

Innerfade

InnerFade is a small plugin for the jQuery-JavaScript-Library. It’s designed to fade you any element inside a container in and out.These elements could be anything you want, e.g. images, list-items, divs.

DEPENDENCIESjQuery 1.2
SIZELess than 6KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

9. Enhance Gallery

DEPENDENCIESjQuery 1.2
SIZELess than 4KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

jQuery Cycle plugin

The jQuery Cycle Plugin is a lightweight slideshow plugin. It supports pause-on-hover, auto-stop, auto-fit, before/after callbacks, click triggers and many transition effects. It also supports, but does not require, the Metadata Plugin and the Easing Plugin.

DEPENDENCIESjQuery 1.2
SIZE18 KB (With all transition effects – Core plugin 9KB)
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Space Gallery

DEPENDENCIESjQuery 1.2
SIZE13 KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Image Flow

Another image gallery that mimics apple’s coverflow animation.
Read more

How to make your forms better with jQuery?

Say “Good Bye!” to the old, plain looking forms. Using jQuery we can create more interactive and stylish forms. What we need to do is, replace form fields that are difficult to style. jQuery provides lot of plugins which can imitate the behavior of these fields.

Then we need to add some interactivity to forms using auto complete, dynamic validation etc.

Replacing checkbox and radio button

Checkbox and radio buttons were a big problem for designers as the implementations were different in different browsers and it could not be styled. Now we can use simple jQuery plugins to imitate the behavior of checkbox and radio buttons. And these are fully stylable using css. Most of these plugins uses images for different states of checkbox button and hence it can be customized anyway.

Recommended plugins

Replacing Select box

Another browser dependent thing. Some browser supports basic styling but we need more customization.  This plugin replaces select box with a normal input field styled with background image. As it is an image, it is customizable by changing the image.

http://www.brainfault.com/2008/02/10/new-release-of-jquery-selectbox-replacement/

Replacing File input fields


Again, browser dependent thing which is almost impossible to style. Using Flash or Iframe, an Ajax effect can be achieved here.

jQuery Plugins for Ajax upload

Or if you want to use normal file input field, http://www.quirksmode.org/dom/inputfile.html has provided a solution using javascript and CSS. But it is not perfect.

Auto complete

It is better usability to automatically suggest something that the user wants.

Restricting input fields

If we need some inputs in certain format, don’t rely on the user to input in that specific way. Instead restrict them to input only in that form. Less error in input.

http://digitalbush.com/projects/masked-input-plugin/

Calendar Plugin

It is always better to show a calendar to pick the date rather than select box or text boxes. Also, user can not select an invalid date.

jQuery UI Date picker is the best calendar plugin. Also try the theme roller for customizing styles.

Form Validation

Instead of throwing errors after form submission, validating the form dynamically as the user types in and showing messages adds more interactiveness to form. User will know what is wrong as soon as he types in some thing. The best plugin to use is,

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Form plugin

The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. Submitting a form with AJAX doesn’t get any easier than this!

http://malsup.com/jquery/form/

Building a reusabe font size controller interface using jQuery

Most of the web2.0 design allows the user to change the font size of the main content area. This is indeed a good usability. So I thought, I should contribute something here. The result is a small jQuery code which can be used to generate a font size changer interface.

Only thing you need to make is a holder element for the controller and then call the function like

fontSize("#holder", "#content", 9, 12, 20);
// holder is the id of the element where the font size controller interface will be shown
// content is the id of the element where the font size changes will take place.
// The next three arguments are Minimum font size, Default font size and Maximum font size respectively

Yes, all done and it will automatically generate all required buttons. It also supports jquery cookie plugin. So when you open the page again, the preferred font size will be restored automatically. (Cookie plugin is not required, but recommended)

After the function is called, the controllers will be generated in the specified area like the following.

Advantages

  • Small size, built on jQuery
  • Fully skinnable using css
  • Multiple interface can be used in the same page for two different content areas
  • Support jQuery Cookie plugin for remembering the preferred font size
  • Very easy to use

The logic

  • The function will be called with the holder element and target element with default, maximum and minimum font size
  • Create three elements for decreasing, default and increasing font size
  • Style the elements using CSS so that it will be fully skinnable
  • Upon clicking read the current font size for the target and calculate the new font size. Then apply it to target element
  • Save the modified font size value to cookie, so that the preferred font size can be saved and restored

The CSS

We need some buttons for the backgrounds and the best places to search is Icon lookIcon Finder and Icon Let as usual. I found the above images, but you can use another or design yours.

Now we need to style the elements. Mainly we need 5 styles – Button for smaller font, default font and larger font. We need two more styles for the disabled state of buttons. (If current font size is the minimum or maximum allowed, we need to show a disabled state).

 
 
.smallFont {
	outline: none; /*for making it look nice in FF */
	background: url(images/font-down.png);
	text-indent: -9999px;
	display: block;
	float: left;
	width: 32px;
	height: 32px;
}
 
.defaultFont {
	/*if you want to hide the default font button, use display:none */
	background: url(images/font-default.png);
	text-indent: -9999px;
	outline: none;
	display: block;
	float: left;
	width: 32px;
	height: 32px;
}
 
.largeFont {
	background: url(images/font-up.png);
	outline: none;
	text-indent: -9999px;
	display: block;
	float: left;
	width: 32px;
	height: 32px;
}
 
.ldisabled,.sdisabled { /*Styles for disabled buttons*/
	opacity: 0.3;
	-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
	/*This is for IE8 */
	filter: alpha(opacity = 30);
}

As you can see I’ve used three background images for the three buttons. Need to set the display:block property as the buttons are of 32px height. I could have optimized the css more by applying common styles to elements. For eg: For the three styles only background is different, so it could’ve declared like the following.

 .smallFont, .defaultFont, .largeFont { 
.... /*common properties*/
}
 
.smallFont { background: url(...) } 
...

But I didn’t use that because it will be easier to declare as is now, if you want to use different sized images or different styles for each button.If you want to have multiple styles in the same page, just use the CSS scope

For eg:

 #container1 .smallFont { ... }
#container2 .smallFont { ... }

Now for the disabled state I used same style for all buttons. Using opacity filter is the easiest way to imitate a disabled button. Here for IE8, I have used an extra style after googling around.

The jQuery function

I didn’t write it as a jQuery plugin because I didn’t find it useful to have the chainable functionality.

function fontSize(container, target, minSize, defSize, maxSize) {
	/*Editable settings*/
	var minCaption = "Make font size smaller"; //title for smallFont button
	var defCaption = "Make font size default"; //title for defaultFont button
	var maxCaption = "Make font size larger"; //title for largefont button
 
 
	//Now we'll add the font size changer interface in container
	smallFontHtml = "<a href='javascript:void(0);' class='smallFont' title='" + minCaption +"'>" + minCaption + "</a> ";
	defFontHtml = "<a href='javascript:void(0);' class='defaultFont' title='" + defCaption +"'>" + defCaption + "</a> ";
	largeFontHtml = "<a href='javascript:void(0);' class='largeFont' title='" + maxCaption +"'>" + maxCaption + "</a> ";
	$(container).html(smallFontHtml + defFontHtml + largeFontHtml);
 
	//Read cookie &amp; sets the fontsize
	if ($.cookie != undefined) {
		var cookie = target.replace(/[#. ]/g,'');
		var value = $.cookie(cookie);
		if (value !=null) {
			$(target).css('font-size', parseInt(value));
		}
	}
 
	//on clicking small font button, font size is decreased by 1px
	$(container + " .smallFont").click(function(){ 
		curSize = parseInt($(target).css("font-size"));
		newSize = curSize - 1;
		if (newSize >= minSize) {
			$(target).css('font-size', newSize);
		} 
		if (newSize <= minSize) {
			$(container + " .smallFont").addClass("sdisabled");
		}
		if (newSize < maxSize) {
			$(container + " .largeFont").removeClass("ldisabled");
		}
		updatefontCookie(target, newSize); //sets the cookie 
 
	});
 
	//on clicking default font size button, font size is reset
	$(container + " .defaultFont").click(function(){
		$(target).css('font-size', defSize);
		$(container + " .smallFont").removeClass("sdisabled");
		$(container + " .largeFont").removeClass("ldisabled");
		updatefontCookie(target, defSize);
	});
 
	//on clicking large font size button, font size is incremented by 1 to the maximum limit
	$(container + " .largeFont").click(function(){
		curSize = parseInt($(target).css("font-size"));
		newSize = curSize + 1;
		if (newSize <= maxSize) {
			$(target).css('font-size', newSize);
		} 
		if (newSize > minSize) {
			$(container + " .smallFont").removeClass("sdisabled");
		}
		if (newSize >= maxSize) {
			$(container + " .largeFont").addClass("ldisabled");
		}
		updatefontCookie(target, newSize);
	});
 
	function updatefontCookie(target, size) { //Private function for setting cookie
		if ($.cookie != undefined) { //If cookie plugin available, set a cookie
			var cookie = target.replace(/[#. ]/g,'');
			$.cookie(cookie, size);
		} 
	}
}

I think the code is self explanatory. If you’ve any doubt in code, please feel free to ask here 

Usage

Include the css file, then after including jQuery include this script like the following (Don’t forget to change the path as required. Also, you need to copy the images in correct folder as specified in CSS file or edit the CSS file to make it correct.

<link rel="stylesheet" type="text/css" href="font-controller.css" />
<script src="jquery-1.2.6.pack.js"></script> 
<script src="font-controller.js"></script>
<script src="jquery.cookie.js"></script>

The function can be called inside a $document.ready() as usual. For eg:

fontSize("#container", "#content", 9, 12, 20);

Then inside your html create the empty container for holding the elements. Give it an ID or class, if possible ID.

<div id="container"></div> ... 
<div id="content">... Font size of this element can be controlled.... </div>

Do not copy paste the code from this page. Instead download the full demo from below link

Demo

View Demo | Download full demo

Please feel free to post your comments and suggestions for improvement

Color picker galore!

A color picker allows the users to preview the color and select it by clicking on it. It is useful when you want to provide some customization for the user (for eg: select a background color, letter color etc). But I think is a very useful piece of code in the admin side of a CMS site (Select font color, theme color or anything that you can imagine). There are simple scripts which generates a simple web safe color palette to advanced ones which generates a color palette like Adobe Photoshop.

Here are some cool color picker scripts that can be used. Some of them are written using plain javascript – means you don’t need any javascript library like jQuery, Mootools. And some of them are written specifically for jQuery, Mootools or Prototype (Here the advantage is a smaller footprint. If you’re already using a javascript library like jQuery or Mootools, use the one particularly written for that library). There are more than 10 scripts to choose from.

Plain Javascript scripts for Color picker

There were lot of scripts using plain javascript. Some are larger in size and some uses a popup window interface which is not Web 2.0 standard (It will be considered as an advertisement popup and will be blocked by most of the browsers). I selected three of them which are smaller in size and has the DHTML style popup or inine popup.

Use any of the following if you are not using a javascript library like jQuery or Mootools.

DHTML color picker from Free-color-picker.com

It can handle web safe colors and grays. Triggering can be customized in many ways. Files can be downloaded separately according to your needs. It also supports popup window. It is a small script – just around 8KB. But if you wan to show more colors, you can’t use it. Also, the license states that it should not be modified and the link to the site should not be altered.

DEPENDENCIESNone
SIZE8KB
RESTRICTIONSLicense states that script should not be altered. Also, the link should not be removed.
DEMOOpen | Open in new window
INFO & DOWNLOADOpen

jsColor

jscolor is JavaScript component extending standard form controls of the smooth color pickerpickerize your text fields

It is a good and very easy to use script when you want to show more colors.

DEPENDENCIESNone
SIZE24KB
RESTRICTIONSNone (GPL)
DEMOOpen | Open in new window
INFO & DOWNLOADOpen

Color Jack

It is the smallest of them all – just 3.5KB. Also this site has two other pickers Color Picker v2 and Color Sphere
. Choose one that matches your required style.

DEPENDENCIESNone
SIZE4KB
RESTRICTIONSNone
DEMOColor Sphere | Color Sphere 
Color Picker 1.0 | Color Picker 1.0 
Color Picker V2.0 | Color Picker 2.0
INFO & DOWNLOADOpen

Others

Color Pickers for jQuery

jQuery is a wonderful javascript library and the number of available plugins are growing rapidly. If you’re already using jQuery, choose a color picker from here.

Farbtastic color picker plug-in

Farbtastic: jQuery color picker plug-in

Farbtastic is a jQuery plug-in that can add one or more color picker widgets into a page through JavaScript. Each widget is then linked to an existing element (e.g. a text field) and will update the element’s value when a color is selected.
Farbtastic uses layered transparent PNGs to render a saturation/luminance gradient inside of a hue circle. No Flash, no pixel sized divs.

DEPENDENCIESjQuery
SIZE9KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Color picker by eyecon.ro

A simple component to select color in the same way you select color in Adobe Photoshop

  • Easy to use and looks good
  • Powerful controls for color selection
  • Easy to customize the look by changing some images
DEPENDENCIESjQuery
SIZE16KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Normal color picker by www.felecan.com

It is a lightweight color picker.

DEPENDENCIESjQuery
SIZELess than 5KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

jQuery color picker by Syronex

It is a simple color picker which is useful when you want to show a defined set of colors and the user should select only from them (For eg: To select a theme color in web sites).

DEPENDENCIESjQuery
SIZELess than 4KB
RESTRICTIONSNone (GPL)
DEMO & DOWNLOADOpen | Open in new window

Others

Color pickers for Mootools

Moo Rainbow

mooRainbow is a powerful Javascript color picker that allows you to visually choose and use colors as a real and useful application.

DEPENDENCIESMooTools
SIZE5KB
RESTRICTIONSNone (MIT License)
DEMO & DOWNLOADOpen | Open in new window

Mootools color picker by Sweetvision.com

The Color Picker displays a Hue selection bar Saturation/Value selection box, Text fields for entering HSV and RGB fields. The dialog for the color picker is drag-able and there are many actions that you can attach function calls to in order to allow your application to respond to events in the Color Picker. The size of the Hue Bar and the SV Box can be set to any size using options. The elements of the Color Picker can be styled to match the design of your site.

It supports two types of interface – a popup layer type and an in-place color picker

DEPENDENCIESMooTools
SIZE12KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Color pickers for Prototype

Color picker by John Dyer

It is a photoshop like color plugin built on prototype library.

DEPENDENCIESPrototype
SIZE10KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Prototype color picker by Myles Eftos

It is a simple color picker which support web safe palette.

DEPENDENCIESPrototype
SIZE5KB
RESTRICTIONSNone
DEMO & DOWNLOADOpen | Open in new window

Add icons to your links automatically using jQuery & CSS

You want to show a particular icon to a particular type of link. For eg: a pdf icon to all pdf file links, a text document icon to all text document links, zip icon to all links that are linked to zip files etc.

Why jQuery?

Yes, it is not that difficult with css. Just declare some classes and give background images then assign that class to the links as required. Then why we need jQuery. The answer is, for simplicity. Who ever entering the content should be cautious to add the right classes for the right links. Also adding classes are difficult in a blog platform – you will need to switch to HTML view instead of the editor view.

Using jQuery we’ll make sure that the right icon is showing for a particular link.

Step 1 – Find the right icons

Getting a free icon describing your file type is easy. You might need to search for free icon sets, or better search in any of the three following icon search engines. For eg: search for the term “pdf” and you will see a lot of images in different dimensions, select the one that suits your need. Just make sure you’re not using a copyrighted icon 

  1. Icon Look – http://www.iconlook.com
  2. Icon Let – http://www.iconlet.com
  3. Icon Finder – http:www.iconfinder.net

Here I am using five icons – One for pdf files, one for txt documents, one for zip files, one for email links and one for external links. You may add any number of icons for any file type as I am going to describe in the next sections.I’ve selected icons of 16px in size because it look better in content. If you need large icons, you will need to use the css display:block property.

CSS styles

Now we’ve have the right icons. Now we need to add classes with background image.

a.pdf { /*The background image*/
	background: url(images/pdf.png) no-repeat left center;
	padding-left: 20px;
	line-height: 16px; /* To center the text vertically with the icon */
}
 
a.txt { /*The background image*/
	background: url(images/txt.png) no-repeat left center;
	padding-left: 20px;
	line-height: 16px;
}
 
a.zip { /*The background image*/
	background: url(images/zip.png) no-repeat left center;
	padding-left: 20px;
	line-height: 16px;
}
 
a.email {
	background: url(images/email.png) no-repeat left center;
	padding-left: 20px;
	line-height: 16px;
}
 
a.external {
	background: url(images/ext_link.png) no-repeat left center;
	padding-left: 20px;
	line-height: 16px;
}

Eg:

 
.download a.zip { /*The background image*/
	background: url(images/zip.png) no-repeat left center;
	height: 48px;
	padding-left: 55px;
	line-height: 48px; /* Center the text vertically with image */
	vertical-align: bottom; /* to align the text with image bottom, line height property required */
	display: block; /* Need this to show the images fully */
	float: left; /* You might need this as well for aligning it with the parent element */
}

JQuery

Now, we can write the jQuery statements.

$(document).ready(function() {
 
 
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf");
 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
 
	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
 
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");
 
	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external");
	//You might also want to set the _target attribute to blank
	/*
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");
	*/
});

For determining the links, we’re using jQuery’s attribute syntax. For eg: To identify PDF links, we check whether the href attribute ends with a ‘.pdf’ extension.

To find external links we’ll compare the anchor tag’s host name with the location host name

Do not copy paste from the above code. It is formatted for viewig. Please download the full source code at the end

demo

It will look like the below image. For an actual demo check the below links.

jQuery seekAttention plugin to get the users attention


The “seekAttention” plugin gracefully get’s your users attention by fading out a definable area but leaving the target element (the element which is seeking attention) un-faded and thereby focusing the users attention on it.

The definable area (to be called “container” from this point forward) can be the entire page or any element which surrounds the target element and the colour which overlays the container can also be defined by you.

This plugin can be useful for web based tutorials or in forms (May be in validation).

DEPENDENCIESjQuery
SIZE5KB (compressed)
RESTRICTIONSNone
DEMO & DOWNLAODOpen | New window