Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b2b8017f

Von Sven Schöling vor fast 3 Jahren hinzugefügt

  • ID b2b8017f6c6d4780cdfc1a7fcf4661b3dadf4e18
  • Vorgänger 53baaec8
  • Nachfolger bf196481

ImageUpload: modal undismissable + cancel

Unterschiede anzeigen:

js/kivi.ImageUpload.js
5 5
  const M = kivi.Materialize;
6 6

  
7 7
  let num_images = 0;
8
  ns.upload_in_progress = undefined;
8 9

  
9 10
  ns.add_files = function(target) {
10 11
    let files = [];
......
67 68
  };
68 69

  
69 70
  ns.upload_selected_files = function(id, type, maxsize) {
71
    $("#upload_modal").modal({ dismissible: false });
70 72
    $("#upload_modal").modal("open");
71 73

  
72 74
    kivi.FileDB.retrieve_all((myfiles) => {
......
91 93

  
92 94
        let xhr = new XMLHttpRequest;
93 95
        xhr.open('POST', 'controller.pl', true);
94
        xhr.onload = ns.attSuccess;
95
        xhr.upload.onprogress = ns.attProgress;
96
        xhr.upload.onerror = ns.attFailed;
97
        xhr.upload.onabort = ns.attCanceled;
96
        xhr.onload = ns.upload_complete;
97
        xhr.upload.onprogress = ns.progress;
98
        xhr.upload.onerror = ns.failed;
99
        xhr.upload.onabort = ns.abort;
98 100
        xhr.send(data);
101

  
102
        ns.upload_in_progress = xhr;
99 103
      });
100 104
    });
101 105
  };
102 106

  
103
  ns.attProgress = function(event) {
107
  ns.progress = function(event) {
104 108
    if (event.lengthComputable) {
105 109
      var percent_complete = (event.loaded / event.total) * 100;
110
      console.log(percent_complete);
106 111
      $("#upload_progress div").removeClass("indeterminate").addClass("determinate").attr("style", "width: " + percent_complete + "%");
107 112
    }
108 113
  };
109 114

  
110
  ns.attFailed = function() {
115
  ns.failed = function() {
111 116
    $('#upload_modal').modal('close');
112 117
    M.flash(kivi.t8("An error occurred while transferring the file."));
113 118
  };
114 119

  
115
  ns.attCanceled = function() {
120
  ns.abort = function() {
116 121
    $('#upload_modal').modal('close');
117 122
    M.flash(kivi.t8("The transfer has been canceled by the user."));
123

  
124
    ns.upload_in_progress = undefined;
118 125
  };
119 126

  
120
  ns.attSuccess = function() {
127
  ns.upload_complete = function() {
121 128
    $('#upload_modal').modal('close');
122 129
    M.flash(kivi.t8("Files have been uploaded successfully."));
123 130
    kivi.FileDB.delete_all(ns.reload_images);
templates/mobile_webpages/image_upload/local_list.html
54 54

  
55 55
<div id="upload_modal" class="modal">
56 56
  <div class="modal-content">
57
    <h4>Uploading</h4>
57
    <h4>[% 'Uploading' | $T8 %]</h4>
58 58

  
59 59
    <div id="upload_progress" class="progress">
60 60
      <div class="indeterminate"></div>
61 61
    </div>
62

  
63
    [% P.M.button_tag("kivi.ImageUpload.upload_in_progress.abort()", LxERP.t8("Abort"), class="modal-close") %]
62 64
  </div>
63 65
</div>
64 66

  

Auch abrufbar als: Unified diff