Move markdown parsing to notification service

This commit is contained in:
Blade Barringer
2015-06-01 17:49:27 -05:00
parent 39f363ec29
commit 3291062b31
2 changed files with 10 additions and 4 deletions

View File

@@ -3,8 +3,8 @@
/* Make user and settings available for everyone through root scope.
*/
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce','$window', '$filter',
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window, $filter) {
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce','$window',
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window) {
var user = User.user;
var initSticky = _.once(function(){
@@ -278,7 +278,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
case 'user': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.profile.name});break;
case 'party': msg = window.env.t('youCastParty', {spell: spell.text()});break;
}
Notification.text($filter("markdown")(msg));
Notification.markdown(msg);
User.sync();
});
}

View File

@@ -2,7 +2,7 @@
Set up "+1 Exp", "Level Up", etc notifications
*/
angular.module("habitrpg").factory("Notification",
[function() {
['$filter', function($filter) {
var stack_topright = {"dir1": "down", "dir2": "left", "spacing1": 15, "spacing2": 15, "firstpos1": 60};
function notify(html, type, icon) {
var notice = $.pnotify({
@@ -62,6 +62,12 @@ angular.module("habitrpg").factory("Notification",
notify(val, 'info');
}
},
markdown: function(val){
if (val) {
var parsed_markdown = $filter("markdown")(val);
notify(parsed_markdown, 'info');
}
},
lvl: function(){
notify(window.env.t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up');
},