add dropzonejs demo

pull/2916/head
REJack 4 years ago
parent 216841f578
commit 204758c7ff

@ -24,6 +24,8 @@
<link rel="stylesheet" href="../../plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css"> <link rel="stylesheet" href="../../plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
<!-- BS Stepper --> <!-- BS Stepper -->
<link rel="stylesheet" href="../../plugins/bs-stepper/css/bs-stepper.min.css"> <link rel="stylesheet" href="../../plugins/bs-stepper/css/bs-stepper.min.css">
<!-- dropzonejs -->
<link rel="stylesheet" href="../../plugins/dropzone/min/dropzone.min.css">
<!-- Theme style --> <!-- Theme style -->
<link rel="stylesheet" href="../../dist/css/adminlte.min.css"> <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
</head> </head>
@ -1435,7 +1437,86 @@
<!-- /.card --> <!-- /.card -->
</div> </div>
</div> </div>
</div><!-- /.container-fluid --> <!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="card card-default">
<div class="card-header">
<h3 class="card-title">Dropzone.js <small><em>jQuery File Upload</em> like look</small></h3>
</div>
<div class="card-body">
<div id="actions" class="row">
<div class="col-lg-6">
<div class="btn-group w-100">
<span class="btn btn-success col fileinput-button">
<i class="fas fa-plus"></i>
<span>Add files</span>
</span>
<button type="submit" class="btn btn-primary col start">
<i class="fas fa-upload"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning col cancel">
<i class="fas fa-times-circle"></i>
<span>Cancel upload</span>
</button>
</div>
</div>
<div class="col-lg-6 d-flex align-items-center">
<span class="fileupload-process w-100">
<div id="total-progress" class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress></div>
</div>
</span>
</div>
</div>
<div class="table table-striped" class="files" id="previews">
<div id="template" class="row mt-2">
<div class="col-auto">
<span class="preview"><img data-dz-thumbnail /></span>
</div>
<div class="col d-flex align-items-center">
<p class="mb-0">
<span class="lead" data-dz-name></span>
(<span data-dz-size></span>)
</p>
<strong class="error text-danger" data-dz-errormessage></strong>
</div>
<div class="col-4 d-flex align-items-center">
<div class="progress progress-striped active w-100" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress></div>
</div>
</div>
<div class="col-auto d-flex align-items-center">
<div class="btn-group">
<button class="btn btn-primary start">
<i class="fas fa-upload"></i>
<span>Start</span>
</button>
<button data-dz-remove class="btn btn-warning cancel">
<i class="fas fa-times-circle"></i>
<span>Cancel</span>
</button>
<button data-dz-remove class="btn btn-danger delete">
<i class="fas fa-trash"></i>
<span>Delete</span>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- /.card-body -->
<div class="card-footer">
Visit <a href="https://www.dropzonejs.com">dropzone.js documentation</a> for more examples and information about the plugin.
</div>
</div>
<!-- /.card -->
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section> </section>
<!-- /.content --> <!-- /.content -->
</div> </div>
@ -1476,6 +1557,8 @@
<script src="../../plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script> <script src="../../plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<!-- BS-Stepper --> <!-- BS-Stepper -->
<script src="../../plugins/bs-stepper/js/bs-stepper.min.js"></script> <script src="../../plugins/bs-stepper/js/bs-stepper.min.js"></script>
<!-- dropzonejs -->
<script src="../../plugins/dropzone/min/dropzone.min.js"></script>
<!-- AdminLTE App --> <!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script> <script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes --> <!-- AdminLTE for demo purposes -->
@ -1557,6 +1640,59 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
window.stepper = new Stepper(document.querySelector('.bs-stepper')) window.stepper = new Stepper(document.querySelector('.bs-stepper'))
}); });
// DropzoneJS Demo Code Start
Dropzone.autoDiscover = false;
// Get the template HTML and remove it from the doumenthe template HTML and remove it from the doument
var previewNode = document.querySelector("#template");
previewNode.id = "";
var previewTemplate = previewNode.parentNode.innerHTML;
previewNode.parentNode.removeChild(previewNode);
var myDropzone = new Dropzone(document.body, { // Make the whole body a dropzone
url: "/target-url", // Set the url
thumbnailWidth: 80,
thumbnailHeight: 80,
parallelUploads: 20,
previewTemplate: previewTemplate,
autoQueue: false, // Make sure the files aren't queued until manually added
previewsContainer: "#previews", // Define the container to display the previews
clickable: ".fileinput-button" // Define the element that should be used as click trigger to select files.
});
myDropzone.on("addedfile", function(file) {
// Hookup the start button
file.previewElement.querySelector(".start").onclick = function() { myDropzone.enqueueFile(file); };
});
// Update the total progress bar
myDropzone.on("totaluploadprogress", function(progress) {
document.querySelector("#total-progress .progress-bar").style.width = progress + "%";
});
myDropzone.on("sending", function(file) {
// Show the total progress bar when upload starts
document.querySelector("#total-progress").style.opacity = "1";
// And disable the start button
file.previewElement.querySelector(".start").setAttribute("disabled", "disabled");
});
// Hide the total progress bar when nothing's uploading anymore
myDropzone.on("queuecomplete", function(progress) {
document.querySelector("#total-progress").style.opacity = "0";
});
// Setup the buttons for all transfers
// The "add files" button doesn't need to be setup because the config
// `clickable` has already been specified.
document.querySelector("#actions .start").onclick = function() {
myDropzone.enqueueFiles(myDropzone.getFilesWithStatus(Dropzone.ADDED));
};
document.querySelector("#actions .cancel").onclick = function() {
myDropzone.removeAllFiles(true);
};
// DropzoneJS Demo Code End
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save