diff --git a/lms/static/js/learner_dashboard/views/explore_new_programs_view.js b/lms/static/js/learner_dashboard/views/explore_new_programs_view.js new file mode 100644 index 0000000000..1a403c4664 --- /dev/null +++ b/lms/static/js/learner_dashboard/views/explore_new_programs_view.js @@ -0,0 +1,44 @@ +;(function (define) { + 'use strict'; + + define(['backbone', + 'jquery', + 'underscore', + 'gettext', + 'text!../../../templates/learner_dashboard/explore_new_programs.underscore' + ], + function( + Backbone, + $, + _, + gettext, + exploreTpl + ) { + return Backbone.View.extend({ + el: '.program-advertise', + + tpl: _.template(exploreTpl), + + initialize: function(data) { + this.context = data.context; + this.$parentEl = $(this.parentEl); + + if (this.context.xseriesUrl){ + // Only render if there is an XSeries link + this.render(); + } else { + /** + * If not rendering remove el because + * styles are applied to it + */ + this.remove(); + } + }, + + render: function() { + this.$el.html(this.tpl(this.context)); + } + }); + } + ); +}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/program_card_view.js b/lms/static/js/learner_dashboard/views/program_card_view.js index c4cf69c91e..d19bb7f609 100644 --- a/lms/static/js/learner_dashboard/views/program_card_view.js +++ b/lms/static/js/learner_dashboard/views/program_card_view.js @@ -17,16 +17,21 @@ picturefill ) { return Backbone.View.extend({ + className: 'program-card', + tpl: _.template(programCardTpl), + initialize: function() { this.render(); }, + render: function() { var templated = this.tpl(this.model.toJSON()); this.$el.html(templated); this.postRender(); }, + postRender: function() { if(navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0){ @@ -36,6 +41,7 @@ }.bind(this), 100); } }, + // Defer loading the rest of the page to limit FOUC reLoadBannerImage: function() { var $img = this.$('.program_card .banner-image'), diff --git a/lms/static/js/learner_dashboard/views/sidebar_view.js b/lms/static/js/learner_dashboard/views/sidebar_view.js index d373463331..3534eb3e02 100644 --- a/lms/static/js/learner_dashboard/views/sidebar_view.js +++ b/lms/static/js/learner_dashboard/views/sidebar_view.js @@ -5,6 +5,7 @@ 'jquery', 'underscore', 'gettext', + 'js/learner_dashboard/views/explore_new_programs_view', 'text!../../../templates/learner_dashboard/sidebar.underscore' ], function( @@ -12,19 +13,27 @@ $, _, gettext, + NewProgramsView, sidebarTpl ) { return Backbone.View.extend({ el: '.sidebar', + tpl: _.template(sidebarTpl), + initialize: function(data) { this.context = data.context; }, + render: function() { - if (this.context.xseriesUrl){ - //Only show the xseries advertising panel if the link is passed in - this.$el.html(this.tpl(this.context)); - } + this.$el.html(this.tpl(this.context)); + this.postRender(); + }, + + postRender: function() { + this.newProgramsView = new NewProgramsView({ + context: this.context + }); } }); } diff --git a/lms/static/js/spec/learner_dashboard/sidebar_view_spec.js b/lms/static/js/spec/learner_dashboard/sidebar_view_spec.js index 4b9104e810..295d25c3be 100644 --- a/lms/static/js/spec/learner_dashboard/sidebar_view_spec.js +++ b/lms/static/js/spec/learner_dashboard/sidebar_view_spec.js @@ -34,7 +34,7 @@ define([ it('should load the xseries advertising based on passed in xseries URL', function() { var $sidebar = view.$el; expect($sidebar.find('.program-advertise .advertise-message').html().trim()) - .toEqual('Browse recently launched courses and see what\'s new in our favorite subjects'); + .toEqual('Browse recently launched courses and see what\'s new in your favorite subjects'); expect($sidebar.find('.program-advertise .ad-link a').attr('href')).toEqual(context.xseriesUrl); }); diff --git a/lms/templates/learner_dashboard/explore_new_programs.underscore b/lms/templates/learner_dashboard/explore_new_programs.underscore new file mode 100644 index 0000000000..1b0e5c6e30 --- /dev/null +++ b/lms/templates/learner_dashboard/explore_new_programs.underscore @@ -0,0 +1,9 @@ + + diff --git a/lms/templates/learner_dashboard/sidebar.underscore b/lms/templates/learner_dashboard/sidebar.underscore index 89a1314072..6ddfcc18a5 100644 --- a/lms/templates/learner_dashboard/sidebar.underscore +++ b/lms/templates/learner_dashboard/sidebar.underscore @@ -1,13 +1,2 @@ -
- - -
-
+
+