Skip to content

Commit

Permalink
Logik implementiert, dass die Werbung leer geschalten wird, wenn zur …
Browse files Browse the repository at this point in the history
…nächsten Seite gewechselt wurde. #45
  • Loading branch information
DracoBlue committed Jan 17, 2016
1 parent 8b4588c commit 9b72374
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>Freie Räume</h2>

<div class="container current-content">

<div class="row js_page jsb_ jsb_views/AdView" data-jsb="">
<div class="row js_page jsb_ jsb_views/AdView" id="ad-view" data-jsb="">
</div>

<div class="row js_page jsb_ jsb_views/TweetsView tweets" data-jsb="">
Expand Down
2 changes: 1 addition & 1 deletion split.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

<div class="container current-content">

<div class="row js_page jsb_ jsb_views/AdView" data-jsb="">
<div class="row js_page jsb_ jsb_views/AdView" id="ad-view" data-jsb="">
</div>

<div class="row js_page jsb_ jsb_views/NewsCollectionView" data-jsb="">
Expand Down
18 changes: 8 additions & 10 deletions static/js/views/AdView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ define('views/AdView', ["jquery", "config", "views/BaseView"], function ($, conf

if (config.get('ads').length == 0) {
$(this.el).addClass('is-hidden');
} else {
this.render();

setInterval(function() {
that.currentIndex++;
if (that.currentIndex >= config.get('ads').length) {
that.currentIndex = 0;
}
that.render();
}, config.get('ads_update_frequency') * 1000);
}

jsb.whenFired('PageSwitcherView::SHOW_PAGE', function(values) {
if (values.id === 'ad-view') {
that.render();
} else {
$(that.el).empty();
}
});
},

render: function() {
Expand Down
14 changes: 12 additions & 2 deletions static/js/views/PageSwitcherView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define('views/PageSwitcherView', ['jquery', "config", "moment", "views/BaseView"
$('.js_app_title').text('Campus ' + config.get('campus') + ', Haus ' + config.get('house'));
document.title = $('.js_app_title').text();

$(this.pages[this.current_page]).show();
this.showCurrentPage();

if (config.get('force_page') === null) {
setInterval(function() {
Expand All @@ -24,6 +24,16 @@ define('views/PageSwitcherView', ['jquery', "config", "moment", "views/BaseView"
}
},

showCurrentPage: function() {
$(this.pages[this.current_page]).show();

if ($(this.pages[this.current_page]).attr('id')) {
jsb.fireEvent('PageSwitcherView::SHOW_PAGE', {"id": $(this.pages[this.current_page]).attr('id')});
} else {
jsb.fireEvent('PageSwitcherView::SHOW_PAGE', {});
}
},

showNextPage: function() {
this.new_page_in--;
if (this.new_page_in == -1)
Expand All @@ -45,7 +55,7 @@ define('views/PageSwitcherView', ['jquery', "config", "moment", "views/BaseView"

console.log('NEXT PAGE after', initial_current_page, 'is now', this.current_page);

$(this.pages[this.current_page]).show();
this.showCurrentPage();

this.new_page_in = this.max_progress;
}
Expand Down

0 comments on commit 9b72374

Please sign in to comment.