Skip to content

Commit

Permalink
Fix #2000 : Balise secret en previsualisation
Browse files Browse the repository at this point in the history
  • Loading branch information
A-312 committed Feb 11, 2015
1 parent 6ea406f commit d41e4e4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions assets/js/spoiler.js
Expand Up @@ -4,30 +4,33 @@
Author: Alex-D / Alexandre Demode
========================================================================== */

(function(document, $, undefined){
(function(document, $, undefined) {
"use strict";
function buildSpoilers($elem){
$elem.each(function(){

function buildSpoilers($elem) {
$elem.each(function() {
$(this).addClass("spoiler-build");
$(this).before($("<a/>", {
text: "Afficher/Masquer le contenu masqué",
class: "spoiler-title ico-after view",
href: "#",
click: function(e){
click: function(e) {
$(this).next(".spoiler").toggle();
e.preventDefault();
}
}));
});
}

$(document).ready(function(){
buildSpoilers($("#content .spoiler"));
$("#content").on("DOMNodeInserted", ".spoiler", function(e){
if($(e.target).is(".spoiler:not(.spoiler-build)")){
buildSpoilers($(e.target));
}
$(document).ready(function() {
var $content = $("#content");
buildSpoilers($content.find(".spoiler"));
$content.on("DOMNodeInserted", function() {
var $spoilers = $(this).find(".spoiler:not(.spoiler-build)");
if ($spoilers.length > 0)
return buildSpoilers($spoilers);
else if ($(this).is(".spoiler:not(.spoiler-build)"))
return buildSpoilers($(this));
});
});
})(document, jQuery);

0 comments on commit d41e4e4

Please sign in to comment.