Announcements for un registered users

This commit is contained in:
Josef Citrine 2016-11-12 14:28:40 +00:00
parent ec8b64f494
commit 80bb95a76d
4 changed files with 44 additions and 8 deletions

View file

@ -1,4 +1,8 @@
<div class="dashboard stretch-to-bottom">
<section class="announce-wrapper" ng-class="announceWrapperClass">
<div id="announcement" ng-show="announcement != null" ng-class="announcementClass"></div>
</section>
<section class="recent-tracks">
<h1>
<a href="/tracks"><i class="fa fa-music"></i> see more</a>

View file

@ -3,9 +3,7 @@
<p marked="announcement.text_content"></p>
</div>
<div class="announce-actions">
<span ng-repeat="link in announcement.links">
<a ng-href="{{ ::link.url }}" target="_blank">{{ ::link.title }}</a>
</span>
<a ng-repeat="link in announcement.links" ng-href="{{ ::link.url }}" target="_blank">{{ ::link.title }}</a>
<a href="#" ng-click="announcement.dontShowAgain()">Don't show again</a>
</div>
<a href="#" class="dismiss-button" ng-click="announcement.dismiss()"><i class="fa fa-times"></i></a>

View file

@ -3,9 +3,7 @@
<p marked="announcement.text_content"></p>
</div>
<div class="announce-actions">
<span ng-repeat="link in announcement.links">
<a ng-href="{{ ::link.url }}" target="_blank">{{ ::link.title }}</a>
</span>
<a ng-repeat="link in announcement.links" ng-href="{{ ::link.url }}" target="_blank">{{ ::link.title }}</a>
<a href="#" ng-click="announcement.dontShowAgain()">Don't show again</a>
</div>
<a href="#" class="dismiss-button" ng-click="announcement.dismiss()"><i class="fa fa-times"></i></a>

View file

@ -20,14 +20,50 @@ window.pfm.preloaders['home'] = [
]
module.exports = angular.module('ponyfm').controller "home", [
'$scope', 'meta', 'dashboard'
($scope, meta, dashboard) ->
'$scope', 'meta', 'dashboard', '$http', 'announcements', '$compile'
($scope, meta, dashboard, $http, announcements, $compile) ->
meta.reset()
$scope.recentTracks = null
$scope.popularTracks = null
$scope.announcementClass = 'disabled'
$scope.announceWrapperClass = 'disabled'
$scope.loadAnnouncementTemplate = (url) ->
$http.get('/templates/' + url).success (templateContent) ->
compiledHtml = $compile(templateContent)($scope)
$('#announcement').append(compiledHtml)
dashboard.refresh().done (res) ->
$scope.recentTracks = res.recent_tracks
$scope.popularTracks = res.popular_tracks
announcements.refresh().done (ann) ->
$scope.announcement = ann
if $scope.announcement != null
if parseInt($.cookie('hide-announcement')) != parseInt($scope.announcement.id)
$scope.announcement.dismiss = () ->
$scope.announceWrapperClass = 'disabled'
$scope.announcement.dontShowAgain = () ->
$scope.announcement.dismiss()
$.cookie('hide-announcement', $scope.announcement.id)
switch $scope.announcement.announcement_type_id
when 1
$scope.announcementClass = "simple-announce " + $scope.announcement.css_class
$scope.announceWrapperClass = null
$scope.loadAnnouncementTemplate('partials/default-announcement.html')
when 2
$scope.announcementClass = "alert-announce " + $scope.announcement.css_class
$scope.announceWrapperClass = null
$scope.loadAnnouncementTemplate('partials/alert-announcement.html')
when 3
$scope.announcementClass = "serious-alert-announce " + $scope.announcement.css_class
$scope.announceWrapperClass = null
$scope.loadAnnouncementTemplate('partials/alert-announcement.html')
when 4
$scope.announcementClass = $scope.announcement.css_class
$scope.announceWrapperClass = null
$scope.loadAnnouncementTemplate($scope.announcement.template_url)
]