diff --git a/README.md b/README.md
index ce2f2f4..1b52af4 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ Here is a simple Balance Text setup:
See the demo provided or [this online version for a working sample](http://adobe-webplatform.github.io/balance-text/demo/index.html).
-Balance Text will *automatically* run on any elements with .balance-text
class:
+Balance Text will *automatically* run on any elements with balance-text
class:
- when the page loads (DOM Ready event)
- when it is resized
@@ -46,11 +46,18 @@ If you need to manually re-balance all triggered elements, use:
$.balanceTextUpdate();
```
+To Balance Text and have it automatically update on resize, use:
+
+```
+ $.balanceText('.my-class');
+```
+
+
## Use from a CDN
-[//cdnjs.cloudflare.com/ajax/libs/balance-text/1.6.0/jquery.balancetext.min.js](//cdnjs.cloudflare.com/ajax/libs/balance-text/1.6.0/jquery.balancetext.min.js)
+[//cdnjs.cloudflare.com/ajax/libs/balance-text/2.0.0/jquery.balancetext.min.js](//cdnjs.cloudflare.com/ajax/libs/balance-text/2.0.0/jquery.balancetext.min.js)
-[//cdn.jsdelivr.net/jquery.balancetext/1.6.0/jquery.balancetext.min.js](//cdn.jsdelivr.net/jquery.balancetext/1.6.0/jquery.balancetext.min.js)
+[//cdn.jsdelivr.net/jquery.balancetext/2.0.0/jquery.balancetext.min.js](//cdn.jsdelivr.net/jquery.balancetext/2.0.0/jquery.balancetext.min.js)
## Requirements
BalanceText is designed to run in most common browsers and implemented as a jQuery plugin. This means that the standard jQuery library is required for it to work. This plugin was last updated using jQuery 1.9.1, but it should work with all newer (and some older) versions of jQuery.
@@ -68,3 +75,4 @@ Code is minified using: http://marijnhaverbeke.nl/uglifyjs
* v 1.5.0 - Re-balance text on resize for manually triggered selectors (rileyjshaw)
* v 1.6.x - Add balanceTextUpdate() method (rileyjshaw), bug fixes (bfred-it)
* v 1.7.0 - Hack for partially working with jQuery 3, remove deprecation warning
+* v 2.0.0 - Fix automatic updating of custom selectors for jQuery 3 (bfred-it)
diff --git a/bower.json b/bower.json
index 02e66e3..c8b43e2 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "balance-text",
- "version": "1.7.0",
+ "version": "2.0.0",
"authors": [
"Adobe Systems, Inc. "
],
diff --git a/jquery.balancetext.min.js b/jquery.balancetext.min.js
index 4899ffa..38404cf 100644
--- a/jquery.balancetext.min.js
+++ b/jquery.balancetext.min.js
@@ -1 +1 @@
-!function(a,b){"use strict";var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){"use strict";function e(){this.reset()}var d,b=document.documentElement.style,c=b.textWrap||b.WebkitTextWrap||b.MozTextWrap||b.MsTextWrap||b.OTextWrap;e.prototype.reset=function(){this.index=0,this.width=0};var f=function(a,b){var e,c=/\s(?![^<]*>)/g;if(!d)for(d=[];null!==(e=c.exec(a));)d.push(e.index);return-1!==d.indexOf(b)},g=function(b){b.find('br[data-owner="balance-text"]').replaceWith(" ");var c=b.find('span[data-owner="balance-text"]');if(c.length>0){var d="";c.each(function(){d+=a(this).text(),a(this).remove()}),b.html(d)}},h=function(a){return b=a.get(0).currentStyle||window.getComputedStyle(a.get(0),null),"justify"===b.textAlign},i=function(b,c,d){c=a.trim(c);var e=c.split(" ").length;if(c+=" ",2>e)return c;var f=a("").html(c);b.append(f);var g=f.width();f.remove();var h=Math.floor((d-g)/(e-1));return f.css("word-spacing",h+"px").attr("data-owner","balance-text"),a("").append(f).html()},j=function(a,b){return 0===b||b===a.length||f(a,b-1)&&!f(a,b)},k=function(a,b,c,d,e,f,g){var h;if(b&&"string"==typeof b)for(;;){for(;!j(b,f);)f+=e;if(a.html(b.substr(0,f)),h=a.width(),0>e?d>=h||0>=h||0===f:h>=d||h>=c||f===b.length)break;f+=e}g.index=f,g.width=h},l=function(a,b){var c=document.createElement("div");c.style.display="block",c.style.position="absolute",c.style.bottom=0,c.style.right=0,c.style.width=0,c.style.height=0,c.style.margin=0,c.style.padding=0,c.style.visibility="hidden",c.style.overflow="hidden";var d=document.createElement("span");d.style.fontSize="2000px",d.innerHTML=" ",c.appendChild(d),a.append(c);var e=d.getBoundingClientRect();c.parentNode.removeChild(c);var f=e.height/e.width;return b/f},m=[".balance-text"],n=function(){var b=m.join(",");a(b).balanceText(!0)};a.fn.balanceTextUpdate=n,a.fn.balanceText=function(b){var f=this.selector;return!b&&f&&-1===m.indexOf(f)&&m.push(f),c?this:this.each(function(){var b=a(this),c=5e3;g(b);var f=this.style.whiteSpace,j=this.style["float"],m=this.style.display,n=this.style.position,o=this.style.lineHeight;b.css("line-height","normal");var p=b.width(),q=b.height();b.css({"white-space":"nowrap","float":"none",display:"inline",position:"static"});var r=b.width(),s=b.height(),t="pre-wrap"===f?0:l(b,s);if(p>0&&r>p&&c>r){for(var u=b.html(),v="",w="",x=h(b),y=Math.round(q/s),z=y;z>1;){d=null;var A=Math.round((r+t)/z-t),B=Math.round((u.length+1)/z)-1,C=new e;k(b,u,p,A,-1,B,C);var D=new e;B=C.index,k(b,u,p,A,1,B,D),C.reset(),B=D.index,k(b,u,p,A,-1,B,C);var E;E=0===C.index?D.index:p'),u=u.substr(E),z--,b.html(u),r=b.width()}x?b.html(v+i(b,u,p)):b.html(v+u)}this.style.whiteSpace=f,this.style["float"]=j,this.style.display=m,this.style.position=n,this.style.lineHeight=o})},a(window).ready(n),a(window).smartresize(n)}(jQuery);
\ No newline at end of file
+!function(a,b){"use strict";var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){"use strict";function e(){this.reset()}var d,b=document.documentElement.style,c=b.textWrap||b.WebkitTextWrap||b.MozTextWrap||b.MsTextWrap||b.OTextWrap;e.prototype.reset=function(){this.index=0,this.width=0};var f=function(a,b){var e,c=/\s(?![^<]*>)/g;if(!d)for(d=[];null!==(e=c.exec(a));)d.push(e.index);return-1!==d.indexOf(b)},g=function(b){b.find('br[data-owner="balance-text"]').replaceWith(" ");var c=b.find('span[data-owner="balance-text"]');if(c.length>0){var d="";c.each(function(){d+=a(this).text(),a(this).remove()}),b.html(d)}},h=function(a){return b=a.get(0).currentStyle||window.getComputedStyle(a.get(0),null),"justify"===b.textAlign},i=function(b,c,d){c=a.trim(c);var e=c.split(" ").length;if(c+=" ",2>e)return c;var f=a("").html(c);b.append(f);var g=f.width();f.remove();var h=Math.floor((d-g)/(e-1));return f.css("word-spacing",h+"px").attr("data-owner","balance-text"),a("").append(f).html()},j=function(a,b){return 0===b||b===a.length||f(a,b-1)&&!f(a,b)},k=function(a,b,c,d,e,f,g){var h;if(b&&"string"==typeof b)for(;;){for(;!j(b,f);)f+=e;if(a.html(b.substr(0,f)),h=a.width(),0>e?d>=h||0>=h||0===f:h>=d||h>=c||f===b.length)break;f+=e}g.index=f,g.width=h},l=function(a,b){var c=document.createElement("div");c.style.display="block",c.style.position="absolute",c.style.bottom=0,c.style.right=0,c.style.width=0,c.style.height=0,c.style.margin=0,c.style.padding=0,c.style.visibility="hidden",c.style.overflow="hidden";var d=document.createElement("span");d.style.fontSize="2000px",d.innerHTML=" ",c.appendChild(d),a.append(c);var e=d.getBoundingClientRect();c.parentNode.removeChild(c);var f=e.height/e.width;return b/f},m={sel:[".balance-text"],$el:a()},n=function(){m.$el.add(m.sel.join(",")).balanceText()};a.fn.balanceTextUpdate=n,a.balanceText=function(b){"string"==typeof b?m.sel.push(b):m.$el=m.$el.add(b),a(b).balanceText()},a.fn.balanceText=function(){return c?this:this.each(function(){var b=a(this),c=5e3;g(b);var f=this.style.whiteSpace,j=this.style["float"],m=this.style.display,n=this.style.position,o=this.style.lineHeight;b.css("line-height","normal");var p=b.width(),q=b.height();b.css({"white-space":"nowrap","float":"none",display:"inline",position:"static"});var r=b.width(),s=b.height(),t="pre-wrap"===f?0:l(b,s);if(p>0&&r>p&&c>r){for(var u=b.html(),v="",w="",x=h(b),y=Math.round(q/s),z=y;z>1;){d=null;var A=Math.round((r+t)/z-t),B=Math.round((u.length+1)/z)-1,C=new e;k(b,u,p,A,-1,B,C);var D=new e;B=C.index,k(b,u,p,A,1,B,D),C.reset(),B=D.index,k(b,u,p,A,-1,B,C);var E;E=0===C.index?D.index:p'),u=u.substr(E),z--,b.html(u),r=b.width()}x?b.html(v+i(b,u,p)):b.html(v+u)}this.style.whiteSpace=f,this.style["float"]=j,this.style.display=m,this.style.position=n,this.style.lineHeight=o})},a(window).ready(n),a(window).smartresize(n)}(jQuery);
\ No newline at end of file
diff --git a/package.json b/package.json
index b0a51fa..d09ff3e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "balance-text",
- "version": "1.7.0",
+ "version": "2.0.0",
"filename": "jquery.balancetext.min.js",
"homepage": "https://github.com/adobe-webplatform/balance-text",
"description": "A jQuery plugin for implementing balancing of text across lines in a web page",