/*! jquery.emphasis.js 0.2.1 06-01-2017 */ !function(a){function b(a,b,c){this.markInfo=a,this.$el=b,this.styleNames=c,this.setEmphasis()}var c,d="9a91ab9b8e64d2cf7fce0616b66efbaf",e="inline-block"+d,f="inline"+d,g="scale"+d,h="over"+d,i="under"+d,j={over:h,under:i},k=0,l={dot:["•","◦"],circle:["●","○"],"double-circle":["◉","◎"],triangle:["▲","△"],sesame:["﹅","﹆"]},m={" ":1," ":1,"፡":1,"တ0":1,"တ1":1,"္F":1,"႑F":1,"་":1,"༌":1,"​":1," ":1," ":1," ":1,"\0":1," ":1,"\n":1,"\r":1,"…":1},n={style:1,script:1,textarea:1,input:1},o=/['"]([^'"]+)['"]/,p=/(dot|circle|double-circle|triangle|sesame)/,q=/(under|over|left|right)/,o=/['"]([^'"]+)['"]/,p=/(dot|circle|double-circle|triangle|sesame)/,q=/(under|over|left|right)/,r={"char":{},color:{},mark:{}},s={addCSSRule:function(b,d){if(!c){var e=document.createElement("style");e.type="text/css",a("head").eq(0).prepend(e),c=document.styleSheets[0]}c.insertRule?c.insertRule(b+"{"+d+"}",c.cssRules.length):c.addRule(b,d,-1)},addBeforeCSSRule:function(a,b,c){var e=r[a];if(e[b])return e[b];var f=a+k++ +d;return this.addCSSRule("."+f+":before",c),e[b]=f,f},testStyle:function(a,b){for(var c=["webkit","moz","o","ms"],d=0,e=c.length;e>d;d++)if(""===a.style[c[d]+b])return c[d]+b;var f=b.charAt(0).toLowerCase()+b.slice(1);return"undefined"!=typeof a.style[f]?f:!1},jsNameToCssName:function(a){return a.replace(/[A-Z]/g,function(a){return"-"+a.toLowerCase()}).replace(/^(webkit|moz|o|ms)\-/,"-$1-")},supportScale:function u(){if("undefined"!=typeof u.result)return u.result;var a,b=document.createElement("div"),c=this.testStyle(b,"Transform"),d=this.testStyle(b,"TransformOrigin");return c&&d?(c=this.jsNameToCssName(c),d=this.jsNameToCssName(d),a=[c,d]):a=null,u.result=a,a},supportEmphasis:function v(){if("undefined"!=typeof v.result)return v.result;var a,b=document.createElement("div"),c=this.testStyle(b,"TextEmphasis"),d=this.testStyle(b,"TextEmphasisPosition");return a=c&&d?[c,d]:null,v.result=a,a},supportWritingMode:function w(){if("undefined"!=typeof w.result)return w.result;var a,b=document.createElement("div"),c=this.testStyle(b,"WritingMode");return c?(c=this.jsNameToCssName(c),a=c):a=null,w.result=a,a},initCSSRule:function x(){if(!x.inited){x.inited=!0,this.addCSSRule("."+e,"position:relative;display:inline-block;_zoom:1;float:none;border:none;margin:0;padding:0 0 0.5em 0;vertical-align: baseline;color:inherit;font-size:inherit;font-family:inherit;letter-spacing: normal;text-decoration:inherit;line-height:inherit;"),this.addCSSRule("."+e+"."+h,"padding:0.5em 0 0 0;"),this.addCSSRule("."+f,"position:relative;float:none;border:none;margin:0;padding:0;vertical-align: baseline;color:inherit;font-size:inherit;font-family:inherit;letter-spacing: normal;text-decoration:inherit;line-height:inherit;");var a="position:absolute;bottom: 0;left: 0;height: 1em;line-height: 1em;text-align: center;width: 100%;float:none;border:none;margin:0;padding:0;vertical-align: baseline;color:inherit;font-size: inherit;font-family:inherit;text-decoration: none;";this.addCSSRule("."+f+":before",a+"bottom: -1em;"),this.addCSSRule("."+e+":before",a),this.addCSSRule("."+f+"."+g+":before","bottom: -0.5em;width: 200%;"),this.addCSSRule("."+f+"."+h+":before","top: -0.5em;bottom: auto;"),this.addCSSRule("."+e+"."+g+":before","width: 200%;"),this.addCSSRule("."+e+"."+h+":before","top: 0;bottom: auto;")}},getLineHeight:function(a,b){var c=a.css("line-height");return"normal"===c?this.getNormalLineHeight(b):c.match(/px/)?parseInt(c,10):b*c},getNormalLineHeight:function y(b){if("undefined"!=typeof y.result)return y.result;var c=a('
Some words.
');c.css("font-size",b+"px"),c.appendTo("body");var d=c.height();return c.remove(),y.result=d,d}},t=function(a,b){this.parse(a,b)};t.prototype.set=function(a,b){return"undefined"!=typeof this[a]?!1:(this[a]=b,!0)},t.prototype.parse=function(b,c){var d;if(c){if(!(d=c.match(q)))return this.error=!0,void 0;this.position=d[1]}if(!b)return this.error=!0,void 0;b=b.split(" ");for(var e,f,g=0,h=b.length;h>g;g++){if(e=b[g],d=e.match(o)){var i=d[1];if(i.length>1&&(i=i.charAt(0)),f=this.set("mark",i),this.isStringMark=!0,f)return}else{if(-1!==e.indexOf("none"))return this.isNone=!0,void 0;f=-1!==e.indexOf("filled")?this.set("filled",!0):-1!==e.indexOf("open")?this.set("filled",!1):(d=e.match(p))?this.set("mark",d[1]):this.set("color",a.trim(e))}if(!f)return this.error=!0,void 0}"undefined"==typeof this.mark&&"undefined"==typeof this.filled&&(this.error=!0)},t.prototype.autoComplete=function(){if(!this.isNone){var a=navigator.language||navigator.browserLanguage||"";a=a.slice(0,2);var b="ja"===a;null==this.position&&(this.position=b?"over":"under");var c="undefined"!=typeof this.filled,d="undefined"!=typeof this.mark;c&&d||d&&this.isStringMark||(d?this.filled=!0:c&&(this.mark="circle"))}},b.prototype.removeEmphasis=function(){this.styleNames?this.$el.css(this.styleNames[0],"none"):this.removeEmphasizedTag(this.$el)},b.prototype.setEmphasis=function(){this.markInfo.isNone?this.removeEmphasis():(this.markInfo.autoComplete(),this.styleNames?this.setEmphasisByCSS():this.setEmphasisByFallback())},b.prototype.setEmphasisByCSS=function(){var a={};a[this.styleNames[0]]=this.markInfo.isStringMark?'"'+this.markInfo.mark+'"':""+(this.markInfo.filled?"filled":"open")+" "+this.markInfo.mark+" "+(this.markInfo.color||""),a[this.styleNames[1]]=this.markInfo.position,this.$el.css(a)},b.prototype.setEmphasisByFallback=function(){s.initCSSRule(),this.markInfo.character=l[this.markInfo.mark]?l[this.markInfo.mark][this.markInfo.filled?0:1]:this.markInfo.mark.charAt(0),this.fakeEmphasis(this.$el,this.markInfo)},b.prototype.removeEmphasizedTag=function(b,c){if(this.isEmphasizedTag(b[0]))return b.replaceWith(b.text()),void 0;for(var d,e=b.children(),f=0,g=e.length;g>f;f++)d=a(e[f]),this.isEmphasizedTag(d[0])?d.replaceWith(d.text()):c||this.removeEmphasizedTag(d)},b.prototype.hasEmphasizedTag=function(a){for(var b,c=a.children(),d=0,e=c.length;e>d;d++)if(b=c[d],this.isEmphasizedTag(b))return!0;return!1},b.prototype.isEmphasizedTag=function(a){var b=a.className;return-1!==b.indexOf(e)||-1!==b.indexOf(f)},b.prototype.fakeEmphasis=function(b,c,d){d=d||1,1===d&&this.removeEmphasizedTag(b,!0);for(var e,f=b.contents(),g=0,h=f.length;h>g;g++)if(e=f[g],3===e.nodeType)this.textToHtml(a(e),b,c);else if(1===e.nodeType){var i=this.isEmphasizedTag(e),j=e.nodeName.toLowerCase();n[j]||i||this.fakeEmphasis(a(e),c,d+1)}},b.prototype.textToHtml=function(a,b,c){var d=parseInt(b.css("font-size"),10),h=s.getLineHeight(b,d),i=d/2,k=!1;i>(h-d)/2&&(k=!0);var l,n=s.supportScale();l=n?n[0]+":scale(0.5);"+n[1]+("over"===c.position?":top left;":":bottom left;"):"font-size:"+i+"px;"+"height:"+i+"px;"+"line-height:"+i+"px;";var o=s.addBeforeCSSRule("mark",n?c.position:i,l),p="";c.color&&(p=s.addBeforeCSSRule("color",c.color,"color:"+c.color+" !important;"));var q=k?e:f,r=s.addBeforeCSSRule("char",c.character,"content:'"+c.character+"';"),t=j[c.position],u=b.css("letter-spacing"),v="";"normal"!==u&&0!==u&&(v="margin-right:"+u+";");for(var w,x='',y="",z=a.text(),A=[],B=0,C=z.length;C>B;B++)w=z.charAt(B),m[w]?A.push(w):(A.push(x),A.push(w),A.push(y));a.replaceWith(A.join(""))},a.fn.emphasis=function(c,d){var e=new t(c,d);if(!e.error)return this.each(function(c,d){var f=a(d),g=s.supportEmphasis();new b(e,f,g)}),this}}(jQuery);