13 ported and 1 new for 1.4.0.
[webos-internals:justyns-modifications.git] / app-launcher / app-launcher-reset-to-middle-page.patch
1 diff --git a/usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js b/usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
2 index 9057138..88eed9d 100644
3 --- a/usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
4 +++ b/usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
5 @@ -178,6 +178,25 @@ var LauncherAssistant = Class.create({
6                 SystemManagerService.showQuickLaunch(true);
7                 
8                 this.launchRequest = undefined;
9 +
10 +               /**
11 +                * Calculate middle page. For an even number of pages,
12 +                * this will be the lower side of the mid-point.
13 +                */
14 +               var numPages=this.pagesModel.getNumPages();
15 +               var middlePage = (numPages % 2) ? (numPages - 1) / 2: numPages / 2 - 1;
16 +
17 +               /* Reset launcher to middle page - seems we need to do scrollTo AND setSnapIndex to be fully compatible with Wrap Pages */
18 +               $('launcher_root').mojo.scrollTo((middlePage) * -this.kPageWidth, undefined, false, true);
19 +               this.activePageIndex = Math.abs($('launcher_root').mojo.getScrollPosition().left) / this.kPageWidth;
20 +               $('launcher_root').mojo.setSnapIndex(middlePage, false);
21 +               this.updatePageIndicators();
22 +
23 +               /* Jump scroll position back to top for all pages */
24 +               for (var i=0; i<numPages; i++) {
25 +                       var scroller = this.getPageScroller(i);
26 +                       if (scroller && scroller.mojo) { scroller.mojo.revealTop(); }
27 +               }
28         },
29         
30         onResize: function(event) {
31 @@ -618,6 +637,18 @@ var LauncherAssistant = Class.create({
32                 
33                 this.globalSearchAssistant.enable(true);
34  
35 +               /**
36 +                * Calculate middle page. For an even number of pages,
37 +                * this will be the lower side of the mid-point.
38 +                */
39 +               var middlePage = (numPages % 2) ? (numPages - 1) / 2: numPages / 2 - 1;
40 +
41 +               /* Set launcher to middle page - seems we need to do scrollTo AND setSnapIndex to be fully compatible with Wrap Pages */
42 +               $('launcher_root').mojo.scrollTo((middlePage) * -this.kPageWidth, undefined, false, true);
43 +               this.activePageIndex = Math.abs($('launcher_root').mojo.getScrollPosition().left) / this.kPageWidth;
44 +               $('launcher_root').mojo.setSnapIndex(middlePage, false);
45 +               this.updatePageIndicators();
46 +
47                 PalmSystem.launcherReady();
48         },
49