From 7c044aa18a870f7bd7607a3c707616b6e2a4a23a Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 28 Jun 2012 16:14:33 -0400 Subject: [PATCH] Correctly hide the content when cancel --- cms/static/coffee/src/views/course.coffee | 7 +++++++ cms/static/coffee/src/views/module_edit.coffee | 8 +++++++- cms/static/coffee/src/views/week.coffee | 15 ++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cms/static/coffee/src/views/course.coffee b/cms/static/coffee/src/views/course.coffee index 769612de72..51413b1ecd 100644 --- a/cms/static/coffee/src/views/course.coffee +++ b/cms/static/coffee/src/views/course.coffee @@ -4,6 +4,7 @@ class CMS.Views.Course extends Backbone.View new CMS.Views.Week el: week, height: @maxWeekHeight() CMS.on('showContent', @showContent) + CMS.on('hideContent', @hideContent) showContent: (subview) => $('body').addClass('content') @@ -11,6 +12,12 @@ class CMS.Views.Course extends Backbone.View @$('.cal').css height: @contentHeight() @$('>section').css minHeight: @contentHeight() + hideContent: => + $('body').removeClass('content') + @$('.main-content').empty() + @$('.cal').css height: '' + @$('>section').css minHeight: '' + maxWeekHeight: -> _.max($('#weeks > li').map -> $(this).height()) + 1 diff --git a/cms/static/coffee/src/views/module_edit.coffee b/cms/static/coffee/src/views/module_edit.coffee index 556424bd9c..403b8277b3 100644 --- a/cms/static/coffee/src/views/module_edit.coffee +++ b/cms/static/coffee/src/views/module_edit.coffee @@ -2,6 +2,12 @@ class CMS.Views.ModuleEdit extends Backbone.View tagName: 'section' className: 'edit-pane' + events: + 'click .cancel': 'cancel' + initialize: -> CMS.trigger 'module.edit' - @$el.append($('
').load(@model.editUrl())) + @$el.append($("""
""").load(@model.editUrl())) + + cancel: -> + CMS.trigger 'hideContent' diff --git a/cms/static/coffee/src/views/week.coffee b/cms/static/coffee/src/views/week.coffee index f80d63de52..d26249065c 100644 --- a/cms/static/coffee/src/views/week.coffee +++ b/cms/static/coffee/src/views/week.coffee @@ -3,13 +3,22 @@ class CMS.Views.Week extends Backbone.View 'click .module-edit': 'edit' initialize: -> - @model = new CMS.Models.Week(id: @el.id) - @$el.height @options.height + @model = new CMS.Models.Week(id: @$el.data('id')) + @setHeight() @$('.editable').inlineEdit() @$('.editable-textarea').inlineEdit(control: 'textarea') - @$('#modules .module').each -> + @$('.modules .module').each -> new CMS.Views.Module el: this + CMS.on('showContent', @resetHeight) + CMS.on('hideContent', @setHeight) + edit: => CMS.trigger('showContent', new CMS.Views.WeekEdit(model: @model)) + + setHeight: => + @$el.height(@options.height) + + resetHeight: => + @$el.height('')