diff --git a/docs/src/app/components/pages/components/date-picker.jsx b/docs/src/app/components/pages/components/date-picker.jsx index 5e7e8d86daf925..c70c59b6711c52 100644 --- a/docs/src/app/components/pages/components/date-picker.jsx +++ b/docs/src/app/components/pages/components/date-picker.jsx @@ -14,7 +14,7 @@ var DatePickerPage = React.createClass({ '//Landscape Dialog\n' + ''; + ' mode="landscape"/>'; var componentInfo = [ { @@ -38,7 +38,13 @@ var DatePickerPage = React.createClass({ type: 'one of: portrait, landscape', header: 'default: portrait', desc: 'Tells the component to display the picker in portrait or landscape mode.' - } + }, + { + name: 'open', + type: 'bool', + header: 'default: no used', + desc: 'Tells the component to show or dismiss the dialog.' + }, ] }, { @@ -77,4 +83,4 @@ var DatePickerPage = React.createClass({ }); -module.exports = DatePickerPage; \ No newline at end of file +module.exports = DatePickerPage; diff --git a/src/js/date-picker/date-picker.jsx b/src/js/date-picker/date-picker.jsx index bf294e6efd6e6a..9c4d848f6a9244 100644 --- a/src/js/date-picker/date-picker.jsx +++ b/src/js/date-picker/date-picker.jsx @@ -14,6 +14,7 @@ var DatePicker = React.createClass({ defaultDate: React.PropTypes.object, formatDate: React.PropTypes.func, mode: React.PropTypes.oneOf(['portrait', 'landscape', 'inline']), + open: React.PropTypes.bool, onFocus: React.PropTypes.func, onTouchTap: React.PropTypes.func, onChange: React.PropTypes.func, @@ -46,6 +47,7 @@ var DatePicker = React.createClass({ onTouchTap, onShow, onDismiss, + open, ...other } = this.props; var classes = this.getClasses('mui-date-picker', { @@ -69,6 +71,7 @@ var DatePicker = React.createClass({ diff --git a/src/js/dialog-window.jsx b/src/js/dialog-window.jsx index 13d5333c072be4..e97785afb91940 100644 --- a/src/js/dialog-window.jsx +++ b/src/js/dialog-window.jsx @@ -15,6 +15,7 @@ var DialogWindow = React.createClass({ actions: React.PropTypes.array, contentClassName: React.PropTypes.string, openImmediately: React.PropTypes.bool, + open: React.PropTypes.bool, onClickAway: React.PropTypes.func, onDismiss: React.PropTypes.func, onShow: React.PropTypes.func, @@ -34,10 +35,24 @@ var DialogWindow = React.createClass({ getInitialState: function() { return { - open: this.props.openImmediately || false + open: this.props.open || this.props.openImmediately || false }; }, + componentWillReceiveProps: function(nextProps) { + if(nextProps.hasOwnProperty('open')) { + this.setState({ + open: nextProps.open, + }); + + if (nextProps.open) { + this.refs.dialogOverlay.preventScrolling(); + } else { + this.refs.dialogOverlay.allowScrolling(); + } + } + }, + componentDidMount: function() { this._positionDialog(); if (this.props.openImmediately) { @@ -51,7 +66,7 @@ var DialogWindow = React.createClass({ }, render: function() { - var classes = this.getClasses('mui-dialog-window', { + var classes = this.getClasses('mui-dialog-window', { 'mui-is-shown': this.state.open }); var contentClasses = 'mui-dialog-window-contents'; @@ -153,16 +168,16 @@ var DialogWindow = React.createClass({ //Vertically center the dialog window, but make sure it doesn't //transition to that position. if (this.props.repositionOnUpdate || !container.style.paddingTop) { - container.style.paddingTop = + container.style.paddingTop = ((containerHeight - dialogWindowHeight) / 2) - 64 + 'px'; } } }, - + _onShow: function() { if (this.props.onShow) this.props.onShow(); }, - + _onDismiss: function() { if (this.props.onDismiss) this.props.onDismiss(); },