Federer will at least be number 1 until the end of the Olympics, which means 4 more weeks, which means at least 289 weeks, that is more than Sampras's 286 weeks.
Djokovic can take the number 1 back after the Olympics : actually he will even take it if he just does the same result as Fed in the Olympics, if
it's at least a quarterfinal (because Fed will replace his 90 points from Doha whereas for Djokovic it will be a completely new result).
BUT after the Olympics, Djokovic will lose many points ... and as you will see below, there's a very big chance that Fed is number 1 during the US Open and until Basel-Bercy (the points from Bercy and last WTF being taken out at that moment)... and that he reaches more than 300 weeks at number 1
Now as far as the rankings are concerned, what will be important will be the Race for the end-of-year number 1, which would also mean for Fed potentially equalize Sampras's 6 end-of-year number 1s.
At the moment for the end-of-year number 1 Fed, Djokovic and Nadal are nearly equal :
Federer 7085 ahead of Djokovic and Nadal 6840,
which means the best from now on (and especially the winner of the US Open and/or the WTF ) will be number 1 in the end of the year.
Before that, here are the ranking points until Shanghai when you take off the points from last year :
after Wimbledon :
after Canada open (won by Djokovic last year then he would drop 1000 points) :
after Cinci for the US Open seeds
(Djokovic was finalist and will lose 600 points) :
after the US Open (Djokovic will have 2685 points to take back to Fed until then !!) :
after Shanghai :