Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=3981)
EXPANDING & COLLAPSING SPOILER TAG v3.2B
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) -> Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3981)
NoticeThis mod is no longer being supported. You are strongly encouraged to use Yet Another Spoiler Mod (https://custom.simplemachines.org/mods/index.php?mod=4166) instead...
IntroductionThis modification adds a BBCode to the forum that allows the post author to hide a spoiler in the post, which is clickable to display it to the user.
This BBCode takes the forms:
[nobbc]
[nobbc][spoiler]{content}[/spoiler][/nobbc]
[nobbc][spoiler {params}]{content}[/spoiler][/nobbc]
[nobbc][spoiler=Some Text]{content goes here}[/spoiler][/nobbc]
[/nobbc]
The
{params} section may be any of the following parameters:
o
text - Replaces default "Spoiler" text in the header.
o
quote - Text that follows the "Spoiler" text in the header. Must be in quotes.
o
show - Replaces default "Show" text in the header.
o
hide - Replaces default "Hide" text in the header.
o
guests - Flag to show spoiler to guests or not. May be
n,
no,
false,
y,
yes, or
true.
Note that the form (#3) with the equal sign does not parse other block-level bbcode tags inside the spoiler. Empty form or form with parameters does not have this restriction.
Admin SettingsThis BBCode may be disabled by going into the
Admin =>
Forum =>
Posts and Topics =>
Bulletin Board Code and unchecking the bbcodes you don't want to use. You may also be uninstall this mod in order to disable it.
Compatibility NotesThis mod was tested on SMF 2.0.9, but should work on SMF 2.1 Beta 1, as well as SMF 2.0 and up. SMF 1.x is not and will not be supported.
ChangelogThe changelog can be viewed at XPtsp.com (http://www.xptsp.com/board/free-modifications/expandable-offtopic-bbcode-42/?tab=1).
LicenseCopyright (c) 2015 - 2018, Douglas Orend
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Don't take this wrong because I love your mods and have some installed but I have a question ...
How is this different than http://custom.simplemachines.org/mods/index.php?mod=195 ?
Up-to-date code, etc.?
That mod looks like it supports 3 different types of spoilers, configurable per theme. If I had been aware of that mod, I probably wouldn't have written up this one.... But I needed a simple spoiler bbcode for our site, and thought other people might appreciate this mod. It also has the benefit of being localize-able...
Okies ... I didn't mean to make you defensive ... the mod I pointed out may be overkill for some folks so your mod is a good addition. (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi1262.photobucket.com%2Falbums%2Fii614%2FOPStuph%2Fnewboard%2Fsmilies%2Fourplace%2Fthumbsup13.gif&hash=300bba8db56c05a772ab074440e0f485d00b9803)
:P I wasn't trying to be defensive..... Just stating facts. ::) Thanks!
Uploaded v1.1 - December 5th, 2014
o Made the "show" and "hide" strings localizable.
o Modified code to replace the strings once per page load, instead of every use of the BBCode.
Uploaded v1.2 - December 6th, 2014
o Added code to disable creation of the validation code if BBCode is disabled.
I've just installed this mod; however I can't see any new buttons added to use the [spoiler] tags although I can type them manually and use them?
Yes, most BBC mods don't really add a button to it, just the functionality.
Oh... :P
Do you know if it would it be easy enough to add in a custom button?
Yes, it is ;) But it's up to dougiefresh to do it or not ;)
It only requires another hook, a function and an image.
Check, eg, this MOD (http://custom.simplemachines.org/mods/index.php?mod=3831) or other BBC-kind MODs to see how it's done ;)
Thank you for the reply margarett,
I've since found a similar mod that does what I was looking for
(http://custom.simplemachines.org/mods/index.php?mod=2330) (for anyone in the future)
but good to know for future ideas! :D
margarett to the rescue as always! lol
kindred edit---
edited to remove the d/l link -- 420 - please do not link directly to downloads. Link to the mod page if you must -- and linking to ANOTHER mod in the support thread for this mod is bad manners anyway.
Uploaded v1.3 - December 10th, 2014
o Added button for the bbcode.
Quote from: 420connect.info on December 10, 2014, 02:04:17 PM(link removed)
That wasn't nice. I clicked the link without realizing it would download automatically instead of taking me to the mod page to see it first.
And dougie is EXTREMELY good at what he does and will bend over backward to add functionality to his mods.
Awesome work as always dougie. :D
Quote from: 420connect.info on December 10, 2014, 02:04:17 PM
Thank you for the reply margarett,
I've since found a similar mod that does what I was looking for
(link removed) (for anyone in the future)
but good to know for future ideas! :D
margarett to the rescue as always! lol
I've been working 11+ hour workdays lately.... next time please give me a chance to implement a new idea/suggestion before giving up....
I apologize!
I was looking for a quick fix and solved my issue but I thank you for the update and mod! :)
@ 420connect.info: Kinda annoyed, but no offense taken! :P Yesterday, you had posted right around the time I started my shift. I got home about an hour or so before I posted the new version.... Today I did a longer shift.... Looking forward to the next 2 days off....
Btw, you're welcome!
@Kindred: Thank you!
Uploaded v1.4 - December 29th, 2014
o Fixed image install locations within package-info.xml.
Question. Are you considering adding this function?
[spoiler=some text here]{content goes here}[/spoiler]
Quote from: Steve on December 29, 2014, 08:40:17 PM
Question. Are you considering adding this function?
[spoiler=some text here]{content goes here}[/spoiler]
And what form would the "some text here" take? Do you want it similar to the
code bbcode, where this:
Quote[code=Find]Blah Blah Blah[/code]
would produce this:
QuoteBlah Blah Blah
Yes, without the parenthesis. For example, my current spoiler box in my sig on my forum looks like this:
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi1262.photobucket.com%2Falbums%2Fii614%2FOPStuph%2Fall2%2Fspoilerscreenie.png%7Eoriginal&hash=8a4345dafb3f6182278d8d7bc15383ac6a84ac98)
:)
Uploaded v1.5 - December 30th, 2014
o language.xml file renamed to english.xml
o Added new form of the bbcode: [spoiler=Some Text]Content Here[/spoiler]
o Changed bbcode definition code based on bbcodes defined in Sources/Subs.php...
You're awesome dude. :)
Uploaded v1.6 - January 16th, 2015
o License change to Simplified BSD. No functionality change.
Doesn't work for me?
I well follow your instructions.
I'm using 2.0.8 verion of SMF.
No idea ?
Quote from: AlphA-Fr on February 01, 2015, 11:16:42 AM
Doesn't work for me?
I well follow your instructions.
I'm using 2.0.8 verion of SMF.
No idea ?
Tell me what you are attempting to use and I'll help you.
Hey, which file do I have to edit to translate "show" and "hide"? Thanks for help.
Those language strings are in Themes/default/languages/index.english.php. You only need to translate the "hide" string (which is $txt['debug_hide']) and "spoiler" (which is $txt['spoiler']).
If you'll post your translations, I'll include them in the next version....
Thank you very much, was wondering why only the show part was translated. I doubt you really want my translation, considering there's no language pack for it, but here go: show = pokaži, hide = skrij. It's Slovenian/slovenščina (Slovenia), be careful you don't add it to Slovakian/slovenština ;)
@muxen: Obviously, I can't include strings for a language pack that doesn't exist..... Thanks anyway....
Uploaded 1.7 - February 19th, 2015
o Added text parameter so users will see the specified text instead of Spoiler.
Usage of the new form would be like:
[spoiler text=Usage]Blah Blah Blah[/spoiler]
I am unable to edit the first post of my topic...
@dougiefresh
When you use the Spoiler bbc button it comes up with:
[/spoiler][spoiler] by this order (which is totally wrong and obviously doesn't work).
Quote from: Paracelsus on February 27, 2015, 04:39:07 PM
@dougiefresh
When you use the Spoiler bbc button it comes up with:
[/spoiler][spoiler] by this order (which is totally wrong and obviously doesn't work).
Ok, forget about my previous post, in simple mode the code works flawlessly, but I'm not so sure in WYSIWYG mode, I'll test again later.
This mod only adds to the bbcode list without making no changes to the WYSIWYG mode code. So this problem is, in all likehood, unrelated to this mod.
Uploaded v1.8 - April 4th, 2015
o Updated for SMF 2.1 Beta 1
Uploaded v1.9 - July 15th, 2015
o Fixed missing BBCode button in editor for SMF 2.1 Beta 1.
o Included Swedish UTF8 language modifications by soderlund (http://www.simplemachines.org/community/index.php?action=profile;u=419717)
o Included Norwegian UTF8 language modifications by soderlund (http://www.simplemachines.org/community/index.php?action=profile;u=419717)
Thanks for the language translations, soderlund (http://www.simplemachines.org/community/index.php?action=profile;u=419717)!
Uploaded v1.10 - July 20th, 2015
o Remade Spoiler bbcode button with different font.
Hey there. Hosting a role-playing forum, and want to install the spoiler tag to help keep streams of information separate. I tried to install the mod here, but I got slammed with a 500 server error after the attempt. Luckily I had backed up and was able to hit the bail-out button, but now I'm a little nervous about trying again.
Is there a trick to installing this, or indeed any other mod without crashing the system?
Howdy and welcome ;)
You should get yourself a copy of your forum in another location --> a test site, so that you can try whatever changes you are considering before you launch them live ;)
That being said, error 500 is a server-side error and it is possible that it relates to permissions. Check if the files created by the MOD have permissions set as 777. if so revert them to 644, some hosts don't like 777 ;)
Quote from: margarett on November 10, 2015, 11:13:24 AM
Howdy and welcome ;)
You should get yourself a copy of your forum in another location --> a test site, so that you can try whatever changes you are considering before you launch them live ;)
That being said, error 500 is a server-side error and it is possible that it relates to permissions. Check if the files created by the MOD have permissions set as 777. if so revert them to 644, some hosts don't like 777 ;)
The test forum sounds brilliant. Just setup another forum at an associated url, such as www.example.com/testforum to make sure that it'll work! Genius!
Forgive what may be a very, very simple question, but does checking permissions happen on download, upload, or install?
This is a bit off-topic but here it goes anyway :P
For you to create your test forum you should:
a) copy all your forum folders to the new location (eg: a subfolder "testforum")
b) duplicate your database
c) load and run repair_settings and fix the database name as well as all the paths, so that everything points to your test forum. Don't skip this step, or you will be messing your live forum! ;)
http://wiki.simplemachines.org/smf/Repair_settings.php
About permissions, they are checked in different occasions, depending on what you are doing :P
Regarding the error you are having, they are checked when the server is accessing the files (after the MOD is already installed). The files are requested by PHP but the server rejects serving them due to their permissions (of course, assuming that this is the problem you're having).
Does this mod support left/right/center justifying inside the spoiler tags? With it installed in v2.0.11, the following bbc:
[spoiler]This is normal text.[/spoiler]
[spoiler][left]This is left-justified.[/left][/spoiler]
[spoiler][center]This is centered.[/center][/spoiler]
[spoiler][right]This is right-justified.[/right][/spoiler]
--is producing a functioning spoiler, followed by three spoilers where the SHOW/HIDE bar appears first, and then the formatted text is displayed afterwards, unhidden, with the [/spoiler] end tag tacked on the end.
(Putting the justification tags outside the spoiler tags results in 4 functioning spoilers, each justified correctly. tag and all.)
I ask because we're trying to replace a previous plug-in of unknown authorship which was used to hide a lot of centered images with the format shown above.
I've reproduced the issue you've described. I'd have to look into the source code to see if I can fix it.....
Great mod. Works perfectly. :)
However, when I check the error log it keeps saying there are errors in lines 20, 25 and 31 of Subs-BBCode-Spoiler.php. Also it says "8: Undefined index: spoiler" and "8: Undefined index: debug_hide"
@AceAH47: I've fixed the mod to address the bug report you provided. It will be in the next version. Thank you for the bug report!
@natcip: I'm looking into your bug reports....
Uploaded v2.0 - November 14th, 2015
o Changed all spoiler tags to block-level tags.
o Changed bbcode tag types so that a validation function can be used to parse content inside tags.
o Changed the [spoiler=text]{content}[/spoiler] form to not parse other block-level tags.
o Moved all language modifications to the end of the language file.
@natcip: I couldn't replicate your bug report, so I moved the added language strings to the end of the language file. Hopefully, this will solve your issue....
Thank you. The error seems to be gone now! :)
Installed and working perfectly! Thanks dougie! :)
Uploaded 2.1 - November 16th, 2015
o Added "show" and "hide" parameters to replace default "show"/"hide" text with user specified text.
Hi dougiefresh!
Is there a way to make the content in between [spoiler][/spoiler] only viewable for registered members?
I want the guests to log in first.
Why not use one of the many "hide from guests" mods, in combination?
http://custom.simplemachines.org/mods/index.php?action=search;basic_search=hide+guests
That should work.....
It definitely should work. But using 2 bbcodes at the same time is a bit much, in my opinion [hide][spoiler]content[/spoiler][/hide]
And I can already foresee some users forgetting to use the hide tag or even leaving it out on purpose, if I did it this way.
I tried incorporating the codes from the hide mod into the spoiler mod, but considering my lack of coding skills, it didn't work. :laugh:
After thinking about this particular request for some time today, I've decided that I'll add this one in all three of my expandable mods, and add a switch in the Modification Settings area to force it into members-only mode all the time.... It may be tomorrow or the day after, I'm not sure.....
Uploaded v2.2 - December 9th, 2015
o Added "guests" parameter to show/hide the spoiler to guests. Accepts n, no, false, y, yes, true.
o Added global default setting to hide spoilers from guests.
@natcip: Hopefully, this update will do what you need it to. Thanks for the idea!
Awesome! Thank you so much! :)
Just tested it, and it works great. Except the "please login or register to view this spoiler" message doesn't show up.
Uploaded v2.3 - December 9th, 2015
o Fixed undefined variable error regarding guest needing to login/register.
@natcip: Damn.... I fixed that one. Sorry! Thanks for the bug report!
Uploaded v2.4 - December 30th, 2015
o Fixed minor visual issue with Spoiler tag without parameters.
Hello. Dougiefresh, this is a nifty little mod! Thank you for creating this.
I would like to use an image (gif) instead of the word "spoiler". Presumably this is in the file index.english.php. Could you possibly let me know what I need to do?
Quote from: ?Almirena? on January 14, 2016, 06:08:26 AM
I would like to use an image (gif) instead of the word "spoiler". Presumably this is in the file index.english.php. Could you possibly let me know what I need to do?
Go into
Themes/default/languages/index.english.php and replace this:
$txt['spoiler'] = "Spoiler";
with something like this:
$txt['spoiler'] = "<img src="{URL}" width=x height=y></img>
You can omit
width and
height if you desire, but you need to replace
{URL} with the URL of the image you want to display in it's place.
Hello - thank you, dougiefresh. It works beautifully.
Just for the information of others who may want to do something similar, don't forget the "; at the end...
$txt['spoiler'] = "<img src=http://www.yourdomain.com/images/spoiler.gif></img>";
or whatever URL is appropriate.
Hi, you considered add the parameter {expand} to sho the spoiler expanded by default?
It can be very useful for indexes, titles and sections on a large post.
Thanks
PD: I'm learning english
I'd have to rewrite the mod for that.... Let me see what I can do.
Quote from: dougiefresh on February 12, 2016, 04:51:39 PM
I'd have to rewrite the mod for that.... Let me see what I can do.
Was just a suggestion, but I do not deserve that rewrites the mod just for my suggestion. Needs to be useful to other users and you have to consider your time and dedication.
I appreciate your work.
Thanks.
Uploaded v3.0 - Febrary 13th, 2016
o Added "expand" parameter to indicate whether or not the spoiler is expanded by default.
o Rewrote spoiler validation function to support new parameter.
@gerno: Your request has been implemented. I don't know if other people might find it useful, but there's only one way to find out!!!! :P Thanks for the suggestion!
EDIT: I honestly thought modifying the mod to do this would be more... problematic, I guess you would say.... It turned out to be quite easy....
Hello there, found some strange thing using this spoiler: when placing something inside him instead of text, things making vanished. i.e. if place an image tag in spoiler- image hide. if placing somwthing within sploiler with text - only text shows all other - hides.
How possible solve it?
I tried this:
[spoiler]
Blah Blah Blah
[img width=800 height=600]http://www.hispanicallyspeakingnews.com/uploads/images/article-images/black_panther_spain.jpg[/img]
[/spoiler]
and couldn't duplicate what you are seeing. Could you provide the actual post you are using, so that I can see what is happening? Thanks![/code]
on my forum if I trying to use [_spoiler=with something inside him more than plain text]
for example image code: [_img]http://i.imgur.com/NIFgNqi.jpg[/img]
i will have nothing inside spoiler, except text
[_/spoiler]
as you understand, without _ this symbol
giving such results:
for preview it will show image (at screenshot 1)
for post - will not (screenshot 2)
What version of this mod are you using? Cause I've just tested with version 3.0 and it functions as expected for me....
version 2.4, but when I've wrote a certain dimesions for included image in spoiler it shown. But I think it is not so useful and not even user on forum will diving deep in correct writing image tag in spoiler. Possible edit this by myself? or I can just upgrade version?
I just tried the post contents you provided with mod version 2.4 and had the same results as version 3.0. Please try upgrading to version 3.0 and tell me if the same thing happens.....
Good afternoon, in index.english missing $txt["debug_show"] = "SHOW";
Mod working ;)
How do I show in button?
That's rather odd, cause the default install of SMF 2.x contains the string. You can fix this particular bug report by adding the following line to the Themes/default/languages/index.english.php file:
$txt['debug_show'] = 'show';
Quote from: dougiefresh on February 16, 2016, 07:15:40 PM
That's rather odd, cause the default install of SMF 2.x contains the string. You can fix this particular bug report by adding the following line to the Themes/default/languages/index.english.php file:
$txt['debug_show'] = 'show';
Already fix this, just sent you here to know they need to fix.
My question now is: How do I show in button?
You should be able to click to the word "Show" in the spoiler header in order to get the contents of the spoiler to show....
Uploaded v3.1 - April 4th, 2016
o Added Spanish Latin translation by Rock Lee [BC] (http://www.simplemachines.org/community/index.php?action=profile;u=322597).
@Rock Lee [BC]: Thank you for the translation (http://www.simplemachines.org/community/index.php?topic=530709.msg3868821#msg3868821). It's been included in this version!
Hey, thanks a lot dougiefresh for your hard work on mods.
Would it be possible to change a bit the spoiler design ? something more like quickspoiler or simplespoiler would be very nice.
(I just hate this straight line below the spoiler... lol)
I don't know Dougie's feelings on the subject but here's my unsolicited two cents worth:
Mod designers intentionally design their mods to look different and work different than other mods. Otherwise, what's the point of creating a mod that does the same basic thing as existing mods (in this case, hiding content)? My vote would be to leave it as is OR have an option to have the lines or not. :)
Steve, I totally agree with you.
If i'm using this spoiler, it's because it has way more options than other mods. Most interesting is the option to hide or not to guests.
A good solution would be as you said, to be able to change a bit the layout, then it would be perfect (at least, for me)
Hello!
I have downloaded and installed your mod (
v3.1), and here's the fun part.
Issue:Guests see the spoilers when global 'Check to disable spoilers for guests globally' parameter is set when using 'parsed_equals' form.
S2R:
- install mod v3.1
- forbid guests to see spoilers globally (set $modSettings['spoiler_no_guests'])
- insert spoiler: [spoiler=Guests see me]They really do![/spoiler]
Expected behavior:
- Guests see that spoiler exists
- Spoiler content is hidden
Actual results:
- Guests see that spoiler exist
- Guests see the spoiler contents
Reason:Well actually in this form of the tag no validation is made, and
'type' is set to
'parsed_equals' (so no content could be parsed). The
BBCode_Spoiler_Validate function won't work as it is nor it actually should.
Dirty fix:Disclaimer: not a developer, don't even know PHP, so please adopt this, though it works.
Subs-BBCode-Spoiler.php:Replace:
$bbc[] = array(
'tag' => 'spoiler',
'type' => 'parsed_equals',
'before' => '<div style="padding: 3px; font-size: 1em;"><div style="text-transform: uppercase; border-bottom: 1px solid #5873B0; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; display: block;"><span onClick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerHTML = \'<b>' . $txt['spoiler'] . ': $1 • </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_hide"] . '</a>\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerHTML = \'<b>' . $txt['spoiler'] . ': $1 • </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_show"] . '</a>\'; }" /><b>' . $txt['spoiler'] . ': $1 • </b><a href="#" onClick="return false;">' . $txt["debug_show"] . '</a></span></div><div class="quotecontent"><div style="display: none;">',
'after' => '</div></div></div>',
'disallow_children' => array_unique($disallowed),
'block-level' => true,
);
... with:
$bbc[] = array(
'tag' => 'spoiler',
// type changed
'type' => 'unparsed_equals_content',
// commented out as we get content now
//'before' => '<div style="padding: 3px; font-size: 1em;"><div style="text-transform: uppercase; border-bottom: 1px solid #5873B0; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; display: block;"><span onClick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerHTML = \'<b>' . $txt['spoiler'] . ': $1 • </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_hide"] . '</a>\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerHTML = \'<b>' . $txt['spoiler'] . ': $1 • </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_show"] . '</a>\'; }" /><b>' . $txt['spoiler'] . ': $1 • </b><a href="#" onClick="return false;">' . $txt["debug_show"] . '</a></span></div><div class="quotecontent"><div style="display: none;">',
//'after' => '</div></div></div>',
'disallow_children' => array_unique($disallowed),
// added custom validation or else guests can see everything when using [spoiler=NAME]TEXT[/spoiler]
'validate' => 'BBCode_Spoiler_Validate_equals',
'block-level' => true,
);
Also,
add validation function for this form.
Before:
function BBCode_Spoiler_Validate(&$tag, &$data, &$disabled)
{ ...
... add:
function BBCode_Spoiler_Validate_equals(&$tag, &$data, &$disabled)
{
global $txt, $user_info, $modSettings;
// guests are handled by global forum setting only
if (!empty($modSettings['spoiler_no_guests']) && !empty($user_info['is_guest']))
return ($tag['content'] = $txt['spoiler_no_guest_html']);
$text = $txt['spoiler'];
$show = $txt['debug_show'];
$hide = $txt['debug_hide'];
// don't expand by default
$expand = false;
// parsing is recommended, separate is due to structure
$data[0] = parse_bbc($data[0]);
$data[1] = parse_bbc($data[1]);
$tag['content'] = <<<EOT
<div style="padding: 3px; font-size: 1em;">
<div style="text-transform: uppercase; border-bottom: 1px solid #5873B0; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; display: block;">
<span onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerHTML = '<b>$text: $data[1] •</b> <a href=\'#\' onClick=\'return false;\'>$hide</a>'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerHTML = '<b>$text: $data[1] •</b> <a href=\'#\' onClick=\'return false;\'>$show</a>'; }" />
<b>$text: $data[1] •</b>
EOT;
$tag['content'] = $tag['content'] . '<a href="#" onClick="return false;">' . ($expand ? $hide : $show) . '</a>' . <<<EOT
</span>
</div>
<div class="quotecontent">
EOT;
$tag['content'] = $tag['content'] . '<div style="display: ' . ($expand ? '' : 'none') . ';">' . $data[0] . '</div></div></div>';
}
And one more thing.
When form with extended params is used, and global setting forbids guests to see spoilers, the
'guests=y' part is simply useless. To change this behavior to allow post writer to add a spoiler which can override global setting, following change in
BBCode_Spoiler_Validate function is needed.
Replace:
if ((!empty($modSettings['spoiler_no_guests']) || $guests == 'n' || $guests == 'no' || $guests == 'false') && !empty($user_info['is_guest']))
return ($tag['content'] = $txt['spoiler_no_guest_html']);
... with:
$allow_guests = false;
if ($guests == 'y' || $guests == 'yes' || $guests == 'true') {
$allow_guests = true;
}
// explicit setting overrides global forum setting
if (!empty($modSettings['spoiler_no_guests']) && !empty($user_info['is_guest']) && $allow_guests == false)
return ($tag['content'] = $txt['spoiler_no_guest_html']);
That's it for the feedback.
Uploaded v3.2 - February 10th, 2017o Added code so that the border underneath the "Spoiler" text could be removed.
o Fixed code where guests are not allowed to view spoilers, but could anyways.
o Fixed code where guests were allowed to view spoilers, but couldn't.
Quote from: Kortal on January 17, 2017, 05:10:30 PM
Would it be possible to change a bit the spoiler design ? something more like quickspoiler or simplespoiler would be very nice.
(I just hate this straight line below the spoiler... lol)
@Kortal: I've added an option to remove the border from underneath the "Spoiler" text for you. Hopefully, this helps you.....
I've got a lot on my plate at the moment, so redesigning the mod's appearance isn't on my list of things to do at the moment. If you want to send over some CSS stuff on how you want it to look, I'll consider adding it to the mod.
Quote from: Steve on January 18, 2017, 06:38:02 AM
I don't know Dougie's feelings on the subject but here's my unsolicited two cents worth:
Mod designers intentionally design their mods to look different and work different than other mods. Otherwise, what's the point of creating a mod that does the same basic thing as existing mods (in this case, hiding content)?
@Steve: I'm not against redesigning the mod, just against redesigning it
AT THIS TIME. If anyone wants to send over some CSS stuff on how you want it to look, I'll consider adding it to the mod.
Quote from: Steve on January 18, 2017, 06:38:02 AM
My vote would be to leave it as is OR have an option to have the lines or not. :)
Implemented that way for now.
Quote from: rez_spb on February 10, 2017, 02:15:37 AM
Guests see the spoilers when global 'Check to disable spoilers for guests globally' parameter is set when using 'parsed_equals' form.
@rez_spb: Thank you for the bug report! Unfortunately, it had already been addressed before receiving the bug report, just not published yet....
Quote from: dougiefresh on February 10, 2017, 11:14:13 AM
@rez_spb: Thank you for the bug report! Unfortunately, it had already been addressed before receiving the bug report, just not published yet....
Thank you for your hard work, glad to hear it was already addressed! Will go with your implementation not to break compatibility for the future (I don't actually like dirty hacks).
I need some help, I made some changes to the design. I have turned it into a multi-purpose spoiler tag. Works as coded.
One trouble I am having from a design perspective is trying to target the "hide/ close" button on the spoiler, i basically want to float:right the button and possibly style the button.
Here's what I have done with it, it's mostly visual (gone with a twitter style spoiler tag):
twitter:
(https://i.imgur.com/umDuqg9.jpg)
Your smf mod version I am working on:
(https://i.imgur.com/XDmYs7T.jpg)
I basically need help targetting that button to move to the right. Issue is, i can do that but when i close and open tag again, the button reverts to its original place next to the text.
Quote from: Wellwisher on September 15, 2017, 09:07:25 PM
(https://i.imgur.com/XDmYs7T.jpg)
I basically need help targetting that button to move to the right. Issue is, i can do that but when i close and open tag again, the button reverts to its original place next to the text.
Solved. :)
[id^='msg_'] a {
float: right;
}
Won't that affect every link in every post? As well as the header for quote and code tags?
Quote from: Arantor on September 17, 2017, 03:05:05 AM
Won't that affect every link in every post? As well as the header for quote and code tags?
Yeah, I found that out later. I could implement this but meant reworking a number of div elements. Kinda annoying so I left it like this for the time being:
(https://i.imgur.com/IsRFor6.jpg)
I will go back to it when I have time. If we were able to target that button, it will open up design options for custom themes. Check out the font-awesome icon on the left. 8)
Hmmmm..... Interesting. I like the new design! Would you be willing to share your modded file? I probably can fix this issue real quick... Probably can make it a choice between the current and new design, too....
Quote from: dougiefresh on September 18, 2017, 10:10:36 AM
Hmmmm..... Interesting. I like the new design! Would you be willing to share your modded file? I probably can fix this issue real quick... Probably can make it a choice between the current and new design, too....
Happy to do so, it's only fair since you've built the mod.
Here's the text in
index.english.php file I modded:
$txt['debug_show'] = ' [View]';
$txt['spoiler'] = "This media may contain sensitive material. ";
$txt['debug_hide'] = '[Close]';
FontAwesome added in the <header> tag (some themes already have a version of it installed):
<!--FontAwesome-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
I belay the rest of the styling edits I made were in
Subs-BBcode-Spoiler.php attached to this post.
@dougiefresh I was also trying to add a simple hype-link after the text "This media may contain sensitive material." but I kept failing. Basically I wanted users to be pointed to a 'knowledge-base' article as to what "sensitive material" mean't. :laugh:
@Everybody: Support for all of my current spoiler-inspired mods are going to be discontinued shortly once I get my new "Yet Another Spoiler Mod" written, as it'll combine the functionality of all of them. It will have a bunch of new options, including the ability to switch spoiler styles and the ability to change the default strings used without changing the language files themselves.
@rez_spb: Your changes have been integrated in the above-mentioned mod. Thank you!
@Wellwisher: I apologize for the delay in fixing this issue. But I've got good news for ya. The good news is that I've managed to fix your issue with the mod's Show/Hide link for you. All I had to do was add a class name to the link itself, and BAM! It's focusable for styling changes.....
Yes, I managed to add the brackets and "removed" the colon from the "Spoiler:" text for the WellWisher style, all without changes to the language file, as well as a few other nifty element-targeting tricks! :P
Do you mind if I use WellWisher as the name of the new style?
@dougiefresh this is Christmas come early buddy. Great work! I am quite happy with some credit but honestly there was no need, you've laid out all the hard work so thank you. You're free to implement and use it however you like without the need to credit me. I am pleased this change opens up so many styling options, it will make your mod a must have. Plus on mobile devices, it will look and feel great!
Just viewing it again, it looks so clean and modern! P.S Add capital "S" letter for word "Show". :P
All the best dougiefresh.
@WellWisher: I've also gotten a link in the Spoiler replacement text in the Admin panel to work using HTML.... ;D Man, it took some recoding of the Javascript to make that work correctly.... 8)
UPDATE: Dammit, the HTML link doesn't function yet.... :-[
@WellWisher: Try this: Yet Another Spoiler Mod (http://www.xptsp.com/board/index.php?topic=1627.0). Please note that the logging functionality doesn't quite work yet....
Quote from: dougiefresh on December 11, 2017, 12:12:08 PM
@WellWisher: Try this: Yet Another Spoiler Mod (http://www.xptsp.com/board/index.php?topic=1627.0). Please note that the logging functionality doesn't quite work yet....
Updated mod....
@dougiefresh thanks mate for the update. I will need to test this on my local since my custom theme is shambles atm.
Got a quick question: Say if i uninstall the previous version of your plugin and reinstall it with the current, updated version - will the old spoiler tags disappear?
The posts with spoiler tags are in database. They won't be effected by uninstalling the mod. However, the contents of said spoilers will be revealed to everybody, because the software to translate them is gone.
All development of this mod has been discontinued. Any further development of this spoiler will take place in the Yet Another Spoiler Mod (https://custom.simplemachines.org/mods/index.php?mod=4166). Please note you must uninstall this mod in order to install Yet Another Spoiler Mod (https://custom.simplemachines.org/mods/index.php?mod=4166).