updates and additions
[webos-internals:modifications.git] / browser / browser-add-to-spare-time-in-context-menu.patch
1 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
2 index 388cffc..fd84037 100644
3 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
5 @@ -632,6 +632,7 @@ PageAssistant.prototype._onWebViewSingleTap = function(event) {
6                                 {label: $L('Open In New Card'), command:'openNew'},
7                                 {label: $L('Share Link'), command:'shareUrl'},
8                                 {label: $L('Copy URL'), command:'copyUrl'},
9 +                           {label: $L('Add to Spare Time'), command:'add-to-spare-time-cmd'},
10                                 {label: $L('Copy to Photos'), command:'copyToPhotos'},
11                                 {label: $L('Share Image'), command:'shareImage'},
12                                 {label: $L('Set Wallpaper'), command:'setWallpaper'}
13 @@ -674,6 +675,9 @@ PageAssistant.prototype._onWebViewSingleTap = function(event) {
14                         var popupSelectFunc = function(value) {
15                                 selectedCommand = value;
16                                 switch (value) {
17 +                                       case 'add-to-spare-time-cmd':
18 +                                               this._addST(urlInfo.url);
19 +                                               break;
20                                         case 'openNew':
21                                                 this._newBrowserPage(urlInfo.url);
22                                                 break;
23 @@ -703,6 +707,7 @@ PageAssistant.prototype._onWebViewSingleTap = function(event) {
24                                         usedItems.push( findItem('openNew') );
25                                         usedItems.push( findItem('shareUrl') );
26                                         usedItems.push( findItem('copyUrl') );
27 +                                       usedItems.push( findItem('add-to-spare-time-cmd') );
28                                 }
29  
30                                 if (response.src) {
31 @@ -1846,7 +1851,37 @@ PageAssistant.prototype._shareUrl = function(url, title, withCapture) {
32                 method: 'open',
33                 parameters: parameters
34         });
35 -};
36 +};PageAssistant.prototype._addST = function(link) {
37 +          this.controller.serviceRequest("palm://com.palm.applicationManager", {
38 +            method: "launch",
39 +
40 +            parameters: {
41 +              id: "com.semicolonapps.sparetime",
42 +              params: {action: "add_url", url: link}
43 +            },
44 +
45 +            onFailure: function() {
46 +              this.controller.showAlertDialog({
47 +                title: $L("Spare Time Not Installed"),
48 +                message: $L("Spare Time is not installed. Would you like to purchase it?"),
49 +
50 +                choices:[
51 +                  {label:$L("Yes"), value:"yes", type:"affirmative"},
52 +                  {label:$L("No"), value:"no", type:"dismissal"}
53 +                ],
54 +
55 +                onChoose: function(value){
56 +                  if("yes" == value){
57 +                    this.controller.serviceRequest("palm://com.palm.applicationManager", {
58 +                      method:"open",
59 +                      parameters:{target: "http://developer.palm.com/appredirect/?packageid=com.semicolonapps.sparetime"}
60 +                    });
61 +                  }
62 +                }
63 +              });
64 +            }.bind(this)
65 +          });
66 + };
67  
68  PageAssistant.prototype._setWallpaper = function(pathToImage) {
69         var errorTitle = $L("Error Setting Wallpaper");