BUGFIX: spoiler tag on lightboxed images wasn't working

This commit is contained in:
Régis Hanol
2014-01-12 19:38:46 +01:00
parent 090d7e2695
commit 70161498b6
5 changed files with 20 additions and 7 deletions

View File

@@ -57,8 +57,6 @@ replaceBBCode('ul', function(contents) { return ['ul'].concat(contents); });
replaceBBCode('ol', function(contents) { return ['ol'].concat(contents); });
replaceBBCode('li', function(contents) { return ['li'].concat(contents); });
replaceBBCode('spoiler', function(contents) { return ['span', {'class': 'spoiler'}].concat(contents); });
Discourse.Dialect.inlineBetween({
start: '[img]',
stop: '[/img]',
@@ -80,7 +78,6 @@ Discourse.Dialect.inlineBetween({
emitter: function(contents) { return ['a', {href: contents, 'data-bbcode': true}, contents]; }
});
replaceBBCodeParamsRaw("url", function(param, contents) {
return ['a', {href: param, 'data-bbcode': true}, contents];
});
@@ -103,3 +100,11 @@ Discourse.Dialect.replaceBlock({
}
});
Discourse.Dialect.replaceBlock({
start: /(\[spoiler\])([\s\S]*)/igm,
stop: '[/spoiler]',
emitter: function(blockContents) {
return ['p', ['div', { 'class': 'spoiler' }, blockContents.join("\n")]];
}
});

View File

@@ -213,7 +213,7 @@ Discourse.Dialect = {
@param {String} [opts.start] The starting token we want to find
@param {String} [opts.matcher] The regular expression to match
@param {Boolean} [opts.wordBoundary] If true, the match must be on a word boundary
@param {Boolean} [opts.spaceBoundary] If true, the match must be on a sppace boundary
@param {Boolean} [opts.spaceBoundary] If true, the match must be on a space boundary
**/
inlineRegexp: function(args) {
this.registerInline(args.start, function(text, match, prev) {

View File

@@ -9,7 +9,11 @@ Discourse.Lightbox = {
apply: function($elem) {
$LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() {
$("a.lightbox", $elem).each(function(i, e) {
$(e).magnificPopup({
var $e = $(e);
// do not lightbox spoiled images
if ($e.parents(".spoiler").length > 0 || $e.parents(".spoiled").length > 0) { return; }
$e.magnificPopup({
type: "image",
closeOnContentClick: false,