diff --git a/js/iD/ui/DragAndDrop.js b/js/iD/ui/DragAndDrop.js index 34d68ae90..b2e7d8aae 100644 --- a/js/iD/ui/DragAndDrop.js +++ b/js/iD/ui/DragAndDrop.js @@ -23,12 +23,14 @@ declare("iD.ui.DragAndDrop", null, { ICONPATH: 'icons/', ITEMSPERROW: 5, - constructor:function(_divname,_map,_gridname) { - this.divname=_divname; - dom.byId(_divname).ondragover = lang.hitch(this,this.update); - dom.byId(_divname).ondrop = function(e) { e.preventDefault(); }; // required by Firefox - this.map=_map; - this.grid=dom.byId(_gridname); + constructor:function(divname, map, gridname) { + // summary: Singleton-like class for POI drag and drop. Loads a config file (draganddrop.json) + // on initialisation, then populates the drop-down palette with it. + this.divname=divname; + dom.byId(divname).ondragover = lang.hitch(this,this.update); + dom.byId(divname).ondrop = function(e) { e.preventDefault(); }; // required by Firefox + this.map=map; + this.grid=dom.byId(gridname); // Load drag and drop config file dojo.xhrGet({ @@ -41,6 +43,7 @@ declare("iD.ui.DragAndDrop", null, { }, drawGrid:function(obj) { + // summary: Draw the grid of icons based on the JSON-derived object loaded. var row; for (var i=0; i containing the steps, and its individual nodes - - stepsDiv:function() { return document.getElementById(this.stepsname); }, - stepsNodes:function() { return this.stepsDiv().childNodes; }, + stepsDiv:function() { + // summary: Getter for the
containing the steps. + return document.getElementById(this.stepsname); + }, + stepsNodes:function() { + // summary: Getter for the nodes of the
containing the steps. + return this.stepsDiv().childNodes; + }, + // ---------------- // Add/remove steps addStep:function(name,text) { + // summary: Add a step to the end of the list. + // name: String A reference to this step (for example, 'start'). + // text: String The text of the step. this.order.push(name); this.stepsDiv().appendChild(document.createElement('li')).innerHTML=text; }, insertStep:function(pos,name,text) { + // summary: Insert a step at a position within the list. + // pos: Number The index at which to insert the step. + // name: String A reference to this step (for example, 'start'). + // text: String The text of the step. this.order.splice(pos,0,name); this.stepsNodes()[pos+1].insertBefore(document.createElement('li')).innerHTML=text; }, setSteps:function(steps,order) { + // summary: Set the entire list of steps. + // steps: Object A hash of each step, keyed by reference name. For example: { start: 'Click to begin', ... } + // order: String An array of the step names, in the desired order. For example: ['start','add','finish'] this.clear(); for (var i=0; i=1; i--) { this.stepsDiv().removeChild(this.stepsNodes()[i]); } this.order=[]; }, + // --------------------------- // Change the highlighted step highlight:function(stepname) { + // summary: Highlight the step with the specified name, and dim all others. this.show(); this.currentStep=stepname; for (var i=1; i