diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 03c859fb2..5d5014acd 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -160,13 +160,7 @@ class App.Controller extends Spine.Controller # human readable file size humanFileSize: (size) => - if size > ( 1024 * 1024 ) - size = Math.round( size / ( 1024 * 1024 ) ) + ' MB' - else if size > 1024 - size = Math.round( size / 1024 ) + ' KB' - else - size = size + ' Bytes' - size + App.Utils.humanFileSize(size) # human readable time humanTime: ( time, escalation, long = true ) => diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index 5cb31e6a4..ae5bd2aa7 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -212,6 +212,10 @@ class App extends Spine.Controller result + # define file size helper + params.humanFileSize = ( size ) -> + App.Utils.humanFileSize(size) + # define template JST["app/views/#{name}"](params) template diff --git a/app/assets/javascripts/app/lib/app_post/utils.js.coffee b/app/assets/javascripts/app/lib/app_post/utils.js.coffee index 40ee90984..876d2bb51 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.js.coffee @@ -273,3 +273,13 @@ class App.Utils attachmentTranslatedRegExp = new RegExp( attachmentTranslated, 'i' ) return true if message.match( attachmentTranslatedRegExp ) false + + # human readable file size + @humanFileSize: (size) => + if size > ( 1024 * 1024 ) + size = Math.round( size / ( 1024 * 1024 ) ) + ' MB' + else if size > 1024 + size = Math.round( size / 1024 ) + ' KB' + else + size = size + ' Bytes' + size diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco index 25007c319..9ce99c92b 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco @@ -56,7 +56,7 @@ <% for attachment in @article.attachments: %>
<% end %>