|
|
(34 intermediate revisions not shown) |
Line 27: |
Line 27: |
| <!-- Internet Explorer PNG fix - END /--> | | <!-- Internet Explorer PNG fix - END /--> |
| | | |
- | <!-- Scripting - START /-->
| |
- | <script type="text/javascript" src="http://nix.lv/history/jquery.history.js"></script>
| |
| | | |
- | <script type="text/javascript">
| |
- | //Global Vars
| |
- | var activePage = "</html>{{{contentpage|home}}}<html>";
| |
- |
| |
- | // Set document ready callback
| |
- | $(function() {
| |
- | // Initialize history plugin.
| |
- | $.history.init(historyCallback);
| |
- | rewriteLinks($("#navlist"));
| |
- |
| |
- | if(activePage == "home") {
| |
- | $.history.load("page=pages/home");
| |
- | // rewriteLinks($("#load"));
| |
- | }
| |
- |
| |
- | // set onlick event for menu buttons
| |
- | $("#wrapper a").click(function(){
| |
- | var hash = this.href;
| |
- | hash = hash.replace(/^.*#/, '');
| |
- | $.history.load(hash);
| |
- | return false;
| |
- | });
| |
- |
| |
- | // setup hovering
| |
- | $(".menu_button").hover(
| |
- | function () { $(this).addClass("hover"); },
| |
- | function () { $(this).removeClass("hover"); }
| |
- | );
| |
- | });
| |
- |
| |
- |
| |
- |
| |
- | function splitHash(hash) {
| |
- | var kvpairs = hash.split('&');
| |
- | var i;
| |
- | var kvmap = {};
| |
- | for(i=0;i<kvpairs.length;i++) {
| |
- | var s = kvpairs[i].split('=');
| |
- | kvmap[s[0]] = s[1];
| |
- | }
| |
- | return kvmap;
| |
- | }
| |
- |
| |
- | function loadPage(page)
| |
- | {
| |
- | var url = wgServer + "/Team:TU_Delft/" + page + "?action=render";
| |
- | $("#load").fadeOut(200);
| |
- | $.get(url, function(data) {
| |
- | $("#load").html(data).fadeIn(200);
| |
- | rewriteLinks($("#load"));
| |
- | });
| |
- | }
| |
- |
| |
- | function historyCallback(hash) {
| |
- | // hash doesn't contain the first # character.
| |
- | if(hash) {
| |
- | if(hash.split('=').length == 1)
| |
- | loadPage(hash);
| |
- | else {
| |
- | var kvmap = splitHash(hash);
| |
- | if (kvmap.page)
| |
- | loadPage(kvmap.page);
| |
- | else if(kvmap.anchor)
| |
- | window.scrollTo(0, $(kvmap.anchor).position().top);
| |
- | }
| |
- | } else {
| |
- | // start page
| |
- | $("#load").empty();
| |
- | }
| |
- | }
| |
- |
| |
- |
| |
- | function rewriteLinks(elem) {
| |
- | $("a",elem).each(function() {
| |
- | var txt = $(this).text();
| |
- | alert(this.href + ';;;' + this.hash);
| |
- | if(this.href.split('#').length == 2)
| |
- | this.href = '#fakeanchor';// '#anchor=' + this.href.substring(1);
| |
- | else if(txt != "edit")
| |
- | this.href = this.href.replace("https://2010.igem.org/Team:TU_Delft/", "#page=");
| |
- | });
| |
- | }
| |
- |
| |
- | </script>
| |
- |
| |
- | <!-- Scripting - END /-->
| |
| | | |
| <!-- Main CSS - START /--> | | <!-- Main CSS - START /--> |