Upload
marc-grabanski
View
6.714
Download
0
Embed Size (px)
Citation preview
When building web interfaces, we have to make decisions on what to use, when.
•When do I use jQuery?
•When do I use CSS Only?
•When do I use a plugin?
•How do I choose a plugin?
Many of the difficult problems I face in user interface development are CSS related.
Learn CSS as well as you can.
Title and address needs to expand.
Overlay with Shadow.
Opacity indicates selected.
Places to Use CSS
.opacity-75 {opacity:0.75; -moz-opacity:0.75; filter:alpha(opacity=75);
}
Pure CSS Opacity
CSS repeating background
#mid-title { background:url(...) repeat-y; }
.opacity-75 {opacity:0.75; -moz-opacity:0.75; filter:alpha(opacity=75);
}
Pure CSS Opacity
Shadows, 24 bit pngs, ddpngfix for IE6
CSS repeating background
http://www.dillerdesign.com/experiment/DD_belatedPNG/
#mid-title { background:url(...) repeat-y; }
Does this user interface need jQuery plugins?
No.
Everything we need here is built into jQuery Core, except for Google Maps.
Getting content via Ajax.
$.get(url, function(response){ $("#property-view").replaceWith(response); $("#overlay").fadeIn();
Getting content via Ajax.
$.get(url, function(response){ $("#property-view").replaceWith(response); $("#overlay").fadeIn();});
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");var currentImg = gallery.find(".main-image img");
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");var currentImg = gallery.find(".main-image img");$("<img />").attr('src', ...).hide()
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");var currentImg = gallery.find(".main-image img");$("<img />").attr('src', ...).hide()
.appendTo(imageHolder).fadeIn();
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");var currentImg = gallery.find(".main-image img");$("<img />").attr('src', ...).hide()
.appendTo(imageHolder).fadeIn();currentImage.fadeOut(function(){
Switching images.
$(".thumbs li").live("click",function(){var gallery = $(this).parents("div.gallery");var currentImg = gallery.find(".main-image img");$("<img />").attr('src', ...).hide()
.appendTo(imageHolder).fadeIn();currentImage.fadeOut(function(){ $(this).remove();});
});
Interactive map function renderMap(el, lat, lng) { if (GBrowserIsCompatible()) {
var map = new GMap2(el); map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(lat, lng), 13); var point = new GLatLng(lat, lng);
var baseIcon = new GIcon(); baseIcon.image = base+"/img/icons/map-pin.png"; baseIcon.shadow = base+"/img/icons/map-pin-shadow.png"; baseIcon.iconSize = new GSize(41, 34); baseIcon.shadowSize = new GSize(41, 34); baseIcon.iconAnchor = new GPoint(15, 32); baseIcon.infoWindowAnchor = new GPoint(9, 2); map.addOverlay(new GMarker(point, baseIcon)); }}
Interactive map function renderMap(el, lat, lng) { if (GBrowserIsCompatible()) {
var map = new GMap2(el); map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(lat, lng), 13); var point = new GLatLng(lat, lng);
var baseIcon = new GIcon(); baseIcon.image = base+"/img/icons/map-pin.png"; baseIcon.shadow = base+"/img/icons/map-pin-shadow.png"; baseIcon.iconSize = new GSize(41, 34); baseIcon.shadowSize = new GSize(41, 34); baseIcon.iconAnchor = new GPoint(15, 32); baseIcon.infoWindowAnchor = new GPoint(9, 2); map.addOverlay(new GMarker(point, baseIcon)); }}
$("#unit-types").live('click', function(){$(this).addClass('active');$("#map-description").removeClass('active')
.next().hide();$(this).next().fadeIn();
});
and tabs.
jQuery core and CSS are great for adding spices to websites, but what about more complex administration panels?
jQuery UI Class Quick Tip
Add hover by grabing buttons with .ui-state-default and attach hover class.
.ui-state-default
jQuery UI Class Quick Tip
Add hover by grabing buttons with .ui-state-default and attach hover class.
.ui-state-hover
.ui-state-default
jQuery UI Class Quick Tip
Add hover by grabing buttons with .ui-state-default and attach hover class.
.ui-state-hover
.ui-state-default
jQuery 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”); })
);
.ui-state-default
jQuery 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”); })
);
JS Treehttp://www.jstree.com/
WYM Editorhttp://www.wymeditor.org/
jQGridDemo: http://trirand.com/jqgrid/jqgrid.htmlDownload: http://www.trirand.com/blog/?page_id=6
Works with ThemeRoller too!
jGrowl (popup notifications)http://stanlemon.net/projects/jgrowl.html
Flot (charts)http://people.iola.dk/olau/flot/examples/graph-types.html
Input Maskshttp://digitalbush.com/projects/masked-input-plugin/
Auto Completehttp://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
jQuery Tooltiphttp://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
Plugin Checklist
•API is like jQuery core•Buzz / mentions in blogs•Documentation•CSS makes sense to you
Plugin Checklist
•API is like jQuery core•Buzz / mentions in blogs•Documentation•CSS makes sense to you•Author is committed to support
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/
Identify Good Plugin API Design
Properties (options)$(...).plugin({ option1: value, option2: value });
Identify Good Plugin API Design
Properties (options)
Callbacks (events)
$(...).plugin({ option1: value, option2: value });
$(...).plugin({ onSomeAction: function(){
// callback action})
});
Identify Good Plugin API Design
Properties (options)
Callbacks (events)
Methods
$(...).plugin({ option1: value, option2: value });
$(...).plugin({ onSomeAction: function(){
// callback action})
});
$(...).plugin(“destroy”);
Identifying Good Plugin Support
•Google Groups, mailing lists
•Comments are ok when plugin is new
•Does author modify plugin based on feedback?
Identifying 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?
Identifying Good Plugin Community
•Buzz - Plugin Lists, Ajaxian, etc
•Does the author make update announcements?
Identifying Good Plugin Community
•Buzz - Plugin Lists, Ajaxian, etc
•Does the author make update announcements?
•Depreciated features well-documented.
Identifying Good Plugin Community
•Buzz - Plugin Lists, Ajaxian, etc
•Does the author make update announcements?
•Depreciated features well-documented.
Identify that the author is communicating.
Questions?
Marc Grabanski: http://marcgrabanski.com
Twitter: http://twitter.com/1MarcEmail: [email protected]
User interface and web application development. Examples: http://mjgin.com/work.html