UNPKG

wise-web-client

Version:

Based on Spine MVC framework

50 lines (46 loc) 1.75 kB
// HomePageView.js // ------- define(['jquery', 'backbone', 'handlebars', 'socketio', './BaseView', 'text!../../../tpl/login_home_page.hbr', 'text!../../../tpl/anonymous_home_page.hbr', './MapComponentView' ], function($, Backbone, Handlebars, socketio, BaseView, loginTemplate, anonymousTemplate, MapComponentView) { var View = BaseView.extend({ // The DOM Element associated with this view el: '#page-container', loginTemplate: Handlebars.compile(loginTemplate), anonymousTemplate: Handlebars.compile(anonymousTemplate), initialize: function(context) { _.extend(this, context); if (this.session) { this.session.bind('change', this.render, this); } }, // View Event Handlers events: { }, // Renders the view's template to the UI render: function() { var that = this; if (this.session && this.session.isLogin()) { this.$el.html(this.loginTemplate()); _.defer(function() { var mapComponentView = new MapComponentView({ 'el': '#mapCompContainer', session: that.session }); mapComponentView.render(); }); } else { this.$el.html(this.anonymousTemplate()); } return this; } }); // Returns the View class return View; } );