149 lines
4.8 KiB
JavaScript
149 lines
4.8 KiB
JavaScript
define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer'], function (m, _ , util, resultParser, topNavBar, footer) {
|
|
var mainPageLogo = {};
|
|
|
|
mainPageLogo.view = function(){
|
|
return m('div.uk-grid.uk-hidden-small', [
|
|
m('div.uk-large-1-3.uk-medium-2-3.uk-container-center', [
|
|
m('div.uk-cover-background', {style: 'height: 500px; width: 500px; background-size: 500px; background-image: url(images/phenix_logo.png);'})
|
|
])
|
|
]);
|
|
};
|
|
|
|
var mainPageNews = {};
|
|
|
|
mainPageNews.view = function(){
|
|
return m('div.uk-panel.uk-panel-box',[
|
|
m('div.uk-panel-badge.uk-badge', [
|
|
m('i.fa.fa-newspaper-o')
|
|
]),
|
|
m('h3.uk-panel-title', 'Nouvelles'),
|
|
m('p', util.loremIpsum())
|
|
]);
|
|
};
|
|
|
|
var nextGameDaySchedule = {};
|
|
|
|
nextGameDaySchedule.controller = function(){
|
|
var games = m.prop([]);
|
|
return m.request({method: "GET", url: "api/resultats.json"})
|
|
.then(games)
|
|
.then(resultParser.getNightGames)
|
|
.then(function(nightGames){
|
|
return nightGames[0].games;
|
|
});
|
|
};
|
|
|
|
nextGameDaySchedule._getTableHead = function(){
|
|
return m('thead', m('tr', [
|
|
m('td', 'Date'),
|
|
m('td', 'Heure'),
|
|
m('td', 'Visiteur'),
|
|
m('td', 'Receveur')
|
|
]));
|
|
};
|
|
|
|
nextGameDaySchedule._getGamesRow = function(game){
|
|
return m('tr', [
|
|
m('td', util.formatDate(game.jsDate)),
|
|
m('td', game.time),
|
|
m('td', game.away),
|
|
m('td', game.home)
|
|
]);
|
|
};
|
|
|
|
nextGameDaySchedule._getGamesRows = function(games){
|
|
return _.map(games(), nextGameDaySchedule._getGamesRow);
|
|
};
|
|
|
|
nextGameDaySchedule.view = function(games){
|
|
return m('table.uk-table.uk-table-hover.uk-table-striped.uk-table-condensed',[
|
|
nextGameDaySchedule._getTableHead(),
|
|
m('tbody',
|
|
nextGameDaySchedule._getGamesRows(games)
|
|
)]);
|
|
};
|
|
|
|
var mainPageSchedule = {};
|
|
|
|
mainPageSchedule.view = function(){
|
|
return m('div.uk-panel.uk-panel-box',[
|
|
m('div.uk-panel-badge.uk-badge', m('i.fa.fa-clock-o')),
|
|
m('h3.uk-panel-title', 'Horaire'),
|
|
m.component(nextGameDaySchedule)
|
|
]);
|
|
};
|
|
|
|
var mainMap = {};
|
|
|
|
mainMap.getMap = function(){
|
|
var iframeUrl = "//www.openstreetmap.org/export/embed.html?bbox=-73.55889558792114%2C45.53089890181621%2C-73.55181455612183%2C45.53426212742867&layer=mapnik";
|
|
var externalLink = "http://www.openstreetmap.org/#map=18/45.53258/-73.55536";
|
|
var iframeParams = {
|
|
style: {border: '1px solid black', 'min-height': '300px'},
|
|
width: '100%',
|
|
height: '100%',
|
|
frameborder: 0,
|
|
scrolling: 'no',
|
|
marginheight: 0,
|
|
src: iframeUrl
|
|
};
|
|
return [
|
|
m('iframe', iframeParams),
|
|
m('br'),
|
|
m('small', m('a', {href: externalLink}, 'Voir la carte'))
|
|
];
|
|
};
|
|
|
|
mainMap.view = function(){
|
|
return m('div.uk-panel.uk-panel-box',[
|
|
m('div.uk-panel-badge.uk-badge', [
|
|
m('i.fa.fa-map-o')
|
|
]),
|
|
m('h3.uk-panel-title', 'Parc Walter-Stewart'),
|
|
mainMap.getMap()
|
|
]);
|
|
};
|
|
|
|
var mainPageBottom = {};
|
|
|
|
mainPageBottom.regularSizeView = function(){
|
|
return m('div.uk-grid.uk-hidden-small.uk-grid-match', [
|
|
m('div.uk-width-large-1-5.uk-hidden-medium'),
|
|
m('div.uk-width-large-1-5.uk-width-medium-1-3', m.component(mainPageNews)),
|
|
m('div.uk-width-large-1-5.uk-width-medium-1-3', m.component(mainPageSchedule)),
|
|
m('div.uk-width-large-1-5.uk-width-medium-1-3', m.component(mainMap))
|
|
]);
|
|
};
|
|
|
|
mainPageBottom.smallSizeView = function(){
|
|
return m('div.uk-visible-small',
|
|
[
|
|
m('div.uk-grid', m('div.uk-width-small-1-1', m.component(mainPageNews))),
|
|
m('div.uk-grid', m('div.uk-width-small-1-1', m.component(mainPageSchedule))),
|
|
m('div.uk-grid', m('div.uk-width-small-1-1', m.component(mainMap)))
|
|
]);
|
|
};
|
|
|
|
|
|
mainPageBottom.view = function(){
|
|
return m('div.uk-margin-top.uk-margin-bottom', [
|
|
mainPageBottom.regularSizeView(),
|
|
mainPageBottom.smallSizeView()
|
|
]);
|
|
|
|
};
|
|
|
|
var mainPage = {};
|
|
|
|
mainPage.view = function(){
|
|
return [
|
|
topNavBar.view(),
|
|
mainPageLogo.view(),
|
|
mainPageBottom.view(),
|
|
footer.view()
|
|
];
|
|
};
|
|
|
|
return mainPage;
|
|
});
|