Skip to content

Commit

Permalink
#1594 Replace with Bootstrap collapse plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed May 12, 2016
1 parent cb79ce2 commit 98ba4e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions include/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,13 @@ function do_bbcode($text, $is_signature = false) {
}

if ($luna_config['o_allow_spoiler'] == 1 && strpos($text, '[spoiler') !== false) {
$text = str_replace('[spoiler]', '</p><div class="panel panel-default panel-spoiler" style="padding: 0px;"><div class="panel-heading" onclick="var e,d,c=this.parentNode,a=c.getElementsByTagName('div')[1],b=this.getElementsByTagName(\'.fa\')[0];if(a.style.display!=''){while(c.parentNode&&(!d||!e||d==e)){e=d;d=(window.getComputedStyle?getComputedStyle(c, null):c.currentStyle)[\'backgroundColor\'];if(d==\'transparent\'||d==\'rgba(0, 0, 0, 0)\')d=e;c=c.parentNode;}a.style.display='';a.style.backgroundColor=d;b.innerHTML=\'&#9650;\';}else{a.style.display=\'none\';b.innerHTML=\'&#9660;\';}\" style=\"font-weight: bold; cursor: pointer; font-size: 0.9em;"><h3 class="panel-title"><i class="fa fa-fw fa-angle-down"></i>'.__('Spoiler', 'luna').'</h3></div><div class="panel-body" style="display: none;"><p>', $text);
$text = preg_replace('#\[spoiler=(.*?)\]#s', '</p><div class="panel panel-default panel-spoiler" style="padding: 0px;"><div class="panel-heading" onclick="var e,d,c=this.parentNode,a=c.getElementsByTagName(\'div\')[1],b=this.getElementsByTagName(\'span\')[0];if(a.style.display!=\'\'){while(c.parentNode&&(!d||!e||d==e)){e=d;d=(window.getComputedStyle?getComputedStyle(c, null):c.currentStyle)[\'backgroundColor\'];if(d==\'transparent\'||d==\'rgba(0, 0, 0, 0)\')d=e;c=c.parentNode;}a.style.display=\'\';a.style.backgroundColor=d;b.innerHTML=\'&#9650;\';}else{a.style.display=\'none\';b.innerHTML=\'&#9660;\';}" style="font-weight: bold; cursor: pointer; font-size: 0.9em;"><h3 class="panel-title"><i class="fa fa-fw fa-angle-down"></i>$1</h3></div><div class="panel-body" style="display: none;"><p>', $text);
$text = str_replace('[/spoiler]', '</p></div></div><p>', $text);
$count = 0;
$spoiler = mt_rand();

$text = preg_replace('%\[spoiler\]\s*%', '<div class="panel panel-default"><div class="panel-heading" role="tab" id="heading'.$spoiler.$count.'"><h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$spoiler.$count.'" aria-expanded="true" aria-controls="collapse'.$spoiler.$count.'"><span class="fa fa-fw fa-angle-down"></span> '.__('Spoiler', 'luna').'</a></h4></div><div id="collapse'.$spoiler.$count.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'.$spoiler.$count.'"><div class="panel-body"><p>', $text, -1, $count);
$text = preg_replace('%\[spoiler=(.*?)\]\s*%', '<div class="panel panel-default"><div class="panel-heading" role="tab" id="heading'.$spoiler.$count.'"><h4 class="panel-title"><a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$spoiler.$count.'" aria-expanded="true" aria-controls="collapse'.$spoiler.$count.'"><span class="fa fa-fw fa-angle-down"></span> $1</a></h4></div><div id="collapse'.$spoiler.$count.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'.$spoiler.$count.'"><div class="panel-body"><p>', $text, -1, $count);

$text = str_replace('[/spoiler]', '</p></div></div></div><p>', $text);
}

if (!$is_signature) {
Expand Down

0 comments on commit 98ba4e9

Please sign in to comment.