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 var MAX_APPS_PER_ROW = []; | 5 var MAX_APPS_PER_ROW = []; |
6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; | 6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; |
7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; | 7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; |
8 | 8 |
9 function getAppsCallback(data) { | 9 function getAppsCallback(data) { |
10 logEvent('received apps'); | 10 logEvent('received apps'); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 var multiplier = Math.floor(Math.abs(delta) / 50) + 1; | 517 var multiplier = Math.floor(Math.abs(delta) / 50) + 1; |
518 | 518 |
519 return sign * scalar * multiplier; | 519 return sign * scalar * multiplier; |
520 }, | 520 }, |
521 | 521 |
522 stopScroll_: function() { | 522 stopScroll_: function() { |
523 this.scrollListener_ = null; | 523 this.scrollListener_ = null; |
524 this.scrollMouseXY_ = null; | 524 this.scrollMouseXY_ = null; |
525 }, | 525 }, |
526 | 526 |
527 saveDrag: function() { | 527 saveDrag: function(draggedItem) { |
528 this.invalidate_(); | 528 this.invalidate_(); |
529 this.layout(); | 529 this.layout(); |
530 | 530 |
| 531 var draggedAppId = draggedItem.querySelector('a').getAttribute('app-id'); |
531 var appIds = this.data.filter(function(id) { | 532 var appIds = this.data.filter(function(id) { |
532 return id != 'web-store-entry'; | 533 return id != 'web-store-entry'; |
533 }); | 534 }); |
534 | 535 |
535 // Wait until the transitions are complete before notifying the browser. | 536 // Wait until the transitions are complete before notifying the browser. |
536 // Otherwise, the apps will be re-rendered while still transitioning. | 537 // Otherwise, the apps will be re-rendered while still transitioning. |
537 setTimeout(function() { | 538 setTimeout(function() { |
538 chrome.send('reorderApps', appIds); | 539 chrome.send('reorderApps', [draggedAppId, appIds]); |
539 }, this.transitionsDuration + 10); | 540 }, this.transitionsDuration + 10); |
540 }, | 541 }, |
541 | 542 |
542 layout: function(options) { | 543 layout: function(options) { |
543 options = options || {}; | 544 options = options || {}; |
544 if (!this.dirty_ && options.force != true) | 545 if (!this.dirty_ && options.force != true) |
545 return; | 546 return; |
546 | 547 |
547 try { | 548 try { |
548 var container = this.dragContainer; | 549 var container = this.dragContainer; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 a.href = localStrings.getString('web_store_url'); | 705 a.href = localStrings.getString('web_store_url'); |
705 a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16'); | 706 a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16'); |
706 a.className = 'item'; | 707 a.className = 'item'; |
707 return a; | 708 return a; |
708 } | 709 } |
709 }; | 710 }; |
710 })(); | 711 })(); |
711 | 712 |
712 // Enable drag and drop reordering of the app launcher. | 713 // Enable drag and drop reordering of the app launcher. |
713 var appDragAndDrop = new DragAndDropController(apps); | 714 var appDragAndDrop = new DragAndDropController(apps); |
OLD | NEW |