Line 3: | Line 3: | ||
+ | |||
+ | |||
+ | (function () { | ||
+ | $(function ($) { | ||
function scrollTo(hash) { | function scrollTo(hash) { | ||
hash = hash + '-scroll'; | hash = hash + '-scroll'; | ||
Line 10: | Line 14: | ||
}, 700, 'swing', function () {}); | }, 700, 'swing', function () {}); | ||
} | } | ||
− | |||
− | |||
− | |||
var target = window.location.hash; | var target = window.location.hash; | ||
Revision as of 19:08, 17 October 2017
// store the hash (DON'T put this code inside the $() function, it has to be executed // right away
(function () {
$(function ($) {
function scrollTo(hash) {
hash = hash + '-scroll'; console.log("Im scrolling to " + hash); $('html, body').animate({ scrollTop: $(hash).offset().top }, 700, 'swing', function () {});
}
var target = window.location.hash;
if (target) {
scrollTo(target);
}
console.log("Im reloading"); $(window).on('hashchange', function () { var hash = window.location.hash; if (hash) {scrollTo(hash);} }); //navbar $(".dropdown-button").dropdown({ hover: false, constrainWidth: false, belowOrigin: true }); $('#menu-btn').click(function () { $('nav').addClass('show-nav'); }); $('#cross').click(function () { $('nav').removeClass('show-nav'); }); var module_classes = ['cas13a', 'TDP', 'detection', 'sampleprep', 'vesicles']; var whosActive = function () { var active = new Array(module_classes.length); $('#notebook-buttons>a').each(function (index) { var $this = $(this); active[index] = hasClass($this, 'active'); }) return active; };
var hasClass = function ($el, className) { return $el.attr('class').split(' ').some( el => el === className) }; var display = function (active) { for (var i = 0; i < active.length; i++) { var $module = $("." + module_classes[i]); if (active[i]) { $module.css("display", "block"); } else { $module.css("display", "none"); } } }; display(whosActive()) // initialization $('#notebook-buttons>a').each(function (index) { var $this = $(this); $this.on('click', function () { console.log("I clicked this"); $this.toggleClass('active'); display(whosActive()); }); });
//toc // $(".scrollspy").scrollSpy(); // setTimeout(function () { // $("#toc").pushpin({ // offset: 150, // top: 0, // bottom: $('footer').offset().top - $('#toc').outerHeight(true) // }) // }, 100); //timeline // $(".scrollspy").scrollSpy( // { // getActiveElement: function (id) { // return "round" + (parseInt(id.replace(/\D/g, )) - 20); // } // } // ); $(".scrollspy").scrollSpy();
//main
// function scaleIn() { // $("scaleIn").each(function() { // setTimeout(function () { // $(this).addClass('activated'); // }, 500) // }); // }
function scaleIn(el) { console.log("im called"); $(".scaleIn").each(function (index) { var that = $(this); setTimeout(function () { that.addClass('activated') }, 200 * index); }) }
$('select').material_select();
var options = [{ selector: '#thisList', offset: 500, callback: function (el) { Materialize.showStaggeredList($(el)); } }, { selector: '#row1', offset: 0, callback: scaleIn }]; Materialize.scrollFire(options);
var white = " ", first = "\u00A0\u00A0tudelft", secon = "igem",
third = "gmail", forth = "com", all = " " + " " + first + "." + secon + "@" + third + "." + forth, sall = " " + " " + all, ma = "ma" + "il", mm = ma + "to" + ":";
// Dynamically add e-mail to distract spam bots $("#mail-button").attr("href", mm + all.trim()); $("#email").text(white + sall);
// Removing empty p tages $("p").filter(function () { return $.trim($(this).text()) === ; }).remove();
$('top_menu_14, top_menu_inside ').on('touchstart', function (e) { var $this = $(this); if ($this.hasClass('hover')) { return true } else { $this.addClass('hover'); e.preventDefault(); return false; // Is this a hack? Unnecesary code anyways. preventDefault should do it already, be you never know you know. } })
});
}($));
function filter_notebook(select) {
console.log(select);
} // function for copying text to clipboard (used for phone number) function copyToClipboard(element) {
var $temp = $("<input>"); $("body").append($temp); $temp.val(element).select(); document.execCommand("copy"); $temp.remove(); alert("You copied: " + element + ".");
}