diff --git a/cps/static/css/upload.css b/cps/static/css/upload.css new file mode 100644 index 00000000..8192bd39 --- /dev/null +++ b/cps/static/css/upload.css @@ -0,0 +1,8 @@ +@media (min-device-width: 768px) { + .modal-dialog { + position: absolute; + top: 45%; + left: 50%; + transform: translate(-50%, -50%) !important; + } +} diff --git a/cps/static/js/uploadprogress.js b/cps/static/js/uploadprogress.js new file mode 100644 index 00000000..b28d17f3 --- /dev/null +++ b/cps/static/js/uploadprogress.js @@ -0,0 +1,198 @@ +/* + * bootstrap-uploadprogress + * github: https://github.com/jakobadam/bootstrap-uploadprogress + * + * Copyright (c) 2015 Jakob Aarøe Dam + * Version 1.0.0 + * Licensed under the MIT license. + */ +(function($){ + "use strict"; + + $.support.xhrFileUpload = !!(window.FileReader && window.ProgressEvent); + $.support.xhrFormData = !!window.FormData; + + if(!$.support.xhrFileUpload || !$.support.xhrFormData){ + // skip decorating form + return; + } + + var template = '
' + response_text + ''; + } + document.write(xhr.responseText); + } + }, + + set_progress: function(percent){ + var txt = percent + '%'; + if (percent == 100) { + txt = this.options.uploaded_msg; + } + this.$modal_bar.attr('aria-valuenow', percent); + this.$modal_bar.text(txt); + this.$modal_bar.css('width', percent + '%'); + }, + + progress: function(/*ProgressEvent*/e){ + var percent = Math.round((e.loaded / e.total) * 100); + this.set_progress(percent); + }, + + // replace_form replaces the contents of the current form + // with the form in the html argument. + // We use the id of the current form to find the new form in the html + replace_form: function(html){ + var new_form; + var form_id = this.$form.attr('id'); + if(form_id !== undefined){ + new_form = $(html).find('#' + form_id); + } + else{ + new_form = $(html).find('form'); + } + + // add the filestyle again + new_form.find(':file').filestyle({buttonBefore: true}); + this.$form.html(new_form.children()); + } + }; + + $.fn.uploadprogress = function(options, value){ + return this.each(function(){ + var _options = $.extend({}, $.fn.uploadprogress.defaults, options); + var file_progress = new UploadProgress(this, _options); + file_progress.constructor(); + }); + }; + + $.fn.uploadprogress.defaults = { + template: template, + uploaded_msg: "Upload done, processing, please wait..." + //redirect_url: ... + + // need to customize stuff? Add here, and change code accordingly. + }; + +})(window.jQuery); diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 5a340672..94b1e7ee 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -12,6 +12,7 @@ + {% if g.current_theme == 1 %} {% endif %} @@ -103,14 +104,6 @@ {%endif%} {% endfor %} -