Skip to content

Commit

Permalink
- add popoverHtml to enable Markdown in Popovers
Browse files Browse the repository at this point in the history
- add markdown filter to get Task Notes as Markdown
  • Loading branch information
negue committed Oct 1, 2014
2 parents a595880 + c501652 commit b1a34a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions public/js/directives/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,34 @@ habitrpg.directive('hrpgSortTags', ['User', function(User) {
});
}
}]);

habitrpg
.directive( 'popoverHtmlPopup', ['$sce', function($sce) {
return {
restrict: 'EA',
replace: true,
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
link: function(scope, element, attrs) {
scope.$watch('content', function(value, oldValue) {
scope.unsafeContent = $sce.trustAsHtml(scope.content);
});
},
templateUrl: 'template/popover/popover-html.html'
};
}])
.directive( 'popoverHtml', [ '$compile', '$timeout', '$parse', '$window', '$tooltip',
function ( $compile, $timeout, $parse, $window, $tooltip ) {
return $tooltip( 'popoverHtml', 'popover', 'click' );
}
])
.run(["$templateCache", function($templateCache) {
$templateCache.put("template/popover/popover-html.html",
"<div class=\"popover {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
" <div class=\"arrow\"></div>\n" +
"\n" +
" <div class=\"popover-inner\">\n" +
" <h3 class=\"popover-title\" ng-bind=\"title\" ng-show=\"title\"></h3>\n" +
" <div class=\"popover-content\" ng-bind-html=\"unsafeContent\" style=\"word-wrap: break-word\"> </div>\n" +
" </div>\n" +
"</div>\n");
}]);
4 changes: 2 additions & 2 deletions views/shared/tasks/task.jade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s"]', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && castEnd(task, "task", $event)', ng-class='{"cast-target":spell}', popover-trigger='mouseenter', popover-placement='top', popover='{{task.notes}}')
li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s"]', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && castEnd(task, "task", $event)', ng-class='{"cast-target":spell}', popover-trigger='mouseenter', data-popover-html="{{task.notes | markdown}}", data-popover-placement="top")
// right-hand side control buttons
.task-meta-controls

Expand Down Expand Up @@ -147,7 +147,7 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s
input.option-content(type='text', ng-model='task.text', required, ng-disabled='task.challenge.id')

label.option-title=env.t('extraNotes')
textarea.option-content(rows='3', ng-model='task.notes')
textarea.option-content(rows='3', ng-model='task.notes', ng-model-options="{debounce: 1000}")

// if Habit, plus/minus command options
fieldset.option-group(ng-if='task.type=="habit" && !task.challenge.id')
Expand Down

0 comments on commit b1a34a2

Please sign in to comment.