define(["require","exports","./AntragsgruenEditor"],function(t,a,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var i=function(){function t(){var t=this;this.$paragraphs=$(".wysiwyg-textarea.single-paragraph"),this.$paragraphs.click(function(a){t.startEditing(a.delegateTarget)}),this.$paragraphs.find(".modifiedActions .revert").click(function(a){a.preventDefault(),a.stopPropagation(),t.revertChanges(a.delegateTarget)}),this.setModifyable(),$(".wysiwyg-textarea").filter(":not(.single-paragraph)").each(function(a,e){t.handleRegularTextField(e)}),$(".texteditorBox").each(function(t,a){var e=$(a),i=e.data("section-id"),r=e.data("changed-para-no");r>-1&&$("#section_holder_"+i+"_"+r).click()})}return t.prototype.handleRegularTextField=function(t){var a=$(t),i=a.find(".texteditor");if(!a.hasClass("hidden")){var r=new e.AntragsgruenEditor(i.attr("id")).getEditor();i.parents("form").submit(function(){i.parent().find("textarea.raw").val(r.getData()),void 0!==r.plugins.lite&&(r.plugins.lite.findPlugin(r).acceptAll(),i.parent().find("textarea.consolidated").val(r.getData()))})}},t.prototype.revertChanges=function(t){var a=$(t).parents(".wysiwyg-textarea"),e=a.find(".texteditor"),i=e.attr("id");$("#"+i).attr("contenteditable","false"),e.html(a.data("original")),a.removeClass("modified"),this.setModifyable()},t.prototype.startEditing=function(t){var a=$(t);if(a.hasClass("modifyable")){a.addClass("modified"),this.setModifyable();var i,r=a.find(".texteditor");if(void 0!==CKEDITOR.instances[r.attr("id")])i=CKEDITOR.instances[r.attr("id")];else{var n=new e.AntragsgruenEditor(r.attr("id"));i=n.getEditor()}r.attr("contenteditable","true"),r.parents("form").submit(function(){r.parent().find("textarea.raw").val(i.getData()),void 0!==i.plugins.lite&&(i.plugins.lite.findPlugin(i).acceptAll(),r.parent().find("textarea.consolidated").val(i.getData()))}),r.focus()}},t.prototype.setModifyable=function(){var t=this.$paragraphs.filter(".modified");0==t.length?this.$paragraphs.addClass("modifyable"):(this.$paragraphs.removeClass("modifyable"),$("input[name=modifiedParagraphNo]").val(t.data("paragraph-no")),$("input[name=modifiedSectionId]").val(t.parents(".texteditorBox").data("section-id")))},t}();a.AmendmentEditSinglePara=i});
//# sourceMappingURL=AmendmentEditSinglePara.js.map
