Commit b1f2f7d3b53f101339f5700b46fe516b0750bca6

This patch wraps the launcher pages. Works for just switching between pages and moving apps from one page to another.
  
1This patch will wrap the launcher pages. Works both for changing between pages and also moving apps from one page to another.
2Index: /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
3===================================================================
4--- .orig/usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
5+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
6@@ -84,7 +84,10 @@ var LauncherAssistant = Class.create({
7
8 this.reorderController = new ReorderController(this, this.onReorderFinished.bind(this));
9 Mojo.listen($('launcher_root'), Mojo.Event.propertyChange, this.onPageChange.bindAsEventListener(this));
10-
11+
12+ this.scrollStartingHandler = this.scrollStarting.bindAsEventListener(this);
13+ Mojo.listen($('launcher_root'), Mojo.Event.scrollStarting, this.scrollStartingHandler);
14+
15 this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems:true}, this.appMenuModel);
16
17 // pre-calculate commonly used measurements
18@@ -153,7 +156,25 @@ var LauncherAssistant = Class.create({
19 }
20 }
21 },
22-
23+
24+ scrollStarting: function(event) {
25+ event.scroller.addListener(this);
26+ },
27+
28+ moved: function(scrollEnding, position) {
29+ // snap to a valid location
30+ if ( Math.abs(position.x) > (this.pageDivs.length-1)*this.kPageWidth + 100)
31+ {
32+ $('launcher_root').mojo.setSnapIndex(0, false);
33+ this.updatePageIndicators();
34+ }
35+ else if( position.x - 100 > 0 )
36+ {
37+ $('launcher_root').mojo.setSnapIndex(this.pageDivs.length-1, false);
38+ this.updatePageIndicators();
39+ }
40+ },
41+
42 /* keep track of which page we are on */
43 onPageChange: function(event) {
44 this.activePageIndex = event.value;
45Index: /usr/lib/luna/system/luna-applauncher/app/controllers/reorder-controller.js
46===================================================================
47--- .orig/usr/lib/luna/system/luna-applauncher/app/controllers/reorder-controller.js
48+++ /usr/lib/luna/system/luna-applauncher/app/controllers/reorder-controller.js
49@@ -426,28 +426,71 @@ var ReorderController = Class.create({
50 },
51
52 _cyclePage: function(direction) {
53-
54 var canPage = false;
55- if (direction == -1 && this.activePage.previous() !== null) {
56+ var useFirst = false;
57+ var useLast = false;
58+ if (direction == -1 ){//&& this.activePage.previous() !== null) {
59 this.previousPage = this.activePage;
60- this.activePage = this.activePage.previous();
61+
62+ if(this.activePage.previous() == null)
63+ {
64+//not sure why this doesnt work and need to do while loop instead.
65+// this.activePage = this.launcherAssistant.pagesModel.getPage(this.launcherAssistant.pagesModel.getNumPages()-1);
66+ while(this.activePage.next() !== null)
67+ {
68+ this.activePage = this.activePage.next();
69+ }
70+ useLast = true;
71+ }
72+ else
73+ {
74+ this.activePage = this.activePage.previous();
75+ }
76+
77 canPage = true;
78 }
79- else if (direction == 1 && this.activePage.next() !== null) {
80+ else if (direction == 1 ){// && this.activePage.next() !== null) {
81 this.previousPage = this.activePage;
82- this.activePage = this.activePage.next();
83+
84+ if(this.activePage.next() == null)
85+ {
86+//not sure why this doesnt work and need to do while loop instead.
87+// this.activePage = this.launcherAssistant.pagesModel.getPage(0);
88+ while(this.activePage.previous() !== null)
89+ {
90+ this.activePage = this.activePage.previous();
91+ }
92+ useFirst = true;
93+ }
94+ else
95+ {
96+ this.activePage = this.activePage.next();
97+ }
98+
99 canPage = true;
100 }
101-
102+
103 if (canPage) {
104 // disable any more reordering while we transition to a new page
105 this._removeDropTargets();
106-
107+
108 // reveal the page we are about to scroll to
109 this.activePage.show();
110
111 this.pagingAnimating = true;
112- $('launcher_root').mojo.setSnapIndex(this.launcherAssistant.activePageIndex + direction, true);
113+
114+ if(useFirst)
115+ {
116+ $('launcher_root').mojo.setSnapIndex(0, true);
117+ }
118+ else if(useLast)
119+ {
120+ $('launcher_root').mojo.setSnapIndex(this.launcherAssistant.pagesModel.getNumPages()-1, true);
121+ }
122+ else
123+ {
124+ $('launcher_root').mojo.setSnapIndex(this.launcherAssistant.activePageIndex + direction, true);
125+ }
126 }
127 },
128