mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00

Unified all tinyMCE instances used across AAC, now they are initiated in one single file + added option to upload images within editor (CTRL-C CTRL-V) + there is new folder: user/, which will be used for all user generated data, like image uploads, guild images, etc.
49 lines
1.6 KiB
Twig
49 lines
1.6 KiB
Twig
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/js/tinymce/tinymce.min.js"></script>
|
|
<script type="text/javascript">
|
|
let unsaved = false;
|
|
let lastContent = '';
|
|
|
|
function tinymceInit() {
|
|
tinymce.init({
|
|
selector: "#editor",
|
|
theme: "silver",
|
|
plugins: 'preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help code emoticons',
|
|
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | emoticons link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat code',
|
|
image_advtab: true,
|
|
images_upload_url: '{{ constant('BASE_URL') }}admin/tools/upload_image.php',
|
|
images_upload_credentials: true,
|
|
// not really sure - do we need those 3 options below?
|
|
//relative_urls: false,
|
|
//remove_script_host: false,
|
|
//document_base_url: "{{ constant('BASE_URL') }}"
|
|
setup: function (ed) {
|
|
ed.on('NodeChange', function (e) {
|
|
if (ed.getContent() !== lastContent) {
|
|
unsaved = true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
$(":input").change(function () { //triggers change in all input fields including text type
|
|
unsaved = true;
|
|
});
|
|
|
|
$("#form").submit(function (event) {
|
|
unsaved = false;
|
|
});
|
|
|
|
lastContent = $("#editor").val();
|
|
});
|
|
|
|
function unloadPage() {
|
|
if (unsaved) {
|
|
return "You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?";
|
|
}
|
|
}
|
|
|
|
window.onbeforeunload = unloadPage;
|
|
</script>
|