From 1ac13c6f433605e7535f09db5fbe1ae7d594ce09 Mon Sep 17 00:00:00 2001 From: Josh Kruder Date: Fri, 20 Mar 2015 20:31:46 -0400 Subject: [PATCH] Refactored onShow and onDismiss and added call to onShow if onImmediately. --- src/js/dialog-window.jsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/js/dialog-window.jsx b/src/js/dialog-window.jsx index 89b98d01a4b3bb..13d5333c072be4 100644 --- a/src/js/dialog-window.jsx +++ b/src/js/dialog-window.jsx @@ -40,7 +40,10 @@ var DialogWindow = React.createClass({ componentDidMount: function() { this._positionDialog(); - if (this.props.openImmediately) this.refs.dialogOverlay.preventScrolling(); + if (this.props.openImmediately) { + this.refs.dialogOverlay.preventScrolling(); + this._onShow(); + } }, componentDidUpdate: function (prevProps, prevState) { @@ -79,14 +82,14 @@ var DialogWindow = React.createClass({ }.bind(this)); this.setState({ open: false }); - if (this.props.onDismiss) this.props.onDismiss(); + this._onDismiss(); }, show: function() { this.refs.dialogOverlay.preventScrolling(); this.setState({ open: true }); - if (this.props.onShow) this.props.onShow(); + this._onShow(); }, _addClassName: function(reactObject, className) { @@ -153,10 +156,16 @@ var DialogWindow = React.createClass({ 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(); + }, _handleOverlayTouchTap: function() { this.dismiss();