| 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 cr.define('ntp4', function() { | 5 cr.define('ntp4', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // We can't pass the currently dragging tile via dataTransfer because of | 8 // We can't pass the currently dragging tile via dataTransfer because of |
| 9 // http://crbug.com/31037 | 9 // http://crbug.com/31037 |
| 10 var currentlyDraggingTile = null; | 10 var currentlyDraggingTile = null; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // image masks. | 118 // image masks. |
| 119 this.dragClone = this.cloneNode(true); | 119 this.dragClone = this.cloneNode(true); |
| 120 this.dragClone.style.right = ''; | 120 this.dragClone.style.right = ''; |
| 121 this.dragClone.classList.add('drag-representation'); | 121 this.dragClone.classList.add('drag-representation'); |
| 122 $('card-slider-frame').appendChild(this.dragClone); | 122 $('card-slider-frame').appendChild(this.dragClone); |
| 123 this.eventTracker.add(this.dragClone, 'webkitTransitionEnd', | 123 this.eventTracker.add(this.dragClone, 'webkitTransitionEnd', |
| 124 this.onDragCloneTransitionEnd_.bind(this)); | 124 this.onDragCloneTransitionEnd_.bind(this)); |
| 125 | 125 |
| 126 this.classList.add('dragging'); | 126 this.classList.add('dragging'); |
| 127 // offsetLeft is mirrored in RTL. Un-mirror it. | 127 // offsetLeft is mirrored in RTL. Un-mirror it. |
| 128 var offsetLeft = ntp4.isRTL() ? | 128 var offsetLeft = isRTL() ? |
| 129 this.parentNode.clientWidth - this.offsetLeft : | 129 this.parentNode.clientWidth - this.offsetLeft : |
| 130 this.offsetLeft; | 130 this.offsetLeft; |
| 131 this.dragOffsetX = e.x - offsetLeft - this.parentNode.offsetLeft; | 131 this.dragOffsetX = e.x - offsetLeft - this.parentNode.offsetLeft; |
| 132 this.dragOffsetY = e.y - this.offsetTop - | 132 this.dragOffsetY = e.y - this.offsetTop - |
| 133 // Unlike offsetTop, this value takes scroll position into account. | 133 // Unlike offsetTop, this value takes scroll position into account. |
| 134 this.parentNode.getBoundingClientRect().top; | 134 this.parentNode.getBoundingClientRect().top; |
| 135 | 135 |
| 136 this.onDragMove_(e); | 136 this.onDragMove_(e); |
| 137 }, | 137 }, |
| 138 | 138 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 clone.classList.remove('real'); | 225 clone.classList.remove('real'); |
| 226 clone.classList.add('doppleganger'); | 226 clone.classList.add('doppleganger'); |
| 227 var clonelets = clone.querySelectorAll('.real'); | 227 var clonelets = clone.querySelectorAll('.real'); |
| 228 for (var i = 0; i < clonelets.length; i++) { | 228 for (var i = 0; i < clonelets.length; i++) { |
| 229 clonelets[i].classList.remove('real'); | 229 clonelets[i].classList.remove('real'); |
| 230 } | 230 } |
| 231 | 231 |
| 232 this.appendChild(clone); | 232 this.appendChild(clone); |
| 233 this.doppleganger_ = clone; | 233 this.doppleganger_ = clone; |
| 234 | 234 |
| 235 if (ntp4.isRTL()) | 235 if (isRTL()) |
| 236 x *= -1; | 236 x *= -1; |
| 237 | 237 |
| 238 this.doppleganger_.style.WebkitTransform = 'translate(' + x + 'px, ' + | 238 this.doppleganger_.style.WebkitTransform = 'translate(' + x + 'px, ' + |
| 239 y + 'px)'; | 239 y + 'px)'; |
| 240 }, | 240 }, |
| 241 | 241 |
| 242 /** | 242 /** |
| 243 * Destroys the current doppleganger. | 243 * Destroys the current doppleganger. |
| 244 */ | 244 */ |
| 245 clearDoppleganger: function() { | 245 clearDoppleganger: function() { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 getWouldBeIndexForPoint_: function(x, y) { | 821 getWouldBeIndexForPoint_: function(x, y) { |
| 822 var grid = this.gridValues_; | 822 var grid = this.gridValues_; |
| 823 var layout = this.layoutValues_; | 823 var layout = this.layoutValues_; |
| 824 | 824 |
| 825 var gridClientRect = this.tileGrid_.getBoundingClientRect(); | 825 var gridClientRect = this.tileGrid_.getBoundingClientRect(); |
| 826 var col = Math.floor((x - gridClientRect.left - layout.leftMargin) / | 826 var col = Math.floor((x - gridClientRect.left - layout.leftMargin) / |
| 827 layout.colWidth); | 827 layout.colWidth); |
| 828 if (col < 0 || col >= layout.numRowTiles) | 828 if (col < 0 || col >= layout.numRowTiles) |
| 829 return -1; | 829 return -1; |
| 830 | 830 |
| 831 if (ntp4.isRTL()) | 831 if (isRTL()) |
| 832 col = layout.numRowTiles - 1 - col; | 832 col = layout.numRowTiles - 1 - col; |
| 833 | 833 |
| 834 var row = Math.floor((y - gridClientRect.top) / layout.rowHeight); | 834 var row = Math.floor((y - gridClientRect.top) / layout.rowHeight); |
| 835 return row * layout.numRowTiles + col; | 835 return row * layout.numRowTiles + col; |
| 836 }, | 836 }, |
| 837 | 837 |
| 838 /** | 838 /** |
| 839 * Window resize event handler. Window resizes may trigger re-layouts. | 839 * Window resize event handler. Window resizes may trigger re-layouts. |
| 840 * @param {Object} e The resize event. | 840 * @param {Object} e The resize event. |
| 841 */ | 841 */ |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 assert(false); | 1230 assert(false); |
| 1231 }, | 1231 }, |
| 1232 }; | 1232 }; |
| 1233 | 1233 |
| 1234 return { | 1234 return { |
| 1235 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1235 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
| 1236 setCurrentDropEffect: setCurrentDropEffect, | 1236 setCurrentDropEffect: setCurrentDropEffect, |
| 1237 TilePage: TilePage, | 1237 TilePage: TilePage, |
| 1238 }; | 1238 }; |
| 1239 }); | 1239 }); |
| OLD | NEW |