Add a markdown input directive and convert both uses of the editor to the directive

This commit is contained in:
Joseph Schorr 2013-11-04 19:59:28 -05:00
parent 9beb627ab0
commit fd68564b3f
6 changed files with 86 additions and 71 deletions

View file

@ -248,23 +248,8 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
$scope.setTag($location.search().tag, false);
});
$scope.editDescription = function() {
if (!$scope.repo.can_write) { return; }
if (!$scope.markdownDescriptionEditor) {
var converter = Markdown.getSanitizingConverter();
var editor = new Markdown.Editor(converter, '-description');
editor.run();
$scope.markdownDescriptionEditor = editor;
}
$('#wmd-input-description')[0].value = $scope.repo.description;
$('#editModal').modal({});
};
$scope.saveDescription = function() {
$('#editModal').modal('hide');
$scope.repo.description = $('#wmd-input-description')[0].value;
$scope.updateForDescription = function(content) {
$scope.repo.description = content;
$scope.repo.put();
};
@ -1003,23 +988,6 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
});
};
$scope.editDescription = function() {
if (!$scope.markdownDescriptionEditor) {
var converter = Markdown.getSanitizingConverter();
var editor = new Markdown.Editor(converter, '-description');
editor.run();
$scope.markdownDescriptionEditor = editor;
}
$('#wmd-input-description')[0].value = $scope.repo.description;
$('#editModal').modal({});
};
$scope.saveDescription = function() {
$('#editModal').modal('hide');
$scope.repo.description = $('#wmd-input-description')[0].value;
};
$scope.createNewRepo = function() {
$('#repoName').popover('hide');