Skip to content

Commit

Permalink
⬆️ release version 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanbraun committed Jan 18, 2023
1 parent cddcae2 commit 7f0f6a5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
4 changes: 2 additions & 2 deletions anchor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anchor-js",
"version": "4.3.1",
"version": "5.0.0",
"authors": [
"Bryan Braun"
],
Expand Down
24 changes: 4 additions & 20 deletions docs/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* globals module:false */

// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
(function(root, factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
Expand All @@ -18,7 +18,7 @@
root.AnchorJS = factory();
root.anchors = new root.AnchorJS();
}
}(this, function () {
}(globalThis, function() {
'use strict';

function AnchorJS(options) {
Expand All @@ -31,7 +31,7 @@
*/
function _applyRemainingDefaultOptions(opts) {
opts.icon = Object.prototype.hasOwnProperty.call(opts, 'icon') ? opts.icon : '\uE9CB'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
opts.visible = Object.prototype.hasOwnProperty.call(opts, 'visible') ? opts.visible : 'hover'; // Also accepts 'always' & 'touch'
opts.visible = Object.prototype.hasOwnProperty.call(opts, 'visible') ? opts.visible : 'hover'; // Also accepts 'always'
opts.placement = Object.prototype.hasOwnProperty.call(opts, 'placement') ? opts.placement : 'right'; // Also accepts 'left'
opts.ariaLabel = Object.prototype.hasOwnProperty.call(opts, 'ariaLabel') ? opts.ariaLabel : 'Anchor'; // Accepts any text.
opts.class = Object.prototype.hasOwnProperty.call(opts, 'class') ? opts.class : ''; // Accepts any class name.
Expand All @@ -43,15 +43,6 @@

_applyRemainingDefaultOptions(this.options);

/**
* Checks to see if this device supports touch. Uses criteria pulled from Modernizr:
* https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40
* @return {Boolean} - true if the current device supports touch.
*/
this.isTouchDevice = function() {
return Boolean('ontouchstart' in window || window.TouchEvent || window.DocumentTouch && document instanceof DocumentTouch);
};

/**
* Add anchor links to page elements.
* @param {String|Array|Nodelist} selector - A CSS selector for targeting the elements you wish to add anchor links
Expand All @@ -69,7 +60,6 @@
tidyText,
newTidyText,
anchor,
visibleOptionToUse,
hrefBase,
indexesToDrop = [];

Expand All @@ -79,11 +69,6 @@
// anchors.options = { visible: 'always'; }
_applyRemainingDefaultOptions(this.options);

visibleOptionToUse = this.options.visible;
if (visibleOptionToUse === 'touch') {
visibleOptionToUse = this.isTouchDevice() ? 'always' : 'hover';
}

// Provide a sensible default selector, if none is given.
if (!selector) {
selector = 'h2, h3, h4, h5, h6';
Expand Down Expand Up @@ -156,7 +141,7 @@
hrefBase = this.options.base || hrefBase;
anchor.href = hrefBase + '#' + elementID;

if (visibleOptionToUse === 'always') {
if (this.options.visible === 'always') {
anchor.style.opacity = '1';
}

Expand Down Expand Up @@ -291,7 +276,6 @@
if (typeof input === 'string' || input instanceof String) {
// See https://davidwalsh.name/nodelist-array for the technique transforming nodeList -> Array.
elements = [].slice.call(document.querySelectorAll(input));
// I checked the 'input instanceof NodeList' test in IE9 and modern browsers and it worked for me.
} else if (Array.isArray(input) || input instanceof NodeList) {
elements = [].slice.call(input);
} else {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anchor-js",
"version": "4.3.1",
"version": "5.0.0",
"main": "anchor.js",
"author": "Bryan Braun (https://github.com/bryanbraun)",
"description": "A JavaScript utility for adding deep anchor links to online docs.",
Expand Down

0 comments on commit 7f0f6a5

Please sign in to comment.