Commit fc67370ef4c2e7eb747706a5a4ce08396545bfcf

Fix few bugs

  - After new page was created in the editor, its view was dangling - it could
    not be reached. Fix that.
  - When page was refreshed, framework was taking it to home page irrespective
    of the URL hash. Fixed.
  
1.title {
2 text-align: center;
3 margin: 0 auto;
4 padding: 3px;
5 font-size: 1.5em;
6}
  
107107 this.render();
108108 },
109109 nameChanged: function(page) {
110 M.pagelistview.render();
110 //M.pagelistview.render();
111111 console.log('name changed', page);
112112 },
113113 render: function() {
209209 console.log('saved', model, response);
210210 model.set(response.page);
211211 model.id = response.page.id;
212 //console.log(model);
213 //console.log(M.pages.models);
214 M.pagelistview.render();
212215 },
213216 error: function(model, xhr) {
214217 console.log('failed', model, xhr);
  
1414 },
1515 render: function() {
1616 var menu = new M.types.model.menu(M.site_content.menu);
17 var navview = new NavigationView({model: menu});
18 navview.render();
17 var navView = new NavigationView({model: menu});
18 navView.render();
19 this.navView = navView;
1920 },
2021 updateBreadcrumbs: function(event) {
2122 //TODO: write code to use bootstrap's breadcrumbs to render a
2727var NavigationView = Backbone.View.extend({
2828 el: '#navigation',
2929 events: {
30 'click .nav li a' : 'navClicked'
30 'click .nav li a' : 'navClicked',
31 'navclicked': 'navClicked'
3132 },
3233 initialize: function() {
3334 _.bindAll(this);
3435 this.template = _.template($('#nav-bar-template').html());
36 this.bind('navclicked', this.navClicked);
3537 },
3638 render: function() {
3739 // if custom menu is not defined, render a default menu
4949 console.log('rendering custom menu..');
5050 this.$el.append(this.model.get('html'));
5151 }
52 var fragment = location.hash.split('/')[1];
53 var pos = _.indexOf(M.pages.models, M.pages.where({'name': fragment})[0]);
54 if(!fragment) {
55 pos = 0;
56 }
57 $(this.$links[pos]).addClass('active');
5258 },
5359 populate: function() {
5460 var item_template = _.template($('#nav-item-template').html());
6666 }));
6767 }, this);
6868 this.$links = $('.nav li');
69 //console.log(this.$links[0]);
70 $(this.$links[0]).addClass('active');
7169 },
7270 navClicked: function(event) {
73 console.log('navClicked');
7471 this.$links.removeClass('active');
75 $(event.currentTarget).parent().addClass('active');
72 if(!event) {
73 var fragment = location.hash.split('/')[1];
74 var pos = _.indexOf(M.pages.models, M.pages.where({'name': fragment})[0]);
75 if(!fragment) {
76 pos = 0;
77 }
78 $(this.$links[pos]).addClass('active');
79 }
80 else {
81 $(event.currentTarget).parent().addClass('active');
82 }
7683 }
7784});
7885
7986var AppRouter = Backbone.Router.extend({
8087 routes : {
81 //'index' : 'index',
8288 ':page' : 'showPage'
8389 },
84 /*index: function() {
85 $('.pageview').hide();
86 var id = nameIdMap['index'];
87 $('#'+id).show();
88 },*/
8990 showPage: function(page) {
9091 $('.pageview').hide();
9192 //news pages are rendered on the fly,
107107 else {
108108 $('#navigation').show();
109109 }
110 M.appView.navView.trigger('navclicked');
110111 },
111112 render404: function() {
112113 $('.pageview').hide();
164164 var app_router = new AppRouter();
165165 Backbone.history.start();
166166
167 var startpage = M.pages.models[0].get('name');
168 app_router.navigate(startpage, {trigger: true});
167 //var startpage = M.pages.models[0].get('name');
168 //app_router.navigate(startpage, {trigger: true});
169169
170170 //M.simHeir();
171171};
  
122122 render: function() {
123123 $('#content-container').append(this.el);
124124 //this.appendNavTemplate();
125 $(this.el).append('<h3>'+this.model.get('title')+'</h3>');
125 $(this.el).append('<div class="title">'+this.model.get('title')+'</div>');
126126 var self = this;
127127 _.each(this.model.get('content'), function(item) {
128128 var view = M.types.view[item.get('type')];
  
1414
1515 <link rel="stylesheet" href="/static/css/normalize.css">
1616 <link rel="stylesheet" href="/static/css/bootstrap.css">
17 <link rel="stylesheet" href="/static/css/mouchak.css">
1718 <link rel="stylesheet" href="/static/css/main.css">
1819 <script src="/static/js/lib/modernizr-2.6.1.min.js"></script>
1920 </head>