Skip to content

Commit beb4f3a

Browse files
authored
Merge pull request #293 from canjs/286-sidebar-width
286 sidebar width
2 parents 97d1fae + 3f0b19b commit beb4f3a

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"connect": "^3.5.0",
4747
"normalize.css": "^5.0.0",
4848
"q": "^1.4.1",
49-
"steal": "^1.5.2",
50-
"steal-qunit": "^1.0.1",
49+
"steal": "^0.16.44",
50+
"steal-qunit": "^0.1.4",
5151
"testee": "^0.6.0",
5252
"zombie": "^5.0.5"
5353
}

static/canjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var $articleContainer,
2828
hasShownSearch = false;
2929
init();
3030

31-
// prevent sidebar from changing width when header hides
31+
// prevent sidebar from changing width when header hides
3232
$('#left').css('min-width', $('.top-left').width());
3333

3434
// Override link behavior

static/layout.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111
#left {
1212
position: fixed;
1313
width: @sidebar-width;
14+
min-width: 0;
15+
transition: min-width 0.4s ease;
1416
@media screen and (min-width: @breakpoint){
1517
flex-shrink: 0;
1618
padding: 0px;
1719
position: relative;
1820
width: auto;
1921
}
2022
}
23+
#left.search-showing {
24+
min-width: 300px !important;
25+
}
2126
#right {
2227
height: 100%;
2328
min-height: 100%;

static/search.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var Search = Control.extend({
3030
keyboardActiveClass: "keyboard-active",
3131

3232
//search options
33-
minSearchLength: 3,
3433
searchTimeout: 400,
3534

3635
localStorageKeyPrefix: "bit-docs-search",
@@ -332,10 +331,10 @@ var Search = Control.extend({
332331
searchEngineSearch: function(value){
333332
var self = this;
334333
return this.searchEngine
335-
//run the search
336-
.search(this.formatSearchTerm(value))
337-
//convert the results into a searchMap subset
338-
.map(function(result){ return self.searchMap[result.ref] });
334+
//run the search
335+
.search(this.formatSearchTerm(value))
336+
//convert the results into a searchMap subset
337+
.map(function(result){ return self.searchMap[result.ref] });
339338
},
340339

341340
//function formatSearchTerm
@@ -381,7 +380,7 @@ var Search = Control.extend({
381380
var value = ev.target.value;
382381

383382
//hide search if input is empty or less than min length
384-
if(!value || !value.length || value.length < this.options.minSearchLength){
383+
if(!value || !value.length){
385384
this.unsetSearchState();
386385
return;
387386
}
@@ -396,6 +395,7 @@ var Search = Control.extend({
396395
this.selectActiveResult();
397396
break;
398397
default:
398+
399399
if(value !== this.searchTerm){
400400
this.searchTerm = value;
401401
this.search(value);
@@ -549,6 +549,7 @@ var Search = Control.extend({
549549
this.options.onResultsHide();
550550
}
551551
this.deactivateResult();
552+
$('#left').removeClass('search-showing');
552553
this.$resultsContainer.stop().addClass("is-hiding").fadeOut({
553554
duration: 400,
554555
complete: function(){
@@ -580,7 +581,7 @@ var Search = Control.extend({
580581
duration: 400,
581582
complete: function(){
582583
if(!self.$resultsContainer.is(".is-hiding")){
583-
self.$resultsContainer.removeClass("is-showing")
584+
self.$resultsContainer.removeClass("is-showing");
584585
if(self.options.onResultsShown){
585586
self.options.onResultsShown();
586587
}
@@ -589,6 +590,7 @@ var Search = Control.extend({
589590
});
590591

591592
this.$resultsContainer.scrollTop(0);
593+
$('#left').addClass('search-showing');
592594
}
593595
},
594596

static/search.less

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@
3636
background-repeat: no-repeat;
3737
display:none;
3838
}
39-
40-
39+
4140
.search{
41+
transition: width 0.4s ease;
4242
background: @code-color;
4343
color: #ffffff;
4444
border: none;
4545
padding: 0;
4646
// text-indent: 1.5em;
47+
width: 40px;
4748
.placeholder(@gray);
4849
&:focus{
4950
outline:none;
@@ -60,6 +61,10 @@
6061
}
6162
}
6263

64+
#left.search-showing .search-bar .search-wrap .search {
65+
width: 100%;
66+
}
67+
6368
.bottom-left{
6469
//Search Results
6570
.search-results-container{

0 commit comments

Comments
 (0)