%PDF- %PDF-
Direktori : /var/www/html/bbw/farmaci/kritik-portale/public/js/backend/comments/ |
Current File : /var/www/html/bbw/farmaci/kritik-portale/public/js/backend/comments/comments.js |
var comments = { options: {}, init: function () { $('#commentTable .editComment').unbind('click'); $('#commentTable .editComment').click(function(){ comments.openCommentForm(($(this).attr('data-entityid'))); }); $('#fullCommentTable .editComment').unbind('click'); $('#fullCommentTable .editComment').click(function(){ comments.openCommentForm(($(this).attr('data-entityid'))); }); $('#moderatorForm [name=save]').unbind('click'); $('#moderatorForm [name=save]').click(function(){ comments.saveCommentForm(); }); $('#moderatorForm').off('click', '[name=saveCloseComment]'); $("#moderatorForm").on('click', '[name=saveCloseComment]', comments.saveAndCloseComment); $('#moderatorForm').off('click', '[name=removeComment]'); $("#moderatorForm").on('click', '[name=removeComment]', this.removeCommentQuestion); $("#moderatorForm").off('change', '[name=activateRemoveComment]'); $("#moderatorForm").on('change', '[name=activateRemoveComment]', this.activateRemoveComment); }, openCommentForm: function (id) { window.location = "#backend/comments/edit/" + id; }, saveCommentForm: function () { var route = $('#moderatorForm').attr('action'); var postFormData = $("#moderatorForm").serializeArray(); $.post(route, postFormData, function (data) { if (!data.error) { location.href = '/backend#/backend/comments/edit/' + $("[name=id]").val() + "?tmp=" + Math.floor(Math.random() * 1000) ; } else { $('#content').html(data.html); $('body').animate({ scrollTop: $('.state-error:first').offset().top - 80 }, 200); } }); }, saveAndCloseComment: function (e) { e.preventDefault(); var route = $('#moderatorForm').attr('action'); var postFormData = $("#moderatorForm").serializeArray(); $.post(route, postFormData, function (data) { if (!data.error) { location.href = '/backend#/backend/index'; } else { $('#content').html(data.html); $('body').animate({ scrollTop: $('.state-error:first').offset().top - 80 }, 200); } }); }, removeCommentQuestion: function (e) { $.SmartMessageBox({ title: _("Should this recommendation and the answer really be deleted?"), content: "Sind Sie sicher?", buttons: '[Nein][Ja]' }, function (ButtonPressed) { if (ButtonPressed === "Ja") { comments.removeComment(e); } }); e.preventDefault(); }, removeComment: function (e) { e.preventDefault(); var route = '/backend/comments/remove-comment/' + $('[name=id]').val(); var postFormData = $("#moderatorForm").serializeArray(); $.post(route, postFormData, function (data) { location.href = "/backend#/backend/comments/commenttable"; }); }, activateRemoveComment: function (e) { e.preventDefault(); if($("#moderatorForm [name=activateRemoveComment]").prop("checked") == true){ $("#moderatorForm [name=removeComment]").removeClass("hidden"); } else { $("#moderatorForm [name=removeComment]").addClass("hidden"); } }, }; $(document).ready(function () { comments.init(); });