Top Banner
Prototyping the Rich Web Experience Bill Scott Yahoo! Ajax Evangelist [email protected] 1
118

Protoscript - Simplified prototype scripting

Oct 17, 2014

Download

Technology

Given at the Rich Web Experience 2007.

http://protoscript.com

Protoscript is a simplified scripting language for creating Ajax style prototypes for the Web. With Protoscript it's easy to bring interface elements to life. Simply connect them to behaviors and events to create complex interactions.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Protoscript - Simplified prototype scripting

Prototyping the Rich Web Experience

Bill ScottYahoo! Ajax Evangelist

[email protected]

1

Page 2: Protoscript - Simplified prototype scripting

stuff i’ve done

2

Page 3: Protoscript - Simplified prototype scripting

stuff i’ve done

2

Page 4: Protoscript - Simplified prototype scripting

stuff i’ve done

2

Page 5: Protoscript - Simplified prototype scripting

stuff i’ve done

2

Page 6: Protoscript - Simplified prototype scripting

prototyping

• Have been involved with prototyping for a number of years

• Last summer wrote a quick dragdrop proto library that was based on CSS class names and associating behavior to these classes (‘dragme’, ‘drophere’)• Goal was to make it easy for designers to start prototyping• However it was not possible to provide enough logic without

resorting to writing code• Been planning to get back to the idea for a year.

• This got me thinking about simplifying the experience of prototyping with dhtml/ajax

3

Page 7: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want

4

Page 8: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want

sprinkle in some behaviors

4

Page 9: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want

sprinkle in some behaviors

4

Page 10: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want

sprinkle in some behaviors

4

Page 11: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 12: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 13: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 14: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 15: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 16: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 17: Protoscript - Simplified prototype scripting

take a rough prototype

what i really want Popup

sprinkle in some behaviors

4

Page 18: Protoscript - Simplified prototype scripting

what we will discuss

• quick overview of common design patterns (behaviors)

• quick survey of techniques to prototype a rich web experience

• dive into protoscript and discuss how it can be used to sprinkle behaviors into web pages

• look at similar techniques emerging (jQuery, css behaviors, DED | Chain, etc.

5

Page 19: Protoscript - Simplified prototype scripting

patterns(common interaction behaviors)

6

Page 20: Protoscript - Simplified prototype scripting

ria patternsinvitation. cursor invitation. hover invitation. tooltip invitation. page

invitation. drop invitation. available. selected. auto complete. live suggest. refining search. dynamic filtering. live search. on-demand scrolling.

deferred content loading. fresh content. on-demand content. periodic refresh. resizable modules. scrolling modules. hover detail. narrowing

actions. narrowing choices. auto form fill. in-place drill down. dependent choices. look before you leap. drag and drop. drag and drop modules. drag and drop objects. persistant portals. in page edit. inline text edit. inline custom edit. direct state edit. rating an object. inline custom edit. inline tag edit. popup custom edit. grid cell edit. slide out custom edit.

module configure. module flip configure. module inline configure. module slide out configure. module faceplate. expandable content. in-context tools. in-context links. in-context hover menu. silent submit.

remembered collection. auto save. remembered preferences. hover spy. inline assistant. inline validation. validate then suggest. indicator. busy

indicator. progress indicator. inline status. in-context busy. cursor busy. opacity fade. high contrast. balloon error tip. dynamic goal. opacity focus. detail zoom. lightbox. transition. brighten. cross-fade. dim. expand. fade-in.

fade-out. flip. move. self-heal. collapse. slide. animate.

7

Page 21: Protoscript - Simplified prototype scripting

8

Page 22: Protoscript - Simplified prototype scripting

patterns

9

Page 23: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

9

Page 24: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

pattern. in-context expand.

9

Page 25: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

pattern. inline editing.

pattern. in-context expand.

9

Page 26: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

pattern. inline editing.

pattern. drag & drop.

pattern. in-context expand.

9

Page 27: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

pattern. inline editing.

pattern. drag & drop.

pattern. in-context expand.

pattern. hover details.

9

Page 28: Protoscript - Simplified prototype scripting

patterns

pattern. in-page action.

pattern. inline editing.

pattern. drag & drop.

pattern. in-context tools.

pattern. in-context expand.

pattern. hover details.

9

Page 29: Protoscript - Simplified prototype scripting

patterns

10

Page 30: Protoscript - Simplified prototype scripting

patterns

pattern. remembered collections.

10

Page 31: Protoscript - Simplified prototype scripting

patterns

pattern. on-demand scrolling.

pattern. remembered collections.

10

Page 32: Protoscript - Simplified prototype scripting

patterns

pattern. on-demand scrolling.

pattern. auto complete.

pattern. remembered collections.

10

Page 33: Protoscript - Simplified prototype scripting

patterns

11

Page 34: Protoscript - Simplified prototype scripting

patterns

pattern. busy indicator.

11

Page 35: Protoscript - Simplified prototype scripting

patterns

pattern. busy indicator.

pattern. lightweight popup + lightbox.

11

Page 36: Protoscript - Simplified prototype scripting

patterns

pattern. busy indicator.

pattern. fade transition + self-healing transition.pattern. lightweight popup + lightbox.

11

Page 37: Protoscript - Simplified prototype scripting

interesting moments

12

Page 38: Protoscript - Simplified prototype scripting

interesting moments

ID: Bill Scott & Eric Miraglia Date:

Mouse

Hover Mouse Down Drag Initiated

Drag Over

Valid Target

Drag Over

Invalid Target

Drag Over

Parent Container

Drop

Accepted

Drop

Rejected

Drop On

Parent Container

Cursor

CSS Move cursorCSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor Normal Cursor Normal Cursor Normal Cursor

Tool Tip

Drag Object

Full Opacity Reduced Opacity Reduced Opacity Reduced Opacity & Invalid Badge Reduced Opacity

Modules animates into the area

just below insertion bar

Modules animates back to

the home area

Modules animates back to

the home area

Module comes to rest in new

area

Module comes back to rest

at full opacity

Modules comes back to

rest at full opacity

Modules slide up in a self-healing

transition to close hole

Drop Target

No insertion bar, just a gap No insertion bar, just a gap Insertion bar showing where it will drop No insertion bar, just a gap No insertion bar, just a gap & original hole

Insertion bar is removed as first

frame of animation

Insertion bar is removed

as first frame of animation

Insertion bar is removed

as first frame of

animation

Drag and Drop Modules - Interesting Moments Grid

Currently on beta.my.yahoo.com Nov-05

12

Page 39: Protoscript - Simplified prototype scripting

interesting moments

ID: Bill Scott & Eric Miraglia Date:

Mouse

Hover Mouse Down Drag Initiated

Drag Over

Valid Target

Drag Over

Invalid Target

Drag Over

Parent Container

Drop

Accepted

Drop

Rejected

Drop On

Parent Container

Cursor

CSS Move cursorCSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor Normal Cursor Normal Cursor Normal Cursor

Tool Tip

Drag Object

Full Opacity Reduced Opacity Reduced Opacity Reduced Opacity & Invalid Badge Reduced Opacity

Modules animates into the area

just below insertion bar

Modules animates back to

the home area

Modules animates back to

the home area

Module comes to rest in new

area

Module comes back to rest

at full opacity

Modules comes back to

rest at full opacity

Modules slide up in a self-healing

transition to close hole

Drop Target

No insertion bar, just a gap No insertion bar, just a gap Insertion bar showing where it will drop No insertion bar, just a gap No insertion bar, just a gap & original hole

Insertion bar is removed as first

frame of animation

Insertion bar is removed

as first frame of animation

Insertion bar is removed

as first frame of

animation

Drag and Drop Modules - Interesting Moments Grid

Currently on beta.my.yahoo.com Nov-05

ID: Bill Scott & Eric Miraglia Date:

Mouse

Hover Mouse Down Drag Initiated

Drag Over

Valid Target

Drag Over

Invalid Target

Drag Over

Parent Container

Drop

Accepted

Drop

Rejected

Drop On

Parent Container

Cursor

CSS Move cursorCSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor CSS Move cursor Normal Cursor Normal Cursor Normal Cursor

Tool Tip

Drag Object

Full Opacity Reduced Opacity Reduced Opacity Reduced Opacity & Invalid Badge Reduced Opacity

Modules animates into the area

just below insertion bar

Modules animates back to

the home area

Modules animates back to

the home area

Module comes to rest in new

area

Module comes back to rest

at full opacity

Modules comes back to

rest at full opacity

Modules slide up in a self-healing

transition to close hole

Drop Target

No insertion bar, just a gap No insertion bar, just a gap Insertion bar showing where it will drop No insertion bar, just a gap No insertion bar, just a gap & original hole

Insertion bar is removed as first

frame of animation

Insertion bar is removed

as first frame of animation

Insertion bar is removed

as first frame of

animation

Drag and Drop Modules - Interesting Moments Grid

Currently on beta.my.yahoo.com Nov-05

12

Page 40: Protoscript - Simplified prototype scripting

interesting moments for drag drop

13

Page 41: Protoscript - Simplified prototype scripting

non-dhtmlprototyping techniques

14

Page 42: Protoscript - Simplified prototype scripting

challenge of interesting momentsWireframing AJAX is a bitch. The best our agency has come up with is the Chuck Jones approach: draw the key frames. Chuck Jones had an advantage: he knew what Bugs Bunny was going to do. We have to determine all the things a user might do, and wireframe the blessed moments of each possibility.- Jeffrey Zeldman

http://www.alistapart.com/articles/web3point0/

• Blessed Moments = Microstates = Interesting Momentsbehavior is not static- Multiple states need to be captured- Happens within a context- Not suited for wireframes

15

Page 43: Protoscript - Simplified prototype scripting

using keyframes

16

Page 44: Protoscript - Simplified prototype scripting

using keyframes

16

Page 45: Protoscript - Simplified prototype scripting

prototyping with visio

Source: http://www.boxesandarrows.com/view/storyboarding_rich_internet_applications_with_visio

• Changes in state placed in different layers

• Storyboard steps toggle visibility of associated layers

• Each storyline serves as a use case in the wireframe

17

Page 46: Protoscript - Simplified prototype scripting

prototyping with visio

Source: http://www.boxesandarrows.com/view/storyboarding_rich_internet_applications_with_visio

• Changes in state placed in different layers

• Storyboard steps toggle visibility of associated layers

• Each storyline serves as a use case in the wireframe

17

Page 47: Protoscript - Simplified prototype scripting

prototyping with keynote/powerpoint• Slides make major steps

• Builds used to bring in transitions, animations

18

Page 48: Protoscript - Simplified prototype scripting

19

Page 49: Protoscript - Simplified prototype scripting

prototyping with photoshop• Easy to create from a series of images

• Images can be created by hand or from other apps

20

Page 50: Protoscript - Simplified prototype scripting

animations from screencasts

Start with screencast (SnapZPro/SnagIt)Turn movie into animated GIF (Adobe ImageReady)

21

Page 51: Protoscript - Simplified prototype scripting

other approaches

FlashFlexiRise (www.irise.com) $$$Axure (www.axure.com)Interactive PDFsFireworks + PDFPowerpoint

DHTML

22

Page 52: Protoscript - Simplified prototype scripting

dhtmlprototyping

23

Page 53: Protoscript - Simplified prototype scripting

prototyping with DHTML

• Benefits• Can start simple and layer in complexity• Works well across different teams (design to code)• Technology the same or similar to final implementation• Most capable to approximate final result• Living example

• Disadvantages• Requires technical savvy• Bugs can suck down time• Too much time spent ‘messing with code’• Hard to extract into documentation

24

Page 54: Protoscript - Simplified prototype scripting

dhtml prototyping skills/techniques

• Keep structure, style and logic separate• Avoid adding onclick handlers in the HTML (unobtrusive)• Avoid any direct styles or html style tags (font, etc.)

• Use style class switching for visual changes

• Use CSS to simulate most mouse hover behavior

• Use innerHTML for content changes

• Understand when to use a class vs. id

• Use CSS query libraries for referencing interface parts• CSS selector syntax allows non-intrusive behavior injection

25

Page 55: Protoscript - Simplified prototype scripting

dhtml prototyping skills/techniques

• Use anchors as basic navigation/action hooks

• Use background images in CSS with style switching

• Use a grid layout system• YUI Grid

• Use Firebug

• Understand CSS Selectors• Ext, jQuery, Dojo, Mootoos, Prototype, cssQuery()

• Use JSON syntax (options)

26

Page 56: Protoscript - Simplified prototype scripting

underlying desire for protoscript

• address the conceptual phase of interface development -- think “interaction theme” (free from solving production issues)

• express an interaction as a configuration(no code; declarative approach)

• dynamically insert interaction themes (behaviors) to any web page (allows experimentation)

• create a gui tool for configuring & exploring interactions

27

Page 57: Protoscript - Simplified prototype scripting

protoscript approach• JSON used to express interaction theme to

express relationship between dom elements, behaviors, attributes, and callbacks

• jQuery CSS Selector syntax for dom elements

• Chain dependent behavior as well as parallel behavior with JSON syntax

• Simple to add behaviors (class with 2 methods)

• Focus is on prototyping

28

Page 58: Protoscript - Simplified prototype scripting

Demohttp://protoscript.com/demos.php

29

Page 59: Protoscript - Simplified prototype scripting

simple example

Simple Click, Fade, Close (self-healing delete)

30

Page 60: Protoscript - Simplified prototype scripting

sprinkling in behaviors

31

Page 61: Protoscript - Simplified prototype scripting

anatomy of an interaction

DOM elementsTarget an element or elements for attaching events & behaviors.

EventsEvents are the glue between the user andbehaviors. They start behaviors.

BehaviorsBlocks of logic, patterns, actions thatoperate on elements.

Event

Behavior

DOMElement

32

Page 62: Protoscript - Simplified prototype scripting

anatomy of self-healing delete

Event

Behavior

DOMElement

33

Page 63: Protoscript - Simplified prototype scripting

anatomy of self-healing delete

Event

Behavior

DOMElement

33

Page 64: Protoscript - Simplified prototype scripting

DOM elements[X] <LI>[X] oldmove.mov</LI>

anatomy of self-healing delete

Event

Behavior

DOMElement

33

Page 65: Protoscript - Simplified prototype scripting

DOM elements[X] <LI>[X] oldmove.mov</LI>

EventsClickonClick (callback)

anatomy of self-healing delete

Event

Behavior

DOMElement

33

Page 66: Protoscript - Simplified prototype scripting

DOM elements[X] <LI>[X] oldmove.mov</LI>

EventsClickonClick (callback)

BehaviorsFadeClose

anatomy of self-healing delete

Event

Behavior

DOMElement

33

Page 67: Protoscript - Simplified prototype scripting

protoscript code

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },}); Event

Behavior

Element

34

Page 68: Protoscript - Simplified prototype scripting

selecting dom elements (targeting)

Event

Behavior

Element

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

35

Page 69: Protoscript - Simplified prototype scripting

selecting dom elements (targeting)

Event

Behavior

Element

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

35

Page 70: Protoscript - Simplified prototype scripting

selecting dom elements (targeting)

Event

Behavior

Element

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

35

Page 71: Protoscript - Simplified prototype scripting

selecting dom elements (targeting)

Event

Behavior

Element

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

35

Page 72: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 73: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 74: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 75: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 76: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 77: Protoscript - Simplified prototype scripting

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } },});

chaining of target scope

Event

Behavior

Element

36

Page 78: Protoscript - Simplified prototype scripting

selector syntax

Consult jQuery docs:http://docs.jquery.com/DOM/Traversing/Selectors#CSS_Selectors

If you are setting up your own prototypes, stick with class and identifier.my-class-name#my-id-name

Other useful examplesa:contains(Click Here).my-class-name #my-id-under-there#my-specific-container .my-items

Consult CSS-1, CSS-2, CSS-3 and XPath

Event

Behavior

Element

37

Page 79: Protoscript - Simplified prototype scripting

Element

Event

behaviors Behavior

Animate. ColorAnimate. Fade. Move. Spotlight. Close. DragDrop. Hide. Open.

Popup. ReplaceClass. Script. SetClass. SetStyle. Show.

ToggleClass. ToggleOpenClose. ToggleShowHide. FetchHtml.

SetHtml.

38

Page 80: Protoscript - Simplified prototype scripting

behavior demos

Site has a demo page for each behaviorhttp://protoscript.com/demos.php

Site has a wiki with documentation page for each behavior

http://docs.protoscript.com/

Element

Event

Behavior

39

Page 81: Protoscript - Simplified prototype scripting

behavior attributesBehaviors may supply attributes for configuring the behavior

Where possible if an underlying YUI component or utility has a config object, this is exposed

EXAMPLE FROM Popup BEHAVIOR

close: true, draggable: true, underlay: 'shadow', model: false, visible: true, effect: null, monitorresize: true, x: null, y: null, xy: null, context: null, fixedcenter: true,

(bold denotes from Panel cfg)

width: '300px', height: null, zIndex: null, contraintoviewport: false, iframe: false, id: 'popup_panel', hd: 'Panel Title', bd: 'This is the body', ft: null

Element

Event

Behavior

40

Page 82: Protoscript - Simplified prototype scripting

plug-in behaviorProtoscript core is independent of any single toolkit

selector is a plugin. default set uses jQuerybehavior set is plugged in. default set uses YUI.ProtoScript.Core.registerBehaviorSet($, YAHOO.protoscript);(yui-proto.js)

You are free to create your own behavior sets or plug in other selector technologies

Example: Mootools selector & behaviorsProtoScript.Core.registerBehaviorSet($ES, MooBehaviors);(moo-proto.js)

You can also add behaviors to the default set

Element

Event

Behavior

41

Page 83: Protoscript - Simplified prototype scripting

peek under the hood of a behavior

YAHOO.protoscript.Show = function (behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg);};YAHOO.protoscript.Show.prototype = { defaultCfg : { }, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.util.Dom.setStyle(currScope.elems, 'visibility', 'visible'); if(this.cfg.onShow) { ProtoScript.Core.callBehaviors(this.cfg.onShow, currScope); } }};

'Show' behavior

Element

Event

Behavior

42

Page 84: Protoscript - Simplified prototype scripting

adding a behavior (to default YUI set)1. Add behavior to YAHOO.protoscript namespace

2. In init store name & apply config parameters

3. In action put your behavior logicThe action performs the behavioraction(currScope)currScope.elems: list of elems resolved from the current target scopecurrScope.idx: if multiple elems, the index into the active element for this actioncurrScope.pseudoElems: some behaviors set dynamic elements (like $drag, $drop in DragDrop behavior.

4. For any interesting moments, callProtoScript.Core.callBehaviors to process the callback

5. Add attributes as needed (in your defaultCfg)

6. Start using it in your scriptsElement

Event

Behavior

43

Page 85: Protoscript - Simplified prototype scripting

Event

Element

Behavior

events

Blur. Click. Dblclick. Focus. Keypress. Mousedown. Mousemove. Mouseout.

Mouseover. Mouseup. Timer.

44

Page 86: Protoscript - Simplified prototype scripting

events are actually behaviorsYAHOO.protoscript.Click = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg);};YAHOO.protoscript.Click.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'click');}};

'Click' behavior

Event

Element

Behavior

45

Page 87: Protoscript - Simplified prototype scripting

Event

Element

Behavior

callbacks

onComplete. onTween. onStart. onClose. onStartDrag. onDrag. onDragEnter. onDragOver.

onDragDrop. onDragOut. onEndDrag. onMouseUp. onInvalidDrop. onBlur. onClick. onDblClick. onFocus.

onKeypress. onMousedown. onMousemove. onMouseout. onMouseover. onMouseup. onTimer.

onHide. onOpen. onReplaceClass. onSetClass. onSetStyle. onShow. onToggleClass.

onToggleOpenClose. onToggleShowHide. onSuccess. onFailure. onSetHtml.

46

Page 88: Protoscript - Simplified prototype scripting

callbacks are interesting moments

47

Page 89: Protoscript - Simplified prototype scripting

callbacks are invoked in behaviors Event

Element

Behavior

'Open' behavior invoking onOpen

YAHOO.protoscript.Open = function (behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg);};YAHOO.protoscript.Open.prototype = { defaultCfg : { },

init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig( this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.util.Dom.setStyle(currScope.elems, 'display', 'block'); if(this.cfg.onOpen) { ProtoScript.Core.callBehaviors(this.cfg.onOpen, currScope); } }};

48

Page 90: Protoscript - Simplified prototype scripting

Bookmarklet*

*humble beginnings

49

Page 91: Protoscript - Simplified prototype scripting

50

Page 92: Protoscript - Simplified prototype scripting

51

Page 93: Protoscript - Simplified prototype scripting

adding protoscript to your page

http://protoscript.com/downloads.php52

Page 94: Protoscript - Simplified prototype scripting

syntax$proto(selector, interaction)where:selector is the jQuery selector syntaxinteraction is a configuration object (JSON) describing the interaction

$proto('span:contains([X])', { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } }});

53

Page 95: Protoscript - Simplified prototype scripting

syntax$proto(config)single config object defines an interactionconvenient for passing interactions around or saving to config files

$proto({ 'span:contains([X])': { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } } } });

54

Page 96: Protoscript - Simplified prototype scripting

syntax$proto(config)single config object defines an interactionconvenient for passing interactions around or saving to config files

var cfg = {'span:contains([X])': { SetStyle: {cursor:'pointer'}, Click: { onClick: { Fade: { target: '#multiple li', opacity: {to: 0}, onComplete: {Close : {} } } } } } };$proto(cfg);

55

Page 97: Protoscript - Simplified prototype scripting

0.1 beta

• Live at http://protoscript.com• Started it last month• reference implementation YUI + jQuery• 31 behaviors (including events)• 40+ live examples• full wiki site with all behaviors documented (docs.protoscript.com)

• Open source• Code is at Google Code. Send me email if you want to participate

will get you acces to SVN trunk• BSD license

• Bookmarklet• Just hack to start experimenting with GUI• Combined with firebug, works ok• Right now best on Firefox

56

Page 98: Protoscript - Simplified prototype scripting

next steps

• 'You' write lots of behaviors• Wiki for docs• Google code for new behaviors & behavior sets

• New GUI tool• Most likely extend Firebug• Combine 'inspector' with behavior wizard to inject behaviors• Persist configurations for pages; allow re-load

• Flesh out behavior self-publishing• Will add spec on how to make behavior publish itself to a GUI tool

57

Page 99: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

58

Page 100: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

58

Page 101: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

Click|_ + behavior [x]edit+ callback

58

Page 102: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Modifier:

Delay:

OK

58

Page 103: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

Click|_ + behavior [x]edit+ callback

58

Page 104: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

58

Page 105: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

58

Page 106: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

58

Page 107: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

58

Page 108: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

58

Page 109: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

SetStyle + behavior [x]edit+ callback|_

58

Page 110: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

SetStyle + behavior [x]edit+ callback|_

Click + behavior [x]edit+ callback|_

58

Page 111: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

SetStyle + behavior [x]edit+ callback|_

Click + behavior [x]edit+ callback|_

58

Page 112: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

ToggleClass|_ + behavior [x]edit

SetStyle + behavior [x]edit+ callback|_

Click + behavior [x]edit+ callback|_

58

Page 113: Protoscript - Simplified prototype scripting

lego-style interaction builderAnimateColorAnimateFadeMoveSpotlightClose DragDrop Hide Open Popup ReplaceClassScriptSetClassSetStyleShow ToggleClass ToggleOpenClose ToggleShowHideFetchHtml SetHtml Blur Click DblClick Focus Keypress Mousedown Mousemove MouseoutMouseoverMouseup Timer

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

onComplete|_ + behavior [x]edit

Click|_ + behavior [x]edit+ callback

Fade|_ + behavior [x]edit+ callback

Close|_ + behavior [x]edit+ callback

#avatar + behavior [x]edit

onClick|_ + behavior [x]edit

ToggleClass|_ + behavior [x]edit

ToggleOpenClose|_ .content + behavior [x]edit+ callback

SetStyle + behavior [x]edit+ callback|_

Click + behavior [x]edit+ callback|_

58

Page 114: Protoscript - Simplified prototype scripting

useful approaches (inspiration)

• Responder• http://www.boxpop.net/responder• given a style class name, associate behavior with those objects

• jQuery• LivePipe’s Event.Behavior

• http://livepipe.net/projects/event_behavior/

• Dustin Diaz, DED Chain• http://dedchain.dustindiaz.com/

59

Page 115: Protoscript - Simplified prototype scripting

useful approaches (inspiration)

• Transclusions• including html from somewhere else on your page• http://ajaxian.com/archives/purple-include-transclusions-you-know-

you-want-them

• DOMDom• nice way to express HTML for Dom insertion• http://www.zachleat.com/web/2007/07/07/domdom-easy-dom-

element-creation/• (merge with protokit)

• Magic DOM• http://amix.dk/blog/viewEntry/19199

• Jester. JavaScriptian REST• http://giantrobots.thoughtbot.com/2007/4/2/jester-javascriptian-rest

• JavaScript Templating Library: MJT• http://mjtemplate.org/

60

Page 116: Protoscript - Simplified prototype scripting

useful approaches (inspiration)

• moz-behaviors (dean.edwards.name)• http://dean.edwards.name/moz-behaviors/intro/• uses CSS Linking mechanisms• http://www.w3.org/TR/becss

• ClassAnim• http://blog.mozmonkey.com/2007/classanim-hoverhijax-keeping-

presentation-out-of-your-javascript/

• JDA Emulator: Spring for JS• Adds properties to the HTML tags themselves

• Ben Nolan’s Behavior Library• http://www.ccs.neu.edu/home/dherman/javascript/behavior/• http://www.ccs.neu.edu/home/dherman/javascript/behavior/

example.html• Ben Nolan, Dave Herman, Simon Wilison

• Prototype Behavior Library (built on prototype.js)

61

Page 117: Protoscript - Simplified prototype scripting

more resourcesArticles

Web 3.0 article: www.alistapart.com/articles/web3point0/looksgoodworkswell.blogspot.com/2005/11/visio-wireframe-toolkit-for-download.htmllooksgoodworkswell.blogspot.com/2005/11/animating-interactions-with-photoshop.htmlPrototyping with PowerPoint: blogs.msdn.com/jensenh/archive/2006/02/20/535444.aspxVisio - the interaction designer’s nail gun: http://www.guuui.com/issues/01_06.phpPDF Prototyping: http://www.gotomedia.com/gotoreport/may2005/news_0505_usable1.html

Productswww.axure.com/demo.aspxiRise Application Simulator: irise.com

Visio Stencilswww.boxesandarrows.com/view/storyboarding_rich_internet_applications_with_visio Visio Stencil Library: swipr.com Wireframe Stencils: http://iainstitute.org/tools/Garrett Dimon’s Stencils: http://www.garrettdimon.com/resources/templates-stencils-for-visio-omnigraffle

62

Page 118: Protoscript - Simplified prototype scripting

site - http://protoscript.comblog - http://looksgoodworkswell.com

presentation - http://billwscott.com/share/presentations/2007/rwe

63