Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: dougiefresh on November 30, 2014, 07:40:36 PM

Title: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 30, 2014, 07:40:36 PM
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)



Notice
This 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...

Introduction
This 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 Settings
This 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 Notes
This 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.

Changelog
The changelog can be viewed at XPtsp.com (http://www.xptsp.com/board/free-modifications/expandable-offtopic-bbcode-42/?tab=1).

License
Copyright (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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on November 30, 2014, 09:26:11 PM
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.?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 01, 2014, 05:36:39 PM
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...
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on December 01, 2014, 07:32:32 PM
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)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 02, 2014, 07:08:04 PM
 :P I wasn't trying to be defensive.....  Just stating facts.   ::) Thanks!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 05, 2014, 08:01:40 AM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 06, 2014, 04:18:01 PM
Uploaded v1.2 - December 6th, 2014
o Added code to disable creation of the validation code if BBCode is disabled.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 420Connect.co.uk on December 10, 2014, 05:02:08 AM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: margarett on December 10, 2014, 09:35:41 AM
Yes, most BBC mods don't really add a button to it, just the functionality.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 420Connect.co.uk on December 10, 2014, 12:51:30 PM
Oh...  :P

Do you know if it would it be easy enough to add in a custom button?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: margarett on December 10, 2014, 01:11:03 PM
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 ;)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 420Connect.co.uk 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
(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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 10, 2014, 06:28:10 PM
Uploaded v1.3 - December 10th, 2014
o Added button for the bbcode.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on December 11, 2014, 09:05:10 AM
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
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 11, 2014, 11:53:14 AM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 420Connect.co.uk on December 11, 2014, 01:22:26 PM
I apologize!
I was looking for a quick fix and solved my issue but I thank you for the update and mod! :)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 11, 2014, 07:27:04 PM
@   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!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 29, 2014, 06:16:02 PM
Uploaded v1.4 - December 29th, 2014
o Fixed image install locations within package-info.xml.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on December 29, 2014, 08:40:17 PM
Question. Are you considering adding this function?

[spoiler=some text here]{content goes here}[/spoiler]
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 30, 2014, 04:00:07 AM
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:
Quote
Code (Find) Select
Blah Blah Blah
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on December 30, 2014, 08:27:08 AM
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)


:)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 30, 2014, 04:25:11 PM
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...
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Steve on December 30, 2014, 04:36:34 PM
You're awesome dude. :)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 30, 2014, 05:01:31 PM
Quote from: Steve on December 30, 2014, 04:36:34 PM
You're awesome dude. :)
Thanks!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on January 16, 2015, 07:59:19 PM
Uploaded v1.6 - January 16th, 2015
o License change to Simplified BSD.  No functionality change.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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 ?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 01, 2015, 01:28:44 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: muxen on February 02, 2015, 04:15:08 PM
Hey, which file do I have to edit to translate "show" and "hide"? Thanks for help.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 02, 2015, 04:57:53 PM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: muxen on February 02, 2015, 05:09:11 PM
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  ;)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 03, 2015, 06:41:19 PM
@muxen: Obviously, I can't include strings for a language pack that doesn't exist.....  Thanks anyway....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 19, 2015, 10:27:57 AM
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...
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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).
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Paracelsus on February 28, 2015, 02:40:37 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on March 05, 2015, 11:30:25 AM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on April 06, 2015, 04:50:16 PM
Uploaded v1.8 - April 4th, 2015
o Updated for SMF 2.1 Beta 1
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on July 15, 2015, 03:54:42 AM
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)!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on July 20, 2015, 06:51:12 PM
Uploaded v1.10 - July 20th, 2015
o Remade Spoiler bbcode button with different font.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: BenjCano on November 10, 2015, 11:08:31 AM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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 ;)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: BenjCano on November 10, 2015, 11:34:52 AM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: margarett on November 10, 2015, 11:59:32 AM
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).
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: AceAH47 on November 11, 2015, 04:23:50 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 11, 2015, 07:10:04 PM
I've reproduced the issue you've described.  I'd have to look into the source code to see if I can fix it.....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: natcip on November 12, 2015, 04:17:13 PM
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"
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 13, 2015, 03:14:15 PM
@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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 14, 2015, 01:00:49 PM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: natcip on November 14, 2015, 02:46:51 PM
Thank you. The error seems to be gone now! :)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: AceAH47 on November 14, 2015, 09:04:00 PM
Installed and working perfectly!  Thanks dougie!  :)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 18, 2015, 06:43:13 PM
Uploaded 2.1 - November 16th, 2015
o Added "show" and "hide" parameters to replace default "show"/"hide" text with user specified text.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: natcip on November 26, 2015, 02:44:13 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Shambles on November 26, 2015, 03:55:35 PM
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
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on November 26, 2015, 04:59:29 PM
That should work.....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: natcip on December 05, 2015, 11:42:11 AM
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:
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 05, 2015, 07:43:28 PM
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.....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 09, 2015, 11:41:56 AM
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!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: natcip on December 09, 2015, 01:17:14 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 09, 2015, 02:07:43 PM
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!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 30, 2015, 06:29:47 PM
Uploaded v2.4 - December 30th, 2015
o Fixed minor visual issue with Spoiler tag without parameters.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: ?Almirena? on January 14, 2016, 06:08:26 AM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on January 15, 2016, 06:36:51 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: ?Almirena? on January 16, 2016, 02:33:26 AM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: gerno on February 12, 2016, 01:05:42 PM
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
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: gerno on February 13, 2016, 04:38:46 AM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 13, 2016, 09:25:37 PM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: spiritus_infernus on February 14, 2016, 04:24:23 AM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 14, 2016, 08:18:16 AM
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]
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: spiritus_infernus on February 14, 2016, 08:43:44 AM
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)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 14, 2016, 10:49:14 AM
What version of this mod are you using?  Cause I've just tested with version 3.0 and it functions as expected for me....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: spiritus_infernus on February 14, 2016, 01:37:20 PM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 14, 2016, 04:24:57 PM
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.....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Darkness_Black on February 16, 2016, 03:17:42 PM
Good afternoon, in index.english missing $txt["debug_show"] = "SHOW";
Mod working  ;)
How do I show in button?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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';
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Darkness_Black on February 16, 2016, 07:48:18 PM
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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 17, 2016, 09:20:31 AM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on April 04, 2016, 04:08:25 PM
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!
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Kortal on January 17, 2017, 05:10:30 PM
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)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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)? My vote would be to leave it as is OR have an option to have the lines or not. :)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Kortal on January 18, 2017, 01:12:59 PM
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)
Title: Re: Expanding & Collapsing Spoiler Tag [BUG?]
Post by: rez_spb on February 10, 2017, 02:15:37 AM
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:
Expected behavior:
Actual results:

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 &#149; </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 &#149; </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_show"] . '</a>\'; }" /><b>' . $txt['spoiler'] . ': $1 &#149; </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 &#149; </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 &#149; </b><a href=\\\'#\\\' onClick=\\\'return false;\\\'>' . $txt["debug_show"] . '</a>\'; }" /><b>' . $txt['spoiler'] . ': $1 &#149; </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] &#149;</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] &#149;</b> <a href=\'#\' onClick=\'return false;\'>$show</a>'; }" />
<b>$text: $data[1] &#149;</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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on February 10, 2017, 11:14:13 AM
Uploaded v3.2 - February 10th, 2017
o 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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: rez_spb on February 10, 2017, 12:56:16 PM
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).
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on September 15, 2017, 09:07:25 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on September 16, 2017, 09:16:36 PM
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;
}

Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on September 17, 2017, 03:36:08 PM
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)
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on September 18, 2017, 02:39:41 PM
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.

Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on September 18, 2017, 02:50:23 PM
@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:
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 09, 2017, 12:14:59 PM
@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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on December 09, 2017, 08:01:58 PM
@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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 09, 2017, 10:12:33 PM
@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....  :-[
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: 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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 18, 2017, 09:34:10 AM
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....
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: Wellwisher on December 18, 2017, 04:34:22 PM
@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?
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 18, 2017, 04:40:28 PM
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.
Title: Re: Expanding & Collapsing Spoiler Tag
Post by: dougiefresh on December 21, 2017, 11:22:03 AM
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).