=Change maxcarlson-20101229-tsP by maxcarl...@friendly on 2010-12-29 09:42:25 
PST
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: UPDATED: Add draggable and droppable mixins

Bugs Fixed: LPP-9591 - Add dragable and dropable mixin

Technical Reviewer: ptw
QA Reviewer: ffeng

Release Notes: New draggable and droppable mixins add seamless drag and drop 
capability to any view.  See examples/draggable.lzx or the documentation for 
more details.

Overview: Adds draggable, droppable and a global dragmanager.  I'm going to 
check this in so folks can play with it.

Details: Updated to address Tucker and Andre's comments:

Bugs:

1) draggable:  There's a paste-oh in your doc -- two open <canvas> with only 
one close </canvas>

Fixed.

2) draggable:  Please use the regex '\\s*,\\s*' for your split pattern.

Fixed.

3) dragmanager:  A component should not be using a private LFC api 
(mouseevent).  Maybe we can motivate Andre to finish his prototype code for 
http://jira.openlaszlo.org/jira/browse/LPP-6034 and solve the "event might not 
be defined" problem more elegantly?

Fixed.

Issues:

1) I wonder if we should be more generic in some of the terms, instead of using 
`drag`* and `drop`*, use `source`* and `destination`*?  In particular, 
`droptest` might be better called something like `validdestination` and 
`dragtest` be `validsource`?

I renamed the relevant *test and *types methods and attributes.

2) Should draggables also register with the dragmanager, so for instance the 
dragmanager could (optionally) highlight them when you mouse over them to 
indicate that they are draggable?

We can add this later if we decide we need it, but I wasn't sure how to expose 
this in a clean way.  Would it be an event or attribute on droppable?

  a) I don't think you want the debug warning when there are no valid 
destinations for a source.  This could very much be a normal thing, and it 
would be indicated by the above:  the source would not highlight when you mouse 
over it, because it has no matching destinations (at the time).

I commented this out for now

Comments:

1) LzTrack, you could make unregistering more efficient by storing the index of 
the view in the list instead of just true in the UID hash.

I can't do this because the indexes change - see Array.splice().

2) And echoing Andre's comment, I suppose it is a stylistic choice, but in 
general we tend to use === only when it's additional semantics is necessary.  I 
think using it everywhere makes code harder to read, because most readers will 
trip over it and think "why id he using identity here?"

Fixed.

>From Andre:
Concerning the LzTrack.lzs changes:

> -            if (reglist.length == 0) {
> +            if (reglist.length === 0) {
I wouldn't go so far and use strict equality checks for number literals in this 
case.

Agreed and fixed.

And there is still one non-strict does-not-equals operator in __LZtopview()
>         // nodeLevel is equal
>         while (atemp.immediateparent != btemp.immediateparent) {
>             atemp = atemp.immediateparent;
>             btemp = btemp.immediateparent;
>         }

Fixed.

Apart from that I'm fine with the changes for register(). For unregister() you 
may want to check "__LZuids" first and later break early from the loop after 
removing the array element.
>
> if (reglist && reglist.__LZuids[v.__LZUID]) {
>   delete reglist.__LZuids[v.__LZUID];
>   for (...) {
>     if (reglist[i] === v) {
>        ....
>        reglist.splice(i, 1);
>        break; // no multiple entries possible, cf. register()
>     }
>   }
> } 

Fixed.


Otherwise:
LzTrack - Prevent duplicate registration for a given view/group.  == -> ===.

lzx-autoincludes - Add autoinclude entries for draggable and droppable mixins.

boxmodel - Remove explicit include from doc example, as it's no longer needed.

draggable/library - All dependencies for draggable/droppable

draggable - Implements the draggable mixin.  See the docs for how to use.

droppable - Implements the droppable mixin.  See the docs for how to use.

dragmanager - Tracks global drag state, delegates events to draggable and 
droppable instances.

Tests: Inline doc example and examples/draggable.lzx work consistently across 
all runtimes.

Files:
M       WEB-INF/lps/lfc/services/LzTrack.lzs
M       WEB-INF/lps/misc/lzx-autoincludes.properties
M       lps/components/mixins/boxmodel.lzx
A       lps/components/mixins/draggable
A       lps/components/mixins/draggable/library.lzx
A       lps/components/mixins/draggable/draggable.lzx
A       lps/components/mixins/draggable/dragmanager.lzx
A       lps/components/mixins/draggable/droppable.lzx
A       examples/draggable.lzx

Changeset: 
http://svn.openlaszlo.org/openlaszlo/patches/maxcarlson-20101229-tsP.tar

Reply via email to