From 7c8bc08470e2884fe51a792377297020270d698a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inez=20Korczyn=CC=81ski?= Date: Fri, 17 May 2013 12:40:12 -0700 Subject: [PATCH] Added very basic support (rendering) for captions of thumb and frame images. Change-Id: I4a59d4601c9bf44b241bb1432c9f1abc3f961743 --- modules/ve/ce/nodes/ve.ce.MWBlockImageNode.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/ve/ce/nodes/ve.ce.MWBlockImageNode.js b/modules/ve/ce/nodes/ve.ce.MWBlockImageNode.js index ce62c3ab14..43c7308821 100644 --- a/modules/ve/ce/nodes/ve.ce.MWBlockImageNode.js +++ b/modules/ve/ce/nodes/ve.ce.MWBlockImageNode.js @@ -17,6 +17,8 @@ * @param {Object} [config] Config options */ ve.ce.MWBlockImageNode = function VeCeMWBlockImageNode( model, config ) { + var captionModel, captionView; + // Parent constructor ve.ce.BranchNode.call( this, model, config ); @@ -52,6 +54,19 @@ ve.ce.MWBlockImageNode = function VeCeMWBlockImageNode( model, config ) { .attr( 'width', this.model.getAttribute( 'width' ) ) .attr( 'height', this.model.getAttribute( 'height' ) ) .appendTo( this.$a ); + + // I smell a caption! + if ( this.model.children.length === 1 ) { + captionModel = this.model.children[0]; + captionView = ve.ce.nodeFactory.create( captionModel.getType(), captionModel ); + captionModel.connect( this, { 'update': 'onModelUpdate' } ); + this.children.push( captionView ); + captionView.attach( this ); + captionView.$.appendTo( this.$thumbInner ); + if ( this.live !== captionView.isLive() ) { + captionView.setLive( this.live ); + } + } }; /* Inheritance */