/* jQuery Accidentals Copyright 2012 by Bret Pimentel http://bretpimentel.com Available under MIT license. See LICENSE.txt for more information. */ (function(c){c.fn.accidentals=function(b){function i(b,c){for(var a in b)b.hasOwnProperty(a)&&c(a,b[a])}function j(a,d,e){var f;if(!b.ignoreWithin||b.ignoreWithin&&0===c(a).closest(b.ignoreWithin).length)3===a.nodeType?(f=a.nodeValue.replace(d,e),/',caseSensitive:!1,ignoreWithin:".no-accidentals",inputTypes:["text"],noteNames:"[A-H]",noteNameWrap:"",outerWrap:"",safeMode:!0},b);b.caseSensitive=b.caseSensitive?"":"i";b.safeMode&&(a=c('
').appendTo(c(this).first()), i(d,function(b,c){a.append(''+c.replacement+"")}),!navigator.userAgent.match(RegExp(k.join("|"),"gi"))&&(a.find(".flat").width()===a.find(".sharp").width()&&a.find(".flat").width()===a.find(".natural").width())&&(d.flat.safe=!1,d.sharp.safe=!1,d.natural.safe=!1),a.find(".doubleFlat").width()===a.find(".doubleSharp").width()&&(d.doubleFlat.safe=!1,d.doubleSharp.safe=!1),a.remove());return this.each(function(){var a=c(this); i(b.inputTypes,function(k,e){i(d,function(f,g){d[f].safe&&a.contents().each(function(){var a;j(this,RegExp("\\b("+b.noteNames+")("+g[e]+")(?=(s)?(\\b|\\s|\\W|$))","g"+b.caseSensitive),function(d,f){var e=f,h=g.replacement;b.noteNameWrap&&(e=c(b.noteNameWrap).text(e).wrap("
").parent().html());b.accidentalWrap&&(a=b.accidentalClassBase?g.text:g.text.replace(/^-/,""),h=c(b.accidentalWrap).addClass(b.accidentalClassBase+a).text(h).wrap("
").parent().html());return b.outerWrap?c(b.outerWrap).html(e+ h).wrap("
").parent().html():e+h})})})})})}})(jQuery);