bug 979470 - When a phone number is highlighted, offer to call it from the context menu or action bar r=mfinkle

This commit is contained in:
Brad Lassey 2014-03-11 15:30:40 -04:00
parent 32415966ea
commit 3b1c716069
6 changed files with 35 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

View File

@ -0,0 +1 @@
blassey@flyingfox.local.319

View File

@ -1,3 +1,4 @@
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -494,6 +495,20 @@ var SelectionHandler = {
selector: ClipboardHelper.searchWithContext,
},
CALL: {
label: Strings.browser.GetStringFromName("contextmenu.call"),
id: "call_action",
icon: "drawable://phone",
action: function() {
SelectionHandler.callSelection();
},
order: 1,
selector: {
matches: function isPhoneNumber(aElement, aX, aY) {
return null != SelectionHandler._getSelectedPhoneNumber();
}
},
},
},
/*
@ -744,6 +759,22 @@ var SelectionHandler = {
this._closeSelection();
},
_phoneRegex: /(?:\s|^)[\+]?(\(?\d{1,8}\)?)?([- \.]+\(?\d{1,8}\)?)+( ?(x|ext) ?\d{1,3})?(?:\s|$)/,
_getSelectedPhoneNumber: function sh_isPhoneNumber() {
let selectedText = this._getSelectedText();
return (selectedText.length && this._phoneRegex.test(selectedText) ?
selectedText : null);
},
callSelection: function sh_callSelection() {
let selectedText = this._getSelectedPhoneNumber();
if (selectedText) {
BrowserApp.loadURI("tel:" + selectedText);
}
this._closeSelection();
},
/*
* Shuts SelectionHandler down.
*/
@ -904,6 +935,7 @@ var SelectionHandler = {
positions: positions,
rtl: this._isRTL
});
this._updateMenu();
},
subdocumentScrolled: function sh_subdocumentScrolled(aElement) {

View File

@ -201,6 +201,8 @@ contextmenu.cut=Cut
contextmenu.selectAll=Select All
contextmenu.paste=Paste
contextmenu.call=Call
# Select UI
selectHelper.closeMultipleSelectDialog=Done