Fix Load ckeditor js plugin only when user is logged on - Refs #8233

remotes/angel/1.11.x
José Loguercio 9 years ago
parent 0ea0a859c5
commit c39a86fb1c
  1. 4
      main/inc/lib/template.lib.php
  2. 127
      main/template/default/layout/header.js.tpl

@ -689,7 +689,9 @@ class Template
} }
foreach ($bowerJsFiles as $file) { foreach ($bowerJsFiles as $file) {
$js_file_to_string .= '<script type="text/javascript" src="'.api_get_path(WEB_PATH).'web/assets/'.$file.'"></script>'."\n"; if (!empty($file)) {
$js_file_to_string .= '<script type="text/javascript" src="'.api_get_path(WEB_PATH).'web/assets/'.$file.'"></script>'."\n";
}
} }
foreach ($js_files as $file) { foreach ($js_files as $file) {

@ -1,74 +1,75 @@
<script> <script>
// External plugins not part of the default Ckeditor package. {% if _u.logged %}
var plugins = [ // External plugins not part of the default Ckeditor package.
'asciimath', var plugins = [
'asciisvg', 'asciimath',
'audio', 'asciisvg',
'ckeditor_wiris', 'audio',
'dialogui', 'ckeditor_wiris',
'glossary', 'dialogui',
'leaflet', 'glossary',
'mapping', 'leaflet',
'maximize', 'mapping',
'mathjax', 'maximize',
'oembed', 'mathjax',
'toolbar', 'oembed',
'toolbarswitch', 'toolbar',
'video', 'toolbarswitch',
'wikilink', 'video',
'wordcount', 'wikilink',
'youtube' 'wordcount',
]; 'youtube'
];
plugins.forEach(function(plugin) {
CKEDITOR.plugins.addExternal(plugin, '{{ _p.web_main ~ 'inc/lib/javascript/ckeditor/plugins/' }}' + plugin + '/'); plugins.forEach(function(plugin) {
}); CKEDITOR.plugins.addExternal(plugin, '{{ _p.web_main ~ 'inc/lib/javascript/ckeditor/plugins/' }}' + plugin + '/');
});
/**
* Function use to load templates in a div
**/
var showTemplates = function (ckeditorName) {
var editorName = 'content';
if (ckeditorName && ckeditorName.length > 0) {
editorName = ckeditorName;
}
CKEDITOR.editorConfig(CKEDITOR.config);
CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a){
var templatesConfig = CKEDITOR.getTemplates("default");
var $templatesUL = $("<ul>"); /**
* Function use to load templates in a div
**/
var showTemplates = function (ckeditorName) {
var editorName = 'content';
if (ckeditorName && ckeditorName.length > 0) {
editorName = ckeditorName;
}
CKEDITOR.editorConfig(CKEDITOR.config);
CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a){
var templatesConfig = CKEDITOR.getTemplates("default");
$.each(templatesConfig.templates, function () { var $templatesUL = $("<ul>");
var template = this;
var $templateLi = $("<li>");
var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>"; $.each(templatesConfig.templates, function () {
templateHTML += "<b>" + template.title + "</b>"; var template = this;
var $templateLi = $("<li>");
if (template.description) { var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
templateHTML += "<div class=description>" + template.description + "</div>"; templateHTML += "<b>" + template.title + "</b>";
}
templateHTML += "</div>"; if (template.description) {
templateHTML += "<div class=description>" + template.description + "</div>";
$("<a>", {
href: "#",
html: templateHTML,
click: function (e) {
e.preventDefault();
if (CKEDITOR.instances[editorName]) {
CKEDITOR.instances[editorName].setData(template.html, function () {
this.checkDirty();
});
} }
}
}).appendTo($templateLi);
$templatesUL.append($templateLi);
});
$templatesUL.appendTo("#frmModel");
});
};
templateHTML += "</div>";
$("<a>", {
href: "#",
html: templateHTML,
click: function (e) {
e.preventDefault();
if (CKEDITOR.instances[editorName]) {
CKEDITOR.instances[editorName].setData(template.html, function () {
this.checkDirty();
});
}
}
}).appendTo($templateLi);
$templatesUL.append($templateLi);
});
$templatesUL.appendTo("#frmModel");
});
};
{% endif %}
$(document).ready(function(){ $(document).ready(function(){
$("#open-view-list").click(function(){ $("#open-view-list").click(function(){
$("#student-list-work").fadeIn(300); $("#student-list-work").fadeIn(300);

Loading…
Cancel
Save