Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes and improvments

  • Loading branch information...
commit 7431e2dbc2c03a4c72c29cc7649300daa73c9dab 1 parent 6e7a15d
Nicolas Pigelet authored
3  index.html
View
@@ -45,8 +45,7 @@
<h1>Title <small>subtitle</small></h1>
</div>
<div class="row main-content">
- Main Content
- </div><!-- /.row -->
+ </div>
</section>
<footer>
3  js/App.js
View
@@ -13,6 +13,9 @@ NS.Model = NS.Model || {};
/* VIEWS */
NS.View = NS.View || {};
+/* PAGES (instanciated views) */
+NS.Page = NS.Page || {};
+
/* DATA */
NS.Data = NS.Data || {};
35 js/app/Router.js
View
@@ -2,7 +2,6 @@
NS.Router = Backbone.Router.extend({
isInit : false,
- currentView : null,
eventHandlers : {},
routes : {
@@ -46,8 +45,8 @@ NS.Router = Backbone.Router.extend({
return;
}
- if ( this.currentView ) {
- this.currentView.hide( callbackEvent );
+ if ( NS.View.Current ) {
+ NS.View.Current.hide( callbackEvent );
} else {
NS.EventManager.trigger( callbackEvent, slug );
}
@@ -92,7 +91,9 @@ NS.Router = Backbone.Router.extend({
// TODO use backbone events ?
$("body").delegate(".nav a, .brand", "click", function(e) {
e.preventDefault();
- NS.AppRouter.navigate($(this).attr("href"), true);
+ var targetLocation = $(this).attr("href");
+ if ( window.location.pathname == targetLocation ) return;
+ NS.AppRouter.navigate( targetLocation, true );
});
},
@@ -106,24 +107,34 @@ NS.Router = Backbone.Router.extend({
switch ( e.type ) {
case NS.Events.APP_READY :
- view = new NS.View.Main({
- collection : NS.Data.Items
- });
- // NS.AppRouter.navigate("/");
+ if ( !NS.Page.Home ) {
+ NS.Page.Home = new NS.View.Main({
+ collection : NS.Data.Items
+ });
+ }
+ view = NS.Page.Home;
break;
case NS.Events.SHOW_ABOUT :
- view = new NS.View.About();
+ if ( !NS.Page.About ) {
+ NS.Page.About = new NS.View.About();
+ }
+ view = NS.Page.About;
break;
case NS.Events.SHOW_CONTACT :
- view = new NS.View.Contact();
+ if ( !NS.Page.Contact ) {
+ NS.Page.Contact = new NS.View.Contact();
+ }
+ view = NS.Page.Contact;
break;
}
- view.render();
- this.currentView = view;
+ if ( view ) {
+ view.render();
+ NS.View.Current = view;
+ }
}
});
11 js/app/views/Base.js
View
@@ -1,7 +1,7 @@
NS.View.Base = Backbone.View.extend({
- el : ".content",
+ el : ".main-content",
tpl : null,
template_name : "",
template_url : "",
@@ -10,9 +10,9 @@ NS.View.Base = Backbone.View.extend({
slug : "",
hide : function (callbackEvent) {
- $(this.el).hide();
- console.log("hide");
- if (callbackEvent) NS.EventManager.trigger(callbackEvent);
+ $(this.el).fadeOut( 500, function(){
+ if (callbackEvent) NS.EventManager.trigger(callbackEvent);
+ });
},
render : function() {
@@ -29,7 +29,7 @@ NS.View.Base = Backbone.View.extend({
self.tpl = data;
self._display();
},
- "noStorage" : true // util for debug
+ "noStorage" : false // set true for debug
});
},
@@ -46,5 +46,6 @@ NS.View.Base = Backbone.View.extend({
$("body").attr("class", "").addClass(this.classname);
$(this.el).html( tpl(params) );
+ $(this.el).fadeIn( 500 );
}
});
9 templates/main.html
View
@@ -1,10 +1,3 @@
<div class="span14">
- <h4>Home Page <%= message %></h4>
- <ul>
- <% _.each(items, function(item){ %>
- <li>
- <a href="#<%= item.get('id') %>"><%= item.get("title") %></a>
- </li>
- <% }); %>
- </ul>
+ <h4>Home Page</h4>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.