Skip to content

Commit

Permalink
setup for issue #76
Browse files Browse the repository at this point in the history
something in urls.py must be wrong, I guess
  • Loading branch information
David Bauer committed Aug 18, 2014
1 parent 0669c84 commit d462e09
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/static/js/controllers/TimelineEmbedCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

var TimelineEmbedCtrl = function($scope, Prediction, Categories, Sources, $rootScope, $location, $filter, $cookies, $timeout, FiltersReset) {
$scope.filters = { page_size : 200 };
angular.extend(this, new HomeCtrl($scope, Prediction, Categories, Sources, $rootScope, $location, $filter, $cookies, $timeout, FiltersReset));

$scope.changeLanguage = function(lang) {
$scope._lang = $scope.language = lang;
$location.path('/' + $scope.language + '/timeline/embed');
$scope.translateTo($scope.language);
$scope.update(false);
};

$scope.spinner = true;

$scope.$watch(function() { return $scope.predictions }, function() {
if ($scope.predictions.length > 0 && !$scope.hideMoreButton) {
$scope.spinner = true;
$scope.update(false);
}
}, true);
};

angular.module('dystopia-tracker').controller('TimelineEmbedCtrl', ['$scope', 'Prediction', 'Categories', 'Sources', '$rootScope', '$location', '$filter', '$cookies', '$timeout', 'Filters', TimelineCtrl]);

// it's the end of the code as we know it
1 change: 1 addition & 0 deletions app/templates/home.dj.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<script type="text/javascript" src="{{ STATIC_URL }}js/controllers/SubmitPredictionCtrl.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/controllers/SubmitRealisationCtrl.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/controllers/TimelineCtrl.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/controllers/TimelineEmbedCtrl.js"></script>

<!-- Filters -->
<script type="text/javascript" src="{{ STATIC_URL }}js/filters.js"></script>
Expand Down
95 changes: 95 additions & 0 deletions app/templates/partials/timeline-embed.dj.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<div id="filters" ng-class="showFilters ? 'visible-mobile' : '' ">

<form id="searchform" ng-submit="update(true)" class="input-group">

<div class="input-group-btn">
<div class="dropdown">
<button type="button" class="btn btn-default dropdown-toggle">
<span class="hidden-xs">
<span ng-if="filters.category != ''">
[[ getCategoryTitle( getCategory(filters.category) ) | translate ]]
</span>
<span ng-if="filters.category == ''">
[[ 'All categories' | translate ]]
</span>
<span class="caret"></span>
</span>
<span class="visible-xs">
<i class="glyphicon glyphicon-filter"></i>
</span>
</button>
<ul class="dropdown-menu categories">
<li ng-class="filters.category == '' ? 'active' : ''">
<a ng-click="filters.category = ''; update(true)">
[['All categories' | translate ]]
</a>
</li>
<li class="color-[[category.color]]" ng-repeat="category in categories" ng-class="filters.category == category.id ? 'active' : ''">
<a ng-click="filters.category = category.id; update(true)">
[[getCategoryTitle(category)]]
</a>
</li>
</ul>
</div>

<div class="dropdown hidden-xs">
<button type="button" class="btn btn-default dropdown-toggle">
<span ng-if="filters.source__type != ''">
[[ sources[filters.source__type] | translate ]]
</span>
<span ng-if="filters.source__type == ''">
[['All sources' | translate ]]
</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li ng-class="filters.source__type == '' ? 'active' : ''">
<a ng-click="filters.source__type = ''; update(true)">
[['All sources' | translate ]]
</a>
</li>
<li ng-repeat="key in sourcesKey" ng-init="source = sources[key]" ng-class="filters.source__type == key ? 'active' : ''">
<a ng-click="filters.source__type = key; update(true)">
[[ source | translate ]]
</a>
</li>
</ul>
</div>
</div>

<input type="text" class="sfTypeahead" options="typeahedOptions" datasets="typeaheadData" placeholder="[['Search for a title' | translate ]]" autofocus ng-model="filters.title">

</form>

</div>

<div id="toggle-filters" ng-init="showFilters = false">
<i class="glyphicon glyphicon-search" ng-click="showFilters = !showFilters"></i>
</div>

<div class="btn-group langswitch hidden-xs">
<button type="button" ng-click="changeLanguage('E')" class="btn btn-default btn-sm" ng-class="isActive('E')">
En<span class="hidden-xs">glish</span>
</button>
<button type="button" ng-click="changeLanguage('D')" class="btn btn-default btn-sm" ng-class="isActive('D')">
De<span class="hidden-xs">utsch</span>
</button>
</div>

<div id="content" class="row latest">
<div class='visible-xs alert alert-welcome alert-dismissable fade in out' style='margin:0 10px 10px 10px'>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<p>[['For the best experience of this visualisation, a larger screen is advised.' | translate]]</p>
</div>
<div id="loading" ng-if="spinner">
<div class="spinner"></div>
Loading...
</div>
<timeline ng-if="!spinner && !noContent"></timeline>
<div ng-if="noContent" class="col-sm-6 col-md-4 col-sm-offset-3 col-md-offset-4">
<p ng-bind-template="[['Bummer, no content' | translate ]]"></p>
<a ng-href="[[language]]/submit/prediction" type="button" class="btn btn-primary btn-lg">
<span class="glyphicon glyphicon-plus"></span> [['Add a prediction' | translate]]
</a>
</div>
</div> <!-- content -->
2 changes: 2 additions & 0 deletions app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

url(r'^[A-Z]{1}/timeline/?$', 'app.views.home'),

url(r'^[A-Z]{1}/timeline/embed$', 'app.views.partial', name='timeline-embed'),

url(r'^api/', include('app.api.urls')),

url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
Expand Down

0 comments on commit d462e09

Please sign in to comment.