jekyll-theme-primer 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.md +1 -1
- data/README.md +3 -4
- data/_layouts/default.html +15 -4
- data/_sass/primer-base/LICENSE +1 -1
- data/_sass/primer-base/README.md +6 -6
- data/_sass/primer-base/build/build.css +1 -1
- data/_sass/primer-base/build/index.js +1 -1
- data/_sass/primer-base/lib/base.scss +11 -0
- data/_sass/primer-base/lib/normalize.scss +1 -3
- data/_sass/primer-base/package.json +25 -20
- data/_sass/primer-layout/LICENSE +1 -1
- data/_sass/primer-layout/README.md +12 -12
- data/_sass/primer-layout/docs/grid.md +392 -0
- data/_sass/primer-layout/package.json +27 -21
- data/_sass/primer-markdown/LICENSE +1 -1
- data/_sass/primer-markdown/README.md +6 -6
- data/_sass/primer-markdown/build/build.css +1 -1
- data/_sass/primer-markdown/build/index.js +1 -1
- data/_sass/primer-markdown/lib/code.scss +3 -16
- data/_sass/primer-markdown/lib/lists.scss +5 -1
- data/_sass/primer-markdown/lib/markdown-body.scss +1 -1
- data/_sass/primer-markdown/package.json +23 -18
- data/_sass/primer-support/LICENSE +1 -1
- data/_sass/primer-support/README.md +20 -6
- data/_sass/primer-support/docs/breakpoints.md +60 -0
- data/_sass/primer-support/docs/color-system.md +392 -0
- data/_sass/primer-support/docs/spacing.md +40 -0
- data/_sass/primer-support/docs/typography.md +90 -0
- data/_sass/primer-support/lib/mixins/buttons.scss +13 -9
- data/_sass/primer-support/lib/variables/layout.scss +8 -0
- data/_sass/primer-support/lib/variables/misc.scss +1 -1
- data/_sass/primer-support/package.json +25 -18
- data/_sass/primer-utilities/LICENSE +1 -1
- data/_sass/primer-utilities/README.md +6 -6
- data/_sass/primer-utilities/build/build.css +1 -1
- data/_sass/primer-utilities/build/index.js +1 -1
- data/_sass/primer-utilities/docs/animations.md +75 -0
- data/_sass/primer-utilities/docs/borders.md +127 -0
- data/_sass/primer-utilities/docs/box-shadow.md +107 -0
- data/_sass/primer-utilities/docs/colors.md +232 -0
- data/_sass/primer-utilities/docs/flexbox.md +665 -0
- data/_sass/primer-utilities/docs/layout.md +300 -0
- data/_sass/primer-utilities/docs/margin.md +126 -0
- data/_sass/primer-utilities/docs/padding.md +110 -0
- data/_sass/primer-utilities/docs/typography.md +138 -0
- data/_sass/primer-utilities/lib/animations.scss +32 -2
- data/_sass/primer-utilities/lib/borders.scss +2 -0
- data/_sass/primer-utilities/lib/layout.scss +7 -3
- data/_sass/primer-utilities/package.json +27 -21
- metadata +54 -42
- data/assets/javascript/anchor-js/.eslintrc +0 -77
- data/assets/javascript/anchor-js/.gitattributes +0 -2
- data/assets/javascript/anchor-js/.npmignore +0 -4
- data/assets/javascript/anchor-js/.travis.yml +0 -6
- data/assets/javascript/anchor-js/anchor.js +0 -334
- data/assets/javascript/anchor-js/anchor.min.js +0 -6
- data/assets/javascript/anchor-js/banner.js +0 -17
- data/assets/javascript/anchor-js/docs/anchor.js +0 -334
- data/assets/javascript/anchor-js/docs/favicon.ico +0 -0
- data/assets/javascript/anchor-js/docs/fonts/anchorjs-extras.eot +0 -0
- data/assets/javascript/anchor-js/docs/fonts/anchorjs-extras.svg +0 -11
- data/assets/javascript/anchor-js/docs/fonts/anchorjs-extras.ttf +0 -0
- data/assets/javascript/anchor-js/docs/fonts/anchorjs-extras.woff +0 -0
- data/assets/javascript/anchor-js/docs/fonts/fonts.css +0 -24
- data/assets/javascript/anchor-js/docs/grunticon/grunticon.loader.js +0 -3
- data/assets/javascript/anchor-js/docs/grunticon/icons.data.png.css +0 -5
- data/assets/javascript/anchor-js/docs/grunticon/icons.data.svg.css +0 -5
- data/assets/javascript/anchor-js/docs/grunticon/icons.fallback.css +0 -5
- data/assets/javascript/anchor-js/docs/grunticon/png/grunticon-link.png +0 -0
- data/assets/javascript/anchor-js/docs/img/anchoring-links.png +0 -0
- data/assets/javascript/anchor-js/docs/img/anchorjs_logo.png +0 -0
- data/assets/javascript/anchor-js/docs/img/anchorlinks2.png +0 -0
- data/assets/javascript/anchor-js/docs/img/gh-link.svg +0 -9
- data/assets/javascript/anchor-js/docs/img/gh_link.svg +0 -9
- data/assets/javascript/anchor-js/docs/img/hyperlink.svg +0 -9
- data/assets/javascript/anchor-js/docs/img/link.svg +0 -6
- data/assets/javascript/anchor-js/docs/img/mini-logo.png +0 -0
- data/assets/javascript/anchor-js/docs/img/primer-md.png +0 -0
- data/assets/javascript/anchor-js/docs/scripts.js +0 -12
- data/assets/javascript/anchor-js/docs/styles.css +0 -493
@@ -1,77 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"env": {
|
3
|
-
"browser": true
|
4
|
-
},
|
5
|
-
|
6
|
-
"rules": {
|
7
|
-
"array-bracket-spacing": [2, "never"],
|
8
|
-
"block-scoped-var": 2,
|
9
|
-
"brace-style": [2, "1tbs"],
|
10
|
-
"camelcase": 2,
|
11
|
-
"comma-spacing": [2, {"before": false, "after": true}],
|
12
|
-
"comma-style": [2, "last"],
|
13
|
-
"computed-property-spacing": [2, "never"],
|
14
|
-
"consistent-this": [2, "that"],
|
15
|
-
"curly": 2,
|
16
|
-
"eol-last": 2,
|
17
|
-
"eqeqeq": 2,
|
18
|
-
"guard-for-in": 2,
|
19
|
-
"handle-callback-err": 2,
|
20
|
-
"indent": [2, 2, {"VariableDeclarator": 2}],
|
21
|
-
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
|
22
|
-
"keyword-spacing": 2,
|
23
|
-
"no-caller": 2,
|
24
|
-
"new-cap": 2,
|
25
|
-
"new-parens": 2,
|
26
|
-
"no-array-constructor": 2,
|
27
|
-
"no-bitwise": 2,
|
28
|
-
"no-constant-condition": 2,
|
29
|
-
"no-else-return": 2,
|
30
|
-
"no-empty": 2,
|
31
|
-
"no-eq-null": 2,
|
32
|
-
"no-extra-parens": 0,
|
33
|
-
"no-extra-semi": 2,
|
34
|
-
"no-undef": 2,
|
35
|
-
"no-floating-decimal": 2,
|
36
|
-
"no-invalid-regexp": 2,
|
37
|
-
"no-irregular-whitespace": 2,
|
38
|
-
"no-lonely-if": 2,
|
39
|
-
"no-mixed-requires": 2,
|
40
|
-
"no-mixed-spaces-and-tabs": 2,
|
41
|
-
"no-multiple-empty-lines": 2,
|
42
|
-
"no-multi-spaces": 0,
|
43
|
-
"no-negated-in-lhs": 2,
|
44
|
-
"no-new-object": 2,
|
45
|
-
"no-path-concat": 2,
|
46
|
-
"no-process-env": 2,
|
47
|
-
"no-regex-spaces": 2,
|
48
|
-
"no-self-compare": 2,
|
49
|
-
"no-sequences": 2,
|
50
|
-
"no-spaced-func": 2,
|
51
|
-
"no-trailing-spaces": 2,
|
52
|
-
"no-underscore-dangle": 0,
|
53
|
-
"no-unused-vars": 0, // we should find a way to only exclude addAnchors and enable this
|
54
|
-
"no-use-before-define": [2, "nofunc"],
|
55
|
-
"no-void": 2,
|
56
|
-
"object-curly-spacing": [2, "always"],
|
57
|
-
"operator-assignment": [2, "always"],
|
58
|
-
"quotes": [2, "single"],
|
59
|
-
"quote-props": [2, "as-needed"],
|
60
|
-
"radix": 2,
|
61
|
-
"semi": [2, "always"],
|
62
|
-
"semi-spacing": 2,
|
63
|
-
"space-before-blocks": [2, "always"],
|
64
|
-
"spaced-comment": [2, "always"],
|
65
|
-
"space-in-parens": [2, "never"],
|
66
|
-
"space-unary-ops": [2, {"words": true, "nonwords": false}],
|
67
|
-
"strict": [2, "function"],
|
68
|
-
"valid-jsdoc": [2, {"requireReturn": false}],
|
69
|
-
"valid-typeof": 2,
|
70
|
-
"wrap-iife": [2, "outside"],
|
71
|
-
"yoda": [2, "never"]
|
72
|
-
},
|
73
|
-
|
74
|
-
"globals": {
|
75
|
-
"DocumentTouch": true,
|
76
|
-
}
|
77
|
-
}
|
@@ -1,334 +0,0 @@
|
|
1
|
-
/* eslint-env amd, node */
|
2
|
-
|
3
|
-
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
4
|
-
(function (root, factory) {
|
5
|
-
'use strict';
|
6
|
-
|
7
|
-
if (typeof define === 'function' && define.amd) {
|
8
|
-
// AMD. Register as an anonymous module.
|
9
|
-
define([], factory);
|
10
|
-
} else if (typeof module === 'object' && module.exports) {
|
11
|
-
// Node. Does not work with strict CommonJS, but
|
12
|
-
// only CommonJS-like environments that support module.exports,
|
13
|
-
// like Node.
|
14
|
-
module.exports = factory();
|
15
|
-
} else {
|
16
|
-
// Browser globals (root is window)
|
17
|
-
root.AnchorJS = factory();
|
18
|
-
root.anchors = new root.AnchorJS();
|
19
|
-
}
|
20
|
-
}(this, function () {
|
21
|
-
'use strict';
|
22
|
-
|
23
|
-
function AnchorJS(options) {
|
24
|
-
this.options = options || {};
|
25
|
-
this.elements = [];
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Assigns options to the internal options object, and provides defaults.
|
29
|
-
* @param {Object} opts - Options object
|
30
|
-
*/
|
31
|
-
function _applyRemainingDefaultOptions(opts) {
|
32
|
-
opts.icon = opts.hasOwnProperty('icon') ? opts.icon : '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
|
33
|
-
opts.visible = opts.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always' & 'touch'
|
34
|
-
opts.placement = opts.hasOwnProperty('placement') ? opts.placement : 'right'; // Also accepts 'left'
|
35
|
-
opts.class = opts.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name.
|
36
|
-
// Using Math.floor here will ensure the value is Number-cast and an integer.
|
37
|
-
opts.truncate = opts.hasOwnProperty('truncate') ? Math.floor(opts.truncate) : 64; // Accepts any value that can be typecast to a number.
|
38
|
-
}
|
39
|
-
|
40
|
-
_applyRemainingDefaultOptions(this.options);
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Checks to see if this device supports touch. Uses criteria pulled from Modernizr:
|
44
|
-
* https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40
|
45
|
-
* @return {Boolean} - true if the current device supports touch.
|
46
|
-
*/
|
47
|
-
this.isTouchDevice = function() {
|
48
|
-
return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch);
|
49
|
-
};
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Add anchor links to page elements.
|
53
|
-
* @param {String|Array|Nodelist} selector - A CSS selector for targeting the elements you wish to add anchor links
|
54
|
-
* to. Also accepts an array or nodeList containing the relavant elements.
|
55
|
-
* @return {this} - The AnchorJS object
|
56
|
-
*/
|
57
|
-
this.add = function(selector) {
|
58
|
-
var elements,
|
59
|
-
elsWithIds,
|
60
|
-
idList,
|
61
|
-
elementID,
|
62
|
-
i,
|
63
|
-
index,
|
64
|
-
count,
|
65
|
-
tidyText,
|
66
|
-
newTidyText,
|
67
|
-
readableID,
|
68
|
-
anchor,
|
69
|
-
visibleOptionToUse,
|
70
|
-
indexesToDrop = [];
|
71
|
-
|
72
|
-
// We reapply options here because somebody may have overwritten the default options object when setting options.
|
73
|
-
// For example, this overwrites all options but visible:
|
74
|
-
//
|
75
|
-
// anchors.options = { visible: 'always'; }
|
76
|
-
_applyRemainingDefaultOptions(this.options);
|
77
|
-
|
78
|
-
visibleOptionToUse = this.options.visible;
|
79
|
-
if (visibleOptionToUse === 'touch') {
|
80
|
-
visibleOptionToUse = this.isTouchDevice() ? 'always' : 'hover';
|
81
|
-
}
|
82
|
-
|
83
|
-
// Provide a sensible default selector, if none is given.
|
84
|
-
if (!selector) {
|
85
|
-
selector = 'h2, h3, h4, h5, h6';
|
86
|
-
}
|
87
|
-
|
88
|
-
elements = _getElements(selector);
|
89
|
-
|
90
|
-
if (elements.length === 0) {
|
91
|
-
return this;
|
92
|
-
}
|
93
|
-
|
94
|
-
_addBaselineStyles();
|
95
|
-
|
96
|
-
// We produce a list of existing IDs so we don't generate a duplicate.
|
97
|
-
elsWithIds = document.querySelectorAll('[id]');
|
98
|
-
idList = [].map.call(elsWithIds, function assign(el) {
|
99
|
-
return el.id;
|
100
|
-
});
|
101
|
-
|
102
|
-
for (i = 0; i < elements.length; i++) {
|
103
|
-
if (this.hasAnchorJSLink(elements[i])) {
|
104
|
-
indexesToDrop.push(i);
|
105
|
-
continue;
|
106
|
-
}
|
107
|
-
|
108
|
-
if (elements[i].hasAttribute('id')) {
|
109
|
-
elementID = elements[i].getAttribute('id');
|
110
|
-
} else if (elements[i].hasAttribute('data-anchor-id')) {
|
111
|
-
elementID = elements[i].getAttribute('data-anchor-id');
|
112
|
-
} else {
|
113
|
-
tidyText = this.urlify(elements[i].textContent);
|
114
|
-
|
115
|
-
// Compare our generated ID to existing IDs (and increment it if needed)
|
116
|
-
// before we add it to the page.
|
117
|
-
newTidyText = tidyText;
|
118
|
-
count = 0;
|
119
|
-
do {
|
120
|
-
if (index !== undefined) {
|
121
|
-
newTidyText = tidyText + '-' + count;
|
122
|
-
}
|
123
|
-
|
124
|
-
index = idList.indexOf(newTidyText);
|
125
|
-
count += 1;
|
126
|
-
} while (index !== -1);
|
127
|
-
index = undefined;
|
128
|
-
idList.push(newTidyText);
|
129
|
-
|
130
|
-
elements[i].setAttribute('id', newTidyText);
|
131
|
-
elementID = newTidyText;
|
132
|
-
}
|
133
|
-
|
134
|
-
readableID = elementID.replace(/-/g, ' ');
|
135
|
-
|
136
|
-
// The following code builds the following DOM structure in a more effiecient (albeit opaque) way.
|
137
|
-
// '<a class="anchorjs-link ' + this.options.class + '" href="#' + elementID + '" aria-label="Anchor link for: ' + readableID + '" data-anchorjs-icon="' + this.options.icon + '"></a>';
|
138
|
-
anchor = document.createElement('a');
|
139
|
-
anchor.className = 'anchorjs-link ' + this.options.class;
|
140
|
-
anchor.href = '#' + elementID;
|
141
|
-
anchor.setAttribute('aria-label', 'Anchor link for: ' + readableID);
|
142
|
-
anchor.setAttribute('data-anchorjs-icon', this.options.icon);
|
143
|
-
|
144
|
-
if (visibleOptionToUse === 'always') {
|
145
|
-
anchor.style.opacity = '1';
|
146
|
-
}
|
147
|
-
|
148
|
-
if (this.options.icon === '\ue9cb') {
|
149
|
-
anchor.style.font = '1em/1 anchorjs-icons';
|
150
|
-
|
151
|
-
// We set lineHeight = 1 here because the `anchorjs-icons` font family could otherwise affect the
|
152
|
-
// height of the heading. This isn't the case for icons with `placement: left`, so we restore
|
153
|
-
// line-height: inherit in that case, ensuring they remain positioned correctly. For more info,
|
154
|
-
// see https://github.com/bryanbraun/anchorjs/issues/39.
|
155
|
-
if (this.options.placement === 'left') {
|
156
|
-
anchor.style.lineHeight = 'inherit';
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
if (this.options.placement === 'left') {
|
161
|
-
anchor.style.position = 'absolute';
|
162
|
-
anchor.style.marginLeft = '-1em';
|
163
|
-
anchor.style.paddingRight = '0.5em';
|
164
|
-
elements[i].insertBefore(anchor, elements[i].firstChild);
|
165
|
-
} else { // if the option provided is `right` (or anything else).
|
166
|
-
anchor.style.paddingLeft = '0.375em';
|
167
|
-
elements[i].appendChild(anchor);
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
for (i = 0; i < indexesToDrop.length; i++) {
|
172
|
-
elements.splice(indexesToDrop[i] - i, 1);
|
173
|
-
}
|
174
|
-
this.elements = this.elements.concat(elements);
|
175
|
-
|
176
|
-
return this;
|
177
|
-
};
|
178
|
-
|
179
|
-
/**
|
180
|
-
* Removes all anchorjs-links from elements targed by the selector.
|
181
|
-
* @param {String|Array|Nodelist} selector - A CSS selector string targeting elements with anchor links,
|
182
|
-
* OR a nodeList / array containing the DOM elements.
|
183
|
-
* @return {this} - The AnchorJS object
|
184
|
-
*/
|
185
|
-
this.remove = function(selector) {
|
186
|
-
var index,
|
187
|
-
domAnchor,
|
188
|
-
elements = _getElements(selector);
|
189
|
-
|
190
|
-
for (var i = 0; i < elements.length; i++) {
|
191
|
-
domAnchor = elements[i].querySelector('.anchorjs-link');
|
192
|
-
if (domAnchor) {
|
193
|
-
// Drop the element from our main list, if it's in there.
|
194
|
-
index = this.elements.indexOf(elements[i]);
|
195
|
-
if (index !== -1) {
|
196
|
-
this.elements.splice(index, 1);
|
197
|
-
}
|
198
|
-
// Remove the anchor from the DOM.
|
199
|
-
elements[i].removeChild(domAnchor);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
return this;
|
203
|
-
};
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Removes all anchorjs links. Mostly used for tests.
|
207
|
-
*/
|
208
|
-
this.removeAll = function() {
|
209
|
-
this.remove(this.elements);
|
210
|
-
};
|
211
|
-
|
212
|
-
/**
|
213
|
-
* Urlify - Refine text so it makes a good ID.
|
214
|
-
*
|
215
|
-
* To do this, we remove apostrophes, replace nonsafe characters with hyphens,
|
216
|
-
* remove extra hyphens, truncate, trim hyphens, and make lowercase.
|
217
|
-
*
|
218
|
-
* @param {String} text - Any text. Usually pulled from the webpage element we are linking to.
|
219
|
-
* @return {String} - hyphen-delimited text for use in IDs and URLs.
|
220
|
-
*/
|
221
|
-
this.urlify = function(text) {
|
222
|
-
// Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\
|
223
|
-
var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g,
|
224
|
-
urlText;
|
225
|
-
|
226
|
-
// The reason we include this _applyRemainingDefaultOptions is so urlify can be called independently,
|
227
|
-
// even after setting options. This can be useful for tests or other applications.
|
228
|
-
if (!this.options.truncate) {
|
229
|
-
_applyRemainingDefaultOptions(this.options);
|
230
|
-
}
|
231
|
-
|
232
|
-
// Note: we trim hyphens after truncating because truncating can cause dangling hyphens.
|
233
|
-
// Example string: // " ⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean."
|
234
|
-
urlText = text.trim() // "⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean."
|
235
|
-
.replace(/\'/gi, '') // "⚡⚡ Dont forget: URL fragments should be i18n-friendly, hyphenated, short, and clean."
|
236
|
-
.replace(nonsafeChars, '-') // "⚡⚡-Dont-forget--URL-fragments-should-be-i18n-friendly--hyphenated--short--and-clean-"
|
237
|
-
.replace(/-{2,}/g, '-') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-short-and-clean-"
|
238
|
-
.substring(0, this.options.truncate) // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-"
|
239
|
-
.replace(/^-+|-+$/gm, '') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated"
|
240
|
-
.toLowerCase(); // "⚡⚡-dont-forget-url-fragments-should-be-i18n-friendly-hyphenated"
|
241
|
-
|
242
|
-
return urlText;
|
243
|
-
};
|
244
|
-
|
245
|
-
/**
|
246
|
-
* Determines if this element already has an AnchorJS link on it.
|
247
|
-
* Uses this technique: http://stackoverflow.com/a/5898748/1154642
|
248
|
-
* @param {HTMLElemnt} el - a DOM node
|
249
|
-
* @return {Boolean} true/false
|
250
|
-
*/
|
251
|
-
this.hasAnchorJSLink = function(el) {
|
252
|
-
var hasLeftAnchor = el.firstChild && ((' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1),
|
253
|
-
hasRightAnchor = el.lastChild && ((' ' + el.lastChild.className + ' ').indexOf(' anchorjs-link ') > -1);
|
254
|
-
|
255
|
-
return hasLeftAnchor || hasRightAnchor || false;
|
256
|
-
};
|
257
|
-
|
258
|
-
/**
|
259
|
-
* Turns a selector, nodeList, or array of elements into an array of elements (so we can use array methods).
|
260
|
-
* It also throws errors on any other inputs. Used to handle inputs to .add and .remove.
|
261
|
-
* @param {String|Array|Nodelist} input - A CSS selector string targeting elements with anchor links,
|
262
|
-
* OR a nodeList / array containing the DOM elements.
|
263
|
-
* @return {Array} - An array containing the elements we want.
|
264
|
-
*/
|
265
|
-
function _getElements(input) {
|
266
|
-
var elements;
|
267
|
-
if (typeof input === 'string' || input instanceof String) {
|
268
|
-
// See https://davidwalsh.name/nodelist-array for the technique transforming nodeList -> Array.
|
269
|
-
elements = [].slice.call(document.querySelectorAll(input));
|
270
|
-
// I checked the 'input instanceof NodeList' test in IE9 and modern browsers and it worked for me.
|
271
|
-
} else if (Array.isArray(input) || input instanceof NodeList) {
|
272
|
-
elements = [].slice.call(input);
|
273
|
-
} else {
|
274
|
-
throw new Error('The selector provided to AnchorJS was invalid.');
|
275
|
-
}
|
276
|
-
return elements;
|
277
|
-
}
|
278
|
-
|
279
|
-
/**
|
280
|
-
* _addBaselineStyles
|
281
|
-
* Adds baseline styles to the page, used by all AnchorJS links irregardless of configuration.
|
282
|
-
*/
|
283
|
-
function _addBaselineStyles() {
|
284
|
-
// We don't want to add global baseline styles if they've been added before.
|
285
|
-
if (document.head.querySelector('style.anchorjs') !== null) {
|
286
|
-
return;
|
287
|
-
}
|
288
|
-
|
289
|
-
var style = document.createElement('style'),
|
290
|
-
linkRule =
|
291
|
-
' .anchorjs-link {' +
|
292
|
-
' opacity: 0;' +
|
293
|
-
' text-decoration: none;' +
|
294
|
-
' -webkit-font-smoothing: antialiased;' +
|
295
|
-
' -moz-osx-font-smoothing: grayscale;' +
|
296
|
-
' }',
|
297
|
-
hoverRule =
|
298
|
-
' *:hover > .anchorjs-link,' +
|
299
|
-
' .anchorjs-link:focus {' +
|
300
|
-
' opacity: 1;' +
|
301
|
-
' }',
|
302
|
-
anchorjsLinkFontFace =
|
303
|
-
' @font-face {' +
|
304
|
-
' font-family: "anchorjs-icons";' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above
|
305
|
-
' src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype");' +
|
306
|
-
' }',
|
307
|
-
pseudoElContent =
|
308
|
-
' [data-anchorjs-icon]::after {' +
|
309
|
-
' content: attr(data-anchorjs-icon);' +
|
310
|
-
' }',
|
311
|
-
firstStyleEl;
|
312
|
-
|
313
|
-
style.className = 'anchorjs';
|
314
|
-
style.appendChild(document.createTextNode('')); // Necessary for Webkit.
|
315
|
-
|
316
|
-
// We place it in the head with the other style tags, if possible, so as to
|
317
|
-
// not look out of place. We insert before the others so these styles can be
|
318
|
-
// overridden if necessary.
|
319
|
-
firstStyleEl = document.head.querySelector('[rel="stylesheet"], style');
|
320
|
-
if (firstStyleEl === undefined) {
|
321
|
-
document.head.appendChild(style);
|
322
|
-
} else {
|
323
|
-
document.head.insertBefore(style, firstStyleEl);
|
324
|
-
}
|
325
|
-
|
326
|
-
style.sheet.insertRule(linkRule, style.sheet.cssRules.length);
|
327
|
-
style.sheet.insertRule(hoverRule, style.sheet.cssRules.length);
|
328
|
-
style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length);
|
329
|
-
style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length);
|
330
|
-
}
|
331
|
-
}
|
332
|
-
|
333
|
-
return AnchorJS;
|
334
|
-
}));
|
@@ -1,6 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* AnchorJS - v4.0.0 - 2017-06-02
|
3
|
-
* https://github.com/bryanbraun/anchorjs
|
4
|
-
* Copyright (c) 2017 Bryan Braun; Licensed MIT
|
5
|
-
*/
|
6
|
-
!function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";function A(A){function e(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.class=A.hasOwnProperty("class")?A.class:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64}function t(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}function n(){if(null===document.head.querySelector("style.anchorjs")){var A,e=document.createElement("style");e.className="anchorjs",e.appendChild(document.createTextNode("")),void 0===(A=document.head.querySelector('[rel="stylesheet"], style'))?document.head.appendChild(e):document.head.insertBefore(e,A),e.sheet.insertRule(" .anchorjs-link { opacity: 0; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }",e.sheet.cssRules.length),e.sheet.insertRule(" *:hover > .anchorjs-link, .anchorjs-link:focus { opacity: 1; }",e.sheet.cssRules.length),e.sheet.insertRule(" [data-anchorjs-icon]::after { content: attr(data-anchorjs-icon); }",e.sheet.cssRules.length),e.sheet.insertRule(' @font-face { font-family: "anchorjs-icons"; src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype"); }',e.sheet.cssRules.length)}}this.options=A||{},this.elements=[],e(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var i,o,s,c,r,a,h,l,u,d,f,g,p=[];if(e(this.options),"touch"===(g=this.options.visible)&&(g=this.isTouchDevice()?"always":"hover"),A||(A="h2, h3, h4, h5, h6"),0===(i=t(A)).length)return this;for(n(),o=document.querySelectorAll("[id]"),s=[].map.call(o,function(A){return A.id}),r=0;r<i.length;r++)if(this.hasAnchorJSLink(i[r]))p.push(r);else{if(i[r].hasAttribute("id"))c=i[r].getAttribute("id");else if(i[r].hasAttribute("data-anchor-id"))c=i[r].getAttribute("data-anchor-id");else{u=l=this.urlify(i[r].textContent),h=0;do{void 0!==a&&(u=l+"-"+h),a=s.indexOf(u),h+=1}while(-1!==a);a=void 0,s.push(u),i[r].setAttribute("id",u),c=u}d=c.replace(/-/g," "),(f=document.createElement("a")).className="anchorjs-link "+this.options.class,f.href="#"+c,f.setAttribute("aria-label","Anchor link for: "+d),f.setAttribute("data-anchorjs-icon",this.options.icon),"always"===g&&(f.style.opacity="1"),""===this.options.icon&&(f.style.font="1em/1 anchorjs-icons","left"===this.options.placement&&(f.style.lineHeight="inherit")),"left"===this.options.placement?(f.style.position="absolute",f.style.marginLeft="-1em",f.style.paddingRight="0.5em",i[r].insertBefore(f,i[r].firstChild)):(f.style.paddingLeft="0.375em",i[r].appendChild(f))}for(r=0;r<p.length;r++)i.splice(p[r]-r,1);return this.elements=this.elements.concat(i),this},this.remove=function(A){for(var e,n,i=t(A),o=0;o<i.length;o++)(n=i[o].querySelector(".anchorjs-link"))&&(-1!==(e=this.elements.indexOf(i[o]))&&this.elements.splice(e,1),i[o].removeChild(n));return this},this.removeAll=function(){this.remove(this.elements)},this.urlify=function(A){var t=/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g;return this.options.truncate||e(this.options),A.trim().replace(/\'/gi,"").replace(t,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&(" "+A.firstChild.className+" ").indexOf(" anchorjs-link ")>-1,t=A.lastChild&&(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ")>-1;return e||t||!1}}return A});
|
@@ -1,17 +0,0 @@
|
|
1
|
-
const fs = require('fs');
|
2
|
-
const pkg = require('./package.json');
|
3
|
-
const filename = 'anchor.min.js';
|
4
|
-
const script = fs.readFileSync(filename);
|
5
|
-
const padStart = str => ('0' + str).slice(-2)
|
6
|
-
const dateObj = new Date;
|
7
|
-
const date = `${dateObj.getFullYear()}-${padStart(dateObj.getMonth() + 1)}-${padStart(dateObj.getDate())}`;
|
8
|
-
const banner = `/**
|
9
|
-
* AnchorJS - v${pkg.version} - ${date}
|
10
|
-
* ${pkg.homepage}
|
11
|
-
* Copyright (c) ${dateObj.getFullYear()} Bryan Braun; Licensed ${pkg.license}
|
12
|
-
*/
|
13
|
-
`;
|
14
|
-
|
15
|
-
if (script.slice(0, 3) != '/**') {
|
16
|
-
fs.writeFileSync(filename, banner + script);
|
17
|
-
}
|