Ejemplo n.º 1
0
                                $l5++;
                                $class = "toc5";
                                $toc = "TOC_5_" . (2 * $l5 - 1);
                                $l5++;
                                $endmatch = "/(.*)==(.*?)/msU";
                            } else {
                                echo "????\n";
                            }
                        }
                    }
                }
            }
            if (!preg_match($endmatch, $cur_text, $matches)) {
                break;
            }
            echo "<li class=\"{$class}\"><a href=\"#{$toc}\">" . trim($matches[1]) . "</a></li>\n";
            $cur_text = $matches[2];
        }
    }
}
$script = "\$(document).ready(function(){\n    var toc = \$('#toc" . $tag . "');   \n    if (toc.length>0) {\n        \$('body').attr('data-spy','scroll');\n            \n        toc.scrollspy();\n        var initialoffset = \$('.page').offset().top;\n        var divLocation = toc.offset();\n        var diff = divLocation.top - initialoffset;\n\n        // A la fin du chargement de la page, on positionne la table a la bonne position\n        \$(window).load(function () { \n            if (\$(document).scrollTop() > divLocation.top) {\n                offset = (\$(document).scrollTop() - initialoffset + 20 ) + 'px';\n                toc.animate({top:offset}, {duration:500,queue:false});\n            }\n        });\n\n        // quand on scrolle, la table suit\n        \$(window).scroll(function () { \n            if (\$(document).scrollTop() > divLocation.top) {\n                offset = (\$(document).scrollTop() - initialoffset + 20 ) + 'px';\n                toc.animate({top:offset}, {duration:500,queue:false});\n            }\n            else {\n                toc.animate({top:diff}, {duration:500,queue:false});\n            }\n        });\n\n        // on anime le passage a un chapitre \n        \$('.toc a').on('click', function () { \n            var link = \$(this).attr('href');\n            \$('html, body').animate({\n                 scrollTop: \$(link).offset().top\n             }, 500);\n            return false;\n        });\n    }\n});\n";
$this->AddJavascript($script);
// on vérifie qu'il y est au moins un titre pour faire la liste
if (preg_match("/(={2,6})(.*)/ms", $toc_body, $matches)) {
    echo "<ul class=\"unstyled\">\n" . translate2toc(preg_replace("/\"\".*?\"\"/ms", "", $toc_body)) . "</ul>\n";
}
// on ferme les divs ouvertes par l'action toc
echo "</div><!-- /.toc-menu -->\n\n    </div><!-- /#toc-menu" . $tag . " -->\n\n    </div><!-- /#toc" . $tag . " -->\n";
?>
 
Ejemplo n.º 2
0
Archivo: toc.php Proyecto: rhertzog/lcs
        { $l1++; $class="toc1"; $toc="TOC_0_1_".(2*$l1 - 1);
          $endmatch="/(.*)======(.*?)/msU"; }
      else if ($matches[1] == "=====")
        { $l2++; $class="toc2"; $toc="TOC_0_2_".(2*$l2 - 1);
          $endmatch="/(.*)=====(.*?)/msU"; }
      else if ($matches[1] == "====")
        { $l3++; $class="toc3"; $toc="TOC_0_3_".(2*$l3 - 1);
          $endmatch="/(.*)====(.*?)/msU"; }
      else if ($matches[1] == "===")
        { $l4++; $class="toc4"; $toc="TOC_0_4_".(2*$l4 - 1);
          $endmatch="/(.*)===(.*?)/msU"; }
      else if ($matches[1] == "==")
        { $l5++; $class="toc5"; $toc="TOC_0_5_".(2*$l5 - 1);
          $endmatch="/(.*)==(.*?)/msU"; }
      else
        echo "????\n";

      if (! preg_match($endmatch, $cur_text, $matches))
        break;

      echo "<div class=\"$class\"><img src=\"images/fleche.png\" alt=\"*\" /> <a href=\"#$toc\">"
        .trim($matches[1])."</a></div>\n";
      $cur_text = $matches[2];
    }
    }
}

translate2toc(preg_replace("/\"\".*?\"\"/ms", "", $toc_body));
echo "</div>\n";
echo "</div>\n";
?>