mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-07 03:01:33 +00:00
Adding text trunctation in Angular
This commit is contained in:
@@ -1,2 +1,13 @@
|
||||
window.Shop = angular.module("Shop", ["ngResource"]).config ($httpProvider) ->
|
||||
window.Shop = angular.module("Shop", ["ngResource", "filters"]).config ($httpProvider) ->
|
||||
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
|
||||
|
||||
#angular.module('Shop', ['filters'])
|
||||
|
||||
angular.module("filters", []).filter "truncate", ->
|
||||
(text, length, end) ->
|
||||
length = 10 if isNaN(length)
|
||||
end = "..." if end is `undefined`
|
||||
if text.length <= length or text.length - end.length <= length
|
||||
text
|
||||
else
|
||||
String(text).substring(0, length - end.length) + end
|
||||
|
||||
Reference in New Issue
Block a user