Commit 07bd1f21 authored by Matthew Taylor's avatar Matthew Taylor

Move to using iframe in modal

like registration
parent cfb7fa03
...@@ -5,6 +5,7 @@ $navigation-height: 50px; ...@@ -5,6 +5,7 @@ $navigation-height: 50px;
.banner { .banner {
position: fixed; position: fixed;
top: $navigation-height; top: $navigation-height;
z-index: 99;
box-shadow: 0 1px 1px $ui-dark-gray; box-shadow: 0 1px 1px $ui-dark-gray;
background-color: $ui-orange; background-color: $ui-orange;
width: 100%; width: 100%;
......
...@@ -17,8 +17,16 @@ var Modal = React.createClass({ ...@@ -17,8 +17,16 @@ var Modal = React.createClass({
}, },
getDefaultProps: function () { getDefaultProps: function () {
return { return {
frameSettings: null, frameSettings: null
style: { };
},
requestClose: function () {
return this.refs.modal.portal.requestClose();
},
render: function () {
var frameSettings = this.props.frameSettings;
var style = this.props.style || {};
defaults(style, {
overlay: { overlay: {
zIndex: 100, zIndex: 100,
backgroundColor: 'rgba(0, 0, 0, .75)' backgroundColor: 'rgba(0, 0, 0, .75)'
...@@ -27,15 +35,7 @@ var Modal = React.createClass({ ...@@ -27,15 +35,7 @@ var Modal = React.createClass({
overflow: 'visible', overflow: 'visible',
borderRadius: '6px' borderRadius: '6px'
} }
} });
};
},
requestClose: function () {
return this.refs.modal.portal.requestClose();
},
render: function () {
var frameSettings = this.props.frameSettings;
var style = this.props.style;
var modalProps = omit(this.props, ['frameSettings', 'style']); var modalProps = omit(this.props, ['frameSettings', 'style']);
if (frameSettings) { if (frameSettings) {
defaults(frameSettings, Modal.defaultFrameSettings); defaults(frameSettings, Modal.defaultFrameSettings);
......
...@@ -41,9 +41,17 @@ var Splash = injectIntl(React.createClass({ ...@@ -41,9 +41,17 @@ var Splash = injectIntl(React.createClass({
this.getActivity(); this.getActivity();
this.getFeaturedCustom(); this.getFeaturedCustom();
this.getNews(); this.getNews();
if (
this.state.session.flags.has_outstanding_email_confirmation &&
this.state.session.flags.confirm_email_banner) {
window.addEventListener('message', this.onMessage);
}
} else { } else {
this.setState({featuredCustom: []}); this.setState({featuredCustom: []});
this.getProjectCount(); this.getProjectCount();
window.removeEventListener('message', this.onMessage);
} }
} }
}, },
...@@ -53,15 +61,36 @@ var Splash = injectIntl(React.createClass({ ...@@ -53,15 +61,36 @@ var Splash = injectIntl(React.createClass({
this.getActivity(); this.getActivity();
this.getFeaturedCustom(); this.getFeaturedCustom();
this.getNews(); this.getNews();
if (
this.state.session.flags.has_outstanding_email_confirmation &&
this.state.session.flags.confirm_email_banner) {
window.addEventListener('message', this.onMessage);
}
} else { } else {
this.getProjectCount(); this.getProjectCount();
} }
}, },
componentWillUnmount: function () {
window.removeEventListener('message', this.onMessage);
},
onMessage: function (e) {
if (e.origin != window.location.origin) return;
if (e.data == 'resend-done') {
this.hideEmailConfirmationModal();
} else {
var data = JSON.parse(e.data);
if (data['action'] === 'leave-page') {
window.location.href = data['uri'];
}
}
},
getActivity: function () { getActivity: function () {
this.api({ this.api({
uri: '/proxy/users/' + this.state.session.user.username + '/activity?limit=5' uri: '/proxy/users/' + this.state.session.user.username + '/activity?limit=5'
}, function (err, body) { }, function (err, body) {
if (!err) this.setState({'activity': body}); if (!err) this.setState({activity: body});
}.bind(this)); }.bind(this));
}, },
getFeaturedGlobal: function () { getFeaturedGlobal: function () {
...@@ -82,7 +111,7 @@ var Splash = injectIntl(React.createClass({ ...@@ -82,7 +111,7 @@ var Splash = injectIntl(React.createClass({
this.api({ this.api({
uri: '/news?limit=3' uri: '/news?limit=3'
}, function (err, body) { }, function (err, body) {
if (!err) this.setState({'news': body}); if (!err) this.setState({news: body});
}.bind(this)); }.bind(this));
}, },
getProjectCount: function () { getProjectCount: function () {
...@@ -93,10 +122,10 @@ var Splash = injectIntl(React.createClass({ ...@@ -93,10 +122,10 @@ var Splash = injectIntl(React.createClass({
}.bind(this)); }.bind(this));
}, },
showEmailConfirmationModal: function () { showEmailConfirmationModal: function () {
this.setState({showEmailConfirmationModal: true}); this.setState({emailConfirmationModalOpen: true});
}, },
hideEmailConfirmationModal: function () { hideEmailConfirmationModal: function () {
this.setState({showEmailConfirmationModal: false}); this.setState({emailConfirmationModalOpen: false});
}, },
handleDismiss: function (cue) { handleDismiss: function (cue) {
this.api({ this.api({
...@@ -250,7 +279,7 @@ var Splash = injectIntl(React.createClass({ ...@@ -250,7 +279,7 @@ var Splash = injectIntl(React.createClass({
}, },
render: function () { render: function () {
var featured = this.renderHomepageRows(); var featured = this.renderHomepageRows();
var showEmailConfirmation = true;( var showEmailConfirmation = (
this.state.session.user && this.state.session.flags.has_outstanding_email_confirmation && this.state.session.user && this.state.session.flags.has_outstanding_email_confirmation &&
this.state.session.flags.confirm_email_banner); this.state.session.flags.confirm_email_banner);
return ( return (
...@@ -260,16 +289,17 @@ var Splash = injectIntl(React.createClass({ ...@@ -260,16 +289,17 @@ var Splash = injectIntl(React.createClass({
className="warning" className="warning"
onRequestDismiss={this.handleDismiss.bind(this, 'confirmed_email')}> onRequestDismiss={this.handleDismiss.bind(this, 'confirmed_email')}>
<a href="#" onClick={this.showEmailConfirmationModal}>Confirm your email</a> <a href="#" onClick={this.showEmailConfirmationModal}>Confirm your email</a>
to enable sharing.{' '} {' '}to enable sharing.{' '}
<a href="/info/faq/#accounts">Having trouble?</a> <a href="/info/faq/#accounts">Having trouble?</a>
</Banner>, </Banner>,
<Modal key="emailConfirmationModal" <Modal key="emailConfirmationModal"
isOpen={this.showEmailConfirmationModal} isOpen={this.state.emailConfirmationModalOpen}
onRequestClose={this.hideEmailConfirmationModal} onRequestClose={this.hideEmailConfirmationModal}
frameSettings={Modal.defaultFrameSettings}> frameSettings={{width: 500, height: 330, padding: 1}}>
<iframe <iframe
src="/accounts/email_resend/" src="/accounts/email_resend_standalone/"
{...omit(Modal.defaultFrameSettings, 'padding')} /> width="500"
height="330" />
</Modal> </Modal>
] : []} ] : []}
<div key="inner" className="inner"> <div key="inner" className="inner">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment