Posts Tagged ‘jquery’

20 of the Best jQuery Slideshow Plugins

Get a free icon and vector bundle (worth $54) just for subscribing to our weekly newsletter!

jQuery sliders, slideshows, and galleries are extremely common on a variety of different types of websites. Portfolio sites, blogs, e-commerce sites, and about any type of site can make use of a jQuery slideshow. Fortunately, there are a number of great plugins already coded that make it easy to add a slideshow in a matter of minutes. Each one offers different features and has it’s own style. In this post we’ll showcase 20 jQuery plugins that you may want to use for adding a slideshow in your own projects.

Slides
Slides is a jQuery slideshow plugin built for simplicity.Features include captions, multiple slideshows, and more.

Slides

jQuery.popeye
jQuery.popeye is an inline lightbox alternative with slideshow. Unlike lightbox plugins, jQuery.popeye doesn’t use modal windows to display images.

jQuery.popeye

jQuery Cycle Plugin
jQuery Cycle offers several different types of transition effects to choose from, including shuffle, zoom, fade, and more.  It supports pause-on-hover, auto-stop, auto-fit, before/after callbacks, click triggers and much more.

jQuery Cycle Plugin

Nivo Slider
One of the most popular options for jQuery sliders/slideshows, Nivo Slider includes 16 different transition effects, customizable settings, keyboard navigation, and it is released under the MIT license. It’s also available as a WordPress plugin (for purchase).

Nivo Slider

TN3 Gallery
TN3 Gallery is a feature-rich slideshow plugin. It is a premium plugin ($37 for a single-site license) that also offers a free Lite version. The Lite version includes features like transition effects, fullscreen options, and optional captions, but it does not include other features from the Pro version including fullscreen keyboard navigation, multiple galleries on the same page, mousewheel navigation, dynamic image sizing, and more.

TN3 Gallery

Pikachoose
Pikachoose is a lightweight jQuery slideshow plugin with features like tooltips and fancybox support. Four premium themes are available for purchase.

Pikachoose

Coin Slider
Coin Slider is released under the MIT license and includes features like unique transition effects, flexible configuration, Android and iPhone compatibility, and more.

Coin Slider

Galleria
Galleria and its classic theme are released under the MIT license. It includes features like scaling images, touch screen support, and optional premium themes to improve the look of your slideshow.

Galleria

Orbit
Orbit is a lightweight slideshow plugin from Zurb.  It features simple implementation, optional captions and links, optional bullet navigation, and more.

Orbit

Supersized
Supersized is a full screen background slideshow plugin. It’s ideal for photography portfolios and other sites that rely on large images and photos.

Supersized

slideViewer
slideViewer is a lightweight jQuery plugin that allows you to implement a slideshow with a simple unordered list.

slideViewer

Advanced jQuery Background Image Slideshow
Originally a tutorial on Marcofolio, this was later converted to a plugin.  It allows you to use a full-screen slideshow as the back for a website.

Advanced jQuery Background Image Slideshow

Simple Controls Gallery v1.4
Simple Controls Gallery allows you to display images as an automatic or manually-controlled slideshow.

Simple Controls Gallery v1.4

s3Slider jQuery Plugin
s3Slider allows you to implement a simple slideshow with image captions.

s3Slider jQuery Plugin

Easy Slider
Easy Slider, from CSS Globe, is a versatile plugin that allows options like manual controls, vertical sliding, continuous sliding, and more.

Easy Slider

ColorBox
ColorBox is a lightweight, customizable lightbox and slideshow plugin.

ColorBox

simpleSli.de
simpleSli.de is lightweight slideshow plugin that comes in two versions, Big Boy (15KB) and Mini (6KB).

simpleSli.de

Skitter
Skitter allows you to implement a slideshow with a simple unordered list.  It includes several animation types, navigation options, and more.

Skitter

ResponsiveSlides.js
ResponsiveSlides.js is a lightweight responsive slideshow plugin. You can use it to create a slideshow that automatically fades from one photo to the next, or you can include manual controls.

ResponsiveSlides.js

Sideways
Sideways is a simple, elegant full-screen image gallery plugin.

Sideways

For more resources please see:

Royalty-Free Graphics

Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

In our earlier jQuery Mobile tutorial I had introduced much of the underlying framework and how to go about setting up your first website. The JS library is both lightweight and easy to pickup in regards to learning difficulty. There is also generic a CSS stylesheet included with the files so you can further customize the elements in your layout.

jquery mobile custom themes Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

For this second segment I’d like to spend a bit of time delving deeper into this idea of jQuery Mobile themes. The entire design industry has been revolutionized by jQM and the process of constructing a mobile template from scratch has been significantly improved. jQuery Mobile isn’t just a scripting library, but an entire ground framework to build upon and produce efficient mobile templates.

Default Stylesheet Contents

I should begin by clarifying exactly what type of CSS code is included with the default files. The stylesheet from jQM 1.0 has been split into two main segments – structure and themes.

The structure code is the stuff you can mostly ignore. This is used to set margins, padding, height/width, font variants, along with many other browser defaults. The internal themes are then split up from A-E which each control different visual effects in your design. This can include background colors, gradients, drop shadows, etc.

Each of these inner theme elements can also be referred to as swatches. When you build a mobile template you’ll generally stick with a single theme. But in almost every scenario the design can be improved upon with differing color schemes. The default stylesheet only includes swatches A-E but you can build swatches F-Z to add another 21 alternatives into your theme library. Just to clarify these terms again a theme is considered 1 single CSS file which can include up to 26 different swatches labeled A-Z.

Switching Styles

If you don’t choose to specify any swatches then jQuery Mobile will stick to the swatch A by default. If you weren’t already aware the jQuery Mobile docs utilize HTML5 data attributes for many internal functions. One of these includes changing swatches via the data-theme attribute. Check out my code example below to see what I mean.

<div data-role="page" id="mypage" data-theme="b">
  <div data-role="header">
    <h1>Default jQM Page</h1>
  </div>
  <div data-role="content">
    <p>Here is some internal content.</p>
    </div>
</div>

Notice that I placed the data-theme attribute on the root page div. This means the new swatch color will effect everything inside which includes both the header and content areas. I could additionally include data-theme="c" into the header div to change only that content from the rest of my page.

Components of a Swatch

It should be fairly straightforward how to implement these different swatches within a single layout. So now let’s take a look at the jQM CSS code so we can break down individual components of a swatch. Check out the latest jQuery Mobile 1.0 CSS file hosted on their own CDN.

You should notice how each swatch is separated by a distinct comment and each of the internal classes ends with the appropriate lettering. For example .ui-bar-a and .ui-body-a are applied into the header/footer bars and content areas by default. Most properties are implementing a reset on font and link colors, background gradients, and other small details. I included simply the ui-bar-a codes to give you an idea of which elements we target.

/* A
---------------------------------------------------------------------------------------------*/
.ui-bar-a {
	border: 1px solid #2A2A2A;
	background: #111111;
	color: #ffffff;
	font-weight: bold;
	text-shadow: 0 /*{a-bar-shadow-x}*/ -1px /*{a-bar-shadow-y}*/ 1px #000000;
	background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#111)); /* Saf4+, Chrome */
	background-image: -webkit-linear-gradient(#3c3c3c, #111); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(#3c3c3c, #111); /* FF3.6 */
	background-image:     -ms-linear-gradient(#3c3c3c, #111); /* IE10 */
	background-image:      -o-linear-gradient(#3c3c3c, #111); /* Opera 11.10+ */
	background-image:         linear-gradient(#3c3c3c, #111);
}
.ui-bar-a,
.ui-bar-a input,
.ui-bar-a select,
.ui-bar-a textarea,
.ui-bar-a button {
	font-family: Helvetica, Arial, sans-serif;
}
.ui-bar-a .ui-link-inherit {
	color: #fff;
}

.ui-bar-a .ui-link {
	color: #7cc4e7 /*{a-bar-link-color}*/;
	font-weight: bold;
}

.ui-bar-a .ui-link:hover {
	color: #2489CE /*{a-bar-link-hover}*/;
}

.ui-bar-a .ui-link:active {
	color: #2489CE /*{a-bar-link-active}*/;
}

.ui-bar-a .ui-link:visited {
    color: #2489CE /*{a-bar-link-visited}*/;
}

If you’re just looking to create a custom swatch I recommend basing the template off one of the originals. The process will go a whole lot smoother if you start writing codes in a new CSS document. You won’t have the hassle of editing in the original file and you can start off working on a clean slate. But the key areas you want to focus on will include the following:

  • header and footer bars
  • body content & page text
  • list styles
  • button states default/hover/active
  • form input controls(extra)

Coding a New Bar Design

From the same CSS file we looked at earlier copy/paste all the swatch A code(lines 12-150) into a new file. We can use the swatch name G to implement these new styles. Now after copying the code you want to rename each class instance ending in -a to -g, as this is how jQuery Mobile will recognize which styles to use.

I’d like to start by redesigning the header bar bg to mimic a more familiar iOS gradient. This can be done solely within the .ui-bar-g selector. We want to edit the background and background-image properties to change up the gradient effects. Check out my code below and a demo screen of the new gradient.

.ui-bar-g {
	border: 1px solid #2d3033 /*{a-bar-border}*/;
	border-left: 0px;
	border-right: 0px;
	background: #6d83a1;
	color: #fff /*{a-bar-color}*/;
	font-weight: bold;
	text-shadow: 0 /*{a-bar-shadow-x}*/ -1px /*{a-bar-shadow-y}*/ 1px /*{a-bar-shadow-radius}*/ #3e4957;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#b4bfce), color-stop(0.5, #899cb3), color-stop(0.505, #7e94b0), to(#6d83a1));
	background-image: -webkit-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* IE10 */
	background-image:      -o-linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #b4bfce, #899cb3 50%, #7e94b0 52%, #6d83a1);
}

blue ios jquery mobile gradient Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

I’m using the blue color scheme found in most default iOS applications. My background is initially set to a solid color for devices which can’t render CSS3 gradients. Then below I’m using color stops around the 50% marker to recreate the traditional Apple-style glossy shine effect. Also inside the same selector I’ve slightly modified the text shadow with a more subtle color and range.

Buttons and Text Effects

It’s important when coding swatches to consider specifically which areas of the interface need attention. The header bar looks great with this new background, but one last modification I’d like to make will match the button styles closer to that of iOS apps.

.ui-btn-up-g {
	border: 1px solid #375073;
	background: #4a6c9b;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 /*{a-bup-shadow-x}*/ -1px /*{a-bup-shadow-y}*/ 1px /*{a-bup-shadow-radius}*/ #40536d;
	box-shadow: none;
	-webkit-box-shadow: none;
	-moz-box-shadow: none;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#89a0be), color-stop(0.5, #5877a2), color-stop(0.505, #476999), to(#4a6c9b));
	background-image: -webkit-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* IE10 */
	background-image:      -o-linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #89a0be, #5877a2 50%, #476999 52%, #4a6c9b);
	border-radius: 4px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
}

.ui-btn-up-g .ui-btn-inner, .ui-btn-hover-g .ui-btn-inner, .ui-btn-down-g .ui-btn-inner { border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; }
.ui-btn-hover-g {
	border: 1px solid #1b49a5;
	background: #2463de;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 /*{a-bup-shadow-x}*/ -1px /*{a-bup-shadow-y}*/ 1px /*{a-bup-shadow-radius}*/ #40536d;
	box-shadow: none;
	-webkit-box-shadow: none;
	-moz-box-shadow: none;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#779be9), color-stop(0.5, #376fe0), color-stop(0.505, #2260dd), to(#2463de));
	background-image: -webkit-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* Chrome 10+, Saf5.1+ */
	background-image:    -moz-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* FF3.6 */
	background-image:     -ms-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* IE10 */
	background-image:      -o-linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de); /* Opera 11.10+ */
	background-image:         linear-gradient(top, #779be9, #376fe0 50%, #2260dd 52%, #2463de);
	border-radius: 4px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
}

jqm topbar with buttons Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

The code area we’re editing now is within the UI button classes. There are 3 different modes to be concerned with: .ui-btn-up-g, .ui-btn-hover-g, and .ui-btn-down-g. I’m mostly focusing on the standard(btn-up) and hover(btn-hover) effects by editing the box shadow and linear gradients. Also I expanded the rounded corners effect so the buttons appear more rectangular.

Because of this I’ve needed to remove the inner border radius from a class titled .ui-btn-inner. This class gets attached onto a span element within each anchor link in your header bar. Without resetting the border radius properties you’ll notice small glitches in the design whenever you hover over a button. As you spend more time coding in jQuery Mobile themes you’ll memorize these little nuances for future projects.

Introduction to ThemeRoller

If you enjoy getting your hands dirty in code then I highly recommend sticking to custom edits. Not only do you have more control but it’s a lot easier to debug issues within the CSS if you made all the edits yourself. But for many designers this process is tiresome and will simply take longer than necessary. Luckily the jQuery Mobile team has released an online editor under the name ThemeRoller.

jquery themeroller Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

From this page you have access to edit the first 3 A-C swatches or even create one of your own. If you look in the left sidebar you can switch between these 3 settings or quickly make changes to the global theme options. These include CSS properties such as border radii, box shadows, or default page fonts. Notice as you select any of the preset swatches that we can edit only the same areas as before – top/bottom bars, body content, and the 3 button states.

adobe kuler Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

But my favorite feature has to be the direct access to Adobe Kuler swatches. You can actually create a few color schemes within your Kuler account and import them into ThemeRoller. The interface supports drag-and-drop functionality so it’s real simple to try out a few different ideas in a matter of minutes.

Ultimately there is no absolute method of properly building your jQM swatches. Some designers prefer to hard code CSS while others will love the intuitive ThemeRoller web app. As long as you’re following the class structure then you should get the same results either way. If you want to read up a bit on ThemeRoller check out this featured jQuery Mobile blog post regarding their newest web tool and its many features.

Helpful Resources

Mobile Design Showcase

What better way to wrap up our guide to jQuery Mobile themes than with a small inspiration showcase? Hundreds of web designers have submitted their themes into the jQM Gallery with some notable success. Check out these astounding mobile templates below which will hopefully stir up your own creative ambitions. And be sure to let us know your thoughts or questions in the post discussion area.

Thumbpark

01 thumbpark Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Elfster

02 elfster Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Let’s GO! Gorizia

03 lets go gorizia Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Woos.at

04 woost Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

iFilmtipset

05 ifilm tipset Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

BAMM.TV

06 bammtv Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Untappd

07 untappd Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

IOUMate

08 ioumate Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Disney Dream Portraits

09 disney dream portraits Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Cookpad

10 cookpad Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Dailymotion

11 dailymotion Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

American Century

12 american century Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Travel Wisconsin

13 travel wisconsin Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Tuscan Maremma

14 tuscan antico casale Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

My Shopping List

15 shopping list Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

twwit

16 twwit Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Take Me Fishing

17 take me fishing Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Lawline Mobile

18 lawline Building Websites and Browser Apps with jQuery Mobile: Designing Custom Themes

Benefits and Pitfalls of Using Code Frameworks

Advertise here with BSA


A code framework is nothing more than a collection of pre-formatted classes and functions. There are frameworks created for practically every language out there – even including frontend web development like JavaScript and CSS. Developers would be wise to follow these trends of working on top of pre-built code.

There are reasons both for and against building on top of web frameworks. You need to spend time learning the code and adjust your website accordingly. But in the long run you’ll save a lot of frustration as many common features are already created for you! Let’s delve into these ideas a bit more and consider some of the most popular frameworks today.

Improvements for Web Developers

Building products for the web can be one of the toughest development jobs. Rules are not set as standards in the same way Windows or Mac OSX programmers follow. Web developers need to work on a server architecture, generally writing in a backend programming language such as PHP or Ruby on Rails.

PHP is by far the most recognized development language for creating dynamic websites. You can build snappy applications working with databases in a short amount of time. And the new PHP5 specs have included a whole slew of additional functionality. The benefits of working on PHP frameworks means you don’t need to start from the very beginning. It can be stressful to include a set of 3rd party libraries and build up your own system from scratch.

Happy Wintertime Snowman

But there are plenty of alternative PHP libraries which each focus on a different set of functions. Some may help you setup a simple blog, backend CMS, social network, or a handful of other common templates. And when you build upon open-source frameworks you’ve actually got a whole community of developers behind you for support.

Model-View-Controller

The MVC hierarchy is crucial to understand when building with frameworks. If you have ever coded software or applications before then developing for the web seems very cryptic. MVC doesn’t appear to make much sense on a standard web page.

However when you include a database connection the functionality of a framework starts to take form. You have a model of functions crunching information to save/pull from the database. Then you have a view of HTML/CSS styles on the frontend, along with a controller generally represented by forms or inputs on the page.

industrial smokestack for business

Frameworks which follow the MVC coding style are generally a lot faster and easier to debug. You know exactly where to look for errors and bugs within the code. It also naturally separates the backend programming from your frontend design view. Because of this, much of the code you find online will also likely work on your own site.

There is a lot of room for recycling code to use on a similar project. This can save you loads of time as a developer and many hours of debugging!

Focus on Custom Functionality

When you start coding with a framework it allows you to jump right into the detailed programming functions of your own project. Since all the ground work is already setup you don’t need to rewrite any of the basics. If you understand the basics this can provide an immensely helpful system.

Most code sources are extremely reliable and thoroughly checked for bugs. This allows you to develop out with your own models, following a similar syntax as the framework itself, without any unnecessary worries. If you enjoy writing code from scratch then this method is not likely to suit you. But the expendable nature of these frameworks means you can write code externally and port it over into the model.

CakePHP Coding backend framework

Or in many scenarios you can actually build out a custom module! Not all frameworks support the plug-and-play mentality. Yet it is a fairly common feature even among some frontend libraries. jQuery is the first which comes to mind featuring dozens of techniques for building your own plug-in. The web development framework Alloy is also modular and written for PHP 5.3+ environments.

Examples of PHP Frameworks

When just getting started you want to stick with something reliable and easy to use. Newbies just getting into frameworks will enjoy Zend or CodeIgniter.

home page design for CodeIgniter

Both of these projects have been under development for a few years. The PHP community is very adapted to their code style, so you will not likely have a difficult time solving problems. But if you start on any of these I highly recommend skimming their documentation pages first! This will give you an idea of how these frameworks behave, and if you can even utilize them.

Below are just a couple ideas for enticing PHP frameworks to check out. I have been a fan of CakePHP in the past, although I mostly work with custom CMS’ these days.

  • CakePHP – A very flexible option for newbies. There is no configuration edits or custom code required – just install the database and Cake is good to go. The whole development team is very knowledgeable and willing to help with issues. There are also a handful of published books geared towards explaining common Cake trends. Check out the CakePHP training videos online if you want to learn more.
  • Recess – A RESTful PHP framework for newbies and advanced programmers alike. Recess is lightning fast, super easy to learn, and perfect to install on a standard LAMP server environment.
  • Adroit – A lightweight PHP5 framework to get you developing faster! The core is built around an MVC hierarchy and utilizes the Smarty template engine. It’s also a breeze to implement your own Ajax calls between the database and frontend view.
  • Flourish – More of a general object-oriented library for coders. With this modular framework you aren’t limited to the MVC paradigm, although it is an option. The code is very secure and provides tons of examples on their website.
  • Yii Framework – A much more detailed framework for web developers. Yii allows you to rapidly prototype dynamic features such as user authentication, Ajax calls, caching, custom themes, and a whole lot more. Check out their full list of features on the website.

CSS Design Bundles

Code frameworks started out popular in the areas of backend development. Both software programmers and web developers have been utilizing these for years. But now there are countless frontend developers releasing their own design frameworks.

CSS is by far the go-to style language for the web. You can mockup an entire web page with fonts, colors, content boxes, alignments, and tons of other effects – all without touching the HTML. It’s a brilliant coding system which has revolutionized the field of web development(especially with HTML5).

Tokyo Japan at Night

CSS libraries can save you even more hardships on coding frontend. There are code frameworks which work on CSS grid systems, resetting browser defaults, dynamic webpage fonts, and a few other nifty concepts. Best of all many of them are free to download and come with an open-source developers license.

Common Recommendations

In the list below I’ve compiled some of my favorite CSS frameworks. This list will not be useful for everyone as not all developers enjoy using these code libraries! I admit that at times it’s just easier to write all your own code from scratch.

But when you really need to shave time off a project there’s no better solution than these libraries. Most can be downloaded and forked on GitHub from the original author. If we skipped over any good ones let us know in the post comments!

Conclusion

I hope this article has paved the way for some interested developers to get started using frameworks. In the modern era it has never been easier to get moving building a website. There are many open source databases of code you can start working on which are scalable in the long term.

Don’t try to push yourself into a single framework on the first day. I find it’s best to tread the waters a bit and try out a couple different names. See if there are any which fit your needs best, as different developers need different tools to work with. Whether coding frontend or backend you’ll slowly develop a sense of trust with these frameworks. Not only do they make your job easier, they provide a stable grounding for nearly any project you create in the future.

You might also like…

CSS Form Templates, Tools & Services →
40 Professional and Detailed Web Layout PSD Templates →
25 Completely Free Fonts Perfect for @fontface →
Liquid, Fluid and Elastic Layout Templates, Tools and Frameworks →
30 Pure CSS Alternatives to Javascript →
40 Essential CSS Templates, Resources and Downloads →
Website Speed Part 1: Write More Efficient CSS →
50 Free Tools and Apps for Web Designers and Developers →
CSS3 Compatibility Tools, Resources and References for Internet Explorer →
10 Online Tools and Apps to Help Optimize and Format CSS →
50 Useful Tools and Generators for Easy CSS Development →


Advertise here with BSA


Building Websites and Browser Apps with jQuery Mobile: A Beginner’s Guide

Over the past 2-3 years we’ve seen a tremendous growth in browser and OS support for mobile websites. Most notably Apple’s iOS and Google’s Android platforms come to mind. But others such as PalmOS and Blackberry are still in the mix. Up until recently it was very difficult to match a single mobile theme into all of these platforms.

jquery mobile Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

JavaScript was a start, but there hasn’t been any truly unified library until now. jQuery Mobile takes all the best features of jQuery and ports them over to a mobile-based web source. The library is more like a framework which includes animations, transition effects, and automatic CSS styles for basic HTML elements. In this guide I hope to introduce the platform in a way that you can feel comfortable designing your own jQuery mobile apps.

Features & OS Support

The reason I suggest learning jQuery Mobile over any other frameworks is simplicity. The code was built on the jQuery core and has an active team of developers writing scripts and editing bugs. Of the many features include HTML5 support, Ajax-powered navigation links, and touch/swipe event handlers.

jquery mobile support Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

Support is varying between phones and is broken into a chart of 3 categories from A-C. A is the top tier which boasts full support of jQuery Mobile, B has everything except Ajax while C is basic HTML with little-to-no JavaScript. Luckily most of the popular operating systems are fully supported – I added a list below of just a few examples.

  • Apple iOS 3-5
  • Android 2.1, 2.2, 2.3
  • Windows Phone 7
  • Blackberry 6.0, Blackberry 7
  • Palm WebOS 1.4-2.0, 3.0

If you want to learn more try reading up on their official docs page. It’s not written in gibberish and actually feels very easy to follow along. Now let’s focus on the basics of writing a jQuery mobile page and how we can build a small application!

The Standard HTML Template

To get your first mobile app working there is a set template you should start with. This includes the jQuery base code along with the mobile JS and CSS, all external hosted from the jQuery CDN. Check out my example code below.

<!DOCTYPE html>
<html>
	<head>
	<title>Basic mobile app</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  

	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css">
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
	<script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
</head>
<body> 

</body>
</html>

The only foreign elements here should be the two meta tags. The top viewport tag updates mobile browsers to use a full zoom effect. Setting the value width=device-width will set the page width at exactly the width of the phone screen. And best of all it doesn’t disable the zoom features since jQuery Mobile can adapt to shifting layouts.

The next meta tag X-UA-Compatible just forces Internet Explorer to render the HTML in it’s most recent iteration. Older browsers and especially mobile will try to get around unfamiliar rendering bugs.

Constructing the Body Content

Now this is where jQuery mobile can get tricky. Each HTML page isn’t necessarily 1 page on the mobile site. The framework makes use of HTML5′s data attributes, which you can create at a whim by appending data- beforehand. In a similar fashion data-role="page" can be set to multiple divs in a single HTML file, giving you more than one page.

You would then move between these pages with anchor links and a unique ID. This setup is a good idea for basic, simple apps. If you only need 3-5 pages then why not store it all in a single file? Unless you have a lot of written content, in which case try using PHP includes to save time.

Check the code example below if you’re lost.

<body>
<div data-role="page" id="index">
	<header data-role="header">
		<h1>Top title bar</h1>
	</header>

	<div data-role="content">
		<h3>Show another page??</h3>
		<p>hint: click the button below!</p>
		<p><a href="#about" data-role="button" data-theme="c">About us</a></p>
	</div>

	<footer data-role="footer">
		<h2>&copy; footer here.</h2>
	</footer>
</div>

<div data-role="page" id="about">
	<header data-role="header">
		<h1>Page 2 Here</h1>
	</header>

	<div data-role="content">
		<p>just some extra content as well.</p>
		<p>I mean, you can <a data-rel="back" href="#index">go back</a> at any time.</p>
	</div>
</div>
</body>
</html>

Take a look at the anchor link from the index page for a moment. Notice I added the attribute data-role="button" to setup the link as a button. But instead of using the default styles we include data-theme="c". This switches between 1 of 5(themes a-e) templates which come packaged by default as CSS styles within jQ Mobile.

jquery mobile themed buttons Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

My button also spans the entire page width. To remove the behavior we need to set the element from block to inline display. The attribute for doing this is data-inline="true" which you could append onto any anchor button.

Header and Footer Bars

Along the very top and bottom of your applications you should append header and footer content. This design style is often attributed with iOS apps which first became popular using Apple’s mobile App Store. jQ Mobile uses attributes of data-role to define the header, footer, and page content. Let’s take a brief look at these areas.

Top Bar Buttons

By default the top bar supports a set of two(2) links in a similar fashion to other mobile apps. iOS defaults to using a “back” button to the left and often an “options” or “config” on the right.

<div data-role="page" id="about" data-add-back-btn="true">
	<header data-role="header">
		<a href="index.html" data-icon="gear" data-theme="b" class="ui-btn-right">Settings</a>
		<h1>Page 2 Here</h1>
	</header>

The code above is just focusing on the div container for our About page along with header content. The additional HTML attribute data-add-back-btn="true" will only work when added onto a page data role. The purpose is to automatically include a back button which works similar to your browser’s back button.

jquery tabs back button Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

We could have added a back button manually with similar code as we used in the content area. But I feel this takes a lot longer to setup especially on multiple pages. All anchor links within the header section will default into left/right button positions. By using class="ui-btn-right" this re-positioned my Settings button so there is free space for the back button. Also I’m using the secondary theme styles to give it some extra spunk!

Footer Navigation

The footer area many not feel very useful at first. It’s a place where you can store copyright stuff and more important links, but this could just as easily be added at the bottom of your content area. So what good is using the footer?

Well the best example I’ve seen utilizes footer space as a navigation system where tab links appear to control the page navigation. There are plenty of options where you can select fullscreen effects, add icons, adjust placement, and a few other attributes as well. But let’s just build a simple footer nav with 3 buttons to get an idea of how this works.

[Preview Live Demo]

<footer data-role="footer" class="ui-body-b">
	<div data-role="navbar">
		<ul>
			<li><a href="#index" data-direction="reverse">App Homescreen!</a></li>
			<li><a href="http://www.google.com/" data-rel="external">Google Me</a></li>
			<li><a href="http://www.hongkiat.com/" data-rel="external">Hongkiat Blog</a></li>
		</ul>
	</div>
</footer>

So here is some footer code for the about page section. data-role="navbar" should be added onto the container element housing an unordered list and NOT the UL element itself. Each link within the list is treated as a tab bar, which then gets equally divided based on the total number of links. The additional class of ui-body-b just adds aesthetic effects as we switch between the few available styles.

ios path app nav bar Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

If you notice on the first button I have the attribute data-direction="reverse". Even though I could use the back button setup as before to return onto the home page, I’ve instead used the page ID of #index. By default the app window will transition to the right which looks pretty tacky since you expect the animation to move backwards. You can play around with even more of these animated effects if you have time. Check out the transitions info page in the jQuery documentation.

Ajax & Dynamic Pages

The first segment has really opened up the key points to building a mobile app with jQuery. But I want to start a new app which loads data from an external page. I’ll be using a very simple PHP script to attain the $_REQUEST[] variable and display a small Dribbble shot accordingly. The screenshow below should give you an idea what we are going to build.

dynamic pages demo Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

First I’ll make an index.html page set on the default template. For this home screen I’m using a list view setup to display each link in order. This is done in the content area with a data-role="listview" attribute on the list container. Cutting out the same header stuff as before, I added all my code from this new index page below.

<body>
<div data-role="page" id="img-listing">
	<header data-role="header">
		<h1>October 2011 Shots</h1>
	</header>

	<div data-role="content">
		<ul data-role="listview" data-theme="c">
			<li><a href="image.php?imgid=1">First image</a></li>
			<li><a href="image.php?imgid=2">Second image</a></li>
			<li><a href="image.php?imgid=3">Third image</a></li>
			<li><a href="image.php?imgid=4">Fourth image</a></li>
		</ul>
	</div>

	<footer data-role="footer"><h3>www.dribbble.com</h3></footer>
</div>
</body>
</html>

Each of the anchor links in my list view point to the same file – index.php. But we’re passing in the parameter imgid as a request variable. On the image.php file we take the ID and test it against 4 preset values. If any match up we use the matching image URL and title, otherwise we just display a default Dribbble shot.

Image Loader Script

The image.php script still has the default jQuery mobile template added into the code. It actually shares a very similar header and footer, except for the addition of our back link attribute data-add-back-btn="true". Notice this button will only show up if we come from index.html first! Try directly loading image.php and nothing will appear since there’s no “back” to move to.

I think we can make a bit more sense of the code by examining my PHP logic first. We use a switch / case method to check against the 4 different IDs and provide a header title, image URL, and original artist source link.

<?php
$theid = $_REQUEST['imgid'];

switch($theid) {
	case 1:
		$heading = "Wunderkit";
		$origin  = "http://dribbble.com/shots/297593-Wunderkit-tasks";
		$source  = "wunderkit.png";
		break;
	case 2:
		$heading = "College";
		$origin  = "http://dribbble.com/shots/298643-Colleeeeeeeeeeeeege";
		$source  = "college.jpg";
		break;
	case 3:
		$heading = "Forum app";
		$origin  = "http://dribbble.com/shots/298649-Forum-app-for-Facebook";
		$source  = "forum-app.jpg";
		break;
	case 4:
		$heading = "Twitter";
		$origin  = "http://dribbble.com/shots/298069-Twitter";
		$source  = "twitter.png";
		break;
	default:
		$heading = "Abandoned lighthouse";
		$origin  = "http://dribbble.com/shots/298615-Abandoned-lighthouse";
		$source  = "lighthouse.jpg";
}
?>

All seems fairly straightforward – even a novice PHP dev should be able to follow along! And if you don’t understand it’s not important to the jQuery code anyway, so don’t worry. We should switch now and take a look at the template I’ve built within this new page. All the HTML code is added after that whole PHP block above. I used the ID of “images” for the container and even setup the header to change with each new photo.

<div data-role="page" id="images" data-add-back-btn="true">
	<header data-role="header">
		<h1><?php echo $heading; ?></h1>
	</header>

	<div data-role="content">
		<p><strong><a href="<?php echo $origin; ?>" data-rel="external">View the Original</a></strong></p>
		<p><a href="<?php echo $origin; ?>" data-rel="external"><img src="img/<?php echo $source; ?>" /></a></p>
	</div>

	<footer data-role="footer"><h3>www.dribbble.com</h3></footer>
</div>

You can probably see how simplistic this demo is. But the whole purpose is to demonstrate the scalability of jQuery mobile. PHP can easily be added into the mix and you can churn out some really neat apps with just a few hours of development.

Fancy Design with List Thumbnails

One last added effect we can implement is the use of thumbnails to liven up listing page. I’m also going to split text into a heading and description box to display both the artwork title and artist’s name.

dribbble image browser app preview Building Websites and Browser Apps with jQuery Mobile: A Beginners Guide

To begin open up Photoshop and create an 80×80 px document. I’m going to quickly re-size each image and save thumbnails to match each one. Then updating the list view items we should include a few more elements.

Check out the code below and my demo example to see what I mean.

[Preview Live Demo]

<div data-role="content">
	<ul data-role="listview" data-theme="c">
		<li><a href="image.php?imgid=1">
		<img src="img/wunderkit-t.png" class="ui-li-thumb" />
		<h3 class="ui-li-heading">Wunderkit tasks</h3>
		<p class="ui-li-desc">by Sebastian Scheerer</p></a></li>

		<li><a href="image.php?imgid=2">
		<img src="img/college-t.jpg" class="ui-li-thumb" />
		<h3 class="ui-li-heading">Colleeeeeeeeeeeeege</h3>
		<p class="ui-li-desc">by Scott Hill</p></a></li>

		<li><a href="image.php?imgid=3">
		<img src="img/forum-app-t.jpg" class="ui-li-thumb" />
		<h3 class="ui-li-heading">Forum app for Facebook</h3>
		<p class="ui-li-desc">by Ionut Zamfir</p></a></li>

		<li><a href="image.php?imgid=4">
		<img src="img/twitter-t.png" class="ui-li-thumb" />
		<h3 class="ui-li-heading">Twitter</h3>
		<p class="ui-li-desc">by Sam Jones</p></a></li>
	</ul>
</div>

The classes for ui-li-heading and ui-li-desc are added by default into the jQuery Mobile stylesheet. This is similar to the image class ui-li-thumb which automatically re-sizes each list view bar according to the image height. Now from here you could build more on the frontend with animations, page effects, stylesheets, etc.

Or alternatively you could begin constructing a backend system to upload new images and automatically trim thumbnails to include in the list. There is so much flexibility with jQuery Mobile you almost can’t label it solely as a JavaScript library. It’s more of an entire HTML5/CSS/jQuery framework for building quick and scalable mobile apps.

Conclusion

As of writing this article the jQuery Mobile team has officially put out RC1.0 of the code library. This means most if not all of the major bug fixes have been squashed and now testers are gearing up for a full release. Because of this you won’t find a whole lot of information on the web.

But as the months advance web developers are sure to pick up on the trend. Mobile applications and even mobile web layouts are growing in popularity with the huge increase in smartphones. Web developers don’t have the time to learn a full programming language for building Android/iOS apps. Thus jQuery Mobile is a slim alternative which includes support for a majority of the mobile industry software, and continues growing each day with an active developer community.

Weekly Design News – Resources, Tutorials and Freebies (N.116)

Advertise here with BSA


This is our weekly column were we share our favorite design related articles, resources and cool tidbits from the past week. Enjoy :)
If you would like to receive our daily updates and kepp up to date with the latest and greatest articles and resources from the design community, you can follow us on Twitter, on Facebookor by subscribing to our RSS feed.

git – the simple guide – no deep shit!

git - the simple guide - no deep shit!

Things We Wish Clients Would Say

Things We Wish Clients Would Say

IE6 declared dead in the USA

IE6 declared dead in the USA

CSS Buttons with Pseudo-elements

CSS Buttons with Pseudo-elements

(Better) Tabs with Round Out Borders

Tabs with Round Out Borders

Just another CSS3 menu

Just another CSS3 menu

Password strength verification with jQuery

Password strength verification with jQuery

Captain America Shield in Pixelmator

Captain America Shield in Pixelmator

Azuka (HTML Template)

Azuka (HTML Template)

Bijou — Tiny, 10 pixel icons for free

Bijou — Tiny, 10 pixel icons for free

New High-Quality Free Fonts (2012 Edition)

New High-Quality Free Fonts (2012 Edition)

Manteka Free Font

Manteka Free Font

Social Switches – psdchest

Social Switches - psdchest

This Week on CodeVisually

We recently launched CodeVisually, our site that focuses solely on resources and tools for web developers and offers a simple solution to painlessly find the resource needed and fast.

Here are our favorite webdev resources from the past week:

jQuery Mobile

jQuery Mobile

Textualizer

Textualizer

The Goldilocks Approach

The Goldilocks Approach

BluCSS

BluCSS

jQuery Transit

jQuery Transit

jQuery Plugin Boilerplate

jQuery Plugin Boilerplate

Previous Weekly Design News…

Design News Roundup Archives →


Advertise here with BSA