Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/browser/resources/ntp/drag_drop_controller.js

Issue 6543017: Track which apps the user has re-ordered on the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix presubmit check Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/ntp/apps.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The delegate interface: 5 // The delegate interface:
6 // dragContainer --> 6 // dragContainer -->
7 // element containing the draggable items 7 // element containing the draggable items
8 // 8 //
9 // transitionsDuration --> 9 // transitionsDuration -->
10 // length of time of transitions in ms 10 // length of time of transitions in ms
11 // 11 //
12 // dragItem --> 12 // dragItem -->
13 // get / set property containing the item being dragged 13 // get / set property containing the item being dragged
14 // 14 //
15 // getItem(e) --> 15 // getItem(e) -->
16 // get's the item that is under the mouse event |e| 16 // get's the item that is under the mouse event |e|
17 // 17 //
18 // canDropOn(coordinates) --> 18 // canDropOn(coordinates) -->
19 // returns true if the coordinates (relative to the drag container) 19 // returns true if the coordinates (relative to the drag container)
20 // point to a valid place to drop an item 20 // point to a valid place to drop an item
21 // 21 //
22 // setDragPlaceholder(coordinates) --> 22 // setDragPlaceholder(coordinates) -->
23 // tells the delegate that the dragged item is currently above 23 // tells the delegate that the dragged item is currently above
24 // the specified coordinates. 24 // the specified coordinates.
25 // 25 //
26 // saveDrag() --> 26 // saveDrag(draggedItem) -->
27 // tells the delegate that the drag is done. move the item to the 27 // tells the delegate that the drag is done. move the item to the
28 // position last specified by setDragPlaceholder. (e.g., commit changes) 28 // position last specified by setDragPlaceholder (e.g., commit changes).
29 // draggedItem was the item being dragged.
29 // 30 //
30 31
31 // The distance, in px, that the mouse must move before initiating a drag. 32 // The distance, in px, that the mouse must move before initiating a drag.
32 var DRAG_THRESHOLD = 35; 33 var DRAG_THRESHOLD = 35;
33 34
34 function DragAndDropController(delegate) { 35 function DragAndDropController(delegate) {
35 this.delegate_ = delegate; 36 this.delegate_ = delegate;
36 37
37 // Install the 'mousedown' handler, the entry point to drag and drop. 38 // Install the 'mousedown' handler, the entry point to drag and drop.
38 var el = this.delegate_.dragContainer; 39 var el = this.delegate_.dragContainer;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 }, 156 },
156 157
157 handleDrop_: function() { 158 handleDrop_: function() {
158 this.disableHandlers_(); 159 this.disableHandlers_();
159 160
160 var dragItem = this.delegate_.dragItem; 161 var dragItem = this.delegate_.dragItem;
161 if (!dragItem) 162 if (!dragItem)
162 return; 163 return;
163 164
164 this.delegate_.dragItem = this.startItem_ = null; 165 this.delegate_.dragItem = this.startItem_ = null;
165 this.delegate_.saveDrag(); 166 this.delegate_.saveDrag(dragItem);
166 dragItem.classList.remove('dragging'); 167 dragItem.classList.remove('dragging');
167 168
168 setTimeout(function() { 169 setTimeout(function() {
169 // Keep the flag around a little so other 'mouseup' and 'click' 170 // Keep the flag around a little so other 'mouseup' and 'click'
170 // listeners know the event is from a drag operation. 171 // listeners know the event is from a drag operation.
171 this.isDragging_ = false; 172 this.isDragging_ = false;
172 dragItem.style.zIndex = 0; 173 dragItem.style.zIndex = 0;
173 }.bind(this), this.delegate_.transitionsDuration); 174 }.bind(this), this.delegate_.transitionsDuration);
174 }, 175 },
175 176
(...skipping 26 matching lines...) Expand all
202 203
203 dragItem.style.left = x + 'px'; 204 dragItem.style.left = x + 'px';
204 dragItem.style.top = y + 'px'; 205 dragItem.style.top = y + 'px';
205 206
206 // Update the layouts and positions based on the new drag location. 207 // Update the layouts and positions based on the new drag location.
207 this.handleDragOver_(); 208 this.handleDragOver_();
208 209
209 this.delegate_.scrollPage(this.mouseXY_); 210 this.delegate_.scrollPage(this.mouseXY_);
210 } 211 }
211 }; 212 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp/apps.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698