Comparing version 1.0.1 to 1.0.2
@@ -67,3 +67,3 @@ (function (global, factory) { | ||
el.insertAdjacentHTML('beforeend', charHtml); | ||
var diff = spaces ? words.slice(max + 1).join(' ') : words.slice(max); | ||
var diff = spaces ? words.slice(max).join(' ') : words.slice(max); | ||
@@ -89,2 +89,2 @@ el.insertAdjacentHTML('beforeend', '<span class="' + classname + '" style="display:none;">' + diff + '</span>'); | ||
}))); | ||
}))); |
/** | ||
* shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height | ||
* @version v1.0.0 | ||
* @version v1.0.2 | ||
* @link https://github.com/dollarshaveclub/shave#readme | ||
* @author Jeff Wainwright <jjwainwright2@gmail.com> (jeffry.in) | ||
* @license ISC */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.shave=t()}(this,function(){"use strict";function e(e,t,n){if(!t)throw Error("maxHeight is required");var s="string"==typeof e?document.querySelectorAll(e):e;"length"in s||(s=[s]);for(var i={character:"…",classname:"js-shave",spaces:!0},a=n&&n.character||i.character,r=n&&n.classname||i.classname,o=(!n||n.spaces!==!1)&&i.spaces,c='<span class="js-shave-char">'+a+"</span>",l=0;l<s.length;l++){var h=s[l],f=h.querySelector("."+r),d=void 0===h.textContent?"innerText":"textContent";f&&(h.removeChild(h.querySelector(".js-shave-char")),h[d]=h[d]);var u=h[d],y=o?u.split(" "):u;if(!(y.length<2)){var p=h.style.height;h.style.height="auto";var v=h.style.maxHeight;if(h.style.maxHeight="none",h.offsetHeight<t)h.style.height=p,h.style.maxHeight=v;else{for(var g=y.length-1,m=0,j=void 0;m<g;)j=m+g+1>>1,h[d]=o?y.slice(0,j).join(" "):y.slice(0,j),h.insertAdjacentHTML("beforeend",c),h.offsetHeight>t?g=o?j-1:j-2:m=j;h[d]=o?y.slice(0,g).join(" "):y.slice(0,g),h.insertAdjacentHTML("beforeend",c);var x=o?y.slice(g+1).join(" "):y.slice(g);h.insertAdjacentHTML("beforeend",'<span class="'+r+'" style="display:none;">'+x+"</span>"),h.style.height=p,h.style.maxHeight=v}}}}if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.shave=function(t,n){return e(this,t,n),this})}return e}); | ||
* @license MIT */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.shave=t()}(this,function(){"use strict";function e(e,t,n){if(!t)throw Error("maxHeight is required");var s="string"==typeof e?document.querySelectorAll(e):e;"length"in s||(s=[s]);for(var i={character:"…",classname:"js-shave",spaces:!0},a=n&&n.character||i.character,r=n&&n.classname||i.classname,o=(!n||n.spaces!==!1)&&i.spaces,c='<span class="js-shave-char">'+a+"</span>",l=0;l<s.length;l++){var h=s[l],f=h.querySelector("."+r),d=void 0===h.textContent?"innerText":"textContent";f&&(h.removeChild(h.querySelector(".js-shave-char")),h[d]=h[d]);var u=h[d],y=o?u.split(" "):u;if(!(y.length<2)){var p=h.style.height;h.style.height="auto";var v=h.style.maxHeight;if(h.style.maxHeight="none",h.offsetHeight<t)h.style.height=p,h.style.maxHeight=v;else{for(var g=y.length-1,m=0,j=void 0;m<g;)j=m+g+1>>1,h[d]=o?y.slice(0,j).join(" "):y.slice(0,j),h.insertAdjacentHTML("beforeend",c),h.offsetHeight>t?g=o?j-1:j-2:m=j;h[d]=o?y.slice(0,g).join(" "):y.slice(0,g),h.insertAdjacentHTML("beforeend",c);var x=o?y.slice(g).join(" "):y.slice(g);h.insertAdjacentHTML("beforeend",'<span class="'+r+'" style="display:none;">'+x+"</span>"),h.style.height=p,h.style.maxHeight=v}}}}if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.shave=function(t,n){return e(this,t,n),this})}return e}); |
{ | ||
"name": "shave", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height", | ||
@@ -5,0 +5,0 @@ "main": "dist/shave.js", |
@@ -63,3 +63,3 @@ | ||
el.insertAdjacentHTML('beforeend', charHtml); | ||
const diff = spaces ? words.slice(max + 1).join(' ') : words.slice(max); | ||
const diff = spaces ? words.slice(max).join(' ') : words.slice(max); | ||
@@ -66,0 +66,0 @@ el.insertAdjacentHTML('beforeend', |
145
14119