(function() { var activate, openContentBrowser, save, template; scrivito.on('load', function() { return scrivito.define_editor('link', scrivito.editors.link_editor); }); scrivito.editors.link_editor = { can_edit: function(element) { return $(element).is('[data-scrivito-field-type=link]'); }, activate: function(element) { return activate($(element)); } }; activate = function(cmsField) { var link, obj_id; link = cmsField.scrivito('content') || {}; cmsField.html(template(link)); if (obj_id = link.obj_id) { scrivito.description_for_editor([obj_id]).then(function(descriptions) { var urlInput; urlInput = cmsField.find('[name=url]'); if (!urlInput.is(':focus')) { return urlInput.val(descriptions[0]); } }); } cmsField.on('blur', 'li input', function() { return save(cmsField); }).on('click', 'a.scrivito_open_content_browser', function() { return openContentBrowser(cmsField); }); return cmsField.find('[name=url]').on('focus', function() { var input, raw; input = $(this); raw = input.data('value'); if (raw) { input.val(raw); } return input.data('value', null); }); }; template = function(link) { var obj_url; obj_url = link.obj_id && ("/" + link.obj_id); return $("