coping with the template change and adding in cache busting for extra points (bug 628792)
This commit is contained in:
Родитель
e54a83f61c
Коммит
12d36dd474
|
@ -133,7 +133,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for preview in addon.previews.all() %}
|
{% for preview in addon.previews.all() %}
|
||||||
<div class="preview-thumb" style="background-image:url({{ preview.thumbnail_url }})"></div>
|
<div class="preview-thumb" data-url="{{ preview.thumbnail_url }}" style="background-image:url({{ preview.thumbnail_url }})"></div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1303,32 +1303,37 @@ var imageStatus = {
|
||||||
this.poller = window.setTimeout(this.check, 100);
|
this.poller = window.setTimeout(this.check, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
newurl: function(org) {
|
||||||
|
var bst = new Date().getTime();
|
||||||
|
(org.indexOf('?') > -1) ? org = org+'&'+bst : org= org+'?'+bst;
|
||||||
|
return org;
|
||||||
|
},
|
||||||
stop: function () {
|
stop: function () {
|
||||||
window.clearTimeout(this.poller);
|
window.clearTimeout(this.poller);
|
||||||
this.poller = null;
|
this.poller = null;
|
||||||
$('#edit-addon-media').find('b.save-badge').remove();
|
$('#edit-addon-media').find('b.save-badge').remove();
|
||||||
$('#edit-addon-media').find('img').each(function() {
|
$('#edit-addon-media').find('img').each(function() {
|
||||||
var org = $(this).attr('src');
|
$(this).attr('src', imageStatus.newurl($(this).attr('src')));
|
||||||
var bst = new Date().getTime();
|
|
||||||
(org.indexOf('?') > -1) ? org = org+'&'+bst : org= org+'?'+bst;
|
|
||||||
$(this).attr('src', org);
|
|
||||||
})
|
})
|
||||||
this.previews(skip_errors=false);
|
this.previews(skip_errors=false);
|
||||||
},
|
},
|
||||||
previews: function(skip_errors) {
|
previews: function(skip_errors) {
|
||||||
$("div.preview-unknown").each(function(e) {
|
$("div.preview-thumb").each(function(e) {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
// No need to keep rechecking bad images until the polling
|
// No need to keep rechecking bad images until the polling
|
||||||
// returns good.
|
// returns good.
|
||||||
if (skip_errors && $this.hasClass('preview-error')) {
|
if ((skip_errors && $this.hasClass('preview-error')) ||
|
||||||
|
$this.hasClass('preview-successful')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var img = Image();
|
var img = Image();
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
$this.removeClass('preview-error preview-unknown').addClass('preview-thumb');
|
$this.removeClass('preview-error preview-unknown').addClass('preview-successful');
|
||||||
$this.attr('style', 'background-image:url(' + $this.attr('data-url') + ')');
|
$this.attr('style', 'background-image:url(' + imageStatus.newurl($this.attr('data-url')) + ')');
|
||||||
}
|
}
|
||||||
img.onerror = function() {
|
img.onerror = function() {
|
||||||
|
$this.attr('style', '');
|
||||||
$this.addClass('preview-error');
|
$this.addClass('preview-error');
|
||||||
}
|
}
|
||||||
img.src = $this.attr('data-url');
|
img.src = $this.attr('data-url');
|
||||||
|
|
Загрузка…
Ссылка в новой задаче