Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed May 9, 2017
1 parent 3c8471b commit a8ae42b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "CodeCopy",
"description": "Because copy to clipboard buttons should exist on every code snippet",
"homepage_url": "https://github.com/zenorocha/codecopy",
"version": "1.1.0",
"version": "1.2.0",
"author": "Zeno Rocha",
"applications": {
"gecko": {
Expand Down
66 changes: 54 additions & 12 deletions dist/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,32 @@ E.prototype = {
module.exports = E;

},{}],9:[function(require,module,exports){
module.exports={
"small": [
"askubuntu.com",
"serverfault.com",
"stackexchange.com",
"stackoverflow.com",
"superuser.com"
],
"large": [
"github.com",
"gist.github.com",
"medium.com",
"www.npmjs.com",
"developer.mozilla.org",
"tableless.com.br",
"laracasts.com",
"docs.rs",
"www.digitalocean.com",
"developer.github.com"
],
"xlarge": [
"nodejs.org"
]
}

},{}],10:[function(require,module,exports){
'use strict';

var _clipboard = require('clipboard');
Expand All @@ -777,6 +803,10 @@ var _util = require('./util');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Get button style based on the current page

var siteStyle = (0, _util.getSiteStyle)();

// Scan for code snippets and append buttons

var snippets = document.querySelectorAll('pre');
Expand All @@ -788,12 +818,8 @@ snippets.forEach(function (snippet) {
parent.replaceChild(wrapper, snippet);
wrapper.appendChild(snippet);

wrapper.classList.add('codecopy');
wrapper.classList.add('codecopy', 'codecopy-' + siteStyle);
wrapper.firstChild.insertAdjacentHTML('beforebegin', _util.htmlButton);

if ((0, _util.isLargeButton)()) {
wrapper.classList.add('codecopy-lg');
}
});

// Add copy to clipboard functionality and user feedback
Expand Down Expand Up @@ -825,17 +851,33 @@ btns.forEach(function (btn) {
});
});

},{"./util":10,"clipboard":2}],10:[function(require,module,exports){
"use strict";
},{"./util":11,"clipboard":2}],11:[function(require,module,exports){
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var htmlButton = exports.htmlButton = "\n <button class=\"codecopy-btn tooltipped tooltipped-s\" aria-label=\"Copy to clipboard\">\n <svg height=\"16\" class=\"codecopy-btn-icon\" viewBox=\"0 0 14 16\" version=\"1.1\" width=\"16\" aria-hidden=\"true\">\n <path fill-rule=\"evenodd\" d=\"M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z\"></path>\n </svg>\n </button>";
exports.htmlButton = undefined;
exports.getSiteStyle = getSiteStyle;

var _styles = require('../data/styles');

var _styles2 = _interopRequireDefault(_styles);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var htmlButton = exports.htmlButton = '\n <button class="codecopy-btn tooltipped tooltipped-s" aria-label="Copy to clipboard">\n <svg height="16" class="codecopy-btn-icon" viewBox="0 0 14 16" version="1.1" width="16" aria-hidden="true">\n <path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path>\n </svg>\n </button>';

function getSiteStyle() {
var currentStyle;

Object.keys(_styles2.default).forEach(function (style) {
if (_styles2.default[style].indexOf(document.location.hostname) !== -1) {
currentStyle = style;
}
});

var isLargeButton = exports.isLargeButton = function isLargeButton() {
var sites = /^(github.com|gist.github.com|medium.com|www.npmjs.com|developer.mozilla.org|tableless.com.br|laracasts.com|docs.rs|www.digitalocean.com)$/;
return sites.exec(document.location.hostname);
return currentStyle || 'small';
};

},{}]},{},[9]);
},{"../data/styles":9}]},{},[10]);
16 changes: 12 additions & 4 deletions dist/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,9 @@
transition: opacity 0.3s ease-in-out;
opacity: 0;
position: absolute;
padding: 2px 6px;
right: 0;
top: 0;
z-index: 1; }
.codecopy .codecopy-btn .codecopy-btn-icon {
border-radius: 0;
margin-top: -3px;
position: relative;
top: 3px;
Expand All @@ -488,7 +486,17 @@
.codecopy:hover .codecopy-btn {
opacity: 1; }

.codecopy.codecopy-lg .codecopy-btn {
.codecopy.codecopy-small .codecopy-btn {
padding: 2px 6px;
right: 0;
top: 0; }

.codecopy.codecopy-large .codecopy-btn {
padding: 3px 6px;
right: 5px;
top: 5px; }

.codecopy.codecopy-xlarge .codecopy-btn {
padding: 3px 6px;
right: 30px;
top: 10px; }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codecopy",
"version": "1.1.0",
"version": "1.2.0",
"description": "Because copy to clipboard buttons should exist on every code snippet",
"main": "src/scripts/main.js",
"repository": "zenorocha/codecopy",
Expand Down

0 comments on commit a8ae42b

Please sign in to comment.