From 5c0484dfed4fb858bf1769d66e7fc9523d8d8ced Mon Sep 17 00:00:00 2001 From: llj Date: Wed, 1 Jul 2020 10:14:44 +0800 Subject: [PATCH] [header] removed 'search & avatar, account info' on the top right corner (#4596) * cleaned up code & files --- media/js/base.js | 54 --------------- seahub/templates/base.html | 50 +------------- seahub/templates/base_for_small_panel.html | 4 -- seahub/templates/snippets/search_form.html | 79 ---------------------- seahub/templates/snippets/search_js.html | 38 ----------- 5 files changed, 3 insertions(+), 222 deletions(-) delete mode 100644 seahub/templates/snippets/search_form.html delete mode 100644 seahub/templates/snippets/search_js.html diff --git a/media/js/base.js b/media/js/base.js index 225ff44e34..c0041b1056 100644 --- a/media/js/base.js +++ b/media/js/base.js @@ -1,57 +1,3 @@ -$(function() { - $('.account-toggle').on('click', function() { - var popup = $('#user-info-popup'); - popup.toggleClass('hide'); - if (!popup.hasClass('hide')) { - var loading_tip = $('.loading-tip', popup), - space_traffic = $('#space-traffic'); - loading_tip.show(); - space_traffic.addClass('hide'); - $('.error', popup).addClass('hide'); - $.ajax({ - url: space_traffic.data('url'), - dataType: 'json', - cache: false, - success: function(data) { - loading_tip.hide(); - space_traffic.html(data['html']).removeClass('hide'); - }, - error: function (xhr, textStatus, errorThrown) { - if (xhr.responseText) { - var error = JSON.parse(xhr.responseText).error; - loading_tip.hide(); - if ($('.error', popup).length == 0) { - loading_tip.after('

' + error + '

'); - } else { - $('.error', popup).removeClass('hide'); - } - } - } - }); - } - - return false; - }); - -}); - -$(document).on('click', function(e) { - var target = e.target || event.srcElement; - var closePopup = function(popup, popup_switch) { - if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) { - popup.addClass('hide'); - } - }; - closePopup($('#user-info-popup'), $('.account-toggle')); -}); - -// search: disable submit when input nothing -$('.search-form').on('submit', function() { - if (!$(this).find('.search-input').val().trim()) { - return false; - } -}); - $('table').on('mouseenter', 'tr:gt(0)', function() { if (app.ui.currentDropDown || app.ui.freezeItemHightlight) { return; diff --git a/seahub/templates/base.html b/seahub/templates/base.html index 1acbdb90bd..d8d8af3e74 100644 --- a/seahub/templates/base.html +++ b/seahub/templates/base.html @@ -1,4 +1,4 @@ -{% load seahub_tags avatar_tags group_avatar_tags i18n staticfiles %} +{% load seahub_tags i18n staticfiles %} @@ -39,48 +39,8 @@ {% block header_right %} - {% if request.user.is_authenticated %} -
- {% block top_search %} - {% if has_file_search %} - {% include 'snippets/search_form.html' %} - {% endif %} - {% endblock %} - -
- - - -
-
- {% else %} {# for non-logged-in user #} + {% if not request.user.is_authenticated %} + {# for non-logged-in user #}
{{ LANGUAGE_CODE|language_name_local|capfirst }}
@@ -183,10 +143,6 @@ $('#info-bar .close').on('click', function() { }); {% endif %} -{% if has_file_search %} - {% include 'snippets/search_js.html' %} -{% endif %} - {% else %} {# for non-logged-in user #} (function() { var lang_context = $('#lang-context'), diff --git a/seahub/templates/base_for_small_panel.html b/seahub/templates/base_for_small_panel.html index 0f3085e278..bd9b22a037 100644 --- a/seahub/templates/base_for_small_panel.html +++ b/seahub/templates/base_for_small_panel.html @@ -27,7 +27,3 @@ input[type=password] { } {% endblock %} - -{% block header_right %} -{# removed the content on the top right corner #} -{% endblock %} diff --git a/seahub/templates/snippets/search_form.html b/seahub/templates/snippets/search_form.html deleted file mode 100644 index 3067bf2bfa..0000000000 --- a/seahub/templates/snippets/search_form.html +++ /dev/null @@ -1,79 +0,0 @@ -{% load i18n %} - - -
- {% if search_repo_id %} - - - {% else %} - - {% endif %} - -
- -
- -
-
- {% if search_repo_id %} - - - {% else %} - {% if search_repo and repo %} - - - {% else %} - - {% endif %} - {% endif %} -
-
- {% if search_ftypes != 'custom' %} - - - {% else %} - - - {% endif %} -
- {% if search_ftypes != 'custom' %} -
- {% else %} -
- {% endif %} - {# ftype value should be the same with utils/file_types.py #} - - - - - - - -
- -

{% trans "Please select at least one file type or input at least one file extension" %}

-
-
- - diff --git a/seahub/templates/snippets/search_js.html b/seahub/templates/snippets/search_js.html deleted file mode 100644 index 8202176464..0000000000 --- a/seahub/templates/snippets/search_js.html +++ /dev/null @@ -1,38 +0,0 @@ -// search-form: top-search-form, advanced-search-form, search-form in search result page -$('.search-form').on('submit', function() { - if (!$(this).find('.search-input').val().trim()) { - return false; - } -}); -$('#top-search-form .icon-caret-down').on('click', function() { - var form = $(this).parent(), - q = form.find('[name="q"]').val(), - advanced_form = $('#advanced-search-form'); - $('#header-inner').css({'position':'relative'}); - advanced_form.css({'right': 0, 'top':form.outerHeight(true)}).toggleClass('hide'); - if (!advanced_form.hasClass('hide') && q) { - advanced_form.find('.search-input').val(q); - } -}); -$('.search-filetypes .item:first-child').on('click', function() { - $(this).parents('.search-form').find('.custom-ftype-options').addClass('hide'); -}); -$('.search-filetypes .item:last-child').on('click', function() { - $(this).parents('.search-form').find('.custom-ftype-options').removeClass('hide'); -}); -$('#advanced-search-form').on('submit', function() { - if ($('#custom-search-ftypes').attr('checked') && - $('.custom-ftype-options .checkbox-checked').length == 0 && - $('.custom-ftype-options .fileext-input').val().trim()) { - $(this).find('.error').removeClass('hide'); - return false; - } -}); -$(document).on('click', function(e) { - var target = e.target || event.srcElement, - popup = $('#advanced-search-form'), - popup_switch = $('#top-search-form .icon-caret-down'); - if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target)) { - popup.addClass('hide'); - } -});