Commit 7dbbcc8f authored by alexandre's avatar alexandre

BaseView (should we call it RootView?)

parent e5732751
......@@ -7,11 +7,14 @@ window.W = window.W || {};
'use strict';
W.ScoreApp = new Backbone.Marionette.Application({
region: 'main',
region: 'body',
onStart: function(options) {
this.showView(new W.BaseView());
var router = new W.ScoreRouter({application: this});
/** Starts the URL handling framework */
Backbone.history.start({
pushState: true,
......
......@@ -8,22 +8,22 @@ window.W = window.W || {};
W.ScoreController = Backbone.Marionette.Object.extend({
home: function () {
var app = this.getOption('application');
var baseView = this.getOption('application').getView();
var view = new W.HomeView();
app.showView(view);
baseView.showChildView('main', view);
},
about: function () {
var app = this.getOption('application');
var baseView = this.getOption('application').getView();
var view = new W.AboutView();
app.showView(view);
baseView.showChildView('main', view);
},
scoreList: function () {
var app = this.getOption('application');
var baseView = this.getOption('application').getView();
var view = new W.ScoreListView();
app.showView(view);
baseView.showChildView('main', view);
},
scoreDetail: function (id) {
var app = this.getOption('application');
var baseView = this.getOption('application').getView();
// Backbone relational refuse to instantiate more than one model
// with the same id
......@@ -34,7 +34,7 @@ window.W = window.W || {};
// Attach the views when the model is successfully fetched
scoreModel.fetch({
success: (function () {
app.showView(myScoreDetailView);
baseView.showChildView('main', myScoreDetailView);
}).bind(this)
});
}
......
......@@ -1145,7 +1145,7 @@ window.W = window.W || {};
title: newModel.get("title") + " (copy)",
}, {
success: function () {
Backbone.history.navigate('/' + newModel.id, {
Backbone.history.navigate('/partitions/' + newModel.id, {
trigger: true
});
}
......@@ -1476,4 +1476,27 @@ window.W = window.W || {};
});
}
});
W.HeaderView = Backbone.Marionette.View.extend({
template: '#header-template',
});
/**
* Base view, the mother of all views
*/
W.BaseView = Backbone.Marionette.View.extend({
template: '#base-template',
regions: {
header: 'header',
main: 'main'
},
onRender: function () {
this.showChildView('header', new W.HeaderView());
}
});
})();
......@@ -10,6 +10,14 @@
<link rel="stylesheet" href="{% static 'playground/vendors/reset.css' %}">
<link rel="stylesheet" href="{% static 'playground/css/styles.css' %}">
<script id="base-template" type="text/template">
{% include "playground/underscore/base.mtpl" %}
</script>
<script id="header-template" type="text/template">
{% include "playground/underscore/header.mtpl" %}
</script>
<script id="home-template" type="text/template">
{% include "playground/underscore/home.mtpl" %}
</script>
......@@ -85,40 +93,6 @@
</head>
<body>
<!-- • FR/EN -->
<!-- • ateliers et présentations (agenda) -->
<!-- • texte de présentation (+ lien vers site W) -->
<!-- • “créer une partition W” > MODE EDIT -->
<!-- • “lire des partitions W existantes” > MODE LECTURE -->
<!-- • Aide -->
<!-- • crédits -->
<header>
<div class="logo">
<h1>Organon</h1>
<h2>Un logiciel pour noter l’action performée, développé par W</h2>
</div>
<nav>
<ul>
<li><a href="/">Accueil</a></li>
<li><a href="/apropos/">À propos</a></li> <!-- + crédits -->
<li><a href="/partitions/">Partitions</a></li>
<li><a href="#">Aide</a></li>
{% if user.is_authenticated %}
<li>Bienvenue {{ user.username }} <a href="{% url 'auth_login' %}">Se déconnecter</a></li>
<li><a href="#">Mes partitions</a></li>
{% else %}
<li><a href="{% url 'auth_login' %}">Se connecter</a></li>
<li><a href="{% url 'registration_register' %}">S'inscrire</a></li>
{% endif %}
</ul>
</nav>
</header>
<main></main>
<script src="{% static 'playground/vendors/jquery.min.js' %}"></script>
<script src="{% static 'playground/vendors/underscore-min.js' %}"></script>
<script src="{% static 'playground/vendors/backbone-min.js' %}"></script>
......
<div id="score" tabindex="1"></div>
<header></header>
<main></main>
<!-- • FR/EN -->
<!-- • ateliers et présentations (agenda) -->
<!-- • texte de présentation (+ lien vers site W) -->
<!-- • “créer une partition W” > MODE EDIT -->
<!-- • “lire des partitions W existantes” > MODE LECTURE -->
<!-- • Aide -->
<!-- • crédits -->
<div class="logo">
<h1>Organon</h1>
<h2>Un logiciel pour noter l’action performée, développé par W</h2>
</div>
<nav>
<ul>
<li><a href="/">Accueil</a></li>
<li><a href="/apropos/">À propos</a></li> <!-- + crédits -->
<li><a href="/partitions/">Partitions</a></li>
<li><a href="#">Aide</a></li>
{% if user.is_authenticated %}
<li>Bienvenue {{ user.username }} <a href="{% url 'auth_login' %}">Se déconnecter</a></li>
<li><a href="#">Mes partitions</a></li>
{% else %}
<li><a href="{% url 'auth_login' %}">Se connecter</a></li>
<li><a href="{% url 'registration_register' %}">S'inscrire</a></li>
{% endif %}
</ul>
</nav>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment