Changeset 14257 for dojo/trunk/dnd

Show
Ignore:
Timestamp:
07/03/08 15:50:20 (5 months ago)
Author:
elazutkin
Message:

dnd: adding the autoSync option, and the AutoSource? class, which utilizes it by default.
Refs #7045. !strict.

Location:
dojo/trunk/dnd
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/dnd/Selector.js

    r14154 r14257  
    1818                // node: Node: node or node's id to build the selector on 
    1919                // params: Object: a dict of parameters, recognized parameters are: 
    20                 //      singular: Boolean: allows selection of only one element, if true 
    21                 //      the rest of parameters are passed to the container 
     20                //      singular: Boolean 
     21                //              allows selection of only one element, if true 
     22                //              the rest of parameters are passed to the container 
     23                //      autoSync: Boolean 
     24                //              autosynchronizes the source with its list of DnD nodes, 
     25                //              false by default 
    2226                if(!params){ params = {}; } 
    2327                this.singular = params.singular; 
     28                this.autoSync = params.autoSync; 
    2429                // class-specific variables 
    2530                this.selection = {}; 
     
    152157                // summary: event processor for onmousedown 
    153158                // e: Event: mouse event 
     159                if(this.autoSync){ this.sync(); } 
    154160                if(!this.current){ return; } 
    155161                if(!this.singular && !dojo.dnd.getCopyKeyState(e) && !e.shiftKey && (this.current.id in this.selection)){ 
  • dojo/trunk/dnd/Source.js

    r14158 r14257  
    4343        //              true by default, works only if copyOnly is true 
    4444        //      withHandles: Boolean? 
    45         //              allows dragging only by handles 
     45        //              allows dragging only by handles, false by default 
    4646        this.isSource = isSource; 
    4747        this.accept = accept; 
    4848        this.horizontal = horizontal; 
    4949        this.copyOnly = copyOnly; 
     50        this.selfCopy = selfCopy; 
     51        this.selfAccept = selfAccept; 
    5052        this.withHandles = withHandles; 
    5153} 
     
    6365        skipForm: false, 
    6466        withHandles: false, 
     67        autoSync: false, 
    6568        accept: ["text"], 
    6669         
     
    238241                // nodes: Array: the list of transferred items 
    239242                // copy: Boolean: copy items, if true, move items otherwise 
     243                if(this.autoSync){ this.sync(); } 
    240244                if(this.isSource){ 
    241245                        this._changeState("Source", this == source ? (copy ? "Copied" : "Moved") : ""); 
     
    464468        } 
    465469}); 
     470 
     471dojo.declare("dojo.dnd.AutoSource", dojo.dnd.Source, { 
     472        // summary: a source, which syncs its DnD nodes by default 
     473         
     474        constructor: function(node, params){ 
     475                // summary: a constructor of the AutoSource --- see the Source constructor for details 
     476                this.autoSync = true; 
     477        }, 
     478 
     479        // markup methods 
     480        markupFactory: function(params, node){ 
     481                params._skipStartup = true; 
     482                return new dojo.dnd.AutoSource(node, params); 
     483        } 
     484});