]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/form/_ListMouseMixin.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dijit / form / _ListMouseMixin.js.uncompressed.js
CommitLineData
f0cfe83e
AD
1define("dijit/form/_ListMouseMixin", [
2 "dojo/_base/declare", // declare
3 "dojo/mouse",
4 "dojo/on",
5 "dojo/touch",
6 "./_ListBase"
7], function(declare, mouse, on, touch, _ListBase){
8
9// module:
10// dijit/form/_ListMouseMixin
11
12return declare( "dijit.form._ListMouseMixin", _ListBase, {
13 // summary:
14 // a Mixin to handle mouse or touch events for a focus-less menu
15 // Abstract methods that must be defined externally:
16 //
17 // - onClick: item was chosen (mousedown somewhere on the menu and mouseup somewhere on the menu)
18 // tags:
19 // private
20
21 postCreate: function(){
22 this.inherited(arguments);
23
24 this.own(on(this.domNode, touch.press, function(evt){ evt.preventDefault(); })); // prevent focus shift on list scrollbar press
25
26 this._listConnect(touch.press, "_onMouseDown");
27 this._listConnect(touch.release, "_onMouseUp");
28 this._listConnect(mouse.enter, "_onMouseOver");
29 this._listConnect(mouse.leave, "_onMouseOut");
30 },
31
32 _onMouseDown: function(/*Event*/ evt, /*DomNode*/ target){
33 if(this._hoveredNode){
34 this.onUnhover(this._hoveredNode);
35 this._hoveredNode = null;
36 }
37 this._isDragging = true;
38 this._setSelectedAttr(target);
39 },
40
41 _onMouseUp: function(/*Event*/ evt, /*DomNode*/ target){
42 this._isDragging = false;
43 var selectedNode = this.selected;
44 var hoveredNode = this._hoveredNode;
45 if(selectedNode && target == selectedNode){
46 this.onClick(selectedNode);
47 }else if(hoveredNode && target == hoveredNode){ // drag to select
48 this._setSelectedAttr(hoveredNode);
49 this.onClick(hoveredNode);
50 }
51 },
52
53 _onMouseOut: function(/*Event*/ evt, /*DomNode*/ target){
54 if(this._hoveredNode){
55 this.onUnhover(this._hoveredNode);
56 this._hoveredNode = null;
57 }
58 if(this._isDragging){
59 this._cancelDrag = (new Date()).getTime() + 1000; // cancel in 1 second if no _onMouseOver fires
60 }
61 },
62
63 _onMouseOver: function(/*Event*/ evt, /*DomNode*/ target){
64 if(this._cancelDrag){
65 var time = (new Date()).getTime();
66 if(time > this._cancelDrag){
67 this._isDragging = false;
68 }
69 this._cancelDrag = null;
70 }
71 this._hoveredNode = target;
72 this.onHover(target);
73 if(this._isDragging){
74 this._setSelectedAttr(target);
75 }
76 }
77});
78
79});