Skip to content

Commit

Permalink
changed some names
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Oct 2, 2017
1 parent 99582ec commit 216d951
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
10 changes: 5 additions & 5 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ function reset() {
loremIpsum.innerText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis lorem ut libero malesuada feugiat. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed porttitor lectus nibh. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
}

function uno() {
function oneRow() {
reset();
ellipsis('.text p', 1);
}

function due() {
function twoRows() {
reset();
ellipsis('.text p', 2);
}

function tre() {
function threeRows() {
reset();
ellipsis('.text p', 3);
}

function quattro() {
function fourRows() {
reset();
ellipsis('.text p', 4);
}

function cinque() {
function fiveRows() {
reset();
ellipsis('.text p', 5);
}
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ <h1>Ellipsed Text Testing</h1>
</div>
<div class="controls">
<button class="btn reset" onclick="reset()">Reset</button>
<button class="btn" onclick="uno()">1</button>
<button class="btn" onclick="due()">2</button>
<button class="btn" onclick="tre()">3</button>
<button class="btn" onclick="quattro()">4</button>
<button class="btn" onclick="cinque()">5</button>
<button class="btn" onclick="oneRow()">1</button>
<button class="btn" onclick="twoRows()">2</button>
<button class="btn" onclick="threeRows()">3</button>
<button class="btn" onclick="fourRows()">4</button>
<button class="btn" onclick="fiveRows()">5</button>
</div>
</div>
<div class="view-on-github">
Expand Down
10 changes: 4 additions & 6 deletions lib/ellipsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
newHeight = elStyle.height;

if (newRowsWrapped === rowsLimit + 1) {
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.' ? textBeforeWrap + '..' : '' + textBeforeWrap + options.replaceStr;
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.' && options.replaceStr === '...' ? textBeforeWrap + '..' : '' + textBeforeWrap + options.replaceStr;

return _extends({}, acc, { elHeight: newHeight, rowsWrapped: newRowsWrapped });
}
Expand All @@ -78,13 +78,11 @@
var rows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var options = arguments[2];

// Setup default options
var opts = {
replaceStr: "..."
var defaultOptions = {
replaceStr: '...'
};

// Override options with any new values if defined
opts = _extends({}, opts, options);
var opts = _extends({}, defaultOptions, options);

var elements = document.querySelectorAll(selector);

Expand Down
10 changes: 4 additions & 6 deletions src/ellipsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function tokensReducer(acc, token) {
newHeight = elStyle.height;

if (newRowsWrapped === rowsLimit + 1) {
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.'
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.' && options.replaceStr === '...'
? `${textBeforeWrap}..`
: `${textBeforeWrap}${options.replaceStr}`;

Expand All @@ -41,13 +41,11 @@ function tokensReducer(acc, token) {
}

function ellipsis(selector = '', rows = 1, options) {
// Setup default options
let opts = {
replaceStr : "..."
let defaultOptions = {
replaceStr : '...',
};

// Override options with any new values if defined
opts = { ...opts, ...options };
let opts = { ...defaultOptions, ...options };

const elements = document.querySelectorAll(selector);

Expand Down

0 comments on commit 216d951

Please sign in to comment.