background preloader

jQuery

Facebook Twitter

Customize checkboxes and radio buttons with iCheck (jQuery and Zepto) plugin. iCheck plugin works with checkboxes and radio buttons like a constructor. It wraps each input with a div, which may be customized by you or using one of the available skins. You may also place inside that div some HTML code or text using insert option. For this HTML: <label><input type="checkbox" name="quux[1]" disabled> Foo </label><label for="baz[1]">Bar</label><input type="radio" name="quux[2]" id="baz[1]" checked><label for="baz[2]">Bar</label><input type="radio" name="quux[2]" id="baz[2]"> With default options you'll get nearly this: <label><div class="icheckbox disabled"><input type="checkbox" name="quux[1]" disabled></div> Foo </label><label for="baz[1]">Bar</label><div class="iradio checked"><input type="radio" name="quux[2]" id="baz[1]" checked></div><label for="baz[2]">Bar</label><div class="iradio"><input type="radio" name="quux[2]" id="baz[2]"></div> By default, iCheck doesn't provide any CSS styles for wrapper divs (if you don't use skins).

Options These options are default: Overflow Image with vertical centering for Responsive Web Design. If you want to use an image in your responsive web design you can use fluid images. But there is another way. You can set a maximum height and crop the image. So how does this work? It's simple. Just put your image in a container and set the width of your image to 100%. If you now change the width of the container, you will see that the image adapts the container's width but does not exceed the max-height. Now you have a cropped image that adapts the width of your container.

To do this you can use JavaScript (jQuery). Margin-top = (container height - image height) / 2 Then call a JavaScript function on the events load, resize and here comes the special: "transitionend". So just use a CSS transition to change the max-width and you can fire the callback function when the transition ends. You can use a CSS transition for the margin-top of the image to make it smooth. That's it. PS: It would be great to see a solution for this technique with CSS only. Automatic Image Montage with jQuery.

Arranging images in a montage like fashion can be a challenging task when considering certain constraints, like the window size when using fullscreen, the right image number to fill all the available space or also the size of the images in use. With the following script you can automatically create a montage, either for a liquid container or a fixed size container (including fullscreen), with the option to fill all the gaps. View demo Download source Having a white space in the end of the container can, as well, be avoided optionally. The last image of the montage can fill the left space, so that the montage will be left gap-less. Another option that can be useful in some cases is the possibility to only allow that the height of all images will be the height of the smallest image, avoiding that any picture gets pixelated/enlarged.

(The default options will allow the enlargement of smaller images if there is a significantly higher number of larger images in the set.) The HTML structure. Apprise - The attractive alert alternative for jQuery. The initial release of Apprise has been a major success and is often what this site is most commonly associated with. As far as I've been able to track, Apprise has been downloaded over 23,000 times and has been mentioned in over 46,000 blogs. Which is fantastic, especially for something that I've never been very proud of.

I've wanted to update, and change the UI, of this for over a year now. Time has finally permitted and it's, finally, ready. Demos Let's get right down to business. Pretty slick, right? Let's take a peak at the default settings before we change the options around a bit. You'll notice that the buttons are completely customizable and can easily be altered using your own CSS rules. Let's try another demo, but changing the settings around a bit. We're going to use a custom CSS class on our confirm button. You'll see the custom blue button with it's custom text, as well as a goofy little callback function that populates the field below: Response: Using. Visual Event. When working with events in Javascript, it is often easy to lose track of what events are subscribed where. This is particularly true if you are using a large number of events, which is typical in a modern interface employing progressive enhancement.

Javascript libraries also add another degree of complexity to listeners from a technical point of view, while from a developers point of view they of course can make life much easier! But when things go wrong it can be difficult to trace down why this might be. It is due to this I've put together a Javascript bookmarklet called Visual Event which visually shows the elements on a page that have events subscribed to them, what those events are and the function that the event would run when triggered. This is primarily intended to assist debugging, but it can also be very interesting and informative to see the subscribed events on other pages.

Using Visual Event on any web-page is extremely simple: Highcharts - Interactive JavaScript charts for your webpage. Useful JavaScript and jQuery Tools, Libraries, Plugins - Smashing Magazine. Advertisement Recently we’ve been receiving more requests for carefully selected, useful round-ups. We try to avoid round-ups on Smashing Magazine, but sometimes the format is useful and — if the resources are relevant — can be extremely helpful.

Besides, we are glad to drive traffic to some obscure, yet useful resources and thus support the developers of these resources. In this round-up, you’ll find some of the useful JavaScript and jQuery tools, libraries and plugins that we have stumbled upon recently. You might want to take a look at the following related posts: Useful JavaScript Libraries Respond.js: Fast CSS3 Media Queries for Internet Explorer 6-8 and More5The goal of this script is to provide a fast and lightweight script to enable responsive Web designs in browsers that don’t support CSS3 Media Queries.

Blackbird: Open Source JavaScript Logging Utility6Blackbird offers a dead-simple way to log messages in JavaScript and an attractive console to view and filter them. SlickGrid! Making a Custom Facebook Wall with jQuery Templates. Martin Angelov In this tutorial, we are going to create our own version of Facebook’s wall. We will be using Facebook’s Graph API with jQuery, and the template plugin. The jQuery.tmpl plugin will allow us to define templates within our page, and convert the posts we’ve obtained from the API into a real HTML page. You can use today’s example to display a feed of the latest posts on your FB page or profile on your website. Before we begin, lets say a few words about the Facebook API. Update on June 19th, 2011: Recently Facebook introduced some changes to their API that broke this script. The Graph API The Graph is Facebook’s solution to providing an interface to every object that exists in the site, along with its connections to other objects.

We will be using two API datapoints – one for selecting the latest posts, and the other for selecting the full name and avatar of the page. Custom Facebook Wall with jQuery. Sticky Sidebar jQuery plugin | Phil Parsons. This jQuery plugin allows you to set a number of sidebar or floating boxes that follow the user down the page as they scroll. The plugin uses absolute positioning calculated from the original css and offset to either the closest positioned parent or to the document. The plugin has been tested in IE6-9 and all the other major browsers. The JavaScript (jQuery) Below is the code for the plugin, to download the code with examples use the link above. Usage The plugin can be used for single or multiple boxes as shown in the examples below A Single sticky sidebar For the above snippet of a HTML page we can use the following to enable the product basket as a sticky sidebar with the default options.

Multiple sticky boxes For the above example we can use the below to set the navbox and basket boxes to both be sticky sidebars with the same options. Options The Sticky Sidebar plugin has four options: Methods The Sticky Sidebar plugin has two methods: Sausage.js. Better Check Boxes with jQuery and CSS. Martin Angelov In this short tutorial, we will be creating a replacement for the default browser checkboxes in the form of a simple jQuery plugin.

It will progressively enhance your forms but at the same time fall back to the default controls if JavaScript is unavailable. The first step is to lay down the structure of the underlying HTML document. We will need a form with checkboxes which we will later be replacing with their enhanced jQuery versions. index.html <! The main container element – the #page div, holds our form. Notice the HTML5 data attributes, specified on some of the labels. And here is the markup of our replacement checkboxes: <span class="tzCheckBox checked"><span class="tzCBContent">ON</span><span class="tzCBPart"></span></span> When our plugin is called, it will loop through the checkboxes, and insert the HTML code you can see above after each one, while at the same time hiding the original.

Checkbox Replacements Explained Now lets move on to the styling. jQuery Conclusion. jQuery Quicktag.