1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/resources/views/partials/sign_up.blade.php

337 lines
13 KiB
PHP
Raw Normal View History

2017-03-24 12:51:24 +01:00
<script type="text/javascript">
2018-04-10 17:07:10 +02:00
$(function() {
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
validateSignUp();
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
$('#signUpModal').on('shown.bs.modal', function () {
2017-03-24 12:51:24 +01:00
trackEvent('/account', '/view_sign_up');
2018-02-16 10:05:44 +01:00
// change the type after page load to prevent errors in Chrome console
2017-12-25 15:27:41 +01:00
$('#new_password').attr('type', 'password');
2017-03-24 12:51:24 +01:00
$(['first_name','last_name','email','password']).each(function(i, field) {
2018-04-10 17:07:10 +02:00
var $input = $('form.signUpForm #new_'+field);
if (!$input.val()) {
$input.focus();
return false;
}
2017-03-24 12:51:24 +01:00
});
2018-04-10 17:07:10 +02:00
})
@if (Auth::check() && !Utils::isNinja() && ! Auth::user()->registered)
$('#closeSignUpButton').hide();
showSignUp();
@elseif(Session::get('sign_up') || Input::get('sign_up'))
showSignUp();
@endif
// Ensure terms is checked for sign up form
@if (Auth::check())
setSignupEnabled(false);
2018-05-08 20:47:41 +02:00
$("#terms_checkbox, #privacy_checkbox").change(function() {
setSignupEnabled($('#terms_checkbox').is(':checked') && $('#privacy_checkbox').is(':checked'));
2018-04-10 17:07:10 +02:00
});
@endif
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
});
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function showSignUp() {
2018-02-16 10:05:44 +01:00
if (location.href.indexOf('/dashboard') == -1) {
location.href = "{{ url('/dashboard') }}?sign_up=true";
} else {
$('#signUpModal').modal('show');
}
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function hideSignUp() {
2017-03-24 12:51:24 +01:00
$('#signUpModal').modal('hide');
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function setSignupEnabled(enabled) {
2017-03-24 12:51:24 +01:00
$('.signup-form input[type=text]').prop('disabled', !enabled);
$('.signup-form input[type=password]').prop('disabled', !enabled);
if (enabled) {
$('.signup-form a.btn').removeClass('disabled');
} else {
$('.signup-form a.btn').addClass('disabled');
}
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function validateSignUp(showError) {
2017-03-24 12:51:24 +01:00
var isFormValid = true;
$(['first_name','last_name','email','password']).each(function(i, field) {
2018-04-10 17:07:10 +02:00
var $input = $('form.signUpForm #new_'+field),
val = $.trim($input.val());
var isValid = val && val.length >= (field == 'password' ? 8 : 1);
if (field == 'password') {
var score = scorePassword(val);
if (isValid) {
isValid = score > 50;
}
showPasswordStrength(val, score);
}
if (isValid && field == 'email') {
isValid = isValidEmailAddress(val);
}
if (isValid) {
$input.closest('div.form-group').removeClass('has-error').addClass('has-success');
} else {
isFormValid = false;
$input.closest('div.form-group').removeClass('has-success');
if (showError) {
$input.closest('div.form-group').addClass('has-error');
}
2017-03-24 12:51:24 +01:00
}
});
2018-05-08 20:47:41 +02:00
if (! $('#terms_checkbox').is(':checked') || ! $('#privacy_checkbox').is(':checked')) {
2018-04-10 17:07:10 +02:00
isFormValid = false;
2018-03-12 15:17:27 +01:00
}
2017-03-24 12:51:24 +01:00
$('#saveSignUpButton').prop('disabled', !isFormValid);
return isFormValid;
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function validateServerSignUp() {
2017-03-24 12:51:24 +01:00
if (!validateSignUp(true)) {
2018-04-10 17:07:10 +02:00
return;
2017-03-24 12:51:24 +01:00
}
$('#signUpDiv, #signUpFooter').hide();
$('#working').show();
$.ajax({
2018-04-10 17:07:10 +02:00
type: 'POST',
url: '{{ URL::to('signup/validate') }}',
data: 'email=' + $('form.signUpForm #new_email').val(),
success: function(result) {
if (result == 'available') {
submitSignUp();
} else {
$('#errorTaken').show();
$('form.signUpForm #new_email').closest('div.form-group').removeClass('has-success').addClass('has-error');
$('#signUpDiv, #signUpFooter').show();
$('#working').hide();
}
2017-03-24 12:51:24 +01:00
}
});
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function submitSignUp() {
2017-03-24 12:51:24 +01:00
$.ajax({
2018-04-10 17:07:10 +02:00
type: 'POST',
url: '{{ URL::to('signup/submit') }}',
data: 'new_email=' + encodeURIComponent($('form.signUpForm #new_email').val()) +
'&new_password=' + encodeURIComponent($('form.signUpForm #new_password').val()) +
'&new_first_name=' + encodeURIComponent($('form.signUpForm #new_first_name').val()) +
'&new_last_name=' + encodeURIComponent($('form.signUpForm #new_last_name').val()) +
'&go_pro=' + $('#go_pro').val(),
success: function(result) {
if (result) {
@if (Auth::user()->registered)
hideSignUp();
NINJA.formIsChanged = false;
location.href = "{{ url('/dashboard') }}";
@else
handleSignedUp();
NINJA.isRegistered = true;
$('#gettingStartedIframe').attr('src', '{{ str_replace('watch?v=', 'embed/', config('ninja.video_urls.getting_started')) }}');
$('#signUpButton').hide();
$('#myAccountButton').html(result);
$('#signUpSuccessDiv, #signUpFooter, #closeSignUpButton').show();
$('#working, #saveSignUpButton').hide();
@endif
}
2017-03-24 12:51:24 +01:00
}
});
2018-04-10 17:07:10 +02:00
}
2017-03-24 12:51:24 +01:00
2018-04-10 17:07:10 +02:00
function handleSignedUp() {
if (isStorageSupported()) {
localStorage.setItem('guest_key', '');
}
fbq('track', 'CompleteRegistration');
trackEvent('/account', '/signed_up');
}
2017-03-24 12:51:24 +01:00
</script>
2018-02-21 16:47:56 +01:00
@if (\Request::is('dashboard'))
2017-03-24 12:51:24 +01:00
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">{{ Auth::user()->registered ? trans('texts.add_company') : trans('texts.sign_up') }}</h4>
</div>
<div class="container" style="width: 100%; padding-bottom: 0px !important">
2017-03-26 10:45:17 +02:00
<div class="panel panel-default">
2017-03-24 12:51:24 +01:00
<div class="panel-body">
<div id="signUpDiv" onkeyup="validateSignUp()" onclick="validateSignUp()" onkeydown="checkForEnter(event)">
2017-04-12 16:04:09 +02:00
{!! Former::open('signup/submit')->addClass('signUpForm')->autocomplete('off') !!}
2017-03-24 12:51:24 +01:00
@if (Auth::check() && ! Auth::user()->registered)
{!! Former::populateField('new_first_name', Auth::user()->first_name) !!}
{!! Former::populateField('new_last_name', Auth::user()->last_name) !!}
{!! Former::populateField('new_email', Auth::user()->email) !!}
@endif
<div style="display:none">
{!! Former::text('path')->value(Request::path()) !!}
{!! Former::text('go_pro') !!}
</div>
<div class="row signup-form">
2018-03-12 15:17:27 +01:00
<div class="col-md-12">
{!! Former::checkbox('terms_checkbox')
->label(' ')
->value(1)
2018-03-12 19:57:46 +01:00
->text(trans('texts.agree_to_terms', [
2018-05-09 11:25:41 +02:00
'terms' => link_to(config('ninja.terms_of_service_url.' . (Utils::isSelfHost() ? 'selfhost' : 'hosted')), trans('texts.terms_of_service'), ['target' => '_blank']),
2018-03-12 19:57:46 +01:00
]))
2018-03-12 15:17:27 +01:00
->raw() !!}
2018-05-08 20:47:41 +02:00
{!! Former::checkbox('privacy_checkbox')
->label(' ')
->value(1)
->text(trans('texts.agree_to_terms', [
2018-05-09 11:25:41 +02:00
'terms' => link_to(config('ninja.privacy_policy_url.' . (Utils::isSelfHost() ? 'selfhost' : 'hosted')), trans('texts.privacy_policy'), ['target' => '_blank']),
2018-05-08 20:47:41 +02:00
]))
->raw() !!}
2018-03-12 15:17:27 +01:00
<br/>
</div>
<br/>&nbsp;<br/>
2017-03-24 12:51:24 +01:00
@if (Utils::isOAuthEnabled() && ! Auth::user()->registered)
<div class="col-md-5">
@foreach (App\Services\AuthService::$providers as $provider)
<a href="{{ URL::to('auth/' . $provider) }}" class="btn btn-primary btn-block"
style="padding-top:10px;padding-bottom:10px;margin-top:10px;margin-bottom:10px"
id="{{ strtolower($provider) }}LoginButton">
<i class="fa fa-{{ strtolower($provider) }}"></i> &nbsp;
{{ $provider }}
</a>
@endforeach
</div>
<div class="col-md-1">
<div style="border-right:thin solid #CCCCCC;height:90px;width:8px;margin-bottom:10px;"></div>
{{ trans('texts.or') }}
<div style="border-right:thin solid #CCCCCC;height:90px;width:8px;margin-top:10px;"></div>
</div>
<div class="col-md-6">
@else
<div class="col-md-12">
@endif
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 0) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 0) }}
{!! Former::text('new_first_name')
->placeholder(trans('texts.first_name'))
->autocomplete('given-name')
2018-02-16 10:05:44 +01:00
->data_lpignore('true')
2017-03-24 12:51:24 +01:00
->label(' ') !!}
{!! Former::text('new_last_name')
->placeholder(trans('texts.last_name'))
->autocomplete('family-name')
2018-02-16 10:05:44 +01:00
->data_lpignore('true')
2017-03-24 12:51:24 +01:00
->label(' ') !!}
{!! Former::text('new_email')
->placeholder(trans('texts.email'))
->autocomplete('email')
2018-02-16 10:05:44 +01:00
->data_lpignore('true')
2017-03-24 12:51:24 +01:00
->label(' ') !!}
2017-12-25 15:27:41 +01:00
{!! Former::text('new_password')
2017-03-24 12:51:24 +01:00
->placeholder(trans('texts.password'))
2017-04-12 16:04:09 +02:00
->autocomplete('new-password')
2018-02-16 10:05:44 +01:00
->data_lpignore('true')
2018-04-10 17:07:10 +02:00
->label(' ')
->help('<span id="passwordStrength">&nbsp;</span>') !!}
2017-03-24 12:51:24 +01:00
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
</div>
2017-04-06 12:43:36 +02:00
<center><div id="errorTaken" style="display:none">&nbsp;<br/><b>{{ trans('texts.email_taken') }}</b></div></center>
2017-03-24 12:51:24 +01:00
<div class="col-md-12">
2017-10-09 22:49:00 +02:00
<div style="padding-top:20px;padding-bottom:10px;">
@if (Auth::user()->registered)
{!! trans('texts.email_alias_message') !!}
2018-03-15 21:20:00 +01:00
@elseif (Utils::isNinjaProd())
2017-10-09 22:49:00 +02:00
@if (Utils::isPro())
{{ trans('texts.free_year_message') }}
@else
{{ trans('texts.trial_message') }}
@endif
@endif
</div>
2017-03-24 12:51:24 +01:00
</div>
</div>
{!! Former::close() !!}
</div>
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="working">
<h3>{{ trans('texts.working') }}...</h3>
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
<div style="background-color: #fff; padding-right:20px;padding-left:20px; display:none" id="signUpSuccessDiv">
<h3>{{ trans('texts.success') }}</h3>
<br/>
@if (Utils::isNinja())
{{ trans('texts.success_message') }}
<br/>&nbsp;<br/>
2017-03-24 12:51:24 +01:00
@endif
2017-12-07 11:33:24 +01:00
@if (! auth()->user()->registered)
<iframe id="gettingStartedIframe" width="100%" height="315"></iframe>
@endif
2017-03-24 12:51:24 +01:00
</div>
</div>
</div>
2017-05-07 16:07:57 +02:00
<div class="modal-footer" style="margin-top: 0px;padding-right:0px">
<span id="signUpFooter">
<button type="button" class="btn btn-default" id="closeSignUpButton" data-dismiss="modal">{{ trans('texts.close') }} <i class="glyphicon glyphicon-remove-circle"></i></button>
<button type="button" class="btn btn-primary" id="saveSignUpButton" onclick="validateServerSignUp()" disabled>{{ trans('texts.save') }} <i class="glyphicon glyphicon-floppy-disk"></i></button>
</span>
2017-03-24 12:51:24 +01:00
</div>
2017-03-24 14:44:01 +01:00
</div>
2017-03-24 12:51:24 +01:00
</div>
</div>
</div>
@endif
2017-03-24 12:51:24 +01:00
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="logoutModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.logout') }}</h4>
</div>
2017-03-24 14:44:01 +01:00
<div class="container" style="width: 100%; padding-bottom: 0px !important">
2017-03-26 10:45:17 +02:00
<div class="panel panel-default">
2017-03-24 14:44:01 +01:00
<div class="panel-body">
<h3>{{ trans('texts.are_you_sure') }}</h3><br/>
2017-03-24 12:51:24 +01:00
<p>{{ trans('texts.erase_data') }}</p>
</div>
2017-03-24 14:44:01 +01:00
</div>
</div>
2017-03-24 12:51:24 +01:00
2017-05-07 16:07:57 +02:00
<div class="modal-footer">
2017-03-24 12:51:24 +01:00
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
2017-03-24 14:44:01 +01:00
<button type="button" class="btn btn-danger" onclick="logout(true)">{{ trans('texts.logout_and_delete') }}</button>
2017-03-24 12:51:24 +01:00
</div>
</div>
</div>
</div>