var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Yunyou;
(function (Yunyou) {
var Core;
(function (Core) {
var PagingType;
(function (PagingType) {
PagingType[PagingType["page"] = 1] = "page";
PagingType[PagingType["prev"] = 2] = "prev";
PagingType[PagingType["next"] = 3] = "next";
PagingType[PagingType["dots"] = 4] = "dots";
})(PagingType = Core.PagingType || (Core.PagingType = {}));
var PagingItemControl = /** @class */ (function (_super) {
__extends(PagingItemControl, _super);
function PagingItemControl() {
return _super !== null && _super.apply(this, arguments) || this;
}
PagingItemControl.prototype.render = function () {
if (this.props.type == PagingType.dots) {
return (React.createElement("li", { className: "dots" },
React.createElement("span", null, "...")));
}
var url = this.props.url;
var classname = this.props.current ? "current" : "";
if (this.props.disable) {
classname += " disabled";
url = "javascript:void();";
}
switch (this.props.type) {
case PagingType.prev:
classname += " prev";
break;
case PagingType.next:
classname += " next";
break;
}
return (React.createElement("li", { className: classname },
React.createElement("a", { href: url }, this.props.text)));
};
return PagingItemControl;
}(React.Component));
Core.PagingItemControl = PagingItemControl;
var PagingControl = /** @class */ (function (_super) {
__extends(PagingControl, _super);
function PagingControl(props) {
var _this = _super.call(this, props) || this;
_this.pre_count = 3;
_this.next_count = 5;
_this.pre_text = "\u4E0A\u4E00\u9875";
_this.next_text = "\u4E0B\u4E00\u9875";
_this.item_list = [];
if (!!_this.props.pre_count) {
_this.pre_count = _this.props.pre_count;
}
if (!!_this.props.next_count) {
_this.next_count = _this.props.next_count;
}
return _this;
}
PagingControl.prototype.getUrl = function (index) {
if (!!this.props.url_func) {
return this.props.url_func(index);
}
return "";
};
PagingControl.prototype.getItem = function (index, current) {
return {
index: index,
url: this.getUrl(index),
disable: false,
current: current,
type: PagingType.page,
text: String(index)
};
};
PagingControl.prototype.getDotsItem = function () {
return {
index: 0,
url: "",
disable: false,
current: false,
type: PagingType.dots,
text: ""
};
};
PagingControl.prototype.getPreNextItem = function (paging, next) {
if (paging.PageCount < 2)
return;
var index = next ? paging.PageIndex + 1 : paging.PageIndex - 1;
var disable = (next && paging.PageIndex == paging.PageCount) || (!next && paging.PageIndex == 1);
return {
index: index,
url: this.getUrl(index),
disable: disable,
current: false,
type: next ? PagingType.next : PagingType.prev,
text: next ? this.next_text : this.pre_text
};
};
PagingControl.prototype.init = function () {
console.log("paging init");
var paging = this.props.data;
var list = [];
if (paging != null && paging.PageIndex <= paging.PageCount && paging.PageIndex > 0) {
var tempindex = 0;
if (paging.PageCount > 1) {
list.push(this.getPreNextItem(paging, false));
}
list.push(this.getItem(1, paging.PageIndex == 1));
tempindex = paging.PageIndex - this.pre_count - 1;
if (tempindex == 2) {
list.push(this.getItem(2, false));
}
else if (tempindex > 1) {
list.push(this.getDotsItem());
}
for (var i = this.pre_count; i > 0; i--) {
if (paging.PageIndex - i > 1) {
list.push(this.getItem(paging.PageIndex - i, false));
}
}
if (paging.PageIndex != 1 && paging.PageIndex != paging.PageCount) {
list.push(this.getItem(paging.PageIndex, true));
}
for (var i = 1; i <= this.next_count; i++) {
if (paging.PageIndex + i < paging.PageCount) {
list.push(this.getItem(paging.PageIndex + i, false));
}
}
tempindex = paging.PageIndex + this.next_count + 1;
if (tempindex == paging.PageCount - 1) {
list.push(this.getItem(tempindex, false));
}
else if (tempindex < paging.PageCount) {
list.push(this.getDotsItem());
}
if (paging.PageCount != 1) {
list.push(this.getItem(paging.PageCount, paging.PageIndex == paging.PageCount));
list.push(this.getPreNextItem(paging, true));
}
}
this.item_list = list;
};
PagingControl.prototype.render = function () {
this.init();
return (React.createElement("ul", { className: "paging" }, this.item_list.map(function (x) {
return React.createElement(PagingItemControl, { key: x.type + "_" + x.index + "_" + x.text, index: x.index, url: x.url, current: x.current, disable: x.disable, type: x.type, text: x.text });
})));
};
return PagingControl;
}(React.Component));
Core.PagingControl = PagingControl;
var MobilePagingControl = /** @class */ (function (_super) {
__extends(MobilePagingControl, _super);
function MobilePagingControl(props) {
return _super.call(this, props) || this;
}
MobilePagingControl.prototype.getPage = function (index) {
if (!!this.props.get_page) {
this.props.get_page(index);
}
};
MobilePagingControl.prototype.page1 = function () {
var _this = this;
if (this.props.data.PageIndex <= 1) {
return (React.createElement("div", { className: "next-page-only", onClick: function (e) { return _this.getPage(_this.props.data.PageIndex + 1); } },
"\u4E0B\u4E00\u9875",
React.createElement("i", { className: "icon icon-new-arrow-right" })));
}
return React.createElement("div", null);
};
MobilePagingControl.prototype.pageOther = function () {
var _this = this;
if (this.props.data.PageIndex > 1) {
return (React.createElement("div", { className: "page-flex c-flexbox" },
React.createElement("div", { className: "page-left" },
React.createElement("div", { className: "first-page" },
React.createElement("div", { onClick: function (e) { return _this.getPage(1); } },
React.createElement("i", { className: "icon icon-new-two-arrow-left" }))),
React.createElement("div", { className: "prev-page" },
React.createElement("div", { onClick: function (e) { return _this.getPage(_this.props.data.PageIndex - 1); } },
React.createElement("i", { className: "icon icon-new-arrow-left" })))),
React.createElement("div", { className: "cur-page" }, "\u7B2C " + this.props.data.PageIndex + " \u9875"),
React.createElement("div", { className: "next-page" }, this.pageNext())));
}
return React.createElement("div", null);
};
MobilePagingControl.prototype.pageNext = function () {
var _this = this;
if (this.props.data.PageIndex < this.props.data.PageCount) {
return (React.createElement("div", { onClick: function (e) { return _this.getPage(_this.props.data.PageIndex + 1); } },
React.createElement("i", { className: "icon icon-new-arrow-right" })));
}
return React.createElement("div", null);
};
MobilePagingControl.prototype.render = function () {
if (!(this.props.data.PageIndex > 1 && this.props.data.PageCount == 1) && this.props.data.PageCount > 1) {
return (React.createElement("div", { className: "page-controller" },
this.page1(),
this.pageOther()));
}
return React.createElement("div", null);
};
return MobilePagingControl;
}(React.Component));
Core.MobilePagingControl = MobilePagingControl;
})(Core = Yunyou.Core || (Yunyou.Core = {}));
})(Yunyou || (Yunyou = {}));
久草小区二区三区四区网页