Difference between revisions of "Team:Paris Bettencourt/Team"
Line 336: | Line 336: | ||
<img width="20px" src="https://static.igem.org/mediawiki/2015/7/7c/ParisBettencourt_LogoEmail.png" alt="Email address" /> <a href="mailto:igembettencourt2015@gmail.com">igembettencourt2015@gmail.com</a> | <img width="20px" src="https://static.igem.org/mediawiki/2015/7/7c/ParisBettencourt_LogoEmail.png" alt="Email address" /> <a href="mailto:igembettencourt2015@gmail.com">igembettencourt2015@gmail.com</a> | ||
+ | |||
+ | <!-- Gallery JS (animation) --> | ||
+ | <script type="text/javascript"> | ||
+ | /** | ||
+ | * Add hash to url without scrolling | ||
+ | * | ||
+ | * @param String $url - it could be hash or url with hash | ||
+ | * | ||
+ | * @return void | ||
+ | */ | ||
+ | function addHashToUrl($url) | ||
+ | { | ||
+ | if ('' == $url || undefined == $url) { | ||
+ | $url = '_'; // it is empty hash because if put empty string here then browser will scroll to top of page | ||
+ | } | ||
+ | $hash = $url.replace(/^.*#/, ''); | ||
+ | var $fx, $node = jQuery('#' + $hash); | ||
+ | if ($node.length) { | ||
+ | $fx = jQuery('<div></div>') | ||
+ | .css({ | ||
+ | position:'absolute', | ||
+ | visibility:'hidden', | ||
+ | top: jQuery(window).scrollTop() + 'px' | ||
+ | }) | ||
+ | .attr('id', $hash) | ||
+ | .appendTo(document.body); | ||
+ | $node.attr('id', ''); | ||
+ | } | ||
+ | document.location.hash = $hash; | ||
+ | if ($node.length) { | ||
+ | $fx.remove(); | ||
+ | $node.attr('id', $hash); | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | $(document).ready(function() { | ||
+ | // Make the list of all members | ||
+ | var members = $('.descriptionArea').map(function(index) { | ||
+ | return this.id; | ||
+ | }); | ||
+ | members = jQuery.makeArray(members); | ||
+ | |||
+ | |||
+ | // Make the hash change: | ||
+ | // Escape removes the hash | ||
+ | $(document).keyup(function(e) { | ||
+ | if (e.keyCode == 27) { | ||
+ | addHashToUrl(""); | ||
+ | }; | ||
+ | }); | ||
+ | |||
+ | |||
+ | // Triggers: hashchange, when page loads with specified hash | ||
+ | // Page is loaded | ||
+ | var hash = window.location.hash.slice(1); | ||
+ | if (jQuery.inArray(hash, members) != -1) { | ||
+ | $("#"+hash).addClass("show"); | ||
+ | $("#empty").removeClass("show"); | ||
+ | }; | ||
+ | |||
+ | |||
+ | // Hash changes | ||
+ | $(window).bind('hashchange', function() { // when hash changes | ||
+ | var hash = window.location.hash.slice(1); | ||
+ | $(".descriptionArea").removeClass("show"); | ||
+ | $("#empty").addClass("show"); | ||
+ | if (jQuery.inArray(hash, members) != -1) { | ||
+ | $("#"+hash).addClass("show"); | ||
+ | $("#empty").removeClass("show"); | ||
+ | }; | ||
+ | }); | ||
+ | |||
+ | // Close window when click outside of it | ||
+ | //$("body").click(function(event) { | ||
+ | // if(!$(event.target).closest(".descriptionArea").length) { | ||
+ | // $(".descriptionArea").removeClass("show"); | ||
+ | // addHashToUrl(""); | ||
+ | // }; | ||
+ | //}); | ||
+ | |||
+ | }); | ||
+ | </script> | ||
Revision as of 22:21, 18 September 2015