_.bindAll(this, 'changeLink', 'deleteLink');
var linkText = this.wlxmlNode.getAttr('href'),
- linkUrl = this.wlxmlNode.document.getUrlForLink(linkText);
+ linkUrl = this.getUrl(linkText);
this.box = $(_.template(boxTemplate)({text: linkText, url: linkUrl}));
this.box.find('.change').on('click', this.changeLink);
if(event.meta.attr === 'href') {
var link = this.box.find('[link]');
link.text(event.meta.newVal);
- link.attr('href', this.wlxmlNode.document.getUrlForLink(event.meta.newVal));
+ link.attr('href', this.getUrl(event.meta.newVal));
}
},
description: gettext('Remove link')
}
});
+ },
+
+ getUrl: function(link) {
+ var pattern = /^[a-z]*:\/\//g;
+ if(!pattern.test(link)) {
+ link = 'http://' + link;
+ }
+ return this.wlxmlNode.document.getUrlForLink(link);
}
});