var MotionTypeEdit=function(){function e(){$("#typeDeadlineMotionsHolder").datetimepicker({locale:$("#typeDeadlineMotions").data("locale")}),$("#typeDeadlineAmendmentsHolder").datetimepicker({locale:$("#typeDeadlineAmendments").data("locale")}),$("#typeSupportType").on("change",function(){$(this).find("option:selected").data("has-supporters")?($("#typeMinSupportersRow").removeClass("hidden"),$("#typeAllowMoreSupporters").removeClass("hidden")):($("#typeMinSupportersRow").addClass("hidden"),$("#typeAllowMoreSupporters").addClass("hidden"))}).change(),$(".deleteTypeOpener a").on("click",function(e){e.preventDefault(),$(".deleteTypeForm").removeClass("hidden"),$(".deleteTypeOpener").addClass("hidden")}),$('[data-toggle="tooltip"]').tooltip(),this.initSectionList()}return e.prototype.initSectionList=function(){var e=$("#sectionsList"),t=0;e.data("sortable",Sortable.create(e[0],{handle:".drag-handle",animation:150})),e.on("click","a.remover",function(e){e.preventDefault();var t=$(this).parents("li").first(),a=t.data("id");bootbox.confirm(__t("admin","deleteMotionSectionConfirm"),function(e){e&&($(".adminTypeForm").append('<input type="hidden" name="sectionsTodelete[]" value="'+a+'">'),t.remove())})}),e.on("change",".sectionType",function(){var e=$(this).parents("li").first(),t=parseInt($(this).val());e.removeClass("title textHtml textSimple image tabularData"),0===t?e.addClass("title"):1===t?e.addClass("textSimple"):2===t?e.addClass("textHtml"):3===t?e.addClass("image"):4===t&&(e.addClass("tabularData"),0==e.find(".tabularDataRow ul > li").length&&e.find(".tabularDataRow .addRow").click().click().click())}),e.find(".sectionType").trigger("change"),e.on("change",".maxLenSet",function(){var e=$(this).parents("li").first();$(this).prop("checked")?e.addClass("maxLenSet").removeClass("no-maxLenSet"):e.addClass("no-maxLenSet").removeClass("maxLenSet")}),e.find(".maxLenSet").trigger("change"),$(".sectionAdder").on("click",function(a){a.preventDefault();var n=$("#sectionTemplate").html();n=n.replace(/#NEW#/g,"new"+t);var i=$(n);e.append(i),t+=1,e.find(".sectionType").trigger("change"),e.find(".maxLenSet").trigger("change");var o=i.find(".tabularDataRow ul");o.data("sortable",Sortable.create(o[0],{handle:".drag-data-handle",animation:150}))});var a=0;e.on("click",".tabularDataRow .addRow",function(e){e.preventDefault();var t=$(this),n=t.parent().find("ul"),i=$(t.data("template").replace(/#NEWDATA#/g,"new"+a));a+=1,i.removeClass("no0").addClass("no"+n.children().length),n.append(i),i.find("input").focus()}),e.on("click",".tabularDataRow .delRow",function(e){var t=$(this);e.preventDefault(),bootbox.confirm(__t("admin","deleteDataConfirm"),function(e){e&&t.parents("li").first().remove()})}),e.find(".tabularDataRow ul").each(function(){$(this).data("sortable",Sortable.create(this,{handle:".drag-data-handle",animation:150}))})},e}();new MotionTypeEdit;
//# sourceMappingURL=MotionTypeEdit.js.map
