application/js/views/piece_view.js in spontaneous-0.1.0.alpha1 vs application/js/views/piece_view.js in spontaneous-0.2.0.alpha1

- old
+ new

@@ -38,20 +38,23 @@ return w; } }); var PieceView = new JS.Class(S.Views.View, { - initialize: function(content, container) { + initialize: function(content, container_view) { this.callSuper(content); - this.container = container; + this.container_view = container_view; }, panel: function() { var wrapper = dom.div(['entry-wrap', this.depth_class(), this.visibility_class(), this.boxes_class()]) var contents = dom.div('.entry-contents'); var inside = dom.div('.entry-inner'); - var outline = dom.div('.white-bg').mouseover(this.mouseover.bind(this)).mouseout(this.mouseout.bind(this)).click(this.edit.bind(this)) - inside.append(outline) + var outline = dom.div('.white-bg'). + mouseover(this.mouseover.bind(this)). + mouseout(this.mouseout.bind(this)). + click(this.edit.bind(this)); + inside.append(outline); if (this.content.depth() < 4) { inside.append(dom.div('.grey-bg')); } contents.append(this.title_bar(contents)); @@ -69,24 +72,41 @@ var box_container = new Spontaneous.BoxContainer(this.content); inside.append(entry); inside.append(box_container.panel()); var preview_area = this.create_edit_wrapper(inside); contents.append(preview_area); - wrapper.append(contents, dom.div('.entry-spacer')); + + wrapper.append(contents, this.entry_spacer()); this.wrapper = wrapper; this.outline = outline; this.fields_preview = fields_panel; return wrapper; }, - + entry_spacer: function() { + var entry_spacer = dom.div('.entry-spacer').hover(function() { + this.container_view.show_add_after(this, entry_spacer); + }.bind(this), function() { + this.container_view.hide_add_after(this, entry_spacer); + }.bind(this)); + return entry_spacer; + }, + edit: function(focus_field) { + this.wrapper.addClass('editing') + this.callSuper(focus_field); + }, + edit_closed: function() { + this.wrapper.removeClass('editing'); + this.callSuper(); + }, alias_target_panel: function() { var content = this.content, wrap = dom.div('.alias-target'), icon = content.alias_icon, click = function() { S.Location.load_id(content.target().id); }, - title = dom.a().text(content.content.alias_title).click(click); + title = dom.a().html(content.content.alias_title).click(click); + if (!content.has_fields()) { wrap.addClass('no-fields'); } if (icon) { var img = new Spontaneous.Image(icon); wrap.append(img.icon(60, 60).click(click)) } @@ -94,11 +114,11 @@ return wrap.append(title) }, title_bar: function(wrapper) { if (!this._title_bar) { var label = user.is_developer() ? dom.a('.developer.source').attr('href', this.content.developer_edit_url()).text(this.content.developer_description()) : (this.content.type().title); - var title_bar = dom.div('.title-bar').append(label); + var title_bar = dom.div('.title-bar')//.append(label); var actions = dom.div('.actions', {'xstyle':'display: none'}); var destroy = dom.a('.delete'); var visibility = dom.a('.visibility'); actions.append(destroy); actions.append(visibility); @@ -168,9 +188,10 @@ } }, destroyed: function() { this.wrapper.disappear(function() { this.wrapper.remove(); + this.trigger('removed', this); }.bind(this)); } }); return PieceView; }(jQuery, Spontaneous));