(function(){RB.WebhookFormView=Backbone.View.extend({events:{"change #id_apply_to":"_onApplyToChanged","change #id_encoding":"_onEncodingChanged","change #id_use_custom_content":"_onUseCustomContentToggled","change #id_events_0":"_onAllEventsToggled"},render:function(){this._$encoding=$("#id_encoding");this._$eventCheckboxes=$("#id_events").find("input");this._$allEventsCheckbox=this._$eventCheckboxes.filter('[value="*"]');this._$applyTo=$("#id_apply_to");this._$applyToSelected=this._$applyTo.find('[value="S"]');this._$customContentRow=this.$(".field-custom_content");this._$reposRow=this.$(".field-repositories");this._$useCustomContent=$("#id_use_custom_content");this._codeMirror=CodeMirror.fromTextArea($("#id_custom_content")[0],{matchBrackets:true,mode:"application/json"});this._$customContentRow.find("p.help").append("<br/>").append($("<a/>").attr("href",MANUAL_URL+"admin/configuration/webhooks/"+"#custom-payloads").text(gettext("Custom payload reference")));this._onAllEventsToggled();this._onApplyToChanged();this._onEncodingChanged();this._onUseCustomContentToggled();return this},_onAllEventsToggled:function(){this._$eventCheckboxes.not(this._$allEventsCheckbox).prop("disabled",this._$allEventsCheckbox[0].checked)},_onApplyToChanged:function(){this._$reposRow.setVisible(this._$applyToSelected[0].checked)},_onEncodingChanged:function(){this._codeMirror.setOption("mode",this._$encoding.val())},_onUseCustomContentToggled:function(){this._$customContentRow.setVisible(this._$useCustomContent[0].checked)}})}).call(this);
