-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathqhm.min.js
More file actions
1 lines (1 loc) · 6.77 KB
/
Copy pathqhm.min.js
File metadata and controls
1 lines (1 loc) · 6.77 KB
1
(function(){QHM.add_onload=function(a){var b;return b=window.onload,window.onload="function"!=typeof b?a:function(){return b&&b(),a()}}}).call(this),function(){var a,b,c;"undefined"!=typeof jQuery&&null!==jQuery&&null!=("undefined"!=typeof QHM&&null!==QHM?QHM.enable_toc:void 0)&&(a=jQuery,c=function(){function b(b){var c;c=a.extend({parent:null,children:[],level:0,depth:0,title:"",id:""},b),this.parent=c.parent,this.children=c.children,this.level=c.level,this.depth=c.depth,this.title=c.title,this.id=c.id}return b.prototype.find_parent=function(a){return this.parent?this.parent.level<a?this.parent:this.parent.find_parent(a):this},b.prototype.count_parent=function(a){return a=a||0,this.parent?this.parent.count_parent(a+1):a},b.prototype.to_s=function(){var a,b,c,d,e,f;if(c="",0===this.children.length)return a=this.count_parent(),c+=" "*a,c+=this.level.toString()+"\n";for(a=this.count_parent(),c+=" "*a,c+=this.level.toString()+"\n",f=[],b=d=0,e=this.children.length-1;0<=e?d<=e:d>=e;b=0<=e?++d:--d)f.push(c+=this.children[b].to_s());return f},b.prototype.to_html=function(a){var b,c,d,e;if(c="",a=a||!1,a&&!this.parent&&(c+="<ul>"),0===this.children.length)this.count_parent(),c+='<li><a href="#'+this.id+'">'+this.title+"</a></li>\n";else{for(this.count_parent(),a||(c+="<ul>"),b=d=0,e=this.children.length-1;0<=e?d<=e:d>=e;b=0<=e?++d:--d)c+=this.children[b].to_html(a);a||(c+="</ul>\n"),this.parent&&(c='<li><a href="#'+this.id+'">'+this.title+"</a>"+c+"</li>\n")}return a&&!this.parent&&(c+="</ul>"),c},b}(),b=function(){function b(d,e){var f,g,h,i;if(this.$element=a(d),this.options=a.extend({},b.options,e),this.root=new c,this.heading_selector=e.selector,this.target_selector=e.target,this.ignore_class=e.ignore||b.options.ignoreClass,QHM.type_is_array(this.target_selector))for(i=this.target_selector,g=0,h=i.length;g<h;g++)if(f=i[g],a(f).length>0){this.target_selector=f;break}this.$headings=a(this.target_selector).find(this.heading_selector).not("."+this.ignore_class).get(),this.$headings.length>0&&(this.scan(),this.$element.html(this.to_html()),null!=this.options.customClass&&this.$element.children("ul").addClass(this.options.customClass))}return b.heading_id_prefix="toc_element_",b.headings_count=0,b.options={ignoreClass:"no-toc",elementTitleContent:"text",elementUseTitleAttr:!0,elementIsNotDescendantOf:!1,customClass:""},b.prototype.scan=function(){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;for(f=this.root,e=0,o=this.$headings,s=[],m=0,n=o.length;m<n;m++)if(g=o[m],d=a(g),!(this.options.elementIsNotDescendantOf&&d.closest(this.options.elementIsNotDescendantOf).length>0)&&(i=d.data("level"),i||(i=1,g.tagName.match(/^h(\d)$/i)&&(i=parseInt(RegExp.$1,10))),h=d.attr("id")||!1,l=this.options.elementUseTitleAttr&&((null!=(p=d.attr("title"))?p.length:void 0)>0||(null!=(q=d.attr("data-title"))?q.length:void 0)>0)?d.attr("data-title")||d.attr("title"):"html"===this.options.elementTitleContent?d.html():d.text(),l=l.replace(/^\s+|\s+$/g,""),0!==l.length)){if(j=null,h||(b.headings_count++,h=""+b.heading_id_prefix+QHM.unique_id()+b.headings_count,d.attr("id",h)),i<this.options.level)break;e<i?(e=i,j=new c({parent:f,level:i,title:l,id:h}),f.children.push(j),s.push(f=j)):e===i?(j=new c({parent:f.parent,level:i,title:l,id:h}),null!=(r=f.parent)&&r.children.push(j),s.push(f=j)):(e=i,k=f.find_parent(i),j=new c({parent:k,level:i,title:l,id:h}),k.children.push(j),s.push(f=j))}return s},b.prototype.to_html=function(){var b,c;return b=this.root.to_html(this.options.flat),this.options.title.length>0&&(c=a("<div><h2></h2></div>").children().addClass(this.ignore_class).text(this.options.title).end().html(),b=c+"\n"+b),b},b}(),a.fn.qhmtoc=function(c){return this.each(function(){var d;return c=a.extend({},c,a(this).data()),null!=c.qhmcontents?a(this).data("toc"):(d=new b(this,c),a(this).data("toc",d))})},a(function(){var b;if(b=a(".plugin-contents").qhmtoc(),null!=("undefined"!=typeof history&&null!==history?history.pushState:void 0))return b.on("click","a",function(b){var c;if(c=a(this).attr("href"),"#"===c.substr(0,1))return b.preventDefault(),QHM.scroll(c),history.pushState("","",c)})}))}.call(this),function(){QHM.external_link=function(a,b){var c,d,e,f,g,h,i,j;c=location.hostname,a&&(c+="|"+a),c=c.replace(/^www\./,""),g=new RegExp("^(www.|)"+c),i=document.links,j=[];for(e in i)f=i[e],null!=f.href&&(d=f.host,"nowin"===(h=f.getAttribute("data-target"))||(null!==h?j.push(f.target=h):d.match(g)||0===d.length||j.push(f.target=b)));return j},QHM.add_onload(function(){if(QHM.window_open)return QHM.external_link(QHM.exclude_host_name_regex,QHM.default_target)})}.call(this),function(){var a;"undefined"!=typeof jQuery&&null!==jQuery&&(a=jQuery)(function(){return a("#navigator.haik-nav ul.list1").each(function(){return a(this).removeClass("list1").addClass("qhm-bs-nav nav navbar-nav")})})}.call(this),function(){QHM.scroll=function(a,b){var c;return b=b||300,c=$(a).offset().top,$("html, body").animate({scrollTop:c},b)}}.call(this),function(){QHM&&(QHM.type_is_array=Array.isArray||function(a){return"[object Array]"==={}.toString.call(a)},QHM.unique_id=function(a){var b;for(null==a&&(a=8),b="";b.length<a;)b+=Math.random().toString(36).substr(2);return b.substr(0,a)})}.call(this),function(a){"use strict";a.fn.fitVids=function(b){var c={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var d=document.head||document.getElementsByTagName("head")[0],e=document.createElement("div");e.innerHTML='<p>x</p><style id="fit-vids-style">'+".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}"+"</style>",d.appendChild(e.childNodes[1])}return b&&a.extend(c,b),this.each(function(){var b=['iframe[src*="player.vimeo.com"]','iframe[src*="youtube.com"]','iframe[src*="youtube-nocookie.com"]','iframe[src*="kickstarter.com"][src*="video.html"]',"object","embed"];c.customSelector&&b.push(c.customSelector);var d=".fitvidsignore";c.ignore&&(d=d+", "+c.ignore);var e=a(this).find(b.join(","));e=e.not("object object"),e=e.not(d),e.each(function(b){var c=a(this);if(!(c.parents(d).length>0||"embed"===this.tagName.toLowerCase()&&c.parent("object").length||c.parent(".fluid-width-video-wrapper").length)){c.css("height")||c.css("width")||!isNaN(c.attr("height"))&&!isNaN(c.attr("width"))||(c.attr("height",9),c.attr("width",16));var e="object"===this.tagName.toLowerCase()||c.attr("height")&&!isNaN(parseInt(c.attr("height"),10))?parseInt(c.attr("height"),10):c.height(),f=isNaN(parseInt(c.attr("width"),10))?c.width():parseInt(c.attr("width"),10),g=e/f;if(!c.attr("id")){var h="fitvid"+b;c.attr("id",h)}c.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",100*g+"%"),c.removeAttr("height").removeAttr("width")}})})}}(window.jQuery||window.Zepto);