%META:TOPICINFO{author="TWikiContributor" date="1131431859" format="1.1" version="2"}%
%META:TOPICPARENT{name="WebHome"}%
<script type="text/javascript">
//<![CDATA[
function capitalize(inForm, inValue) {
  // only capitalize if user wants a WikiWord
  if (inForm.nonwikiword.checked == true) {
    return removeSpaces(inValue);
  }
  var sIn = inValue;
  var sOut = '';
  var chgUpper = true;
  for ( var i = 0; i < sIn.length; i++ ) {
    var ch = sIn.charAt( i );
    if( ch!=' ' ) {
      if( chgUpper ) {
        ch = ch.toUpperCase();
        chgUpper = false;
      }
    }
    if( ch==' ' ) {
      chgUpper = true;
    } else {
      chgUpper = false;
    }
    sOut += ch;
  }
  return removeSpaces(sOut); 
}
function removeSpaces(inValue) {
  var sIn = inValue;
  var sOut = '';
  for ( var i = 0; i < sIn.length; i++ ) {
    var ch = sIn.charAt( i );
    if( ch==' ' ) {
      chgUpper = true;
      continue;
    }
    sOut += ch;
  }
  return sOut;
}
function canSubmit(inForm) {
  inForm.topic.value = capitalize(inForm, inForm.topic.value);
  // Use the negative value of the checkbox. This is the ugly way but must be used until edit script parameter =allowsnonwikiword= is implemented.
  inForm.onlywikiname.value = (inForm.nonwikiword.checked == true) ? "off" : "on";
  return true;
}
//]]>
</script>
<form name="newtopic" action="%SCRIPTURLPATH{edit}%/%BASEWEB%/" onsubmit="return canSubmit(this);">
---+ %MAKETEXT{"Create New Topic in [_1] Web" args="<nop>%BASEWEB%"}%
<div class="twikiFormSteps">
<div class="twikiFormStep">
---+++ %MAKETEXT{"Topic name:"}%
<p><input type="text" class="twikiInputField" name="topic" size="40" value="" onblur="this.value=capitalize(this.form, this.value);" />
<!-- TODO: move JS to a separate file and make it callable on click of the button too -->
<!-- TODO: blank out all the irrelevant links: Edit, Compose, Attach, Printable, ... Raw text, versions, History, More topic actions: could this be a CSS? -->
</p>
<p><input type="checkbox" class="twikiCheckbox" id="nonwikiword" name="nonwikiword" /><label for="nonwikiword">%MAKETEXT{"Allow non <nop>WikiWord for the new topic name"}%</label></p>
<p class="twikiGrayText">%MAKETEXT{"It's usually best to choose a <a target='WikiWord' onclick=\"return launchWindow('[_1]','WikiWord')\" href='[_1]' rel='nofollow'>WikiWord</a> for the new topic name, otherwise automatic linking may not work. Characters not allowed in topic names, such as spaces will automatically be removed." args="%TWIKIWEB%,%SCRIPTURLPATH{"view"}%/%TWIKIWEB%/WikiWord"}%</p>
</div><!--/twikiFormStep-->
<div class="twikiFormStep">
---+++ %MAKETEXT{"Topic parent:"}%
<select name="topicparent" size="10">
%TOPICLIST{"<option $marker value='$name'>$name</option>" separator=" " selection="%URLPARAM{ "parent" default="%MAKETEXT{"(no parent, orphaned topic)"}%" }%"}%
<option value="">%MAKETEXT{"(no parent, orphaned topic)"}%</option>
</select>
</div><!--/twikiFormStep-->
<div class="twikiFormStep twikiLast">
<input type="submit" class="twikiSubmit" value='%MAKETEXT{"Create this topic"}%' />
</div><!--/twikiFormStep-->
</div><!--/twikiFormSteps-->
<input type="hidden" name="onlywikiname" value="off" />
<input type="hidden" name="onlynewtopic" value="on" />
</form>
%BR%
<div class="twikiHelp">
%ICON{info}% %MAKETEXT{"Once you have created the topic, consider adding links in related topics to the new topic so that there are more ways people can discover it."}%
</div>