Template:Montgomery Cougars NJUSA/Common JS
From 2014hs.igem.org
Casey.chow (Talk | contribs) |
Casey.chow (Talk | contribs) |
||
Line 31: | Line 31: | ||
}); | }); | ||
- | + | $('#jqtoc > ul').pin({ | |
- | + | containerSelector: '#jqtoc' | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
}); | }); | ||
} | } | ||
Line 77: | Line 70: | ||
/* http://silvestreh.github.io/onScreen/ */ | /* http://silvestreh.github.io/onScreen/ */ | ||
(function($){$.fn.onScreen=function(options){var params=$.extend({container:window,direction:'vertical',toggleClass:null,doIn:null,doOut:null,tolerance:0,throttle:null,lazyAttr:null,lazyPlaceholder:'data:image/gif;base64,R0lGODlhEAAFAIAAAP///////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQAAACwAAAAAEAAFAAACCIyPqcvtD00BACH5BAkJAAIALAAAAAAQAAUAgfT29Pz6/P///wAAAAIQTGCiywKPmjxUNhjtMlWrAgAh+QQJCQAFACwAAAAAEAAFAIK8urzc2tzEwsS8vrzc3tz///8AAAAAAAADFEiyUf6wCEBHvLPemIHdTzCMDegkACH5BAkJAAYALAAAAAAQAAUAgoSChLS2tIyKjLy+vIyOjMTCxP///wAAAAMUWCQ09jAaAiqQmFosdeXRUAkBCCUAIfkECQkACAAsAAAAABAABQCDvLq83N7c3Nrc9Pb0xMLE/P78vL68/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCEwkCnKGbegvQn4RjGMx8F1HxBi5Il4oEiap2DcVYlpZwQAIfkECQkACAAsAAAAABAABQCDvLq85OLkxMLE9Pb0vL685ObkxMbE/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCDwnCGHEcIMxPn4VAGMQNBx0zQEZHkiYNiap5RaBKG9EQAh+QQJCQAJACwAAAAAEAAFAIOEgoTMysyMjozs6uyUlpSMiozMzsyUkpTs7uz///8AAAAAAAAAAAAAAAAAAAAAAAAEGTBJiYgoBM09DfhAwHEeKI4dGKLTIHzCwEUAIfkECQkACAAsAAAAABAABQCDvLq85OLkxMLE9Pb0vL685ObkxMbE/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCAQSTmMEGaco8+UBSACwWBqHxKOJYd+q1iaXFoRRMbtEQAh+QQJCQAIACwAAAAAEAAFAIO8urzc3tzc2tz09vTEwsT8/vy8vrz8+vz///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAEIhBJWc6wJZAtJh3gcRBAaXiIZV2kiRbgNZbA6VXiUAhGL0QAIfkECQkABgAsAAAAABAABQCChIKEtLa0jIqMvL68jI6MxMLE////AAAAAxRoumxFgoxGCbiANos145e3DJcQJAAh+QQJCQAFACwAAAAAEAAFAIK8urzc2tzEwsS8vrzc3tz///8AAAAAAAADFFi6XCQwtCmAHbPVm9kGWKcEQxkkACH5BAkJAAIALAAAAAAQAAUAgfT29Pz6/P///wAAAAIRlI8SAZsPYnuJMUCRnNksWwAAOw==',debug:false},options);return this.each(function(){var isOnScreen=false;var scrollTop;var scrollLeft;var $el=$(this);var $container;var containerHeight;var containerWidth;var containerBottom;var containerRight;var elHeight;var elWidth;var elTop;var elLeft;var containerIsWindow=$.isWindow(params.container);function verticalIn(){if(containerIsWindow){return elTop<containerBottom-params.tolerance&&scrollTop<(elTop+elHeight)-params.tolerance;}else{return elTop<containerHeight-params.tolerance&&elTop>(-elHeight)+params.tolerance;}}function verticalOut(){if(containerIsWindow){return elTop+(elHeight-params.tolerance)<scrollTop||elTop>containerBottom-params.tolerance;}else{return elTop>containerHeight-params.tolerance||-elHeight+params.tolerance>elTop;}}function horizontalIn(){if(containerIsWindow){return elLeft<containerRight-params.tolerance&&scrollLeft<(elLeft+elWidth)-params.tolerance;}else{return elLeft<containerWidth-params.tolerance&&elLeft>(-elWidth)+params.tolerance;}}function horizontalOut(){if(containerIsWindow){return elLeft+(elWidth-params.tolerance)<scrollLeft||elLeft>containerRight-params.tolerance;}else{return elLeft>containerWidth-params.tolerance||-elWidth+params.tolerance>elLeft;}}function directionIn(){if(isOnScreen){return false;}if(params.direction==='horizontal'){return horizontalIn();}else{return verticalIn();}}function directionOut(){if(!isOnScreen){return false;}if(params.direction==='horizontal'){return horizontalOut();}else{return verticalOut();}}function throttle(fn,timeout,ctx){var timer,args,needInvoke;return function(){args=arguments;needInvoke=true;ctx=ctx||this;if(!timer){(function(){if(needInvoke){fn.apply(ctx,args);needInvoke=false;timer=setTimeout(arguments.callee,timeout);}else{timer=null;}})();}};}var checkPos=function(){if(!containerIsWindow&&$(params.container).css('position')==='static'){$(params.container).css('position','relative');}$container=$(params.container);containerHeight=$container.height();containerWidth=$container.width();containerBottom=$container.scrollTop()+containerHeight;containerRight=$container.scrollLeft()+containerWidth;elHeight=$el.outerHeight(true);elWidth=$el.outerWidth(true);if(containerIsWindow){var offset=$el.offset();elTop=offset.top;elLeft=offset.left;}else{var position=$el.position();elTop=position.top;elLeft=position.left;}scrollTop=$container.scrollTop();scrollLeft=$container.scrollLeft();if(params.debug){console.log('Container: '+params.container+'\n'+'Width: '+containerHeight+'\n'+'Height: '+containerWidth+'\n'+'Bottom: '+containerBottom+'\n'+'Right: '+containerRight);console.log('Matched element: '+($el.attr('class')!==undefined?$el.prop('tagName').toLowerCase()+'.'+$el.attr('class'):$el.prop('tagName').toLowerCase())+'\n'+'Left: '+elLeft+'\n'+'Top: '+elTop+'\n'+'Width: '+elWidth+'\n'+'Height: '+elHeight);}if(directionIn()){if(params.toggleClass){$el.addClass(params.toggleClass);}if($.isFunction(params.doIn)){params.doIn.call($el[0]);}if(params.lazyAttr&&$el.prop('tagName')==='IMG'){var lazyImg=$el.attr(params.lazyAttr);$el.css({background:'url('+params.lazyPlaceholder+') 50% 50% no-repeat',minHeight:'5px',minWidth:'16px'});$el.prop('src',lazyImg);}isOnScreen=true;}else if(directionOut()){if(params.toggleClass){$el.removeClass(params.toggleClass);}if($.isFunction(params.doOut)){params.doOut.call($el[0]);}isOnScreen=false;}};if(window.location.hash){throttle(checkPos,50);}else{checkPos();}if(params.throttle){checkPos=throttle(checkPos,params.throttle);}$(params.container).on('scroll resize',checkPos);if(!containerIsWindow){$(window).on('resize',checkPos);}if(typeof module==='object'&&module&&typeof module.exports==='object'){module.exports=jQuery;}else{if(typeof define==='function'&&define.amd){define('jquery-onscreen',[],function(){return jQuery;});}}});};})(jQuery); | (function($){$.fn.onScreen=function(options){var params=$.extend({container:window,direction:'vertical',toggleClass:null,doIn:null,doOut:null,tolerance:0,throttle:null,lazyAttr:null,lazyPlaceholder:'data:image/gif;base64,R0lGODlhEAAFAIAAAP///////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQAAACwAAAAAEAAFAAACCIyPqcvtD00BACH5BAkJAAIALAAAAAAQAAUAgfT29Pz6/P///wAAAAIQTGCiywKPmjxUNhjtMlWrAgAh+QQJCQAFACwAAAAAEAAFAIK8urzc2tzEwsS8vrzc3tz///8AAAAAAAADFEiyUf6wCEBHvLPemIHdTzCMDegkACH5BAkJAAYALAAAAAAQAAUAgoSChLS2tIyKjLy+vIyOjMTCxP///wAAAAMUWCQ09jAaAiqQmFosdeXRUAkBCCUAIfkECQkACAAsAAAAABAABQCDvLq83N7c3Nrc9Pb0xMLE/P78vL68/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCEwkCnKGbegvQn4RjGMx8F1HxBi5Il4oEiap2DcVYlpZwQAIfkECQkACAAsAAAAABAABQCDvLq85OLkxMLE9Pb0vL685ObkxMbE/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCDwnCGHEcIMxPn4VAGMQNBx0zQEZHkiYNiap5RaBKG9EQAh+QQJCQAJACwAAAAAEAAFAIOEgoTMysyMjozs6uyUlpSMiozMzsyUkpTs7uz///8AAAAAAAAAAAAAAAAAAAAAAAAEGTBJiYgoBM09DfhAwHEeKI4dGKLTIHzCwEUAIfkECQkACAAsAAAAABAABQCDvLq85OLkxMLE9Pb0vL685ObkxMbE/Pr8////AAAAAAAAAAAAAAAAAAAAAAAAAAAABCAQSTmMEGaco8+UBSACwWBqHxKOJYd+q1iaXFoRRMbtEQAh+QQJCQAIACwAAAAAEAAFAIO8urzc3tzc2tz09vTEwsT8/vy8vrz8+vz///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAEIhBJWc6wJZAtJh3gcRBAaXiIZV2kiRbgNZbA6VXiUAhGL0QAIfkECQkABgAsAAAAABAABQCChIKEtLa0jIqMvL68jI6MxMLE////AAAAAxRoumxFgoxGCbiANos145e3DJcQJAAh+QQJCQAFACwAAAAAEAAFAIK8urzc2tzEwsS8vrzc3tz///8AAAAAAAADFFi6XCQwtCmAHbPVm9kGWKcEQxkkACH5BAkJAAIALAAAAAAQAAUAgfT29Pz6/P///wAAAAIRlI8SAZsPYnuJMUCRnNksWwAAOw==',debug:false},options);return this.each(function(){var isOnScreen=false;var scrollTop;var scrollLeft;var $el=$(this);var $container;var containerHeight;var containerWidth;var containerBottom;var containerRight;var elHeight;var elWidth;var elTop;var elLeft;var containerIsWindow=$.isWindow(params.container);function verticalIn(){if(containerIsWindow){return elTop<containerBottom-params.tolerance&&scrollTop<(elTop+elHeight)-params.tolerance;}else{return elTop<containerHeight-params.tolerance&&elTop>(-elHeight)+params.tolerance;}}function verticalOut(){if(containerIsWindow){return elTop+(elHeight-params.tolerance)<scrollTop||elTop>containerBottom-params.tolerance;}else{return elTop>containerHeight-params.tolerance||-elHeight+params.tolerance>elTop;}}function horizontalIn(){if(containerIsWindow){return elLeft<containerRight-params.tolerance&&scrollLeft<(elLeft+elWidth)-params.tolerance;}else{return elLeft<containerWidth-params.tolerance&&elLeft>(-elWidth)+params.tolerance;}}function horizontalOut(){if(containerIsWindow){return elLeft+(elWidth-params.tolerance)<scrollLeft||elLeft>containerRight-params.tolerance;}else{return elLeft>containerWidth-params.tolerance||-elWidth+params.tolerance>elLeft;}}function directionIn(){if(isOnScreen){return false;}if(params.direction==='horizontal'){return horizontalIn();}else{return verticalIn();}}function directionOut(){if(!isOnScreen){return false;}if(params.direction==='horizontal'){return horizontalOut();}else{return verticalOut();}}function throttle(fn,timeout,ctx){var timer,args,needInvoke;return function(){args=arguments;needInvoke=true;ctx=ctx||this;if(!timer){(function(){if(needInvoke){fn.apply(ctx,args);needInvoke=false;timer=setTimeout(arguments.callee,timeout);}else{timer=null;}})();}};}var checkPos=function(){if(!containerIsWindow&&$(params.container).css('position')==='static'){$(params.container).css('position','relative');}$container=$(params.container);containerHeight=$container.height();containerWidth=$container.width();containerBottom=$container.scrollTop()+containerHeight;containerRight=$container.scrollLeft()+containerWidth;elHeight=$el.outerHeight(true);elWidth=$el.outerWidth(true);if(containerIsWindow){var offset=$el.offset();elTop=offset.top;elLeft=offset.left;}else{var position=$el.position();elTop=position.top;elLeft=position.left;}scrollTop=$container.scrollTop();scrollLeft=$container.scrollLeft();if(params.debug){console.log('Container: '+params.container+'\n'+'Width: '+containerHeight+'\n'+'Height: '+containerWidth+'\n'+'Bottom: '+containerBottom+'\n'+'Right: '+containerRight);console.log('Matched element: '+($el.attr('class')!==undefined?$el.prop('tagName').toLowerCase()+'.'+$el.attr('class'):$el.prop('tagName').toLowerCase())+'\n'+'Left: '+elLeft+'\n'+'Top: '+elTop+'\n'+'Width: '+elWidth+'\n'+'Height: '+elHeight);}if(directionIn()){if(params.toggleClass){$el.addClass(params.toggleClass);}if($.isFunction(params.doIn)){params.doIn.call($el[0]);}if(params.lazyAttr&&$el.prop('tagName')==='IMG'){var lazyImg=$el.attr(params.lazyAttr);$el.css({background:'url('+params.lazyPlaceholder+') 50% 50% no-repeat',minHeight:'5px',minWidth:'16px'});$el.prop('src',lazyImg);}isOnScreen=true;}else if(directionOut()){if(params.toggleClass){$el.removeClass(params.toggleClass);}if($.isFunction(params.doOut)){params.doOut.call($el[0]);}isOnScreen=false;}};if(window.location.hash){throttle(checkPos,50);}else{checkPos();}if(params.throttle){checkPos=throttle(checkPos,params.throttle);}$(params.container).on('scroll resize',checkPos);if(!containerIsWindow){$(window).on('resize',checkPos);}if(typeof module==='object'&&module&&typeof module.exports==='object'){module.exports=jQuery;}else{if(typeof define==='function'&&define.amd){define('jquery-onscreen',[],function(){return jQuery;});}}});};})(jQuery); | ||
+ | |||
+ | /* http://webpop.github.io/jquery.pin/ */ | ||
+ | (function(e){"use strict";e.fn.pin=function(t){var n=0,r=[],i=false,s=e(window);t=t||{};var o=function(){for(var n=0,o=r.length;n<o;n++){var u=r[n];if(t.minWidth&&s.width()<=t.minWidth){if(u.parent().is(".pin-wrapper")){u.unwrap()}u.css({width:"",left:"",top:"",position:""});if(t.activeClass){u.removeClass(t.activeClass)}i=true;continue}else{i=false}var a=t.containerSelector?u.closest(t.containerSelector):e(document.body);var f=u.offset();var l=a.offset();var c=u.offsetParent().offset();if(!u.parent().is(".pin-wrapper")){u.wrap("<div class='pin-wrapper'>")}var h=e.extend({top:0,bottom:0},t.padding||{});u.data("pin",{pad:h,from:(t.containerSelector?l.top:f.top)-h.top,to:l.top+a.height()-u.outerHeight()-h.bottom,end:l.top+a.height(),parentTop:c.top});u.css({width:u.outerWidth()});u.parent().css("height",u.outerHeight())}};var u=function(){if(i){return}n=s.scrollTop();var o=[];for(var u=0,a=r.length;u<a;u++){var f=e(r[u]),l=f.data("pin");if(!l){continue}o.push(f);var c=l.from,h=l.to;if(c+f.outerHeight()>l.end){f.css("position","");continue}if(c<n&&h>n){!(f.css("position")=="fixed")&&f.css({left:f.offset().left,top:l.pad.top}).css("position","fixed");if(t.activeClass){f.addClass(t.activeClass)}}else if(n>=h){f.css({left:"",top:h-l.parentTop+l.pad.top}).css("position","absolute");if(t.activeClass){f.addClass(t.activeClass)}}else{f.css({position:"",top:"",left:""});if(t.activeClass){f.removeClass(t.activeClass)}}}r=o};var a=function(){o();u()};this.each(function(){var t=e(this),n=e(this).data("pin")||{};if(n&&n.update){return}r.push(t);e("img",this).one("load",o);n.update=a;e(this).data("pin",n)});s.scroll(u);s.resize(function(){o()});o();s.load(a);return this}})(jQuery) |
Revision as of 01:26, 19 June 2014
/* Edit this file: https://2014hs.igem.org/wiki/index.php?title=Template:Montgomery_Cougars_NJUSA/Common_CSS&action=edit */
/* https://2011.igem.org/Team:DTU-Denmark/How_to_customize_an_iGEM_wiki#Remove_all_empty_.3Cp.3E.3C.2Fp.3E_tags */ $(document).ready(function() {
$("p").filter( function() { return $.trim($(this).html()) == ; }).remove(); $("br:only-child").remove();
if($('#slider').length != 0) { $('.generic-image').remove(); $('#slider').unslider({ delay: 3250, fluid: true }); }
if($('#toc').length != 0) { var visible = false;
$('#toc').remove(); $('body').addClass('with-toc');var $jqtoc = $('')
.prependTo('#main-wrapper') .toc({ container: '#inner-content', headerText: function(i, heading, $heading) { // remove [edit] link return $heading.text().replace(/\[edit\]/g, ); } });
$('#jqtoc > ul').pin({ containerSelector: '#jqtoc' }); }
});
/**
* Unslider by @idiot */(function(e,t){if(!e)return t;var n=function(){this.el=t;this.items=t;this.sizes=[];this.max=[0,0];this.current=0;this.interval=t;this.opts={speed:500,delay:3e3,complete:t,keys:!t,dots:t,fluid:t};var n=this;this.init=function(t,n){this.el=t;this.ul=t.children("ul");this.max=[t.outerWidth(),t.outerHeight()];this.items=this.ul.children("li").each(this.calculate);this.opts=e.extend(this.opts,n);this.setup();return this};this.calculate=function(t){var r=e(this),i=r.outerWidth(),s=r.outerHeight();n.sizes[t]=[i,s];if(i>n.max[0])n.max[0]=i;if(s>n.max[1])n.max[1]=s};this.setup=function(){this.el.css({overflow:"hidden",width:n.max[0],height:this.items.first().outerHeight()});this.ul.css({width:this.items.length*100+"%",position:"relative"});this.items.css("width",100/this.items.length+"%");if(this.opts.delay!==t){this.start();this.el.hover(this.stop,this.start)}this.opts.keys&&e(document).keydown(this.keys);this.opts.dots&&this.dots();if(this.opts.fluid){var r=function(){n.el.css("width",Math.min(Math.round(n.el.outerWidth()/n.el.parent().outerWidth()*100),100)+"%")};r();e(window).resize(r)}if(this.opts.arrows){this.el.parent().append('
â†â†’
').find(".arrows span").click(function(){e.isFunction(n[this.className])&&n[this.className]()})}if(e.event.swipe){this.el.on("swipeleft",n.prev).on("swiperight",n.next)}};this.move=function(t,r){if(!this.items.eq(t).length)t=0;if(t<0)t=this.items.length-1;var i=this.items.eq(t);var s={height:i.outerHeight()};var o=r?5:this.opts.speed;if(!this.ul.is(":animated")){n.el.find(".dot:eq("+t+")").addClass("active").siblings().removeClass("active");this.el.animate(s,o)&&this.ul.animate(e.extend({left:"-"+t+"00%"},s),o,function(i){n.current=t;e.isFunction(n.opts.complete)&&!r&&n.opts.complete(n.el)})}};this.start=function(){n.interval=setInterval(function(){n.move(n.current+1)},n.opts.delay)};this.stop=function(){n.interval=clearInterval(n.interval);return n};this.keys=function(t){var r=t.which;var i={37:n.prev,39:n.next,27:n.stop};if(e.isFunction(i[r])){i[r]()}};this.next=function(){return n.stop().move(n.current+1)};this.prev=function(){return n.stop().move(n.current-1)};this.dots=function(){var t='- ';e.each(this.items,function(e){t+='<li class="dot'+(e<1?" active":"")+'">'+(e+1)+""});t+="
// jQuery.event.swipe // 0.5 // Stephen Band
// Dependencies // jQuery.event.move 1.2
// One of swipeleft, swiperight, swipeup or swipedown is triggered on // moveend, when the move has covered a threshold ratio of the dimension // of the target node, or has gone really fast. Threshold and velocity // sensitivity changed with: // // jQuery.event.special.swipe.settings.threshold // jQuery.event.special.swipe.settings.sensitivity (function(module){if(typeof define==='function'&&define.amd){define(['jquery'],module);}else{module(jQuery);}})(function(jQuery,undefined){var add=jQuery.event.add,remove=jQuery.event.remove,trigger=function(node,type,data){jQuery.event.trigger(type,data,node);},settings={threshold:0.4,sensitivity:6};function moveend(e){var w,h,event;w=e.currentTarget.offsetWidth;h=e.currentTarget.offsetHeight;event={distX:e.distX,distY:e.distY,velocityX:e.velocityX,velocityY:e.velocityY,finger:e.finger};if(e.distX>e.distY){if(e.distX>-e.distY){if(e.distX/w>settings.threshold||e.velocityX*e.distX/w*settings.sensitivity>1){event.type='swiperight';trigger(e.currentTarget,event);}} else{if(-e.distY/h>settings.threshold||e.velocityY*e.distY/w*settings.sensitivity>1){event.type='swipeup';trigger(e.currentTarget,event);}}} else{if(e.distX>-e.distY){if(e.distY/h>settings.threshold||e.velocityY*e.distY/w*settings.sensitivity>1){event.type='swipedown';trigger(e.currentTarget,event);}} else{if(-e.distX/w>settings.threshold||e.velocityX*e.distX/w*settings.sensitivity>1){event.type='swipeleft';trigger(e.currentTarget,event);}}}} function getData(node){var data=jQuery.data(node,'event_swipe');if(!data){data={count:0};jQuery.data(node,'event_swipe',data);} return data;} jQuery.event.special.swipe=jQuery.event.special.swipeleft=jQuery.event.special.swiperight=jQuery.event.special.swipeup=jQuery.event.special.swipedown={setup:function(data,namespaces,eventHandle){var data=getData(this);if(data.count++>0){return;} add(this,'moveend',moveend);return true;},teardown:function(){var data=getData(this);if(--data.count>0){return;} remove(this,'moveend',moveend);return true;},settings:settings};});
/*!
* toc - jQuery Table of Contents Plugin * v0.3.2 * http://projects.jga.me/toc/ * copyright Greg Allen 2014 * MIT License
- /