jquery.readtime/build/jquery.readtime.min.js
Josh Sherman ca545cfc33 Gruntified and added more options
Ability to configure if you compensate for images as well as being able to
adjust the number of words per minute being used. Closes #1
2014-09-03 22:04:59 -04:00

2 lines
No EOL
548 B
JavaScript

/*! jquery.readtime 2014-09-03 */
!function(a){a.fn.readtime=function(b){var c={"class":"readtime",format:"# min read",images:12,wpm:275,wrapper:"time"};return b=a.extend(c,b),this.each(function(){var c=this.textContent||this.innerText||"",d=c.replace(/(^\s*)|(\s*$)/gi,"").replace(/[ ]{2,}/gi," ").replace(/\n /,"\n").split(" ").length,e=d/b.wpm*60;b.images&&(e+=a(this).find("img").length*b.images),e=Math.round(e/60),e=b.format.replace(/#/,e);var f=document.createElement(b.wrapper);a(f).addClass(b.class).html(e).prependTo(a(this))})}}(jQuery);