--- a/src/pyams_content/skin/resources/js/pyams_content.js Fri Mar 30 15:38:11 2018 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.js Tue Apr 03 12:46:09 2018 +0200
@@ -34,6 +34,71 @@
initEditor: function(settings) {
settings.image_list = PyAMS_content.TinyMCE.getImagesList;
settings.link_list = PyAMS_content.TinyMCE.getLinksList;
+ settings.style_formats = [
+ {
+ title: 'Headings',
+ items: [
+ {title: 'Heading 3', format: 'h3'},
+ {title: 'Heading 4', format: 'h4'},
+ {title: 'Heading 5', format: 'h5'},
+ {title: 'Heading 6', format: 'h6'}
+ ]
+ },
+ {
+ title: 'Inline',
+ items: [
+ {title: 'Bold', icon: 'bold', format: 'bold'},
+ {title: 'Italic', icon: 'italic', format: 'italic'},
+ {title: 'Underline', icon: 'underline', format: 'underline'},
+ {title: 'Strikethrough', icon: 'strikethrough', format: 'strikethrough'},
+ {title: 'Superscript', icon: 'superscript', format: 'superscript'},
+ {title: 'Subscript', icon: 'subscript', format: 'subscript'},
+ {title: 'Code', icon: 'code', format: 'code'}
+ ]
+ },
+ {
+ title: 'Blocks',
+ items: [
+ {title: 'Paragraph', format: 'p'},
+ {title: 'Blockquote', format: 'blockquote'},
+ {title: 'Div', format: 'div'},
+ {title: 'Pre', format: 'pre'}
+ ]
+ },
+ {
+ title: 'Alignment',
+ items: [
+ {title: 'Left', icon: 'alignleft', format: 'alignleft'},
+ {title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
+ {title: 'Right', icon: 'alignright', format: 'alignright'},
+ {title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
+ ]
+ }
+ ];
+ // Declare direct H3 style formatter
+ tinyMCE.PluginManager.add('styles', function (editor, url) {
+ ['h3'].forEach(function (name) {
+ editor.addButton("style-" + name, {
+ tooltip: "Toggle " + name + " header",
+ text: name.toUpperCase(),
+ onClick: function () {
+ editor.execCommand('mceToggleFormat', false, name);
+ },
+ onPostRender: function () {
+ var self = this, setup = function () {
+ editor.formatter.formatChanged(name, function (state) {
+ self.active(state);
+ });
+ };
+ editor.formatter ? setup() : editor.on('init', setup);
+ }
+ })
+ });
+ });
+ settings.plugins += ' styles';
+ if (settings.toolbar1) {
+ settings.toolbar1 = "undo redo | styleselect style-h3 style-h4 | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent";
+ }
return settings;
},
@@ -57,6 +122,29 @@
},
/**
+ * Alerts management
+ */
+ alerts: {
+
+ switchVisibility: function (element) {
+ return function () {
+ var source = $(this);
+ var association = source.parents('tr');
+ var container = association.parents('table');
+ MyAMS.ajax.post(container.data('ams-location') + '/set-alert-visibility.json',
+ {object_name: association.data('ams-element-name')},
+ function (result, status) {
+ if (result.visible) {
+ $('i', source).attr('class', 'fa fa-fw fa-eye');
+ } else {
+ $('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
+ }
+ });
+ };
+ }
+ },
+
+ /**
* Galleries management
*/
galleries: {
@@ -269,7 +357,6 @@
var editor = $('.editor', para);
if (editor.is(':empty')) {
editor.html(result[para_id]);
- MyAMS.initContent(editor);
}
$('.fa-plus-square-o', para).removeClass('fa-plus-square-o')
.addClass('fa-minus-square-o');
@@ -279,6 +366,7 @@
switcher.removeClass('fa-cog fa-spin')
.addClass('fa-minus-square-o');
}
+ MyAMS.initContent(container);
});
} else {
$('.editor', container).each(function() {