Commit 7c044aa1 by Prem Sichanugrist

Correctly hide the content when cancel

parent b46f6a6d
...@@ -4,6 +4,7 @@ class CMS.Views.Course extends Backbone.View ...@@ -4,6 +4,7 @@ class CMS.Views.Course extends Backbone.View
new CMS.Views.Week el: week, height: @maxWeekHeight() new CMS.Views.Week el: week, height: @maxWeekHeight()
CMS.on('showContent', @showContent) CMS.on('showContent', @showContent)
CMS.on('hideContent', @hideContent)
showContent: (subview) => showContent: (subview) =>
$('body').addClass('content') $('body').addClass('content')
...@@ -11,6 +12,12 @@ class CMS.Views.Course extends Backbone.View ...@@ -11,6 +12,12 @@ class CMS.Views.Course extends Backbone.View
@$('.cal').css height: @contentHeight() @$('.cal').css height: @contentHeight()
@$('>section').css minHeight: @contentHeight() @$('>section').css minHeight: @contentHeight()
hideContent: =>
$('body').removeClass('content')
@$('.main-content').empty()
@$('.cal').css height: ''
@$('>section').css minHeight: ''
maxWeekHeight: -> maxWeekHeight: ->
_.max($('#weeks > li').map -> $(this).height()) + 1 _.max($('#weeks > li').map -> $(this).height()) + 1
......
...@@ -2,6 +2,12 @@ class CMS.Views.ModuleEdit extends Backbone.View ...@@ -2,6 +2,12 @@ class CMS.Views.ModuleEdit extends Backbone.View
tagName: 'section' tagName: 'section'
className: 'edit-pane' className: 'edit-pane'
events:
'click .cancel': 'cancel'
initialize: -> initialize: ->
CMS.trigger 'module.edit' 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 ...@@ -3,13 +3,22 @@ class CMS.Views.Week extends Backbone.View
'click .module-edit': 'edit' 'click .module-edit': 'edit'
initialize: -> initialize: ->
@model = new CMS.Models.Week(id: @el.id) @model = new CMS.Models.Week(id: @$el.data('id'))
@$el.height @options.height @setHeight()
@$('.editable').inlineEdit() @$('.editable').inlineEdit()
@$('.editable-textarea').inlineEdit(control: 'textarea') @$('.editable-textarea').inlineEdit(control: 'textarea')
@$('#modules .module').each -> @$('.modules .module').each ->
new CMS.Views.Module el: this new CMS.Views.Module el: this
CMS.on('showContent', @resetHeight)
CMS.on('hideContent', @setHeight)
edit: => edit: =>
CMS.trigger('showContent', new CMS.Views.WeekEdit(model: @model)) 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