From cf08d757c49c8a551816f20bd3dee943eaa3bc81 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 13 Dec 2016 20:41:45 +0000 Subject: [PATCH 01/44] chore(package): update dependencies https://greenkeeper.io/ --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cd227efb..c5b6e6e4 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,14 @@ "dependencies": { "escape-html": "^1.0.3", "unescape-html": "^1.0.0", - "jquery": "^2.2.4" + "jquery": "^3.1.1" }, "devDependencies": { "bit-docs-generate-html": "^0.3.0", "q": "^1.4.1", - "connect": "^2.14.4", - "normalize.css": "^4.1.1", - "zombie": "^4.2.1", - "bit-docs-html-toc": "^0.2.0" + "connect": "^3.5.0", + "normalize.css": "^5.0.0", + "zombie": "^5.0.5", + "bit-docs-html-toc": "^0.5.0" } } From da55c09aff65dfe818c1c63e4b51074f712029c1 Mon Sep 17 00:00:00 2001 From: Jamie McCue Date: Mon, 29 May 2017 13:39:30 -0700 Subject: [PATCH 02/44] navigation updates gh-197 - Refactoring the menu so the has the padding and
  • is just the wrapper - Separating the / as an individual li - Reversing out the background when selected - Removing the caret triangle altogether --- static/breadcrumb.less | 181 ++++++++++++++++------------------ templates/breadcrumb.mustache | 8 +- 2 files changed, 92 insertions(+), 97 deletions(-) diff --git a/static/breadcrumb.less b/static/breadcrumb.less index dbff8b43..55e59892 100644 --- a/static/breadcrumb.less +++ b/static/breadcrumb.less @@ -1,32 +1,32 @@ .breadcrumb { - display: none; - @media screen and (min-width: @breakpoint) { + display: none; + @media screen and (min-width: @breakpoint) { height: 48px; - display: block; - padding-left: @gutter*2; - background: @code-color; - cursor: pointer; - color: lighten(@gray, 10%); - .breadcrumb-dropdown { + display: block; + padding-left: @gutter*2; + background: @code-color; + cursor: pointer; + color: lighten(@gray, 10%); + .breadcrumb-dropdown { display: none; - padding: @gutter @gutter/4; + padding: @gutter @gutter/4; position: relative; color: lighten(@gray, 10%); a { - padding-left: @gutter/4; cursor: pointer; color: white; } &:hover { - .on-this-page { - display: flex; - li { - flex-grow: 1; - flex-basis: auto; - } - } - } - &::after { + color: @link-color; + .on-this-page { + display: flex; + li { + flex-grow: 1; + flex-basis: auto; + } + } + } + &::after { display: inline-block; width: 16px; height: 16px; @@ -35,85 +35,78 @@ background-image: url(img/down_white.svg); background-size: cover; background-repeat: no-repeat; - } - } - li { + } + } + li { display: inline-block; list-style: none; - color: @link-color; - padding: @gutter @gutter/4; - a { - color: white; - font-size: 14px; - code { - background: none; - line-height: 14px; - } - } - } - } + a { + color: white; + font-size: 14px; + padding: @gutter; + border-radius: 4px 4px 0 0; + code { + background: none; + line-height: 14px; + } + } + a:hover { + background-color: white; + color: @link-color !important; + text-decoration: none; + } + .on-this-page a { + padding: @gutter/4 0; + } + } + } } .on-this-page { - width: 100%; - font-size: 14px; - margin-top:@gutter/2; - margin-bottom: @gutter !important; - background: #fff; - list-style: none; - line-height: 1.5em; - a { - color: @link-color !important; - } - @media screen and (min-width: @breakpoint) { - padding: @gutter; - margin: 0; - position: fixed; - .box-shadow; - z-index: 15; - cursor: pointer; - display: none; - margin-top: 15px; - width: auto; - flex-direction: column; - flex-wrap: nowrap; - li { - padding: 0px; - margin: 0px; - code { - background: none; - font-weight: 600; - padding: 0; - } - a { - width: auto; - padding: 0px; - margin: 0px; - } - } - li:hover { - text-decoration: underline; - } - li .current { - text-decoration: underline; - font-weight: bold; - } - &::before { - content: ''; - width:10px; - height: 10px; - background: #fff; - position: absolute; - top:-4px; - left: @gutter; - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - transform: rotate(-45deg); - z-index: 16; - } - } + width: 100%; + font-size: 14px; + margin-top:@gutter/2; + margin-bottom: @gutter !important; + background: #fff; + list-style: none; + line-height: 1.5em; + a { + color: @link-color !important; + } + @media screen and (min-width: @breakpoint) { + padding: @gutter; + margin: 0; + position: fixed; + .box-shadow; + z-index: 15; + cursor: pointer; + display: none; + margin-top: 15px; + width: auto; + flex-direction: column; + flex-wrap: nowrap; + li { + padding: 0px; + margin: 0px; + code { + background: none; + font-weight: 600; + padding: 0; + } + a { + width: auto; + padding: 0px; + margin: 0px; + } + } + li:hover { + text-decoration: underline; + } + li .current { + text-decoration: underline; + font-weight: bold; + } + } } .nav-toggle { @@ -137,5 +130,5 @@ } .on-this-page:empty{ - visibility: hidden; + visibility: hidden; } diff --git a/templates/breadcrumb.mustache b/templates/breadcrumb.mustache index 04fb056d..1ebc3783 100644 --- a/templates/breadcrumb.mustache +++ b/templates/breadcrumb.mustache @@ -1,12 +1,14 @@
  • {{getShortTitle .}}
  • / +
  • {{getShortTitle .}}
  • +
  • /
  • {{/each}} {{#with (getCurrent)}}
  • {{getShortTitle .}}
  • {{/with}} -
  • /
  • + From e63a474015d69a4d6cfe1ccb83cf8be221b4ab9c Mon Sep 17 00:00:00 2001 From: Jamie McCue Date: Tue, 30 May 2017 09:16:12 -0700 Subject: [PATCH 03/44] removed border radius updates gh 197 --- static/breadcrumb.less | 1 - 1 file changed, 1 deletion(-) diff --git a/static/breadcrumb.less b/static/breadcrumb.less index 55e59892..aeaf5144 100644 --- a/static/breadcrumb.less +++ b/static/breadcrumb.less @@ -44,7 +44,6 @@ color: white; font-size: 14px; padding: @gutter; - border-radius: 4px 4px 0 0; code { background: none; line-height: 14px; From a52a2ad28000c6033439e4795f35c3947efb8b50 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Wed, 31 May 2017 12:39:53 -0700 Subject: [PATCH 04/44] Fix some in-page nav style issues - Only show the pointer cursor when hovering over a link/dropdown - Show the white background behind the anchor anytime the dropdown is open Related to https://github.com/canjs/bit-docs-html-canjs/issues/197 --- static/breadcrumb.less | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/breadcrumb.less b/static/breadcrumb.less index aeaf5144..59959088 100644 --- a/static/breadcrumb.less +++ b/static/breadcrumb.less @@ -5,7 +5,6 @@ display: block; padding-left: @gutter*2; background: @code-color; - cursor: pointer; color: lighten(@gray, 10%); .breadcrumb-dropdown { display: none; @@ -18,6 +17,10 @@ } &:hover { color: @link-color; + a { + background-color: white; + color: @link-color !important; + } .on-this-page { display: flex; li { From effdf5073cbe82a76907859f338eb7f26c21e906 Mon Sep 17 00:00:00 2001 From: imaustink Date: Wed, 31 May 2017 15:45:24 -0700 Subject: [PATCH 05/44] Upped font-weight of On this page section --- static/breadcrumb.less | 1 + 1 file changed, 1 insertion(+) diff --git a/static/breadcrumb.less b/static/breadcrumb.less index dbff8b43..6c1b15fd 100644 --- a/static/breadcrumb.less +++ b/static/breadcrumb.less @@ -16,6 +16,7 @@ padding-left: @gutter/4; cursor: pointer; color: white; + font-weight: 700; } &:hover { .on-this-page { From 166445e5f932a40e1378f683599c16c73c9f4f8f Mon Sep 17 00:00:00 2001 From: imaustink Date: Wed, 31 May 2017 17:52:31 -0700 Subject: [PATCH 06/44] Fix responsive buttons --- static/article-title.less | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/static/article-title.less b/static/article-title.less index cc6332a1..60985925 100644 --- a/static/article-title.less +++ b/static/article-title.less @@ -7,8 +7,9 @@ section.title-footer{ } ul.title-social{ display: flex; + flex-flow: row wrap; + justify-content: space-around; padding-left: 0; - justify-content: flex-start; margin: 0; li{ list-style: none; @@ -37,8 +38,14 @@ ul.title-links { .title-social { float: right; margin-top: @gutter; + @media screen and (max-width: (@breakpoint / 2)){ + width: 100%; + } li{ - margin: 0 0 0 @gutter; + margin: 0 0 @gutter @gutter; + &:first-child { + margin-left: 0px; + } } } div{ From 2c36e95f4a3cd4c27a0c37c83f2633814685c3b0 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 13:40:16 -0700 Subject: [PATCH 07/44] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3dc56651..be60dec0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "can-control": "^3.0.3", "can-util": "^3.0.10", "escape-html": "^1.0.3", - "jquery": "^3.1.1" + "jquery": "^3.1.1", "lodash": "^4.17.4", "lunr": "^2.0.3", "steal-stache": "^3.0.1", From 56c866a2e6040e3c5997ea6333d9270619f649ab Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 14:13:03 -0700 Subject: [PATCH 08/44] Fix breadcrumb styles for pages with no table of contents --- static/breadcrumb.less | 2 +- templates/breadcrumb.mustache | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/static/breadcrumb.less b/static/breadcrumb.less index 59959088..954ba826 100644 --- a/static/breadcrumb.less +++ b/static/breadcrumb.less @@ -8,7 +8,6 @@ color: lighten(@gray, 10%); .breadcrumb-dropdown { display: none; - padding: @gutter @gutter/4; position: relative; color: lighten(@gray, 10%); a { @@ -43,6 +42,7 @@ li { display: inline-block; list-style: none; + padding: @gutter @gutter/4; a { color: white; font-size: 14px; diff --git a/templates/breadcrumb.mustache b/templates/breadcrumb.mustache index 1ebc3783..2e813400 100644 --- a/templates/breadcrumb.mustache +++ b/templates/breadcrumb.mustache @@ -6,8 +6,9 @@ {{#with (getCurrent)}}
  • {{getShortTitle .}}
  • {{/with}} -
  • /
  • - From 2bf60a2567a295c76dd5ccac87032313c825a54f Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 15:16:05 -0700 Subject: [PATCH 09/44] Remove color from the search results - Remove the dark border-left - Change the highlight color from green to gray --- static/search.less | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/static/search.less b/static/search.less index d4309b53..1ec0af61 100644 --- a/static/search.less +++ b/static/search.less @@ -90,7 +90,6 @@ > li{ padding: .9em .5em; border-bottom: 1px solid @light-gray-color; - border-left:3px solid transparent; a{ color: @link-color; padding-bottom:0; @@ -119,8 +118,7 @@ } &:hover, &.keyboard-active{ - background-color: @highlight-color; - border-left-color:@gray; + background-color: @light-gray-color; cursor:pointer; } } @@ -128,7 +126,6 @@ .search-results-heading{ padding:0 .5em; - border-left: 3px solid transparent; border-bottom: 1px solid @light-gray-color; padding-bottom: 1em; .count{ From 672fb3dde69f8aa04f084d75921bc94bb414e150 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 17:01:30 -0700 Subject: [PATCH 10/44] Fix storing items in local storage --- static/search.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/static/search.js b/static/search.js index c4200ec5..ebe9809a 100644 --- a/static/search.js +++ b/static/search.js @@ -16,7 +16,7 @@ var Search = Control.extend({ //renderer stuff resultsRenderer: searchResultsRenderer, pathPrefix: window.pathPrefix, - searchMapHashUrl: '/searchMapHash.json', + searchMapHashUrl: '/searchMapHash.json', searchMapUrl: '/searchMap.json', //callbacks @@ -105,7 +105,7 @@ var Search = Control.extend({ this.$element = $(this.element); this.$inputWrap = this.$element.find('.search-wrap'); this.$input = this.$inputWrap.find(".search"); - this.$resultsContainer = $(this.options.searchResultsContainerSelector); + this.$resultsContainer = $(this.options.searchResultsContainerSelector); this.$resultsWrap = this.$resultsContainer.find(".search-results-wrap"); this.$resultsContainerParent = this.$resultsContainer.closest(this.options.searchResultsContainerParentSelector); this.$resultsCancelLink = this.$resultsContainer.find(".search-cancel"); @@ -127,7 +127,7 @@ var Search = Control.extend({ getLocalStorageItem: function(key){ var storageItem = (this.useLocalStorage) ? localStorage.getItem(key) : this.storageFallback[key]; if (storageItem) { - return JSON.parse(storageItem); + return JSON.parse(storageItem); } return null; }, @@ -136,9 +136,9 @@ var Search = Control.extend({ if (data) { var storageItem = JSON.stringify(data); if (this.useLocalStorage) { - this.storageFallback[key] = storageItem; - } else { localStorage.setItem(key, storageItem); + } else { + this.storageFallback[key] = storageItem; } return true; } @@ -432,7 +432,7 @@ var Search = Control.extend({ ev.stopPropagation(); this.clear(); }, - + // ---- END EVENTS ---- // // ---- RESULTS EVENTS ---- // @@ -587,7 +587,7 @@ var Search = Control.extend({ } } }); - + this.$resultsContainer.scrollTop(0); } }, @@ -618,7 +618,7 @@ var Search = Control.extend({ $nextResult = this.$activeResult.next("li"); - //if no next result, + //if no next result, // activate the first one if(!$nextResult || ($nextResult && !$nextResult.length)){ this.activateResult(this.$resultsList.find("li").first()); @@ -647,7 +647,7 @@ var Search = Control.extend({ $prevResult = this.$activeResult.prev("li"); - //if no prev result, + //if no prev result, // activate the last one if(!$prevResult || ($prevResult && !$prevResult.length)){ this.activateResult(this.$resultsList.find("li").last()); @@ -659,7 +659,7 @@ var Search = Control.extend({ // function activateResult // sets property and adds class to active result activateResult: function($result){ - this.deactivateResult(); + this.deactivateResult(); this.$activeResult = $result; this.$activeResult.addClass(this.options.keyboardActiveClass); @@ -694,7 +694,7 @@ var Search = Control.extend({ // if method provided, use the return value // otherwise, use the position().top of the first list item getActiveResultOffset: function(){ - + if(this.options.getActiveResultOffset){ return this.options.getActiveResultOffset(); } @@ -711,7 +711,7 @@ var Search = Control.extend({ // ---- HELPERS ---- // - // function navigate + // function navigate //if we've been given a navigate method, call it // otherwise, just navigate normally navigate: function(href){ @@ -722,7 +722,7 @@ var Search = Control.extend({ } this.clear(); - + } // ---- END HELPERS ---- // From d4c7b76decd0c469c2156e8234bfa1a5340215d9 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 17:25:24 -0700 Subject: [PATCH 11/44] Add testing infrastructure --- .travis.yml | 5 +++++ package.json | 6 ++++++ test/browser.html | 4 ++++ test/browser.js | 7 +++++++ 4 files changed, 22 insertions(+) create mode 100644 .travis.yml create mode 100644 test/browser.html create mode 100644 test/browser.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ff54548e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: node +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" \ No newline at end of file diff --git a/package.json b/package.json index be60dec0..77aaaa59 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "scripts": { "start": "node make-example.js -f", "styles": "rm -rf node_modules/bit-docs-generate-html/site/static && node make-example.js -f", + "test": "npm run testee", + "testee": "testee test/browser.html --browsers firefox", + "preversion": "npm test", "postversion": "git push --tags && git push", "release:pre": "npm version prerelease && npm publish", "release:patch": "npm version patch && npm publish", @@ -43,6 +46,9 @@ "connect": "^3.5.0", "normalize.css": "^5.0.0", "q": "^1.4.1", + "steal": "^1.5.2", + "steal-qunit": "^1.0.1", + "testee": "^0.6.0", "zombie": "^5.0.5" } } diff --git a/test/browser.html b/test/browser.html new file mode 100644 index 00000000..e3ad6db2 --- /dev/null +++ b/test/browser.html @@ -0,0 +1,4 @@ + +bit-docs-html-canjs + +
    diff --git a/test/browser.js b/test/browser.js new file mode 100644 index 00000000..12ebd936 --- /dev/null +++ b/test/browser.js @@ -0,0 +1,7 @@ +import QUnit from 'steal-qunit'; + +QUnit.module('bit-docs-html-canjs'); + +QUnit.test('Placeholder test', function(){ + QUnit.equal(1, 1, '1 is 1'); +}); From a594afcdd5296664bf092058c39640251f5f2acd Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 18:42:29 -0700 Subject: [PATCH 12/44] Fix sidebar width. closes #286 --- static/canjs.js | 3 --- static/layout.less | 5 +++++ static/search.js | 15 ++++++++++----- static/search.less | 8 ++++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/static/canjs.js b/static/canjs.js index a39f5bb5..81d147d4 100644 --- a/static/canjs.js +++ b/static/canjs.js @@ -28,9 +28,6 @@ var $articleContainer, hasShownSearch = false; init(); - // prevent sidebar from changing width when header hides - $('#left').css('min-width', $('.top-left').width()); - // Override link behavior $(document.body).on("click", "a", function(ev) { var noModifierKeys = !ev.altKey && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey, diff --git a/static/layout.less b/static/layout.less index 57ae9746..a0165cfd 100644 --- a/static/layout.less +++ b/static/layout.less @@ -11,6 +11,8 @@ #left { position: fixed; width: @sidebar-width; + min-width: 0; + transition: min-width 0.4s ease; @media screen and (min-width: @breakpoint){ flex-shrink: 0; padding: 0px; @@ -18,6 +20,9 @@ width: auto; } } +#left.search-showing { + min-width: 300px; +} #right { height: 100%; min-height: 100%; diff --git a/static/search.js b/static/search.js index c4200ec5..6c55b1ed 100644 --- a/static/search.js +++ b/static/search.js @@ -30,7 +30,6 @@ var Search = Control.extend({ keyboardActiveClass: "keyboard-active", //search options - minSearchLength: 3, searchTimeout: 400, localStorageKeyPrefix: "bit-docs-search", @@ -331,11 +330,14 @@ var Search = Control.extend({ // takes a value and returns a map of all relevant search items searchEngineSearch: function(value){ var self = this; - return this.searchEngine + console.time('Search for ' + value); + var results = this.searchEngine //run the search .search(this.formatSearchTerm(value)) //convert the results into a searchMap subset .map(function(result){ return self.searchMap[result.ref] }); + console.timeEnd('Search for ' + value); + return results; }, //function formatSearchTerm @@ -381,7 +383,7 @@ var Search = Control.extend({ var value = ev.target.value; //hide search if input is empty or less than min length - if(!value || !value.length || value.length < this.options.minSearchLength){ + if(!value || !value.length){ this.unsetSearchState(); return; } @@ -396,6 +398,7 @@ var Search = Control.extend({ this.selectActiveResult(); break; default: + if(value !== this.searchTerm){ this.searchTerm = value; this.search(value); @@ -541,7 +544,7 @@ var Search = Control.extend({ // function hideResults // animate the results out - hideResults: function(){ + hideResults: function(collapse){ var self = this; if(this.$resultsContainer.is(":visible")){ @@ -549,6 +552,7 @@ var Search = Control.extend({ this.options.onResultsHide(); } this.deactivateResult(); + $('#left').removeClass('search-showing'); this.$resultsContainer.stop().addClass("is-hiding").fadeOut({ duration: 400, complete: function(){ @@ -580,7 +584,7 @@ var Search = Control.extend({ duration: 400, complete: function(){ if(!self.$resultsContainer.is(".is-hiding")){ - self.$resultsContainer.removeClass("is-showing") + self.$resultsContainer.addClass("is-showing"); if(self.options.onResultsShown){ self.options.onResultsShown(); } @@ -589,6 +593,7 @@ var Search = Control.extend({ }); this.$resultsContainer.scrollTop(0); + $('#left').addClass('search-showing'); } }, diff --git a/static/search.less b/static/search.less index d4309b53..efa7b268 100644 --- a/static/search.less +++ b/static/search.less @@ -36,14 +36,14 @@ background-repeat: no-repeat; display:none; } - - + .search{ background: @code-color; color: #ffffff; border: none; padding: 0; // text-indent: 1.5em; + width: 50px; .placeholder(@gray); &:focus{ outline:none; @@ -60,6 +60,10 @@ } } +#left.search-showing .search-bar .search-wrap .search { + width: 100%; +} + .bottom-left{ //Search Results .search-results-container{ From 292f1c18335dfe3afe2d1daa4cb99a5b97038415 Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 18:47:24 -0700 Subject: [PATCH 13/44] Removed debugging code --- static/search.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/static/search.js b/static/search.js index 6c55b1ed..77d91834 100644 --- a/static/search.js +++ b/static/search.js @@ -330,14 +330,11 @@ var Search = Control.extend({ // takes a value and returns a map of all relevant search items searchEngineSearch: function(value){ var self = this; - console.time('Search for ' + value); - var results = this.searchEngine - //run the search - .search(this.formatSearchTerm(value)) - //convert the results into a searchMap subset - .map(function(result){ return self.searchMap[result.ref] }); - console.timeEnd('Search for ' + value); - return results; + return this.searchEngine + //run the search + .search(this.formatSearchTerm(value)) + //convert the results into a searchMap subset + .map(function(result){ return self.searchMap[result.ref] }); }, //function formatSearchTerm From ca13085815b81d6c7d473977bb69ee6da65685d0 Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 18:49:46 -0700 Subject: [PATCH 14/44] Removed unused argument --- static/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 77d91834..8cda442d 100644 --- a/static/search.js +++ b/static/search.js @@ -541,7 +541,7 @@ var Search = Control.extend({ // function hideResults // animate the results out - hideResults: function(collapse){ + hideResults: function(){ var self = this; if(this.$resultsContainer.is(":visible")){ From 6714b04d5d7f07ac385ffa692397a8088997b153 Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 19:07:44 -0700 Subject: [PATCH 15/44] Starting width of 40px --- static/search.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/search.less b/static/search.less index efa7b268..0bdd91bf 100644 --- a/static/search.less +++ b/static/search.less @@ -43,7 +43,7 @@ border: none; padding: 0; // text-indent: 1.5em; - width: 50px; + width: 40px; .placeholder(@gray); &:focus{ outline:none; From d7a35eef7abb3e31a0f8de1c794c3bd8e86f7b18 Mon Sep 17 00:00:00 2001 From: imaustink Date: Thu, 1 Jun 2017 19:17:04 -0700 Subject: [PATCH 16/44] Fixed header jankyness --- static/canjs.js | 3 +++ static/layout.less | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/static/canjs.js b/static/canjs.js index 81d147d4..2d958f96 100644 --- a/static/canjs.js +++ b/static/canjs.js @@ -28,6 +28,9 @@ var $articleContainer, hasShownSearch = false; init(); + // prevent sidebar from changing width when header hides + $('#left').css('min-width', $('.top-left').width()); + // Override link behavior $(document.body).on("click", "a", function(ev) { var noModifierKeys = !ev.altKey && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey, diff --git a/static/layout.less b/static/layout.less index a0165cfd..25b51d6b 100644 --- a/static/layout.less +++ b/static/layout.less @@ -21,7 +21,7 @@ } } #left.search-showing { - min-width: 300px; + min-width: 300px !important; } #right { height: 100%; From f6cd4efc4a3f11c04e4267ea3bc56c16cd31f348 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 19:27:21 -0700 Subject: [PATCH 17/44] Use StealJS 0.16.x I believe 1.x was conflicting with steal-tools 0.16.x --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 77aaaa59..0965491a 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "connect": "^3.5.0", "normalize.css": "^5.0.0", "q": "^1.4.1", - "steal": "^1.5.2", - "steal-qunit": "^1.0.1", + "steal": "^0.16.44", + "steal-qunit": "^0.1.4", "testee": "^0.6.0", "zombie": "^5.0.5" } From d00a7dd55947e318eb48e2e7026e85c606efc38b Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 10:51:33 -0700 Subject: [PATCH 18/44] Don't hide search after selecting result. closes #289 --- static/search.js | 5 ----- static/search.less | 12 ++++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/static/search.js b/static/search.js index ebe9809a..198a3a27 100644 --- a/static/search.js +++ b/static/search.js @@ -459,8 +459,6 @@ var Search = Control.extend({ self.navigate($a.attr("href")); return; } - - self.clear(); }); } }, @@ -720,9 +718,6 @@ var Search = Control.extend({ }else{ window.location.href = href; } - - this.clear(); - } // ---- END HELPERS ---- // diff --git a/static/search.less b/static/search.less index d4309b53..eddf7e2c 100644 --- a/static/search.less +++ b/static/search.less @@ -53,11 +53,15 @@ &.has-value .search-icon-cancel{ display:block; } + @media screen and (max-width: @breakpoint) { + &.has-value{ + width: 200px; + } + } } - @media screen and (min-width: @breakpoint) { - display: block; - } + display: block; + } } .bottom-left{ @@ -72,7 +76,7 @@ left: 0; overflow-y: auto; padding: 2em 0; - + z-index: 1; .search-cancel{ color: @code-color; display: block; From 95b559b0c4ecf965f29a0458e707b5fe8023e5ed Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 11:15:10 -0700 Subject: [PATCH 19/44] Align the search icon and placeholder. close #287 --- static/search.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/search.less b/static/search.less index d4309b53..3003d115 100644 --- a/static/search.less +++ b/static/search.less @@ -43,7 +43,8 @@ color: #ffffff; border: none; padding: 0; - // text-indent: 1.5em; + position: relative; + bottom: 2px; .placeholder(@gray); &:focus{ outline:none; From 214c45cce729d63fc08ae419ba4fca18ff165671 Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 12:53:01 -0700 Subject: [PATCH 20/44] Smooth transition --- static/search.js | 4 +++- static/search.less | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 2f84a1e8..f3c936e0 100644 --- a/static/search.js +++ b/static/search.js @@ -334,7 +334,7 @@ var Search = Control.extend({ //run the search .search(this.formatSearchTerm(value)) //convert the results into a searchMap subset - .map(function(result){ return self.searchMap[result.ref] }); + .map(function(result){ return self.searchMap[result.ref] }).slice(0, 3); }, //function formatSearchTerm @@ -566,6 +566,7 @@ var Search = Control.extend({ } }); } + $('#left').removeClass('search-showing'); }, // function showResults @@ -592,6 +593,7 @@ var Search = Control.extend({ this.$resultsContainer.scrollTop(0); $('#left').addClass('search-showing'); } + $('#left').addClass('search-showing'); }, // ---- END SHOW/HIDE ---- // diff --git a/static/search.less b/static/search.less index 0bdd91bf..b9829988 100644 --- a/static/search.less +++ b/static/search.less @@ -38,6 +38,7 @@ } .search{ + transition: width 0.4s ease; background: @code-color; color: #ffffff; border: none; From 70dd5b4bc4369f560197429088ce63bf36829c4b Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 12:54:48 -0700 Subject: [PATCH 21/44] Removed test code --- static/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index f3c936e0..84000282 100644 --- a/static/search.js +++ b/static/search.js @@ -334,7 +334,7 @@ var Search = Control.extend({ //run the search .search(this.formatSearchTerm(value)) //convert the results into a searchMap subset - .map(function(result){ return self.searchMap[result.ref] }).slice(0, 3); + .map(function(result){ return self.searchMap[result.ref] }); }, //function formatSearchTerm From a84ec781e34b26b7f549eec2b8868ccc5554dbf4 Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 13:06:37 -0700 Subject: [PATCH 22/44] Removed accidental change --- static/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 84000282..ac8c9e42 100644 --- a/static/search.js +++ b/static/search.js @@ -582,7 +582,7 @@ var Search = Control.extend({ duration: 400, complete: function(){ if(!self.$resultsContainer.is(".is-hiding")){ - self.$resultsContainer.addClass("is-showing"); + self.$resultsContainer.removeClass("is-showing"); if(self.options.onResultsShown){ self.options.onResultsShown(); } From 3f0b19b4a60d395697bdaf036ced90a04b9a4c4a Mon Sep 17 00:00:00 2001 From: imaustink Date: Fri, 2 Jun 2017 13:36:43 -0700 Subject: [PATCH 23/44] Removed extra add/remove class --- static/search.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/static/search.js b/static/search.js index ac8c9e42..d82d8e5b 100644 --- a/static/search.js +++ b/static/search.js @@ -566,7 +566,6 @@ var Search = Control.extend({ } }); } - $('#left').removeClass('search-showing'); }, // function showResults @@ -593,7 +592,6 @@ var Search = Control.extend({ this.$resultsContainer.scrollTop(0); $('#left').addClass('search-showing'); } - $('#left').addClass('search-showing'); }, // ---- END SHOW/HIDE ---- // From 8dba6c3d6b291042e8477bd68726e16bfd5d9f81 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 21:37:30 -0700 Subject: [PATCH 24/44] Add a test for the search control --- static/search.js | 115 ++++++++++++++++++++++++++--------------------- test/browser.js | 9 +--- test/search.js | 31 +++++++++++++ 3 files changed, 96 insertions(+), 59 deletions(-) create mode 100644 test/search.js diff --git a/static/search.js b/static/search.js index dcb0f508..8251b3eb 100644 --- a/static/search.js +++ b/static/search.js @@ -4,7 +4,7 @@ var searchResultsRenderer = require("./templates/search-results.stache!steal-sta var joinURIs = require("can-util/js/join-uris/"); //https://lunrjs.com/guides/getting_started.html -var searchEngine = require("lunr"); +var lunr = require("lunr"); var Search = Control.extend({ @@ -66,6 +66,7 @@ var Search = Control.extend({ init: function(){ + var options = this.options; var self = this; //init elements @@ -76,23 +77,28 @@ var Search = Control.extend({ this.useLocalStorage = this.localStorageIsAvailable(); - this.checkSearchMapHash(this.options.pathPrefix + this.options.searchMapHashUrl).then(function(searchMapHashChangedObject){ - self.getSearchMap(self.options.pathPrefix + self.options.searchMapUrl, searchMapHashChangedObject).then(function(searchMap){ - self.initSearchEngine(searchMap); + this.searchEnginePromise = new Promise(function(resolve, reject) { + self.checkSearchMapHash(options.pathPrefix + options.searchMapHashUrl).then(function(searchMapHashChangedObject){ + self.getSearchMap(options.pathPrefix + options.searchMapUrl, searchMapHashChangedObject).then(function(searchMap){ + var searchEngine = self.initSearchEngine(searchMap); + resolve(searchEngine); - //show the search input when the search engine is ready - if(self.options.animateInOnStart){ - self.$inputWrap.fadeIn(400); - }else{ - self.$inputWrap.show(); - } + //show the search input when the search engine is ready + if(self.options.animateInOnStart){ + self.$inputWrap.fadeIn(400); + }else{ + self.$inputWrap.show(); + } - self.bindResultsEvents(); + self.bindResultsEvents(); + }, function(error){ + console.error("getSearchMap error", error); + reject(error); + }); }, function(error){ - console.error("getSearchMap error", error); + console.error("checkSearchMapHash error", error); + reject(error); }); - }, function(error){ - console.error("checkSearchMapHash error", error); }); }, destroy: function(){ @@ -305,12 +311,13 @@ var Search = Control.extend({ // else // generates search engine from searchMap & saves index to local storage initSearchEngine: function(searchMap){ - var localStorageKey = this.formatLocalStorageKey(this.searchIndexLocalStorageKey), - index = this.getLocalStorageItem(localStorageKey); + var searchEngine; + var localStorageKey = this.formatLocalStorageKey(this.searchIndexLocalStorageKey); + var index = this.getLocalStorageItem(localStorageKey); if(index){ - this.searchEngine = searchEngine.Index.load(index); + searchEngine = lunr.Index.load(index); }else{ - this.searchEngine = searchEngine(function(){ + searchEngine = lunr(function(){ this.ref('name'); this.field('title'); this.field('description'); @@ -322,19 +329,22 @@ var Search = Control.extend({ } } }); - this.setLocalStorageItem(localStorageKey, this.searchEngine); + this.setLocalStorageItem(localStorageKey, searchEngine); } + return searchEngine; }, // function searchEngineSearch // takes a value and returns a map of all relevant search items searchEngineSearch: function(value){ var self = this; - return this.searchEngine - //run the search - .search(this.formatSearchTerm(value)) - //convert the results into a searchMap subset - .map(function(result){ return self.searchMap[result.ref] }); + return this.searchEnginePromise.then(function(searchEngine) { + return searchEngine + //run the search + .search(self.formatSearchTerm(value)) + //convert the results into a searchMap subset + .map(function(result){ return self.searchMap[result.ref] }); + }); }, //function formatSearchTerm @@ -395,7 +405,7 @@ var Search = Control.extend({ this.selectActiveResult(); break; default: - + if(value !== this.searchTerm){ this.searchTerm = value; this.search(value); @@ -485,36 +495,37 @@ var Search = Control.extend({ clearTimeout(this.searchDebounceHandle); var self = this; this.searchDebounceHandle = setTimeout(function(){ - var resultsMap = self.searchEngineSearch(value), - numResults = Object.keys(resultsMap).length, - resultsFrag = self.options.resultsRenderer({ - results:resultsMap, - numResults:numResults, - searchValue:value, - pathPrefix: (self.options.pathPrefix === '.') ? '' : '/' + self.options.pathPrefix + '/' - },{ - docUrl: function(){ - if(!self.options.pathPrefix){ - return this.url; - } - - var root = joinURIs(window.location.href, self.options.pathPrefix); - if(root.substr(-1) === "/"){ - root = root.substr(0, root.length-1); - } - - return root + "/" + this.url; + self.searchEngineSearch(value).then(function(resultsMap) { + var numResults = Object.keys(resultsMap).length; + var resultsFrag = self.options.resultsRenderer({ + results:resultsMap, + numResults:numResults, + searchValue:value, + pathPrefix: (self.options.pathPrefix === '.') ? '' : '/' + self.options.pathPrefix + '/' + },{ + docUrl: function(){ + if(!self.options.pathPrefix){ + return this.url; } - }); - self.$resultsWrap.empty(); - self.$resultsWrap[0].appendChild(resultsFrag); + var root = joinURIs(window.location.href, self.options.pathPrefix); + if(root.substr(-1) === "/"){ + root = root.substr(0, root.length-1); + } - //refresh necessary dom - self.$resultsList = null; - if(numResults){ - self.$resultsList = self.$resultsWrap.find(".search-results > ul"); - } + return root + "/" + this.url; + } + }); + + self.$resultsWrap.empty(); + self.$resultsWrap[0].appendChild(resultsFrag); + + //refresh necessary dom + self.$resultsList = null; + if(numResults){ + self.$resultsList = self.$resultsWrap.find(".search-results > ul"); + } + }); }, this.options.searchTimeout); }, diff --git a/test/browser.js b/test/browser.js index 12ebd936..7d6c4e01 100644 --- a/test/browser.js +++ b/test/browser.js @@ -1,7 +1,2 @@ -import QUnit from 'steal-qunit'; - -QUnit.module('bit-docs-html-canjs'); - -QUnit.test('Placeholder test', function(){ - QUnit.equal(1, 1, '1 is 1'); -}); +// All test files that should be run in a browser go here +require('./search'); diff --git a/test/search.js b/test/search.js new file mode 100644 index 00000000..c2b6b47b --- /dev/null +++ b/test/search.js @@ -0,0 +1,31 @@ +var QUnit = require('steal-qunit'); +var SearchControl = require('../static/search'); + +/* Helper function for finding a specific result */ +var indexOfPageInResults = function(pageName, results) { + return results.findIndex(function(result) { + return result.name === pageName; + }); +}; + +/* Create the search bar element */ +var searchBar = document.createElement('div'); +searchBar.id = 'search-bar'; +document.body.appendChild(searchBar); + +/* Create a new instance of the search control */ +var search = new SearchControl('#search-bar', { + pathPrefix: '../temp' +}); + +/* Tests */ +QUnit.module('search control'); + +QUnit.test('Search for “about”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('about').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('about', results), 0, 'first result is the About page'); + done(); + }); +}); From 7d63b8b8d1569570039a2854d245aa4d9cd49b70 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 22:42:07 -0700 Subject: [PATCH 25/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9Ccan-component=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 12 +++++++++++- test/search.js | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 8251b3eb..4731f550 100644 --- a/static/search.js +++ b/static/search.js @@ -318,9 +318,16 @@ var Search = Control.extend({ searchEngine = lunr.Index.load(index); }else{ searchEngine = lunr(function(){ + lunr.tokenizer.separator = /[\s]+/; + + this.pipeline.remove(lunr.stemmer); + this.pipeline.remove(lunr.stopWordFilter); + this.searchPipeline.remove(lunr.stemmer); + this.ref('name'); this.field('title'); this.field('description'); + this.field('name'); this.field('url'); for (var itemKey in searchMap) { @@ -341,7 +348,10 @@ var Search = Control.extend({ return this.searchEnginePromise.then(function(searchEngine) { return searchEngine //run the search - .search(self.formatSearchTerm(value)) + .query(function(q) { + // look for an exact match and apply a large positive boost + q.term(value, { usePipeline: true, boost: 100 }); + }) //convert the results into a searchMap subset .map(function(result){ return self.searchMap[result.ref] }); }); diff --git a/test/search.js b/test/search.js index c2b6b47b..b947d645 100644 --- a/test/search.js +++ b/test/search.js @@ -8,6 +8,9 @@ var indexOfPageInResults = function(pageName, results) { }); }; +/* Clear local storage */ +window.localStorage.clear(); + /* Create the search bar element */ var searchBar = document.createElement('div'); searchBar.id = 'search-bar'; @@ -29,3 +32,12 @@ QUnit.test('Search for “about”', function(assert) { done(); }); }); + +QUnit.test('Search for “can-component”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('can-component').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('can-component', results), 0, 'first result is the can-component page'); + done(); + }); +}); From c932163e0e04f075e10d9b09a71f7eed8929d7cb Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 23:15:04 -0700 Subject: [PATCH 26/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9CLive=20Binding=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 7 +++++++ test/search.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/static/search.js b/static/search.js index 4731f550..09330453 100644 --- a/static/search.js +++ b/static/search.js @@ -349,8 +349,15 @@ var Search = Control.extend({ return searchEngine //run the search .query(function(q) { + // look for an exact match and apply a large positive boost q.term(value, { usePipeline: true, boost: 100 }); + + // look for matches in any of the fields and apply a medium positive boost + var split = value.split(lunr.tokenizer.separator); + split.forEach(function(term) { + q.term(term.toLowerCase(), { usePipeline: false, fields: q.allFields, boost: 10 }); + }); }) //convert the results into a searchMap subset .map(function(result){ return self.searchMap[result.ref] }); diff --git a/test/search.js b/test/search.js index b947d645..6178ae13 100644 --- a/test/search.js +++ b/test/search.js @@ -41,3 +41,12 @@ QUnit.test('Search for “can-component”', function(assert) { done(); }); }); + +QUnit.test('Search for “Live Binding”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('Live Binding').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('can-stache.Binding', results) < 2, true, 'first result is the can-stache Live Binding page'); + done(); + }); +}); From 7813b0a48ce93fcc6700a6fefe180b45f066986c Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 23:25:53 -0700 Subject: [PATCH 27/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9CPlay=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 1 + test/search.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/static/search.js b/static/search.js index 09330453..285f781f 100644 --- a/static/search.js +++ b/static/search.js @@ -357,6 +357,7 @@ var Search = Control.extend({ var split = value.split(lunr.tokenizer.separator); split.forEach(function(term) { q.term(term.toLowerCase(), { usePipeline: false, fields: q.allFields, boost: 10 }); + q.term(term.toLowerCase() + '*', { usePipeline: false, fields: q.allFields, boost: 10 }); }); }) //convert the results into a searchMap subset diff --git a/test/search.js b/test/search.js index 6178ae13..74f088b6 100644 --- a/test/search.js +++ b/test/search.js @@ -50,3 +50,12 @@ QUnit.test('Search for “Live Binding”', function(assert) { done(); }); }); + +QUnit.test('Search for “Play”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('Play').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('guides/recipes/playlist-editor', results), 0, 'first result is the “Playlist Editor (Advanced)” guide'); + done(); + }); +}); From 7fa59d9f8f12eac79c1b061ccc4308209209fae0 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 23:34:01 -0700 Subject: [PATCH 28/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9Ccan-connect=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 2 +- test/search.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 285f781f..7b267f3d 100644 --- a/static/search.js +++ b/static/search.js @@ -357,7 +357,7 @@ var Search = Control.extend({ var split = value.split(lunr.tokenizer.separator); split.forEach(function(term) { q.term(term.toLowerCase(), { usePipeline: false, fields: q.allFields, boost: 10 }); - q.term(term.toLowerCase() + '*', { usePipeline: false, fields: q.allFields, boost: 10 }); + q.term(term.toLowerCase() + '*', { usePipeline: false, fields: q.allFields }); }); }) //convert the results into a searchMap subset diff --git a/test/search.js b/test/search.js index 74f088b6..a955e4fb 100644 --- a/test/search.js +++ b/test/search.js @@ -42,6 +42,15 @@ QUnit.test('Search for “can-component”', function(assert) { }); }); +QUnit.test('Search for “can-connect”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('can-connect').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('can-connect', results), 0, 'first result is the can-connect page'); + done(); + }); +}); + QUnit.test('Search for “Live Binding”', function(assert) { var done = assert.async(); search.searchEngineSearch('Live Binding').then(function(results) { From a1584adb249eef02cbe2a27d9a3c2fe5cc2bc9da Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Thu, 1 Jun 2017 23:45:57 -0700 Subject: [PATCH 29/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9Chelpers/=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 5 ++++- test/search.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/static/search.js b/static/search.js index 7b267f3d..3e8f5c6d 100644 --- a/static/search.js +++ b/static/search.js @@ -351,7 +351,10 @@ var Search = Control.extend({ .query(function(q) { // look for an exact match and apply a large positive boost - q.term(value, { usePipeline: true, boost: 100 }); + q.term(value, { usePipeline: true, boost: 120 }); + + // look for terns that match the beginning or end of this query + q.term('*' + value + '*', { usePipeline: false }); // look for matches in any of the fields and apply a medium positive boost var split = value.split(lunr.tokenizer.separator); diff --git a/test/search.js b/test/search.js index a955e4fb..f7e2bf97 100644 --- a/test/search.js +++ b/test/search.js @@ -51,6 +51,14 @@ QUnit.test('Search for “can-connect”', function(assert) { }); }); +QUnit.test('Search for “helpers/', function(assert) { + var done = assert.async(); + search.searchEngineSearch('helpers/').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + done(); + }); +}); + QUnit.test('Search for “Live Binding”', function(assert) { var done = assert.async(); search.searchEngineSearch('Live Binding').then(function(results) { From 0d346e5b32244c61d9063c104cad53ac85d9b96f Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 2 Jun 2017 14:34:04 -0700 Subject: [PATCH 30/44] Refresh the Lunr index when we change the indexer Previously, if we made changes to the indexing code, the cached version of the Lunr index (from local storage) would still be used. This commit adds a version number near our indexing code that should be incremented whenever we make changes to how Lunr indexes our content. --- static/search.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/static/search.js b/static/search.js index 3e8f5c6d..f04ffd8c 100644 --- a/static/search.js +++ b/static/search.js @@ -32,7 +32,7 @@ var Search = Control.extend({ //search options searchTimeout: 400, - localStorageKeyPrefix: "bit-docs-search", + localStorageKeyPrefix: "search", //whether or not to animate in upon initialization animateInOnStart: true @@ -170,7 +170,7 @@ var Search = Control.extend({ // ---- END LOCAL STORAGE ---- // // ---- END DATA RETRIEVAL ---- // - searchMapLocalStorageKey: "searchMap", + searchMapLocalStorageKey: 'map', searchMap: null, // function getSearchMap @@ -231,7 +231,7 @@ var Search = Control.extend({ return returnDeferred; }, - searchMapHashLocalStorageKey: "searchMapHash", + searchMapHashLocalStorageKey: 'map-hash', // function checkSearchMapHash // retrieves the searchMapHash localStorage (if present) // and from the specified url @@ -241,22 +241,18 @@ var Search = Control.extend({ // // @returns thenable that resolves to true if localStorage was cleared and false otherwise checkSearchMapHash: function(dataUrl) { - var self = this, - returnDeferred = $.Deferred(), - localStorageKey = self.formatLocalStorageKey(self.searchMapHashLocalStorageKey), - searchMapHashLocalStorage = self.getLocalStorageItem(localStorageKey), - lsHash = searchMapHashLocalStorage && searchMapHashLocalStorage.hash; + var returnDeferred = $.Deferred(); + var self = this; //no need to do anything if localStorage isn't present - if(!window.localStorage){ + if (!this.useLocalStorage) { returnDeferred.resolve(false); return; } - - localStorageKey = self.formatLocalStorageKey(self.searchMapHashLocalStorageKey); - searchMapHashLocalStorage = self.getLocalStorageItem(localStorageKey); - lsHash = searchMapHashLocalStorage && searchMapHashLocalStorage.hash; + var localStorageKey = self.formatLocalStorageKey(self.searchMapHashLocalStorageKey); + var searchMapHashLocalStorage = self.getLocalStorageItem(localStorageKey); + var lsHash = searchMapHashLocalStorage && searchMapHashLocalStorage.hash; $.ajax({ url: dataUrl, @@ -302,7 +298,8 @@ var Search = Control.extend({ // ---- SEARCHING / PARSING ---- // - searchIndexLocalStorageKey: "searchIndex", + searchIndexLocalStorageKey: 'index', + searchIndexVersionLocalStorageKey: 'index-version', searchEngine: null, // function initSearchEngine // checks localStorage for an index @@ -312,9 +309,13 @@ var Search = Control.extend({ // generates search engine from searchMap & saves index to local storage initSearchEngine: function(searchMap){ var searchEngine; - var localStorageKey = this.formatLocalStorageKey(this.searchIndexLocalStorageKey); - var index = this.getLocalStorageItem(localStorageKey); - if(index){ + var searchIndexKey = this.formatLocalStorageKey(this.searchIndexLocalStorageKey); + var searchIndexVersionKey = this.formatLocalStorageKey(this.searchIndexVersionLocalStorageKey); + var index = this.getLocalStorageItem(searchIndexKey); + var indexVersion = this.getLocalStorageItem(searchIndexVersionKey); + var currentIndexVersion = 1;// Bump this whenever the index code is changed + + if (index && currentIndexVersion === indexVersion) { searchEngine = lunr.Index.load(index); }else{ searchEngine = lunr(function(){ @@ -336,7 +337,8 @@ var Search = Control.extend({ } } }); - this.setLocalStorageItem(localStorageKey, searchEngine); + this.setLocalStorageItem(searchIndexKey, searchEngine); + this.setLocalStorageItem(searchIndexVersionKey, currentIndexVersion); } return searchEngine; }, From 9f2500fcfe1271d483925a626aa168e9a6b09b2a Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 2 Jun 2017 16:09:06 -0700 Subject: [PATCH 31/44] =?UTF-8?q?Add=20a=20test=20for=20searching=20for=20?= =?UTF-8?q?=E2=80=9Cstache=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/search.js | 23 ++++++++++++++++------- test/search.js | 9 +++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/static/search.js b/static/search.js index f04ffd8c..44ec9d16 100644 --- a/static/search.js +++ b/static/search.js @@ -346,23 +346,32 @@ var Search = Control.extend({ // function searchEngineSearch // takes a value and returns a map of all relevant search items searchEngineSearch: function(value){ + var searchTerm = value.toLowerCase(); var self = this; return this.searchEnginePromise.then(function(searchEngine) { return searchEngine //run the search .query(function(q) { - // look for an exact match and apply a large positive boost - q.term(value, { usePipeline: true, boost: 120 }); - // look for terns that match the beginning or end of this query - q.term('*' + value + '*', { usePipeline: false }); + if (searchTerm.indexOf('can-') > -1) {// If the search term includes “can-” + + // look for an exact match and apply a large positive boost + q.term(searchTerm, { usePipeline: true, boost: 120 }); + + } else { + // add “can-”, look for an exact match in the title field, and apply a positive boost + q.term('can-' + searchTerm, { usePipeline: false, fields: ['title'], boost: 12 }); + } + + // look for terms that match the beginning or end of this query + q.term('*' + searchTerm + '*', { usePipeline: false }); // look for matches in any of the fields and apply a medium positive boost - var split = value.split(lunr.tokenizer.separator); + var split = searchTerm.split(lunr.tokenizer.separator); split.forEach(function(term) { - q.term(term.toLowerCase(), { usePipeline: false, fields: q.allFields, boost: 10 }); - q.term(term.toLowerCase() + '*', { usePipeline: false, fields: q.allFields }); + q.term(term, { usePipeline: false, fields: q.allFields, boost: 10 }); + q.term(term + '*', { usePipeline: false, fields: q.allFields }); }); }) //convert the results into a searchMap subset diff --git a/test/search.js b/test/search.js index f7e2bf97..385dd374 100644 --- a/test/search.js +++ b/test/search.js @@ -76,3 +76,12 @@ QUnit.test('Search for “Play”', function(assert) { done(); }); }); + +QUnit.test('Search for “stache”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('stache').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('can-stache', results), 0, 'first result is the can-stache page'); + done(); + }); +}); From 9b18d768ba11712c3779a6a81a74622637c5d863 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 2 Jun 2017 16:10:57 -0700 Subject: [PATCH 32/44] Generate the site before running the tests --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0965491a..03cb9ca2 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "static/canjs", "scripts": { "start": "node make-example.js -f", - "styles": "rm -rf node_modules/bit-docs-generate-html/site/static && node make-example.js -f", - "test": "npm run testee", + "styles": "rm -rf node_modules/bit-docs-generate-html/site/static && npm start", + "test": "npm start && npm run testee", "testee": "testee test/browser.html --browsers firefox", "preversion": "npm test", "postversion": "git push --tags && git push", From 12384e90d6d43dd9f2a136a30ac07b1c94c584c2 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 2 Jun 2017 17:13:35 -0700 Subject: [PATCH 33/44] Truncate results to 50 Fixes https://github.com/canjs/bit-docs-html-canjs/issues/274 --- static/search.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/static/search.js b/static/search.js index 44ec9d16..48b576e9 100644 --- a/static/search.js +++ b/static/search.js @@ -527,11 +527,15 @@ var Search = Control.extend({ clearTimeout(this.searchDebounceHandle); var self = this; this.searchDebounceHandle = setTimeout(function(){ - self.searchEngineSearch(value).then(function(resultsMap) { - var numResults = Object.keys(resultsMap).length; + self.searchEngineSearch(value).then(function(results) { + var numResults = results.length; + if (numResults > 50) { + numResults = '50+'; + results = results.slice(0, 50); + } var resultsFrag = self.options.resultsRenderer({ - results:resultsMap, - numResults:numResults, + results: results, + numResults: numResults, searchValue:value, pathPrefix: (self.options.pathPrefix === '.') ? '' : '/' + self.options.pathPrefix + '/' },{ From ebb8897165adeb758f559121b461b4cbd8e723c1 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Fri, 2 Jun 2017 17:30:47 -0700 Subject: [PATCH 34/44] =?UTF-8?q?Fix=20searching=20for=20terms=20like=20?= =?UTF-8?q?=E2=80=9C%special=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/canjs/bit-docs-html-canjs/issues/279 --- static/search.js | 6 +++--- test/search.js | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/static/search.js b/static/search.js index 44ec9d16..94f503e1 100644 --- a/static/search.js +++ b/static/search.js @@ -313,7 +313,7 @@ var Search = Control.extend({ var searchIndexVersionKey = this.formatLocalStorageKey(this.searchIndexVersionLocalStorageKey); var index = this.getLocalStorageItem(searchIndexKey); var indexVersion = this.getLocalStorageItem(searchIndexVersionKey); - var currentIndexVersion = 1;// Bump this whenever the index code is changed + var currentIndexVersion = 2;// Bump this whenever the index code is changed if (index && currentIndexVersion === indexVersion) { searchEngine = lunr.Index.load(index); @@ -323,6 +323,7 @@ var Search = Control.extend({ this.pipeline.remove(lunr.stemmer); this.pipeline.remove(lunr.stopWordFilter); + this.pipeline.remove(lunr.trimmer); this.searchPipeline.remove(lunr.stemmer); this.ref('name'); @@ -353,11 +354,10 @@ var Search = Control.extend({ //run the search .query(function(q) { - if (searchTerm.indexOf('can-') > -1) {// If the search term includes “can-” // look for an exact match and apply a large positive boost - q.term(searchTerm, { usePipeline: true, boost: 120 }); + q.term(searchTerm, { usePipeline: true, boost: 375 }); } else { // add “can-”, look for an exact match in the title field, and apply a positive boost diff --git a/test/search.js b/test/search.js index 385dd374..a80acbd5 100644 --- a/test/search.js +++ b/test/search.js @@ -85,3 +85,12 @@ QUnit.test('Search for “stache”', function(assert) { done(); }); }); + +QUnit.test('Search for “%special”', function(assert) { + var done = assert.async(); + search.searchEngineSearch('%special').then(function(results) { + assert.equal(results.length > 0, true, 'got results'); + assert.equal(indexOfPageInResults('can-stache/keys/special', results), 0, 'first result is the can-stache/keys/special page'); + done(); + }); +}); From bf406e5705437d2bc5b59e1eb04c1324e4d84d0a Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 11:10:34 -0700 Subject: [PATCH 35/44] Improve the speed of searching for can-* Searching for modules like can-compute was _really_ slow. This commit optimizes those queries by not also doing a fuzzy search. --- static/search.js | 41 ++++++++++++++++++++++------------------- test/search.js | 10 ++++++++++ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/static/search.js b/static/search.js index effb4e0a..127a8f5a 100644 --- a/static/search.js +++ b/static/search.js @@ -350,32 +350,35 @@ var Search = Control.extend({ var searchTerm = value.toLowerCase(); var self = this; return this.searchEnginePromise.then(function(searchEngine) { - return searchEngine - //run the search - .query(function(q) { - if (searchTerm.indexOf('can-') > -1) {// If the search term includes “can-” + //run the search + var queryResults = searchEngine.query(function(q) { - // look for an exact match and apply a large positive boost - q.term(searchTerm, { usePipeline: true, boost: 375 }); + if (searchTerm.indexOf('can-') > -1) {// If the search term includes “can-” - } else { - // add “can-”, look for an exact match in the title field, and apply a positive boost - q.term('can-' + searchTerm, { usePipeline: false, fields: ['title'], boost: 12 }); - } + // look for an exact match and apply a large positive boost + q.term(searchTerm, { usePipeline: true, boost: 375 }); + + } else { + // add “can-”, look for an exact match in the title field, and apply a positive boost + q.term('can-' + searchTerm, { usePipeline: false, fields: ['title'], boost: 12 }); // look for terms that match the beginning or end of this query q.term('*' + searchTerm + '*', { usePipeline: false }); + } + + // look for matches in any of the fields and apply a medium positive boost + var split = searchTerm.split(lunr.tokenizer.separator); + split.forEach(function(term) { + q.term(term, { usePipeline: false, fields: q.allFields, boost: 10 }); + q.term(term + '*', { usePipeline: false, fields: q.allFields }); + }); + }); + + //convert the results into a searchMap subset + var mappedResults = queryResults.map(function(result){ return self.searchMap[result.ref] }); - // look for matches in any of the fields and apply a medium positive boost - var split = searchTerm.split(lunr.tokenizer.separator); - split.forEach(function(term) { - q.term(term, { usePipeline: false, fields: q.allFields, boost: 10 }); - q.term(term + '*', { usePipeline: false, fields: q.allFields }); - }); - }) - //convert the results into a searchMap subset - .map(function(result){ return self.searchMap[result.ref] }); + return mappedResults; }); }, diff --git a/test/search.js b/test/search.js index a80acbd5..f2baca61 100644 --- a/test/search.js +++ b/test/search.js @@ -94,3 +94,13 @@ QUnit.test('Search for “%special”', function(assert) { done(); }); }); + +QUnit.test('Speed while searching for can-*', function(assert) { + var done = assert.async(); + var startTime = new Date(); + search.searchEngineSearch('can-zone').then(function() { + var totalTime = new Date() - startTime; + assert.equal(totalTime < 300, true, 'less than 300 milliseconds'); + done(); + }); +}); From 48b2ca38e1ad448be1e7f1791773c1ef7886eed0 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 16:11:05 -0700 Subject: [PATCH 36/44] Fix opening search animation Previously, when the user would start a new search and the results would open, the sidebar would jump to a specific width and then animate the rest of the width change. This fixes the styles so the sidebar animates smoothly to its new width. --- static/layout.less | 7 ++++--- static/search.less | 35 ++++++++--------------------------- static/sidebar.less | 15 --------------- templates/search-bar.mustache | 3 ++- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/static/layout.less b/static/layout.less index 25b51d6b..6ef6c3a9 100644 --- a/static/layout.less +++ b/static/layout.less @@ -18,11 +18,12 @@ padding: 0px; position: relative; width: auto; + + &.search-showing { + min-width: 300px !important; + } } } -#left.search-showing { - min-width: 300px !important; -} #right { height: 100%; min-height: 100%; diff --git a/static/search.less b/static/search.less index 14035517..adcf1bbb 100644 --- a/static/search.less +++ b/static/search.less @@ -6,13 +6,10 @@ cursor:pointer; .search-wrap{ - position: relative; - padding: 0 1.5em; + display: flex; + .search-icon{ display: block; - position: absolute; - top: 1px; - left: 0; height: 1em; width: 1em; font-size: 1em; @@ -23,12 +20,11 @@ } .search-icon-cancel{ display: block; - position: absolute; - right: 0; + position: relative; height: 1em; width: 1em; font-size: .8em; - top: 0.25em; + top: 0.125em; cursor: pointer; background-color: @code-color; background-image: url(img/icon-x-white.svg); @@ -36,16 +32,16 @@ background-repeat: no-repeat; display:none; } - + .search{ transition: width 0.4s ease; background: @code-color; color: #ffffff; border: none; - padding: 0; + padding: 0 .5em; position: relative; - bottom: 2px; - width: 40px; + bottom: 0.125em; + flex: 1; .placeholder(@gray); &:focus{ outline:none; @@ -55,21 +51,9 @@ &.has-value .search-icon-cancel{ display:block; } - @media screen and (max-width: @breakpoint) { - &.has-value{ - width: 200px; - } - } - } - @media screen and (min-width: @breakpoint) { - display: block; } } -#left.search-showing .search-bar .search-wrap .search { - width: 100%; -} - .bottom-left{ //Search Results .search-results-container{ @@ -90,9 +74,6 @@ padding: .5em; font-size: 1em; line-height: 1; - position: absolute; - top: 0; - right: 0; } ul{ diff --git a/static/sidebar.less b/static/sidebar.less index adaa56ff..4603ca3e 100644 --- a/static/sidebar.less +++ b/static/sidebar.less @@ -1,18 +1,3 @@ -.search-bar { - background: @code-color; - padding: @gutter @gutter*2; - height: 48px; - p { - border: none; - margin: 0px; - color: white; - font-weight: 300; - } - @media screen and (min-width: @breakpoint) { - display: block; - } -} - // ----- SOCIAL BUTTONS FOR MOBILE VIEW ----- ul.social-side{ margin: 0; diff --git a/templates/search-bar.mustache b/templates/search-bar.mustache index 4cb5739b..0ff781cb 100644 --- a/templates/search-bar.mustache +++ b/templates/search-bar.mustache @@ -1,9 +1,9 @@ From 4d7d50785aff89cb172ceb616ec17d86e4718fa1 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 16:12:50 -0700 Subject: [PATCH 37/44] Make a variable for the search animation duration --- static/search.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/search.js b/static/search.js index 127a8f5a..f45a968f 100644 --- a/static/search.js +++ b/static/search.js @@ -30,6 +30,7 @@ var Search = Control.extend({ keyboardActiveClass: "keyboard-active", //search options + searchAnimation: 400, searchTimeout: 400, localStorageKeyPrefix: "search", @@ -85,7 +86,7 @@ var Search = Control.extend({ //show the search input when the search engine is ready if(self.options.animateInOnStart){ - self.$inputWrap.fadeIn(400); + self.$inputWrap.fadeIn(self.options.searchAnimation); }else{ self.$inputWrap.show(); } @@ -599,7 +600,7 @@ var Search = Control.extend({ this.deactivateResult(); $('#left').removeClass('search-showing'); this.$resultsContainer.stop().addClass("is-hiding").fadeOut({ - duration: 400, + duration: this.options.searchAnimation, complete: function(){ self.$resultsContainer.removeClass("is-hiding"); if(!self.$resultsContainer.is(".is-showing")){ @@ -626,7 +627,7 @@ var Search = Control.extend({ } this.$resultsContainerParent.stop().addClass("search-active"); this.$resultsContainer.addClass("is-showing").fadeIn({ - duration: 400, + duration: this.options.searchAnimation, complete: function(){ if(!self.$resultsContainer.is(".is-hiding")){ self.$resultsContainer.removeClass("is-showing"); From 7a6cbb275188c06e3dc1d4f2fa77e9242a5ddb94 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 17:46:25 -0700 Subject: [PATCH 38/44] Add a blur to the background of search results --- static/layout.less | 2 +- static/search.js | 2 +- static/search.less | 11 ++++++++++- static/variables.less | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/static/layout.less b/static/layout.less index 6ef6c3a9..2e1fc581 100644 --- a/static/layout.less +++ b/static/layout.less @@ -12,7 +12,7 @@ position: fixed; width: @sidebar-width; min-width: 0; - transition: min-width 0.4s ease; + transition: min-width @transition-speed ease; @media screen and (min-width: @breakpoint){ flex-shrink: 0; padding: 0px; diff --git a/static/search.js b/static/search.js index f45a968f..42b40cdd 100644 --- a/static/search.js +++ b/static/search.js @@ -30,7 +30,7 @@ var Search = Control.extend({ keyboardActiveClass: "keyboard-active", //search options - searchAnimation: 400, + searchAnimation: 250,// matches @transition-speed in variables.less searchTimeout: 400, localStorageKeyPrefix: "search", diff --git a/static/search.less b/static/search.less index adcf1bbb..4b9e0bea 100644 --- a/static/search.less +++ b/static/search.less @@ -34,7 +34,7 @@ } .search{ - transition: width 0.4s ease; + transition: width @transition-speed ease; background: @code-color; color: #ffffff; border: none; @@ -66,6 +66,7 @@ left: 0; overflow-y: auto; padding: 2em 0; + transition: -webkit-backdrop-filter backdrop-filter background @transition-speed ease; z-index: 1; .search-cancel{ color: @code-color; @@ -138,3 +139,11 @@ position:relative; } } + +@supports (-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px)) { + .bottom-left .search-results-container { + -webkit-backdrop-filter: @backdrop-blur; + backdrop-filter: @backdrop-blur; + background: rgba(100%, 100%, 100%, .65); + } +} diff --git a/static/variables.less b/static/variables.less index a55d1f1f..a5a3bcda 100644 --- a/static/variables.less +++ b/static/variables.less @@ -18,3 +18,6 @@ /*----- TYPE -----*/ @font-weight-heading: 500; + +/*----- OTHER -----*/ +@backdrop-blur: saturate(180%) blur(20px); From 1c36a61fe86a775e5d1218107bd11a81fcb4a72a Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 18:00:07 -0700 Subject: [PATCH 39/44] Fix the cancel search button --- static/search.js | 13 +++++++------ static/search.less | 1 - templates/search-bar.mustache | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/static/search.js b/static/search.js index 42b40cdd..b9b1c5d6 100644 --- a/static/search.js +++ b/static/search.js @@ -473,11 +473,8 @@ var Search = Control.extend({ }, //cancel search on cancel click - ".search-icon-cancel click": function(el, ev){ - ev.preventDefault(); - ev.stopPropagation(); - this.clear(); - }, + ".search-icon-cancel click": "clear", + ".search-icon-cancel touchend": "clear", // ---- END EVENTS ---- // @@ -574,7 +571,11 @@ var Search = Control.extend({ // function clear // - clears & focuses the input // - unsets the search state - clear: function(){ + clear: function(element, event) { + if (event) { + event.preventDefault(); + event.stopPropagation(); + } this.$input.val("").trigger("focus"); this.unsetSearchState(); }, diff --git a/static/search.less b/static/search.less index 4b9e0bea..a5c46fb0 100644 --- a/static/search.less +++ b/static/search.less @@ -19,7 +19,6 @@ background-repeat: no-repeat; } .search-icon-cancel{ - display: block; position: relative; height: 1em; width: 1em; diff --git a/templates/search-bar.mustache b/templates/search-bar.mustache index 0ff781cb..52628aec 100644 --- a/templates/search-bar.mustache +++ b/templates/search-bar.mustache @@ -10,6 +10,6 @@ autocorrect="off" autocapitalize="none" spellcheck="false"/> + - From a2409914214f3fef7a979679840ae0b3d5e3442b Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 18:07:40 -0700 Subject: [PATCH 40/44] Better align the search field with the rest of the text in the black bar --- static/search.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/search.less b/static/search.less index a5c46fb0..11d6f5b5 100644 --- a/static/search.less +++ b/static/search.less @@ -7,6 +7,8 @@ .search-wrap{ display: flex; + position: relative; + top: 1px; .search-icon{ display: block; @@ -38,8 +40,6 @@ color: #ffffff; border: none; padding: 0 .5em; - position: relative; - bottom: 0.125em; flex: 1; .placeholder(@gray); &:focus{ From fa9077f6f1e158c2b92b8e8b16c138e48368f5e6 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Mon, 5 Jun 2017 18:23:11 -0700 Subject: [PATCH 41/44] Escape the description This prevents html elements that should show up as code from being inserted into the DOM. --- static/templates/search-results.stache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/templates/search-results.stache b/static/templates/search-results.stache index 72f738d4..141c8343 100644 --- a/static/templates/search-results.stache +++ b/static/templates/search-results.stache @@ -23,12 +23,12 @@ {{#if result.title}} ({{result.name}}) - + {{/if}} {{#if result.description}}
    - {{{result.description}}} + {{result.description}}
    {{/if}} From 5ee54641b006db9b0aea11f732458dfdeb0c59e9 Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Tue, 6 Jun 2017 10:49:32 -0700 Subject: [PATCH 42/44] Temporarily disable search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’ll be re-enabled in a future version. --- static/canjs.js | 22 +++++++++++----------- static/search.less | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/static/canjs.js b/static/canjs.js index 2d958f96..13c4c4de 100644 --- a/static/canjs.js +++ b/static/canjs.js @@ -28,7 +28,7 @@ var $articleContainer, hasShownSearch = false; init(); - // prevent sidebar from changing width when header hides + // prevent sidebar from changing width when header hides $('#left').css('min-width', $('.top-left').width()); // Override link behavior @@ -88,14 +88,14 @@ function init() { buildTOC(); setNavToggleListener(); setScrollPosition(); - searchControl = new SearchControl(".search-bar", { - navigate: function(href){ - window.history.pushState(null, null, href); - navigate(href); - }, - pathPrefix: window.pathPrefix, - animateInOnStart: !hasShownSearch - }); + // searchControl = new SearchControl(".search-bar", { + // navigate: function(href){ + // window.history.pushState(null, null, href); + // navigate(href); + // }, + // pathPrefix: window.pathPrefix, + // animateInOnStart: !hasShownSearch + // }); hasShownSearch = true; } @@ -172,7 +172,7 @@ function navigate(href) { clearInterval(scrollPositionInterval); loader.start(); - + navigating = true; $.ajax(href, { dataType: "text", @@ -224,7 +224,7 @@ function navigate(href) { $.getScript('https://buttons.github.io/buttons.js'); loader.end(); - + // go through every package and re-init for (var packageName in window.PACKAGES) { if (typeof window.PACKAGES[packageName] === "function") { diff --git a/static/search.less b/static/search.less index 11d6f5b5..7de9e824 100644 --- a/static/search.less +++ b/static/search.less @@ -3,7 +3,7 @@ background: @code-color; padding: @gutter @gutter*2; height: 48px; - cursor:pointer; + // cursor:pointer; .search-wrap{ display: flex; From 81270e9bae36f1747b8abe5822951fe28653a63d Mon Sep 17 00:00:00 2001 From: Chasen Le Hara Date: Tue, 6 Jun 2017 11:03:03 -0700 Subject: [PATCH 43/44] Change links to https Also update links to donejs.com to point to the right sections. --- templates/footer.mustache | 2 +- templates/header-left.mustache | 6 +++--- templates/header-right.mustache | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/footer.mustache b/templates/footer.mustache index 2c32e8ed..6c923d92 100644 --- a/templates/footer.mustache +++ b/templates/footer.mustache @@ -1 +1 @@ -

    CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently {{package.version}}.

    \ No newline at end of file +

    CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently {{package.version}}.

    diff --git a/templates/header-left.mustache b/templates/header-left.mustache index b5af5c48..cb78d49c 100644 --- a/templates/header-left.mustache +++ b/templates/header-left.mustache @@ -3,10 +3,10 @@
    diff --git a/templates/header-right.mustache b/templates/header-right.mustache index 0787cc3b..0e25b0a0 100644 --- a/templates/header-right.mustache +++ b/templates/header-right.mustache @@ -1,7 +1,7 @@