Skip to content

Commit c88d057

Browse files
author
Dan Lasky
committed
event fixes
1 parent 8517b58 commit c88d057

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/shared/js/ajax.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,6 @@
132132
this.fire("abort-queue", {instance:this}, {prefix:true});
133133
},
134134

135-
handleProgress: function(e) {
136-
this.fire("progress", {
137-
percent: e.totalSize/e.position,
138-
total: e.totalSize,
139-
current: e.position
140-
}, {prefix:true});
141-
},
142-
143135
addHeader: function(name, value) {
144136
this.options.headers = this.options.headers || [];
145137
this.options.headers.push({name:name, value:value});

src/shared/js/request.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,24 @@
116116
},
117117

118118
handleProgress: function(e) {
119-
var detail = {
120-
percent: e.total || e.totalSize/e.loaded || e.position,
121-
total: e.total || e.totalSize,
122-
current: e.loaded || e.position
123-
};
119+
var detail = this._getProgressDetail(e);
124120
if (this.progress) {
125121
this.progress(detail);
126122
}
127123
this.fire('progress', detail);
128124
},
129125

126+
_getProgressDetail(e) {
127+
var current = e.loaded || e.position;
128+
var total = e.total || e.totalSize;
129+
130+
return {
131+
percent: Math.round(current/total*100),
132+
total: e.total || e.totalSize,
133+
current: e.loaded || e.position
134+
};
135+
},
136+
130137
responseHandler: {
131138

132139
xml: function() {

0 commit comments

Comments
 (0)