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