Apply spoiler mod

This commit is contained in:
Travis Burtrum 2014-02-19 20:23:34 -05:00
parent 1ad3593908
commit 417facb436
13 changed files with 237 additions and 3 deletions

Binary file not shown.

View File

@ -1 +1 @@
1391538735 1392908711

View File

@ -453,6 +453,8 @@ function ModifyBasicSettings($return_config = false)
$config_vars = array( $config_vars = array(
// Big Options... polls, sticky, bbc.... // Big Options... polls, sticky, bbc....
array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])), array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),
array('select', 'defaultSpoilerStyle', array(1 => $txt['spoiler_tag_onhoverovershow'], 2 => $txt['spoiler_tag_onlinkclickshow'], 3 => $txt['spoiler_tag_onbuttonclickshow'])),
'', '',
// Basic stuff, titles, flash, permissions... // Basic stuff, titles, flash, permissions...
array('check', 'allow_guestAccess'), array('check', 'allow_guestAccess'),

View File

@ -1674,6 +1674,14 @@ function create_control_richedit($editorOptions)
'after' => '[/quote]', 'after' => '[/quote]',
'description' => $txt['bbc_quote'] 'description' => $txt['bbc_quote']
), ),
array(
'image' => 'spoiler',
'code' => 'spoiler',
'before' => '[spoiler]',
'after' => '[/spoiler]',
'description' => $txt['bbc_spoiler']
),
array(), array(),
array( array(
'image' => 'list', 'image' => 'list',

View File

@ -844,6 +844,87 @@ function shorten_subject($subject, $len)
// Shorten it by the length it was too long, and strip off junk from the end. // Shorten it by the length it was too long, and strip off junk from the end.
return $smcFunc['substr']($subject, 0, $len) . '...'; return $smcFunc['substr']($subject, 0, $len) . '...';
} }
// Spoiler choosing function
function build_spoiler($position, $topic = '')
{
global $txt, $settings, $context, $modSettings;
// Optional topic if given
if($topic != '')
$topic = ': '.$topic;
//Use global style if the theme-specific isn't set or is set to "follow global" (aka 0)
$spoilerTagStyle = isset($settings['spoiler_style']) ? $settings['spoiler_style'] : 0;
if($spoilerTagStyle == 0)
{
//Use "hover" if the global style isn't explicitly set
$spoilerTagStyle = isset($modSettings['defaultSpoilerStyle']) ? $modSettings['defaultSpoilerStyle'] : 1;
}
/*
Styles:
3: button
2: link
1: hover (default)
*/
$retval = '';
switch($position)
{
case 'before':
switch($spoilerTagStyle)
{
case 3:
$retval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<input type="button" class="spoilerbutton" value="'.$txt['spoiler_tag_text'].$topic.'" '.
'onclick="n = this.parentNode.parentNode.lastChild;if(n.style.display == \'none\') {n.style.display = \'block\';} else {n.style.display = \'none\';} return false;"/> '.
$txt['spoiler_tag_click_info'].'</div><div class="spoilerbody" style="display: none">'
);
break;
case 2:
$retval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<a href="javascript:void(0)" '.
'onclick="n = this.parentNode.parentNode.lastChild; if(n.style.display == \'none\') { n.style.display = \'block\'; } else { n.style.display = \'none\'; } return false;">'.$txt['spoiler_tag_text'].$topic.'</a> '.
$txt['spoiler_tag_click_info'].'</div><div class="spoilerbody" style="display: none">'
);
break;
case 1:
default:
$retval = (
'<fieldset class="spoiler" '.
'onmouseover="this.lastChild.style.display = \'block\';" onmouseout="this.lastChild.style.display=\'none\'">'.
'<legend><b>'.$txt['spoiler_tag_text'].$topic.'</b> <small>'.$txt['spoiler_tag_hover_info'].'</small>'.
'</legend><div class="spoilerbody" style="display: none">'
);
}
break;
case 'after':
switch($spoilerTagStyle)
{
case 3:
case 2:
$retval = (
'</div></div>'
);
break;
case 1:
default:
$retval = (
'</div></fieldset>'
);
}
break;
}
return $retval;
}
// The current time with offset. // The current time with offset.
function forum_time($use_user_offset = true, $timestamp = null) function forum_time($use_user_offset = true, $timestamp = null)
@ -1539,6 +1620,24 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
'before' => '<sup>', 'before' => '<sup>',
'after' => '</sup>', 'after' => '</sup>',
), ),
array(
'tag' => 'spoiler',
'block_level' => true,
'before' => build_spoiler('before'),
'after' => build_spoiler('after'),
'disabled_before' => '<div style="display: none;">',
'disabled_after' => '</div>',
),
array(
'tag' => 'spoiler',
'type' => 'unparsed_equals',
'block_level' => true,
'before' => build_spoiler('before', "$1"),
'after' => build_spoiler('after'),
'disabled_before' => '<div style="display: none;">',
'disabled_after' => '</div>',
),
array( array(
'tag' => 'table', 'tag' => 'table',
'before' => '<table class="bbc_table">', 'before' => '<table class="bbc_table">',

View File

@ -257,6 +257,19 @@ function template_settings()
'label' => $txt['hide_post_group'], 'label' => $txt['hide_post_group'],
'description' => $txt['hide_post_group_desc'], 'description' => $txt['hide_post_group_desc'],
), ),
array(
'id' => 'spoiler_style',
'label' => $txt['spoiler_tag_label'],
'description' => $txt['spoiler_tag_desc'],
'options' => array(
0 => $txt['spoiler_tag_default'],
1 => $txt['spoiler_tag_onhoverovershow'],
2 => $txt['spoiler_tag_onlinkclickshow'],
3 => $txt['spoiler_tag_onbuttonclickshow'],
),
'type' => 'number',
),
'', '',
array( array(
'id' => 'show_bbc', 'id' => 'show_bbc',

View File

@ -3553,3 +3553,40 @@ img#smflogo
{ {
display: none; display: none;
} }
fieldset.spoiler
{
border: 1px dashed gray;
}
fieldset.spoiler > legend
{
font-size: 1.2em;
}
div.spoilerheader a
{
font-family: sans-serif;
font-size: 1.1em;
font-weight: bold;
}
div.spoilerheader input
{
background-color: #cececc;
color: #3e3e33;
font: 0.9em sans-serif;
}
div.spoilerbody
{
color: #0f0f0f;
border: 1px dotted gray;
padding: 1em;
margin: 1em;
}
fieldset.spoiler div.spoilerbody
{
border: 0px;
padding: 0em;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

View File

@ -263,6 +263,19 @@ function template_settings()
'label' => $txt['hide_post_group'], 'label' => $txt['hide_post_group'],
'description' => $txt['hide_post_group_desc'], 'description' => $txt['hide_post_group_desc'],
), ),
array(
'id' => 'spoiler_style',
'label' => $txt['spoiler_tag_label'],
'description' => $txt['spoiler_tag_desc'],
'options' => array(
0 => $txt['spoiler_tag_default'],
1 => $txt['spoiler_tag_onhoverovershow'],
2 => $txt['spoiler_tag_onlinkclickshow'],
3 => $txt['spoiler_tag_onbuttonclickshow'],
),
'type' => 'number',
),
'', '',
array( array(
'id' => 'show_bbc', 'id' => 'show_bbc',

View File

@ -3650,3 +3650,40 @@ img#smflogo
{ {
display: none; display: none;
} }
fieldset.spoiler
{
border: 1px dashed gray;
}
fieldset.spoiler > legend
{
font-size: 1.2em;
}
div.spoilerheader a
{
font-family: sans-serif;
font-size: 1.1em;
font-weight: bold;
}
div.spoilerheader input
{
background-color: #cececc;
color: #3e3e33;
font: 0.9em sans-serif;
}
div.spoilerbody
{
color: #0f0f0f;
border: 1px dotted gray;
padding: 1em;
margin: 1em;
}
fieldset.spoiler div.spoilerbody
{
border: 0px;
padding: 0em;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

View File

@ -601,4 +601,8 @@ $helptxt['custom_mask'] = 'The input mask is important for your forum\'s securit
</div><br /><br /> </div><br /><br />
More information and advanced techniques may be found on the internet.'; More information and advanced techniques may be found on the internet.';
// Spoiler Tag Mod
$helptxt['defaultSpoilerStyle'] = 'Set this to change the default type of spoiler used on the forum.';
?> ?>

View File

@ -11,4 +11,25 @@ $txt['doublePostHelp'] = 'Time(in Days) before double posting is considered as a
$txt['doublePostAdmin_sub'] = 'Is set as in Days. Click on the "?" if you want more information. Leave Blank to prevent double posting always'; $txt['doublePostAdmin_sub'] = 'Is set as in Days. Click on the "?" if you want more information. Leave Blank to prevent double posting always';
// Spoiler Mod
// BBC Strings
$txt['bbc_spoiler'] = 'Insert Spoiler';
// Post View Text
$txt['spoiler_tag_text'] = 'Spoiler';
$txt['spoiler_tag_click_info'] = '(click to show/hide)';
$txt['spoiler_tag_hover_info'] = '(hover to show)';
// Mod Settings
$txt['defaultSpoilerStyle'] = 'Spoiler Mode';
$txt['spoiler_tag_onhoverovershow'] = 'Show on Hover';
$txt['spoiler_tag_onlinkclickshow'] = 'Show on Link Click';
$txt['spoiler_tag_onbuttonclickshow'] = 'Show on Button Click';
// Extra Settings String for per-theme selection
$txt['spoiler_tag_label'] = 'Spoiler Mode';
$txt['spoiler_tag_desc'] = 'Choose how spoilers will display on the theme.';
$txt['spoiler_tag_default'] = '(use global default spoiler mode)';
?> ?>