sterzycom/panel/app/fields/url/assets/js/url.js

38 lines
604 B
JavaScript
Raw Normal View History

(function($) {
$.fn.urlfield = function() {
return this.each(function() {
var $this = $(this);
if($this.data('urlfield')) {
return;
} else {
$this.data('urlfield', true);
}
var $icon = $this.next('.field-icon');
$icon.css({
'cursor': 'pointer',
'pointer-events': 'auto'
});
$icon.on('click', function() {
var url = $.trim($this.val());
if(url !== '' && $this.is(':valid')) {
window.open(url);
} else {
$this.focus();
}
});
});
};
})(jQuery);