-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgithub-fork-ribbon.min.js
1 lines (1 loc) · 5.55 KB
/
github-fork-ribbon.min.js
1
(function(d,i){function h(l){var m=document.createElement("style");m.type="text/css";try{m.appendChild(document.createTextNode(l))}catch(k){m.styleSheet.cssText=l}document.getElementsByTagName("head")[0].appendChild(m)}function c(m,p,l){for(var k in p){if(p.hasOwnProperty(k)&&(!m.hasOwnProperty(k)||l)){m[k]=p[k]}}return m}function b(){return/Mobile/i.test(navigator.userAgent)}function j(p){var o=location.search;var n=o.substring(1).split("&");var r={};for(var q=0,k=n.length;q<k;q++){var m=n[q];if(m){r[m.substring(0,m.indexOf("=")).toLowerCase()]=m.substring(m.indexOf("=")+1,m.length)}}if(!p){return r}var l=r[p.toLowerCase()];return l?l.trim():""}function a(l){var o=location.hostname;var k=o.indexOf(".github.io");var n=j("githubFork");var m=l;if(m===g.url){if(k!==-1){m="//github.com/"+o.slice(0,k)}else{if(!!n){m="//github.com/"+n}}}return m}function e(m,k){var l="github-fork-ribbon";if(!!m&&m.indexOf("left")!==-1){l+=" gf-ribbon-left"}if(!!m&&m.indexOf("bottom")!==-1){l+="gf-ribbon-bottom"}if(!!k){l+=" gf-ribbon-"+k}return l}var g={text:"Fork me on Github",url:"//github.com/merrier/",position:["right","top"],type:"black",zIndex:2,fixed:false,target:"_blank",fontSize:"13px",isMobileHide:false};var f=function(k){f.prototype.options=c(g,k,true);return f.prototype.init(this.options)};f.prototype={constructor:f,_setStyle:function(l,k){l.className=e(k.position,this.options.type);l.setAttribute("target",k.target||this.options.target);l.setAttribute("href",a(k.url||this.options.url));l.setAttribute("data-ribbon",k.text||this.options.text);l.setAttribute("title",k.text||this.options.text);l.style.zIndex=k.zIndex||this.options.zIndex;l.style.fontSize=k.fontSize||this.options.fontSize;l.style.position=k.fixed&&"fixed"},_getDom:function(){return document.getElementsByClassName("github-fork-ribbon")[0]},create:function(k,m){this.options=c(f.prototype.options,k,true);if(!this.hasDom){var l=document.createElement("a");this._setStyle(l,this.options);document.getElementsByTagName("body")[0].appendChild(l)}else{this._setStyle(this._getDom(),k)}this.hasDom=true;if(b()&&this.options.isMobileHide){this.hide()}m&&m();return this},show:function(l){if(this.hasDom){var k=this._getDom();k.style.display="block"}l&&l();return this},hide:function(l){if(this.hasDom){var k=this._getDom();k.style.display="none"}l&&l();return this},remove:function(l){if(this.hasDom){var k=this._getDom();document.getElementsByTagName("body")[0].removeChild(k);this.hasDom=false}l&&l();return this},config:function(k,l){if(this.hasDom&&k){this._setStyle(this._getDom(),k)}l&&l();return this}};f.prototype.init=function(k){this.hasDom=false;return this.create(k)};f.prototype.init.prototype=f.prototype;if(typeof module!=="undefined"&&module.exports){module.exports=f}else{if(typeof define==="function"&&define.amd){define(function(){return f})}else{d.githubFork=f}}(function(){var k='.github-fork-ribbon {width: 12.1em;height: 12.1em;position: absolute;overflow: hidden;top: 0;right: 0;z-index: 2;font-size: 13px;text-decoration: none;text-indent: -999999px;}.github-fork-ribbon:before, .github-fork-ribbon:after{position: absolute;display: block;width: 15.38em;height: 1.54em;top: 3.23em;right: -3.23em; -webkit-box-sizing: content-box; -moz-box-sizing: content-box;box-sizing: content-box; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg);transform: rotate(45deg);}.github-fork-ribbon:before {content: "";padding: .38em 0;background-color: #333;background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.15)));background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); -webkit-box-shadow: 0 0.15em 0.23em 0 rgba(0, 0, 0, 0.5); -moz-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);box-shadow: 0 0.15em 0.23em 0 rgba(0, 0, 0, 0.5);pointer-events: auto;}.github-fork-ribbon:after {content: attr(data-ribbon);color: #fff;font: 700 1em "Helvetica Neue", Helvetica, Arial, sans-serif;line-height: 1.54em;text-decoration: none;text-shadow: 0 -0.08em rgba(0, 0, 0, 0.5);text-align: center;text-indent: 0;padding: .15em 0;margin: .15em 0;border-width: .08em 0;border-style: dotted;border-color: #fff;border-color: rgba(255, 255, 255, 0.7);}.github-fork-ribbon.gf-ribbon-fixed {position: fixed;}.github-fork-ribbon.gf-ribbon-left {left: 0;right: auto;}.github-fork-ribbon.gf-ribbon-bottom {top: auto;bottom: 0;}.github-fork-ribbon.gf-ribbon-left:before,.github-fork-ribbon.gf-ribbon-left:after {left: -3.23em;right: auto;}.github-fork-ribbon.gf-ribbon-left.gf-ribbon-top:before,.github-fork-ribbon.gf-ribbon-left.gf-ribbon-top:after,.github-fork-ribbon.gf-ribbon-right.gf-ribbon-bottom:before,.github-fork-ribbon.gf-ribbon-right.gf-ribbon-bottom:after { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg);transform: rotate(-45deg);}.github-fork-ribbon.gf-ribbon-black:before {background-color: #333;}.github-fork-ribbon.gf-ribbon-red:before {background-color: #a00;}.github-fork-ribbon.gf-ribbon-orange:before {background-color: #f80;}.github-fork-ribbon.gf-ribbon-green:before {background-color: #090;}';h(k)})();if(location.hostname.indexOf(".github.io")!==-1||!!j("githubFork")){return d.githubForkRibbon=new f({url:a(g.url)})}})(window);