| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/on", |
| 4 |
"dojo/touch", |
| 5 |
"./_ListBase" |
| 6 |
], function(declare, on, touch, _ListBase){ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
return declare("dijit.form._ListMouseMixin", _ListBase, { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
postCreate: function(){ |
| 21 |
this.inherited(arguments); |
| 22 |
|
| 23 |
|
| 24 |
this.domNode.dojoClick = true; |
| 25 |
|
| 26 |
this._listConnect("click", "_onClick"); |
| 27 |
this._listConnect("mousedown", "_onMouseDown"); |
| 28 |
this._listConnect("mouseup", "_onMouseUp"); |
| 29 |
this._listConnect("mouseover", "_onMouseOver"); |
| 30 |
this._listConnect("mouseout", "_onMouseOut"); |
| 31 |
}, |
| 32 |
|
| 33 |
_onClick: function( evt, target){ |
| 34 |
this._setSelectedAttr(target, false); |
| 35 |
if(this._deferredClick){ |
| 36 |
this._deferredClick.remove(); |
| 37 |
} |
| 38 |
this._deferredClick = this.defer(function(){ |
| 39 |
this._deferredClick = null; |
| 40 |
this.onClick(target); |
| 41 |
}); |
| 42 |
}, |
| 43 |
|
| 44 |
_onMouseDown: function( evt, target){ |
| 45 |
if(this._hoveredNode){ |
| 46 |
this.onUnhover(this._hoveredNode); |
| 47 |
this._hoveredNode = null; |
| 48 |
} |
| 49 |
this._isDragging = true; |
| 50 |
this._setSelectedAttr(target, false); |
| 51 |
}, |
| 52 |
|
| 53 |
_onMouseUp: function( evt, target){ |
| 54 |
this._isDragging = false; |
| 55 |
var selectedNode = this.selected; |
| 56 |
var hoveredNode = this._hoveredNode; |
| 57 |
if(selectedNode && target == selectedNode){ |
| 58 |
this.defer(function(){ |
| 59 |
this._onClick(evt, selectedNode); |
| 60 |
}); |
| 61 |
}else if(hoveredNode){ |
| 62 |
this.defer(function(){ |
| 63 |
this._onClick(evt, hoveredNode); |
| 64 |
}); |
| 65 |
} |
| 66 |
}, |
| 67 |
|
| 68 |
_onMouseOut: function( evt, target){ |
| 69 |
if(this._hoveredNode){ |
| 70 |
this.onUnhover(this._hoveredNode); |
| 71 |
this._hoveredNode = null; |
| 72 |
} |
| 73 |
if(this._isDragging){ |
| 74 |
this._cancelDrag = (new Date()).getTime() + 1000; |
| 75 |
} |
| 76 |
}, |
| 77 |
|
| 78 |
_onMouseOver: function( evt, target){ |
| 79 |
if(this._cancelDrag){ |
| 80 |
var time = (new Date()).getTime(); |
| 81 |
if(time > this._cancelDrag){ |
| 82 |
this._isDragging = false; |
| 83 |
} |
| 84 |
this._cancelDrag = null; |
| 85 |
} |
| 86 |
this._hoveredNode = target; |
| 87 |
this.onHover(target); |
| 88 |
if(this._isDragging){ |
| 89 |
this._setSelectedAttr(target, false); |
| 90 |
} |
| 91 |
} |
| 92 |
}); |
| 93 |
}); |