|
|
|
@ -34,7 +34,6 @@ module.exports = CoreView.extend({
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_loadImage: function (imageUrl, color) {
|
|
|
|
|
var self = this;
|
|
|
|
|
var isSVG = this._isSVG(imageUrl);
|
|
|
|
|
var $imgContainer = this.$('.js-image-container');
|
|
|
|
|
if ($imgContainer.length === 0) {
|
|
|
|
@ -42,11 +41,11 @@ module.exports = CoreView.extend({
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isSVG) {
|
|
|
|
|
this._requestImage(imageUrl, function (content) {
|
|
|
|
|
this._requestImage(imageUrl, (content) => {
|
|
|
|
|
var svg = content.cloneNode(true);
|
|
|
|
|
var $svg = $(svg);
|
|
|
|
|
$svg = $svg.removeAttr('xmlns:a');
|
|
|
|
|
$svg.attr('class', self._imageClass + ' js-image');
|
|
|
|
|
$svg.attr('class', this._imageClass + ' js-image');
|
|
|
|
|
|
|
|
|
|
for (var attribute in IMAGE_FILE_ATTRS) {
|
|
|
|
|
$svg.attr(attribute, IMAGE_FILE_ATTRS[attribute]);
|
|
|
|
@ -59,7 +58,7 @@ module.exports = CoreView.extend({
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
var $img = $('<img crossorigin="anonymous"/>');
|
|
|
|
|
$img.attr('class', self._imageClass + ' js-image');
|
|
|
|
|
$img.attr('class', this._imageClass + ' js-image');
|
|
|
|
|
$img.attr('src', imageUrl + '?req=markup');
|
|
|
|
|
|
|
|
|
|
for (var attribute in IMAGE_FILE_ATTRS) {
|
|
|
|
@ -71,19 +70,18 @@ module.exports = CoreView.extend({
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_requestImage: function (url, callback) {
|
|
|
|
|
var self = this;
|
|
|
|
|
var completeUrl = url + '?req=ajax';
|
|
|
|
|
|
|
|
|
|
if (this._lastImage.url === completeUrl) {
|
|
|
|
|
callback && callback(this._lastImage.content);
|
|
|
|
|
} else {
|
|
|
|
|
$.ajax(completeUrl)
|
|
|
|
|
.done(function (data) {
|
|
|
|
|
self._lastImage.url = completeUrl;
|
|
|
|
|
var content = self._lastImage.content = data.getElementsByTagName('svg')[0];
|
|
|
|
|
.done((data) => {
|
|
|
|
|
this._lastImage.url = completeUrl;
|
|
|
|
|
var content = this._lastImage.content = data.getElementsByTagName('svg')[0];
|
|
|
|
|
callback && callback(content);
|
|
|
|
|
})
|
|
|
|
|
.fail(function () {
|
|
|
|
|
.fail((data) => {
|
|
|
|
|
throw new Error("Couldn't get " + completeUrl + ' file.');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|