gross, but it works. checkboxes in search results work

This commit is contained in:
Devin Howard 2016-02-05 20:02:57 +08:00
parent c427e7fd7e
commit 5f90843da2

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,
@ -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;
@ -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;
@ -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();
@ -641,6 +649,13 @@ Metamaps.GlobalUI.Search = {
} }
$('.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;
var searchQuery = $('.sidebarSearchField.tt-input').val(); var searchQuery = $('.sidebarSearchField.tt-input').val();