Improved see more feature.

This commit is contained in:
Martin Edenhofer 2012-05-08 00:55:17 +02:00
parent 21b244bc08
commit 8a1226a708

View file

@ -82,23 +82,26 @@ class Index extends App.Controller
if article_lines.length > preview if article_lines.length > preview
preview_mode = true preview_mode = true
if article_lines[preview] is '' if article_lines[preview] is ''
article_lines.splice( preview, 0, "----SEEMORE----" ) article_lines.splice( preview, 0, '----SEEMORE----' )
else else
article_lines.splice( preview + 1, 0, "----SEEMORE----" ) article_lines.splice( preview + 1, 0, '----SEEMORE----' )
article['html'] = article_lines.join("\n") article['html'] = article_lines.join("\n")
article['html'] = window.linkify( article['html'] ) article['html'] = window.linkify( article['html'] )
notify = "<a href=\"#\" class=\"show_toogle\">" + T('See more') + "</a>" notify = '<a href="#" class="show_toogle">' + T('See more') + '</a>'
# preview mode # preview mode
if preview_mode if preview_mode
article['html'] = article['html'].replace /^\n----SEEMORE----\n/m, (match) => @article_changed = false
article['html'] = article['html'].replace /^\n{0,10}----SEEMORE----\n/m, (match) =>
@article_changed = true
notify + '<div class="hide">' notify + '<div class="hide">'
if @article_changed
article['html'] = article['html'] + '</div>' article['html'] = article['html'] + '</div>'
# hide signatures and so on # hide signatures and so on
else else
@article_changed = false @article_changed = false
article['html'] = article['html'].replace /^\n(--|__)/m, (match) => article['html'] = article['html'].replace /^\n{0,10}(--|__)/m, (match) =>
@article_changed = true @article_changed = true
notify + '<div class="hide">' + match notify + '<div class="hide">' + match
if @article_changed if @article_changed