Enabled support for applying color settings in new colors tab

This commit is contained in:
Siteshwar Vashisht 2013-10-12 23:55:37 +05:30
parent 044ff5e055
commit e4029d00b6
2 changed files with 28 additions and 21 deletions

View file

@ -21,7 +21,7 @@
<br> <br>
<span data-ng-style="{ 'color': selectedColorScheme.command}" ng-click="selectColorSetting('command')">Th</span><span data-ng-style="{ 'color': selectedColorScheme.autosuggestion }" ng-click="selectColorSetting('autosuggestion')"><span class="fake_cursor"><span style="visibility: hidden">i</span></span>s is an autosuggestion</span> <span data-ng-style="{ 'color': selectedColorScheme.command}" ng-click="selectColorSetting('command')">Th</span><span data-ng-style="{ 'color': selectedColorScheme.autosuggestion }" ng-click="selectColorSetting('autosuggestion')"><span class="fake_cursor"><span style="visibility: hidden">i</span></span>s is an autosuggestion</span>
<span class="save_button" style="position: absolute; right: 5px; bottom: 5px;" data-ng-style="{'color': text_color_for_color(selectedColorScheme.preferred_background || 'white')}">Apply</span> <span class="save_button" style="position: absolute; right: 5px; bottom: 5px;" data-ng-style="{'color': text_color_for_color(selectedColorScheme.preferred_background || 'white')}" ng-show="showSaveButton" ng-click="setTheme()">Apply</span>
</div> </div>

View file

@ -137,19 +137,6 @@ webconfig.controller("colorsController", function($scope, $http) {
*/ */
webconfig.controller("newColorsController", function($scope, $http) { webconfig.controller("newColorsController", function($scope, $http) {
$scope.changeSelectedColorScheme= function(newScheme) {
$scope.selectedColorScheme = newScheme;
if ($scope.selectedColorScheme.preferred_background) {
$scope.terminalBackgroundColor = $scope.selectedColorScheme.preferred_background;
}
$scope.selectedColorSetting = 'command';
$scope.colorArraysArray = $scope.getColorArraysArray();
}
$scope.changeTerminalBackgroundColor = function(color) {
$scope.terminalBackgroundColor = color;
}
$scope.term256Colors = [ //247 $scope.term256Colors = [ //247
"ffd7d7", "ffd7d7",
"d7afaf", "d7afaf",
@ -438,6 +425,21 @@ webconfig.controller("newColorsController", function($scope, $http) {
return adjust_lightness(color_str, compute_constrast); return adjust_lightness(color_str, compute_constrast);
} }
$scope.changeSelectedColorScheme= function(newScheme) {
$scope.selectedColorScheme = newScheme;
if ($scope.selectedColorScheme.preferred_background) {
$scope.terminalBackgroundColor = $scope.selectedColorScheme.preferred_background;
}
$scope.selectedColorSetting = 'command';
$scope.colorArraysArray = $scope.getColorArraysArray();
//TODO: Save button should be shown only when colors are changed
$scope.showSaveButton = true;
}
$scope.changeTerminalBackgroundColor = function(color) {
$scope.terminalBackgroundColor = color;
}
$scope.getColorArraysArray = function() { $scope.getColorArraysArray = function() {
var result = null; var result = null;
if ($scope.selectedColorScheme.colors.length > 0) if ($scope.selectedColorScheme.colors.length > 0)
@ -696,6 +698,18 @@ webconfig.controller("newColorsController", function($scope, $http) {
$scope.changeSelectedColorScheme($scope.color_schemes[0]); $scope.changeSelectedColorScheme($scope.color_schemes[0]);
$scope.color_settings = $scope.color_schemes.colors; $scope.color_settings = $scope.color_schemes.colors;
$scope.setTheme = function() {
var settingNames = ["autosuggestion", "command", "param", "redirection", "comment", "error", "escape", "operator", "quote", "end"];
for (name in settingNames) {
var postData = "what=" + settingNames[name] + "&color=" + $scope.selectedColorScheme[settingNames[name]] + "&background_color=&bold=&underline=";
$http.post("/set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
console.log(data);
})
}
};
range = function(start, end) { range = function(start, end) {
var result = []; var result = [];
@ -755,13 +769,6 @@ webconfig.controller("newColorsController", function($scope, $http) {
$scope.selectedCell = $scope.term256Colors.indexOf($scope.selectedColorConfig.color); $scope.selectedCell = $scope.term256Colors.indexOf($scope.selectedColorConfig.color);
})}; })};
$scope.setColor = function() {
var config = $scope.selectedColorConfig;
var postData = "what=" + config.name + "&color=" + config.color + "&background_color="+ config.background + "&bold=" + config.bold + "&underline=" + config.underline;
$http.post("/set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
console.log(data);
})
};
$scope.fetchColors(); $scope.fetchColors();
}); });