| OLD | NEW |
| 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 /** | 5 /** |
| 6 * @fileoverview DragWrapper | 6 * @fileoverview DragWrapper |
| 7 * A class for simplifying HTML5 drag and drop. Classes should use this to | 7 * A class for simplifying HTML5 drag and drop. Classes should use this to |
| 8 * handle the nitty gritty of nested drag enters and leaves. | 8 * handle the nitty gritty of nested drag enters and leaves. |
| 9 */ | 9 */ |
| 10 cr.define('cr.ui', function() { | 10 cr.define('cr.ui', function() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 doDrop: assertNotReached, | 34 doDrop: assertNotReached, |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Creates a DragWrapper which listens for drag target events on |target| and | 38 * Creates a DragWrapper which listens for drag target events on |target| and |
| 39 * delegates event handling to |delegate|. | 39 * delegates event handling to |delegate|. |
| 40 * @param {!Element} target | 40 * @param {!Element} target |
| 41 * @param {!cr.ui.DragWrapperDelegate} delegate | 41 * @param {!cr.ui.DragWrapperDelegate} delegate |
| 42 * @constructor | 42 * @constructor |
| 43 */ | 43 */ |
| 44 function DragWrapper(target, delegate) { this.initialize(target, delegate); } | 44 function DragWrapper(target, delegate) { |
| 45 this.initialize(target, delegate); |
| 46 } |
| 45 | 47 |
| 46 DragWrapper.prototype = { | 48 DragWrapper.prototype = { |
| 47 initialize: function(target, delegate) { | 49 initialize: function(target, delegate) { |
| 48 target.addEventListener('dragenter', this.onDragEnter_.bind(this)); | 50 target.addEventListener('dragenter', this.onDragEnter_.bind(this)); |
| 49 target.addEventListener('dragover', this.onDragOver_.bind(this)); | 51 target.addEventListener('dragover', this.onDragOver_.bind(this)); |
| 50 target.addEventListener('drop', this.onDrop_.bind(this)); | 52 target.addEventListener('drop', this.onDrop_.bind(this)); |
| 51 target.addEventListener('dragleave', this.onDragLeave_.bind(this)); | 53 target.addEventListener('dragleave', this.onDragLeave_.bind(this)); |
| 52 | 54 |
| 53 this.target_ = target; | 55 this.target_ = target; |
| 54 this.delegate_ = delegate; | 56 this.delegate_ = delegate; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 this.target_.classList.remove('drag-target'); | 133 this.target_.classList.remove('drag-target'); |
| 132 this.delegate_.doDragLeave(e); | 134 this.delegate_.doDragLeave(e); |
| 133 }, | 135 }, |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 return { | 138 return { |
| 137 DragWrapper: DragWrapper, | 139 DragWrapper: DragWrapper, |
| 138 DragWrapperDelegate: DragWrapperDelegate, | 140 DragWrapperDelegate: DragWrapperDelegate, |
| 139 }; | 141 }; |
| 140 }); | 142 }); |
| OLD | NEW |