⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jquery.jpage.js

📁 分页其他人不需帐号就可自由下载此源码
💻 JS
📖 第 1 页 / 共 2 页
字号:
					getStartEnd();
					getRemoteData();
				}
			);
			
			//页码输入框监听
			valCurrentPage.keydown(
				function(event){
					var targetPage = parseInt($(this).val());
					if(event.keyCode==13 && targetPage>=1 && targetPage<=totalPage){
						if(!dataStore || gpStartPage > targetPage || (gpEndPage > 0 && gpEndPage < targetPage)){
							currentPage = targetPage;
							getGroupStartEnd();
							getStartEnd();
							getRemoteData();
						}else{
							currentPage = targetPage;
							getStartEnd();
							loadData();
							refresh();
						}
					}
				}
			);
			
			valPerPage.change(
				function(){
					perPage = parseInt($(this).val());
					currentPage = 1;
					totalPage = Math.ceil(totalRecord/perPage);
					if(groupSize){
						getGroupStartEnd();
						getStartEnd();
						getRemoteData();
					}else{
						getStartEnd();
						loadData();
						refresh();				
					}			
				}
			);
			
			/*********************************init私有函数***************************************************/
			/**
			   * 置为正在检索状态
			   */
			function startLoad(){
				$(t).addClass(themeName+"_container");
				mask = document.createElement('div');
				$(mask).addClass(themeName+"_mask");
				$(mask).css("height",$(t).height());
				$(t).append(mask);
				$(t+" ."+themeName+"_pgRefresh").addClass(themeName+"_pgLoad");
				$(t+" ."+themeName+"_pgSearchInfo").html("正在检索中,请稍后...");
			}
			
			/**
			   * 置为结束检索状态
			   */
			function overLoad(){
				$(t+" ."+themeName+"_pgRefresh").removeClass(themeName+"_pgLoad");
				$(t+" ."+themeName+"_pgSearchInfo").html('检索到&nbsp;' + totalRecord + '&nbsp;条记录,显示第&nbsp;<span class="'+themeName+'_pgStartRecord">' + startRecord + '</span>&nbsp;条&nbsp;-&nbsp;第&nbsp;<span class="'+themeName+'_pgEndRecord">' + endRecord + '</span>&nbsp;条记录');
				$(mask).remove();
			}
		
			/**
			   * 获得远程数据
			   */
			function getRemoteData(){
				startLoad();
				$.ajax(
					{
						type: "POST",
						url: proxyUrl + "?startrecord="+gpStartRecord+"&endrecord="+gpEndRecord+"&perpage="+perPage ,
						cache: false,
						data: ajaxParam,
						dataType: "script", ///设置返回数据类型----------------------------------------------------------------------
						timeout: 30000,
						success: function(msg){
							//alert(msg);
							eval(msg);
							getStartEnd();
							loadData();
							refresh();
							overLoad();
						},
						error: function(){
							alert("请求失败或超时,请稍后再试!");
							overLoad();
							return;
						}
					}
				);
			}
			
			/**
			   * 获得当前页开始结束记录
			   */
			function getStartEnd(){
				if(groupSize){
					startRecord = (currentPage-1)*perPage+1 - gpStartRecord + 1;
					endRecord = Math.min(currentPage*perPage,totalRecord) - gpStartRecord + 1;
				}else{
					startRecord = (currentPage-1)*perPage+1;
					endRecord = Math.min(currentPage*perPage,totalRecord);
				}
			}
		
			/**
			   * 获得当前组开始结束页码
			   */
			function getGroupStartEnd(){
				if(groupSize==null)
					return;
				var groupId = Math.ceil(currentPage/groupSize);
				gpStartPage = (groupId-1)*groupSize+1;
				gpEndPage = Math.min(groupId*groupSize,totalPage);
				gpStartRecord = (gpStartPage-1)*perPage+1;
				gpEndRecord = Math.min(gpEndPage*perPage,totalRecord);
			}
		
			/**
			   * 刷新数据容器 --------------附加内容
			   */
			function loadData(){
				var view = "";
				for(var i=startRecord-1;i<=endRecord-1;i++){
					view += dataStore[i].replace("{id}",gpStartRecord+i);
				}
				valContainer.html(dataBefore + view + dataAfter);
				
				//为加载数据后的table添加排序事件----------------------------------------------------------------------------------------------------
				TableSort();
				
				AddTableHover();
			}
		
			/**
			   * 刷新工具栏状态
			   */
			function refresh(){
				if(openCookies){
					//当前页码写入cookie
					$.cookie(t+'_currentPage', currentPage);
					$.cookie(t+'_perPage', perPage);
				}
		
				valCurrentPage.val(currentPage);
				valStartRecord.html(startRecord);
				valEndRecord.html(endRecord);
				valTotalPage.html(totalPage);
				
				btn.unbind("mousedown",pressHandler);
				btn.bind("mouseup",unpressHandler);
				btn.bind("mouseout",unpressHandler);
				if(currentPage == 1 && currentPage != totalPage){
					enabled();
					btnGo.bind("mousedown",pressHandler);
					btnPrev.addClass(themeName+"_pgPrevDisabled");
					btnFirst.addClass(themeName+"_pgFirstDisabled");
				}else if(currentPage != 1 && currentPage == totalPage){
					enabled();
					btnBack.bind("mousedown",pressHandler);
					btnNext.addClass(themeName+"_pgNextDisabled");
					btnLast.addClass(themeName+"_pgLastDisabled");
				}else if(currentPage == 1 && currentPage == totalPage){
					disabled();
				}else{
					enabled();
					btnBack.bind("mousedown",pressHandler);
					btnGo.bind("mousedown",pressHandler);
					btnNext.addClass(themeName+"_pgNext");
					btnPrev.addClass(themeName+"_pgPrev");
					btnFirst.addClass(themeName+"_pgFirst");
					btnLast.addClass(themeName+"_pgLast");
				}
			}
			
			/**
			   * 移除按钮disabled状态样式
			   */
			function enabled(){
					btnNext.removeClass(themeName+"_pgNextDisabled");
					btnPrev.removeClass(themeName+"_pgPrevDisabled");
					btnFirst.removeClass(themeName+"_pgFirstDisabled");
					btnLast.removeClass(themeName+"_pgLastDisabled");
			}
			
			/**
			   * 添加按钮disabled状态样式
			   */
			function disabled(){
					btnNext.addClass(themeName+"_pgNextDisabled");
					btnPrev.addClass(themeName+"_pgPrevDisabled");
					btnFirst.addClass(themeName+"_pgFirstDisabled");
					btnLast.addClass(themeName+"_pgLastDisabled");
			}
		
			/**
			   * 添加按钮按下状态样式
			   */
			function pressHandler(){
				$(this).addClass(themeName+"_pgPress");
			}
		
			/**
			   * 移除按钮按下状态样式
			   */
			function unpressHandler(){
				$(this).removeClass(themeName+"_pgPress");
			}
		
		}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -