Clickable link revealing hidden pop-up textbox (like an Alert)

MachineGunHarry
MachineGunHarry
edited September 2014 in Campaign Portal Building
Had a cool idea to assist in one of the PbP's I am in. BUT, once again my long search (scouring the Internet) in how to carry it out has ended in OP not supporting the code. In this case it is the 'onclick' function using the {alert()} script. My thought was to have a hidden text box that would be exposed when clicking a hyperlink. Thus, allowing me to hide OOC comments inline with the actual story, including dice rolls. I was using 'title', but that really is limited to certain platforms, touchscreen devices NOT being one of those.

So TWO questions. First, has someone already composed a list of workable functions on Obsidian Portal. That would be a great resource.

Second, does someone have a workable alternative to my unworkable solution? This a clickable link, that would allow for a pop-up textbox, much like an Alert to pop up providing hidden text, that is workable on a touchscreen device (hence the need to be a clickable link, rather than a rollover). I would prefer inline code if possible.

Comments

  • MachineGunHarry
    MachineGunHarry
    Posts: 115 edited September 2014
    I found that javascript can be substituted in an html editor, but it still doesn't work on Obsidian Portal. Here is the code. Can anyone tell me why its not working? Does something have to be added to the CSS?

    This is the Hyperlink

    The onclick html code is this:

    Visible text
    Post edited by MachineGunHarry on
  • MachineGunHarry
    MachineGunHarry
    Posts: 115 edited September 2014
    .
    Post edited by MachineGunHarry on
  • SkidAce
    SkidAce
    Posts: 830
    I think I saw a campaign where "hover" worked similar to what you are discussing.

    I remember checking it out, hovering over stuff, and a little "pop up" showing up.

    No clue where I saw it. Might try searching the threads for "pop up" or "hover".
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    I was using 'title' as a handle (this would be like what we used on the interactive map in A Hero's Odyssey), but it only works on desktops and laptops. I was hoping to have something functional on a touchscreen device.

    In will try searching 'pop up' in the threads. That is something I hadn't considered.
  • Basileus
    Basileus
    Posts: 585 edited September 2014
    A work in progress solution. This should be possible with pseudo-selectors and the adjacent-sibling selector. It isn't really practical yet, but this is what I have so far.

    Some oddities at the moment I haven't figure out yet: This doesn't work with spans, so it can't be placed in the midst of text/paragraphs, but has to be its own. Also once you lose focus it stops working until you click on something else, then it works again.

    Anyway, CSS:

    @.popupcontent {display: none; position: fixed; border: solid 1px black; padding: 1em; background: white; color: black;}
    .popupbutton:active + .popupcontent {display: block;}@

    Only the selectors and the display properties are really relevant for functionality, the rest is basic styling.

    Then HTML on the page:

    @Test
    Test popup text.@

    The ".popupbutton" class can then be styled to look however you want (like a normal link, a button, etc...)


    Currently have a test up here: "Test":https://outremer.obsidianportal.com/wikis/test

    EDIT: Scratch the bit about only working once. That was the case with IE but doesn't appear to be so on the iPhone.
    Post edited by Basileus on
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    Basileus! I knew you would come up with this answer. I thought of just messaging you privately. But then I thought, "Nah, I gotta let the forums know how awesome you are at this stuff!" Dude that is amazing! You are like a freaking OP god! Pretty soon "CrIsis":https://a-god-rebuilt.obsidianportal.com will be seeking your advice where the holy left testicle of Osiris is hidden.
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    It works great on my Android as well.
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    @basileus - Is there something that can be added to the CSS to force it to be more in the center (or at least higher up)? It is totally visible in portrait, but too low to be seen in landscape.
  • NikMak
    NikMak
    Posts: 379
    have you tried the 'top:xx%' command in the div class descriptor in ccs?

    My floating nav bar (as per here https://the-great-pendragon.obsidianportal.com/wikis/main-page ) has something along the lines of .navbar{right:25px; width:175px; top:36%;} in the CCS to get the position where I want it. But be warned it can do some odd things to the adventure log update section sometimes!
  • Basileus
    Basileus
    Posts: 585 edited September 2014
    Yah, I used fixed positioning to make it positioned relative to the browser window rather than other elements. Per NikMak's method, something like this would do the trick (add into the ".popupcontent" CSS):

    @top: 35%; left: 25%; width: 50%; z-index: 20;@

    Should always be centered horizontally, and start about a third of the way down the screen (should look pretty good per the Rule of Thirds in visual composition).

    Also, LOL @ "Scareder". :D Anyway, check out the test page again to see what this looks like.

    EDIT: Tried it on a phone. Looks cramped in portrait, so I switched the width and left values to make it wider.

    ALSO EDIT: Set a z-index so the sidebar wouldn't overlap it.
    Post edited by Basileus on
  • NikMak
    NikMak
    Posts: 379
    whats up SkidAce? I am missing something here :)
  • SkidAce
    SkidAce
    Posts: 830
    its the code man...and the results...I'm impressed.
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    Just noticed that :

    @.popupbutton:active, .popupbutton:hover + .popupcontent {display: block;}@

    works even better! It makes it stay open until you click the screen again.
  • SkidAce
    SkidAce
    Posts: 830
    Can you post an example MGH?
  • MachineGunHarry
    MachineGunHarry
    Posts: 115 edited October 2014
    SkidAce you can go "HERE":https://blood-in-the-water-1.obsidianportal.com/posts/turn-of-the-tide#comment-151369 . Click on the Bold Underlined "GM NOTE". It gives a good example. On a PC screen it is a mouseover popup box with some hidden information. On a Mobile Device, it is the same popup box, BUT it allows you to keep the box open until you click again on the screen. If you don't add the two modifiers (active AND hover) to .popupbutton, and just do active, the popup box will only stay open while your finger is on the screen.

    By the way, you should be able to attach this an image too. Furthermore you can attach it to an link-tag. You have to set the url as "#", so as not to get a blank screen to open up.

    @Button TextHELLO! Secret Content HERE!!!@
    Post edited by MachineGunHarry on
  • cgregory
    cgregory
    Posts: 780
    Thanks could be useful.

    They are among us!

    image

                       XCom: Defiance - Campaign of the Month November 2016

     

     

  • Bortas
    Bortas
    Posts: 645
    I'm ready to do something similar on my campaign, and I can't seem to get the popup to display... any tips for me?

    CSS: @.popupcontent {display: none; position: fixed; border: solid 1px black; padding: 1em; background: white; color: black; top: 35%; left: 25%; width: 50%; z-index: 20;}
    .popupbutton:active + .popupcontent {display: block;}@

    HTML: @Test
    Test popup text.@

    Thanks,

    -bort
    "Morwindl":http://morwindl.obsidianportal.com
  • Bortas
    Bortas
    Posts: 645
    Hmmm... must be me. I cut & paste the code to a new wiki page and it works fine, but can't seem to add it to an existing one where I want. Investigating...

    Sorry for the bother!

    -bort
    "Morwindl":http://morwindl.obsidianportal.com
  • Unknown
    I am working on a similar project. The one issue I have right now is that when someone on mobile clicks the link to get the tooltip they are jumped to the top of the page rather than being left where they are. If someone has a suggestion on how to clean that up it would be awesome:

    *CSS*

    /* TOOLTIP TEST */
    .mobile-tooltip {
    position: relative;
    background: transparent;
    cursor: help;
    display: inline-block;
    text-decoration: none;
    color: #222;
    outline: medium none;
    }

    .mobile-tooltip span {
    visibility: hidden;
    position: absolute;
    bottom: 30px;
    left: 50%;
    z-index: 999;
    width: 280px;
    margin-left: -127px;
    padding: 10px;
    border: 2px solid #CCC;
    opacity: 0.9;
    background-color: #DDD;
    background-image: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    border-radius: 4px;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4), 0px 1px 0px rgba(255, 255, 255, 0.5) inset;
    text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.4);
    }

    .mobile-tooltip:hover {
    border: 0; /* IE6 fix */
    cursor:help;
    }

    .mobile-tooltip:hover span {
    visibility: visible;
    }

    .mobile-tooltip span:before, .mobile-tooltip span:after {
    content: "";
    position: absolute;
    z-index: 1000;
    bottom: -7px;
    left: 50%;
    margin-left: -8px;
    border-width: 8px 8px 0px;
    border-style: solid solid none;
    border-color: #DDD transparent -moz-use-text-color;
    }

    .mobile-tooltip span:before {
    border-top-color: #CCC;
    bottom: -8px;
    }

    .navy span {
    color: #FFF;
    text-shadow: 0px 1px 0px #000;
    border-color: #161A1F;
    background-color: #1E2227;
    }

    .navy span:after {
    border-top-color: #1E2227;
    }

    .navy span:before {
    border-top-color: #161A1F;
    }
    /* END TOOLTIP */

    *HTML*

    @Item TestLorem ipsum dolor sit amet, no oblique alienum invidunt mel. Eos an virtute equidem. Nibh quodsi moderatius no usu, eam timeam similique an. Quo quem phaedrum interesset ut, eum praesent voluptaria ei. Quo te animal euripidis. Eum ei labitur salutandi contentiones, in duo primis maiorum singulis, id vim quidam ceteros iudicabit.@

    --
    Alex
    "Dragon Age: Requiem":https://dragon-age-requiem.obsidianportal.com/
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    To Bortas and Alex; send us a link to a page that has your sample function.
  • Unknown
    I temporarily made my CSS Test page publicly available which has a demonstration of the tooltip on it. Again, for mine all I need to get resolved is making clicking it not pop you to the top of the site again for mobile users (since desktop can get it simply on a hover):

    "CSS Test Page":https://dragon-age-requiem.obsidianportal.com/wikis/css-test

    --
    Alex
    "Dragon Age: Requiem":https://dragon-age-requiem.obsidianportal.com/
  • Bortas
    Bortas
    Posts: 645
    MGH: I figured out the issue was using textile tables - it won't call the tooltip at all.

    Unfortunately, inside a html table, it will only call the first popup, not additional popups.

    You can see an example "here":https://morwindl.obsidianportal.com/wikis/test. The code for each little area is just cut and paste: first is raw, second is a textile table (no popups), third is HTML table (first only popup).

    @


    @

    @|
    |
    |@

    @

    @

    -bort
    "Morwindl":http://morwindl.obsidianportal.com
  • Unknown
    @Bort:

    Looking at the page with Inspect Element shows that on the HTML based tabled on the second image you have two break tags which is likely botching the display. Many times this is caused with the Textile system still messing with things in the HTML you write. I would suggest trying to remove the return you have between the divs for those and see if it works. Sometimes little things like that can make a significant difference on OP.

    Finally, if all else fails you could use some CSS and add additional classes to the divs so that you could make them appear to be inside of a table without actually needing the table in the first place. That route may be best since some things on OP just don't seem to want to pan out the way we may anticipate (due to not having access to the CSS, JS, etc that they run in the background on the site and being intimately familiar with it and what it will do).

    --
    Alex
    "Dragon Age: Requiem":https://dragon-age-requiem.obsidianportal.com/
  • Bortas
    Bortas
    Posts: 645
    Good call - removing the line breaks between the div in the textile clears things up some - but again, the first pic loads, the second pic does not, just like the HTML table. I hope to have some time to dive into that tonight!

    -bort
    "Morwindl":http://morwindl.obsidianportal.com
  • Unknown
    Interesting -- there could be a couple things causing the issue then I think, will take some work to narrow it down some. What I would like to look into first is seeing if it is the popup design itself conflicting with the table. Try to make an example using the following as it does not make use of divs which tables are known for having issues with:

    *CSS*

    /* TOOLTIP TEST */
    .mobile-tooltip {
    position: relative;
    background: transparent;
    cursor: help;
    display: inline-block;
    text-decoration: none;
    color: #222;
    outline: medium none;
    }

    .mobile-tooltip span {
    visibility: hidden;
    position: absolute;
    bottom: 30px;
    left: 50%;
    z-index: 999;
    width: 280px;
    margin-left: -127px;
    padding: 10px;
    border: 2px solid #CCC;
    background-color: #DDD;
    background-image: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    border-radius: 4px;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4), 0px 1px 0px rgba(255, 255, 255, 0.5) inset;
    text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.4);
    }

    .mobile-tooltip:hover {
    border: 0; /* IE6 fix */
    cursor:help;
    }

    .mobile-tooltip:hover span {
    visibility: visible;
    }

    .mobile-tooltip span:before, .mobile-tooltip span:after {
    content: "";
    position: absolute;
    z-index: 1000;
    bottom: -7px;
    left: 50%;
    margin-left: -8px;
    border-width: 8px 8px 0px;
    border-style: solid solid none;
    border-color: #DDD transparent -moz-use-text-color;
    }

    .mobile-tooltip span:before {
    border-top-color: #CCC;
    bottom: -8px;
    }
    /* END TOOLTIP */

    *HTML*

    @@

    I think this might get it responding how you were overall trying to get, I tested it on my own page and it works fine in both a Textile Table and an HTML Table, but it has a different look than you were getting at originally. It also still has the issue for mobile users where when they click the item they will get pushed to the top of the page and have to scroll back down to see it (still haven't resolved that, but this is the tooltip I am developing to replace the one you are currently using so I will get it worked out sooner or later).

    --
    Alex
    "Dragon Age: Requiem":https://dragon-age-requiem.obsidianportal.com/
  • Bortas
    Bortas
    Posts: 645
    So Alex-

    I had this on my agenda to give a try to, but I needed to finish a project bit of code out, when I encountered some oddity: I was right clicking to get something, and it gave me the image dialog box, and it occurred to me: with the code given above, it doesn't actually stop displaying the popup, it's just transparent. I couldn't mouse over the second item in the table and make it pop up, because it was behind the transparent first one. So I changed the CSS:

    @.popupcontent {position: fixed; top: 10%; left:30%; z-index: 20;
    background-image: url('https://db4sgowjqfwig.cloudfront.net/campaigns/67984/assets/422340/StreamRecentUpdates.png');
    background-size: contain;
    padding: 1em;
    color: #6d0808;
    box-shadow:0 10px 10px 4px rgba(0,0,0,0.3);
    visibility:hidden;
    opacity:0;
    transition:visibility 0s linear 0.5s,opacity 0.5s linear;
    }
    .popupbutton:hover + .popupcontent,
    .popupbutton:active + .popupcontent {
    visibility:visible;
    opacity:1;
    transition-delay:0s;
    }@

    Instead of making it transparent, I just make it not display. No alterations to the HTML. Everything works as it should now.

    I hope someone out there finds this handy.

    -bort
    "Morwindl":http://morwindl.obsidianportal.com
  • Unknown
    Nice catch - you're clearly getting more and more acquainted with CSS as you go along. I'm a little sad I didn't catch that myself now, but that is how it goes sometimes. Multiple perspectives for the win!

    --
    Alex
    "Dragon Age: Requiem":https://dragon-age-requiem.obsidianportal.com/
Sign In or Register to comment.

April 2024
Season of Strife

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions