leftPartTemplate_wev8.js
4.3 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*初始化查询搜索框*/
function initSearchText(callbackFn){
var $searchText = $(".e8_searchText");
var $searchTextTip = $(".e8_searchText_tip");
$searchTextTip.click(function(){
$searchText[0].focus();
});
$searchText.focus(function(){
$searchTextTip.hide();
});
$searchText.blur(function(){
if(this.value == ""){
$searchTextTip.show();
}
});
var preSearchText = "";
$searchText.keyup(function(event){
if(this.value != preSearchText){
preSearchText = this.value;
if(typeof(callbackFn) == "function"){
currPageIndex = 0;
callbackFn.call(this, this.value);
}
}
});
}
/*分页*/
var pageSize = 10;
var currPageIndex = 0;
var pgHtml = "";
var $pg;
var pageNum;
function doPagination(pgDatas, dataRenderCallFn, pSize){
if(pSize) pageSize=pSize;
var totalSize = pgDatas.length;
pageNum = Math.ceil(totalSize/pageSize);
if(pageNum>0&&currPageIndex>=pageNum){
currPageIndex=pageNum-1;
}
var isInitPageForCall = true;
$pg = $('#pagination');
$pg.pagination(totalSize, {
callback: PageCallback,
link_to: 'javascript:void(0);',
prev_text: SystemEnv.getHtmlNoteName(3445), //上一页按钮里text
next_text: SystemEnv.getHtmlNoteName(3446), //下一页按钮里text
items_per_page: pageSize, //显示条数
num_display_entries: 1, //连续分页主体部分分页条目数
current_page: currPageIndex, //当前页索引
num_edge_entries: 2 //两侧首尾分页条目数
});
function changeEventAndStatusOfProxy(){
var $pg_first = $(".e8_paginationProxy span.e8_pg_first");
var $pg_prev = $(".e8_paginationProxy span.e8_pg_prev");
var $pg_next = $(".e8_paginationProxy span.e8_pg_next");
var $pg_last = $(".e8_paginationProxy span.e8_pg_last");
$pg_first.unbind("click", toFirstPage);
$pg_prev.unbind("click", toPrevPage);
$pg_next.unbind("click", toNextPage);
$pg_last.unbind("click", toLastPage);
if(currPageIndex == 0){
$pg_first.addClass("disabled");
$pg_prev.addClass("disabled");
}else{
$pg_first.removeClass("disabled");
$pg_prev.removeClass("disabled");
$pg_first.bind("click", toFirstPage);
$pg_prev.bind("click", toPrevPage);
}
if(currPageIndex >= (pageNum - 1)){
$pg_next.addClass("disabled");
$pg_last.addClass("disabled");
}else{
$pg_next.removeClass("disabled");
$pg_last.removeClass("disabled");
$pg_next.bind("click", toNextPage);
$pg_last.bind("click", toLastPage);
}
}
function getPagedData() {
var start = currPageIndex * pageSize
, end = (currPageIndex + 1) * pageSize
, part = [];
if(end > totalSize){
end = totalSize;
}
for(;start < end; start++) {
part.push(pgDatas[start]);
}
return part;
}
function PageCallback(index, jq) {
currPageIndex = index;
changeEventAndStatusOfProxy();
$(".e8_paginationProxy span.e8_pg_label").html("第" + (index + 1) + "页");
if(typeof(dataRenderCallFn) == "function"){
var speed = isInitPageForCall ? 0 : 200;
var $dataContainer = $(".e8_left_center ul");
$dataContainer.fadeOut(speed, function(){
$dataContainer.find("*").remove();
var pagedData = getPagedData();
if(pagedData.length == 0){
var $dataLi = $("<li class='nodata'><a>"+SystemEnv.getHtmlNoteName(3656,readCookie("languageidweaver"))+"</a></li>");
$dataContainer.append($dataLi);
}else{
$.each(pagedData, function(i, data){
var $dataLi = $("<li></li>");
$dataLi.append(dataRenderCallFn.call(jq, data));
$dataContainer.append($dataLi);
});
}
$dataContainer.fadeIn(speed, function(){
if(typeof(onPagedCallback) == "function"){ //翻页时的钩子方法
onPagedCallback(index);
}
});
});
}
isInitPageForCall = false;
}
}
function isLessThan10(){
var flag = false;
if(currentDatas){
var size = currentDatas.length;
var st = $(".e8_searchText").val();
if(st!=""){
size = srarchData.length;
}
if(size<=10){
flag = true;
}
}
return flag;
}
function toFirstPage(){
if(isLessThan10()){
return;
}
$pg.trigger('setPage', [0]);
}
function toPrevPage(){
if(isLessThan10()){
return;
}
$pg.trigger('prevPage');
}
function toNextPage(){
if(isLessThan10()){
return;
}
$pg.trigger('nextPage');
}
function toLastPage(){
if(isLessThan10()){
return;
}
$pg.trigger('setPage', [pageNum - 1]);
}