@model GheyasPlusShop.Models.Admin.SettingModel
@section styles
{
    <style>
        body {
            background-color: #f6f6f6;
        }

    </style>
}

<div style="padding:15px;">
    <div class="d-flex justify-content-end py-2 w-100">
        <button type="button" class="button-accept float-left" onclick="save()">ذخیره</button>
    </div>
    <div style="height: calc(100vh - 90px);" id="div-editor">
        <textarea id="editor">@(Model.WebsitePrivacyContext)</textarea>
    </div>
</div>


@section scripts{
    <script src="~/App_Scripts/app/ckeditor/ckeditor.js"></script>
    <script>
        closeLoading();
        $(document).ready(function () {
            var editorElem = document.getElementById("div-editor");
            CKEDITOR.replace("editor", {
                toolbar: [
                    { name: "clipboard", items: ["PasteText", "PasteFromWord", "Undo", "Redo"] },
                    { name: "styles", items: ["Font", "FontSize"] },
                    { name: "basicstyles", items: ["Bold", "Italic", "Underline", "Strike"] },
                    { name: "colors", items: ["TextColor"] },
                    { name: "align", items: ["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"] },
                    {
                        name: "paragraph",
                        items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "BidiLtr", "BidiRtl"]
                    },
                    { name: "insert", items: ["Image", "Table"] },
                    { name: "tools", items: ["Maximize"] }
                ],
                contentsCss: [
                     "../../App_Css/app/editor.contents.css",
                     "../../App_Css/app/editor.iframe.css"
                ],
                bodyClass: "document-editor",
                extraPlugins: "image2,tableresize",
                on: {
                    // maximize the editor on startup
                    'instanceReady': function (evt) {
                        evt.editor.resize("100%", editorElem.clientHeight);
                    }
                },
                font_names: "seyagh",
                font_defaultLabel:"seyagh"
                
            });
        });

        function save() {
            var $body = $(CKEDITOR.instances.editor.document.$).find("body").html();
            ajax({
                loading: true,
                url: "Admin/SavePrivacyContext",
                data: JSON.stringify({ privacyContext: $body }),
                success: function () {
                     window.location.reload();
                }
            });
        }

    </script>
}
