Академический Документы
Профессиональный Документы
Культура Документы
Web 1.0
Web 1.5
Interactivity
Web 2.0
Web 3.0
Semantic data
Structured data
Ajax
Why Ajax
Standards-compliant (to some degree)
HTML 4.01, HTML 5
ECMAScript 3rd/5th edition
XMLHttpRequest
CSS 2.1, CSS 3
Require no browser plug-ins/add-ons
Avoid vendor lock-in
Easy to integrate with legacy web applications
Low learning curve for front-end developers
Logic
Client
Server
Logic
Client
Server
Behavior
JavaScript
Brain
Presentation
CSS
Flesh
Structure
HTML
Skeleton
Semantic HTML
Semantic HTML
Best Practices
CSS
Elements of CSS
@ rule
@import, @media, @charset
Style rule set
Style rule set
Rule = Selector + Declaration
Selector
Select elements in current DOM tree
Declaration
Name-value pair
Apply style declaration to elements selected by selector
Selectors
Universal selector : *
Type selector : span, div
Descendant selector : div span
Child selector : div > span
Adjacent sibling selector : div + span
Attribute selector : div[title]
Class selector : .content
ID selector : #myId
Pseudo-elements and pseudo-classes : :firstchild, :hover
Cascading Order
The order of a style rule is determined by the selector it uses and the
stylesheet position it appears
Selector order (high -> low)
!important
Declared in style attribute
ID selector
Class selector, attribute selector, pseudo-elements and pseudoclasses
Type selector
Universal selector
Position order (high -> low)
<style> element
@import in <style> element
<link> element
@import in <link> element
User-provided stylesheet
Browser's default stylesheet
!import in user-provided stylesheet has the highest priority
Browser Compatibility
Maintainable CSS
Object-oriented CSS
Divide CSS files into multiple components
Heading, buttons, menus
Single responsibility
Separate structure and visual style
Organize multiple CSS files using @import
dojo.query()
dojo.query(selector, node)
Use CSS selectors
Return value of dojo.query() is dojo.NodeList
Functions of dojo.NodeList
forEach(), map(), filter(), slice(), splice(),
indexOf(), lastIndexOf(), every(), some()
style(), addClass(), removeClass(), toggleClass()
append(), prepend(), after(), before()
appendTo(), prependTo(), insertBefore(),
insertAfter()
wrap(), wrapAll(), wrapInner()
Chaining of dojo.query()
Most of dojo.NodeList's functions return dojo.NodeList
Functions can be chained together to write concise code
dojo.query(".item").children().addClass("subItem").
end().parent().addClass("itemContainer")
DOM Manipulation
dojo.NodeList plug-in
dojo.behavior
Events
Event Propagation
Event Handling
Event object
Contains contextual information
Contains different properties
Dojo fixes the event object
Using dojo.connect(), event handlers receive a
normalized event object as the parameter
this keyword points to what in event handlers
DOM level 0 : current node
W3C event model : current node
IE event model : window object
Dojo
Dojo base
Basic features for Ajax applications
Dojo core
Core features useful for many Ajax applications
Dijit
Dojo widgets
Dojox
Dojo extensions
Utilities
Array process
dojo.forEach()
dojo.every()
dojo.some()
dojo.map()
dojo.filter()
dojo.indexOf()
String process
dojo.trim()
dojo.replace() : A simple template implementation
JSON
dojo.toJson()
dojo.fromJson()
dojo.Deferred
Object-oriented JavaScript
Declare classes
Looks like Java classes
dojo.declare("com.example.Sample",
[com.example.AbstractSample], {})
Mixin properties
dojo.mixin({}, defaultOptions, userOptions)
dojo.extend
Extends a object's prototype
dojo.delegate
Delegate the properties search to another object
dojo.getObject
Get a property using dot expression
dojo.setObject
Set a property using dot expression
dojo.exists
Check property existence
dojo.data
Advanced I/O
Script
Use JSONP
Can access data from other domains
iframe
Useful for file uploading
window.name
Multi-part
Dijit Creation
Dijit Destroy
Create Dijits
Declaratively
Use HTML markup and custom attributes
dojoType attribute is the dijit's class name
Other attributes are mapped to dijit's properties
Properties in dijit's prototype, excluding those in
Object.prototype and name starts with "_", are
mapped
DOM node attributes are transformed according to
properties' data type
Use <script> element to declare functions
dojo.parser.parse() is used to create the dijits behind
the scene
Programmatically
Use new operator
Set/Get Attributes
Template
Mixin dijit._Templated to support building dijit UI using
templates
Use dojoAttachPoint and dojoAttachEvent to reference DOM
node and add event listeners
Container
Mixin dijit._Container to support managing children dijits
Container's startup() function calls children dijits' startup()
Removing a child dijit from the container doesn't destroy it
Registry
All dijit references in current page can be found at
dijit.registry
An instance of dijit.WidgetSet
Be careful when creating dijits with specified IDs
The infamous error : Tried to register widget with id==myId
but that id is already registered
Remove the old dijit from dijit.registry first before
creating a new dijit with the same ID
Dojox Components
dojox.grid
A comprehensive data grid
dojox.fx
Effects
dojox.gfx
Drawing
dojox.gfx3d
3D drawing
dojox.charting
Charting
dojox.layout
UI layout
dojox.mobile
Create mobile web applications
Dojox Components
dojox.lang
dojox.lang.async : Manage asynchronous operations
with dojo.Deferred
dojox.lang.aspect : AOP support
dojox.html
Dynamic CSS style rules
Font metrics
dojox.collections
ArrayList, Set, Stack, Dictionary, Queue,
SortedList, BinaryTree
JSON
dojox.json.query : Query JSON objects
dojox.json.schema : Validate JSON objects
Data stores
XML, CSV, Name-value pair, HTML table, server-side query
Build Process
Security
JSON Hijacking
Performance
Thank you!