|
6 | 6 | /* eslint-env amd, node */ |
7 | 7 |
|
8 | 8 | // https://github.com/umdjs/umd/blob/master/templates/returnExports.js |
9 | | -(function(root, factory) { |
| 9 | +(function (root, factory) { |
10 | 10 | 'use strict'; |
11 | 11 | if (typeof define === 'function' && define.amd) { |
12 | 12 | // AMD. Register as an anonymous module. |
|
21 | 21 | root.AnchorJS = factory(); |
22 | 22 | root.anchors = new root.AnchorJS(); |
23 | 23 | } |
24 | | -})(this, function() { |
| 24 | +})(this, function () { |
25 | 25 | 'use strict'; |
26 | 26 | function AnchorJS(options) { |
27 | 27 | this.options = options || {}; |
|
51 | 51 | * https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40 |
52 | 52 | * @returns {Boolean} - true if the current device supports touch. |
53 | 53 | */ |
54 | | - this.isTouchDevice = function() { |
| 54 | + this.isTouchDevice = function () { |
55 | 55 | return !!( |
56 | 56 | 'ontouchstart' in window || |
57 | 57 | (window.DocumentTouch && document instanceof DocumentTouch) |
|
64 | 64 | * to. Also accepts an array or nodeList containing the relavant elements. |
65 | 65 | * @returns {this} - The AnchorJS object |
66 | 66 | */ |
67 | | - this.add = function(selector) { |
| 67 | + this.add = function (selector) { |
68 | 68 | var elements, |
69 | 69 | elsWithIds, |
70 | 70 | idList, |
|
193 | 193 | * OR a nodeList / array containing the DOM elements. |
194 | 194 | * @returns {this} - The AnchorJS object |
195 | 195 | */ |
196 | | - this.remove = function(selector) { |
| 196 | + this.remove = function (selector) { |
197 | 197 | var index, |
198 | 198 | domAnchor, |
199 | 199 | elements = _getElements(selector); |
|
216 | 216 | /** |
217 | 217 | * Removes all anchorjs links. Mostly used for tests. |
218 | 218 | */ |
219 | | - this.removeAll = function() { |
| 219 | + this.removeAll = function () { |
220 | 220 | this.remove(this.elements); |
221 | 221 | }; |
222 | 222 |
|
|
229 | 229 | * @param {String} text - Any text. Usually pulled from the webpage element we are linking to. |
230 | 230 | * @returns {String} - hyphen-delimited text for use in IDs and URLs. |
231 | 231 | */ |
232 | | - this.urlify = function(text) { |
| 232 | + this.urlify = function (text) { |
233 | 233 | // Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\ |
234 | 234 | var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g, |
235 | 235 | urlText; |
|
260 | 260 | * @param {HTMLElemnt} el - a DOM node |
261 | 261 | * @returns {Boolean} true/false |
262 | 262 | */ |
263 | | - this.hasAnchorJSLink = function(el) { |
| 263 | + this.hasAnchorJSLink = function (el) { |
264 | 264 | var hasLeftAnchor = |
265 | 265 | el.firstChild && |
266 | 266 | (' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1, |
|
0 commit comments