Team:Freiburg/Templates/html/js.html

From 2014.igem.org

(Difference between revisions)
 
(10 intermediate revisions not shown)
Line 1: Line 1:
<html>
<html>
-
<svg xmlns="http://www.w3.org/1999/xhtml"
 
-
      xmlns:svg="http://www.w3.org/2000/svg">
 
-
    <filter id="invertfilter">
 
-
      <feColorMatrix values="-1      0      0      0 1
 
-
                              0    -1      0      0 1
 
-
                              0      0    -1      0 1
 
-
                              0      0      0      1 0" style="color-interpolation-filters:sRGB"/>
 
-
    </filter>
 
-
  </svg>
 
<button class="invertbutton" onclick="invertColors();">Inv.</button>
<button class="invertbutton" onclick="invertColors();">Inv.</button>
<script>
<script>
-
var inverted = false;
+
function invertColors() {
-
    function invertColors() {
+
       var $html = $('html');
       var $html = $('html');
       $html.toggleClass('inverted-colors');
       $html.toggleClass('inverted-colors');
-
      var $uninvert = $html.find('.content img, .slideshow,.invertbutton');
 
-
      inverted = !inverted;
 
-
      if (inverted) {
 
-
        $html.css('filter', 'url(#invertfilter)');
 
-
        $uninvert.css('filter', 'url(#invertfilter)');
 
-
      } else {
 
-
        $html.css('filter', 'none');
 
-
        $uninvert.css('filter', 'none');
 
-
      }
 
     };
     };
(function(){
(function(){
Line 110: Line 91:
           }
           }
         });
         });
 +
      });
 +
 +
 +
     
 +
      $('.svg-container').each(function(){
 +
        var $this = $(this);
 +
        if ($this.find('svg a').length === 0){
 +
          $this.magnificPopup({
 +
            items: {
 +
                src: $this.clone(),
 +
                type: 'inline'
 +
            }
 +
          });
 +
        }
       });
       });
Line 117: Line 112:
           type: 'iframe'
           type: 'iframe'
         });
         });
-
      });
 
-
 
-
      $('body').scrollspy({
 
-
        target: '#content-nav',
 
-
        offset: $(window).height()/4
 
       });
       });
Line 182: Line 172:
     });
     });
</script>
</script>
 +
 +
<script>
 +
    // remove url in front of anchor links so scroll spy behaves correctly
 +
    var navLinks = $('#content-nav .nav a');
 +
 +
    // check all links' href attributes for equality with url
 +
    var currentPath = location.pathname;
 +
    for (var i=0;i<navLinks.length;i++) {
 +
      var href = navLinks[i].getAttribute('href')
 +
      var indexOfPath = href.indexOf(currentPath);
 +
      if (indexOfPath === -1) continue;
 +
      if (indexOfPath > 2) continue;
 +
 +
      var indexOfSharp = href.indexOf('#');
 +
      // check if the url part of the href ends with our location
 +
      var hreflength = href.length;
 +
      if (indexOfSharp !== -1) hreflength = indexOfSharp;
 +
      if (indexOfPath >= hreflength - currentPath.length - 1){
 +
        if (indexOfSharp === -1) {
 +
          navLinks[i].setAttribute('href', '#');
 +
          navLinks[i].setAttribute('class', 'active');
 +
        } else {
 +
          navLinks[i].setAttribute('href', href.slice(indexOfSharp));
 +
        }
 +
      }
 +
    }
 +
 +
    // initialize scrollspy
 +
    $('body').scrollspy({
 +
      target: '#content-nav',
 +
      offset: $(window).height()/4
 +
    });
 +
 +
    // different click navigation for first link
 +
    $('#content-nav .nav > li > a ').click(function(e){
 +
      var $parent = $(this.parentNode);
 +
      var children = $parent.children('ul');
 +
      // prevent redirect if we have children
 +
      if (children.length == 0) return;
 +
      e.preventDefault();
 +
 +
      // open up the nav otherwise
 +
      $parent.toggleClass('active');
 +
    });
 +
  </script>
<script src="/Team:Freiburg/js/jquery.qtip.min.js?action=raw&ctype=text/javascript"></script>
<script src="/Team:Freiburg/js/jquery.qtip.min.js?action=raw&ctype=text/javascript"></script>

Latest revision as of 22:56, 17 October 2014