Lines 567-580
Link Here
|
567 |
[% ELSE %] |
567 |
[% ELSE %] |
568 |
<script> |
568 |
<script> |
569 |
$(document).ready(function() { |
569 |
$(document).ready(function() { |
570 |
if( $("#tabs .tab-pane.active").length < 1 ){ |
|
|
571 |
$("#tabs a:first").tab("show"); |
572 |
} |
573 |
[% IF category == 'news' %] |
570 |
[% IF category == 'news' %] |
574 |
$("#add_additional_content").validate({ |
571 |
$("#add_additional_content").validate({ |
575 |
submitHandler: function(form){ |
572 |
submitHandler: function(form){ |
576 |
if ( ! $("#title_default").val().length > 0 ) { |
573 |
if ( ! $("#title_default").val().length > 0 ) { |
577 |
alert(__("Please specify a title for 'Default'")); |
574 |
alert(_("Please specify a title for 'Default'")); |
578 |
return false; |
575 |
return false; |
579 |
} |
576 |
} |
580 |
|
577 |
|
Lines 603-642
Link Here
|
603 |
[% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %] |
600 |
[% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %] |
604 |
[% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %] |
601 |
[% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %] |
605 |
<script> |
602 |
<script> |
606 |
$("textarea[name^='content_']").each( function(index) { |
603 |
let editors = new Object(); /* Keeps track of initialized CodeMirror instances */ |
607 |
var this_lang = $(this).attr('data-lang'); |
604 |
$(document).ready(function(){ |
608 |
var editor = CodeMirror.fromTextArea(document.getElementById('content_' + this_lang), { |
605 |
|
609 |
lineNumbers: true, |
606 |
if( $("#tabs .tab-pane.active").length < 1 ){ |
610 |
lineWrapping: true, |
607 |
/* Activate first tab and initialize its CodeMirror instance */ |
611 |
lint: true, |
608 |
let firstTab = $("#tabs a:first"); |
612 |
mode: "text/html", |
609 |
firstTab.tab("show"); |
613 |
gutters: ["CodeMirror-lint-markers"], |
610 |
initCodeMirror( firstTab[0].hash ); |
614 |
viewportMargin: Infinity, |
611 |
} |
|
|
612 |
|
613 |
$("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) { |
614 |
/* Try to initialize CodeMirror instance when tab opens */ |
615 |
initCodeMirror( e.target.hash ); |
615 |
}); |
616 |
}); |
616 |
}); |
617 |
}); |
|
|
618 |
|
619 |
function initCodeMirror( container ){ |
620 |
/* Initialize CodeMirror instance only if it doesn't exist */ |
621 |
if( !editors[ container ] ){ |
622 |
let textarea = $( container ).find("textarea[name^='content_']"); |
623 |
let this_lang = textarea.attr('data-lang'); |
624 |
let editor = CodeMirror.fromTextArea( document.getElementById('content_' + this_lang), { |
625 |
lineNumbers: true, |
626 |
lineWrapping: true, |
627 |
lint: true, |
628 |
mode: "text/html", |
629 |
gutters: ["CodeMirror-lint-markers"], |
630 |
viewportMargin: Infinity, |
631 |
}); |
632 |
editors[ container ] = editor; |
633 |
return editor; |
634 |
} |
635 |
} |
617 |
</script> |
636 |
</script> |
618 |
[% ELSE %] |
637 |
[% ELSE %] |
619 |
[% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] |
638 |
[% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] |
620 |
[% INCLUDE 'str/tinymce_i18n.inc' %] |
639 |
[% INCLUDE 'str/tinymce_i18n.inc' %] |
621 |
<script> |
640 |
<script> |
622 |
tinyMCE.init({ |
641 |
|
623 |
verify_html: false, |
642 |
$(document).ready(function(){ |
624 |
force_br_newlines : false, |
643 |
if( $("#tabs .tab-pane.active").length < 1 ){ |
625 |
force_p_newlines : false, |
644 |
/* Activate first tab and initialize its tinyMCE instance */ |
626 |
forced_root_block : '', |
645 |
let firstTab = $("#tabs a:first"); |
627 |
branding : false, |
646 |
firstTab.tab("show"); |
628 |
relative_urls : false, |
647 |
initTinyMce( firstTab[0].hash ); |
629 |
content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css", |
648 |
} |
630 |
menubar : "file edit view insert format tools table", |
649 |
|
631 |
mode : "specific_textareas", |
650 |
$("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) { |
632 |
plugins : "autoresize table hr link image charmap lists code emoticons", |
651 |
/* Try to initialize tinyMCE instance when tab opens */ |
633 |
extended_valid_elements:"style,link[href|rel]", |
652 |
initTinyMce( e.target.hash ); |
634 |
custom_elements:"style,link,~link", |
653 |
}); |
635 |
toolbar : [ |
|
|
636 |
"formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr", |
637 |
"table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code" |
638 |
], |
639 |
}); |
654 |
}); |
|
|
655 |
|
656 |
function initTinyMce( container ){ |
657 |
let textarea = $( container ).find("textarea[name^='content_']"); |
658 |
/* TinyMCE seems to do its own check to prevent double-initialization |
659 |
so We don't need to keep track of it */ |
660 |
let editor = tinyMCE.init({ |
661 |
branding : false, |
662 |
content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css", |
663 |
custom_elements:"style,link,~link", |
664 |
extended_valid_elements:"style,link[href|rel]", |
665 |
force_br_newlines : false, |
666 |
force_p_newlines : false, |
667 |
forced_root_block : '', |
668 |
menubar : "file edit view insert format tools table", |
669 |
plugins : "autoresize table hr link image charmap lists code emoticons", |
670 |
relative_urls : false, |
671 |
selector: "#" + textarea[0].id, |
672 |
verify_html: false, |
673 |
toolbar : [ |
674 |
"formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr", |
675 |
"table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code" |
676 |
], |
677 |
}); |
678 |
return editor; |
679 |
} |
640 |
</script> |
680 |
</script> |
641 |
[% END # /UNLESS wysiwyg %] |
681 |
[% END # /UNLESS wysiwyg %] |
642 |
[% END %] |
682 |
[% END %] |
643 |
- |
|
|