Skip to content

Commit e73e5d9

Browse files
Merge pull request #190 from canjs/123-search
Adding client search
2 parents 111c439 + fb1a65a commit e73e5d9

17 files changed

+1075
-142
lines changed

make-example.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
var generate = require("bit-docs-generate-html/generate");
2+
var generateSearchMap = require("bit-docs-generate-searchmap/generate");
23
var Q = require("q");
34
var fs = require("fs");
45
var readFile = Q.denodeify(fs.readFile);
56
var path = require("path");
67

8+
var forceBuild = process.argv.indexOf("-f") !== -1;
9+
710
var docMap = readFile(__dirname+"/docMap.json").then(function(source){
811
return JSON.parse(""+source);
912
});
10-
11-
var forceBuild = process.argv.indexOf("-f") !== -1;
12-
13-
generate(docMap,{
13+
var siteConfig = {
1414
html: {
1515
templates: path.join(__dirname, "templates"),
1616
dependencies: {
1717
"bit-docs-html-canjs": __dirname,
1818
"bit-docs-prettify": "^0.1.0",
19-
"bit-docs-html-highlight-line": "^0.2.2"
19+
"bit-docs-html-highlight-line": "^0.2.2",
20+
//TODO: This should not be include here and should only be included in package.json.
21+
// we get an error without this, here, though
22+
"steal-stache": "^3.0.1"
2023
}
2124
},
2225
dest: path.join(__dirname, "temp"),
@@ -27,4 +30,8 @@ generate(docMap,{
2730
"2.3.27": "https://v2.canjs.com"
2831
},
2932
debug: true
33+
};
34+
35+
generate(docMap,siteConfig).then(function(){
36+
return generateSearchMap(docMap, siteConfig);
3037
}).done();

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@
2727
"homepage": "https://github.com/canjs/bit-docs-html-canjs#readme",
2828
"system": {},
2929
"dependencies": {
30+
"can-control": "^3.0.3",
31+
"can-util": "^3.0.10",
3032
"escape-html": "^1.0.3",
3133
"jquery": "^2.2.4",
3234
"lodash": "^4.17.4",
35+
"lunr": "^2.0.3",
36+
"steal-stache": "^3.0.1",
3337
"unescape-html": "^1.0.0"
3438
},
3539
"devDependencies": {
36-
"bit-docs-generate-html": "^0.3.0",
40+
"bit-docs-generate-html": "^0.5.0",
41+
"bit-docs-generate-searchmap":"^0.0.1-0",
3742
"q": "^1.4.1",
3843
"connect": "^2.14.4",
3944
"normalize.css": "^4.1.1",

static/canjs.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
require("./canjs.less!");
21
$ = require("jquery");
32
var debounce = require("lodash/debounce");
3+
require("./canjs.less!");
4+
var SearchControl = require('./search');
45

56
// state
67
var $articleContainer,
@@ -14,7 +15,8 @@ var $articleContainer,
1415
animating,
1516
navigating,
1617
scrollPositionInterval,
17-
currentHref;
18+
currentHref,
19+
searchControl;
1820

1921
(function() {
2022
init();
@@ -74,6 +76,12 @@ function init() {
7476
buildTOC();
7577
setNavToggleListener();
7678
setScrollPosition();
79+
searchControl = new SearchControl(".search-bar", {
80+
navigate(href){
81+
window.history.pushState(null, null, href);
82+
navigate(href);
83+
}
84+
});
7785
}
7886

7987
function setDocTitle() {

static/canjs.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
@import "mobile.less";
2020
@import "breadcrumb.less";
2121
@import "screenshots.less";
22+
@import "search.less";
23+

static/img/icon-search-white.svg

Lines changed: 6 additions & 0 deletions
Loading

static/img/icon-x-white.svg

Lines changed: 6 additions & 0 deletions
Loading

static/mixins.less

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,18 @@
7171
border-bottom: 1px solid lighten(@warning-color, 40%);
7272
}
7373
}
74+
75+
.placeholder(@color: #f4f4f4){
76+
&::-webkit-input-placeholder { /* Chrome/Opera/Safari */
77+
color: @color;
78+
}
79+
&::-moz-placeholder { /* Firefox 19+ */
80+
color: @color;
81+
}
82+
&:-ms-input-placeholder { /* IE 10+ */
83+
color: @color;
84+
}
85+
&:-moz-placeholder { /* Firefox 18- */
86+
color: @color;
87+
}
88+
}

0 commit comments

Comments
 (0)