updates and additions
[webos-internals:jeffrotulls-modifications.git] / browser / browser-mega-mix.patch
1 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
2 index 6bf5870..5edd0ca 100644
3 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
4 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
5 @@ -12,13 +12,53 @@ MenuData.ApplicationMenu = {
6                 label: $L('New Card'),
7                 command: 'new-page-cmd'
8         },
9 +
10 +       EnableGesture: {
11 +               label: $L('Enable Gesture'),
12 +               command: 'enable-gesture-cmd',
13 +               checkEnabled: true
14 +       },
15 +       DisableGesture: {
16 +               label: $L('Disable Gesture'),
17 +               command: 'disable-gesture-cmd',
18 +               checkEnabled: true
19 +       },      
20         
21         SharePage: {
22                 label: $L('Share'),
23                 command: 'share-page-cmd',
24                 checkEnabled: true
25         },
26 -       
27 +
28 +       NeatoThatUrl: {
29 +               label: $L('Neato! it'),
30 +               command: 'add-neato-cmd',
31 +               checkEnabled: true
32 +       },
33 +
34 +       TweetViaBadKitty: {
35 +               label: $L('Tweet Link'),
36 +               command: 'add-badkitty-cmd',
37 +               checkEnabled: true
38 +       },
39 +               ShortenURL: {
40 +               label: $L('Shorten URL'),
41 +               command: 'shorten-url-cmd',
42 +               checkEnabled: true
43 +       },
44 +
45 +       AddToRelego: {
46 +               label: $L('Add To Relego'),
47 +               command: 'add-relego-cmd',
48 +               checkEnabled: true
49 +       },
50 +
51 +       AddToSpareTime: {
52 +               label: $L('Add To Spare Time'),
53 +               command: 'add-sparetime-cmd',
54 +               checkEnabled: true
55 +       },
56 +                               
57         AddToLauncher: {
58                 label: $L('Add to Launcher'),
59                 command: 'add-launch-icon-cmd',
60 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
61 index 388cffc..da7b263 100644
62 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
63 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
64 @@ -93,7 +93,7 @@ PageAssistant.prototype.setup = function() {
65                 this._updateOrientation();
66  
67                 // Allow override of 'back' gesture in landscape mode.
68 -               this.controller.useLandscapePageUpDown(true);
69 +               this.controller.useLandscapePageUpDown(false);
70  
71                 // Create the browser server status control.
72                 this._browserServerStatus = new BrowserServerStatus(this.controller);
73 @@ -303,6 +303,9 @@ PageAssistant.prototype.activate = function(message) {
74         try {
75                 
76                 this._updateOrientation();
77 +
78 +               // FullScreen Browser
79 +        this.controller.enableFullScreenMode(true);
80                 
81                 // Update any pending web preferences changes
82                 AppAssistant.WebPreferences.activate(this._webView.mojo);
83 @@ -791,16 +794,31 @@ PageAssistant.prototype._setupMenus = function() {
84                 this.appMenuModel = {
85                         visible: true,
86                         items: [
87 -                               MenuData.ApplicationMenu.NewCard,
88 -                               MenuData.ApplicationMenu.AddBookmark,
89 +                               {
90 +                                       label: $L("On/Off Gesture"),
91 +                                       items: [
92 +                                           {label:$L('Enable Gesture'),     shortcut:'e', command:'enable-gesture-cmd'},
93 +                        {label:$L('Disable Gesture'),     shortcut:'d', command:'disable-gesture-cmd'},
94 +                                                  ]
95 +                               },      
96 +                               {label:$L('New Card'),     shortcut:'n', command:'new-page-cmd'},
97 +                               {label:$L('Add Bookmark'),     shortcut:'m', command:'add-bookmark-cmd'},
98                                 {
99                                         label: $L("Page"),
100                                         items: [
101 -                                               MenuData.ApplicationMenu.AddToLauncher,
102 -                                               MenuData.ApplicationMenu.SharePage]
103 +                                               MenuData.ApplicationMenu.ShortenURL,
104 +                                               MenuData.ApplicationMenu.NeatoThatUrl,
105 +                                               MenuData.ApplicationMenu.TweetViaBadKitty,
106 +                                               MenuData.ApplicationMenu.AddToRelego,
107 +                                               MenuData.ApplicationMenu.AddToSpareTime,
108 +                                               {label:$L('Add To Launcher'),     shortcut:'l', command:'add-launch-icon-cmd'},
109 +                                               {label:$L('Share Page'),     shortcut:'s', command:'share-page-cmd'},
110 +                       {label:$L('Refresh Page'),     shortcut:'r', command:'refresh'},
111 +                           ]
112                                 },
113 -                               MenuData.ApplicationMenu.ShowBookmarks,
114 -                               MenuData.ApplicationMenu.ShowHistory]
115 +                               {label:$L('Bookmarks'),     shortcut:'b', command:'show-bookmarks-cmd'},
116 +                               {label:$L('History'),     shortcut:'h', command:'show-history-cmd'},
117 +                           ]
118                 };
119  
120                 this.controller.setupWidget(Mojo.Menu.appMenu, undefined, this.appMenuModel);
121 @@ -1946,6 +1964,7 @@ PageAssistant.prototype.moved = function(scrollState) {
122                         this._addressBar.hide();
123                         this.chrome.hide();
124  
125 +                       this.controller.enableFullScreenMode(true);
126                         // Only focus this webview widget if this assistant has
127                         // focus. All page-assisants can receive 'moved' events
128                         // so we have to be careful when explicitly setting the
129 @@ -1970,6 +1989,7 @@ PageAssistant.prototype.moved = function(scrollState) {
130                 this._addressBar.show();
131                 this.chrome.show();
132  
133 +               this.controller.enableFullScreenMode(false);
134         } else {
135                 //Mojo.Log.info("-> TOP == 0 Do Nothing.");
136                 // Do nothing.
137 @@ -2156,6 +2176,10 @@ PageAssistant.prototype.handleCommand = function(event) {
138                                         this._openBookmarkView();
139                                         break;
140  
141 +                               case MenuData.ApplicationMenu.DisableGesture.command:
142 +                                       this.controller.useLandscapePageUpDown(false);
143 +                                       break;
144 +
145                                 case MenuData.ApplicationMenu.NewCard.command:
146                                         this._newBrowserPage();
147                                         break;
148 @@ -2166,6 +2190,189 @@ PageAssistant.prototype.handleCommand = function(event) {
149                                         this.showBookmarkDialog(BookmarkDialogAssistant.createBookmarkTask, urlReference);
150                                         break;
151  
152 +                               
153 +                               case MenuData.ApplicationMenu.NeatoThatUrl.command:
154 +                                       // Lets Neato! that URL
155 +                                       try{
156 +                                               this.neatoappid = "com.zhephree.neato";
157 +                                               this.controller.serviceRequest("palm://com.palm.applicationManager", {
158 +                                                       method: 'open',
159 +                                                       parameters: {
160 +                                                               id: this.neatoappid,
161 +                                                               params: {send: '{"a":"url","c":"'+this.currentUrl+'"}'}
162 +                                                       },
163 +                                                       onFailure:function(){
164 +                                                               //--> Promt to download if Neato! is not installed
165 +                                                               this.controller.showAlertDialog({
166 +                                                                       onChoose: function(value){
167 +                                                                               if (value=="yes"){
168 +                                                                                       //--> open app catalog at Neato! page
169 +                                                                                       this.controller.serviceRequest('palm://com.palm.applicationManager', {
170 +                                                                                               method:'open',
171 +                                                                                               parameters:{
172 +                                                                                                       target: "http://developer.palm.com/appredirect/?packageid=" + this.neatoappid
173 +                                                                                               }
174 +                                                                                       });
175 +                                                                               }
176 +                                                                       },
177 +                                                                       preventCancel: false,
178 +                                                                       title: $L("Neato! Not Installed"),
179 +                                                                       message: $L("Neato! is not installed. Would you like to download it?"),
180 +                                                                       choices:[
181 +                                                                               {label:$L('Yes'), value:"yes", type:'affirmative'},
182 +                                                                               {label:$L('No'), value:"no", type:'dismissal'}
183 +                                                                       ]
184 +                                                               });
185 +                                                       }.bind(this)
186 +                                               })
187 +                                       }catch(e){
188 +                                               Mojo.Log.error("Neato Patch Error: " + e);
189 +                                       }
190 +                                       break;
191 +                               
192 +                               case MenuData.ApplicationMenu.TweetViaBadKitty.command:
193 +                                       // Send the URL to Bad Kitty
194 +                                       try{
195 +                                               this.badkittyappid = "com.superinhuman.badkitty";
196 +                                               this.controller.serviceRequest("palm://com.palm.applicationManager", {
197 +                                                       method: 'open',
198 +                                                       parameters: {
199 +                                                               id: this.badkittyappid,
200 +                                                               params: {action: 'tweet', tweet: this.currentTitle + ' ' + this.currentUrl}
201 +                                                       },
202 +                                                       onFailure:function(){
203 +                                                               //--> How do they not have it installed?
204 +                                                               this.controller.showAlertDialog({
205 +                                                                       onChoose: function(value){
206 +                                                                               if (value=="yes"){
207 +                                                                                       //--> And weee'rrre.. of to see the wizard
208 +                                                                                       this.controller.serviceRequest('palm://com.palm.applicationManager', { 
209 +                                                                                               method:'open',
210 +                                                                                               parameters:{
211 +                                                                                                       target: "http://developer.palm.com/appredirect/?packageid=" + this.badkittyappid
212 +                                                                                               }
213 +                                                                                       });
214 +                                                                               }
215 +                                                                       },
216 +                                                                       preventCancel: false,
217 +                                                                       title: $L("Bad Kitty Not Installed"),
218 +                                                                       message: $L("Bad Kitty is not installed. Would you like to download it?"),
219 +                                                                       choices:[
220 +                                                                               {label:$L('Yes'), value:"yes", type:'affirmative'},
221 +                                                                               {label:$L('No'), value:"no", type:'dismissal'}
222 +                                                                       ]
223 +                                                               });
224 +                                                       }.bind(this)
225 +                                               })
226 +                                       }catch(e){
227 +                                               Mojo.Log.error("Bad Kitty Patch Error: " + e);
228 +                                       }
229 +                                       break;
230 +                               
231 +                               case MenuData.ApplicationMenu.AddToRelego.command:
232 +                                       // Send the URL to Spare Time
233 +                                       try{
234 +                                               this.relegoappid = "com.webosroundup.relego";
235 +                                               this.controller.serviceRequest("palm://com.palm.applicationManager", {
236 +                                                       method: 'open',
237 +                                                       parameters: {
238 +                                                               id: this.relegoappid,
239 +                                                               params: {action: 'addtorelego', url: this.currentUrl, title: this.currentTitle}
240 +                                                       },
241 +                                                       onFailure:function(){
242 +                                                               //--> How do they not have it installed?
243 +                                                               this.controller.showAlertDialog({
244 +                                                                       onChoose: function(value){
245 +                                                                               if (value=="yes"){
246 +                                                                                       //--> And weee'rrre.. of to see the wizard
247 +                                                                                       this.controller.serviceRequest('palm://com.palm.applicationManager', {
248 +                                                                                               method:'open',
249 +                                                                                               parameters:{
250 +                                                                                                       target: "http://developer.palm.com/appredirect/?packageid=" + this.relegoappid
251 +                                                                                               }
252 +                                                                                       });
253 +                                                                               }
254 +                                                                       },
255 +                                                                       preventCancel: false,
256 +                                                                       title: $L("Relego Not Installed"),
257 +                                                                       message: $L("Relego is not installed. Would you like to download it? It's Free!"),
258 +                                                                       choices:[
259 +                                                                               {label:$L('Yes'), value:"yes", type:'affirmative'},
260 +                                                                               {label:$L('No'), value:"no", type:'dismissal'}
261 +                                                                       ]
262 +                                                               });
263 +                                                       }.bind(this)
264 +                                               })
265 +                                       }catch(e){
266 +                                               Mojo.Log.error("Relego Patch Error: " + e);
267 +                                       }
268 +                                       break;
269 +                               case MenuData.ApplicationMenu.AddToSpareTime.command:
270 +                                       // Send the URL to Spare Time
271 +                                       try{
272 +                                               this.sparetimeappid = "com.semicolonapps.sparetime";
273 +                                               this.controller.serviceRequest("palm://com.palm.applicationManager", {
274 +                                                       method: 'open',
275 +                                                       parameters: {
276 +                                                               id: this.sparetimeappid,
277 +                                                               params: {action: "add_url", url: this.currentUrl, title: this.currentTitle}
278 +                                                       },
279 +                                                       onFailure:function(){
280 +                                                               //--> How do they not have it installed?
281 +                                                               this.controller.showAlertDialog({
282 +                                                                       onChoose: function(value){
283 +                                                                               if (value=="yes"){
284 +                                                                                       //--> And weee'rrre.. of to see the wizard
285 +                                                                                       this.controller.serviceRequest('palm://com.palm.applicationManager', {
286 +                                                                                               method:'open',
287 +                                                                                               parameters:{
288 +                                                                                                       target: "http://developer.palm.com/appredirect/?packageid=" + this.sparetimeappid
289 +                                                                                               }
290 +                                                                                       });
291 +                                                                               }
292 +                                                                       },
293 +                                                                       preventCancel: false,
294 +                                                                       title: $L("Spare Time Not Installed"),
295 +                                                                       message: $L("Spare Time is not installed. Would you like to download it?"),
296 +                                                                       choices:[
297 +                                                                               {label:$L('Yes'), value:"yes", type:'affirmative'},
298 +                                                                               {label:$L('No'), value:"no", type:'dismissal'}
299 +                                                                       ]
300 +                                                               });
301 +                                                       }.bind(this)
302 +                                               })
303 +                                       }catch(e){
304 +                                               Mojo.Log.error("Spare Time Patch Error: " + e);
305 +                                       }
306 +                                       break;
307 +       
308 +                               case MenuData.ApplicationMenu.ShortenURL.command:
309 +                                       // Set up the url
310 +                                               var url = "http://is.gd/api.php?longurl=" + this.currentUrl;
311 +                                               var target = this;
312 +       
313 +                                       // Attempt to connect to api
314 +                                               var request = new Ajax.Request(url, {
315 +                                                       method: 'get',
316 +                                                       evalJSON: 'false',
317 +                                                       onSuccess: function(response) {
318 +                                                               // Retrieve the short url and copy it
319 +                                                               var short_url = response.responseText;
320 +                                                               target.controller.stageController.setClipboard(short_url, false);
321 +               
322 +                                                               // Set up and show the banner message for success
323 +                                                               var message = "URL copied to clipboard.";
324 +                                                               var appController = Mojo.Controller.getAppController();
325 +                                                               var bannerParams = {soundClass: '', soundFile: '', icon: '', messageText: message};
326 +                                                               appController.showBanner(bannerParams, {banner: message});
327 +                                                       },
328 +                                                       onFailure: function(response) {
329 +                                                       // What happens when the api call fails
330 +                                                       }
331 +                                               });
332 +
333 +                               break;
334 +
335                                 case MenuData.ApplicationMenu.AddToLauncher.command:
336                                         // Bookmarks can deal with one that has no title, but not the launcher
337                                         urlReference = new UrlReference(this.currentUrl, this._getDisplayTitle(), new Date());
338 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
339 index 6ad7ebd..e8b61fb 100644
340 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
341 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
342 @@ -99,7 +99,8 @@ PageControls.prototype={
343                         type: 'idle',
344                         label: MenuData.NavigationMenu.Reload.label,
345                         icon: MenuData.NavigationMenu.Reload.icon,
346 -                       command: MenuData.NavigationMenu.Reload.command
347 +                       command: MenuData.NavigationMenu.Reload.command,
348 +                        
349                 };
350  
351                 if (this._animation) {
352 @@ -112,6 +113,7 @@ PageControls.prototype={
353                 // The spacer... right aligns the following button.
354                 this._model.items.push(idleModel);
355                 this._controller.modelChanged(this._model);
356 +               this._controller.setMenuVisible(Mojo.Menu.commandMenu, false);
357  
358                 this._currentPageModel = idleModel;
359         },
360 @@ -142,6 +144,7 @@ PageControls.prototype={
361                         this._model.items.push(progressModel);
362                         this._controller.modelChanged(this._model);
363                         this._animation.start(0);
364 +                       this._controller.setMenuVisible(Mojo.Menu.commandMenu, true);
365  
366                         this._currentPageModel = progressModel;
367  
368 @@ -187,6 +190,7 @@ PageControls.prototype={
369                         this._model.items.push(searchModel);
370                         this._controller.modelChanged(this._model);
371                         this._animation.start();
372 +                       this._controller.setMenuVisible(Mojo.Menu.commandMenu, true);
373  
374                         this._currentPageModel = searchModel;
375  
376 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js b/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
377 index f024692..9212984 100644
378 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
379 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
380 @@ -23,7 +23,7 @@ StartpageAssistant.prototype.setup = function() {
381         this._updateOrientation();
382  
383         // Allow override of 'back' gesture in landscape mode.
384 -       this.controller.useLandscapePageUpDown(true);
385 +       this.controller.useLandscapePageUpDown(false);
386  
387         // Listen for scene scope keyboard events.
388         this.controller.listen(this.controller.sceneElement, Mojo.Event.keydown, this._onKeyDownEventHandler);
389 @@ -42,6 +42,13 @@ StartpageAssistant.prototype.setup = function() {
390         this.appMenuModel = {
391                 visible: true,
392                 items: [
393 +                               {
394 +                                       label: $L("On/Off Gesture"),
395 +                                       items: [
396 +                                           {label:$L('Enable Gesture'),     shortcut:'e', command:'enable-gesture-cmd'},
397 +                        {label:$L('Disable Gesture'),     shortcut:'d', command:'disable-gesture-cmd'},
398 +                                                  ]
399 +                               },                      
400                         MenuData.ApplicationMenu.NewCard,
401                         MenuData.ApplicationMenu.AddBookmark,
402                         {