Skip to content

Commit 0bf6b9a

Browse files
abishekvashokParthS007
authored andcommitted
app/templates/index.html: Creates dropdown (fossasia#413)
Changed mutliple server listing buttons into a single dropdown to enhance accessiblity of the UI. Fixes fossasia#410
1 parent 7ebac43 commit 0bf6b9a

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

app/templates/index.html

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<meta name="author" content="enigmaeth, @enigmaeth">
2424
<script src="{{ url_for('static', filename='bower_components/jquery/dist/jquery.js') }}"></script>
2525
<script src="{{ url_for('static', filename='bower_components/prismjs/prism.js') }}"></script>
26+
<script src="{{ url_for('static', filename='bower_components/bootstrap/dist/js/bootstrap.min.js') }}"></script>
2627
<link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='images/favicon.ico') }}">
2728
<title>query-server &middot; FOSSASIA</title>
2829
</head>
@@ -63,21 +64,34 @@ <h1><code>query-server</code></h1>
6364
</div>
6465
</div>
6566
<br/>
66-
<div class="col-md-10 col-xs-12 col-sm-10" style="padding:0; margin: 0 auto;">
67-
<div class="btn-toolbar">
68-
{% for engine in engines_list %}
69-
<button id="{{engine}}" type="submit" value={{ engine }} class="btn btn-lg search btn-outline">
70-
{% if engine in ['ask', 'baidu', 'bing', 'yahoo'] %}
71-
<img src="{{ url_for('static', filename='images/' + engine + '_icon.ico') }}" width="30px" alt="{{ engine }} Icon">
72-
{% else %}
73-
<img src="{{ url_for('static', filename='images/' + engine + '_icon.png') }}" width="30px" alt="{{ engine }} Icon">
74-
{% endif %}
75-
{{ engine }}
76-
</button>
77-
{% endfor %}
78-
</div>
67+
<div class="col-sm-4 col-xs-6" style="padding:0; margin: 0 auto;">
68+
<div class="dropdown">
69+
<label>Engine:</label><br/>
70+
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
71+
<span id="drop_down_text">
72+
<img src='static/images/google_icon.png' width='25px'>&nbsp;google
73+
</span>
74+
&nbsp;
75+
<span class="caret"></span>
76+
</button>
77+
<input type="hidden" id="engine" value="google">
78+
<ul class="dropdown-menu">
79+
{% for engine in engines_list %}
80+
<li onClick="update_button('{{ engine }}')" id="{{engine}}">
81+
<a style="cursor:pointer">
82+
{% if engine in ['ask', 'baidu', 'bing', 'yahoo'] %}
83+
<img src="{{ url_for('static', filename='images/' + engine + '_icon.ico') }}" width="15px">
84+
{% else %}
85+
<img src="{{ url_for('static', filename='images/' + engine + '_icon.png') }}" width="15px">
86+
{% endif %}
87+
{{ engine }}
88+
</a>
89+
</li>
90+
{% endfor %}
91+
</ul>
92+
</div>
7993
</div>
80-
<div class="col-xs-2">
94+
<div class="col-sm-4 col-xs-4">
8195
<div class="form-group" style="display:inline-block; margin: 0 auto; min-width:50%;">
8296
<label for="resp">Max:</label>
8397
<select class="form-control" id="resp">
@@ -94,6 +108,9 @@ <h1><code>query-server</code></h1>
94108
</select>
95109
</div>
96110
</div>
111+
<div class="col-sm-4 col-xs-s6" style="margin-top:20px;">
112+
<input type="submit" value="Submit" id="submitter" class="btn btn-primary"/>
113+
</div>
97114
</div>
98115
</form>
99116
</div>
@@ -141,15 +158,26 @@ <h1><code>query-server</code></h1>
141158
</div>
142159
</footer>
143160
<script>
161+
function update_button(engine) {
162+
var html = ""
163+
if(engine == "bing" || engine == "baidu" ||
164+
engine == "ask" || engine == "yahoo")
165+
html = "<img src='static/images/"+engine+"_icon.ico' width='25px'>";
166+
else
167+
html = "<img src='static/images/"+engine+"_icon.png' width='25px'>";
168+
html += "&nbsp;"+engine;
169+
$("#drop_down_text").html(html);
170+
$("#engine").val(engine);
171+
}
144172
$(function () {
145173
$('#yandex').prop('disabled', true);
146174
$('#yandex').attr('title', 'Yandex search has been temporarily disabled.');
147-
$('.btn-toolbar > button.btn').click(function (e) {
175+
$('#submitter').click(function (e) {
148176
e.preventDefault();
149177
if ($('#query').val()) {
150178
$('#load').show();
151179
$('#feed').hide();
152-
var sengine = $(this).val();
180+
var sengine = $("#engine").val();
153181
var squery = $('#query').val();
154182
var sformat = $(' #format label.active input').val();
155183
var count = $('#resp').val();

0 commit comments

Comments
 (0)