HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/HKemperman1/osthoes.nl/wwwroot/DesktopModules/Journal/Scripts/journalcomments.js
(function ($, window) {
    $.fn.journalComments = function (options) {
        $.fn.journalComments.defaultOptions = {
            maxLength: 2000
        };
        var opts = $.extend({}, $.fn.journalComments.defaultOptions, options),
            $wrap = this,
            $id = $(this).attr('id'),
            $maxLength = opts.maxLength,
            $textarea = $('#' + $id + '-txt'),
            $placeHolder = $('#' + $id + ' .editorPlaceholder'),
            $button = $('#' + $id + ' .cmtbtn a'),
            $delete = $('#' + $id + ' .miniclose');

        $placeHolder.click(function () {
            $placeHolder.hide();
            $button.addClass('disabled').show();
            $textarea.show().animate({
                height: '+=45'
            }, 400, function () {

                $textarea.focus();
                $textarea.bind('keypress', isDirtyHandler);
            });
        });
        $delete.bind('click', deleteComment);

        $textarea.bind('paste', function (e) {
            setTimeout(function () {
                $textarea.val($textarea.val());
                if ($textarea.val().length > $maxLength) {
                    var txt = $textarea.val().substring(0, $maxLength);
                    $textarea.val(txt);
                }
            }, 100);
            isDirtyHandler(e);

        });
        function deleteComment() {
            var data = {};
            data.JournalId = $id.replace('jcmt-', '');
            data.CommentId = $(this).parent().attr('id').replace('cmt-', '');
            Post('CommentDelete', data);
            $(this).parent().fadeOut(function () {
                var p = $(this).parent();
                var id = $(this).attr('id');
                $(this).animate({
                    height: '0'
                }, 400, function () {
                    p.remove('#' + id);
                });

            });
        }
        var isDirtyHandler = function (event) {
            $button.removeClass('disabled');
            $textarea.unbind('keypress', isDirtyHandler);
        };

        $button.click(function (event) {
            event.preventDefault();
            var jid = $id.replace('jcmt-', '');
            var data = {};
            data.JournalId = jid;
            data.Comment = encodeURIComponent($textarea.val());
            data.mentions = $textarea.data("mentions");
            var tmpValue = $textarea.val();
            tmpValue = tmpValue.replace(/<(?:.|\n)*?>/gm, '').replace(/\s+/g, '').replace(/&nbsp;/g, '');
            if (tmpValue == '') {
                return false;
            }
            if (data.Comment == '' || data.Comment == '%3Cbr%3E') {
                return false;
            }
            Post('CommentSave', data, commentComplete, jid);
        });
        function commentComplete(data, journalId) {
            $textarea.animate({
                height: '0'
            }, 400, function () {
                $button.addClass('disabled').hide();
                $textarea.val('').hide();
                $placeHolder.show();

            });
            var li = $(data);
            li.insertBefore('#' + $id + ' .cmteditarea');
            $(li).find('.miniclose').bind('click', deleteComment);
            bindConfirm();
        }
        function Post(method, data, callback, journalId) {
            var sf = opts.servicesFramework;
            
            $.ajax({
                type: "POST",
                url: sf.getServiceRoot('Journal') + 'Services/' + method,
                beforeSend: sf.setModuleHeaders,
                data: data,
                success: function (data) {
                    if (typeof (callback) != "undefined") {
                        callback(data, journalId);

                    }
                },
                error: function (xhr, status, error) {
                    alert(error);
                }
            });
        };
    }
} (jQuery, window));