Fixed issue #438 - Introduced App.Utils.phoneify() for phone numbers.
This commit is contained in:
parent
4b4e157806
commit
cb4c4c85e4
3 changed files with 26 additions and 6 deletions
|
@ -111,12 +111,13 @@ class App extends Spine.Controller
|
||||||
|
|
||||||
# transform input tel|url to make it clickable
|
# transform input tel|url to make it clickable
|
||||||
if attribute_config.tag is 'input'
|
if attribute_config.tag is 'input'
|
||||||
isHtmlEscape = true
|
|
||||||
result = App.Utils.htmlEscape(result)
|
|
||||||
if attribute_config.type is 'tel'
|
if attribute_config.type is 'tel'
|
||||||
result = "<a href=\"tel://#{result}\">#{result}</a>"
|
result = "<a href=\"#{App.Utils.phoneify(result)}\">#{App.Utils.htmlEscape(result)}</a>"
|
||||||
if attribute_config.type is 'url'
|
else if attribute_config.type is 'url'
|
||||||
result = App.Utils.linkify(result)
|
result = App.Utils.linkify(result)
|
||||||
|
else
|
||||||
|
result = App.Utils.htmlEscape(result)
|
||||||
|
isHtmlEscape = true
|
||||||
|
|
||||||
# use pretty time for datetime
|
# use pretty time for datetime
|
||||||
else if attribute_config.tag is 'datetime'
|
else if attribute_config.tag is 'datetime'
|
||||||
|
|
|
@ -46,8 +46,13 @@ class App.Utils
|
||||||
.replace(/\n{3,20}/g, "\n\n") # remove multiple empty lines
|
.replace(/\n{3,20}/g, "\n\n") # remove multiple empty lines
|
||||||
|
|
||||||
# htmlEscapedAndLinkified = App.Utils.linkify(rawText)
|
# htmlEscapedAndLinkified = App.Utils.linkify(rawText)
|
||||||
@linkify: (ascii) ->
|
@linkify: (string) ->
|
||||||
window.linkify(ascii)
|
window.linkify(string)
|
||||||
|
|
||||||
|
# htmlEscapedAndLinkified = App.Utils.linkify(rawText)
|
||||||
|
@phoneify: (string) ->
|
||||||
|
string = string.replace(/\s+/g, '')
|
||||||
|
"tel://#{encodeURIComponent(string)}"
|
||||||
|
|
||||||
# wrappedText = App.Utils.wrap(rawText, maxLineLength)
|
# wrappedText = App.Utils.wrap(rawText, maxLineLength)
|
||||||
@wrap: (ascii, max = 82) ->
|
@wrap: (ascii, max = 82) ->
|
||||||
|
|
|
@ -197,6 +197,20 @@ test("html2text", function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// phoneify
|
||||||
|
test("phoneify", function() {
|
||||||
|
|
||||||
|
var source = "+1 123 123 123-123"
|
||||||
|
var should = 'tel://%2B1123123123-123'
|
||||||
|
var result = App.Utils.phoneify(source)
|
||||||
|
equal(result, should, source)
|
||||||
|
|
||||||
|
source = "+1 123 123 A 123-123<>"
|
||||||
|
should = 'tel://%2B1123123A123-123%3C%3E'
|
||||||
|
result = App.Utils.phoneify(source)
|
||||||
|
equal(result, should, source)
|
||||||
|
})
|
||||||
|
|
||||||
// linkify
|
// linkify
|
||||||
test("linkify", function() {
|
test("linkify", function() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue