var EDITBOX_ID="topic";var EDITBOX_PREF_ROWS_ID="EditTextareaRows";var EDITBOX_CHANGE_STEP_SIZE=4;var EDITBOX_MIN_ROWCOUNT=4;var EDITBOX_PREF_FONTSTYLE_ID="EditTextareaFontStyle";var EDITBOX_FONTSTYLE_MONO="mono";var EDITBOX_FONTSTYLE_PROPORTIONAL="proportional";var EDITBOX_FONTSTYLE_MONO_STYLE="foswikiEditboxStyleMono";var EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE="foswikiEditboxStyleProportional";(function($){foswiki.Edit={textareaInited:false,fontStyle:null,validateSuppressed:false};foswiki.Edit.getFontStyle=function(){if(foswiki.Edit.fontStyle){return foswiki.Edit.fontStyle;}
var pref=foswiki.Pref.getPref(EDITBOX_PREF_FONTSTYLE_ID);if(!pref||(pref!==EDITBOX_FONTSTYLE_PROPORTIONAL&&pref!==EDITBOX_FONTSTYLE_MONO)){pref=EDITBOX_FONTSTYLE_PROPORTIONAL;}
return pref;};foswiki.Edit.setFontStyle=function(inFontStyle){if(inFontStyle===EDITBOX_FONTSTYLE_MONO){$('#'+EDITBOX_ID).removeClass(EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE).addClass(EDITBOX_FONTSTYLE_MONO_STYLE);}
if(inFontStyle===EDITBOX_FONTSTYLE_PROPORTIONAL){$('#'+EDITBOX_ID).removeClass(EDITBOX_FONTSTYLE_MONO_STYLE).addClass(EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE);}
foswiki.Edit.fontStyle=inFontStyle;foswiki.Pref.setPref(EDITBOX_PREF_FONTSTYLE_ID,inFontStyle);};foswiki.Edit.changeEditBox=function(inDirection){var rowCount=$('#'+EDITBOX_ID).attr('rows');rowCount+=(inDirection*EDITBOX_CHANGE_STEP_SIZE);rowCount=(rowCount<EDITBOX_MIN_ROWCOUNT)?EDITBOX_MIN_ROWCOUNT:rowCount;$('#'+EDITBOX_ID).attr('rows',rowCount);foswiki.Pref.setPref(EDITBOX_PREF_ROWS_ID,rowCount);return false;};foswiki.Edit.validateMandatoryFields=function(){if(foswiki.Edit.validateSuppressed){return true;}
var alerts=[];$('select.foswikiMandatory').each(function(index,el){var one=false;var k;for(k=0;k<el.options.length;k=k+1){if(el.options[k].selected){one=true;break;}}
if(!one){alerts.push("The required form field '"
+el.name+
"' has no value.");}});$('textarea.foswikiMandatory, input.foswikiMandatory').each(function(index,el){if(el.value===null||el.value.length===0){alerts.push("The required form field '"
+el.name+
"' has no value.");}});if(alerts.length>0){alert(alerts.join("\n"));return false;}else{return true;}};$(function(){try{document.main.text.focus();}catch(er){}
var prefRowsId=foswiki.Pref.getPref(EDITBOX_PREF_ROWS_ID);if(prefRowsId){$('#'+EDITBOX_ID).attr('rows',parseInt(prefRowsId,10));}
var prefStyle=foswiki.Edit.getFontStyle();foswiki.Edit.setFontStyle(prefStyle);$(document.forms[name='main']).submit(function(e){return foswiki.Edit.validateMandatoryFields();});$('.foswikiTextarea').keydown(function(e){var code;if(e.keyCode){code=e.keyCode;}
return(code!==27);});$('.foswikiButtonCancel').click(function(e){foswiki.Edit.validateSuppressed=true;});});}(jQuery));