@Mercury.modalHandlers.insertlink = -> # make the inputs work with the radio buttons @element.find('label input').click (event) -> $(@).closest('label').next('.selectable').focus() @element.find('.selectable').focus -> $(@).prev('label').find('input[type=radio]').prop("checked", true) # show/hide the link target options on target change @element.find('#link_target').change => @element.find(".link-target-options").hide() @element.find("##{@element.find('#link_target').val()}_options").show() @resize(true) # fill the existing bookmark select bookmarkSelect = @element.find('#link_existing_bookmark') for link in $('a[name]', window.mercuryInstance.document) bookmarkSelect.append($('