94
jQuery UI and Plugins by Marc Grabanski

jQuery UI and Plugins

Embed Size (px)

DESCRIPTION

Dive into jQuery UI and its CSS framework, as well as some of the better plugins in the jQuery landscape.

Citation preview

Page 1: jQuery UI and Plugins

jQuery UI and Pluginsby Marc Grabanski

Page 2: jQuery UI and Plugins

What do you think of when you hear, “jQuery UI”?

Page 3: jQuery UI and Plugins

Widgets?

Page 4: jQuery UI and Plugins

Yeah, it’s got widgets.

Page 5: jQuery UI and Plugins

But, what else should you think of?

Page 6: jQuery UI and Plugins

One of the most under-hyped piece of software on the web

Page 7: jQuery UI and Plugins

jQuery UI CSS framework

Page 8: jQuery UI and Plugins

jQuery UI Classes

Page 9: jQuery UI and Plugins

.ui-state-activejQuery UI Classes

Page 10: jQuery UI and Plugins

.ui-state-active

.ui-state-default

jQuery UI Classes

Page 11: jQuery UI and Plugins

.ui-widget-header

.ui-state-active

.ui-state-default

jQuery UI Classes

Page 12: jQuery UI and Plugins

.ui-widget-content

.ui-widget-header

.ui-state-active

.ui-state-default

jQuery UI Classes

Page 13: jQuery UI and Plugins

UI Icons

.ui-icon

CSS Sprite

Page 14: jQuery UI and Plugins

Add rounded corners to anything

Page 15: jQuery UI and Plugins

.ui-corner-all

Add rounded corners to anything

Page 16: jQuery UI and Plugins

UI Class Quick Tip

Add hover by grabing buttons with .ui-state-default and attach hover class.

.ui-state-default

Page 17: jQuery UI and Plugins

UI Class Quick Tip

Add hover by grabing buttons with .ui-state-default and attach hover class.

.ui-state-hover

Page 18: jQuery UI and Plugins

.ui-state-default

UI Class Quick Tip

Add hover by grabing buttons with .ui-state-default and attach hover class.

.ui-state-hover

Page 19: jQuery UI and Plugins

.ui-state-default

UI Class Quick Tip

Add hover by grabing buttons with .ui-state-default and attach hover class.

.ui-state-hover

$(“.ui-state-default”).hover(function(){ $(this).addClass(“ui-state-hover”); }),function(){ $(this).removeClass(“ui-state-hover”); })

);

Page 20: jQuery UI and Plugins

.ui-state-default

UI Class Quick Tip

Add hover by grabing buttons with .ui-state-default and attach hover class.

http://www.filamentgroup.com/lab/styling_buttons_and_toolbars_with_the_jquery_ui_css_framework/

More info:

.ui-state-hover

$(“.ui-state-default”).hover(function(){ $(this).addClass(“ui-state-hover”); }),function(){ $(this).removeClass(“ui-state-hover”); })

);

Page 21: jQuery UI and Plugins

Customize your CSSwith ThemeRoller

Page 22: jQuery UI and Plugins

Bring ThemeRoller right into your page

Page 23: jQuery UI and Plugins

Design your own theme

jQuery UI Aristo Themehttp://taitems.tumblr.com/post/482577430/introducing-aristo-a-jquery-ui-theme

Page 24: jQuery UI and Plugins

jQuery UI Widgets

Page 25: jQuery UI and Plugins

UI Button

$(“button”).button();

<button>A button element</button>

Page 26: jQuery UI and Plugins

UI Button

$(“button”).button();

<button>A button element</button>

<div id="radio1"> <input type="radio" id="radio1" name="radio" />

<label for="radio1">Choice 1</label> <input type="radio" id="radio2" name="radio" checked="checked" />

<label for="radio2">Choice 2</label> <input type="radio" id="radio3" name="radio" />

<label for="radio3">Choice 3</label></div>

$(“#radio1”).buttonset();

Radio Group

Page 27: jQuery UI and Plugins

UI Accordion

<div id="accordion"> <h3><a href="#">Section 1</a></h3> <div>…content…</div> <h3><a href="#">Section 2</a></h3> <div>…content…</div> <h3><a href="#">Section 3</a></h3> <div>…content…</div></div>

Page 28: jQuery UI and Plugins

UI Accordion

<div id="accordion"> <h3><a href="#">Section 1</a></h3> <div>…content…</div> <h3><a href="#">Section 2</a></h3> <div>…content…</div> <h3><a href="#">Section 3</a></h3> <div>…content…</div></div>

$(“#accordion”).accordion();

Page 29: jQuery UI and Plugins

UI Dialog

<div id="dialog" title="Dialog Title">I'm in a dialog</div>

Page 30: jQuery UI and Plugins

UI Dialog

$("#dialog").dialog();

<div id="dialog" title="Dialog Title">I'm in a dialog</div>

Page 31: jQuery UI and Plugins

UI Dialog

$("#dialog").dialog();

<div id="dialog" title="Dialog Title">I'm in a dialog</div>

Page 32: jQuery UI and Plugins

UI Datepicker

$("#datepicker").datepicker();

Page 33: jQuery UI and Plugins

UI Datepicker

$("#datepicker").datepicker();

Page 34: jQuery UI and Plugins

UI Progressbar

$("#progressbar").progressbar({ value: 37 });

Page 35: jQuery UI and Plugins

UI Progressbar

$("#progressbar").progressbar({ value: 37 });

Page 36: jQuery UI and Plugins

$("input#autocomplete").autocomplete({

source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]

});

UI Autocomplete

Page 37: jQuery UI and Plugins

$("input#autocomplete").autocomplete({

source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]

});

UI Autocomplete

Page 38: jQuery UI and Plugins

UI Tabs<div id="tabs"> <ul> <li><a href="#tabs-1">First</a></li> <li><a href="#tabs-2">Second</a></li> <li><a href="#tabs-3">Third</a></li> </ul> <div id="tabs-1">...</div> <div id="tabs-2">...</div> <div id="tabs-3">...</div></div>

Page 39: jQuery UI and Plugins

UI Tabs<div id="tabs"> <ul> <li><a href="#tabs-1">First</a></li> <li><a href="#tabs-2">Second</a></li> <li><a href="#tabs-3">Third</a></li> </ul> <div id="tabs-1">...</div> <div id="tabs-2">...</div> <div id="tabs-3">...</div></div>

$("#tabs").tabs();

Page 40: jQuery UI and Plugins

UI Tabs<div id="tabs"> <ul> <li><a href="#tabs-1">First</a></li> <li><a href="#tabs-2">Second</a></li> <li><a href="#tabs-3">Third</a></li> </ul> <div id="tabs-1">...</div> <div id="tabs-2">...</div> <div id="tabs-3">...</div></div>

$("#tabs").tabs();

Page 41: jQuery UI and Plugins

User Interaction

Page 42: jQuery UI and Plugins

User Interaction

• Draggable

Page 43: jQuery UI and Plugins

User Interaction

• Draggable• Droppable

Page 44: jQuery UI and Plugins

User Interaction

• Draggable• Droppable• Sortable

Page 45: jQuery UI and Plugins

User Interaction

• Draggable• Droppable• Sortable• Resizable

Page 46: jQuery UI and Plugins

User Interaction

• Draggable• Droppable• Sortable• Resizable• Selectable

Page 47: jQuery UI and Plugins

$("#draggable").draggable();

User Interaction

Page 48: jQuery UI and Plugins

$("#draggable").draggable();

$("#droppable").droppable({ accept: '#draggable', drop: function(event, ui) { // do something }});

User Interaction

Add droppable that accepts draggable

Page 49: jQuery UI and Plugins

UI Effects

Page 50: jQuery UI and Plugins

UI Effects

• Color animations

Page 51: jQuery UI and Plugins

UI Effects

• Color animations• Animated add/remove class

Page 52: jQuery UI and Plugins

UI Effects

• Color animations• Animated add/remove class• Effects like shake and drop

Page 53: jQuery UI and Plugins

UI Effects

• Color animations• Animated add/remove class• Effects like shake and drop• Easing

Page 54: jQuery UI and Plugins

$(...).animate({ backgroundColor: "#68BFEF" }, 500);

UI EffectsAnimate background color in .5 seconds

Page 55: jQuery UI and Plugins

$(...).animate({ backgroundColor: "#68BFEF" }, 500);

UI EffectsAnimate background color in .5 seconds

$(...).switchClass('currentClass','newClass', 500);

Animate to newClass in .5 seconds

Page 56: jQuery UI and Plugins

$(...).animate({ backgroundColor: "#68BFEF" }, 500);

UI EffectsAnimate background color in .5 seconds

$(...).switchClass('currentClass','newClass', 500);

Animate to newClass in .5 seconds

$(...).hide("drop", { direction: "down" }, 500);

Hide elements with drop animation

Page 57: jQuery UI and Plugins

http://marcgrabanski.com/article/building-a-tmnt-game-with-jquery

My Fun Little Tutorial

Building a Ninja Turtles Game with jQuery

Page 58: jQuery UI and Plugins

jQuery UI Widget Factory

Page 59: jQuery UI and Plugins

$.widget("ui.mywidget", { // default options options: { option1: "defaultValue", hidden: true }, _create: function() { // creation code for mywidget // can use this.options if (this.options.hidden) {

// and this.element this.element.hide(); } }});

Writing Plugins

http://jqueryui.com/docs/Developer_Guide

Page 61: jQuery UI and Plugins

jQuery UI in Practice

Page 62: jQuery UI and Plugins

http://mjgin.com/img/portfolio/videos/subarucms.swf

Video Example

Page 63: jQuery UI and Plugins
Page 64: jQuery UI and Plugins

UI Datepicker

Page 65: jQuery UI and Plugins

UI Datepicker

UI Sortable

Page 66: jQuery UI and Plugins

UI Tabs

UI Datepicker

UI Sortable

Page 67: jQuery UI and Plugins

UI Tabs

UI Dialog

UI Datepicker

UI Sortable

Page 68: jQuery UI and Plugins

What about Plugins?

Page 69: jQuery UI and Plugins
Page 70: jQuery UI and Plugins

JS Treehttp://www.jstree.com/

Page 71: jQuery UI and Plugins

JS Treehttp://www.jstree.com/

WYM Editorhttp://www.wymeditor.org/

Page 72: jQuery UI and Plugins

Good Plugin Checklist

Page 73: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core

Page 74: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core•Buzz / mentions in blogs

Page 75: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core•Buzz / mentions in blogs•Documentation

Page 76: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core•Buzz / mentions in blogs•Documentation•CSS makes sense to you

Page 77: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core•Buzz / mentions in blogs•Documentation•CSS makes sense to you•Author is committed to support

Page 78: jQuery UI and Plugins

Good Plugin Checklist

•API is like jQuery core•Buzz / mentions in blogs•Documentation•CSS makes sense to you•Author is committed to support•or.. Jörn made it http://bassistance.de/

Page 79: jQuery UI and Plugins

Identify Good Plugin API

Page 80: jQuery UI and Plugins

Identify Good Plugin API

Properties (options)$(...).plugin({ option1: value, option2: value });

Page 81: jQuery UI and Plugins

Identify Good Plugin API

Properties (options)

Callbacks (events)

$(...).plugin({ option1: value, option2: value });

$(...).plugin({ onSomeAction: function(){

// callback action})

});

Page 82: jQuery UI and Plugins

Identify Good Plugin API

Properties (options)

Callbacks (events)

Methods

$(...).plugin({ option1: value, option2: value });

$(...).plugin({ onSomeAction: function(){

// callback action})

});

$(...).plugin(“destroy”);

Page 83: jQuery UI and Plugins

Good Plugin Support

Page 84: jQuery UI and Plugins

Good Plugin Support

•Google Groups, mailing lists

Page 85: jQuery UI and Plugins

Good Plugin Support

•Google Groups, mailing lists

•Comments are ok when plugin is new

Page 86: jQuery UI and Plugins

Good Plugin Support

•Google Groups, mailing lists

•Comments are ok when plugin is new

•Does author modify plugin based on feedback?

Page 87: jQuery UI and Plugins

Good Plugin Support

•Google Groups, mailing lists

•Comments are ok when plugin is new

•Does author modify plugin based on feedback?

•Code repository, when was last commit?

Page 88: jQuery UI and Plugins

Good Plugin Community

Page 89: jQuery UI and Plugins

Good Plugin Community

•Buzz - Plugin Lists, Ajaxian, etc

Page 90: jQuery UI and Plugins

Good Plugin Community

•Buzz - Plugin Lists, Ajaxian, etc

•Does the author make update announcements?

Page 91: jQuery UI and Plugins

Good Plugin Community

•Buzz - Plugin Lists, Ajaxian, etc

•Does the author make update announcements?

•Depreciated features well-documented.

Page 92: jQuery UI and Plugins

Good Plugin Community

•Buzz - Plugin Lists, Ajaxian, etc

•Does the author make update announcements?

•Depreciated features well-documented.

Identify that the author is communicating.

Page 93: jQuery UI and Plugins

http://marcgrabanski.com/article/jquery-plugins-toolbox

My “Plugins Toolbox”

Page 94: jQuery UI and Plugins

Thank you!

Marc Grabanski: http://marcgrabanski.com

Twitter: @1Marc