# HG changeset patch # User Jan Heylen # Date 2015-01-30 20:57:02 # Node ID 749b5e8cead3cf751f5a59c6e2da647da772dab4 # Parent d7420a74b98da68cc700d5eb33035248b8989ec5 comment: warn before leaving page with open comments diff --git a/kallithea/templates/changeset/changeset_file_comment.html b/kallithea/templates/changeset/changeset_file_comment.html --- a/kallithea/templates/changeset/changeset_file_comment.html +++ b/kallithea/templates/changeset/changeset_file_comment.html @@ -201,6 +201,14 @@ $(document).ready(function () { MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA); + $(window).on('beforeunload', function(){ + if($('.form-open').size() || $('textarea#text').val()){ + // this message will not be displayed on all browsers + // (e.g. some versions of Firefox), but the user will still be warned + return 'There are uncommitted comments.'; + } + }); + $('#preview-btn').click(function(){ var _text = $('#text').val(); if(!_text){