Commit 553eb53f by Prem Sichanugrist

Correctly hide the content when cancel

parent 9fcf098f
......@@ -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
......
......@@ -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($('<div id="module-html">').load(@model.editUrl()))
@$el.append($("""<div id="#{@model.get('id')}">""").load(@model.editUrl()))
cancel: ->
CMS.trigger 'hideContent'
......@@ -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('')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment