Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Javascript] Next and Previous button at private messages



View previous topic View next topic Go down Message [Page 1 of 1]

1
Offline

  Shadow

avatar
Administrator
Administrator


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



- 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]);
 }
}
});


- 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"
}


- 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



Forum Administrator, Coolyou,
Due to the volume of PMs I receive, I do not provide support via PM.
We have community forums for most support requests. If it's truly confidential, please do PM me.

Useful links:
-> Before asking question,  please use a Search option.
-> If you want to check our staff members click here.
->  Forum rules, this is a MUST READ thread.
->  FAQ (Frenquently asked questions)

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

2
Offline

  Rukiafan

avatar
Punbb Rookie
Punbb Rookie
What pages should I enable the Javascript in for this to work properly?

Powered by PunBB
Currently 0 users have thanked Rukiafan for this post:

3
Offline

  Shadow

avatar
Administrator
Administrator
Rukiafan wrote:[link="/t1088-javascript-next-and-previous-button-at-private-messages#7489"]What pages should I enable the Javascript in for this to work properly?
In all pages.



Forum Administrator, Coolyou,
Due to the volume of PMs I receive, I do not provide support via PM.
We have community forums for most support requests. If it's truly confidential, please do PM me.

Useful links:
-> Before asking question,  please use a Search option.
-> If you want to check our staff members click here.
->  Forum rules, this is a MUST READ thread.
->  FAQ (Frenquently asked questions)

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

4
Offline

  Sponsored content



Powered by PunBB
Currently 0 users have thanked Sponsored content for this post:

View previous topic View next topic Back to top Message [Page 1 of 1]


Topic URL's

URL
BBcode
HTML

Permissions in this forum:
You cannot reply to topics in this forum