To respond to myself as I was the last in this thread : it was related to the activation of template comment.
Edit : OK, after more than 2 years, someone respond during me answering ^^
New problem :
I want to use this tutorial for the last version of mybb : 1.8.24
For this to work I have already made some modifications :
Up to now, I have made edit only for the file "root/jscripts/bbcodes_sceditor.js" :
First change SAME.
/***********************
* Add Spoiler command *
***********************/
$.sceditor.formats.bbcode.set("spoiler", {
allowsEmpty: true,
isInline: false,
format: function(element, content) {
var desc = '',
$elm = $(element),
$cite = $elm.children('cite').first();
if($cite.length === 1 || $elm.data('desc')) {
desc = $elm.data('desc') || $cite.text() ;
$elm.data('desc', desc);
$cite.remove();
content = this.elementToBbcode($(element));
desc = '=' + desc;
$elm.prepend($cite);
}
return '[spoiler' + desc + ']' + content + '[/spoiler]';
},
html: function (token, attrs, content) {
var data = '';
if (attrs.defaultattr) {
content = '<cite>' + attrs.defaultattr + '</cite>' + content;
data += ' data-desc="' + attrs.defaultattr + '"';
}
return '<blockquote' + data + ' class="spoiler">' + content + '</blockquote>';
},
breakStart: true,
breakEnd: true
});
$.sceditor.command.set("spoiler", {
_dropDown: function (editor, caller, html) {
var $content;
$content = $(
'<div>' +
'<label for="des">' + editor._('Description (optional):') + '</label> ' +
'<input type="text" id="des" />' +
'</div>' +
'<div><input type="button" class="button" value="' + editor._('Insert') + '" /></div>'
);
$content.find('.button').click(function (e) {
var description = $content.find('#des').val(),
descriptionAttr = '',
before = '[spoiler]',
end = '[/spoiler]';
if (description) {
descriptionAttr = '=' + description + '';
before = '[spoiler'+ descriptionAttr +']';
}
if (html) {
before = before + html + end;
end = null;
}
editor.insert(before, end);
editor.closeDropDown(true);
e.preventDefault();
});
editor.createDropDown(caller, 'insertspoiler', $content);
},
exec: function (caller) {
$.sceditor.command.get('spoiler')._dropDown(this, caller);
},
txtExec: function (caller) {
$.sceditor.command.get('spoiler')._dropDown(this, caller);
},
tooltip: 'Insert a spoiler'
});
(
modification of line :
$.sceditor.plugins.bbcode.bbcode.set("spoiler", {
to
$.sceditor.formats.bbcode.set("spoiler", {
)
$.sceditor.formats.bbcode.remove('code').remove('php').remove('quote').remove('video').remove('img').remove('spoiler');
With this file modification and the others in the fisrt post, if I tried to use the spoiler button I have this error in my console :
Uncaught TypeError: e.querySelectorAll is not a function
jQuery 2
_dropDown http://ip/jscripts/bbcodes_sceditor.js?ver=1824:613
exec http://ip/jscripts/bbcodes_sceditor.js?ver=1824:616
jQuery 16
<anonymous> http://ip/newreply.php?tid=5642:462
jQuery 13
The lines 613 and 616 are from the previous additions :
613 : editor.createDropDown(caller, 'insertspoiler', $content);
616 : $.sceditor.command.get('spoiler')._dropDown(this, caller);
In the file we can see this type of line :
editor.createDropDown(caller, 'insertimage', $content.get(0));
I have tried to add the ".get(0)" to line 613.
The button is showing the first step for the description but I can't go further. Pressing enter reload the page with nothing more.
Edit :
In the modifications of the edit in the file "root/jscripts/bbcodes_sceditor.js", it seems that this :
$content.find('.button').click(function (e) {
should be :
$content.find('.button').on('click', function (e) {
Still not working.
Edit 2 :
if ($(element[0]).hasClass('spoiler')) {
change to
if ($(element).hasClass('spoiler')) {