# HG changeset patch # User Mads Kiilerich # Date 2014-07-18 18:44:54 # Node ID 60ea826baf096110ed03a69041ac3efced038134 # Parent c2e3923eebe459aca242ace418f623782e3f8680 compare: disable compare button until revisions have been selected diff --git a/kallithea/templates/compare/compare_diff.html b/kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html +++ b/kallithea/templates/compare/compare_diff.html @@ -173,17 +173,33 @@ ${self.repo_context_bar('changelog')} }, }); + var values_changed = function() { + var values = $('#compare_org').select2('data') && $('#compare_other').select2('data'); + if (values) { + $('#compare_revs').removeClass("disabled"); + // TODO: the swap button ... if any + } else { + $('#compare_revs').addClass("disabled"); + // TODO: the swap button ... if any + } + } + values_changed(); + $('#compare_org').change(values_changed); + $('#compare_other').change(values_changed); $('#compare_revs').on('click', function(e){ var org = $('#compare_org').select2('data'); var other = $('#compare_other').select2('data'); + if (!org || !other) { + return; + } var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='__other_ref_type__',org_ref_name='__org__',other_ref_type='__org_ref_type__',other_ref_name='__other__', other_repo=c.other_repo.repo_name)}"; var u = compare_url.replace('__other_ref_type__',org.type) .replace('__org__',org.text) .replace('__org_ref_type__',other.type) .replace('__other__',other.text); - window.location=u; - }) + window.location = u; + }); });