Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Edited README. Fixed TextContent bug. Add -min.

  • Loading branch information...
commit 26af0ec48233537823c7d04777d6cdcca178b9c7 1 parent 19a243c
Nathan Ford authored
Showing with 18 additions and 6 deletions.
  1. +4 −0 README
  2. +2 −0  widowtamer-min.js
  3. +12 −6 widowtamer.js
View
4 README
@@ -58,6 +58,10 @@ And on the same page, on the same events, we may want to fix the headers in our
event: 'resize'
});
+*Browser Support*
+
+The Widow Tamer works in IE8+ and all other modern browsers.
+
*Details*
The Widow Tamer was created by Nathan Ford. Feel free to interrupt him any time with questions, concerns, complaints, etc.
View
2  widowtamer-min.js
@@ -0,0 +1,2 @@
+// Widow Tamer JS by Nathan C. Ford http://artequalswork.com
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2={u:{B:\'p,1h,1i\',v:14,6:\'1j\',C:\'1k\',M:\'1l\'},D:N 1m(),1n:3(a){2.E(\'1o\',3(){2.O(a)})},O:3(a){5 m=a.6;1p(m){k\'8-P\':k\'Q\':k\'8-R\':k\'S-w\':k\'T-w\':k U:4(a.C==\'F\'&&m&&m.G(\'8\')){V.W(\'X 6. 1q 1r Y F 1s 8.\')}7 2.H(a);11;1t:V.W(\'X 6. 1u Y 1v 8-P, 8-R, S-w, 1w T-w.\')}},H:3(a){5 b=N 1x();4(a){1y(i 1z 2.u){4(a[i])b[i]=(i==\'6\'&&a[i].G(\'-\'))?2.12(a[i]):a[i];7 b[i]=2.u[i]}}7 b=2.u;5 d=13.1A(b.B),i=0;15(i<d.I){5 t=d[i];4(t.J>2.16(t,\'1B-1C\',17)){5 e=t.1D,j=e.I-1,c=1E;15(j>=0){5 f=2.x(e[j]);4(f!=U&&f.I>b.v){c=e[j];11}j--}t.18[b.6]=\'0\';5 g=2.x(c);4(c)2.K(c,t,g,0,b)}i++}2.E(b.M,3(){2.19(b)})},x:3(t){l t.L||t.1a},o:3(e,t){4(e.L)e.L=t;7 e.1a=t},K:3(c,t,a,i,b){5 h=t.J;2.o(c,a.1b(0,(b.v*-1)));4(t.J<h){4(b.6==\'Q\')2.o(c,2.x(c)+a.1b((b.v*-1)).q(/\\s/g,\'\\1F\'));7{5 d=(b.6.G(\'8\'))?(i/10):(i/1G);4(b.C==\'F\')d=d*-1;t.18[b.6]=d+\'1H\';2.o(c,a);2.K(c,t,a,i+1,b)}}7 2.o(c,a)},19:3(a){5 b="\'"+a.B.q(/[^a-1c-1I-9\\-\\.]/g,\'\')+"\'";1J(2.D[b]);2.D[b]=1K(3(){2.H(a)},1L)},E:3(e,f){4(y.1d)y.1d(\'1M\'+e,f);7 y.1N(e,f,17)},12:3(s){l s.q(/-([a-1c-Z])/,3(m){l m.q(\'-\',\'\').1e()})},16:3(t,s,n){5 r;4(t.1f)r=t.1f[s.q(/-([A-z])/1O,3(a,b){l b.1e()})];7 4(y.1g)r=13.1P.1g(t,1Q).1R(s);4(n)l 1S(r);7 l r}};',62,117,'||wt|function|if|var|method|else|padding||||||||||||case|return|||settext||replace||||opts|chars|spacing|text|window|||elements|dir|to|bind|neg|match|hunter|length|offsetHeight|tamer|innerText|event|new|init|right|nbsp|left|word|letter|undefined|console|log|Invalid|use|||break|fixmethod|document||while|getstyle|true|style|onevent|textContent|slice|zA|attachEvent|toUpperCase|currentStyle|getComputedStyle|li|dd|wordSpacing|pos|orientationchange|Array|fix|load|switch|You|cannot|with|default|Please|either|or|Object|for|in|querySelectorAll|line|height|childNodes|false|u00a0|100|em|Z0|clearTimeout|setTimeout|250|on|addEventListener|gi|defaultView|null|getPropertyValue|parseFloat'.split('|'),0,{}))
View
18 widowtamer.js
@@ -102,17 +102,23 @@ wt = {
return t.innerText || t.textContent;
},
+
+ settext : function (e, t) {
+
+ if (e.innerText) e.innerText = t;
+ else e.textContent = t;
+
+ },
tamer : function (c, t, text, i, opts) {
-
+
var h = t.offsetHeight;
- c.innerHTML = text.slice(0, (opts.chars * -1));
+ wt.settext(c, text.slice(0, (opts.chars * -1)));
if (t.offsetHeight < h) {
- if (opts.method == 'nbsp')
- c.innerHTML = wt.text( c ) + text.slice((opts.chars * -1)).replace(/\s/g, '&nbsp;');
+ if (opts.method == 'nbsp') wt.settext(c, wt.text( c ) + text.slice((opts.chars * -1)).replace(/\s/g, '\u00a0'));
else {
@@ -122,14 +128,14 @@ wt = {
t.style[opts.method] = inc + 'em';
- c.innerHTML = text;
+ wt.settext(c, text);
wt.tamer(c, t, text, i + 1, opts);
}
}
- else c.innerHTML = text;
+ else wt.settext(c, text);
},
Please sign in to comment.
Something went wrong with that request. Please try again.