-
Notifications
You must be signed in to change notification settings - Fork 4
/
repo-card.min.js
1 lines (1 loc) · 8.89 KB
/
repo-card.min.js
1
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RepoCard=t():n.RepoCard=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var i=e[r]={exports:{},id:r,loaded:!1};return n[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){e(1),n.exports=e(2)},function(n,t){"use strict";var e=e||function(){function n(n){return console.warn("script tag with id [%s] could not be found",n),null}function t(t,e){for(var r=document.getElementsByTagName("script"),i=0,a=r.length;a>i;i++){var o=r[i],s=o.getAttribute("id");if(s===t)return r[i]}return e?null:n(t)}function e(n,e){var r=t(n,e);if(!r)return null;var i={},a=r.attributes;for(var o in a)if(a.hasOwnProperty(o)){var s=a[o];i[s.name.replace(/data-/g,"")]=s.value}return i}return{getScript:t,getData:e}}()},function(n,t,e){function r(){if(!(this instanceof r))return new r;var n=c.getData("repo-card-lib",!0);n&&Object.keys(n).length>2&&this.configure(n)}function i(n,t){var e=document.getElementById(n);e.style.background=t}function a(n){var t=document.getElementById("repo-card-container").style;t.position="fixed",t.top=t.right=t.bottom=t.left="initial";for(var e in n)t[e]=n[e]+"px"}function o(n,t,e){return['<li class="repo-card__social-item"><iframe src="https://ghbtns.com/github-btn.html?user=',n,"&repo=",t,"&type=",e,'&count=true"','frameborder="0" scrolling="0" width="90px" height="20px"></iframe></li>'].join("")}function s(n){return['<li class="repo-card__social-item"><iframe src="https://ghbtns.com/github-btn.html?user=',n,'&type=follow"','frameborder="0" scrolling="0" width="130px" height="20px"></iframe></li>'].join("")}function p(n){var t=[];return n.stars!==!1&&t.push(o(n.username,n.repo,"star")),n.fork!==!1&&t.push(o(n.username,n.repo,"fork")),n.follow!==!1&&t.push(s(n.username)),t.join("")}function d(n){var t=document.createElement("style");return t.innerHTML=r.themes[n||"doodle"].style,t}function l(n,t){var e=[];return t.split("{{").forEach(function(t){/subtitle}}/.test(t)?(e.push(n.subtitle),e.push(t.split("subtitle}}")[1])):/title}}/.test(t)?(e.push(n.title),e.push(t.split("title}}")[1])):/info}}/.test(t)?(e.push(n.info),e.push(t.split("info}}")[1])):/buttons}}/.test(t)?(e.push(p(n)),e.push(t.split("buttons}}")[1])):e.push(t)}),e.join("")}var c=e(3);r.themes={doodle:{template:'<div id="repo-card">\n <p id="repo-card-close" onclick="javascript:document.getElementById(\'repo-card\').style.display=\'none\'">X</p>\n <div id="repo-card__image-wrap">\n <div id="repo-card__thumb-wrap">\n <img id="repo-card__thumb" />\n </div>\n <header id="repo-card__header">\n <h1 id="repo-card__title">\n {{title}}\n </h1>\n\n <div id="repo-card__subtitle">\n {{subtitle}}\n </div>\n </header>\n </div>\n <div id="repo-card__content-wrap">\n <div id="repo-card__content">\n {{info}}\n </div>\n </div>\n <ul id="repo-card__social">\n {{buttons}}\n </ul>\n</div>',style:"#repo-card {\n box-sizing: border-box;\n font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\n background-color: #FFFFFF;\n line-height: 1.5em;\n margin: 0 auto;\n padding-bottom: 60px;\n width: 350px;\n border: 1px solid #CCCCCC;\n border-radius: 5px;\n overflow: hidden;\n}\n\n#repo-card a {\n color: #999;\n}\n\n#repo-card__image-wrap {\n height: 100px;\n width: 100%;\n position: relative;\n -webkit-transition: height .3s ease-in;\n transition: height .3s ease-in;\n}\n\n#repo-card__image-wrap:before {\n content: '';\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n background-color: rgba(51, 51, 51, .25);\n z-index: 1;\n}\n\n#repo-card__header {\n text-align: left;\n padding-left: 140px;\n position: absolute;\n bottom: -28px;\n left: 0;\n color: #FFFFFF;\n z-index: 20;\n -webkit-transition: -webkit-transform .3s ease-in;\n transition: transform .3s ease-in;\n}\n\n#repo-card__title {\n margin: 0;\n color: #FFFFFF;\n font-size: 1.125em;\n font-weight: 400;\n z-index: 10;\n position: relative;\n padding-bottom: 6px;\n}\n\n#repo-card__subtitle {\n color: #999999;\n font-size: .875em;\n padding-top: 12px;\n -webkit-transition: -webkit-transform .3s ease-in;\n transition: transform .3s ease-in;\n}\n\n#repo-card__thumb-wrap {\n width: 110px;\n height: 110px;\n padding: 3px;\n position: absolute;\n bottom: -55px;\n left: 15px;\n border-radius: 50%;\n z-index: 10;\n -webkit-transition: -webkit-transform .3s linear;\n transition: transform .3s linear;\n}\n\n#repo-card__thumb {\n width: 104px;\n height: 104px;\n display: block;\n border-radius: 50%;\n background-size: cover !important;\n}\n\n#repo-card__content-wrap {\n padding-bottom: 0;\n min-height: 50px;\n position: relative;\n}\n\n#repo-card__content-wrap::after {\n content: '';\n position: absolute;\n top: -10px;\n left: 50%;\n z-index: 20;\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 0 10px 10px;\n border-color: transparent transparent #FFFFFF;\n -webkit-transform: translateY(10px);\n -ms-transform: translateY(10px);\n transform: translateY(10px);\n -webkit-transition: -webkit-transform .3s ease-in;\n transition: transform .3s ease-in;\n margin-left: -10px;\n}\n\n#repo-card__content {\n padding: 25px 20px 5px 20px;\n text-align: left;\n font-size: .875em;\n color: #666666;\n max-height: 0;\n overflow: hidden;\n -webkit-transform: translateY(-10%);\n -ms-transform: translateY(-10%);\n transform: translateY(-10%);\n -webkit-transition: max-height .3s ease-in, opacity .3s ease-in;\n transition: max-height .3s ease-in, opacity .3s ease-in;\n opacity: 0;\n visibility: hidden;\n}\n\n#repo-card__social {\n position: absolute;\n bottom: 0;\n left: 0;\n list-style: none;\n margin: 0;\n width: 100%;\n display: table;\n border-top: 1px solid #CCCCCC;\n padding: 10px 0px 5px 0px;\n}\n\n.repo-card__social-item {\n display: table-cell;\n text-align: center;\n position: relative;\n left: 5px;\n}\n\n#repo-card:hover #repo-card__image-wrap {\n height: 150px;\n}\n\n#repo-card-close {\n position: absolute;\n top: -7px;\n right: 8px;\n color: white;\n background: rgba(0, 0, 0, 0.5);\n padding: 0 6px;\n border-radius: 5px;\n cursor: pointer;\n z-index: 9999;\n}\n\n#repo-card:hover #repo-card__content-wrap:after {\n -webkit-transform: translateY(0);\n -ms-transform: translateY(0);\n transform: translateY(0);\n}\n\n#repo-card:hover #repo-card__content {\n max-height: 200px;\n opacity: 1;\n visibility: visible;\n -webkit-transform: translateY(0);\n -ms-transform: translateY(0);\n transform: translateY(0);\n -webkit-transition: max-height .3s ease-in, opacity .3s ease-in;\n transition: max-height .3s ease-in, opacity .3s ease-in;\n}\n\n#repo-card:hover #repo-card__thumb-wrap {\n -webkit-transform: translateY(-70%);\n -ms-transform: translateY(-70%);\n transform: translateY(-70%);\n}\n\n#repo-card:hover #repo-card__header {\n -webkit-transform: translateY(-110%);\n -ms-transform: translateY(-110%);\n transform: translateY(-110%);\n}\n\n#repo-card:hover #repo-card__subtitle {\n color: #FFFFFF;\n -webkit-transform: translateY(-10px);\n -ms-transform: translateY(-10px);\n transform: translateY(-10px);\n}",selectors:{background:"repo-card__image-wrap",thumb:"repo-card__thumb"}}},r.prototype.setTheme=function(n){var t=r.themes[n];return t?this.theme=t:(this.theme=r.themes.doodle,console.warn('"%s" is an invalid Repo Card theme. Reverting to default',n)),this},r.prototype.setStyling=function(n){var n=this.params=Object.assign(this.params,n);return n.background&&i(this.theme.selectors.background,n.background),n.thumb&&i(this.theme.selectors.thumb,n.thumb),n.position&&a(n.position),this},r.prototype.configure=function(n){if(this.params=this.params?Object.assign(this.params,n):n,(!this.theme||this.params.theme)&&this.setTheme(this.params.theme),this.repoCardTemplateInjected){var t=document.getElementById("repo-card-container");t.innerHTML=l(this.params,this.theme.template)}else{var e=document.createElement("div");e.id="repo-card-container",e.style.zIndex=999999,e.innerHTML=l(this.params,this.theme.template),document.body.appendChild(e),document.getElementsByTagName("head")[0].appendChild(d(this.params.theme)),this.repoCardTemplateInjected=!0}return(this.params.background||this.params.thumb||this.params.position)&&this.setStyling(this.params),this},n.exports=new r},function(n,t){"use strict";var e=e||function(){function n(n){return console.warn("script tag with id [%s] could not be found",n),null}function t(t,e){for(var r=document.getElementsByTagName("script"),i=0,a=r.length;a>i;i++){var o=r[i],s=o.getAttribute("id");if(s===t)return r[i]}return e?n(t):null}function e(e,r){var i=t(e);if(!i)return r&&n(e),null;var a={},o=i.attributes;for(var s in o)if(o.hasOwnProperty(s)){var p=o[s];a[p.name.replace(/data-/g,"")]=p.value}return a}return{getScript:t,getData:e}}();n.exports=e}])});