Sha256: 383fbbd4ec94de678a7d6f6c4e990d45b1d495138e54940daa4794da6b30be4c

Contents?: true

Size: 907 Bytes

Versions: 4

Compression:

Stored size: 907 Bytes

Contents

var ThemesCtrl = function ThemesCtrl($scope, Themes) {
  $scope.themes = Themes;

  // save when a theme is selected
  $scope.$watch('themes.active', function() {
    // watch for corner case where 'themes.active' update was causing themes to
    // be saved as undefined
    if (Themes.list) { Themes.save(); }
  });

  // selecting a theme for editing
  $scope.edit = function(theme) {
    if ($scope.editing === theme || !theme.custom) {
      return $scope.editing = null;
    }

    $scope.editing = theme;
  };

  // add a new theme
  $scope.add = function(name) {
    if (!name || name === '') { return false; }

    var result = Themes.add(name);
    if (result) {
      $scope.edit(result);
      $scope.name = '';
    }
  };

  // remove an existing theme
  $scope.remove = function(name) {
    if ($scope.editing === Themes.find(name)) { $scope.editing = null; }
    Themes.remove(name);
  };
};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
robeaux-0.3.0 js/controllers/themes_ctrl.js
robeaux-0.2.0 js/controllers/themes_ctrl.js
robeaux-0.1.1 js/controllers/themes_ctrl.js
robeaux-0.1.0 js/controllers/themes_ctrl.js