mardi 28 juin 2016

Formstone upload maxQueue not working

I am using this plugin jquery https://formstone.it/components/upload/ and everything works perfect, but ... has an option to limit the maximum file up and does not work, called "maxQueue".

My code is this:

var $filequeue,
    $filelist;

    $filequeue = $(".filelist.queue");
    $filelist = $(".filelist.complete");

    $(".upload").upload({
        label: "SUELTA AQUI",
        maxQueue: 1,
    }).on("start.upload", onStart)
      .on("complete.upload", onComplete)
      .on("filestart.upload", onFileStart)
      .on("fileprogress.upload", onFileProgress)
      .on("filecomplete.upload", onFileComplete)
      .on("fileerror.upload", onFileError);

function onStart(e, files) {
    console.log("Start");
    var html = '';
    for (var i = 0; i < files.length; i++) {
        html += '<li data-index="' + files[i].index + '"><span class="file">' + files[i].name + '</span><span class="progress">Cola</span></li>';
    }
    $filequeue.append(html);
}

function onComplete(e) {
    console.log("Complete");
    // All done!
}

function onFileStart(e, file) {
    console.log("File Start");
    $filequeue.find("li[data-index=" + file.index + "]")
              .find(".progress").text("0%");
}

function onFileProgress(e, file, percent) {
    console.log("File Progress");
    $filequeue.find("li[data-index=" + file.index + "]")
              .find(".progress").text(percent + "%");
}

function onFileComplete(e, file, response) {
    console.log("File Complete");
    if (response.trim() === "" || response.toLowerCase().indexOf("error") > -1) {
        $filequeue.find("li[data-index=" + file.index + "]").addClass("errorb")
                  .find(".progress").text(response.trim());
    } else {
        var $target = $filequeue.find("li[data-index=" + file.index + "]");
        $target.find(".file").text(file.name);
        $target.find(".progress").remove();
        $target.appendTo($filelist);
        console.log(response);
    }
}

function onFileError(e, file, error) {
    console.log("File Error");
    $filequeue.find("li[data-index=" + file.index + "]").addClass("errorb")
              .find(".progress").text("Error: " + error);
}

                            <div class="upload target" data-upload-options='{"action":"<?php echo get_template_directory_uri().'/inc/upload.php'; ?>", "maxSize": "1048576", "maxQueue": "1"}'></div>

Everything works perfect, but there is no limit, lets you upload 1, 10, 100 or all you want.

What can be wrong?

Aucun commentaire:

Enregistrer un commentaire