First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,43 @@
angular
.module('app', ['unsavedChanges', 'ngRoute'])
.config(['$routeProvider', 'unsavedWarningsConfigProvider',
function($routeProvider, unsavedWarningsConfigProvider) {
$routeProvider
.when('/page1', {
templateUrl: 'page1.html'
})
.when('/page2', {
templateUrl: 'page2.html'
})
.otherwise({
redirectTo: '/page1'
});
// We can turn on logging through this provider method
// We uncomment out the below line in order to watch for angular-ui router events
// rather than standard Angular router events. The default event is $locationChangeStart
//unsavedWarningsConfigProvider.setRouteEventToWatchFor('$stateChangeStart');
// We uncomment out the below line in order to change the navigate message
//unsavedWarningsConfigProvider.setNavigateMessage('Leaving now will lose your unsaved work');
// We uncomment out the below line in order to change the refresh message
//unsavedWarningsConfigProvider.setReloadMessage('Refreshing now will lose your unsaved work');
// We use the below line in order to override the default and tell unsavedWarning to NOT
// use the awesome angular-translate library for some reason
unsavedWarningsConfigProvider.useTranslateService = false;
}
])
.controller('demoCtrl', function($scope) {
$scope.user = {};
$scope.demoFormSubmit = function() {
$scope.message = 'Form Saved';
//$scope.user = {};
}
$scope.clearChanges = function() {
$scope.user = {};
}
});

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html class="no-js" ng-app="app">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Angular Unsaved Changes</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="../src/unsavedChanges.js"></script>
<script src="app.js"></script>
</head>
<body>
<a id="page1" href="#/page1">Page 1</a>
<a id="page2" href="#/page2">Page 2</a>
<div ng-view></div>
</body>
</html>

View file

@ -0,0 +1,17 @@
<h1>Page 1</h1>
<div ng-controller="demoCtrl">
<form name="demoForm" ng-submit="demoFormSubmit()" novalidate unsaved-warning-form>
<input id="userName" type="text" name="name" lazy-model="user.name" required>
<input type="text" name="email" lazy-model="user.email">
<button id="submitForm" type="submit">Submit Form</button>
<button id="clear" type="reset" unsaved-warning-clear ng-disabled="demoForm.$pristine">Disregard Changes</button>
</form>
<pre>
{{user | json}}
</pre>
<p>Is Form Dirty?: {{demoForm.$dirty}}</p>
<p ng-show="message">Message: {{message}}</p>
</div>
<input ng-model="outsideForm">

View file

@ -0,0 +1,33 @@
<div>
<h1>Page 2</h1>
<div ng-controller="demoCtrl">
<form name="demoForm1" ng-submit="demoFormSubmit()" novalidate unsaved-warning-form>
<legend>Form 1</legend>
<input type="text" name="name" ng-model="user1.name">
<button type="submit">Submit Form</button>
<button id="clear" type="button" unsaved-warning-clear>Disregard Form 1 Changes</button>
</form>
<p>Is Form 1 Dirty?: {{demoForm1.$dirty}}</p>
<p ng-show="message">Message: {{message}}</p>
</div>
<div ng-controller="demoCtrl">
<form name="demoForm2" ng-submit="demoFormSubmit()" novalidate unsaved-warning-form>
<legend>Form 2</legend>
<input type="text" name="name" ng-model="user2.name">
<button type="submit">Submit Form</button>
</form>
<p>Is Form 2 Dirty?: {{demoForm2.$dirty}}</p>
<p ng-show="message">Message: {{message}}</p>
</div>
<div ng-controller="demoCtrl">
<form name="demoForm3" ng-submit="demoFormSubmit()" novalidate unsaved-warning-form>
<legend>Form 3</legend>
<input type="text" name="name" ng-model="user3.name">
<button type="submit">Submit Form</button>
<button type="button" unsaved-warning-clear>Disregard Form 3 Changes</button>
</form>
<p>Is Form 3 Dirty?: {{demoForm3.$dirty}}</p>
<p ng-show="message">Message: {{message}}</p>
</div>
</div>