summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gallery/controllers/uploader.php8
-rw-r--r--modules/gallery/css/gallery.css4
-rw-r--r--modules/gallery/views/form_uploadify.html.php32
-rw-r--r--modules/gallery/views/form_uploadify_buttons.html.php1
4 files changed, 38 insertions, 7 deletions
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php
index 85d344d6..fb496f60 100644
--- a/modules/gallery/controllers/uploader.php
+++ b/modules/gallery/controllers/uploader.php
@@ -102,6 +102,14 @@ class Uploader_Controller extends Controller {
}
}
+ public function status($success_count, $error_count) {
+ // The "errors" won't be properly pluralized :-/
+ print t2("Uploaded %count photo (%error errors)",
+ "Uploaded %count photos (%error errors)",
+ $success_count,
+ array("error" => $error_count));
+ }
+
public function finish() {
access::verify_csrf();
diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css
index fb72bd48..8012c6cc 100644
--- a/modules/gallery/css/gallery.css
+++ b/modules/gallery/css/gallery.css
@@ -78,6 +78,10 @@
margin-bottom: 0
}
+#g-add-photos-status-message {
+ float: right;
+}
+
/* Permissions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#g-edit-permissions-form {
diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php
index 2ed7912f..36f5f284 100644
--- a/modules/gallery/views/form_uploadify.html.php
+++ b/modules/gallery/views/form_uploadify.html.php
@@ -3,7 +3,24 @@
<script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script>
<script type="text/javascript">
<? $flash_minimum_version = "9.0.24" ?>
+ var success_count = 0;
+ var error_count = 0;
+ var updating = 0;
$("#g-add-photos-canvas").ready(function () {
+ var update_status = function() {
+ if (updating) {
+ // poor man's mutex
+ setTimeout(function() { update_status(); }, 500);
+ }
+ updating = 1;
+ $.get("<?= url::site("uploader/status/_S/_E") ?>"
+ .replace("_S", success_count).replace("_E", error_count),
+ function(data) {
+ $("#g-add-photos-status-message").html(data);
+ updating = 0;
+ });
+ };
+
if (swfobject.hasFlashPlayerVersion("<?= $flash_minimum_version ?>")) {
$("#g-uploadify").uploadify({
width: 150,
@@ -40,13 +57,12 @@
onComplete: function(event, queueID, fileObj, response, data) {
var re = /^error: (.*)$/i;
var msg = re.exec(response);
- if (msg) {
- $("#g-add-photos-status ul").append(
- "<li class=\"g-error\">" + fileObj.name + " - " + msg[1] + "</li>");
- } else {
- $("#g-add-photos-status ul").append(
- "<li class=\"g-success\">" + fileObj.name + " - " + <?= t("Completed")->for_js() ?> + "</li>");
- }
+ $("#g-add-photos-status ul").append(
+ "<li id=\"q" + queueID + "\" class=\"g-success\">" + fileObj.name + " - " +
+ <?= t("Completed")->for_js() ?> + "</li>");
+ setTimeout(function() { $("#q" + queueID).slideUp("slow") }, 5000);
+ success_count++;
+ update_status();
return true;
},
onError: function(event, queueID, fileObj, errorObj) {
@@ -73,6 +89,8 @@
$("#g-add-photos-status ul").append(
"<li class=\"g-error\">" + fileObj.name + msg + "</li>");
$("#g-uploadify" + queueID).remove();
+ error_count++;
+ update_status();
},
onSelect: function(event) {
if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) {
diff --git a/modules/gallery/views/form_uploadify_buttons.html.php b/modules/gallery/views/form_uploadify_buttons.html.php
index ce4d989c..e002d82d 100644
--- a/modules/gallery/views/form_uploadify_buttons.html.php
+++ b/modules/gallery/views/form_uploadify_buttons.html.php
@@ -7,4 +7,5 @@
<button id="g-upload-cancel-all" class="ui-state-default ui-corner-all ui-state-disabled" onclick="$('#g-uploadify').uploadifyClearQueue();return false;" disabled="disabled">
<?= t("Cancel uploads") ?>
</button>
+ <span id="g-add-photos-status-message" />
</div>