Permalink
Browse files

Don't truncate description in the middle of a word

  • Loading branch information...
Floris Verloop
Floris Verloop committed Aug 3, 2016
1 parent 440e75b commit daa910b545f3ced3d94710c15abaef7307a7b30f
Showing with 5 additions and 11 deletions.
  1. +5 −11 framer/Components/ShareComponent.coffee
@@ -135,23 +135,18 @@ class ShareComponent
@_startListening()
_truncateCredential: (str, words) ->
_truncateCredential: (str) ->
maxLength = 36
maxLengthWithAvatar = 25
str = _.escape(str)
if words
separator = " "
else
separator = ""
# If an avatar is shown
if @shareInfo.twitter isnt undefined and str.length > maxLengthWithAvatar
str = _.truncate(str, {"length": maxLengthWithAvatar, "separator": separator})
str = _.truncate(str, {"length": maxLengthWithAvatar})
else if str.length > maxLength
str = _.truncate(str, {"length": maxLength, "separator": separator})
str = _.truncate(str, {"length": maxLength})
return str
@@ -163,7 +158,7 @@ class ShareComponent
# Truncate title if too long
if @shareInfo.title
@shareInfo.title = @_truncateCredential(@shareInfo.title, true)
@shareInfo.title = @_truncateCredential(@shareInfo.title)
# Render main sheet
_renderSheet: ->
@@ -418,8 +413,7 @@ class ShareComponent
# Truncate if description is too long
if @shareInfo.description.length > @options.maxDescriptionLength
truncated = @shareInfo.description.substring(@options.maxDescriptionLength,length).trim()
@options.shortDescription = truncated + ""
@options.shortDescription = _.truncate(@shareInfo.description, {"length": @options.maxDescriptionLength, "separator": " "})
@descriptionTruncatedSize = Utils.textSize(
parseDescription(@options.shortDescription),

0 comments on commit daa910b

Please sign in to comment.