Home > Web Front-end > JS Tutorial > body text

The helper displayed on a certain page number has been slightly adjusted, and a js version is attached_javascript skills

WBOY
Release: 2016-05-16 18:19:39
Original
999 people have browsed it

If you just want to download the ready-made one, you can go to this page to find it.
The license is "WTFPL", which is "Do What The Fuck You Want To Public License".

The source code is as follows (because there are comments, I will not explain it separately):
Copy the code The code is as follows:

public static class PageNumExt
{
///
/// Calculates and produces a friendly page number using the passed in delegate.
///

///
/// Current page number
/// How to handle page numbers
/// Handling folded page numbers way
/// The number of adjacent page numbers
/// Prevent folding The critical value of page number. Page numbers exceeding this number will be folded
public static void PageNumView(this object o,
long currentPage, PageNumAction actionPageNum, Action actionFolding,
long maxSiblings = 2 , long preventFolding = 1)
{
o.PageNumView(currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings, preventFolding);
}
///
/// Calculate and produce friendly page numbers using the passed delegate. The current page number will be treated specially.
///

///
/// Current page number
/// How to handle the current page number
/// How to handle the page number Method
/// How to handle folded page numbers
/// Close The number of page numbers
/// The critical value that prevents folding page numbers. Page numbers exceeding this number will be folded
public static void PageNumView(this object o,
long currentPage, PageNumAction actionCurrent,
PageNumAction actionPageNum, Action actionFolding,
long maxSiblings = 2, long preventFolding = 1)
{
o.PageNumView(
currentPage, actionCurrent,
1, long.MaxValue,
actionPageNum, i => { },
maxSiblings, actionPageNum,
preventFolding, actionFolding,
maxSiblings, 0,
actionPageNum, i => { }
);
}
///
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The current page number will be treated specially.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle page numbers
/// How to handle folded page numbers
/// The number of adjacent page numbers
/// The critical value that prevents folding page numbers. Pages exceeding this number will be folded
public static void PageNumView(this object o,
long currentPage, PageNumAction actionCurrent,
long beginPage, long endPage,
PageNumAction actionPageNum, Action actionFolding,
long maxSiblings = 2, long preventFolding = 1)
{
o.PageNumView(currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionPageNum, actionPageNum, actionFolding, maxSiblings, preventFolding);
}
///
/ // Calculate and generate friendly page numbers based on the passed parameters and delegates. The current page number, starting page number and ending page number are all assigned special delegates for processing.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle the starting page number
/// How to handle the ending page number
/// How to handle adjacent page numbers
/// How to handle folded page numbers
/// The number of adjacent page numbers
/// The critical value that prevents folding page numbers. Pages exceeding this number will be foldedlong maxSiblings = 2, long preventFolding = 1)
{
o.PageNumView(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin, actionEnd,
maxSiblings, actionSebling,
preventFolding, actionFolding,
maxSiblings, maxSiblings,
actionSebling, actionSebling
);
}
///
/// According to the incoming parameters and delegates to calculate and generate friendly page numbers. The specific processing method of each page number requires a delegate assigned by the caller.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle the starting page number
/// How to handle the ending page number
/// Number of adjacent page numbers for the current page number
/// How to handle adjacent page numbers
/// The threshold value that prevents folding page numbers. Pages exceeding this number will be folded
/// How to handle folded page numbers< ;/param> Number of adjacent page numbers
/// How to handle adjacent page numbers of the start page
/// How to handle page numbers near the end page
public static void PageNumView(this object o,
long currentPage, PageNumAction actionCurrent,
long beginPage, long endPage,
PageNumAction actionBegin, PageNumAction actionEnd,
long currentSiblings, PageNumAction actionCurrentSibling,
long preventFolding, Action actionFolding,
long endOfBegin, long beginOfEnd,
PageNumAction actionBeginSibling, PageNumAction actionEndSibling
)
{
long i = beginPage;
//If the starting page is smaller than the current page, start processing the starting page
if (beginPage < currentPage)
#region
{
actionBegin(beginPage ; = siblingBegin - preventFolding; // The bottom line of page number folding
if (endOfBegin > siblingBegin)
endOfBegin = siblingBegin; // Ensure the adjacent pages of the current page, sacrificing the adjacent pages of the starting page
for (; i < endOfBegin; i )
actionBeginSibling(i);
if (i < foldingStart) // If the folding bottom line has not been reached, start folding immediately
{
actionFolding();
i = foldingStart 1; // Jump to the page number after folding
}
}
#endregion
// Process the adjacent page before the current page
for (; i < currentPage ; i )
actionCurrentSibling(i);
// Process the current page
actionCurrent(currentPage);
i = currentPage 1; // Indicates that the current page has been processed.
// Since the relationship between the current page and the desired starting page cannot be guaranteed, calculation starts from the current page.
var goal = i currentSiblings; // Set a goal
if (goal > endPage) // The goal should not exceed the end page
goal = endPage;
// Process the proximity after the current page pages until reaching the target page
for (; i < goal; i )
actionCurrentSibling(i);
// If the end page is larger than the current page, start processing the end page
if ( endPage > currentPage)
#region
{
beginOfEnd = endPage - beginOfEnd; // Calculate where adjacent pages of the end page start
var foldingStart = beginOfEnd - preventFolding;
if (i < foldingStart) // Without touching the folding bottom line, start folding immediately
{
actionFolding();
i = beginOfEnd;
}
else // Treat everything as the current page Process adjacent pages, but retain adjacent pages of the end page
for (; i < beginOfEnd; i )
actionCurrentSibling(i);

for (; i < endPage; i )
actionEndSibling(i);
actionEnd(endPage);
}
#endregion
}
}

The source code of the JavaScript version can be directly at the front Download the mentioned page, but here it is also listed:
Copy the code The code is as follows:

!function () {
var g = this;
var def_maxSiblings = 2;
var def_preventFolding = 1;
function pnView1(
currentPage, actionPageNum, actionFolding,
maxSiblings, preventFolding
) {
///
/// Calculates and produces friendly page numbers using the passed in delegate.
///

///
/// Current page number
/// How to handle page numbers
/// Handling folded page numbers way
/// The number of adjacent page numbers
/// Prevent folding The critical value of page number. Page numbers exceeding this number will be folded
pnView2(currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings || def_maxSiblings, preventFolding || def_preventFolding);
}
function pnView2(
currentPage, actionCurrent,
actionPageNum, actionFolding,
maxSiblings, preventFolding
) {
///
/// Calculated using the passed in delegate and generate friendly page numbers. The current page number will be treated specially.
///

///
/// Current page number
/// How to handle the current page number
/// How to handle the page number Method
/// How to handle folded page numbers
/// Close The number of page numbers
/// The critical value that prevents folding page numbers. Page numbers exceeding this number will be folded
pnView(
currentPage, actionCurrent,
1, Number.POSITIVE_INFINITY,
actionPageNum, null,
maxSiblings || def_maxSiblings, actionPageNum,
preventFolding || def_preventFolding, actionFolding,
maxSiblings || def_maxSiblings , 0,
actionPageNum, null
);
}
function pnView3(
currentPage, actionCurrent,
beginPage, endPage,
actionPageNum, actionFolding,
maxSiblings, preventFolding
) {
///
/// Calculate and generate friendly page numbers based on the passed parameters and delegates. The current page number will be treated specially.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle page numbers
/// How to handle folded page numbers
/// The number of adjacent page numbers
/// The critical value that prevents folding page numbers. Pages exceeding this number will be folded
pnView4(currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionPageNum, actionPageNum, actionFolding, maxSiblings || def_maxSiblings, preventFolding || def_preventFolding);
}
function pnView4(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin, actionEnd,
actionSebling, actionFolding,
maxSiblings, preventFolding
) {
///
/// According to the parameters passed in and delegates to calculate and produce friendly page numbers. The current page number, starting page number and ending page number are all assigned special delegates for processing.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle the starting page number
/// How to handle the ending page number
/// How to handle adjacent page numbers
/// How to handle folded page numbers
/// The number of adjacent page numbers
/// The critical value that prevents folding page numbers. Pages exceeding this number will be folded
pnView(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin, actionEnd,
maxSiblings || def_maxSiblings, actionSebling,
preventFolding || >maxSiblings || def_maxSiblings, maxSiblings || def_maxSiblings,
actionSebling, actionSebling
);
}
function pnView(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin , actionEnd,
currentSiblings, actionCurrentSibling,
preventFolding, actionFolding,
endOfBegin, beginOfEnd,
actionBeginSibling, actionEndSibling
) {
///
// / Calculate and generate friendly page numbers based on the passed parameters and delegates. The specific processing method of each page number requires a delegate assigned by the caller.
///

///
/// Current page number
/// How to handle the current page number
/// Default Starting page number
/// Default end page number
/// How to handle the starting page number
/// How to handle the ending page number
/// Number of adjacent page numbers for the current page number
/// How to handle adjacent page numbers
/// The threshold value that prevents folding page numbers. Pages exceeding this number will be folded
/// How to handle folded page numbers< ;/param> Number of adjacent page numbers
/// How to handle adjacent page numbers of the start page
/// How to process page numbers adjacent to the end page
var i = beginPage;
// If the starting page is smaller than the current page, start processing the starting page
if (beginPage < ; currentPage) {
actionBegin && actionBegin(beginPage);
i ;
endOfBegin = i; // After resolving page numbers close to the start page
var siblingBegin = currentPage - currentSiblings; // Current page Where does the adjacent page start?
var foldingStart = siblingBegin - preventFolding; // The bottom line of page number folding
if (endOfBegin > siblingBegin)
endOfBegin = siblingBegin; // Ensure the adjacent page of the current page, sacrifice Adjacent pages of the start page
for (; i < endOfBegin; i )
actionBeginSibling && actionBeginSibling(i);
if (i < foldingStart) // If the folding bottom line has not been reached yet, immediately Start folding
{
actionFolding && actionFolding();
i = foldingStart 1; // Jump to the page number after folding
}
}
// Process the proximity before the current page Page
for (; i < currentPage; i )
actionCurrentSibling && actionCurrentSibling(i);
// Process the current page
actionCurrent && actionCurrent(currentPage);
i = currentPage 1; // Indicates that the current page has been processed.
// Since the relationship between the current page and the desired starting page cannot be guaranteed, calculation starts from the current page.
var goal = i currentSiblings; // Set a goal
if (goal > endPage) // The goal should not exceed the end page
goal = endPage;
// Process the proximity after the current page pages until the target page is reached
for (; i < goal; i )
actionCurrentSibling && actionCurrentSibling(i);
// If the end page is larger than the current page, start processing the end page
if (endPage > currentPage) {
beginOfEnd = endPage - beginOfEnd; // Calculate where adjacent pages of the end page start
var foldingStart = beginOfEnd - preventFolding;
if (i < foldingStart) // The folding bottom line is not touched, start folding immediately
{
actionFolding && actionFolding();
i = beginOfEnd;
}
else // All are treated as adjacent pages to the current page , but keep the adjacent pages of the end page
{
for (; i < beginOfEnd; i )
actionCurrentSibling && actionCurrentSibling(i);
}

for (; i < ; endPage; i )
actionEndSibling && actionEndSibling(i);
actionEnd && actionEnd(endPage);
}
}
g.pnView1 = pnView1;
g.pnView2 = pnView2 ;
g.pnView3 = pnView3;
g.pnView4 = pnView4;
g.pnView5 = pnView;
g.pnView = pnView;
} ();

/201009/yuanma/pnView_NanaView.rar
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template