更新 infowindow-view.js

This commit is contained in:
钟进 2020-06-13 13:47:00 +00:00
parent 72663aac2d
commit f08c99fd29

View File

@ -143,9 +143,9 @@ var Infowindow = View.extend({
return;
}
if (!this._isValidURL(url)) {
if (!this._isValidVideoURL(url)) {
this._stopCoverLoader();
this._showInfowindowImageError();
this._showInfowindowVideoError();
return;
}
@ -155,6 +155,20 @@ var Infowindow = View.extend({
this._loadCoverFromUrl(url);
}
},
_isValidVideoURL: function (url) {
if (url) {
var urlPattern = /^(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-|]*[\w@?^=%&\/~+#-])?$/;
return String(url).match(urlPattern) !== null;
}
return false;
},
_showInfowindowVideoError: function () {
this.$('.js-infowindow').addClass('is-fail');
this.$('.js-cover').append('<p class="CDB-infowindow-fail">Non-valid Video URL</p>');
},
// end video
_initBinds: function () {