Template:Montgomery Cougars NJUSA/Common JS

From 2014hs.igem.org

(Difference between revisions)
 
(23 intermediate revisions not shown)
Line 15: Line 15:
         });
         });
     }
     }
 +
   
 +
    $('#nav ul ul').parent().children('a').addClass('is-parent');
     if($('#toc').length != 0) {
     if($('#toc').length != 0) {
-
        var visible = false;
 
-
 
         $('#toc').remove();
         $('#toc').remove();
         $('body').addClass('with-toc');
         $('body').addClass('with-toc');
         var $jqtoc = $('<div id="jqtoc"></div>')
         var $jqtoc = $('<div id="jqtoc"></div>')
-
         .prependTo('#main-wrapper')
+
         .prependTo('#main')
         .toc({
         .toc({
             container: '#inner-content',
             container: '#inner-content',
             headerText: function(i, heading, $heading) { // remove [edit] link
             headerText: function(i, heading, $heading) { // remove [edit] link
                 return $heading.text().replace(/\[edit\]/g, '');  
                 return $heading.text().replace(/\[edit\]/g, '');  
-
             }
+
             },
 +
            selectors: 'h1, h2'
         });
         });
-
         if (!window.location.hash) {
+
         $('#jqtoc > ul').stickySidebar({
-
            $jqtoc.children('ul').fadeOut(0);
+
            breakingPoint1: 401,
-
         }
+
            contentSelector: '#inner-content',
 +
            footerThreshold: 150,
 +
            sidebarTopMargin: 0
 +
         });
-
 
+
         if($(window).height() < $('#jqtoc > ul').height()) {
-
         $('#header').onScreen({
+
             $('<a id="scrolltop" href="#">▲</a>')
-
             doOut: function() {
+
                .appendTo('#main')
-
                 $jqtoc.children('ul').fadeIn();
+
                .fadeOut()
-
            }
+
                .click(function()  {
-
        });
+
                    $('html, body').animate({scrollTop: 0});
 +
                    return false;
 +
                });
 +
            $(window).scroll(function() {
 +
                 if($(window).scrollTop() > 500) {
 +
                    $('#scrolltop').fadeIn(200);
 +
                } else {
 +
                    $('#scrolltop').fadeOut(200);
 +
                }
 +
            });
 +
        }
     }
     }
Line 75: Line 89:
!function(a){a.fn.smoothScroller=function(b){b=a.extend({},a.fn.smoothScroller.defaults,b);var c=a(this);return a(b.scrollEl).animate({scrollTop:c.offset().top-a(b.scrollEl).offset().top-b.offset},b.speed,b.ease,function(){var a=c.attr("id");a.length&&(history.pushState?history.pushState(null,null,"#"+a):document.location.hash=a),c.trigger("smoothScrollerComplete")}),this},a.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},a("body").on("click","[data-smoothscroller]",function(b){b.preventDefault();var c=a(this).attr("href");0===c.indexOf("#")&&a(c).smoothScroller()})}(jQuery),function(a){var b={};a.fn.toc=function(b){var c,d=this,e=a.extend({},jQuery.fn.toc.defaults,b),f=a(e.container),g=a(e.selectors,f),h=[],i=e.activeClass,j=function(b,c){if(e.smoothScrolling&&"function"==typeof e.smoothScrolling){b.preventDefault();var f=a(b.target).attr("href");e.smoothScrolling(f,e,c)}a("li",d).removeClass(i),a(b.target).parent().addClass(i)},k=function(){c&&clearTimeout(c),c=setTimeout(function(){for(var b,c=a(window).scrollTop(),f=Number.MAX_VALUE,g=0,j=0,k=h.length;k>j;j++){var l=Math.abs(h[j]-c);f>l&&(g=j,f=l)}a("li",d).removeClass(i),b=a("li:eq("+g+")",d).addClass(i),e.onHighlight(b)},50)};return e.highlightOnScroll&&(a(window).bind("scroll",k),k()),this.each(function(){var b=a(this),c=a(e.listType);g.each(function(d,f){var g=a(f);h.push(g.offset().top-e.highlightOffset);var i=e.anchorName(d,f,e.prefix);if(f.id!==i){a("<span/>").attr("id",i).insertBefore(g)}var l=a("<a/>").text(e.headerText(d,f,g)).attr("href","#"+i).bind("click",function(c){a(window).unbind("scroll",k),j(c,function(){a(window).bind("scroll",k)}),b.trigger("selected",a(this).attr("href"))}),m=a("<li/>").addClass(e.itemClass(d,f,g,e.prefix)).append(l);c.append(m)}),b.html(c)})},jQuery.fn.toc.defaults={container:"body",listType:"<ul/>",selectors:"h1,h2,h3",smoothScrolling:function(b,c,d){a(b).smoothScroller({offset:c.scrollToOffset}).on("smoothScrollerComplete",function(){d()})},scrollToOffset:0,prefix:"toc",activeClass:"toc-active",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(c,d,e){if(d.id.length)return d.id;var f=a(d).text().replace(/[^a-z0-9]/gi," ").replace(/\s+/g,"-").toLowerCase();if(b[f]){for(var g=2;b[f+g];)g++;f=f+"-"+g}return b[f]=!0,e+"-"+f},headerText:function(a,b,c){return c.text()},itemClass:function(a,b,c,d){return d+"-"+c[0].tagName.toLowerCase()}}}(jQuery);
!function(a){a.fn.smoothScroller=function(b){b=a.extend({},a.fn.smoothScroller.defaults,b);var c=a(this);return a(b.scrollEl).animate({scrollTop:c.offset().top-a(b.scrollEl).offset().top-b.offset},b.speed,b.ease,function(){var a=c.attr("id");a.length&&(history.pushState?history.pushState(null,null,"#"+a):document.location.hash=a),c.trigger("smoothScrollerComplete")}),this},a.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},a("body").on("click","[data-smoothscroller]",function(b){b.preventDefault();var c=a(this).attr("href");0===c.indexOf("#")&&a(c).smoothScroller()})}(jQuery),function(a){var b={};a.fn.toc=function(b){var c,d=this,e=a.extend({},jQuery.fn.toc.defaults,b),f=a(e.container),g=a(e.selectors,f),h=[],i=e.activeClass,j=function(b,c){if(e.smoothScrolling&&"function"==typeof e.smoothScrolling){b.preventDefault();var f=a(b.target).attr("href");e.smoothScrolling(f,e,c)}a("li",d).removeClass(i),a(b.target).parent().addClass(i)},k=function(){c&&clearTimeout(c),c=setTimeout(function(){for(var b,c=a(window).scrollTop(),f=Number.MAX_VALUE,g=0,j=0,k=h.length;k>j;j++){var l=Math.abs(h[j]-c);f>l&&(g=j,f=l)}a("li",d).removeClass(i),b=a("li:eq("+g+")",d).addClass(i),e.onHighlight(b)},50)};return e.highlightOnScroll&&(a(window).bind("scroll",k),k()),this.each(function(){var b=a(this),c=a(e.listType);g.each(function(d,f){var g=a(f);h.push(g.offset().top-e.highlightOffset);var i=e.anchorName(d,f,e.prefix);if(f.id!==i){a("<span/>").attr("id",i).insertBefore(g)}var l=a("<a/>").text(e.headerText(d,f,g)).attr("href","#"+i).bind("click",function(c){a(window).unbind("scroll",k),j(c,function(){a(window).bind("scroll",k)}),b.trigger("selected",a(this).attr("href"))}),m=a("<li/>").addClass(e.itemClass(d,f,g,e.prefix)).append(l);c.append(m)}),b.html(c)})},jQuery.fn.toc.defaults={container:"body",listType:"<ul/>",selectors:"h1,h2,h3",smoothScrolling:function(b,c,d){a(b).smoothScroller({offset:c.scrollToOffset}).on("smoothScrollerComplete",function(){d()})},scrollToOffset:0,prefix:"toc",activeClass:"toc-active",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(c,d,e){if(d.id.length)return d.id;var f=a(d).text().replace(/[^a-z0-9]/gi," ").replace(/\s+/g,"-").toLowerCase();if(b[f]){for(var g=2;b[f+g];)g++;f=f+"-"+g}return b[f]=!0,e+"-"+f},headerText:function(a,b,c){return c.text()},itemClass:function(a,b,c,d){return d+"-"+c[0].tagName.toLowerCase()}}}(jQuery);
-
/* 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);
+
// http://spoiledmilk.com/blog/sticky-sidebar/
 +
(function ($) {
 +
 
 +
    $.fn.stickySidebar = function (options) {
 +
 
 +
        var config = $.extend({
 +
            headerSelector: 'header',
 +
            navSelector: 'nav',
 +
            contentSelector: '#content',
 +
            footerSelector: 'footer',
 +
            sidebarTopMargin: 20,
 +
            footerThreshold: 40
 +
        }, options);
 +
 
 +
        var fixSidebr = function () {
 +
 
 +
            var sidebarSelector = $(this);
 +
            var viewportHeight = $(window).height();
 +
            var viewportWidth = $(window).width();
 +
            var documentHeight = $(document).height();
 +
            var headerHeight = $(config.headerSelector).outerHeight();
 +
            var navHeight = $(config.navSelector).outerHeight();
 +
            var sidebarHeight = sidebarSelector.outerHeight();
 +
            var contentHeight = $(config.contentSelector).outerHeight();
 +
            var footerHeight = $(config.footerSelector).outerHeight();
 +
            var scroll_top = $(window).scrollTop();
 +
            var fixPosition = contentHeight - sidebarHeight;
 +
            var breakingPoint1 = config.breakingPoint1 || (headerHeight + navHeight);
 +
            var breakingPoint2 = documentHeight - (sidebarHeight + footerHeight + config.footerThreshold);
 +
 
 +
            // calculate
 +
            if ((contentHeight > sidebarHeight) && (viewportHeight > sidebarHeight)) {
 +
 
 +
                if (scroll_top < breakingPoint1) {
 +
 
 +
                    sidebarSelector.removeClass('sticky');
 +
 
 +
                } else if ((scroll_top >= breakingPoint1) && (scroll_top < breakingPoint2)) {
 +
 
 +
                    sidebarSelector.addClass('sticky').css('top', config.sidebarTopMargin);
 +
 
 +
                } else {
 +
 
 +
                    var negative = breakingPoint2 - scroll_top;
 +
                    sidebarSelector.addClass('sticky').css('top', negative);
 +
 
 +
                }
 +
 
 +
            }
 +
        };
 +
 
 +
        return this.each(function () {
 +
            $(window).on('scroll', $.proxy(fixSidebr, this));
 +
            $(window).on('resize', $.proxy(fixSidebr, this))
 +
            $.proxy(fixSidebr, this)();
 +
        });
 +
 
 +
    };
 +
 
 +
}(jQuery));

Latest revision as of 19:26, 20 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
       });
   }
   
   $('#nav ul ul').parent().children('a').addClass('is-parent');
   if($('#toc').length != 0) {
       $('#toc').remove();
       $('body').addClass('with-toc');
var $jqtoc = $('
')
       .prependTo('#main')
       .toc({
           container: '#inner-content',
           headerText: function(i, heading, $heading) { // remove [edit] link
               return $heading.text().replace(/\[edit\]/g, ); 
           },
           selectors: 'h1, h2'
       });
       $('#jqtoc > ul').stickySidebar({
           breakingPoint1: 401,
           contentSelector: '#inner-content',
           footerThreshold: 150,
           sidebarTopMargin: 0
       });
       if($(window).height() < $('#jqtoc > ul').height()) {
           $('<a id="scrolltop" href="#">▲</a>')
               .appendTo('#main')
               .fadeOut()
               .click(function()  {
                   $('html, body').animate({scrollTop: 0});
                   return false;
               });
           $(window).scroll(function() {
               if($(window).scrollTop() > 500) {
                   $('#scrolltop').fadeIn(200);
               } else {
                   $('#scrolltop').fadeOut(200);
               }
           });
       }
   }

});

/**

*   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+="
";this.el.addClass("has-dots").append(t).find(".dot").click(function(){n.move(e(this).index())})}};e.fn.unslider=function(t){var r=this.length;return this.each(function(i){var s=e(this);var u=(new n).init(s,t);s.data("unslider"+(r>1?"-"+(i+1):""),u)})}})(window.jQuery,false);

// 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
  • /
!function(a){a.fn.smoothScroller=function(b){b=a.extend({},a.fn.smoothScroller.defaults,b);var c=a(this);return a(b.scrollEl).animate({scrollTop:c.offset().top-a(b.scrollEl).offset().top-b.offset},b.speed,b.ease,function(){var a=c.attr("id");a.length&&(history.pushState?history.pushState(null,null,"#"+a):document.location.hash=a),c.trigger("smoothScrollerComplete")}),this},a.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},a("body").on("click","[data-smoothscroller]",function(b){b.preventDefault();var c=a(this).attr("href");0===c.indexOf("#")&&a(c).smoothScroller()})}(jQuery),function(a){var b={};a.fn.toc=function(b){var c,d=this,e=a.extend({},jQuery.fn.toc.defaults,b),f=a(e.container),g=a(e.selectors,f),h=[],i=e.activeClass,j=function(b,c){if(e.smoothScrolling&&"function"==typeof e.smoothScrolling){b.preventDefault();var f=a(b.target).attr("href");e.smoothScrolling(f,e,c)}a("li",d).removeClass(i),a(b.target).parent().addClass(i)},k=function(){c&&clearTimeout(c),c=setTimeout(function(){for(var b,c=a(window).scrollTop(),f=Number.MAX_VALUE,g=0,j=0,k=h.length;k>j;j++){var l=Math.abs(h[j]-c);f>l&&(g=j,f=l)}a("li",d).removeClass(i),b=a("li:eq("+g+")",d).addClass(i),e.onHighlight(b)},50)};return e.highlightOnScroll&&(a(window).bind("scroll",k),k()),this.each(function(){var b=a(this),c=a(e.listType);g.each(function(d,f){var g=a(f);h.push(g.offset().top-e.highlightOffset);var i=e.anchorName(d,f,e.prefix);if(f.id!==i){a("<span/>").attr("id",i).insertBefore(g)}var l=a("<a/>").text(e.headerText(d,f,g)).attr("href","#"+i).bind("click",function(c){a(window).unbind("scroll",k),j(c,function(){a(window).bind("scroll",k)}),b.trigger("selected",a(this).attr("href"))}),m=a("
  • ").addClass(e.itemClass(d,f,g,e.prefix)).append(l);c.append(m)}),b.html(c)})},jQuery.fn.toc.defaults={container:"body",listType:"<ul/>",selectors:"h1,h2,h3",smoothScrolling:function(b,c,d){a(b).smoothScroller({offset:c.scrollToOffset}).on("smoothScrollerComplete",function(){d()})},scrollToOffset:0,prefix:"toc",activeClass:"toc-active",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(c,d,e){if(d.id.length)return d.id;var f=a(d).text().replace(/[^a-z0-9]/gi," ").replace(/\s+/g,"-").toLowerCase();if(b[f]){for(var g=2;b[f+g];)g++;f=f+"-"+g}return b[f]=!0,e+"-"+f},headerText:function(a,b,c){return c.text()},itemClass:function(a,b,c,d){return d+"-"+c[0].tagName.toLowerCase()}}}(jQuery); // http://spoiledmilk.com/blog/sticky-sidebar/ (function ($) { $.fn.stickySidebar = function (options) { var config = $.extend({ headerSelector: 'header', navSelector: 'nav', contentSelector: '#content', footerSelector: 'footer', sidebarTopMargin: 20, footerThreshold: 40 }, options); var fixSidebr = function () { var sidebarSelector = $(this); var viewportHeight = $(window).height(); var viewportWidth = $(window).width(); var documentHeight = $(document).height(); var headerHeight = $(config.headerSelector).outerHeight(); var navHeight = $(config.navSelector).outerHeight(); var sidebarHeight = sidebarSelector.outerHeight(); var contentHeight = $(config.contentSelector).outerHeight(); var footerHeight = $(config.footerSelector).outerHeight(); var scroll_top = $(window).scrollTop(); var fixPosition = contentHeight - sidebarHeight; var breakingPoint1 = config.breakingPoint1 || (headerHeight + navHeight); var breakingPoint2 = documentHeight - (sidebarHeight + footerHeight + config.footerThreshold); // calculate if ((contentHeight > sidebarHeight) && (viewportHeight > sidebarHeight)) { if (scroll_top < breakingPoint1) { sidebarSelector.removeClass('sticky'); } else if ((scroll_top >= breakingPoint1) && (scroll_top < breakingPoint2)) { sidebarSelector.addClass('sticky').css('top', config.sidebarTopMargin); } else { var negative = breakingPoint2 - scroll_top; sidebarSelector.addClass('sticky').css('top', negative); } } }; return this.each(function () { $(window).on('scroll', $.proxy(fixSidebr, this)); $(window).on('resize', $.proxy(fixSidebr, this)) $.proxy(fixSidebr, this)(); }); }; }(jQuery));