Skip to content

Commit

Permalink
fix(codestyle): codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Feb 28, 2016
1 parent 1524a00 commit 8f6a157
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"quotes": 0,
"no-param-reassign": [2, {"props": false}],
"max-len": [2, 120, 4],
"strict": [
2,
"global"
Expand Down
17 changes: 10 additions & 7 deletions build/js/marklib.js

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

2 changes: 1 addition & 1 deletion build/js/marklib.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/marklib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/marklib.min.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions build/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,16 @@ return /******/ (function(modules) { // webpackBootstrap
outer = outer[outer.length - 1];
var contextContainer = outer ? outer : commonAncestor;

// Same Element, means the selection is fully contained in a discrete area, start and endpoint have the same parent
// Same Element, means the selection is fully contained in a discrete area,
// start and endpoint have the same parent
// but are different nodes:

// Start and End offset have to be recalculated because dom might be already changed by highlighting in given node
// Start and End offset have to be recalculated because dom might be already changed by
// highlighting in given node
// 1: First detect real start offset in startContainer:

// That works by selecting the highest wrapper and get original-offset-start data element, see "findOriginalOffset"
// That works by selecting the highest wrapper and get original-offset-start data element,
// see "findOriginalOffset"
// So first select that container:
var originalStartOffset = _Util2.default.findOriginalOffset(startContainer);
var originalEndOffset = _Util2.default.findOriginalOffset(endContainer);
Expand Down Expand Up @@ -3481,17 +3484,17 @@ return /******/ (function(modules) { // webpackBootstrap

/**
* Generates a unique id
*
* @return {String}
*/

}, {
key: 'guid',
value: function guid() {
var s4 = function s4() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
};
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}

return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + (s4() + s4() + s4());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion build/js/site.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/site.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/site.min.map

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/main/Rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,16 @@ class Rendering extends RenderingEvents {
outer = outer[outer.length - 1];
const contextContainer = outer ? outer : commonAncestor;

// Same Element, means the selection is fully contained in a discrete area, start and endpoint have the same parent
// Same Element, means the selection is fully contained in a discrete area,
// start and endpoint have the same parent
// but are different nodes:

// Start and End offset have to be recalculated because dom might be already changed by highlighting in given node
// Start and End offset have to be recalculated because dom might be already changed by
// highlighting in given node
// 1: First detect real start offset in startContainer:

// That works by selecting the highest wrapper and get original-offset-start data element, see "findOriginalOffset"
// That works by selecting the highest wrapper and get original-offset-start data element,
// see "findOriginalOffset"
// So first select that container:
const originalStartOffset = Util.findOriginalOffset(startContainer);
const originalEndOffset = Util.findOriginalOffset(endContainer);
Expand Down Expand Up @@ -463,7 +466,7 @@ class Rendering extends RenderingEvents {
}

// Get the last text node:
const endContainerContents = Util.closest(toFindNode, ':not([' + DATA_IS_SELECTION + '])').childNodes;
const endContainerContents = Util.closest(toFindNode, `:not([${DATA_IS_SELECTION}])`).childNodes;
if (endContainerContents.length) {
const r = endContainerContents[endContainerContents.length - 1];
if (r.nodeType === Node.TEXT_NODE) {
Expand Down
24 changes: 11 additions & 13 deletions src/main/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ class Util {

/**
* Generates a unique id
*
* @return {String}
*/
static guid() {
const s4 = () => {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}

return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
}

/**
Expand Down Expand Up @@ -132,7 +131,8 @@ class Util {
break;
}
// reset index when original index is found
const maybeIndexOfOriginal = el.getAttribute ? el.getAttribute(ATTR_DATA_ORIGINAL_INDEX) : null;
const maybeIndexOfOriginal = el.getAttribute ?
el.getAttribute(ATTR_DATA_ORIGINAL_INDEX) : null;

if (maybeIndexOfOriginal) {
calculatedIndex = parseInt(maybeIndexOfOriginal, 10);
Expand Down Expand Up @@ -264,9 +264,7 @@ class Util {
let path = null;
let node = el;

const filterSiblings = (thisEl) => {
return !Util.isMarkNode(thisEl) && thisEl.nodeName === node.nodeName;
};
const filterSiblings = (thisEl) => !Util.isMarkNode(thisEl) && thisEl.nodeName === node.nodeName;

while (node) {
let name = null;
Expand All @@ -279,7 +277,7 @@ class Util {

// Extract original index of this node:
// Outer most data-original-index is original index
const outerMostElement = Util.parents(node, '[' + ATTR_DATA_ORIGINAL_INDEX + ']').reverse()[0];
const outerMostElement = Util.parents(node, `[${ATTR_DATA_ORIGINAL_INDEX}]`).reverse()[0];
// if element is not yet wrapped in span, recalculate index based on parent container:
// We have to do this because text node indexes != element indexes...
let calculatedIndex = 0;
Expand Down Expand Up @@ -316,10 +314,10 @@ class Util {
const nodeIndex = Util.index(node, siblings);

if (siblings.length > 1 && nodeIndex >= 0) {
name += ':nth-of-type(' + (nodeIndex + 1) + ')';
name += `:nth-of-type(${(nodeIndex + 1)})`;
}

path = name + (path ? '>' + path : '');
path = name + (path ? `>${path}` : '');


if (parent === context) {
Expand All @@ -342,7 +340,7 @@ class Util {
if (!element.parentNode.hasAttribute(ATTR_DATA_ORIGINAL_OFFSET_START)) {
return 0;
}
const lengthElement = Util.parent(element, '[' + ATTR_DATA_ORIGINAL_OFFSET_START + ']');
const lengthElement = Util.parent(element, `[${ATTR_DATA_ORIGINAL_OFFSET_START}]`);
return lengthElement ? parseInt(lengthElement.getAttribute(ATTR_DATA_ORIGINAL_OFFSET_START), 10) : 0;
}

Expand Down

0 comments on commit 8f6a157

Please sign in to comment.