From 9f9e989704b5274afba6a1de0b7bdcc6e7296314 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 27 Mar 2017 21:05:10 -0400 Subject: Bug 1350909 - Make index.cgi cache-friendly for logged out requests --- js/global.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/global.js b/js/global.js index a997821f4..651d10241 100644 --- a/js/global.js +++ b/js/global.js @@ -16,6 +16,8 @@ * */ +var BUGZILLA = $('head').data('bugzilla'); + $(function () { $('.show_mini_login_form').on("click", function (event) { return show_mini_login_form($(this).data('qs-suffix')); @@ -32,15 +34,55 @@ $(function () { $('.check_mini_login_fields').on("click", function (event) { return check_mini_login_fields($(this).data('qs-suffix')); }); - $('form .quicksearch_check_empty').on("submit", function (event) { + $('.quicksearch_check_empty').on("submit", function (event) { if (this.quicksearch.value == '') { - alert('Please enter one or more search terms first.'); - return false; + alert('Please enter one or more search terms first.'); + event.preventDefault(); } - return true; }); + + unhide_language_selector(); + $("#lob_action").on("change", update_text); + $("#lob_newqueryname").on("keyup", manage_old_lists); }); +function unhide_language_selector() { + $('#lang_links_container').removeClass('bz_default_hidden'); +} + +function update_text() { + // 'lob' means list_of_bugs. + var lob_action = document.getElementById('lob_action'); + var action = lob_action.options[lob_action.selectedIndex].value; + var text = document.getElementById('lob_direction'); + var new_query_text = document.getElementById('lob_new_query_text'); + + if (action == "add") { + text.innerHTML = "to"; + new_query_text.style.display = 'inline'; + } + else { + text.innerHTML = "from"; + new_query_text.style.display = 'none'; + } +} + +function manage_old_lists() { + var old_lists = document.getElementById('lob_oldqueryname'); + // If there is no saved searches available, returns. + if (!old_lists) return; + + var new_query = document.getElementById('lob_newqueryname').value; + + if (new_query != "") { + old_lists.disabled = true; + } + else { + old_lists.disabled = false; + } +} + + function show_mini_login_form( suffix ) { $('#login_link' + suffix).addClass('bz_default_hidden'); $('#mini_login' + suffix).removeClass('bz_default_hidden'); @@ -148,4 +190,4 @@ $().ready(function() { $(window).on('pageshow', function(event) { $('.bz_autocomplete').attr('autocomplete', 'off'); }); -}); +}); \ No newline at end of file -- cgit v1.2.3-24-g4f1b