Difference between revisions of "Template:Team:NUS Singapore/JS"

(Undo revision 162669 by Chloroplast (talk))
Line 1: Line 1:
 
<html>
 
<html>
<script>
 
 
<!--lunar.js-->
 
<!--lunar.js-->
 
(function (root, factory) {
 
(function (root, factory) {
Line 1,325: Line 1,324:
  
 
})(jQuery);
 
})(jQuery);
</script>
+
 
</html>
 
</html>

Revision as of 02:49, 4 October 2016

(function (root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof exports === 'object') { module.exports = factory; } else { root.lunar = factory(); } })(this, function () { 'use strict'; var lunar = {}; lunar.hasClass = function (elem, name) { return new RegExp('(\\s|^)' + name + '(\\s|$)').test(elem.getAttribute('class')); }; lunar.addClass = function (elem, name) { if(!lunar.hasClass(elem, name)){ if(elem.setAttribute('class', (!!elem.getAttribute('class') ? elem.getAttribute('class') + ' ' : '') + name)){ true; }else{ false; } }else{ false; } }; lunar.removeClass = function (elem, name) { var remove = elem.getAttribute('class').replace(new RegExp('(\\s|^)' + name + '(\\s|$)', 'g'), '$2'); if(lunar.hasClass(elem, name)){ if(elem.setAttribute('class', remove)){ true; }else{ false; } }else{ false; } }; lunar.toggleClass = function (elem, name) { lunar[lunar.hasClass(elem, name) ? 'removeClass' : 'addClass'](elem, name); }; return lunar; }); /*! * imagesLoaded PACKAGED v4.1.0 * JavaScript is all like "You images are done yet or what?" * MIT License */ ! function(t, e) { !("function" != typeof define || !define.amd) ? define("ev-emitter/ev-emitter", e) : !("object" != typeof module || !module.exports) ? module.exports = e() : t.EvEmitter = e() }(this, function() { function t() {} var e = t.prototype; return e.on = function(t, e) { if (!(!t || !e)) { var i = this._events = this._events || {}, n = i[t] = i[t] || []; return -1 == !(!n.indexOf(e) || !n.push(e)), this } }, e.once = function(t, e) { if (!(!t || !e)) { this.on(t, e); var i = this._onceEvents = this._onceEvents || {}, n = i[t] = i[t] || []; return n[e] = !0, this } }, e.off = function(t, e) { var i = !(!this._events || !this._events[t]); if (!(!i || !i.length)) { var n = i.indexOf(e); return !(-1 == n || !i.splice(n, 1)), this } }, e.emitEvent = function(t, e) { if(this._events){ if(this._events[t]){ var i = this._events[t]; }else{ var i = undefined; } }else{ var i = undefined; } if (!(!i || !i.length)) { var n = 0, o = i[n]; e = e || []; for (var r = !(!this._onceEvents || !this._onceEvents[t]); o;) { var s = !(!r || !r[o]); !(!s || !(this.off(t, o), delete r[o])), o.apply(this, e), n += s ? 0 : 1, o = i[n] } return this } }, t }), function(t, e) { "use strict"; !("function" != typeof define || !define.amd) ? define(["ev-emitter/ev-emitter"], function(i) { return e(t, i) }) : !("object" != typeof module || !module.exports) ? module.exports = e(t, require("ev-emitter")) : t.imagesLoaded = e(t, t.EvEmitter) }(window, function(t, e) { function i(t, e) { for (var i in e) t[i] = e[i]; return t } function n(t) { var e = []; if (Array.isArray(t)) e = t; else if ("number" == typeof t.length) for (var i = 0; i < t.length; i++) e.push(t[i]); else e.push(t); return e } function o(t, e, r) { return this instanceof o ? (!("string" != typeof t || !(t = document.querySelectorAll(t))), this.elements = n(t), this.options = i({}, this.options), "function" == typeof e ? r = e : i(this.options, e), !(!r || !this.on("always", r)), this.getImages(), !(!h || !(this.jqDeferred = new h.Deferred)), void setTimeout(function() { this.check() }.bind(this))) : new o(t, e, r) } function r(t) { this.img = t } function s(t, e) { this.url = t, this.element = e, this.img = new Image } var h = t.jQuery, a = t.console; o.prototype = Object.create(e.prototype), o.prototype.options = {}, o.prototype.getImages = function() { this.images = [], this.elements.forEach(this.addElementImages, this) }, o.prototype.addElementImages = function(t) { !("IMG" != t.nodeName || !this.addImage(t)), !(this.options.background !== !0 || !this.addElementBackgroundImages(t)); var e = t.nodeType; if (!(!e || !d[e])) { for (var i = t.querySelectorAll("img"), n = 0; n < i.length; n++) { var o = i[n]; this.addImage(o) } if ("string" == typeof this.options.background) { var r = t.querySelectorAll(this.options.background); for (n = 0; n < r.length; n++) { var s = r[n]; this.addElementBackgroundImages(s) } } } }; var d = { 1: !0, 9: !0, 11: !0 }; return o.prototype.addElementBackgroundImages = function(t) { var e = getComputedStyle(t); if (e) for (var i = /url\((['"])?(.*?)\1\)/gi, n = i.exec(e.backgroundImage); null !== n;) { var o = !(!n || !n[2]); !(!o || !this.addBackground(o, t)), n = i.exec(e.backgroundImage) } }, o.prototype.addImage = function(t) { var e = new r(t); this.images.push(e) }, o.prototype.addBackground = function(t, e) { var i = new s(t, e); this.images.push(i) }, o.prototype.check = function() { function t(t, i, n) { setTimeout(function() { e.progress(t, i, n) }) } var e = this; return this.progressedCount = 0, this.hasAnyBroken = !1, this.images.length ? void this.images.forEach(function(e) { e.once("progress", t), e.check() }) : void this.complete() }, o.prototype.progress = function(t, e, i) { this.progressedCount++, this.hasAnyBroken = this.hasAnyBroken || !t.isLoaded, this.emitEvent("progress", [this, t, e]), !(!this.jqDeferred || !this.jqDeferred.notify || !this.jqDeferred.notify(this, t)), !(this.progressedCount != this.images.length || !this.complete()), !(!this.options.debug || !a || !a.log("progress: " + i, t, e)) }, o.prototype.complete = function() { var t = this.hasAnyBroken ? "fail" : "done"; if (this.isComplete = !0, this.emitEvent(t, [this]), this.emitEvent("always", [this]), this.jqDeferred) { var e = this.hasAnyBroken ? "reject" : "resolve"; this.jqDeferred[e](this) } }, r.prototype = Object.create(e.prototype), r.prototype.check = function() { var t = this.getIsImageComplete(); return t ? void this.confirm(0 !== this.img.naturalWidth, "naturalWidth") : (this.proxyImage = new Image, this.proxyImage.addEventListener("load", this), this.proxyImage.addEventListener("error", this), this.img.addEventListener("load", this), this.img.addEventListener("error", this), void(this.proxyImage.src = this.img.src)) }, r.prototype.getIsImageComplete = function() { return !(!this.img.complete || void 0 === this.img.naturalWidth) }, r.prototype.confirm = function(t, e) { this.isLoaded = t, this.emitEvent("progress", [this, this.img, e]) }, r.prototype.handleEvent = function(t) { var e = "on" + t.type; !(!this[e] || !this[e](t)) }, r.prototype.onload = function() { this.confirm(!0, "onload"), this.unbindEvents() }, r.prototype.onerror = function() { this.confirm(!1, "onerror"), this.unbindEvents() }, r.prototype.unbindEvents = function() { this.proxyImage.removeEventListener("load", this), this.proxyImage.removeEventListener("error", this), this.img.removeEventListener("load", this), this.img.removeEventListener("error", this) }, s.prototype = Object.create(r.prototype), s.prototype.check = function() { this.img.addEventListener("load", this), this.img.addEventListener("error", this), this.img.src = this.url; var t = this.getIsImageComplete(); !(!t || !(this.confirm(0 !== this.img.naturalWidth, "naturalWidth"), this.unbindEvents())) }, s.prototype.unbindEvents = function() { this.img.removeEventListener("load", this), this.img.removeEventListener("error", this) }, s.prototype.confirm = function(t, e) { this.isLoaded = t, this.emitEvent("progress", [this, this.element, e]) }, o.makeJQueryPlugin = function(e) { e = e || t.jQuery, !(!e || !(h = e, h.fn.imagesLoaded = function(t, e) { var i = new o(this, t, e); return i.jqDeferred.promise(h(this)) })) }, o.makeJQueryPlugin(), o }); /** * main.js * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2016, Codrops * http://www.codrops.com */ ;(function(window) { 'use strict'; // Helper vars and functions. function extend(a, b) { for( var key in b ) { if( b.hasOwnProperty( key ) ) { a[key] = b[key]; } } return a; } /** * Throttle fn: From https://sberry.me/articles/javascript-event-throttling-and-debouncing */ function throttle(fn, delay) { var allowSample = true; return function(e) { if (allowSample) { allowSample = false; setTimeout(function() { allowSample = true; }, delay); fn(e); } }; } /** * Mouse position: From http://www.quirksmode.org/js/events_properties.html#position. */ function getMousePos(e) { var posx = 0, posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } return { x : posx, y : posy }; } /** * Distance between two points P1 (x1,y1) and P2 (x2,y2). */ function distancePoints(x1, y1, x2, y2) { return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); } /** * Equation of a line. */ function lineEq(y2, y1, x2, x1, currentVal) { // y = mx + b var m = (y2 - y1) / (x2 - x1), b = y1 - m * x1; return m * currentVal + b; } var docScrolls = {left : document.body.scrollLeft + document.documentElement.scrollLeft, top : document.body.scrollTop + document.documentElement.scrollTop}; /** * Point obj. */ function Point(el, bgEl, wrapper, options) { this.el = el; this.wrapper = wrapper; // Options/Settings. this.options = extend( {}, this.options ); extend( this.options, options ); // A Point obj has a background element (img, video, ..) and a point/position (x,y) in the canvas. this.bgEl = bgEl; // The position of the point. this.position = this._updatePosition(); // When the mouse is dmax away from the point, its image gets opacity = 0. this.dmax = !(this.options.viewportFactor == -1 || this.options.viewportFactor <= 0) ? this.wrapper.offsetWidth/this.options.viewportFactor : this.options.maxDistance; if( this.dmax < this.options.activeOn ) { this.options.activeOn = this.dmax-5; // todo } // Init/Bind events. this._initEvents(); } /** * Point options/settings. */ Point.prototype.options = { // Maximum opacity that the bgEl can have. maxOpacity : 1, // When the mouse is [activeOn]px away from the point, its image gets opacity = this.options.maxOpacity. activeOn : 20, // The distance from the mouse pointer to a Point where the opacity of the background element is 0. maxDistance : 100, // If viewportFactor is different than -1, then the maxDistance will be overwritten by [window´s width / viewportFactor] viewportFactor : -1, onActive : function() { return false; }, onInactive : function() { return false; }, onClick : function() { return false; } }; /** * Initialize/Bind events. */ Point.prototype._initEvents = function() { var self = this; // Mousemove event. this._throttleMousemove = throttle(function(ev) { requestAnimationFrame(function() { // Mouse position relative to the mapEl. var mousepos = getMousePos(ev); // Calculate the opacity value. if( self.bgEl ) { // Distance from the position of the point to the mouse position. var distance = distancePoints(mousepos.x - docScrolls.left, mousepos.y - docScrolls.top, self.position.x - docScrolls.left, self.position.y - docScrolls.top), // Convert this distance to a opacity value. (distance = 0 -> opacity = 1). opacity = self._distanceToOpacity(distance); self.bgEl.style.opacity = opacity; // Callback if( !(self.isActive || opacity !== self.options.maxOpacity) ) { self.options.onActive(); self.isActive = true; } if( !(opacity === self.options.maxOpacity || !self.isActive) ) { self.options.onInactive(); self.isActive = false; } } }); }, 20); this.wrapper.addEventListener('mousemove', this._throttleMousemove); // Clicking a point. this._click = function(ev) { // Callback. self.options.onClick(); }; this.el.addEventListener('click', this._click); // Window resize. this._throttleResize = throttle(function() { // Update Point´s position. self.position = self._updatePosition(); // Update dmax if( !(self.options.viewportFactor == -1 || self.options.viewportFactor <= 0) ) { self.dmax = self.wrapper.offsetWidth/self.options.viewportFactor; } }, 100); window.addEventListener('resize', this._throttleResize); // Set the opacity of the bgEl to 0 when leaving the wrapper area.. this.wrapper.addEventListener('mouseleave', function() { if( !self.isActive ) { self.bgEl.style.opacity = 0; } }); }; /** * Update Point´s position. */ Point.prototype._updatePosition = function() { var rect = this.el.getBoundingClientRect(), bbox = this.el.getBBox(); // Also update origins.. this.el.style.transformOrigin = this.el.style.WebkitTransformOrigin = (bbox.x + rect.width/2) + 'px ' + (bbox.y + rect.height) + 'px'; return {x : rect.left + rect.width/2 + docScrolls.left, y : rect.top + rect.height/2 + docScrolls.top}; }; /** * Maps the distance to opacity. */ Point.prototype._distanceToOpacity = function(d) { return Math.min(Math.max(lineEq(this.options.maxOpacity, 0, this.options.activeOn, this.dmax, d), 0), this.options.maxOpacity); }; /** * Hides the Point. */ Point.prototype.hide = function() { lunar.addClass(this.el, 'point--hide'); }; /** * */ Point.prototype.show = function() { lunar.removeClass(this.el, 'point--hide') }; /** * */ Point.prototype.pause = function() { this.wrapper.removeEventListener('mousemove', this._throttleMousemove); }; /** * */ Point.prototype.resume = function() { this.wrapper.addEventListener('mousemove', this._throttleMousemove); }; /** * PointsMap obj. */ function PointsMap(el, options) { this.el = el; // Options/Settings. this.options = extend( {}, this.options ); extend( this.options, options ); // Backgrounds container. this.bgsWrapper = this.el.querySelector('.backgrounds'); if( !this.bgsWrapper ) { return; } // Background elements. this.bgElems = [].slice.call(this.bgsWrapper.querySelectorAll('.background__element')); // Total background elements. this.bgElemsTotal = this.bgElems.length; if( this.bgElemsTotal <= 1 ) { return; } // Points container. this.pointsWrapper = this.el.querySelector('.points'); if( !this.pointsWrapper || getComputedStyle(this.pointsWrapper, null).display === 'none' ) { return; } // Points tooltips this.tooltips = [].slice.call(this.el.querySelector('.points-tooltips').children); // Points´s content this.pointsContentWrapper = this.el.querySelector('.points-content'); this.contents = [].slice.call(this.pointsContentWrapper.children); // Init.. this._init(); } /** * PointsMap options/settings. */ PointsMap.prototype.options = { // Maximum opacity that the background element of a Point can have when the point is active (mouse gets closer to it). maxOpacityOnActive : 0.3, // The distance from the mouse pointer to a Point where the opacity of the background element is 0. maxDistance : 100, // If viewportFactor is different than -1, then the maxDistance will be overwritten by [point´s parent width / viewportFactor] viewportFactor : 9, // When the mouse is [activeOn]px away from one point, its image gets opacity = point.options.maxOpacity. activeOn : 30 }; /** * Init. */ PointsMap.prototype._init = function() { var self = this, onLoaded = function() { // Create the Points. self._createPoints(); }; // Preload all images. imagesLoaded(this.bgsWrapper, { background: true }, onLoaded); // Init/Bind events. this._initEvents(); }; /** * Init/Bind events. */ PointsMap.prototype._initEvents = function() { var self = this; // Window resize. this._throttleResize = throttle(function() { // Update Document scroll values. docScrolls = {left : document.body.scrollLeft + document.documentElement.scrollLeft, top : document.body.scrollTop + document.documentElement.scrollTop}; }, 100); window.addEventListener('resize', this._throttleResize); // Close content. this._closeContent = function() { var currentPoint = self.points[self.currentPoint]; currentPoint.isActive = false; // Hide Point´s bgEl. currentPoint.bgEl.style.opacity = 0; // Hide content. self.pointsContentWrapper.classList.remove('points-content--open'); self.contents[self.currentPoint].classList.remove('point-content--current'); // Start mousemove event on Points. self._pointsAction('resume'); // Show all points. self._pointsAction('show'); }; this.pointsContentWrapper.addEventListener('click', this._closeContent); // Keyboard navigation events. this.el.addEventListener('keydown', function(ev) { var keyCode = ev.keyCode || ev.which; if( keyCode === 27 ) { self._closeContent(); } }); }; /** * Create the Points. */ PointsMap.prototype._createPoints = function() { this.points = []; var self = this; [].slice.call(this.pointsWrapper.querySelectorAll('.point')).forEach(function(point, pos) { var p = new Point(point, self.bgElems[pos], self.el, { maxOpacity : self.options.maxOpacityOnActive, activeOn : self.options.activeOn, maxDistance : self.options.maxDistance, viewportFactor : self.options.viewportFactor, onActive : function() { // Add class active (scales up the pin and changes the fill color). lunar.addClass(self.points[pos].el, 'point--active'); // Hide all other points. self._pointsAction('hide', pos); // Show tooltip. var tooltip = self.tooltips[pos]; tooltip.classList.add('point-tooltip--current'); // Position tooltip. var rect = self.points[pos].el.getBoundingClientRect(), bounds = self.el.getBoundingClientRect(); tooltip.style.left = rect.left - bounds.left + rect.width/2 + 'px'; tooltip.style.top = rect.top - bounds.top + rect.height + 'px'; }, onInactive : function() { lunar.removeClass(self.points[pos].el, 'point--active'); // Show all points. self._pointsAction('show', pos); // Hide tooltip. self.tooltips[pos].classList.remove('point-tooltip--current'); }, onClick : function() { self.currentPoint = pos; lunar.removeClass(self.points[pos].el, 'point--active'); // Hide the current point (and all other points). self._pointsAction('hide'); // Hide tooltip. self.tooltips[pos].classList.remove('point-tooltip--current'); // Stop mousemove event on Points. self._pointsAction('pause'); // Show Point´s bgEl. self.points[pos].bgEl.style.opacity = 1; // Show content. self.pointsContentWrapper.classList.add('points-content--open'); self.contents[pos].classList.add('point-content--current'); } }); self.points.push(p); }); }; /** * Calls a Point´s fn. Excludes the point with index = excludedPoint. */ PointsMap.prototype._pointsAction = function(action, excludedPoint) { for(var i = 0, len = this.points.length; i < len; ++i) { if( i !== excludedPoint ) { this.points[i][action](); } } }; window.PointsMap = PointsMap; document.documentElement.className = 'js'; })(window); (function() { new PointsMap(document.querySelector('#interactive-2'), { // Maximum opacity that the background element of a Point can have when the point is active (mouse gets closer to it). maxOpacityOnActive : 1, // When the mouse is [activeOn]px away from one point, its image gets opacity = point.options.maxOpacity. activeOn : 90 }); })(); /*! * classie - class helper functions * from bonzo https://github.com/ded/bonzo * * classie.has( elem, 'my-class' ) -> true/false * classie.add( elem, 'my-new-class' ) * classie.remove( elem, 'my-unwanted-class' ) * classie.toggle( elem, 'my-class' ) */ /*jshint browser: true, strict: true, undef: true */ /*global define: false */ ( function( window ) { 'use strict'; // class helper functions from bonzo https://github.com/ded/bonzo function classReg( className ) { return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); } // classList support for class management // altho to be fair, the api sucks because it won't accept multiple classes at once var hasClass, addClass, removeClass; if ( 'classList' in document.documentElement ) { hasClass = function( elem, c ) { return elem.classList.contains( c ); }; addClass = function( elem, c ) { elem.classList.add( c ); }; removeClass = function( elem, c ) { elem.classList.remove( c ); }; } else { hasClass = function( elem, c ) { return classReg( c ).test( elem.className ); }; addClass = function( elem, c ) { if ( !hasClass( elem, c ) ) { elem.className = elem.className + ' ' + c; } }; removeClass = function( elem, c ) { elem.className = elem.className.replace( classReg( c ), ' ' ); }; } function toggleClass( elem, c ) { var fn = hasClass( elem, c ) ? removeClass : addClass; fn( elem, c ); } var classie = { // full names hasClass: hasClass, addClass: addClass, removeClass: removeClass, toggleClass: toggleClass, // short names has: hasClass, add: addClass, remove: removeClass, toggle: toggleClass }; // transport if ( typeof define === 'function') { if(define.amd){ // AMD define( classie ); }else { // browser global window.classie = classie; } } else { // browser global window.classie = classie; } })( window ); /** * sidebarEffects.js v1.0.0 * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2013, Codrops * http://www.codrops.com */ var SidebarMenuEffects = (function() { function hasParentClass( e, classname ) { if(e === document) return false; if( classie.has( e, classname ) ) { return true; } return e.parentNode && hasParentClass( e.parentNode, classname ); } // http://coveroverflow.com/a/11381730/989439 function mobilecheck() { var check = false; (function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera); return check; } function init() { var container = document.getElementById( 'st-container' ), buttons = Array.prototype.slice.call( document.querySelectorAll( '#st-trigger-effects > button' ) ), // event type (if mobile use touch events) eventtype = mobilecheck() ? 'touchstart' : 'click', resetMenu = function() { classie.remove( container, 'st-menu-open' ); }, bodyClickFn = function(evt) { if( !hasParentClass( evt.target, 'st-menu' ) ) { resetMenu(); document.removeEventListener( eventtype, bodyClickFn ); } }; buttons.forEach( function( el, i ) { var effect = el.getAttribute( 'data-effect' ); el.addEventListener( eventtype, function( ev ) { ev.stopPropagation(); ev.preventDefault(); container.className = 'st-container'; // clear classie.add( container, effect ); setTimeout( function() { classie.add( container, 'st-menu-open' ); }, 25 ); document.addEventListener( eventtype, bodyClickFn ); }); } ); } init(); })(); // Generated by CoffeeScript 1.6.2 /* jQuery Waypoints - v2.0.2 Copyright (c) 2011-2013 Caleb Troughton Dual licensed under the MIT license and GPL license. https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt */ (function() { var t = [].indexOf || function(t) { for (var e = 0, n = this.length; e < n; e++) { if (!(!(e in this) || this[e] !== t)) return e } return -1 }, e = [].slice; (function(t, e) { if (!(typeof define !== "function" || !define.amd)) { return define("waypoints", ["jquery"], function(n) { return e(n, t) }) } else { return e(t.jQuery, t) } })(this, function(n, r) { var i, o, l, s, f, u, a, c, h, d, p, y, v, w, g, m; i = n(r); c = t.call(r, "ontouchstart") >= 0; s = { horizontal: {}, vertical: {} }; f = 1; a = {}; u = "waypoints-context-id"; p = "resize.waypoints"; y = "scroll.waypoints"; v = 1; w = "waypoints-waypoint-ids"; g = "waypoint"; m = "waypoints"; o = function() { function t(t) { var e = this; this.$element = t; this.element = t[0]; this.didResize = false; this.didScroll = false; this.id = "context" + f++; this.oldScroll = { x: t.scrollLeft(), y: t.scrollTop() }; this.waypoints = { horizontal: {}, vertical: {} }; t.data(u, this.id); a[this.id] = this; t.bind(y, function() { var t; if (!(e.didScroll || c)) { e.didScroll = true; t = function() { e.doScroll(); return e.didScroll = false }; return r.setTimeout(t, n[m].settings.scrollThrottle) } }); t.bind(p, function() { var t; if (!e.didResize) { e.didResize = true; t = function() { n[m]("refresh"); return e.didResize = false }; return r.setTimeout(t, n[m].settings.resizeThrottle) } }) } t.prototype.doScroll = function() { var t, e = this; t = { horizontal: { newScroll: this.$element.scrollLeft(), oldScroll: this.oldScroll.x, forward: "right", backward: "left" }, vertical: { newScroll: this.$element.scrollTop(), oldScroll: this.oldScroll.y, forward: "down", backward: "up" } }; if (!(!c || !(!t.vertical.oldScroll || !t.vertical.newScroll))) { n[m]("refresh") } n.each(t, function(t, r) { var i, o, l; l = []; o = r.newScroll > r.oldScroll; i = o ? r.forward : r.backward; n.each(e.waypoints[t], function(t, e) { var n, i; if (!(r.oldScroll >= (n = e.offset) || n > r.newScroll)) { return l.push(e) } else if (!(r.newScroll >= (i = e.offset) || i > r.oldScroll)) { return l.push(e) } }); l.sort(function(t, e) { return t.offset - e.offset }); if (!o) { l.reverse() } return n.each(l, function(t, e) { if (e.options.continuous || t === l.length - 1) { return e.trigger([i]) } }) }); return this.oldScroll = { x: t.horizontal.newScroll, y: t.vertical.newScroll } }; t.prototype.refresh = function() { var t, e, r, i = this; r = n.isWindow(this.element); e = this.$element.offset(); this.doScroll(); t = { horizontal: { contextOffset: r ? 0 : e.left, contextScroll: r ? 0 : this.oldScroll.x, contextDimension: this.$element.width(), oldScroll: this.oldScroll.x, forward: "right", backward: "left", offsetProp: "left" }, vertical: { contextOffset: r ? 0 : e.top, contextScroll: r ? 0 : this.oldScroll.y, contextDimension: r ? n[m]("viewportHeight") : this.$element.height(), oldScroll: this.oldScroll.y, forward: "down", backward: "up", offsetProp: "top" } }; return n.each(t, function(t, e) { return n.each(i.waypoints[t], function(t, r) { var i, o, l, s, f; i = r.options.offset; l = r.offset; o = n.isWindow(r.element) ? 0 : r.$element.offset()[e.offsetProp]; if (n.isFunction(i)) { i = i.apply(r.element) } else if (typeof i === "string") { i = parseFloat(i); if (r.options.offset.indexOf("%") > -1) { i = Math.ceil(e.contextDimension * i / 100) } } r.offset = o - e.contextOffset + e.contextScroll - i; if (!(!r.options.onlyOnScroll || l == null) || !r.enabled) { return } if (!(l === null || l >= (s = e.oldScroll) || s > r.offset)) { return r.trigger([e.backward]) } else if (!(l === null || l <= (f = e.oldScroll) || f < r.offset)) { return r.trigger([e.forward]) } else if (!(l !== null || e.oldScroll < r.offset)) { return r.trigger([e.forward]) } }) }) }; t.prototype.checkEmpty = function() { if (!(!n.isEmptyObject(this.waypoints.horizontal) || !n.isEmptyObject(this.waypoints.vertical))) { this.$element.unbind([p, y].join(" ")); return delete a[this.id] } }; return t }(); l = function() { function t(t, e, r) { var i, o; r = n.extend({}, n.fn[g].defaults, r); if (r.offset === "bottom-in-view") { r.offset = function() { var t; t = n[m]("viewportHeight"); if (!n.isWindow(e.element)) { t = e.$element.height() } return t - n(this).outerHeight() } } this.$element = t; this.element = t[0]; this.axis = r.horizontal ? "horizontal" : "vertical"; this.callback = r.handler; this.context = e; this.enabled = r.enabled; this.id = "waypoints" + v++; this.offset = null; this.options = r; e.waypoints[this.axis][this.id] = this; s[this.axis][this.id] = this; i = (o = t.data(w)) != null ? o : []; i.push(this.id); t.data(w, i) } t.prototype.trigger = function(t) { if (!this.enabled) { return } if (this.callback != null) { this.callback.apply(this.element, t) } if (this.options.triggerOnce) { return this.destroy() } }; t.prototype.disable = function() { return this.enabled = false }; t.prototype.enable = function() { this.context.refresh(); return this.enabled = true }; t.prototype.destroy = function() { delete s[this.axis][this.id]; delete this.context.waypoints[this.axis][this.id]; return this.context.checkEmpty() }; t.getWaypointsByElement = function(t) { var e, r; r = n(t).data(w); if (!r) { return [] } e = n.extend({}, s.horizontal, s.vertical); return n.map(r, function(t) { return e[t] }) }; return t }(); d = { init: function(t, e) { var r; if (e == null) { e = {} } if ((r = e.handler) == null) { e.handler = t } this.each(function() { var t, r, i, s; t = n(this); i = (s = e.context) != null ? s : n.fn[g].defaults.context; if (!n.isWindow(i)) { i = t.closest(i) } i = n(i); r = a[i.data(u)]; if (!r) { r = new o(i) } return new l(t, r, e) }); n[m]("refresh"); return this }, disable: function() { return d._invoke(this, "disable") }, enable: function() { return d._invoke(this, "enable") }, destroy: function() { return d._invoke(this, "destroy") }, prev: function(t, e) { return d._traverse.call(this, t, e, function(t, e, n) { if (e > 0) { return t.push(n[e - 1]) } }) }, next: function(t, e) { return d._traverse.call(this, t, e, function(t, e, n) { if (e < n.length - 1) { return t.push(n[e + 1]) } }) }, _traverse: function(t, e, i) { var o, l; if (t == null) { t = "vertical" } if (e == null) { e = r } l = h.aggregate(e); o = []; this.each(function() { var e; e = n.inArray(this, l[t]); return i(o, e, l[t]) }); return this.pushStack(o) }, _invoke: function(t, e) { t.each(function() { var t; t = l.getWaypointsByElement(this); return n.each(t, function(t, n) { n[e](); return true }) }); return this } }; n.fn[g] = function() { var t, r; r = arguments[0], t = 2 <= arguments.length ? e.call(arguments, 1) : []; if (d[r]) { return d[r].apply(this, t) } else if (n.isFunction(r)) { return d.init.apply(this, arguments) } else if (n.isPlainObject(r)) { return d.init.apply(this, [null, r]) } else if (!r) { return n.error("jQuery Waypoints needs a callback function or handler option.") } else { return n.error("The " + r + " method does not exist in jQuery Waypoints.") } }; n.fn[g].defaults = { context: r, continuous: true, enabled: true, horizontal: false, offset: 0, triggerOnce: false }; h = { refresh: function() { return n.each(a, function(t, e) { return e.refresh() }) }, viewportHeight: function() { var t; return (t = r.innerHeight) != null ? t : i.height() }, aggregate: function(t) { var e, r, i; e = s; if (t) { e = (i = a[n(t).data(u)]) != null ? i.waypoints : void 0 } if (!e) { return [] } r = { horizontal: [], vertical: [] }; n.each(r, function(t, i) { n.each(e[t], function(t, e) { return i.push(e) }); i.sort(function(t, e) { return t.offset - e.offset }); r[t] = n.map(i, function(t) { return t.element }); return r[t] = n.unique(r[t]) }); return r }, above: function(t) { if (t == null) { t = r } return h._filter(t, "vertical", function(t, e) { return e.offset <= t.oldScroll.y }) }, below: function(t) { if (t == null) { t = r } return h._filter(t, "vertical", function(t, e) { return e.offset > t.oldScroll.y }) }, left: function(t) { if (t == null) { t = r } return h._filter(t, "horizontal", function(t, e) { return e.offset <= t.oldScroll.x }) }, right: function(t) { if (t == null) { t = r } return h._filter(t, "horizontal", function(t, e) { return e.offset > t.oldScroll.x }) }, enable: function() { return h._invoke("enable") }, disable: function() { return h._invoke("disable") }, destroy: function() { return h._invoke("destroy") }, extendFn: function(t, e) { return d[t] = e }, _invoke: function(t) { var e; e = n.extend({}, s.vertical, s.horizontal); return n.each(e, function(e, n) { n[t](); return true }) }, _filter: function(t, e, r) { var i, o; i = a[n(t).data(u)]; if (!i) { return [] } o = []; n.each(i.waypoints[e], function(t, e) { if (r(i, e)) { return o.push(e) } }); o.sort(function(t, e) { return t.offset - e.offset }); return n.map(o, function(t) { return t.element }) } }; n[m] = function() { var t, n; n = arguments[0], t = 2 <= arguments.length ? e.call(arguments, 1) : []; if (h[n]) { return h[n].apply(null, t) } else { return h.aggregate.call(null, n) } }; n[m].settings = { resizeThrottle: 100, scrollThrottle: 30 }; return i.load(function() { return n[m]("refresh") }) }) }).call(this); function growDiv(param) { var id = param; var growDiv = document.getElementById('grow-'+id); if (growDiv.clientHeight) { growDiv.style.height = 0; } else { var wrapper = document.querySelector('.measuringWrapper-'+id); growDiv.style.height = wrapper.clientHeight + "px"; } if(document.getElementById("menu-item-"+id).className.indexOf("focus") >= 0){ document.getElementById("menu-item-"+id).className = document.getElementById("menu-item-"+id).className.replace("focus", ""); }else{ document.getElementById("menu-item-"+id).className += " focus"; } event.preventDefault(); } var $head = $( '#ha-header' ); $( '.ha-waypoint' ).each( function(i) { var $el = $( this ), animClassDown = $el.data( 'animateDown' ), animClassUp = $el.data( 'animateUp' ); $el.waypoint( function( direction ) { if( !(direction !== 'down' || !animClassDown) ) { $head.attr('class', 'ha-header ' + animClassDown); } else if( !(direction !== 'up' || !animClassUp) ){ $head.attr('class', 'ha-header ' + animClassUp); } }, { offset: '100%' } ); } ); (function($) { var setCss = function() { if($(window).width() <= 550) { $('#nus_logo').css('left', "15%"); $('#sci_logo').css('display', "none"); $('#sps_logo').css('display', "none"); $('#igem_logo').css('display', "none"); }else{ $('#nus_logo').css('left', "0%"); $('#sci_logo').css('display', "block"); $('#sps_logo').css('display', "block"); $('#igem_logo').css('display', "block"); } }; $(document).ready(function() { setCss(); $(window).resize(setCss); }); })(jQuery);