2016-01-29, 10:51
Tutorial: Next and Previous button at private messages |
This tutorial will make a next and previous button to your private messages, in that way you can easily skip to the older and new messages.
Credits: @no_way
Updated by: Shadow
--> Tutorials, tips and tricks <--
Next and Previous button at private messages
Next and Previous button at private messages
1º - Javascript
- Code:
[panda=js]$(function(){
var maxMP=50;/*2%/MP*/
var a=["inbox","savebox"],b,dl=document.location.toString(),cc=1,cI=0,collect=[],SPP=false;
var fpidP=function(dossier){var dossier=dossier,stop=stop||false;
if(!stop)$.get("/privmsg?folder="+dossier+"&start="+cI,(function(dossier,d){
var c,$d=$(d),i,l=dossier,$navMP=$("<div>",{id:"navMP"}),precedent,suivant;
c=$("form[action^='/privmsg'] a[href^='/privmsg?folder="+l+"&mode=read&p=']",$d);
if(!SPP){
SPP=$("form[action^='/privmsg'] a[href*='&start=']",$d).length?parseInt(/&start=(\d+)/.exec($("a[href*='&start=']",$d)[0].href)[1]):50;
}
for(i=0;i<c.length;i++){
collect[cI+i]=c[i];
}
for(i=0;i<collect.length;i++){
if(collect[i].href.indexOf('&p='+pid)!=-1){
if(i!==collect.length-1)$navMP.append($('<a>',{id:"navMP-precedent",href:collect[i+1].href,title:collect[i+1].textContent}));
if(i!==0)$navMP.append($('<a>',{id:"navMP-suivant",href:collect[i-1].href,title:collect[i-1].textContent}));
/*Evitons les requetes inutiles...*/
stop=i<collect.length-1;
break;
};
}
cI+=SPP;cc++;
if(cc<=Math.ceil(maxMP/SPP)&&!stop){fpidP(dossier);}
$("#navMP").length?$("#navMP").html($navMP.html()):$("form[action^='/privmsg']").before($navMP);
}).bind(null,dossier))};
for(b in a){
if(dl.indexOf("/privmsg\?folder="+a[b]+"&mode=read&p=")!=-1){
var pid=/&p=(\d+)/.exec(dl)[1];
fpidP(a[b]);
}
}
});
2º - CSS
Add the following part to your CSS
- Code:
[panda=css]#navMP>a{
display:inline-block;
padding-left:10px;
padding-right:10px;
font-size:16px;
line-height:16px;
color:#eee;
background:#0090A8;
text-decoration:none !important;
border:1px solid #aaa;
}
#navMP>a:hover{
color:#fff;
background:#004854;
text-decoration:none !important;
}
#navMP-precedent{
border-radius:8px 0 0 8px;
}
#navMP-suivant{
float:right;
border-radius:0 8px 8px 0;
}
#navMP-precedent::before{
content:"Previous"
}
#navMP-suivant::before{
content:"Next"
}
3º - Preview
© PunBB Design
If you have any questions related to this topic create a topic with the following title: Next and Previous button at private messages |