!function(e){"use strict";foswiki.webTopicCreator={parentList:void 0,canSubmit:function(i,t){var o,r,n=e("input[name=topic]",i).val(),a=foswiki.getPreference("NAMEFILTER"),c=!1,s=foswiki.String.trimSpaces(n);return"string"==typeof a&&(a=new RegExp(a,"g")),0===n.length?(e("input[type=submit]",i).addClass("foswikiSubmitDisabled").attr("disabled",!0),e(".webTopicCreatorFeedback",i).html(""),e(".webTopicCreatorError",i).html(""),!1):(e("input[name=onlywikiname]",i).each((function(e,i){c=i.checked})),0!==s.length&&(c?o=(s=n.replace(a,"")).substr(0,1).toLocaleUpperCase()+s.substr(1):(s=n.replace(a," "),o=(o=foswiki.String.capitalize(s)).replace(/\s+/g,"")),t&&e("input[name=topic]",i).val(o),o!==n?(r=foswiki.getPreference("webTopicCreator.nameFeedback")+"<strong>"+o+"</strong>",e(".webTopicCreatorFeedback",i).html(r)):(e(".webTopicCreatorFeedback",i).html(""),e(".webTopicCreatorError",i).html("")),foswiki.String.isWikiWord(o)||!c?(e("input[type=submit]",i).removeClass("foswikiSubmitDisabled").attr("disabled",!1),e(".webTopicCreatorError",i).html(""),!0):(o.length>3&&e(".webTopicCreatorError",i).html(foswiki.getPreference("webTopicCreator.errorFeedbackNoWikiName")),e("input[type=submit]",i).addClass("foswikiSubmitDisabled").attr("disabled",!0),!1)))},removeSpacesAndPunctuation:function(e){return foswiki.String.removePunctuation(foswiki.String.removeSpaces(e))},filterSpacesAndPunctuation:function(e){return foswiki.String.removeSpaces(foswiki.String.filterPunctuation(e))},loadParentList:function(i,t){if(void 0===this.parentList){var o=e("input[name=topicparent]",i).val(),r=foswiki.getPreference("SCRIPTURLPATH")+"/view/"+foswiki.getPreference("SYSTEMWEB")+"/ParentList?section=select;web="+foswiki.getPreference("WEB")+";cover=text;selected="+o,n=this;e.get(r,(function(e){n.parentList=e,t||n.onParentListLoaded(i)}))}else this.onParentListLoaded(i)},onParentListLoaded:function(i){var t=e("input[name=topicparent]",i).val();e("input[name=topicparent]",i).replaceWith(this.parentList),t&&e("select[name=topicparent] option[value="+t+"]",i).attr("selected","selected"),this.afterLoadParentList(i)},beforeLoadParentList:function(i){e("img.processing",i).removeClass("foswikiHidden"),e("input[name=topicparent]",i).attr("readonly","readonly")},afterLoadParentList:function(i){e("img.processing",i).hide()}},e((function(){e("form[name=newtopicform]").each((function(i,t){var o=e(t);e("input[name=topic]",o).each((function(e,i){i.focus()})).keyup((function(e){foswiki.webTopicCreator.canSubmit(o,!1)})).change((function(e){foswiki.webTopicCreator.canSubmit(o,!1)})).blur((function(e){foswiki.webTopicCreator.canSubmit(o,!0)})),e("input[name=onlywikiname]",o).change((function(){foswiki.webTopicCreator.canSubmit(o,!1)})).mouseup((function(){foswiki.webTopicCreator.canSubmit(o,!1)})),e("a.pickparent",o).click((function(i){return e(this).hide(),foswiki.webTopicCreator.beforeLoadParentList(o),foswiki.webTopicCreator.loadParentList(o),!1})),foswiki.webTopicCreator.canSubmit(o,!1),foswiki.webTopicCreator.loadParentList(o,!0)})).submit((function(){return foswiki.webTopicCreator.canSubmit(this,!0)}))}))}(jQuery);
