updateds
[webos-internals:modifications.git] / browser / browser-hold-tap-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..9bfddb6 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 @@ -75,6 +75,7 @@ function PageAssistant(params){
6         this._onUrlRedirectHandler = this._onUrlRedirect.bind(this);
7         this._onWebViewResourceHandoffHandler = this._onWebViewResourceHandoff.bind(this);
8         this._onWebViewSingleTap = this._onWebViewSingleTap.bind(this);
9 +       this._onWebViewHoldTap = this._onWebViewHoldTap.bind(this);
10  
11         // Spotlight handlers (flash support)
12         this._onSpotlightStartHandler = this._onSpotlightStart.bind(this);
13 @@ -329,6 +330,7 @@ PageAssistant.prototype.activate = function(message) {
14                 webView.addEventListener(Mojo.Event.webViewServerConnect, this._onAdapterConnectHandler, false);
15                 webView.addEventListener(Mojo.Event.webViewServerDisconnect, this._onAdapterDisconnectHandler, false);
16                 webView.addEventListener('singletap', this._onWebViewSingleTap, true);
17 +               webView.addEventListener(Mojo.Event.hold, this._onWebViewHoldTap, true);
18  
19                 //this.controller.getSceneScroller().addEventListener(Mojo.Event.scrollStarting,
20                 //      this._addAsScrollListenerHandler, false);
21 @@ -434,6 +436,7 @@ PageAssistant.prototype.deactivate = function() {
22                 webView.removeEventListener(Mojo.Event.webViewServerConnect, this._onAdapterConnectHandler, false);
23                 webView.removeEventListener(Mojo.Event.webViewServerDisconnect, this._onAdapterDisconnectHandler, false);
24                 webView.removeEventListener('singletap', this._onWebViewSingleTap, true);
25 +               webView.removeEventListener(Mojo.Event.hold, this._onWebViewHoldTap, true);
26  
27                 //this.controller.getSceneScroller().removeEventListener(Mojo.Event.scrollStarting,
28                 //      this._addAsScrollListenerHandler, false);
29 @@ -623,8 +626,16 @@ PageAssistant.prototype._onWebViewSingleTap = function(event) {
30  
31         try {
32                 var tapPt = Element.viewportOffset(this._webView);
33 -               tapPt.left = event.centerX - tapPt.left;
34 -               tapPt.top  = event.centerY - tapPt.top;
35 +               
36 +               if(event.isHoldTap) {
37 +                       event.altKey = true;
38 +                       tapPt.left = event.down.offsetX;
39 +                       tapPt.top = event.down.offsetY;
40 +               }
41 +               else {
42 +                       tapPt.left = event.centerX - tapPt.left;
43 +                       tapPt.top  = event.centerY - tapPt.top;         
44 +               }
45  
46                 if (event.altKey) {
47  
48 @@ -734,6 +745,11 @@ PageAssistant.prototype._onWebViewSingleTap = function(event) {
49         }
50  };
51  
52 +PageAssistant.prototype._onWebViewHoldTap = function(event) {  
53 +       event.isHoldTap = true;
54 +       this._onWebViewSingleTap(event);        
55 +};
56 +
57  PageAssistant.prototype._onCardActivate = function(event) {
58  
59         this.hasFocus = true;