Merge branch 'feature/help' into release/5.4
Showing
4 changed files
with
19 additions
and
8 deletions
@@ -9,11 +9,16 @@ var cutStr = function(params) { | @@ -9,11 +9,16 @@ var cutStr = function(params) { | ||
9 | var strCut = ''; | 9 | var strCut = ''; |
10 | var i, curStr, addTxt, strLen; | 10 | var i, curStr, addTxt, strLen; |
11 | 11 | ||
12 | - params.str = params.str.replace(/\s/g, ''); | ||
13 | - params.str = params.str.replace(/<[^>]*>/g, ''); | 12 | + params.str = params.str.replace(/ /ig, ''); |
13 | + params.str = params.str.replace(/(?=[^>]*(?=<))\s+/g, ''); | ||
14 | + params.str = params.str.replace(/<(?!a|\/a).*?>/g, ''); | ||
14 | 15 | ||
15 | strLen = params.str.length || 0; | 16 | strLen = params.str.length || 0; |
16 | 17 | ||
18 | + if (!strLen) { | ||
19 | + return ''; | ||
20 | + } | ||
21 | + | ||
17 | if (params.type === 2) { | 22 | if (params.type === 2) { |
18 | addTxt = ''; | 23 | addTxt = ''; |
19 | } else { | 24 | } else { |
@@ -45,8 +50,12 @@ var cutStr = function(params) { | @@ -45,8 +50,12 @@ var cutStr = function(params) { | ||
45 | var keywordLabel = function(str, key) { | 50 | var keywordLabel = function(str, key) { |
46 | var reg = new RegExp(key, 'gm'); | 51 | var reg = new RegExp(key, 'gm'); |
47 | 52 | ||
53 | + if (str === '') { | ||
54 | + return str; | ||
55 | + } | ||
56 | + | ||
48 | str = str.replace(reg, '<i class="keyword">' + key + '</i>'); | 57 | str = str.replace(reg, '<i class="keyword">' + key + '</i>'); |
49 | - return str.replace('www.yohobuy.com', '<a href="http://www.yohobuy.com" class="keyword">www.yohobuy.com</a>'); | 58 | + return str; |
50 | }; | 59 | }; |
51 | 60 | ||
52 | exports.cutStr = cutStr; | 61 | exports.cutStr = cutStr; |
@@ -36,11 +36,13 @@ if (keywords) { | @@ -36,11 +36,13 @@ if (keywords) { | ||
36 | s.problem = true; | 36 | s.problem = true; |
37 | } | 37 | } |
38 | 38 | ||
39 | - if (s.secendCategoryId === '0') { | 39 | + if (parseInt(s.secendCategoryId, 10) === 0) { |
40 | id = s.firstCategoryId; | 40 | id = s.firstCategoryId; |
41 | } else { | 41 | } else { |
42 | id = s.secendCategoryId; | 42 | id = s.secendCategoryId; |
43 | } | 43 | } |
44 | + | ||
45 | + | ||
44 | s.content = helper.cutStr({ | 46 | s.content = helper.cutStr({ |
45 | str: s.content, | 47 | str: s.content, |
46 | len: 290, | 48 | len: 290, |
@@ -48,8 +50,6 @@ if (keywords) { | @@ -48,8 +50,6 @@ if (keywords) { | ||
48 | url: '/help/detail?id=' + id + '&contId=' + s.id | 50 | url: '/help/detail?id=' + id + '&contId=' + s.id |
49 | }); | 51 | }); |
50 | 52 | ||
51 | - // console.log(s.content) | ||
52 | - | ||
53 | s.content = helper.keywordLabel(s.content, keywords); | 53 | s.content = helper.keywordLabel(s.content, keywords); |
54 | s.caption = helper.keywordLabel(s.caption, keywords); | 54 | s.caption = helper.keywordLabel(s.caption, keywords); |
55 | }); | 55 | }); |
@@ -75,6 +75,8 @@ | @@ -75,6 +75,8 @@ | ||
75 | margin-top: 15px; | 75 | margin-top: 15px; |
76 | font-size: 14px; | 76 | font-size: 14px; |
77 | line-height: 20px; | 77 | line-height: 20px; |
78 | + height: 60px; | ||
79 | + overflow: hidden; | ||
78 | } | 80 | } |
79 | 81 | ||
80 | .show-all { | 82 | .show-all { |
@@ -94,7 +96,7 @@ | @@ -94,7 +96,7 @@ | ||
94 | line-height: 24px; | 96 | line-height: 24px; |
95 | 97 | ||
96 | img { | 98 | img { |
97 | - width: 100%; | 99 | + max-width: 100%; |
98 | } | 100 | } |
99 | } | 101 | } |
100 | } | 102 | } |
-
Please register or login to post a comment