From 7e0034f6743a11ca1fbd3ca5d246a1e56be3247e Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 14 Aug 2014 13:13:05 +0300 Subject: [PATCH] see more --- .../Espo/Resources/i18n/en_US/Global.json | 3 ++- frontend/client/src/view-helper.js | 1 + frontend/client/src/views/fields/text.js | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 4894bf19c6..dffb524c24 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -115,7 +115,8 @@ "Run Import": "Run Import", "Duplicate": "Duplicate", "Notifications": "Notifications", - "Mark all read": "Mark all read" + "Mark all read": "Mark all read", + "See More": "See More" }, "messages": { "notModified": "You have not modified the record", diff --git a/frontend/client/src/view-helper.js b/frontend/client/src/view-helper.js index d01b3bcaae..f0af70e63f 100644 --- a/frontend/client/src/view-helper.js +++ b/frontend/client/src/view-helper.js @@ -139,6 +139,7 @@ text = text.replace(self.urlRegex, function (url) { return '' + url + ''; }); + text = text.replace('[#see-more-text]', ' ' + self.language.translate('See More')) + ''; return new Handlebars.SafeString(text); }); diff --git a/frontend/client/src/views/fields/text.js b/frontend/client/src/views/fields/text.js index 3d0918e6e0..6976b808fa 100644 --- a/frontend/client/src/views/fields/text.js +++ b/frontend/client/src/views/fields/text.js @@ -31,10 +31,31 @@ Espo.define('Views.Fields.Text', 'Views.Fields.Base', function (Dep) { editTemplate: 'fields.text.edit', + detailMaxLength: 400, + + seeMoreText: false, + + events: { + 'click a[data-action="seeMoreText"]': function (e) { + this.seeMoreText = true; + this.render(); + } + }, + setup: function () { this.params.rows = this.params.rows || 4; }, + getValueForDisplay: function () { + var text = this.model.get(this.name); + if ((this.mode == 'detail' || this.mode == 'list') && !this.seeMoreText) { + if (text.length > this.detailMaxLength) { + text = text.substr(0, this.detailMaxLength) + ' ...\n[#see-more-text]'; + } + } + return text; + }, + fetchSearch: function () { var value = this.$element.val(); if (value) {