Controls, Extensions, and Events

1 view
Skip to first unread message

nlloyds

unread,
Nov 15, 2009, 9:44:21 PM11/15/09
to scripty2
It looks like some S2.UI controls are now in Thomas's branch, and they
look great.

I was wondering if S2 will have some documented way of adding controls
as extensions. It would be nice to have a great controls ecosystem
along the lines of dijit and jquery ui based on S2.

I've done some work on LivePipe UI (http://livepipe.net/) and there is
a lot of overlap with the new controls. Some sharing of code could
probably be done with this and other projects to make scripty the
"standard" platform for controls using Prototype.

One of the things that's great about LivePipe is Object.Event (the
same code is also used in Active Event (http://activejs.org/
event.html)), as working with events in all of the controls and any
other object is really easy to use and makes a consistent API
possible. Maybe S2 could implement some form of this pattern, as so
far the events used in the controls don't seem too obvious (I know
it's only alpha, though.) It looks like S2.UI.Behavior is close to
this, but Object.Event's events don't necessarily correspond with
elements.

Nathan

Andrew Dupont

unread,
Nov 24, 2009, 9:58:03 AM11/24/09
to scripty2
Andrew here. I wrote the UI controls.

On Nov 15, 8:44 pm, nlloyds <nllo...@gmail.com> wrote:
> I was wondering if S2 will have some documented way of adding controls
> as extensions. It would be nice to have a great controls ecosystem
> along the lines of dijit and jquery ui based on S2.

This implies two things:

1. Having a starting point from which to write the JavaScript for a
custom control. The idea is that all controls will subclass
`S2.UI.Base`, which would contain all the stuff you'd need for a
generic control. You'd be able to use the same conveniences within
your controls that are used by all the built-in controls: adding and
removing behaviors, etc.

2. The ability to make a custom control look and feel like the built-
in controls. For this, we've actually adopted jQuery UI's conventions
for HTML structure, class names, and the like. This means that any
jQuery UI theme [1] can be used in scripty2; it also means that
whatever themes come with scripty2, like the built-in one you see in
all the functional tests, will be compatible with jQuery UI.

Now, will all this be documented? Yes. (In time.)

> I've done some work on LivePipe UI (http://livepipe.net/) and there is
> a lot of overlap with the new controls. Some sharing of code could
> probably be done with this and other projects to make scripty the
> "standard" platform for controls using Prototype.

Agreed.

> One of the things that's great about LivePipe is Object.Event (the
> same code is also used in Active Event (http://activejs.org/
> event.html)), as working with events in all of the controls and any
> other object is really easy to use and makes a consistent API
> possible. Maybe S2 could implement some form of this pattern, as so
> far the events used in the controls don't seem too obvious (I know
> it's only alpha, though.) It looks like S2.UI.Behavior is close to
> this, but Object.Event's events don't necessarily correspond with
> elements.

Let me try to speak for the Prototype team: we like custom events a
lot, but we don't like the idea of mixing in "observability" to any
arbitrary object. Rather than have an object broadcast its own events,
we designed the `document` object to be the global event "broker," the
hub that all custom events go through.

S2 UI controls will broadcast custom events, but will do so through
the DOM. For instance, the `S2.UI.Menu` component (useful for context
menus and the like) is used by `S2.UI.Autocompleter` to display the
list of results. The menu uses custom events to tell the autocompleter
when it opens, when it closes, when a choice has been made. Some
events are explicitly cancelable — if you cancel a `ui:menu:opened`
event, for instance, the menu won't open after all. This is all quite
preliminary, but I promise it all makes sense in my cluttered head.

Cheers,
Andrew

[1] http://jqueryui.com/themeroller/
[2] http://github.com/madrobby/scripty2/blob/master/src/ui/controls/menu.js#L182

nlloyds

unread,
Nov 24, 2009, 11:18:43 AM11/24/09
to scripty2
Andrew,

Thanks for the reply. That makes sense. I'd love to help out on the
development of these and other controls. Are there any specific areas
where help is needed?

Nathan

Andrew Dupont

unread,
Nov 24, 2009, 12:20:24 PM11/24/09
to scripty2
You can try porting over the in-place editor from scripty1, if you
like. Aside from that, browse the new commits every so often and leave
comments on github.

Thanks!
Reply all
Reply to author
Forward
0 new messages