'use strict'; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var LoginModal = (function (_React$Component) { _inherits(LoginModal, _React$Component); function LoginModal(props) { _classCallCheck(this, LoginModal); _get(Object.getPrototypeOf(LoginModal.prototype), 'constructor', this).call(this, props); this.state = { tab: this.props.tab || 'login' }; this.loginModal = this.loginModal.bind(this); } _createClass(LoginModal, [{ key: 'loginModal', value: function loginModal(ref) { var _this = this; if (ref != null) { this._modal = $(ref); this._modal.on('show.bs.modal', function (event) { if (event.relatedTarget) { var button = $(event.relatedTarget); if (button.data('tab')) { _this.setState({ tab: button.data('tab') }); } if (button.data('next')) { _this.setState({ 'next': button.data('next') }); } if (button.data('username')) { _this.setState({ 'username': button.data('username') }); } if (button.data('tab')) { _this.setState({ tab: button.data('tab') }); } } }); this._modal.on('shown.bs.modal', function (event) { // Select the first input whenever the modal shows. var $visibleInput = _this._modal.find('input:visible'); if ($visibleInput.length) { // Not all auth modal panes have inputs. $visibleInput[0].focus(); } }); this._modal.on('hide.bs.modal', function (event) { $('body').css('overflow', ''); $('body').css('position', ''); }); // NB: the LoginModal is _always_ mounted after the page loads // It is just hidden - this code runs only once per page load. if (window.location.hash) { // Handle the cases when we're navigating from another page or link to login/passwordReset form var tab = window.location.hash.slice(1); var deviceTypeModal = new UAParser().getDevice().type; // referral is a mobile only form, it just prompts the user to download the app. if (tab != 'referral' || deviceTypeModal == 'mobile') { var forms = ['login', 'signup', 'forgotPassword', 'resetPassword', 'referral', 'download']; if (forms.indexOf(tab) >= 0) { this._modal.modal('show'); } } } window.relogin = (function () { this.setState({ error: "You're not logged in.", next: url('path') }); this._modal.modal('show'); }).bind(this); } } }, { key: 'render', value: function render() { return React.createElement("div", { ref: this.loginModal, id: "authModal", tabIndex: "-100", className: "modal fade", role: "dialog", 'aria-labelledby': "authTabs", 'aria-hidden': "true" }, React.createElement("div", { className: "modal-dialog" }, React.createElement("div", { className: "modal-content text-center" }, React.createElement("div", { className: "modal-header bg-primary" }, React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-xs-1 col-xs-offset-11" }, React.createElement("button", { type: "button", className: "close", 'data-dismiss': "modal", 'aria-label': "Close" }, React.createElement("span", { 'aria-hidden': "true" }, "×")))), React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-xs-4 col-xs-offset-4" }, React.createElement("img", { style: { width: '100%' }, src: "/static/images/bird.png", alt: "Cam" })))), React.createElement(LoginForm, { referralCode: this.props.referralCode, accountType: cambly.LOGIN_ACCOUNT_TYPE, language: this.props.language, next: this.state.next || this.props.next, username: this.state.username, pageType: "modal-body", tab: this.state.tab, email: this.props.email, code: this.props.code, error: this.state.error })))); } }]); return LoginModal; })(React.Component);