Added warning when leaving page with unsaved work

This commit is contained in:
Hillel Coren 2014-04-17 17:48:56 +03:00
parent 016b21584e
commit a6bd9d30be
24 changed files with 5169 additions and 44 deletions

4
.gitignore vendored
View File

@ -12,12 +12,10 @@
/bootstrap/environment.php
/vendor
/.env.development.php
/composer.phar
/composer.lock
/.DS_Store
/Thumbs.db
/ninja.sublime-project
/ninja.sublime-workspace
/tests/_log
.idea
.project
.project

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddRememberToken extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function($table)
{
$table->string('remember_token', 100)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function($table)
{
$table->dropColumn('remember_token');
});
}
}

View File

@ -310,5 +310,7 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -310,4 +310,6 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -309,5 +309,7 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -309,6 +309,8 @@ return array(
'pro_plan_product' => 'Plan Pro',
'pro_plan_description' => 'Inscription d\'une durée d\'un an au Plan Pro d\'Invoice ninja',
'pro_plan_success' => 'Merci pour votre inscription ! Une fois la facture réglée, votre adhésion au Plan Pro commencera.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -310,5 +310,7 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -310,5 +310,7 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -298,5 +298,7 @@ return array(
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
'unsaved_changes' => 'You have unsaved changes',
);

View File

@ -17,6 +17,11 @@ class Utils
return $_SERVER['SERVER_NAME'] == 'www.invoiceninja.com';
}
public static function isNinjaDev()
{
return isset($_ENV['NINJA_DEV']) && $_ENV['NINJA_DEV'];
}
public static function basePath()
{
return substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') + 1);

View File

@ -138,4 +138,19 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
{
return $this->isPro() ? MAX_NUM_CLIENTS_PRO : MAX_NUM_CLIENTS;
}
public function getRememberToken()
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName()
{
return 'remember_token';
}
}

View File

@ -312,6 +312,4 @@ if (Auth::check() && Auth::user()->id === 1)
{
Auth::loginUsingId(1);
}
*/
//dd(Session::has(REQUESTED_PRO_PLAN));
*/

View File

@ -11,7 +11,7 @@
</style>
{{ Former::open_for_files()->addClass('col-md-10 col-md-offset-1')->rules(array(
{{ Former::open_for_files()->addClass('col-md-10 col-md-offset-1 warn-on-exit')->rules(array(
'name' => 'required',
'email' => 'email|required'
)); }}

View File

@ -3,7 +3,7 @@
@section('content')
@parent
{{ Former::open('company/import_export') }}
{{ Former::open('company/import_export')->addClass('warn-on-exit') }}
{{ Former::legend('import_clients') }}
@if ($headers)

View File

@ -3,7 +3,7 @@
@section('content')
@parent
{{ Former::open()->addClass('col-md-8 col-md-offset-2') }}
{{ Former::open()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
{{ Former::populate($account) }}
{{ Former::populateField('notify_sent', intval(Auth::user()->notify_sent)) }}
{{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }}

View File

@ -3,7 +3,7 @@
@section('content')
@parent
{{ Former::open()->addClass('col-md-8 col-md-offset-2') }}
{{ Former::open()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
{{ Former::populate($account) }}
{{ Former::legend('Payment Gateway') }}

View File

@ -9,7 +9,7 @@
<div class="row">
<!--<h3>{{ $title }} Client</h3>-->
{{ Former::open($url)->addClass('col-md-12 main_form')->method($method)->rules(array(
{{ Former::open($url)->addClass('col-md-12 warn-on-exit')->method($method)->rules(array(
'email' => 'email|required'
)); }}

View File

@ -8,7 +8,7 @@
@section('content')
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 main_form')->method($method)->rules(array(
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 warn-on-exit')->method($method)->rules(array(
'client' => 'required',
'amount' => 'required',
)); }}

View File

@ -48,7 +48,7 @@
var currency = currencies[i];
currencyMap[currency.id] = currency;
}
var NINJA = {};
var NINJA = NINJA || {};
NINJA.parseFloat = function(str) {
if (!str) return '';
str = (str+'').replace(/[^0-9\.\-]/g, '');
@ -319,7 +319,7 @@ Want something changed? We're {{ link_to('https://github.com/hillelcoren/invoice
</div>
@endif
@if (!Utils::isNinjaProd())
@if (!Utils::isNinjaProd() && !Utils::isNinjaDev())
<div class="container">{{ trans('texts.powered_by') }} <a href="https://www.invoiceninja.com/" target="_blank">InvoiceNinja.com</a></div>
@endif
@ -435,8 +435,7 @@ Want something changed? We're {{ link_to('https://github.com/hillelcoren/invoice
}
}
$(function()
{
$(function() {
$('#search').focus(function(){
if (!window.hasOwnProperty('searchData')) {
$.get('{{ URL::route('getSearchData') }}', function(data) {
@ -482,13 +481,6 @@ Want something changed? We're {{ link_to('https://github.com/hillelcoren/invoice
});
})
/*
$(window).on('beforeunload', function() {
return true;
});
$('form').submit(function() { $(window).off('beforeunload') });
$('a[rel!=ext]').click(function() { $(window).off('beforeunload') });
*/
@endif
@if (false && Session::has('message'))

View File

@ -16,7 +16,7 @@
</ol>
@endif
{{ Former::open($url)->method($method)->addClass('main_form')->rules(array(
{{ Former::open($url)->method($method)->addClass('warn-on-exit')->rules(array(
'client' => 'required',
'email' => 'required',
'product_key' => 'max:20',
@ -274,7 +274,7 @@
<iframe id="theFrame" style="display:none" frameborder="1" width="100%" height="1180"></iframe>
<canvas id="theCanvas" style="display:none;width:100%;border:solid 1px #CCCCCC;"></canvas>
@if (false && !Auth::user()->account->isPro())
@if (Utils::isNinjaDev() && !Auth::user()->account->isPro())
{{ trans('texts.pro_plan.remove_logo', ['link'=>'<a href="#" onclick="showProPlan()">'.trans('texts.pro_plan.remove_logo_link').'</a>']) }}
@endif
@ -443,9 +443,9 @@
<div style="background-color: #fff; padding-left: 16px; padding-right: 16px" id="proPlanDiv">
&nbsp;
{{-- trans('texts.') --}}
&nbsp;
</div>
</div>
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="proPlanWorking">

View File

@ -26,7 +26,7 @@
@else
{{ die('Error: Failed to find jQuery') }}
@endif
<script type="text/javascript">
window.onerror = function(e) {
try {
@ -52,20 +52,36 @@
<body>
@if (App::environment() == ENV_PRODUCTION && isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY'])
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
@if (App::environment() == ENV_PRODUCTION && isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY'])
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}');
ga('send', 'pageview');
</script>
@endif
ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}');
ga('send', 'pageview');
</script>
@endif
@yield('body')
<script type="text/javascript">
var NINJA = NINJA || {};
NINJA.formIsChanged = false;
$(function() {
$('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').on('change', function() {
NINJA.formIsChanged = true;
});
});
$(window).on('beforeunload', function() {
if (NINJA.formIsChanged) {
return "{{ trans('texts.unsaved_changes') }}";
}
});
//$('a[rel!=ext]').click(function() { $(window).off('beforeunload') });
</script>
</body>
</html>

View File

@ -8,7 +8,7 @@
@section('content')
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 main_form')->method($method)->rules(array(
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 warn-on-exit')->method($method)->rules(array(
'client' => 'required',
'invoice' => 'required',
'amount' => 'required',

View File

@ -41,16 +41,14 @@
<p class="blue-text">Co-Founder, CEO</p>
<p>Shalom has specialized in small business development for nearly 10 years. In addition to InvoiceNinja.com Shalom is CEO of a leading tour agency in Israel.</p>
<p><span class="social"><a href="https://twitter.com/shalomstark" target="_blank"><img src="images/twitter.svg" alt="Twitter"></a></span>
<span class="social"><a href="https://twitter.com/shalomstark" target="_blank"><img src="images/linkedin.svg" alt="LinkedIn"></a></span>
</p>
<p class="blue-text" style="margin-bottom: 2px;"><a href="http://shalomisraeltours.com/">shalomisraeltours.com</a></p>
<p class="blue-text"><a href="http://shalomholytours.com/" target="_blank">shalomholytours.com</a></p>
<p class="blue-text" style="margin-bottom: 2px;"><a href="http://shalomisraeltours.com/" target="_blank">shalomisraeltours.com</a></p>
</div>
<div class="col-md-3">
<img src="images/hillelcoren.jpg" alt="Hillel Coren" class="img-circle">
<h2>HILLEL COREN</h2>
<p class="blue-text">Co-Founder, CTO</p>
<p>Hillel has been developing enterprise applications for nearly 15 years. His open-source <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1721530">AutoComplete component</a> has been used by thousands of developers around the world.</p>
<p>Hillel has been developing enterprise applications for 15 years. His open-source <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1721530" target="_blank">AutoComplete</a> component has been used by thousands of developers around the world.</p>
<p><span class="social"><a href="https://twitter.com/hillelcoren" target="_blank"><img src="images/twitter.svg" alt="Twitter"></a></span>
<span class="social"><a href="http://www.linkedin.com/profile/view?id=105143214" target="_blank"><img src="images/linkedin.svg" alt="LinkedIn"></a></span>
</p>
@ -72,7 +70,7 @@
<img src="images/benjacobson.jpg" alt="Ben Jacobsen" class="img-circle">
<h2>BEN JACOBSON</h2>
<p class="blue-text">Marketing</p>
<p>A veteran digital marketer and content strategist, Ben specializes in building communities around brands that make business easier for freelancers, SMBs and micro-entrepreneurs. Ben issues electronic invoices like they were free.
<p>A veteran digital marketer and content strategist, Ben specializes in building communities around brands that make business easier for freelancers, SMBs and micro-entrepreneurs.
</p>
<p><span class="social"><a href="https://twitter.com/osbennn" target="_blank"><img src="images/twitter.svg" alt="Twitter"></a></span>
<span class="social"><a href="https://www.linkedin.com/pub/razi-kantorp/35/368/973" target="_blank"><img src="images/linkedin.svg" alt="LinkedIn"></a></span>

5055
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff