From 498d0af6a4298489aba979bef15cd7115d8001c5 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 23 Feb 2015 16:43:59 -0500 Subject: [PATCH] directives: add optional placeholder for markdown --- static/directives/repo-list-grid.html | 2 +- static/js/directives/ui/markdown-view.js | 6 ++++-- static/js/services/util-service.js | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/static/directives/repo-list-grid.html b/static/directives/repo-list-grid.html index 92c9b9b6d..52db92ab5 100644 --- a/static/directives/repo-list-grid.html +++ b/static/directives/repo-list-grid.html @@ -32,7 +32,7 @@ -
+
diff --git a/static/js/directives/ui/markdown-view.js b/static/js/directives/ui/markdown-view.js index 65f123f33..88bdbf5be 100644 --- a/static/js/directives/ui/markdown-view.js +++ b/static/js/directives/ui/markdown-view.js @@ -10,12 +10,14 @@ angular.module('quay').directive('markdownView', function () { restrict: 'C', scope: { 'content': '=content', - 'firstLineOnly': '=firstLineOnly' + 'firstLineOnly': '=firstLineOnly', + 'placeholderNeeded': '=placeholderNeeded' }, controller: function($scope, $element, $sce, UtilService) { $scope.getMarkedDown = function(content, firstLineOnly) { if (firstLineOnly) { - return $sce.trustAsHtml(UtilService.getFirstMarkdownLineAsText(content)); + console.log($scope.placeholderNeeded); + return $sce.trustAsHtml(UtilService.getFirstMarkdownLineAsText(content, $scope.placeholderNeeded)); } return $sce.trustAsHtml(UtilService.getMarkedDown(content)); }; diff --git a/static/js/services/util-service.js b/static/js/services/util-service.js index 195097b08..64956f1b8 100644 --- a/static/js/services/util-service.js +++ b/static/js/services/util-service.js @@ -10,11 +10,16 @@ angular.module('quay').factory('UtilService', ['$sanitize', function($sanitize) }; utilService.getMarkedDown = function(string) { - return Markdown.getSanitizingConverter().makeHtml(string || ''); + return html = Markdown.getSanitizingConverter().makeHtml(string || ''); }; - utilService.getFirstMarkdownLineAsText = function(commentString) { - if (!commentString) { return ''; } + utilService.getFirstMarkdownLineAsText = function(commentString, placeholderNeeded) { + if (!commentString) { + if (placeholderNeeded) { + return '

placeholder

'; + } + return ''; + } var lines = commentString.split('\n'); var MARKDOWN_CHARS = {