forked from Archives/Athou_commafeed
modify settings only when saving
This commit is contained in:
@@ -346,6 +346,9 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
|
||||
|
||||
module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
|
||||
$scope.settingsService = SettingsService;
|
||||
$scope.$watch('settingsService.settings', function(value) {
|
||||
$scope.settings = angular.copy(value);
|
||||
});
|
||||
$scope.codeMirrorConfig = {
|
||||
mode : 'css',
|
||||
lineNumbers : true
|
||||
@@ -356,8 +359,9 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
|
||||
});
|
||||
};
|
||||
$scope.save = function() {
|
||||
SettingsService.settings = $scope.settings;
|
||||
SettingsService.save(function() {
|
||||
$location.path('/');
|
||||
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -2,27 +2,29 @@
|
||||
<div class="page-header">
|
||||
<h1>Settings</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="active"><a href="#general" data-toggle="pill">General</a></li>
|
||||
<li><a href="#custom-css" data-toggle="pill" ng-click="refreshCodemirror=!refreshCodemirror">Custom CSS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="general" style="height: 500px">
|
||||
Placeholder for general settings
|
||||
</div>
|
||||
<div class="tab-pane" id="custom-css">
|
||||
<textarea ui-codemirror="codeMirrorConfig" ng-model="settingsService.settings.customCss" ui-refresh="refreshCodemirror">
|
||||
</textarea>
|
||||
<form name="settingsForm" ng-submit="save()">
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="active"><a href="#general" data-toggle="pill">General</a></li>
|
||||
<li><a href="#custom-css" data-toggle="pill" ng-click="refreshCodemirror=!refreshCodemirror">Custom CSS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="general" style="height: 500px">
|
||||
Placeholder for general settings
|
||||
</div>
|
||||
<div class="tab-pane" id="custom-css">
|
||||
<textarea ui-codemirror="codeMirrorConfig" ng-model="settings.customCss" ui-refresh="refreshCodemirror">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-primary" ng-click="save()">Save</button>
|
||||
<button type="button" class="btn" ng-click="cancel()">Cancel</button>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
<button type="button" class="btn" ng-click="cancel()">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user