Nao

  • Dadman with a boy
  • Posts: 16,082
Attachment handler bug
« on April 28th, 2012, 03:02 PM »
This is minor but should be fixed because there's code in the implementation that doesn't work as expected.

Reproducing: attach 2 files to a post (let's say there are 4 attachments max), and save.

Edit post again. There are two files in there, let's click to add one.. Done... Click again to add one... Done. The Browse button is still active, even though we technically reached the limit.
Now, go to post.js and do this.checkActive() BEFORE current_element is assigned to element. This fixes the bug.
However, it creates another one -- if you then click Delete to remove one of the files, the Browse button is still disabled. This bug might be due to my rewrite though, as I changed a few blocks in here (which is why I'd rather we discuss this bug than commit something and force me to resolve the conflict, eh eh.)

Anyway, I'm sure it's an easy fix, but I didn't write the code logic so I'm not sure how best to handle it without looking into it very seriously. (And I have to leave for now.)
Re: Attachment handler bug
« Reply #1, on April 28th, 2012, 08:52 PM »
Okay, the disable=false not triggering bug was that it was targetting the wrong input, because of a buggy current_element assignation at the end of the input creation code. (The longer one, not the createFileSelector one.)
Removing it fixed it...
(Plus, as usual -- it saves 32 extra bytes :P)
Re: Attachment handler bug
« Reply #2, on April 28th, 2012, 09:06 PM »
Saved another 14 bytes by converting the this.parentNode stuff with:

Code: [Select]
$(this.parentNode.element).remove();
$(this.parentNode).remove();

It sounds too good to be true, but jQuery allows objects to remove themselves... Any idea why you didn't do it that way, Pete? In case you didn't know it's possible, here's me making sure to spread the word :)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Attachment handler bug
« Reply #3, on April 28th, 2012, 09:34 PM »
The original version of the code that I got it from, and two adapted versions (first for SimpleDesk, second for Wedge), none of those used jQuery.

Sounds good to me though :)
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,082