Merge pull request #459 from metamaps/fix/searchbox

searchbox fixes for master
This commit is contained in:
Devin Howard 2016-02-05 20:20:13 +08:00
commit ef307f1d46
8 changed files with 63 additions and 39 deletions

View file

@ -25,7 +25,7 @@ git clone git@github.com:metamaps/metamaps_gen002.git
Now ensure you have VirtualBox and Vagrant installed on your computer Now ensure you have VirtualBox and Vagrant installed on your computer
``` ```
cd metamaps_gen002 cd metamaps_gen002
./configure.sh ./bin/configure.sh
``` ```
This will do all the setup steps to make Metamaps work with a bit of behind the scenes ninja magick. This will do all the setup steps to make Metamaps work with a bit of behind the scenes ninja magick.

View file

@ -367,6 +367,8 @@ Metamaps.GlobalUI.Account = {
Metamaps.GlobalUI.Search = { Metamaps.GlobalUI.Search = {
locked: false, locked: false,
isOpen: false, isOpen: false,
limitTopicsToMe: false,
limitMapsToMe: false,
timeOut: null, timeOut: null,
changing: false, changing: false,
optionsInitialized: false, optionsInitialized: false,
@ -450,7 +452,7 @@ Metamaps.GlobalUI.Search = {
var self = Metamaps.GlobalUI.Search; var self = Metamaps.GlobalUI.Search;
self.timeOut = setTimeout(function () { self.timeOut = setTimeout(function () {
if (!self.locked && !self.changing && self.isOpen && (bypass || $('.sidebarSearchField').val() == '')) { if (!self.locked && !self.changing && self.isOpen && (bypass || $('.sidebarSearchField.tt-input').val() == '')) {
self.changing = true; self.changing = true;
$('.sidebarSearchField, .sidebarSearch .tt-hint').css({ $('.sidebarSearchField, .sidebarSearch .tt-hint').css({
padding: '7px 0 3px 0', padding: '7px 0 3px 0',
@ -481,7 +483,7 @@ Metamaps.GlobalUI.Search = {
display: function(s) { return s.label; }, display: function(s) { return s.label; },
templates: { templates: {
notFound: function(s) { notFound: function(s) {
return Hogan.compile($('#topicSearchTemplate').html()).render({ return Hogan.compile(topicheader + $('#topicSearchTemplate').html()).render({
value: "No results", value: "No results",
label: "No results", label: "No results",
typeImageURL: "<%= asset_path('icons/wildcard.png') %>", typeImageURL: "<%= asset_path('icons/wildcard.png') %>",
@ -500,7 +502,7 @@ Metamaps.GlobalUI.Search = {
url: '/search/topics', url: '/search/topics',
prepare: function(query, settings) { prepare: function(query, settings) {
settings.url += '?term=' + query; settings.url += '?term=' + query;
if (Metamaps.Active.Mapper && $("#limitTopicsToMe").is(':checked')) { if (Metamaps.Active.Mapper && self.limitTopicsToMe) {
settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
} }
return settings; return settings;
@ -515,7 +517,7 @@ Metamaps.GlobalUI.Search = {
display: function(s) { return s.label; }, display: function(s) { return s.label; },
templates: { templates: {
notFound: function(s) { notFound: function(s) {
return Hogan.compile($('#mapSearchTemplate').html()).render({ return Hogan.compile(mapheader + $('#mapSearchTemplate').html()).render({
value: "No results", value: "No results",
label: "No results", label: "No results",
rtype: "noresult" rtype: "noresult"
@ -533,7 +535,7 @@ Metamaps.GlobalUI.Search = {
url: '/search/maps', url: '/search/maps',
prepare: function(query, settings) { prepare: function(query, settings) {
settings.url += '?term=' + query; settings.url += '?term=' + query;
if (Metamaps.Active.Mapper && $("#limitMapsToMe").is(':checked')) { if (Metamaps.Active.Mapper && self.limitMapsToMe) {
settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
} }
return settings; return settings;
@ -548,7 +550,7 @@ Metamaps.GlobalUI.Search = {
display: function(s) { return s.label; }, display: function(s) { return s.label; },
templates: { templates: {
notFound: function(s) { notFound: function(s) {
return Hogan.compile($('#mapperSearchTemplate').html()).render({ return Hogan.compile(mapperheader + $('#mapperSearchTemplate').html()).render({
value: "No results", value: "No results",
label: "No results", label: "No results",
rtype: "noresult", rtype: "noresult",
@ -584,6 +586,12 @@ Metamaps.GlobalUI.Search = {
self.hideLoader(); self.hideLoader();
var h = $(window).height(); var h = $(window).height();
$(".tt-dropdown-menu").css('max-height', h - 100); $(".tt-dropdown-menu").css('max-height', h - 100);
if (self.limitTopicsToMe) {
$('#limitTopicsToMe').prop('checked', true);
}
if (self.limitMapsToMe) {
$('#limitMapsToMe').prop('checked', true);
}
}); });
$(window).resize(function () { $(window).resize(function () {
var h = $(window).height(); var h = $(window).height();
@ -599,11 +607,10 @@ Metamaps.GlobalUI.Search = {
}); });
// make sure that when you click on 'limit to me' or 'toggle section' it works // make sure that when you click on 'limit to me' or 'toggle section' it works
$('.sidebarSearchField').bind('typeahead:change', function(){ $('.sidebarSearchField.tt-input').keyup(function(){
if ($(this).val() === "") { if ($('.sidebarSearchField.tt-input').val() === '') {
self.hideLoader(); self.hideLoader();
} } else {
else {
self.showLoader(); self.showLoader();
} }
}); });
@ -630,26 +637,29 @@ Metamaps.GlobalUI.Search = {
var self = Metamaps.GlobalUI.Search; var self = Metamaps.GlobalUI.Search;
function toggleResultSet(set) { function toggleResultSet(set) {
var s = $('.tt-dataset-' + set + ' .tt-dataset'); var s = $('.tt-dataset-' + set + ' .tt-suggestion, .tt-dataset-' + set + ' .resultnoresult');
if (s.css('height') == '0px') { if (s.is(':visible')) {
s.css({ s.hide();
'height': 'auto',
'overflow': 'visible'
});
$(this).removeClass('maximizeResults').addClass('minimizeResults');
} else {
s.css({
'height': '0',
'overflow': 'hidden'
});
$(this).removeClass('minimizeResults').addClass('maximizeResults'); $(this).removeClass('minimizeResults').addClass('maximizeResults');
} else {
s.show();
$(this).removeClass('maximizeResults').addClass('minimizeResults');
} }
} }
$('.limitToMe').unbind().bind("change", function (e) { $('.limitToMe').unbind().bind("change", function (e) {
if ($(this).attr('id') == 'limitTopicsToMe') {
self.limitTopicsToMe = !self.limitTopicsToMe;
}
if ($(this).attr('id') == 'limitMapsToMe') {
self.limitMapsToMe = !self.limitMapsToMe;
}
// set the value of the search equal to itself to retrigger the autocomplete event // set the value of the search equal to itself to retrigger the autocomplete event
self.isOpen = false; self.isOpen = false;
$('.sidebarSearchField').typeahead('val', $('.sidebarSearchField').val()); var searchQuery = $('.sidebarSearchField.tt-input').val();
$(".sidebarSearchField").typeahead('val', '')
$(".sidebarSearchField").focus().typeahead('val', searchQuery).focus();
setTimeout(function () { setTimeout(function () {
self.isOpen = true; self.isOpen = true;
}, 2000); }, 2000);

View file

@ -67,6 +67,14 @@
width: 100%; width: 100%;
} }
.resultnoresult {
padding: 8px 0;
> div {
display: table-cell;
vertical-align: middle;
}
}
.canEditMap button.addToMap { .canEditMap button.addToMap {
display: block; display: block;
} }
@ -219,15 +227,14 @@
font-style: italic; font-style: italic;
font-family: helvetica, sans-serif; font-family: helvetica, sans-serif;
} }
.topicMetacode,
.searchResIconWrapper {
vertical-align: middle;
padding: 0 0 0 8px;
width: 70px;
}
}/* tt-suggestion */ }/* tt-suggestion */
.searchResIconWrapper {
vertical-align: middle;
width: 70px;
padding: 0 18px 0 28px;
}
.tt-dataset { .tt-dataset {
overflow: visible; overflow: visible;
} }
@ -242,8 +249,12 @@
.topicIcon { .topicIcon {
width: 32px; width: 32px;
height: 32px; height: 32px;
margin: 0 auto;
} }
.resulttopic .topicIcon {
margin: 0 auto
}
.metacodeTip { .metacodeTip {
display: none; display: none;
margin: 0 auto; margin: 0 auto;
@ -313,7 +324,7 @@
.tt-suggestion:hover .autoOptions { .tt-suggestion:hover .autoOptions {
display: block; display: block;
} }
.tt-suggestion .resultnoresult .autoOptions { .resultnoresult .autoOptions {
display: none; display: none;
} }

View file

@ -18,7 +18,7 @@
<div id="rightAboutParms"> <div id="rightAboutParms">
<p>PRIVATE BETA</p> <p>PRIVATE BETA</p>
<p>2.7</p> <p>2.7.1</p>
<p>Nov 29, 2014</p> <p>Nov 29, 2014</p>
</div> </div>
<div class="clearfloat"> <div class="clearfloat">

View file

@ -97,7 +97,7 @@
<script type="text/template" id="topicSearchTemplate"> <script type="text/template" id="topicSearchTemplate">
<div class="result{{rtype}}"> <div class="result{{rtype}}">
<div class="topicMetacode"> <div class="topicMetacode searchResIconWrapper">
<img src="{{typeImageURL}}" class="topicIcon" /> <img src="{{typeImageURL}}" class="topicIcon" />
<div class="metacodeTip">{{type}}</div> <div class="metacodeTip">{{type}}</div>
</div> </div>

View file

@ -14,4 +14,4 @@ vagrant ssh --command "cd /vagrant; bundle install";
vagrant ssh --command "cd /vagrant; cp .example-env .env"; vagrant ssh --command "cd /vagrant; cp .example-env .env";
# Rake all the things # Rake all the things
vagrant ssh --command "cd /vagrant; rake db:create; rake db:schema:load; rake db:fixtures:load" vagrant ssh --command "cd /vagrant; rake db:create; rake db:setup"

View file

@ -4,8 +4,11 @@
#sudo aptitude -q -y install libpq-dev #sudo aptitude -q -y install libpq-dev
source "$HOME/.rvm/scripts/rvm" source "$HOME/.rvm/scripts/rvm"
rvm install $(cat .ruby-version) rvm use $(cat .ruby-version) || \
rvm gemset use $(cat .ruby-gemset) rvm install $(cat .ruby-version)
rvm gemset use $(cat .ruby-gemset) || \
rvm gemset create $(cat .ruby-gemset) && \
rvm gemset use $(cat .ruby-gemset)
gem install bundler gem install bundler
set -x set -x

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151028061513) do ActiveRecord::Schema.define(version: 20160120061513) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"