123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- //#region 分页控件
- Namespace.register("U.PG");
- //分页控件设置
- /*
- 功能:传统分页控件,此函数将预先加载。以后需多做几种样式。
- 参数一:UDE代表className为UD_SYFLB的div元素
- 参数二:UOD代表聊天条数。
- 参数三:UDP为整形1,默认第一页,其他数字,则为相应的显示页。
- 参数四: UNP代表一页显示多少条数据
- 参数五:USN为打印聊天信息的函数
- */
- U.PG.PPage = function (UOD, USN, UNP, UDN, UCF, UTF) {
- var i, j, _USE, _UKE,
- _UME = U.PG.PPage.setPage(USN, UNP, UDN, UCF);
- if (U.Ut.isFunction(UTF)) {
- _USE = UTF(this);
- _UKE = { //按钮对应事件处理
- "pre": { "onclick": [[U.PG.PPage.exec, [UNP - 1, _UBE[1], UOD, USN, UNP, UDN, UCF]]] }, //上一页
- "next": { "onclick": [[U.PG.PPage.exec, [UNP + 1, _UBE[2], UOD, USN, UNP, UDN, UCF]]] }, //下一页
- "frit": { "onclick": [[U.PG.PPage.exec, [1, _UBE[0], UOD, USN, UNP, UDN, UCF]]] }, //第一页
- "last": { "onclick": [[U.PG.PPage.exec, [UNP + 1, _UBE[2], UOD, USN, UNP, UDN, UCF]]] }, //最后一页
- "input": [{ "onkeyup": [U.M.returnkeylogin, [null, [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, null, UDP]]]]] },
- { "onclick": [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, null, UDP]]]}], //输入框 按钮
- "page": [] //页码按钮 变化样式 当前页的样式
- };
- for (i in _USE) {
- if (_USE.hasOwnProperty(i) && _UKE[i]) {
- if (U.Ut.isArray(_UKE[i])) {
- for (j = 0; j < _UKE[i].length; j++) {
- }
- }
- else {
- for (j in _UKE[i]) {
- _USE[i][j] = _UKE[i][j]
- }
- }
- }
- }
- }
- else if (!UTF) { // 创建分页控件
- U.PG.PPage.CPage(_UME[0], UOD, _UME[1], UNP, USN, UDN, UCF)
- }
- return _UME;
- }
- //分页控件显示
- U.PG.PPage.CPage = function (UDE, UOD, UDP, UNP, USN, UDN, UCF, UDOD) {
- var i, _UN, _USP, _UDOD, _UDTD, _UDSD, _UDGD, _UTE, _UAE, _UCE = [], _UBE = [];
- for (i = 0; i < 4; i++) {
- switch (i) {
- case 0:
- _UTF = UNP != 1;
- break;
- case 1:
- _UTF = UNP > 1;
- break;
- case 2:
- _UTF = UNP < UDP;
- break;
- case 3:
- _UTF = UNP != UDP;
- break;
- }
- if (_UTF) {
- _UBE[i] = UDE[i == 3 ? i + 1 : i];
- } else {
- _UCE[i] = "O";
- }
- }
- if (UDOD) {
- //分页控件分页
- _UDTD = $(UDOD).Child(),
- _UDAD = $(_UDTD[0]).childg(),
- _UTE = [1, UNP - 1, UNP + 1, UDP];
- $(_UDTD[1]).Child()[2].innerText = UNP + "页";
- _UAE = ["O", "T", "S", "F"];
- //跳页赋值
- for (i = 0; i < 4; i++) {
- _UDAD.addAttrArray({
- "onclick": _UCE[i] ? "" : [[U.PG.PPage.exec, [_UTE[i], _UBE[i], UOD, USN, UNP, UDN, UCF, UDOD]]],
- "className": "UD_SYI UD_SYFYL" + _UAE[i] + (_UCE[i] || "")
- }, (UCF.isp && i > 1) ? i + 1 : i);
- }
- //页码赋值
- if (UCF.isp) {
- _UDAD[2].innerText = ""; //清空
- _UN = UNP > 5 ? UNP - 5 : 0; //当前页的范围
- _USP = UNP + UCF.isp > UDP ? UDP : UNP + UCF.isp;
- _UAE = U.PG.PPage.setPage([_UN, _USP], null, null, UCF); //获取点击事件
- for (i = _UN; i < _USP; i++) { //范围使用
- $$("div", { "onclick": [[U.PG.PPage.exec, [i + 1, _UAE[i - _UN], UOD, USN, UNP, UDN, UCF, UDOD]]], "className": "UD_SYFYNO" + ((i + 1 == UNP) ? " UD_SYFYNOO" : ""), "innerHTML": i + 1 }, _UDAD[2]);
- }
- }
- $(_UDTD[1]).childg(0, 1).addAttrArray({
- "onclick": (_UTE = [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, UDOD, UDP]]])
- }, 8);
- $("input", UDOD).addAttrArray({
- "onkeyup": [[U.M.returnkeylogin, [null, _UTE]]]
- });
- }
- else {
- _UDOD = $$("div", {
- "className": "UD_SYFY"
- });
- _UDTD = $$("div", {
- "className": "UD_SYFYL"
- }, _UDOD);
- $$("div", {
- "className": "UD_SYI UD_SYFYLO" + (_UCE[0] || ""),
- "onclick": _UCE[0] ? null : [[U.PG.PPage.exec, [1, _UBE[0], UOD, USN, UNP, UDN, UCF, _UDOD]]],
- "title": "首页"
- }, _UDTD);
- $$("div", {
- "className": "UD_SYI UD_SYFYLT" + (_UCE[1] || ""),
- "onclick": _UCE[1] ? null : [[U.PG.PPage.exec, [UNP - 1, _UBE[1], UOD, USN, UNP, UDN, UCF, _UDOD]]],
- "title": "上一页"
- }, _UDTD);
- if (UCF.isp && UDP > 0) {
- _UDSD = $$("div", { "className": "UD_SYFYN" }, _UDTD);
- _UN = UNP > 5 ? UNP - 5 : 0;
- _USP = UNP + UCF.isp > UDP ? UDP : UNP + UCF.isp;
- _UAE = U.PG.PPage.setPage([_UN, _USP], null, null, UCF); //获取点击事件
- for (i = _UN; i < _USP; i++) {
- $$("div", { "onclick": [[U.PG.PPage.exec, [i + 1, _UAE[i - _UN], UOD, USN, UNP, UDN, UCF, _UDOD]]], "className": "UD_SYFYNO" + ((i + 1 == UNP) ? " UD_SYFYNOO" : ""), "innerHTML": i + 1 }, _UDSD);
- }
- }
- $$("div", {
- "className": "UD_SYI UD_SYFYLS" + (_UCE[2] || ""),
- "onclick": _UCE[2] ? null : [[U.PG.PPage.exec, [UNP + 1, _UBE[2], UOD, USN, UNP, UDN, UCF, _UDOD]]],
- "title": "下一页"
- }, _UDTD);
- $$("div", {
- "className": "UD_SYI UD_SYFYLF" + (_UCE[3] || ""),
- "onclick": _UCE[3] ? null : [[U.PG.PPage.exec, [UDP, _UBE[3], UOD, USN, UNP, UDN, UCF, _UDOD]]],
- "title": "尾页"
- }, _UDTD);
- _UDTD = $$("div", {
- "className": "UD_SYFYR"
- }, _UDOD);
- _UDSD = $$("div", {
- "className": "UD_SYFYRL"
- }, _UDTD);
- $$("span", {
- "innerHTML": "到"
- }, _UDSD);
- _UDGD = $$("div", {}, _UDSD);
- $$("input", {
- "type": "text",
- "onkeyup": [U.M.returnkeylogin, [null, [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, _UDOD, UDP]]]]]
- }, _UDGD);
- $$("span", {
- "innerHTML": "页"
- }, _UDSD);
- $$("div", {
- "className": "UD_SYFYRZ",
- "innerHTML": "确定",
- "onclick": [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, _UDOD, UDP]]]
- }, _UDTD);
- $$("div", {
- "className": "UD_SYFYRR",
- "innerHTML": UNP + "页"
- }, _UDTD);
- UOD.appendChild(_UDOD);
- }
- }
- //函数执行
- U.PG.PPage.exec = function (UTF, UFN, UOD, USN, UNP, UDN, UCF, UDOD) {
- if (UFN != null) {
- var _UDE = U.PG.PPage.main(UOD, USN, UTF, UDN, UCF, true);
- U.PG.PPage.CPage(_UDE[0], UOD, Math.ceil(USN / UDN), UTF, USN, UDN, UCF, UDOD);
- U.M.apply(this, UFN)();
- }
- }
- //输入框设置
- U.PG.PPage.PageAchieve = function (UFN, UOD, USN, UNP, UDN, UCF, UDOD, UDP) {
- var _UN = $(event.srcElement).parentg().find("input")[0].value;
- if (U.MS.Number.test(_UN)) {
- _UN = _UN.toInt();
- if (_UN <= UDP && _UN > 0) {
- (UNP != _UN) && (U.PG.PPage.exec(_UN, UFN, UOD, USN, UNP, UDN, UCF, UDOD));
- }
- else {
- parent.U.Alert("输入范围异常!");
- }
- }
- else {
- parent.U.Alert("无效输入!");
- }
- };
- //设置页数函数
- U.PG.PPage.setPage = function (USN, UNP, UDN, UCF) {
- var i, j, k, _USE, _UKE, _UGE, _UME = [],
- _UCE = UCF["fun"], //回调函数
- _UIP = UCF["page"]; //当前使用页数;
- if (U.Ut.isArray(USN)) {
- for (i = USN[0]; i < USN[1]; i++) {
- _UGE = [];
- for (j = 0; j < _UCE.length; j++) {
- _USE = _UCE[j][1];
- if (_UIP[j] != null) {
- _USE = _USE.concat();
- _USE[_UIP[j]] = i + 1;
- }
- _UGE.push[_UCE[j][0], _USE];
- }
- _UME.push(_UGE);
- }
- return _UME;
- }
- else { //添加事件处理
- var _UDP = Math.ceil(USN / UDN), //总页数
- _UDE = [1, UNP - 1, UNP + 1, "$(event.srcElement).parentg().find('input')[0].value", _UDP]; //前一页后一页处理
- for (i = 0; i < _UDE.length; i++) {
- _UGE = [];
- for (j = 0; j < _UCE.length; j++) {
- _USE = _UCE[j][1];
- if (_UIP[j] != null) {
- _USE = _USE.concat();
- _USE[_UIP[j]] = _UDE[i];
- }
- _UGE.push[_UCE[j][0], _USE];
- }
- _UME.push(_UGE);
- }
- return [_UME, _UDP];
- }
- }
- //控件设置
- U.PG.PPage.main = function (UOD, USN, UNP, UDN, UCF, UTF) {
- var i, j, _USE, _UKE,
- _UME = U.PG.PPage.setPage(USN, UNP, UDN, UCF);
- if (U.Ut.isFunction(UTF)) {
- _USE = UTF(this);
- _UKE = { //按钮对应事件处理
- "pre": { "onclick": [[U.PG.PPage.exec, [UNP - 1, _UBE[1], UOD, USN, UNP, UDN, UCF]]] }, //上一页
- "next": { "onclick": [[U.PG.PPage.exec, [UNP + 1, _UBE[2], UOD, USN, UNP, UDN, UCF]]] }, //下一页
- "frit": { "onclick": [[U.PG.PPage.exec, [1, _UBE[0], UOD, USN, UNP, UDN, UCF]]] }, //第一页
- "last": { "onclick": [[U.PG.PPage.exec, [UNP + 1, _UBE[2], UOD, USN, UNP, UDN, UCF]]] }, //最后一页
- "input": [{ "onkeyup": [U.M.returnkeylogin, [null, [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, null, UDP]]]]] },
- { "onclick": [[U.PG.PPage.PageAchieve, [UDE[3], UOD, USN, UNP, UDN, UCF, null, UDP]]]}], //输入框 按钮
- "page": [] //页码按钮 变化样式 当前页的样式
- };
- for (i in _USE) {
- if (_USE.hasOwnProperty(i) && _UKE[i]) {
- if (U.Ut.isArray(_UKE[i])) {
- for (j = 0; j < _UKE[i].length; j++) {
- }
- }
- else {
- for (j in _UKE[i]) {
- _USE[i][j] = _UKE[i][j]
- }
- }
- }
- }
- }
- else if (!UTF) { // 创建分页控件
- U.PG.PPage.CPage(_UME[0], UOD, _UME[1], UNP, USN, UDN, UCF)
- }
- return _UME;
- }
- ;
- // return main;
- //U.PG.PPage = (function () { })()
- //#endregion
|