Improved shown articles.
This commit is contained in:
parent
d357a03ded
commit
8e98470b82
1 changed files with 26 additions and 7 deletions
|
@ -70,18 +70,37 @@ class Index extends App.Controller
|
||||||
article = App.TicketArticle.find(article_id)
|
article = App.TicketArticle.find(article_id)
|
||||||
|
|
||||||
# build html body
|
# build html body
|
||||||
|
# cleanup body
|
||||||
article['html'] = article.body.trim()
|
article['html'] = article.body.trim()
|
||||||
article['html'].replace(/\n\n/m, "\n");
|
article['html'].replace(/\n\r/g, "\n");
|
||||||
article['html'].replace(/\n\r\n\r/m, "\n");
|
article['html'].replace(/\n\n/mg, "\n");
|
||||||
|
|
||||||
|
# if body has more then x lines / else search for signature
|
||||||
|
preview = 15
|
||||||
|
preview_mode = false
|
||||||
|
article_lines = article['html'].split(/\n/)
|
||||||
|
if article_lines.length > preview
|
||||||
|
preview_mode = true
|
||||||
|
article_lines.splice( preview+1, 1, "----SEEMORE----" )
|
||||||
|
article['html'] = article_lines.join("\n")
|
||||||
article['html'] = window.linkify( article['html'] )
|
article['html'] = window.linkify( article['html'] )
|
||||||
notify = "<a href=\"#\" style=\"color:blue\" class=\"show_toogle\">" + T('See more') + "</a>"
|
notify = "<a href=\"#\" style=\"color:blue\" class=\"show_toogle\">" + T('See more') + "</a>"
|
||||||
@article_changed = false
|
|
||||||
article['html'] = article['html'].replace /^(--|__)/m, (match) =>
|
# preview mode
|
||||||
@article_changed = true
|
if preview_mode
|
||||||
notify + '<div class="hide">' + match
|
article['html'] = article['html'].replace /^----SEEMORE----/m, (match) =>
|
||||||
if @article_changed
|
notify + '<div class="hide">'
|
||||||
article['html'] = article['html'] + '</div>'
|
article['html'] = article['html'] + '</div>'
|
||||||
|
|
||||||
|
# hide signatures and so on
|
||||||
|
else
|
||||||
|
@article_changed = false
|
||||||
|
article['html'] = article['html'].replace /^(--|__)/m, (match) =>
|
||||||
|
@article_changed = true
|
||||||
|
notify + '<div class="hide">' + match
|
||||||
|
if @article_changed
|
||||||
|
article['html'] = article['html'] + '</div>'
|
||||||
|
|
||||||
@articles.push article
|
@articles.push article
|
||||||
|
|
||||||
# check attachments
|
# check attachments
|
||||||
|
|
Loading…
Reference in a new issue