channel.js
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require('./channel/detail');
require('./channel/magazine')
var $=require("jquery");
var tips=require("yoho-tips");
var box=require("yoho-box");
//首页碎片交互=================================================================================================
function dealItems() {
var citems = $(".content-item,.content-item-without-border");
if (!citems.length) {
return;
}
var totalLineNum = 7;
// 7 行
var maxTitleStrNum = 45;
// 15个字
var maxDetailStrNum = 24;
// 22个字
if (document.body.clientWidth < 1190&&document.body.clientWidth>768) {
totalLineNum = 6;
// 6 行
maxTitleStrNum = 15;
// 13个字
maxDetailStrNum = 20;
// 18个字
}
else if(document.body.clientWidth<=768){
totalLineNum = 5;
// 6 行
maxTitleStrNum = 10;
// 13个字
maxDetailStrNum = 15;
}
var titleLineNum = 0;
var subTitleLineNum = 0;
var detailLineNum = 0;
var detailStr = "";
var self = null;
citems.each(function() {
self = $(this);
var itemTitleObj= self.find(".content-item-detail-title");
// 主标题行数
if(typeof(itemTitleObj.attr("_title"))==="undefined"||itemTitleObj.attr("_title")===null)
return;
titleLineNum = 1;
if (maxTitleStrNum < itemTitleObj.attr("_title").length) {
titleLineNum = 2;
}
// 副标题行数
subTitleLineNum = 1;
if (maxTitleStrNum < $(".content-item-detail-subtitle").attr("_title").length) {
subTitleLineNum = 2;
}
// 摘要内容行数
detailLineNum = totalLineNum - titleLineNum - subTitleLineNum;
if ((maxDetailStrNum * detailLineNum) < self.find(".content-item-detail").attr("_title").length) {
detailStr = self.find(".content-item-detail").attr("_title").substring(0, (maxDetailStrNum-1) * detailLineNum ) + " ...";
self.find(".content-item-detail").html(detailStr.replace(/[a-zA-Z]+?\s{1}\.\.\.\$/, " ..."));
console.log(detailStr);
}
else
{
self.find(".content-item-detail").text(self.find(".content-item-detail-detail").attr("_title"));
}
});
citems = null;
}
dealItems();
//=============================================================
//邮件订阅=============================================================================================================
$(".followus-button").click(function(){
if($(".follow-us-input-content input").val()=='')
{
box.alert(tips.getTips("emailEmpty"));
return;
}
if(!tools.IYOHO_isEmail($(".follow-us-input-content input").val()))
{
box.alert(tips.getTips("emailError"));
return;
}
$(".search-suggest").hide();
window.open( '/passport/subscribe/index?email='+$(".follow-us-input-content input").val());
});
$(".followus-input").keydown(function(event){
if(event.keyCode==13)
{
$(".followus-button").trigger("click");
}
});