//>>built
define("dijit/_editor/plugins/FontChoice","require dojo/_base/array dojo/_base/declare dojo/dom-construct dojo/i18n dojo/_base/lang dojo/string dojo/store/Memory ../../registry ../../_Widget ../../_TemplatedMixin ../../_WidgetsInTemplateMixin ../../form/FilteringSelect ../_Plugin ../range dojo/i18n!../nls/FontChoice".split(" "),function(k,g,n,A,B,p,C,D,E,F,G,H,J,t,u){k=n("dijit._editor.plugins._FontDropDown",[F,G,H],{label:"",plainText:!1,templateString:"\x3cspan style\x3d'white-space: nowrap' class\x3d'dijit dijitReset dijitInline'\x3e\x3clabel class\x3d'dijitLeft dijitInline' for\x3d'${selectId}'\x3e${label}\x3c/label\x3e\x3cinput data-dojo-type\x3d'../../form/FilteringSelect' required\x3d'false' data-dojo-props\x3d'labelType:\"html\", labelAttr:\"label\", searchAttr:\"name\"' class\x3d'${comboClass}' tabIndex\x3d'-1' id\x3d'${selectId}' data-dojo-attach-point\x3d'select' value\x3d''/\x3e\x3c/span\x3e",
contextRequire:k,postMixInProperties:function(){this.inherited(arguments);this.strings=B.getLocalization("dijit._editor","FontChoice");this.label=this.strings[this.command];this.id=E.getUniqueId(this.declaredClass.replace(/\./g,"_"));this.selectId=this.id+"_select";this.inherited(arguments)},postCreate:function(){this.select.set("store",new D({idProperty:"value",data:g.map(this.values,function(a){var b=this.strings[a]||a;return{label:this.getLabel(a,b),name:b,value:a}},this)}));this.select.set("value",
"",!1);this.disabled=this.select.get("disabled")},_setValueAttr:function(a,b){b=!1!==b;this.select.set("value",0>g.indexOf(this.values,a)?"":a,b);b||(this.select._lastValueReported=null)},_getValueAttr:function(){return this.select.get("value")},focus:function(){this.select.focus()},_setDisabledAttr:function(a){this._set("disabled",a);this.select.set("disabled",a)}});var v=n("dijit._editor.plugins._FontNameDropDown",k,{generic:!1,command:"fontName",comboClass:"dijitFontNameCombo",postMixInProperties:function(){this.values||
(this.values=this.generic?["serif","sans-serif","monospace","cursive","fantasy"]:["Arial","Times New Roman","Comic Sans MS","Courier New"]);this.inherited(arguments)},getLabel:function(a,b){return this.plainText?b:"\x3cdiv style\x3d'font-family: "+a+"'\x3e"+b+"\x3c/div\x3e"},_normalizeFontName:function(a){var b=this.values;if(!a||!b)return a;var d=a.split(",");if(1<d.length)for(var c=0,e=d.length;c<e;c++){var f=C.trim(d[c]);if(-1<g.indexOf(b,f))return f}return a},_setValueAttr:function(a,b){b=!1!==
b;a=this._normalizeFontName(a);this.generic&&(a={Arial:"sans-serif",Helvetica:"sans-serif",Myriad:"sans-serif",Times:"serif","Times New Roman":"serif","Comic Sans MS":"cursive","Apple Chancery":"cursive",Courier:"monospace","Courier New":"monospace",Papyrus:"fantasy","Estrangelo Edessa":"cursive",Gabriola:"fantasy"}[a]||a);this.inherited(arguments,[a,b])}}),w=n("dijit._editor.plugins._FontSizeDropDown",k,{command:"fontSize",comboClass:"dijitFontSizeCombo",values:[1,2,3,4,5,6,7],getLabel:function(a,
b){return this.plainText?b:"\x3cfont size\x3d"+a+"'\x3e"+b+"\x3c/font\x3e"},_setValueAttr:function(a,b){b=!1!==b;a.indexOf&&-1!=a.indexOf("px")&&(a={10:1,13:2,16:3,18:4,24:5,32:6,48:7}[parseInt(a,10)]||a);this.inherited(arguments,[a,b])}}),z=n("dijit._editor.plugins._FormatBlockDropDown",k,{command:"formatBlock",comboClass:"dijitFormatBlockCombo",values:"noFormat p h1 h2 h3 pre".split(" "),postCreate:function(){this.inherited(arguments);this.set("value","noFormat",!1)},getLabel:function(a,b){return this.plainText||
"noFormat"==a?b:"\x3c"+a+"\x3e"+b+"\x3c/"+a+"\x3e"},_execCommand:function(a,b,d){if("noFormat"===d){var c;if((b=u.getSelection(a.window))&&0<b.rangeCount&&(d=b.getRangeAt(0),d)){b=d.startContainer;for(c=d.endContainer;b&&b!==a.editNode&&b!==a.document.body&&1!==b.nodeType;)b=b.parentNode;for(;c&&c!==a.editNode&&c!==a.document.body&&1!==c.nodeType;)c=c.parentNode;var e=p.hitch(this,function(h,x){if(h.childNodes&&h.childNodes.length){var q;for(q=0;q<h.childNodes.length;q++){var l=h.childNodes[q];if(1==
l.nodeType&&a.selection.inSelection(l)){var I=l.tagName?l.tagName.toLowerCase():"";-1!==g.indexOf(this.values,I)&&x.push(l);e(l,x)}}}});d=p.hitch(this,function(h){if(h&&h.length){for(a.beginEditing();h.length;)this._removeFormat(a,h.pop());a.endEditing()}});var f=[];if(b==c){for(c=b;c&&c!==a.editNode&&c!==a.document.body;){if(1==c.nodeType){var r=c.tagName?c.tagName.toLowerCase():"";if(-1!==g.indexOf(this.values,r)){var y=c;break}}c=c.parentNode}e(b,f);y&&(f=[y].concat(f))}else for(c=b;a.selection.inSelection(c);)1==
c.nodeType&&(r=c.tagName?c.tagName.toLowerCase():"",-1!==g.indexOf(this.values,r)&&f.push(c),e(c,f)),c=c.nextSibling;d(f);a.onDisplayChanged()}}else a.execCommand(b,d)},_removeFormat:function(a,b){if(a.customUndo){for(;b.firstChild;)A.place(b.firstChild,b,"before");b.parentNode.removeChild(b)}else{a.selection.selectElementChildren(b);var d=a.selection.getSelectedHtml();a.selection.selectElement(b);a.execCommand("inserthtml",d||"")}}}),m=n("dijit._editor.plugins.FontChoice",t,{useDefaultCommand:!1,
_initButton:function(){var a={fontName:v,fontSize:w,formatBlock:z}[this.command],b=this.params;this.params.custom&&(b.values=this.params.custom);var d=this.editor;this.button=new a(p.delegate({dir:d.dir,lang:d.lang},b));this.own(this.button.select.on("change",p.hitch(this,function(c){this.editor.focused&&this.editor.focus();"fontName"==this.command&&-1!=c.indexOf(" ")&&(c="'"+c+"'");this.button._execCommand?this.button._execCommand(this.editor,this.command,c):this.editor.execCommand(this.command,
c)})))},updateState:function(){var a=this.editor,b=this.command;if(a&&a.isLoaded&&b.length&&this.button){var d=this.get("disabled");this.button.set("disabled",d);if(!d){try{var c=a.queryCommandValue(b)||""}catch(f){c=""}(d=p.isString(c)&&(c.match(/'([^']*)'/)||c.match(/"([^"]*)"/)))&&(c=d[1]);"fontSize"!==b||c||(c=3);if("formatBlock"===b)if(c&&"p"!=c)0>g.indexOf(this.button.values,c)&&(c="noFormat");else{c=null;if((b=u.getSelection(this.editor.window))&&0<b.rangeCount&&(b=b.getRangeAt(0)))var e=b.endContainer;
for(;e&&e!==a.editNode&&e!==a.document;){if((b=e.tagName?e.tagName.toLowerCase():"")&&-1<g.indexOf(this.button.values,b)){c=b;break}e=e.parentNode}c||(c="noFormat")}c!==this.button.get("value")&&this.button.set("value",c,!1)}}}});g.forEach(["fontName","fontSize","formatBlock"],function(a){t.registry[a]=function(b){return new m({command:a,plainText:b.plainText})}});m._FontDropDown=k;m._FontNameDropDown=v;m._FontSizeDropDown=w;m._FormatBlockDropDown=z;return m});