Fandom Developers Wiki
Advertisement

This is the talk page for discussing improvements to the AjaxPoll page.

Script suddenly stopped working[]

I installed this script on my wiki to add a poll on its main page. Everything was working correctly: people were actively voting and giving it one of the custom styles went flawlessly. However, the next morning the script bugged out for some reason and now both on the page where the <div> is placed, as well as the wiki's main page, only the words [object Object] appear instead.

I checked all related pages: the Discussions post where the poll was created, the page where the <div> is placed, the wiki's MediaWiki.Common.css where the custom style is set, and the wiki's main page (although I've already removed the poll's code there), and everything appears to be in order and just as I left it, with no one else having meddled with them.

Is this a temporary bug? If so, are there any records of it happening often? I really wouldn't like my wiki to randomly appear with errors on its main page and for unspecified periods of time.

Thank you in advance.

UPDATE: I checked another wiki where the script is also installed and the issue is appearing there too. I can confirm it had been working correctly there ever since it was installed, so that would mean the error is happening globally. If it's in your hands, please fix it as soon as possible.

LaVey (talk) 10:37, 6 April 2021 (UTC)

This should be fixed now. -- Cube-shaped garbage can 15:55, 6 April 2021 (UTC)
It is indeed! Thanks a lot for the heads up.
LaVey (talk) 15:57, 6 April 2021 (UTC)

Link to poll in title?[]

AjaxPoll worked great on the first time we used it. I was wondering though: could you add an optional parameter to make the poll title a link to the poll in Discussions? While for our first use I think it was appropriate not to have such a link, I can definitely see future polls where discussion may be encouraged, and offering it as a title link would make that experience a little smoother than putting a link manually before/after the poll. Thank you for AjaxPoll, and for your consideration! AimeePlaysMSM (talk) 04:52, 2 February 2022 (UTC)

As an alternative, you can create a template with code like the follwing:
([{{#replace:{{fullurl:!}}|/wiki/!|/f/p/{{{1}}}}} link])
<div class="d-poll" data-id="{{{1}}}"></div>
Using the template, it would add a linked word "(link)" above the poll which links to the original poll. Other advantages are that it would avoid cluttering a page with unnecessary HTML tags, and that the link would work even on mobile or when the JavaScript isn't loaded for whatever reason.
Nam 23:56, 8 February 2022 (UTC)

'Discussions' styling doesn't display percentage bars[]

The 'Discussions' styling currently isn't displaying the percentage bars for each option on a poll as votes are cast. I can confirm that this issue has been happening for a long time, as I did a test with it about a year ago on a sandbox wiki and even then it didn't display the bars. I was fearing the styling didn't display correctly due to custom CSS used on certain wikis, but the sandbox wiki I'm talking about doesn't have any custom or other effects added. Could you give it a look, please?

Thank you in advance.

LaVey (talk) 14:54, 7 February 2022 (UTC)

can you link the wiki where this script is used? ARandomCitizen (talk) 07:25, 8 February 2022 (UTC)
Sure.
UPDATE: I can see the percentage bars now, but barely; they're almost invisible.
LaVey (talk) 07:30, 8 February 2022 (UTC)
You can change the color of that bar with
.d-poll__answerBar > div { background-color: your_color !important;}

with your_color is the color of your choice ARandomCitizen (talk) 07:44, 8 February 2022 (UTC)

Awesome! I'll give it a try right away (and report back if I couldn't make it work). Thanks you very much.
LaVey (talk) 07:47, 8 February 2022 (UTC)
One last thing, if it's not much to ask - is there a way to change the colors of the [VOTE] button? I tried making tests with the Theme Designer but couldn't find if the colors are taken from other settings.
LaVey (talk) 03:59, 14 February 2022 (UTC)
you can change the background and color of the selector .d-poll input[type="submit"] and .d-poll input[type="submit"]:hover. Also the button by default has the accent color as text color, and accent's label color (which is dependent on the accent color) as background color, and I realized it doesnt look good so i changed it back. ARandomCitizen (talk) 09:44, 14 February 2022 (UTC)

Looks better already, thank you. How and where do I use the .d-poll input codes, though? Should I replace the "submit" parts with my custom colors?

LaVey (talk) 09:53, 14 February 2022 (UTC)

/* AjaxPoll Vote button */
.d-poll input[type="submit"] {
    background-color:
    color:
}

/* AjaxPoll Vote button when hovered */
.d-poll input[type="submit"]:hover {
    background-color:
    color:
}
ARandomCitizen (talk) 09:58, 14 February 2022 (UTC)
This clearly explains its usage. Thank you very much for your help.
LaVey (talk) 10:48, 14 February 2022 (UTC)

Hiding the results before your own vote[]

Is it possible to hide the Poll Results before you vote yourself? So the same way Polls work on the discussion forums /f. AvengingAngel54 (talk) 20:15, 11 August 2023 (UTC)

While you can't hide poll results before you submit the result, you can hide it before you select an answer. You can do it with one line of css:
.d-poll:not(:has(:checked)) :where(.d-poll__answerBar, .d-poll__answerVotes) { display: none; }
If you want to play an animation when it shows, however, you can do so with a little more code (this way also prevents layout shift when using some of the stylesheets mentioned in the article):
/* Set animations for the vote count and the answer bar. */
.d-poll .d-poll__answerVotes {
    transition: opacity 200ms;
}

.d-poll .d-poll__answerBar {
    transition: opacity 200ms, transform 400ms ease-out;
}

/* Hide them when you haven't selected an option yet. */
.d-poll :where(.d-poll__answerBar, .d-poll__answerVotes) {
    opacity: 0;
}

.d-poll .d-poll__answerBar {
    transform: scaleX(0);
    transform-origin: left;
}

[dir='rtl'] .d-poll .d-poll__answerBar {
    transform-origin: right;
}

/* Show them when you select an option. */
.d-poll:has(:checked) :where(.d-poll__answerBar, .d-poll__answerVotes) {
    opacity: 1;
}

.d-poll:has(:checked) .d-poll__answerBar {
    transform: scaleX(1);
}
Hope it helps! Polymeric (talk) 20:49, 11 August 2023 (UTC)
Perfect. Thank you very much. AvengingAngel54 (talk) 18:23, 12 August 2023 (UTC)

Is it possible to remove the Vote Button and "enforce" the vote the moment a User clicks?[]

Hey back again. We are now using the Animation from the previous question. Just a thing I've noticed is that when clicking an option it looks as if you have voted, yet you'd need to click "Vote" in order for your vote to go through. As it's still possible to Cancel your Vote, I'm wondering whether it's plausible to make it so, that clicking on an option already counts as the Vote? Otherwise I'm afraid we cannot use your fancy animation :/ AvengingAngel54 (talk) 17:12, 14 August 2023 (UTC)

Advertisement