//>>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(f,h,l,u,v,m,w,x,y,z,A,B,C,n,p){f=l("dijit._editor.plugins._FontDropDown",[z,A,B],{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:f,postMixInProperties:function(){this.inherited(arguments);this.strings=v.getLocalization("dijit._editor","FontChoice");this.label=this.strings[this.command];this.id=y.getUniqueId(this.declaredClass.replace(/\./g,"_"));this.selectId=this.id+"_select";this.inherited(arguments)},postCreate:function(){this.select.set("store",new x({idProperty:"value",data:h.map(this.values,function(b){var a=this.strings[b]||b;return{label:this.getLabel(b,a),name:a,value:b}},this)}));this.select.set("value",
"",!1);this.disabled=this.select.get("disabled")},_setValueAttr:function(b,a){a=!1!==a;this.select.set("value",0>h.indexOf(this.values,b)?"":b,a);a||(this.select._lastValueReported=null)},_getValueAttr:function(){return this.select.get("value")},focus:function(){this.select.focus()},_setDisabledAttr:function(b){this._set("disabled",b);this.select.set("disabled",b)}});var q=l("dijit._editor.plugins._FontNameDropDown",f,{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(b,a){return this.plainText?a:"\x3cdiv style\x3d'font-family: "+b+"'\x3e"+a+"\x3c/div\x3e"},_normalizeFontName:function(b){var a=this.values;if(!b||!a)return b;var d=b.split(",");if(1<d.length)for(var c=0,e=d.length;c<e;c++){var k=w.trim(d[c]);if(-1<h.indexOf(a,k))return k}return b},_setValueAttr:function(b,a){a=!1!==
a;b=this._normalizeFontName(b);this.generic&&(b={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"}[b]||b);this.inherited(arguments,[b,a])}}),r=l("dijit._editor.plugins._FontSizeDropDown",f,{command:"fontSize",comboClass:"dijitFontSizeCombo",values:[1,2,3,4,5,6,7],getLabel:function(b,
a){return this.plainText?a:"\x3cfont size\x3d"+b+"'\x3e"+a+"\x3c/font\x3e"},_setValueAttr:function(b,a){a=!1!==a;b.indexOf&&-1!=b.indexOf("px")&&(b={10:1,13:2,16:3,18:4,24:5,32:6,48:7}[parseInt(b,10)]||b);this.inherited(arguments,[b,a])}}),t=l("dijit._editor.plugins._FormatBlockDropDown",f,{command:"formatBlock",comboClass:"dijitFormatBlockCombo",values:"noFormat p h1 h2 h3 pre".split(" "),postCreate:function(){this.inherited(arguments);this.set("value","noFormat",!1)},getLabel:function(b,a){return this.plainText||
"noFormat"==b?a:"\x3c"+b+"\x3e"+a+"\x3c/"+b+"\x3e"},_execCommand:function(b,a,d){if("noFormat"===d){var c;if((a=p.getSelection(b.window))&&0<a.rangeCount){d=a.getRangeAt(0);var e;if(d){a=d.startContainer;for(c=d.endContainer;a&&a!==b.editNode&&a!==b.document.body&&1!==a.nodeType;)a=a.parentNode;for(;c&&c!==b.editNode&&c!==b.document.body&&1!==c.nodeType;)c=c.parentNode;var k=m.hitch(this,function(a,c){if(a.childNodes&&a.childNodes.length){var d;for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];
if(1==e.nodeType&&b.selection.inSelection(e)){var f=e.tagName?e.tagName.toLowerCase():"";-1!==h.indexOf(this.values,f)&&c.push(e);k(e,c)}}}});d=m.hitch(this,function(a){if(a&&a.length){for(b.beginEditing();a.length;)this._removeFormat(b,a.pop());b.endEditing()}});var f=[];if(a==c){var g;for(c=a;c&&c!==b.editNode&&c!==b.document.body;){if(1==c.nodeType&&(e=c.tagName?c.tagName.toLowerCase():"",-1!==h.indexOf(this.values,e))){g=c;break}c=c.parentNode}k(a,f);g&&(f=[g].concat(f))}else for(c=a;b.selection.inSelection(c);)1==
c.nodeType&&(e=c.tagName?c.tagName.toLowerCase():"",-1!==h.indexOf(this.values,e)&&f.push(c),k(c,f)),c=c.nextSibling;d(f);b.onDisplayChanged()}}}else b.execCommand(a,d)},_removeFormat:function(b,a){if(b.customUndo){for(;a.firstChild;)u.place(a.firstChild,a,"before");a.parentNode.removeChild(a)}else{b.selection.selectElementChildren(a);var d=b.selection.getSelectedHtml();b.selection.selectElement(a);b.execCommand("inserthtml",d||"")}}}),g=l("dijit._editor.plugins.FontChoice",n,{useDefaultCommand:!1,
_initButton:function(){var b={fontName:q,fontSize:r,formatBlock:t}[this.command],a=this.params;this.params.custom&&(a.values=this.params.custom);var d=this.editor;this.button=new b(m.delegate({dir:d.dir,lang:d.lang},a));this.own(this.button.select.on("change",m.hitch(this,function(a){this.editor.focused&&this.editor.focus();"fontName"==this.command&&-1!=a.indexOf(" ")&&(a="'"+a+"'");this.button._execCommand?this.button._execCommand(this.editor,this.command,a):this.editor.execCommand(this.command,
a)})))},updateState:function(){var b=this.editor,a=this.command;if(b&&b.isLoaded&&a.length&&this.button){var d=this.get("disabled");this.button.set("disabled",d);if(!d){var c;try{c=b.queryCommandValue(a)||""}catch(k){c=""}(d=m.isString(c)&&(c.match(/'([^']*)'/)||c.match(/"([^"]*)"/)))&&(c=d[1]);"fontSize"!==a||c||(c=3);if("formatBlock"===a)if(c&&"p"!=c)0>h.indexOf(this.button.values,c)&&(c="noFormat");else{c=null;var e;(a=p.getSelection(this.editor.window))&&0<a.rangeCount&&(a=a.getRangeAt(0))&&(e=
a.endContainer);for(;e&&e!==b.editNode&&e!==b.document;){if((a=e.tagName?e.tagName.toLowerCase():"")&&-1<h.indexOf(this.button.values,a)){c=a;break}e=e.parentNode}c||(c="noFormat")}c!==this.button.get("value")&&this.button.set("value",c,!1)}}}});h.forEach(["fontName","fontSize","formatBlock"],function(b){n.registry[b]=function(a){return new g({command:b,plainText:a.plainText})}});g._FontDropDown=f;g._FontNameDropDown=q;g._FontSizeDropDown=r;g._FormatBlockDropDown=t;return g});
//# sourceMappingURL=FontChoice.js.map