Browse files

Pull in GH styling

  • Loading branch information...
1 parent e08a2ae commit bad837b4522cfaf629f8e03354b05976f8182504 @rwdaigle committed Oct 18, 2012
Showing with 37 additions and 46 deletions.
  1. +7 −7 app/assets/javascripts/search.js
  2. +21 −6 app/assets/stylesheets/search.sass
  3. +9 −33 app/views/gists/search.html.haml
View
14 app/assets/javascripts/search.js
@@ -13,28 +13,28 @@ var setInitialElementStates = function() {
searchField().select();
// Pass form submits through Turbolinks
- $("#search-form").submit(function() {
+ $("#top_search_form").submit(function() {
form = $(this);
Turbolinks.visit(form.attr('action') + '?' + form.serialize());
return false;
});
};
var searchField = function() {
- return $("#search-form #q");
+ return $("#top_search_form #command-bar");
};
var wireSearch = function() {
var selectedClass = 'selected';
Mousetrap.bind(['down'], function(e) {
- navigateList('down', $("ul.search-results li:first"));
+ navigateList('down', $(".display .choice:first"));
haltEvent(e);
});
Mousetrap.bind(['up'], function(e) {
- navigateList('up', $("ul.search-results li:last"));
+ navigateList('up', $(".display .choice:last"));
haltEvent(e);
});
@@ -48,7 +48,7 @@ var wireSearch = function() {
Mousetrap.bind(['/', 's'], function(e) {
executeOutsideInputFields(e, function() {
searchField().focus().select();
- $("ul.search-results li.selected").removeClass(selectedClass);
+ $(".display .choice.selected").removeClass(selectedClass);
haltEvent(e);
});
});
@@ -61,7 +61,7 @@ var wireSearch = function() {
// direction == up|down
var navigateList = function(direction, defaultEl) {
- previouslySelectedEl = $("ul.search-results li.selected");
+ previouslySelectedEl = $(".display .choice.selected");
if(previouslySelectedEl.size() <= 0) {
defaultEl.addClass(selectedClass);
@@ -77,7 +77,7 @@ var wireSearch = function() {
}
var goToSelectedResult = function() {
- selectedEl = $("ul.search-results li.selected");
+ selectedEl = $(".display .choice.selected");
if(selectedEl.size() >= 1) {
location.href = selectedEl.find("a.gist-url").attr('href');
}
View
27 app/assets/stylesheets/search.sass
@@ -1,11 +1,26 @@
+.container
+ .site-logo
+ font-family: Tahoma
+ font-size: 18px
+ margin-top: 2px
+ margin-right: 5px
+ width: auto
+
#header
- width: 700px
+ width: 715px
margin: -20px 0 0 -360px
top: 20%
-.topsearch
- border-left: 0px
- box-shadow: none
-
.launch .command_bar_form
- width: 600px
+ width: 600px
+
+.commandbar
+ .display
+ max-height: 550px
+
+ div.choice.selected
+ background: #D8EBFA
+ text-shadow: none
+
+.command_bar_form
+ padding-right: 0px
View
42 app/views/gists/search.html.haml
@@ -1,43 +1,19 @@
-/ %style(type="text/css")
-/ :sass
-/ ul.search-results
-/ list-style-type: none
-/ li:nth-child(even)
-/ background: #EEE
-/ li.selected
-/ background: #999
-
-/ %p
-/ = form_tag(search_gists_path, :method => "get", :id => "search-form") do
-/ = image_tag("#{current_user.gh_avatar_url}&s=25")
-/ = text_field_tag(:q, params[:q], :size => 50, :class => "mousetrap")
-/ = submit_tag("Search")
-/ = "(last indexed: #{current_user.last_gh_fetch ? current_user.last_gh_fetch.to_formatted_s(:short) : "not yet"})"
-
-/ - if @results.size > 0
-/ %ul.search-results
-/ - for result in @results
-/ %li(style="#{search_result_styles(result)}")
-/ = search_result_link(result)
-/ %span.meta
-/ %span.modified-at= "modified #{distance_of_time_in_words_to_now(result.gh_updated_at)} ago"
-/ %span.comments= "#{pluralize(result.comment_count, "comments")}"
-/ / %p= result.inspect
-/ - else
-/ %p= "No results found for \"#{params[:q]}\""
+%span.site-logo
+ Gisted
.topsearch.command-bar-activated
= form_tag(search_gists_path, :method => "get", :id => "top_search_form", :class => "command_bar_form") do
- %a.advanced-search.tooltipped.downwards.command-bar-search(href="#")
- %span.mini-icon.mini-icon-advanced-search
.commandbar.focused
= text_field_tag(:q, params[:q], :size => 50, :class => "mousetrap", :id => "command-bar", :placeholder => "Search your gists", :tabindex => "1")
.display(style="display: block;")
- - for result in @results
+ - if @results.size > 0
+ - for result in @results
+ .choice
+ %span.command= search_result_link(result)
+ %span.description= pluralize(result.comment_count, "comments")
+ - else
.choice
- %span.command= search_result_link(result)
- %span.description= pluralize(result.comment_count, "comments")
- %span.mini-icon.help.tooltipped.downwards(title="Show Command Bar Help") 
+ %span.command= "No results found. Bummer."
/ = submit_tag("Search")
/ = "(last indexed: #{current_user.last_gh_fetch ? current_user.last_gh_fetch.to_formatted_s(:short) : "not yet"})"

0 comments on commit bad837b

Please sign in to comment.