application/js/views.js in spontaneous-0.2.0.beta5 vs application/js/views.js in spontaneous-0.2.0.beta6

- old
+ new

@@ -3,11 +3,29 @@ var dom = S.Dom; var View = new JS.Class({ include: Spontaneous.Properties, initialize: function(content) { this.content = content; + this._subviews = []; }, + unload: function() { + this.unwatchOthers(); + this.unloadView(); + this.unloadChildren(); + }, + unloadView: function() { + // cleanup + }, + unloadChildren: function() { + for (var i = 0, c = this._subviews, ii = c.length; i < ii; i++) { + if (typeof c[i].unload === 'function') { + c[i].unload(); + } else { + console.warn('unable to unload child view', c[i]); + } + } + }, id: function() { return this.content.id(); }, uid: function() { return this.content.uid(); @@ -19,10 +37,16 @@ return this.content.depth(); }, visibility_class: function() { return this.content.hidden() ? 'hidden' : 'visible'; }, + alias_class: function() { + return this.content.type().is_alias() ? 'alias' : 'not-alias'; + }, + fields_class: function() { + return this.content.has_fields() ? 'fields' : 'no-fields'; + }, boxes_class: function() { return this.content.has_boxes() ? 'boxes' : 'no-boxes'; }, has_fields: function() { @@ -49,13 +73,13 @@ }, 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 s = {'style':'position: relative; overflow: hidden;'}; + var outer = dom.div('.edit-wrapper-outer', 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); @@ -80,12 +104,12 @@ 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', 'display':'none'}) + w.css({'z-index': front, 'position':'relative', 'height':'auto'}); + r.css({'z-index': back, 'position':'absolute', 'display':'none'}); o.css('height', 'auto'); panel.on_show(focus_field); }}); }, edit_closing: false, @@ -95,19 +119,19 @@ var time_to_reveal = 300, back = 10, front = 20, a = this.editing_area, o = a.outer, w = a.write, r = a.read.css('display', 'block'), wi = a.write_inner, ri = a.read_inner, __content = this, h = ri.outerHeight(); 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') + 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));