Skip to content

Commit

Permalink
final little tweaks for 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
theporchrat committed Oct 9, 2014
1 parent 1c33502 commit 451bad1
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 44 deletions.
8 changes: 4 additions & 4 deletions browser/react-widgets.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/components/docs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ var Docs = React.createClass({
<Navbar page={this.props.page}/>
<div className='container'>
<aside className='col-sm-3'>
<Affix offsetTop={52} className='nav-aside'>
<div className='nav-aside'>
<Nav className='side-nav' onSelect={this.handleNavItemSelect}>
<NavItem key={0} href='#intro' active={href === '#intro' }>Getting Started</NavItem>
<NavItem key={1} href='#dropdown-list' active={ href === '#dropdown-list' }>Dropdown List</NavItem>
<NavItem key={2} href='#combobox' active={href === '#combobox'}>Combobox</NavItem>
<NavItem key={6} href='#number-picker' active={href === '#number-picker' }>Number Picker</NavItem>
<NavItem key={3} href='#select-list' active={href === '#select-list'}>Select</NavItem>
<NavItem key={4} href='#calendar' active={href === '#calendar'}>Calendar</NavItem>
<NavItem key={5} href='#date-picker' active={href === '#date-picker'}>Date Picker</NavItem>
<NavItem key={5} href='#date-picker' active={href === '#date-picker'}>Date {' & '} Time Picker</NavItem>
</Nav>
</Affix>
</div>
</aside>
<article className='col-sm-9 tab-content'>
<GettingStarted className={cx({"tab-pane": true, "active": href === '#intro' })}/>
Expand Down
12 changes: 7 additions & 5 deletions docs/components/examples/combobox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ module.exports = React.createClass({
</Button>
</div>
<div className='form-group'>
<label className='form-label'>Suggest</label>
<RW.DropDownlist
value={this.state.suggest}
data={[false, true]}
onChange={_.partial(this._set, 'suggest')}/>
<label className='form-label'></label>
<label className='checkbox-inline'>
<input type='checkbox'
checked={this.state.suggest}
onChange={_.partial(this._set, 'suggest', !this.state.suggest)}/>
Suggestions
</label>
</div>
<div className='form-group'>
<label className='form-label'>Filter</label>
Expand Down
9 changes: 1 addition & 8 deletions docs/components/examples/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ module.exports = React.createClass({

render: function(){
var allVals = this.state.value
, disabled = this.state.disabled === true || _.isArray(this.state.disabled)
// _.map(list, function(){
// return this.state.value
// })
//
console.log(disabled, this.state.disabled)

//allVals.unshift({ id: false, label: 'none'});
, disabled = this.state.disabled === true || _.isArray(this.state.disabled);

return (
<div className='example'>
Expand Down
6 changes: 6 additions & 0 deletions docs/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ h3 > .default {
max-width: 300px;
}

.nav-aside {
position: fixed;
top: 72px;
}

@media (max-width: 767px) {
.nav-aside {
position: static;
}
}

pre > code.hljs {
background: none;
}
Expand Down
17 changes: 17 additions & 0 deletions docs/docs.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions lib/dropdowns/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = React.createClass({
, this.props.value)
, idx = this._dataIndexOf(items, this.props.value);


return {
selectedIndex: idx,
focusedIndex: idx === -1 ? 0 : idx,
Expand Down Expand Up @@ -109,7 +110,6 @@ module.exports = React.createClass({
, idx = this._dataIndexOf(items, nextProps.value)
, focused = this.filterIndexOf(items, this._dataText(valueItem));

//console.log('set it', nextProps.value, this._dataText(valueItem))
this._searchTerm = '';

this.setState({
Expand Down Expand Up @@ -266,9 +266,8 @@ module.exports = React.createClass({
, selectedIdx = this.state.selectedIndex
, focusedIdx = this.state.focusedIndex
, isOpen = this.state.open
, noselection = selectedIdx == null || selectedIdx === -1 ;
, noselection = selectedIdx == null || selectedIdx === -1;

//console.log('focused:', focusedIdx, 'select: ', selectedIdx)
if ( key === 'End' )
select(this._data().length - 1)

Expand All @@ -287,7 +286,6 @@ module.exports = React.createClass({
if ( alt )
this.open()
else {
//if( noselection) select(focusedIdx)
if ( isOpen ) this.setFocusedIndex(this.nextFocusedIndex())
else select(this.nextSelectedIndex())
}
Expand All @@ -296,15 +294,14 @@ module.exports = React.createClass({
if ( alt )
this.close()
else {
//if( noselection) select(focusedIdx)
if ( isOpen ) this.setFocusedIndex(this.prevFocusedIndex())
else select(this.prevSelectedIndex())
}
}

function select(idx) {
if( idx === -1 || self._data().length === 0)
return self.change(self.refs.input.value, false)
return self.change(self.refs.input.getDOMNode().value, false)

self.refs.input.accept(true); //removes caret
self.change(self._data()[idx], false)
Expand Down
10 changes: 5 additions & 5 deletions lib/mixins/DataFilterMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ module.exports = {
},

filterIndexOf: function(items, searchTerm){
var matches = typeof this.props.filter === 'string'
? filters[this.props.filter]
: this.props.filter;
var matches = typeof this.props.filter === 'function'
? this.props.filter
: filters[this.props.filter || 'eq'];

if ( !matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1))
return items
if ( !searchTerm || !searchTerm.trim() || (this.props.filter && searchTerm.length < (this.props.minLength || 1)))
return -1

if ( !this.props.caseSensitive)
searchTerm = searchTerm.toLowerCase();
Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/DataHelpersMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ module.exports = {
_dataValue: function(item){
var field = this.props.valueField;

//item = this._dataItem(item)

return field && item && _.has(item, field)
? item[field]
: item
Expand Down Expand Up @@ -42,6 +40,8 @@ module.exports = {
, idx;

// make an attempt to see if we were passed in dataItem vs just a valueField value
// either an object with the right prop, or a primitive
// { valueField: 5 } || "hello" [ "hello" ]
if( _.has(item, field) || typeof(first) === typeof(val))
return item

Expand Down
9 changes: 3 additions & 6 deletions src/dropdowns/combobox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module.exports = React.createClass({
, this.props.value)
, idx = this._dataIndexOf(items, this.props.value);


return {
selectedIndex: idx,
focusedIndex: idx === -1 ? 0 : idx,
Expand Down Expand Up @@ -108,7 +109,6 @@ module.exports = React.createClass({
, idx = this._dataIndexOf(items, nextProps.value)
, focused = this.filterIndexOf(items, this._dataText(valueItem));

//console.log('set it', nextProps.value, this._dataText(valueItem))
this._searchTerm = '';

this.setState({
Expand Down Expand Up @@ -265,9 +265,8 @@ module.exports = React.createClass({
, selectedIdx = this.state.selectedIndex
, focusedIdx = this.state.focusedIndex
, isOpen = this.state.open
, noselection = selectedIdx == null || selectedIdx === -1 ;
, noselection = selectedIdx == null || selectedIdx === -1;

//console.log('focused:', focusedIdx, 'select: ', selectedIdx)
if ( key === 'End' )
select(this._data().length - 1)

Expand All @@ -286,7 +285,6 @@ module.exports = React.createClass({
if ( alt )
this.open()
else {
//if( noselection) select(focusedIdx)
if ( isOpen ) this.setFocusedIndex(this.nextFocusedIndex())
else select(this.nextSelectedIndex())
}
Expand All @@ -295,15 +293,14 @@ module.exports = React.createClass({
if ( alt )
this.close()
else {
//if( noselection) select(focusedIdx)
if ( isOpen ) this.setFocusedIndex(this.prevFocusedIndex())
else select(this.prevSelectedIndex())
}
}

function select(idx) {
if( idx === -1 || self._data().length === 0)
return self.change(self.refs.input.value, false)
return self.change(self.refs.input.getDOMNode().value, false)

self.refs.input.accept(true); //removes caret
self.change(self._data()[idx], false)
Expand Down
10 changes: 5 additions & 5 deletions src/mixins/DataFilterMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ module.exports = {
},

filterIndexOf: function(items, searchTerm){
var matches = typeof this.props.filter === 'string'
? filters[this.props.filter]
: this.props.filter;
var matches = typeof this.props.filter === 'function'
? this.props.filter
: filters[this.props.filter || 'eq'];

if ( !matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1))
return items
if ( !searchTerm || !searchTerm.trim() || (this.props.filter && searchTerm.length < (this.props.minLength || 1)))
return -1

if ( !this.props.caseSensitive)
searchTerm = searchTerm.toLowerCase();
Expand Down

0 comments on commit 451bad1

Please sign in to comment.