@Mercury.modalHandlers.insertLink = -> # make the inputs work with the radio buttons @element.find('label input').on 'click', -> jQuery(@).closest('label').next('.selectable').focus() @element.find('.selectable').on 'focus', -> jQuery(@).prev('label').find('input[type=radio]').prop("checked", true) # show/hide the link target options on target change @element.find('#link_target').on '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 jQuery('a[name]', window.mercuryInstance.document) bookmarkSelect.append(jQuery('