Sha256: c3e1a27ef56558b17102e7e459d15bb7f8f7f48b4c19ea3e452541701aae7277

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

var WidgetEditorCtrl = function WidgetEditorCtrl($scope, Widgets) {
  $scope.widgets = Widgets;

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

    var result = Widgets.add(name);

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

  $scope.edit = function(widget) {
    if ($scope.editing === widget || !widget.custom) {
      return $scope.editing = null;
    }

    $scope.editing = widget;
  };

  $scope.addAttr = function() {
    if ($scope.editing && $scope.newAttr.length) {
      $scope.editing.attrs.push($scope.newAttr);
    }

    $scope.newAttr = '';

    Widgets.save();
  };

  $scope.removeAttr = function(index) {
    if (!$scope.editing) {
      return;
    }

    $scope.editing.attrs.splice(index, 1);

    Widgets.save();
  };
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
robeaux-0.3.0 js/controllers/widget_editor_ctrl.js