-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathjquery.exdent.min.js
4 lines (4 loc) · 1.08 KB
/
jquery.exdent.min.js
1
2
3
4
/*jQuery exdent - hanging punctuation
Copyright (c) 2011 Manuel Strehl, http://www.manuel-strehl.de
Published under MIT and GPL license
*/(function(a){var b={};a.fn.exdent=function(c){c=a.extend({by:".5em",detect:!1,className:"exdented"},c),c.detect===!0&&(c.detect="“");return this.each(function(){var d=a(this),e=0,f,g,h,i;c.detect?(h=d.css("fontWeight")+" "+d.css("fontSize")+" "+d.css("fontFamily")+" "+c.detect,h in b||(g=a("<span>"+c.detect+"</span>").prependTo(this),b[h]=g.width(),g.remove()),f=b[h]):(g=a('<span style="display:inline-block"></span>').css("width",c.by).prependTo(this),f=g.width(),g.remove()),g=null,g=a('<span style="display:inline"> </span>').prependTo(this),e=g.offset().left,g.remove(),g=null,d.prev("br._exdent_helper").remove(),e-f-1<=d.parent().offset().left?(i=d.offset().top,d.css("marginLeft",-f).addClass(c.className),i!==d.offset().top&&d.before('<br class="_exdent_helper"/>')):d.css("marginLeft","0").removeClass(c.className)})},a.cssHooks&&(a.cssHooks.exdent={get:function(b,c,d){return a.css(b,marginLeft)},set:function(b,c){a(b).exdent({by:c})}})})(jQuery)