live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
req_win bug
« on August 23rd, 2013, 04:29 PM »
Suppose ask() is abused slightly to show a small form for input from the user. All <input> elements inside the popup get a click event and are populated with text.

Code: [Select]
/Themes/default/scripts/script.js (working copy)
@@ -189,7 +189,7 @@
  .html('<section class="nodrag confirm">' + string + '</section><footer><input type="button" class="submit'
  + (modal_type == 1 ? ' floatleft" /><input type="button" class="delete floatright" />' : '" />') + '</footer>')
  .each(animate_popup)
- .find('input')
+ .find('footer input')
  .val(we_cancel)
  .click(function () {
  close_window();
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: req_win bug
« Reply #1, on August 23rd, 2013, 04:31 PM »
I've wanted to use reqwin for popping up modal forms (e.g. registration, login) for ages but I realised all the event handling was screwed anyway.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: req_win bug
« Reply #2, on August 23rd, 2013, 08:35 PM »
It'd be a bad idea, basically.
I did my best to code something that was both modal and with nice effects. It was a bit... unrealistic, to think I could come up with it, but I did. I sort of regret it now, because ask/say functions are still a bit limited in what you can do with them, but still, I don't think I could have stopped myself from using them, ah ah...

Anyway, if you want to do some kind of form popup, you should rely on an actual popup, it's probably safer. <sigh>
Unless you have workarounds, of course...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: req_win bug
« Reply #3, on August 23rd, 2013, 08:55 PM »
Other sites do it, I don't entirely understand why we can't - but I'd be the first to admit I'm not an expert on all the crazy ways JS works.

We already have a modal popup that has two buttons on it. All we really need is for a variation which 1) can indicate that the form shouldn't be able to be cancelled by when clicking outside it, 2) allows the popup to indicate an AJAX post event on clicking one of the buttons before closing the popup.

I'm not sure what else is missing really - essentially it's a variation of what live's talking about - he's abusing an ask() that way, it's only really a formalisation of what he's talking about... I think.

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Re: req_win bug
« Reply #4, on August 23rd, 2013, 09:57 PM »
@Nao> You wrote it ages ago. Now it's high time to use it.

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: req_win bug
« Reply #5, on August 24th, 2013, 10:07 AM »
Last time I tried to use reqWin for something a bit more complex (just loading an image with no HTML), I ended up adding 200+ bytes of code to it, and felt it was overkill for an admin area feature, and reverted my changes. I guess it influenced my post above, and yes, it's still possible to do great things with it.
If you have any suggestions...

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Re: req_win bug
« Reply #6, on August 24th, 2013, 02:43 PM »
Code: [Select]
ask(tmp.innerHTML, null, function (answer)
{
// do stuff

if (answer)
// they hit OK
});

Is that 200 bytes?

tmp is a DOM element with an input, a select, a textarea, and some labels.

The callback is fired when the textual input is clicked.