Spontaneous.Views = (function($, S) { var dom = S.Dom; var View = new JS.Class({ initialize: function(content) { this.content = content; }, id: function() { return this.content.id(); }, uid: function() { return this.content.uid(); }, depth_class: function() { return 'depth-'+this.content.depth(); }, depth: function() { return this.content.depth(); }, visibility_class: function() { return this.content.hidden() ? 'hidden' : 'visible'; }, boxes_class: function() { return this.content.has_boxes() ? 'boxes' : 'no-boxes'; }, has_fields: function() { return this.content.field_list().length > 0; }, field_list: function() { return this.content.field_list(); }, image_fields: function() { return this.content.image_fields(); }, text_fields: function() { return this.content.text_fields(); }, file_fields: function() { return this.content.file_fields(); }, mouseover: function(event) { }, mouseout: function(event) { }, save_path: function() { return this.content.save_path(); }, create_edit_wrapper: function(read_content) { var s = {'style':'position: relative; overflow: hidden;'} var outer = dom.div(s); var write = dom.div({'style':'position: absolute; height: 0; overflow: hidden;'}) var write_inner = dom.div(); var read = dom.div(s); var read_inner = dom.div(); write.append(write_inner); read_inner.append(read_content); read.append(read_inner); outer.append(write).append(read); this.editing_area = { outer: outer, write: write, write_inner: write_inner, read: read, read_inner: read_inner }; return outer; }, edit: function(focus_field) { var time_to_reveal = 300, back = 10, front = 20, a = this.editing_area, o = a.outer, w = a.write, r = a.read, wi = a.write_inner, ri = a.read_inner; var panel = new Spontaneous.EditPanel(this), view = panel.view(); r.css('z-index', front); w.css('z-index', back).css('height', 'auto').show(); wi.append(view); var h = wi.outerHeight(); o.add(r).animate({'height':h}, { queue: false, duration: time_to_reveal }); w.css({'position':'relative'}); r.css({'position':'absolute', 'top':0, 'right':0, 'left':0}).animate({'top':h}, { queue: false, duration: time_to_reveal, complete:function() { w.css({'z-index': front, 'position':'relative', 'height':'auto'}) r.css({'z-index': back, 'position':'absolute'}) o.css('height', 'auto'); panel.on_show(focus_field); }}); }, edit_closing: false, edit_closed: function() { if (this.edit_closing) { return; } this.edit_closing = true; var time_to_reveal = 300, back = 10, front = 20, a = this.editing_area, o = a.outer, w = a.write, r = a.read, wi = a.write_inner, ri = a.read_inner, h = ri.outerHeight(), __content = this; o.add(r).animate({'height':h}, { queue: false, duration: time_to_reveal }); r.css({'z-index':front, 'height':h, 'top':wi.outerHeight()+'px'}).animate({'top':0}, { queue: true, duration: time_to_reveal, complete: function() { w.css({'position':'absolute', 'z-index':back}); r.css({'position':'relative', 'height':'auto', 'z-index':front}) o.css('height', 'auto') wi.empty(); __content.edit_closing = false; }}); }, save_complete:function(response) { this.content.save_complete(response); } }); return { View: View } }(jQuery, Spontaneous));