diff --git a/.gitignore b/.gitignore index db060afa..a2b03a61 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ #assety stuff realtime/node_modules public/assets +vendor/ #secrets and config .env diff --git a/README.md b/README.md index 76444337..5cfd3a37 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ git clone git@github.com:metamaps/metamaps_gen002.git Now ensure you have VirtualBox and Vagrant installed on your computer ``` 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. diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb index f00025c4..a7f2f017 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb @@ -379,6 +379,8 @@ Metamaps.GlobalUI.Account = { Metamaps.GlobalUI.Search = { locked: false, isOpen: false, + limitTopicsToMe: false, + limitMapsToMe: false, timeOut: null, changing: false, optionsInitialized: false, @@ -462,7 +464,7 @@ Metamaps.GlobalUI.Search = { var self = Metamaps.GlobalUI.Search; 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; $('.sidebarSearchField, .sidebarSearch .tt-hint').css({ padding: '7px 0 3px 0', @@ -493,7 +495,7 @@ Metamaps.GlobalUI.Search = { display: function(s) { return s.label; }, templates: { notFound: function(s) { - return Hogan.compile($('#topicSearchTemplate').html()).render({ + return Hogan.compile(topicheader + $('#topicSearchTemplate').html()).render({ value: "No results", label: "No results", typeImageURL: "<%= asset_path('icons/wildcard.png') %>", @@ -512,7 +514,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; @@ -527,7 +529,7 @@ Metamaps.GlobalUI.Search = { display: function(s) { return s.label; }, templates: { notFound: function(s) { - return Hogan.compile($('#mapSearchTemplate').html()).render({ + return Hogan.compile(mapheader + $('#mapSearchTemplate').html()).render({ value: "No results", label: "No results", rtype: "noresult" @@ -545,7 +547,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; @@ -560,7 +562,7 @@ Metamaps.GlobalUI.Search = { display: function(s) { return s.label; }, templates: { notFound: function(s) { - return Hogan.compile($('#mapperSearchTemplate').html()).render({ + return Hogan.compile(mapperheader + $('#mapperSearchTemplate').html()).render({ value: "No results", label: "No results", rtype: "noresult", @@ -596,6 +598,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(); @@ -611,11 +619,10 @@ Metamaps.GlobalUI.Search = { }); // make sure that when you click on 'limit to me' or 'toggle section' it works - $('.sidebarSearchField').bind('typeahead:change', function(){ - if ($(this).val() === "") { + $('.sidebarSearchField.tt-input').keyup(function(){ + if ($('.sidebarSearchField.tt-input').val() === '') { self.hideLoader(); - } - else { + } else { self.showLoader(); } }); @@ -642,29 +649,29 @@ Metamaps.GlobalUI.Search = { var self = Metamaps.GlobalUI.Search; function toggleResultSet(set) { - var s = $('.tt-dataset-' + set + ' .tt-dataset'); - if (s.css('height') == '0px') { - s.css({ - 'height': 'auto', - 'overflow': 'visible' - }); - $(this).removeClass('maximizeResults').addClass('minimizeResults'); - } else { - s.css({ - 'height': '0', - 'overflow': 'hidden' - }); + var s = $('.tt-dataset-' + set + ' .tt-suggestion, .tt-dataset-' + set + ' .resultnoresult'); + if (s.is(':visible')) { + s.hide(); $(this).removeClass('minimizeResults').addClass('maximizeResults'); + } else { + s.show(); + $(this).removeClass('maximizeResults').addClass('minimizeResults'); } } $('.limitToMe').unbind().bind("change", function (e) { - // set the value of the search equal to itself to retrigger the autocomplete event - self.isOpen = false; - $('.sidebarSearchField').typeahead('val', $('.sidebarSearchField').val()); - setTimeout(function () { - self.isOpen = true; - }, 2000); + 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 + var searchQuery = $('.sidebarSearchField.tt-input').val(); + $(".sidebarSearchField").typeahead('val', '') + .typeahead('val', searchQuery); }); // when the user clicks minimize section, hide the results for that section diff --git a/app/assets/stylesheets/search.scss.erb b/app/assets/stylesheets/search.scss.erb index 0f806f96..1d7ec7c4 100644 --- a/app/assets/stylesheets/search.scss.erb +++ b/app/assets/stylesheets/search.scss.erb @@ -67,6 +67,14 @@ width: 100%; } +.resultnoresult { + padding: 8px 0; + > div { + display: table-cell; + vertical-align: middle; + } +} + .canEditMap button.addToMap { display: block; } @@ -128,6 +136,7 @@ top: 40px !important; background: #F5F5F5; width: 472px; + max-height: 25em; overflow-y: auto; overflow-x: visible; box-shadow: 0 10px 10px rgba(0,0,0,0.19), 0 6px 3px rgba(0,0,0,0.23); @@ -219,15 +228,14 @@ font-style: italic; font-family: helvetica, sans-serif; } - - .topicMetacode, - .searchResIconWrapper { - vertical-align: middle; - padding: 0 0 0 8px; - width: 70px; - } }/* tt-suggestion */ + .searchResIconWrapper { + vertical-align: middle; + width: 70px; + padding: 0 18px 0 28px; + } + .tt-dataset { overflow: visible; } @@ -242,8 +250,12 @@ .topicIcon { width: 32px; height: 32px; - margin: 0 auto; } + + .resulttopic .topicIcon { + margin: 0 auto + } + .metacodeTip { display: none; margin: 0 auto; @@ -313,7 +325,7 @@ .tt-suggestion:hover .autoOptions { display: block; } - .tt-suggestion .resultnoresult .autoOptions { + .resultnoresult .autoOptions { display: none; } diff --git a/app/views/layouts/_templates.html.erb b/app/views/layouts/_templates.html.erb index 4218bfda..b3099ad9 100644 --- a/app/views/layouts/_templates.html.erb +++ b/app/views/layouts/_templates.html.erb @@ -97,7 +97,7 @@