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,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE;AAC9C,cAAM,CAAC,+BAA+B,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;KACtE,CAAC,CAAC;;AAEH,WAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY;AAC3C,YAAI,CAAC,eAAe,EAAE,CAAC,CAAC;KAC3B,CAAC,CAAC;CACN,CAAC,CAAC","file":"plugin.js","sourcesContent":["// LICENSE : MIT\n\"use strict\";\nrequire(['gitbook'], function (gitbook) {\n function addBeforeHeader(element) {\n jQuery('.book-header > h1').before(element)\n }\n\n function createButton({\n user,\n repo,\n type,\n size,\n width,\n height,\n count\n }) {\n var extraParam = type === \"watch\" ? \"&v=2\" : \"\";\n return `<a class=\"btn pull-right hidden-mobile\" aria-label=\"github\">\n <iframe style=\"display:inline-block;vertical-align:middle;\" src=\"https://ghbtns.com/github-btn.html?user=${user}&repo=${repo}&type=${type}&count=${count}&size=${size}${extraParam}\" frameborder=\"0\" scrolling=\"0\" width=\"${width}px\" height=\"${height}px\"></iframe>\n </a>`;\n }\n\n\n function insertGitHubLink({\n user,\n repo,\n types,\n size,\n width,\n height,\n count\n }) {\n types.reverse().forEach(type => {\n var elementString = createButton({\n user,\n repo,\n type,\n size,\n width,\n height,\n count\n });\n addBeforeHeader(elementString);\n });\n }\n\n function init(config) {\n var repoPath = config.repo;\n var [user, repo] = repoPath.split(\"/\");\n if (repoPath == null) {\n console.log(\"Should set github.repo\");\n return;\n }\n var types = config.types || [\"star\", \"watch\"];\n var size = config.size || \"large\";\n var width = config.width || (size === \"large\" ? \"150\" : \"100\");\n var height = config.height || (size === \"large\" ? \"30\" : \"20\");\n var count = typeof config.count === \"undefined\" ? \"true\" : \"false\";\n insertGitHubLink({\n user,\n repo,\n types,\n size,\n width,\n height,\n count\n });\n }\n\n // injected by html hook\n function getPluginConfig() {\n return window[\"gitbook-plugin-github-buttons\"];\n }\n\n // make sure configuration gets injected\n gitbook.events.bind('start', function (e, config) {\n window[\"gitbook-plugin-github-buttons\"] = config[\"github-buttons\"];\n });\n\n gitbook.events.bind('page.change', function () {\n init(getPluginConfig());\n });\n});\n"]} |