cms.registerWidgetHandler("form",new function(){InlineWidget.apply(this,arguments);this.getName=function(){return"form"};this.getIcon=function(){return"fa-envelope-o"};this.getToolbarButtons=function(){var a=this;return{options:{click:function(c,b){a.openOptionsForm(c,b)}}}};this.getOptionsFormSettings=function(){var a=this;return{onCreate:function(b){$(".fields-list",b).sortable({handle:".drag-handle"});$(".f-email-type select",b).on("change",function(){$(".f-email",b).toggle($(this).val()=="custom")}).change();b.on("click",".actions .b-mandatory",function(c){c.preventDefault();$(this).toggleClass("active")});b.on("click",".actions .b-delete",function(c){c.preventDefault();$(this).parents(".form-field").remove()});$(".f-add button",b).click(function(d){d.preventDefault();var c=$(".fields-list",b);$(".field-template",b).clone().removeClass("field-template").addClass("form-field").appendTo(c)})},onShow:function(c,b){$(".f-email-type select",c).change();var d=$(".fields-list",c);$(".form-field",d).remove();if(!b||!b.fields){return}$.each(b.fields,function(e,g){var f=$(".field-template",c).clone().removeClass("field-template").addClass("form-field").appendTo(d);$(".field-title",f).val(g.title);$(".field-type",f).val(g.type);if(g.isMandatory){$(".b-mandatory",f).addClass("active")}d.append(f)})}}};this.onCreateWidget=function(a,b){this.openOptionsForm(b,a.id);return a};this.onInitWidget=function(b,c){var a=this};this.applyOptions=function(c,a,b){cms.showLoadingIndicator();var d=this.dom(c);a.fields=[];$(".fields-list .form-field",b).each(function(f){var h=$(this);var i=$("input.field-title",h).val();if(!i){return}var g=$("select.field-type",h).val();var e=$(".b-mandatory",h).hasClass("active");a.fields.push({type:g,title:i,isMandatory:e})});this.runBackend("buildForm",{id:c.domId,options:JSON.stringify(a)},function(e){d.empty().append(e.html);cms.hideLoadingIndicator()});return a}});