Fixed JSLint errors

This commit is contained in:
Henry
2015-12-08 14:51:25 -08:00
parent 4fbf547bfc
commit 4b7287e51e
7 changed files with 46 additions and 50 deletions

View File

@@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
/*global define,Promise, confirm*/
/**
* This bundle implements Browse mode.
@@ -52,6 +52,13 @@ define(
($route.current.params.ids || DEFAULT_PATH).split("/")
);
function isDirty(){
var editorCapability = $scope.navigatedObject &&
$scope.navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges;
}
function updateRoute(domainObject) {
var priorRoute = $route.current,
// Act as if params HADN'T changed to avoid page reload
@@ -72,6 +79,15 @@ define(
}
// Callback for updating the in-scope reference to the object
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
}
function setSelectedObject(domainObject) {
if (domainObject !== $scope.navigatedObject && isDirty() && !confirm(CONFIRM_MSG)) {
$scope.treeModel.selectedObject = $scope.navigatedObject;
@@ -83,15 +99,6 @@ define(
}
}
// Callback for updating the in-scope reference to the object
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
}
function navigateTo(domainObject) {
// Check if an object has been navigated-to already...
@@ -159,18 +166,11 @@ define(
selectedObject: navigationService.getNavigation()
};
function isDirty(){
var editorCapability = $scope.navigatedObject &&
$scope.navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges;
}
$scope.beforeUnloadWarning = function() {
return isDirty() ?
"Unsaved changes will be lost if you leave this page." :
undefined;
}
};
// Listen for changes in navigation state.
navigationService.addListener(setNavigation);

View File

@@ -78,11 +78,11 @@ define(
$scope.cancelEditing = function() {
navigationService.setNavigation($scope.domainObject.getDomainObject());
}
};
$scope.doAction = function (action){
$scope[action] && $scope[action]();
}
return $scope[action] && $scope[action]();
};
}