1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Implemented Changes to XenForo.AutoInlineUploader to support multiple file inputs

Discussion in 'Closed Suggestions' started by xfrocks, Sep 26, 2011.

  1. xfrocks

    xfrocks Well-Known Member

    Hi there,

    I'm currently working on an add-on and I tried to use the XenForo.AutoInlineUploader. It's great! But there is one small problem with it: it doesn't support multiple file inputs very well. Let say I have 2 file inputs in my form, after the first inline upload, there will be 4 file inputs, after another upload, there will be 16 file inputs (because the replaceAll replace each file input with 2 file inputs, doh!).

    I have worked through the problem so I'm just asking you guys to implement it in the next version of XenForo. Please do this... (otherwise I will have to remove the awesome inline upload feature or I will have to manually edit every upgrade). Here is the changed version (very little changes but it's hard to point them individually, I highlighted the changed lines)

    XenForo.AutoInlineUploader = function($form)
    * Fires when the contents of an input:file change.
    * Submits the form into a temporary iframe.
    * @param event e
     var $uploader = $form.find('input:file').each(function(){
     var $target = $(this);
    if ($(e.target).val() != '')
    var $iframe,
    $iframe = $('<iframe src="about:blank" style="display:none; background-color: white" name="AutoInlineUploader"></iframe>')
    var $iframe = $(e.target),
    ajaxData = $iframe.contents().text(),
    eComplete = null;
    // Opera fires this function when it's not done with no data
    if (!ajaxData)
    return false;
    // alert the global progress indicator that the transfer is complete
     $uploader = $uploaderOrig.clone(true).replaceAll($target);
    // removing the iframe after a delay to prevent Firefox' progress indicator staying active
    setTimeout(function() { $iframe.remove(); }, 500);
    ajaxData = $.parseJSON(ajaxData);
    console.info('Inline file upload completed successfully. Data: %o', ajaxData);
    return false;
    if (XenForo.hasResponseError(ajaxData))
    return false;
    $('input:submit', this.$form).removeAttr('disabled');
    eComplete = new $.Event('AutoInlineUploadComplete');
    eComplete.$form = $form;
    eComplete.ajaxData = ajaxData;
    if (!eComplete.isDefaultPrevented() && ajaxData.message)
    XenForo.alert(ajaxData.message, '', 2500);
    (removed for easy reading)
     var $uploaderOrig = $target.clone(true);
    Thank you very much!
    Marcus, Crazy-Achmet and Andy.N like this.
  2. xfrocks

    xfrocks Well-Known Member

    1.1 beta is going out today. Can you guys include this? Please?
  3. Andy.N

    Andy.N Well-Known Member

    Looks like xfrocks is working on my addon so I support his request. :)
    Please consider his question.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    I flagged this to Kier and Mike and although it's too late to make it into 1.1 Beta 1 today due to a lack of available testing time, it may be possible to include it with the next Beta release.
    yavuz and xfrocks like this.
  5. Andy.N

    Andy.N Well-Known Member

    Thanks for bringing this to the team's attention and hope you can remind them again so it can be included in next release.
  6. Crazy-Achmet

    Crazy-Achmet Active Member

    I also support this request! :)
  7. xfrocks

    xfrocks Well-Known Member

    Can we have a response from the devs on this? :D
  8. Kier

    Kier XenForo Developer Staff Member

    I'm testing it.
  9. ragtek

    ragtek Guest

    moved to implemented?

  10. Kier

    Kier XenForo Developer Staff Member

    If someone would like to send me some code to test it with multiple inputs, please do so.
  11. xfrocks

    xfrocks Well-Known Member

    Thank you very much! Btw, I sent you a message ;)

Share This Page