Improved reply of twitter status, set cursor to end of input field.
This commit is contained in:
parent
7cbe4f9da1
commit
f3cc078cb3
3 changed files with 39 additions and 31 deletions
|
@ -240,7 +240,7 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
else
|
else
|
||||||
articleNew.body = "#{recipientString} "
|
articleNew.body = "#{recipientString} "
|
||||||
|
|
||||||
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew, position: 'end' } )
|
||||||
|
|
||||||
twitterDirectMessageReply: (e) =>
|
twitterDirectMessageReply: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -141,6 +141,11 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
# preselect article type
|
# preselect article type
|
||||||
@setArticleType(data.type.name)
|
@setArticleType(data.type.name)
|
||||||
|
|
||||||
|
# set focus at end of field
|
||||||
|
if data.position is 'end'
|
||||||
|
@placeCaretAtEnd(@textarea.get(0))
|
||||||
|
return
|
||||||
|
|
||||||
# set focus into field
|
# set focus into field
|
||||||
@textarea.focus()
|
@textarea.focus()
|
||||||
)
|
)
|
||||||
|
@ -158,6 +163,22 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
@render()
|
@render()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
placeCaretAtEnd: (el) ->
|
||||||
|
el.focus()
|
||||||
|
if typeof window.getSelection isnt 'undefined' && typeof document.createRange isnt 'undefined'
|
||||||
|
range = document.createRange()
|
||||||
|
range.selectNodeContents(el)
|
||||||
|
range.collapse(false)
|
||||||
|
sel = window.getSelection()
|
||||||
|
sel.removeAllRanges()
|
||||||
|
sel.addRange(range)
|
||||||
|
return
|
||||||
|
if typeof document.body.createTextRange isnt 'undefined'
|
||||||
|
textRange = document.body.createTextRange()
|
||||||
|
textRange.moveToElementText(el)
|
||||||
|
textRange.collapse(false)
|
||||||
|
textRange.select()
|
||||||
|
|
||||||
isIE10: ->
|
isIE10: ->
|
||||||
Function('/*@cc_on return document.documentMode===10@*/')()
|
Function('/*@cc_on return document.documentMode===10@*/')()
|
||||||
|
|
||||||
|
@ -293,32 +314,17 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
params.type_id = type.id
|
params.type_id = type.id
|
||||||
|
|
||||||
if params.type is 'twitter status'
|
if params.type is 'twitter status'
|
||||||
rawHTML = @$('[data-name=body]').html()
|
App.Utils.htmlRemoveRichtext(@$('[data-name=body]'), false)
|
||||||
cleanHTML = App.Utils.htmlRemoveRichtext(rawHTML)
|
|
||||||
|
|
||||||
# if markup is included, strip it out
|
|
||||||
if cleanHTML && cleanHTML.html() isnt rawHTML && "<div>#{cleanHTML.html()}</div>" isnt rawHTML
|
|
||||||
@$('[data-name=body]').html(cleanHTML)
|
|
||||||
params.content_type = 'text/plain'
|
params.content_type = 'text/plain'
|
||||||
params.body = "#{App.Utils.html2text(params.body, true)}\n#{@signature.text()}"
|
params.body = "#{App.Utils.html2text(params.body, true)}\n#{@signature.text()}"
|
||||||
|
|
||||||
if params.type is 'twitter direct-message'
|
if params.type is 'twitter direct-message'
|
||||||
rawHTML = @$('[data-name=body]').html()
|
App.Utils.htmlRemoveRichtext(@$('[data-name=body]'), false)
|
||||||
cleanHTML = App.Utils.htmlRemoveRichtext(rawHTML)
|
|
||||||
|
|
||||||
# if markup is included, strip it out
|
|
||||||
if cleanHTML && cleanHTML.html() isnt rawHTML && "<div>#{cleanHTML.html()}</div>" isnt rawHTML
|
|
||||||
@$('[data-name=body]').html(cleanHTML)
|
|
||||||
params.content_type = 'text/plain'
|
params.content_type = 'text/plain'
|
||||||
params.body = "#{App.Utils.html2text(params.body, true)}\n#{@signature.text()}"
|
params.body = "#{App.Utils.html2text(params.body, true)}\n#{@signature.text()}"
|
||||||
|
|
||||||
if params.type is 'facebook feed comment'
|
if params.type is 'facebook feed comment'
|
||||||
rawHTML = @$('[data-name=body]').html()
|
App.Utils.htmlRemoveRichtext(@$('[data-name=body]'), false)
|
||||||
cleanHTML = App.Utils.htmlRemoveRichtext(rawHTML)
|
|
||||||
|
|
||||||
# if markup is included, strip it out
|
|
||||||
if cleanHTML && cleanHTML.html() isnt rawHTML && "<div>#{cleanHTML.html()}</div>" isnt rawHTML
|
|
||||||
@$('[data-name=body]').html(cleanHTML)
|
|
||||||
params.content_type = 'text/plain'
|
params.content_type = 'text/plain'
|
||||||
params.body = App.Utils.html2text(params.body, true)
|
params.body = App.Utils.html2text(params.body, true)
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ class App.Utils
|
||||||
html
|
html
|
||||||
|
|
||||||
# htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext(html)
|
# htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext(html)
|
||||||
@htmlRemoveRichtext: (html) ->
|
@htmlRemoveRichtext: (html, parent = true) ->
|
||||||
return html if !html
|
return html if !html
|
||||||
html = @_checkTypeOf(html)
|
html = @_checkTypeOf(html)
|
||||||
|
|
||||||
|
@ -165,7 +165,8 @@ class App.Utils
|
||||||
@_removeComments(html)
|
@_removeComments(html)
|
||||||
|
|
||||||
# remove style and class
|
# remove style and class
|
||||||
@_removeAttributes(html)
|
if parent
|
||||||
|
@_removeAttributes(html)
|
||||||
|
|
||||||
# remove work markup
|
# remove work markup
|
||||||
@_removeWordMarkup(html)
|
@_removeWordMarkup(html)
|
||||||
|
@ -241,16 +242,17 @@ class App.Utils
|
||||||
catch err
|
catch err
|
||||||
return $("<div>#{item}</div>")
|
return $("<div>#{item}</div>")
|
||||||
|
|
||||||
@_removeAttributes: (html) ->
|
@_removeAttributes: (html, parent = true) ->
|
||||||
html.find('*')
|
if parent
|
||||||
.removeAttr('style')
|
html.find('*')
|
||||||
.removeAttr('class')
|
.removeAttr('style')
|
||||||
.removeAttr('title')
|
.removeAttr('class')
|
||||||
.removeAttr('lang')
|
.removeAttr('title')
|
||||||
.removeAttr('type')
|
.removeAttr('lang')
|
||||||
.removeAttr('id')
|
.removeAttr('type')
|
||||||
.removeAttr('wrap')
|
.removeAttr('id')
|
||||||
.removeAttrs(/data-/)
|
.removeAttr('wrap')
|
||||||
|
.removeAttrs(/data-/)
|
||||||
html
|
html
|
||||||
.removeAttr('style')
|
.removeAttr('style')
|
||||||
.removeAttr('class')
|
.removeAttr('class')
|
||||||
|
|
Loading…
Reference in a new issue