Skip to content

Search Bar #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions css/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ nav h3 {
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.48), inset 0 -2px 2px rgba(0, 0, 0, 0.36);
}

input.search_bar {
box-sizing: border-box;
background: rgba(0, 0, 0, .10);
border: none;
border-bottom: 2px solid rgb(38, 38, 38);
width: 100%;
height: 30px;
color: white;
padding-left: 10px;
}

input.search_bar:focus {
outline: none;
}

.workspace {
position: absolute;
top: 30px;
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ gulp.task('watch', ['build'], function() {

// Default

gulp.task('default', ['connect', 'watch']);
gulp.task('default', ['connect', 'watch']);
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ <h3>
</div>
</nav>
<section class="sidemenu active">
<input type = "text" class="search_bar" id="search-bar" autofocus/>
<div id="list">
</div>
<div id="footer">
Expand Down
35 changes: 35 additions & 0 deletions js/dom/enable_search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

module.exports = () => {
let $buttons = $('[data-category]');

$('#search-bar').keyup (function () {
let query = $(this).val ();
let re = new RegExp (query, 'i');

if (query) $('#footer').hide ();
else $('#footer').show ();

$.each ($('#list .category'), function (i, c) {
let $c = $(c);
!$c.hasClass ('open') && $c.click ();
});

$buttons.show ().filter (function () {
let cName = $(this).attr ('data-category');

if ($(this).hasClass ('category')) {
return !re.test ($(`[data-category="${cName}"]`).text ());
}
else {
return !(
re.test ($(`.category[data-category="${cName}"]`).text()) || re.test ($(this).text ())
);
}
}).hide ();

$('.algorithms').show ().filter (function () {
return !$(this).children (':visible').length;
}).hide ();
});
};
4 changes: 3 additions & 1 deletion js/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const addFiles = require('./add_files');
const showFirstAlgorithm = require('./show_first_algorithm');
const showRequestedAlgorithm = require('./show_requested_algorithm');
const showWiki = require('./show_wiki');
const enableSearch = require('./enable_search');

module.exports = {
showAlgorithm,
Expand All @@ -15,5 +16,6 @@ module.exports = {
addFiles,
showFirstAlgorithm,
showRequestedAlgorithm,
showWiki
showWiki,
enableSearch
};
3 changes: 3 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ $(() => {
app.setCategories(data);
DOM.addCategories();

//enable search feature
DOM.enableSearch ();

// determine if the app is loading a pre-existing scratch-pad
// or the home page
const {
Expand Down
15 changes: 15 additions & 0 deletions public/algorithm_visualizer.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ nav h3 {
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.48), inset 0 -2px 2px rgba(0, 0, 0, 0.36);
}

input.search_bar {
box-sizing: border-box;
background: rgba(0, 0, 0, .10);
border: none;
border-bottom: 2px solid rgb(38, 38, 38);
width: 100%;
height: 30px;
color: white;
padding-left: 10px;
}

input.search_bar:focus {
outline: none;
}

.workspace {
position: absolute;
top: 30px;
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy