link(rel='stylesheet', type='text/css', href='/js/scrawl/css/scrawl.css')
script(type='text/javascript', src='/js/scrawl/scrawl.js')
script(language='javascript').
    var msgid = "#{chatMessage.id}", fileid = "#{chatMessage.attachmentid}";
    var height;
    var width;
    $(document).ready(function () {
        height = $('#ukefu-image-content')[0].offsetHeight;
        width = $('#ukefu-image-content')[0].offsetWidth;
        $('#ukefu-image-content')[0].width = width;
        if('#{agentUser}' && !'#{t}'){
            top.layer.confirm(
                "访客在线，是否邀请协作对话？",
                {
                    btn: ['邀请', '不邀请'] //按钮
                },
                function (index) {
                    layer.close(index);
                    top.WebIM.sendTypeMessage("${chatMessage.id!''}", "${user.id!''}", "${agentUser.appid!''}", "${user.sessionid!''}", "${agentUser.orgi!''}", "<#if agentUser??>${agentUser.userid!''}</#if>", "${user.username!''}", "cooperation", "${chatMessage.attachmentid!''}");
                },
                function (index) {
                    layer.close(index);
                }
            );
        }
        $("#ukefu_img_ctx").load(function () {

            console.log($('#ukefu-image-content')[0].offsetHeight);
            new Canvas({
                canvasId: "canvas-borad",
                width: width,
                height: height
            });
            var canvas = $("#canvas-borad")[0];
            if (canvas.getContext) {
                //获取对应的CanvasRenderingContext2D对象(画笔)
                var ctx = canvas.getContext("2d");

                //创建新的图片对象
                var img = new Image();
                //指定图片的URL
                img.src = "/res/image.html?id=${chatMessage.attachmentid!''}&cooperation=true&original=true";
                //浏览器加载图片完毕后再绘制图片
                img.onload = function () {
                    //以Canvas画布上的坐标(10,10)为起始点，绘制图像
                    ctx.drawImage(img, 0, 0);
                };
            }
        });
    });
.ukefu-preview-image.scrawl-main#scrawl-main
    .ukefu-image-content.hot(style='max-width: none;width: 100%')
        .ukefu-image-canvas#ukefu-image-content
            img#ukefu_img_ctx(src=chatMessage.message)
        .drawBoard
            canvas#canvas-borad.brushBorad 你的浏览器不支持 canvas 绘图
