OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options.browser_options', function() { | 5 cr.define('options.browser_options', function() { |
6 /** @const */ var AutocompleteList = cr.ui.AutocompleteList; | 6 /** @const */ var AutocompleteList = cr.ui.AutocompleteList; |
7 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 7 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
9 | 9 |
10 /** | 10 /** |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 this.draggedItem = target; | 185 this.draggedItem = target; |
186 this.draggedItem.editable = false; | 186 this.draggedItem.editable = false; |
187 e.dataTransfer.effectAllowed = 'move'; | 187 e.dataTransfer.effectAllowed = 'move'; |
188 // We need to put some kind of data in the drag or it will be | 188 // We need to put some kind of data in the drag or it will be |
189 // ignored. Use the URL in case the user drags to a text field or the | 189 // ignored. Use the URL in case the user drags to a text field or the |
190 // desktop. | 190 // desktop. |
191 e.dataTransfer.setData('text/plain', target.urlField_.value); | 191 e.dataTransfer.setData('text/plain', target.urlField_.value); |
192 } | 192 } |
193 }, | 193 }, |
194 | 194 |
195 /* | 195 /** |
196 * Handles the dragenter event. | 196 * Handles the dragenter event. |
197 * @param {Event} e The dragenter event. | 197 * @param {Event} e The dragenter event. |
198 * @private | 198 * @private |
199 */ | 199 */ |
200 handleDragEnter_: function(e) { | 200 handleDragEnter_: function(e) { |
201 e.preventDefault(); | 201 e.preventDefault(); |
202 }, | 202 }, |
203 | 203 |
204 /* | 204 /** |
205 * Handles the dragover event. | 205 * Handles the dragover event. |
206 * @param {Event} e The dragover event. | 206 * @param {Event} e The dragover event. |
207 * @private | 207 * @private |
208 */ | 208 */ |
209 handleDragOver_: function(e) { | 209 handleDragOver_: function(e) { |
210 var dropTarget = this.getTargetFromDropEvent_(e); | 210 var dropTarget = this.getTargetFromDropEvent_(e); |
211 // Determines whether the drop target is to accept the drop. | 211 // Determines whether the drop target is to accept the drop. |
212 // The drop is only successful on another StartupPageListItem. | 212 // The drop is only successful on another StartupPageListItem. |
213 if (!(dropTarget instanceof StartupPageListItem) || | 213 if (!(dropTarget instanceof StartupPageListItem) || |
214 dropTarget == this.draggedItem || dropTarget.isPlaceholder) { | 214 dropTarget == this.draggedItem || dropTarget.isPlaceholder) { |
215 this.hideDropMarker_(); | 215 this.hideDropMarker_(); |
216 return; | 216 return; |
217 } | 217 } |
218 // Compute the drop postion. Should we move the dragged item to | 218 // Compute the drop postion. Should we move the dragged item to |
219 // below or above the drop target? | 219 // below or above the drop target? |
220 var rect = dropTarget.getBoundingClientRect(); | 220 var rect = dropTarget.getBoundingClientRect(); |
221 var dy = e.clientY - rect.top; | 221 var dy = e.clientY - rect.top; |
222 var yRatio = dy / rect.height; | 222 var yRatio = dy / rect.height; |
223 var dropPos = yRatio <= .5 ? 'above' : 'below'; | 223 var dropPos = yRatio <= .5 ? 'above' : 'below'; |
224 this.dropPos = dropPos; | 224 this.dropPos = dropPos; |
225 this.showDropMarker_(dropTarget, dropPos); | 225 this.showDropMarker_(dropTarget, dropPos); |
226 e.preventDefault(); | 226 e.preventDefault(); |
227 }, | 227 }, |
228 | 228 |
229 /* | 229 /** |
230 * Handles the drop event. | 230 * Handles the drop event. |
231 * @param {Event} e The drop event. | 231 * @param {Event} e The drop event. |
232 * @private | 232 * @private |
233 */ | 233 */ |
234 handleDrop_: function(e) { | 234 handleDrop_: function(e) { |
235 var dropTarget = this.getTargetFromDropEvent_(e); | 235 var dropTarget = this.getTargetFromDropEvent_(e); |
236 | 236 |
237 if (!(dropTarget instanceof StartupPageListItem) || | 237 if (!(dropTarget instanceof StartupPageListItem) || |
238 dropTarget.pageInfo_.modelIndex == -1) { | 238 dropTarget.pageInfo_.modelIndex == -1) { |
239 return; | 239 return; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 this.hideDropMarkerTimer_ = window.setTimeout(function() { | 312 this.hideDropMarkerTimer_ = window.setTimeout(function() { |
313 $('startupPagesListDropmarker').style.display = ''; | 313 $('startupPagesListDropmarker').style.display = ''; |
314 }, 100); | 314 }, 100); |
315 }, | 315 }, |
316 }; | 316 }; |
317 | 317 |
318 return { | 318 return { |
319 StartupPageList: StartupPageList | 319 StartupPageList: StartupPageList |
320 }; | 320 }; |
321 }); | 321 }); |
OLD | NEW |