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) {
$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) {

@ -1,74 +1,75 @@
<script>
// External plugins not part of the default Ckeditor package.
var plugins = [
'asciimath',
'asciisvg',
'audio',
'ckeditor_wiris',
'dialogui',
'glossary',
'leaflet',
'mapping',
'maximize',
'mathjax',
'oembed',
'toolbar',
'toolbarswitch',
'video',
'wikilink',
'wordcount',
'youtube'
];
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");
{% if _u.logged %}
// External plugins not part of the default Ckeditor package.
var plugins = [
'asciimath',
'asciisvg',
'audio',
'ckeditor_wiris',
'dialogui',
'glossary',
'leaflet',
'mapping',
'maximize',
'mathjax',
'oembed',
'toolbar',
'toolbarswitch',
'video',
'wikilink',
'wordcount',
'youtube'
];
plugins.forEach(function(plugin) {
CKEDITOR.plugins.addExternal(plugin, '{{ _p.web_main ~ 'inc/lib/javascript/ckeditor/plugins/' }}' + plugin + '/');
});
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 template = this;
var $templateLi = $("<li>");
var $templatesUL = $("<ul>");
var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
templateHTML += "<b>" + template.title + "</b>";
$.each(templatesConfig.templates, function () {
var template = this;
var $templateLi = $("<li>");
if (template.description) {
templateHTML += "<div class=description>" + template.description + "</div>";
}
var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
templateHTML += "<b>" + template.title + "</b>";
templateHTML += "</div>";
$("<a>", {
href: "#",
html: templateHTML,
click: function (e) {
e.preventDefault();
if (CKEDITOR.instances[editorName]) {
CKEDITOR.instances[editorName].setData(template.html, function () {
this.checkDirty();
});
if (template.description) {
templateHTML += "<div class=description>" + template.description + "</div>";
}
}
}).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(){
$("#open-view-list").click(function(){
$("#student-list-work").fadeIn(300);

Loading…
Cancel
Save