From 5f90843da2a03937cbc81edcd94b880b422c2887 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 5 Feb 2016 20:02:57 +0800 Subject: [PATCH] gross, but it works. checkboxes in search results work --- .../javascripts/src/Metamaps.GlobalUI.js.erb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb index 19681df9..4072ced9 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb @@ -367,6 +367,8 @@ Metamaps.GlobalUI.Account = { Metamaps.GlobalUI.Search = { locked: false, isOpen: false, + limitTopicsToMe: false, + limitMapsToMe: false, timeOut: null, changing: false, optionsInitialized: false, @@ -500,7 +502,7 @@ Metamaps.GlobalUI.Search = { url: '/search/topics', prepare: function(query, settings) { 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(); } return settings; @@ -533,7 +535,7 @@ Metamaps.GlobalUI.Search = { url: '/search/maps', prepare: function(query, settings) { 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(); } return settings; @@ -584,6 +586,12 @@ Metamaps.GlobalUI.Search = { self.hideLoader(); var h = $(window).height(); $(".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 () { var h = $(window).height(); @@ -641,6 +649,13 @@ Metamaps.GlobalUI.Search = { } $('.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 self.isOpen = false; var searchQuery = $('.sidebarSearchField.tt-input').val();