Skip to content

Commit

Permalink
add changes 8️⃣
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-co committed Dec 18, 2015
1 parent 0111dc6 commit a6cd3db
Show file tree
Hide file tree
Showing 47 changed files with 104,693 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7,065 changes: 7,065 additions & 0 deletions ch10/zip/bootstrap.css

Large diffs are not rendered by default.

67,417 changes: 67,417 additions & 0 deletions ch10/zip/browser.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions ch10/zip/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<script src="react.js"></script>
<script src="react-dom.js"></script>
<script src="browser.js"></script>
<script src="jquery.js"></script>
<script src="jquery.ziptastic.js"></script>
<link href="bootstrap.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="container-fluid">
<div class="col-md-3"></div>
<div id="content" class="col-md-6"></div>
<div class="col-md-3"></div>
</div>

<script type="text/babel">
var Content = React.createClass({
getInitialState: function(){
return {
stateName: '',
city: '',
zip: ''
}
},
resolveZip: function(event){
var zipNode = this.refs.zip
$.ziptastic(zipNode.value, function(country, stateName, stateCode, city, zip) {
this.setState({
city: city,
stateName: stateName
})
}.bind(this))
},
handleTyping: function(event){
if (event.target.value.length === 5) {
this.resolveZip()
}
this.setState({zip: event.target.value.replace(/[a-z]/ig, '').substr(0,5)})
},
render: function() {
return (
<div className="well">
<h1>Address Form</h1>
<div className="form-group">
Zip: <input ref="zip" className="form-control" type="text" placeholder="94103" onChange={this.handleTyping} value={this.state.zip}/>
</div>
<div className="form-group">
<a className="btn btn-primary" onClick={this.resolveZip}>Fill City and State</a>
</div>
<div className="form-group">
City: <input type="text" ref="city" className="form-control" disabled="true" value={this.state.city}/>
</div>
<div className="form-group">
State: <input type="text" ref="stateName" className="form-control" disabled="true" value={this.state.stateName}/>
</div>
</div>
)
}
})

ReactDOM.render(
<Content />,
document.getElementById('content')
)
</script>
</body>
</html>
Loading

0 comments on commit a6cd3db

Please sign in to comment.