4 * @class Roo.htmleditor.BlockFigure
5 * Block that has an image and a figcaption
6 * @cfg {String} image_src the url for the image
7 * @cfg {String} align (left|right) alignment for the block default left
8 * @cfg {String} caption the text to appear below (and in the alt tag)
9 * @cfg {String} caption_display (block|none) display or not the caption
10 * @cfg {String|number} image_width the width of the image number or %?
11 * @cfg {String|number} image_height the height of the image number or %?
14 * Create a new Filter.
15 * @param {Object} config Configuration options
18 Roo.htmleditor.BlockFigure = function(cfg)
21 this.readElement(cfg.node);
22 this.updateElement(cfg.node);
26 Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
33 caption_display : 'block',
39 // margin: '2%', not used
41 text_align: 'left', // (left|right) alignment for the text caption default left. - not used at present
44 // used by context menu
45 friendly_name : 'Image with caption',
46 deleteTitle : "Delete Image and Caption",
48 contextMenu : function(toolbar)
51 var block = function() {
52 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
56 var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
58 var syncValue = toolbar.editorcore.syncValue;
66 xns : rooui.Toolbar //Boostrap?
74 keyup : function (combo, e)
76 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
78 b.image_src = this.getValue();
81 toolbar.editorcore.onEditorEvent();
90 xns : rooui.Toolbar //Boostrap?
98 triggerAction : 'all',
104 select : function (combo, r, index)
106 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
108 b.width = r.get('val');
111 toolbar.editorcore.onEditorEvent();
116 xtype : 'SimpleStore',
129 xns : rooui.Toolbar //Boostrap?
134 displayField : 'val',
137 triggerAction : 'all',
143 select : function (combo, r, index)
145 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
147 b.align = r.get('val');
150 toolbar.editorcore.onEditorEvent();
155 xtype : 'SimpleStore',
169 text: 'Hide Caption',
170 name : 'caption_display',
173 setValue : function(v) {
174 this.toggle(v == 'block' ? false : true);
177 toggle: function (btn, state)
180 b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
181 this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
184 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
185 toolbar.editorcore.onEditorEvent();
194 * create a DomHelper friendly object - for use with
195 * Roo.DomHelper.markup / overwrite / etc..
197 toObject : function()
199 var d = document.createElement('div');
200 d.innerHTML = this.caption;
202 var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0;
206 contenteditable : 'false',
207 src : this.image_src,
208 alt : d.innerText.replace(/\n/g, " ").replace(/\s+/g, ' ').trim(), // removeHTML and reduce spaces..
218 '<div class="{0}" width="420" height="315" src="{1}" frameborder="0" allowfullscreen>' +
220 '<img class="{0}-thumbnail" src="{3}/Images/{4}/{5}#image-{4}" />' +
225 if (this.href.length > 0) {
229 contenteditable : 'true',
237 if (this.video_url.length > 0) {
242 allowfullscreen : true,
243 width : 420, // these are for video tricks - that we replace the outer
245 src : this.video_url,
254 'data-block' : 'Figure',
255 contenteditable : 'false',
259 'max-width': this.width,
273 contenteditable : true,
275 'text-align': 'left',
276 'margin-top' : '16px',
277 'font-size' : '16px',
278 'line-height' : '24px',
279 'font-style': 'italic',
280 display : this.caption_display
282 cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
291 readElement : function(node)
293 // this should not really come from the link...
294 this.video_url = this.getVal(node, 'div', 'src');
295 this.cls = this.getVal(node, 'div', 'class');
296 this.href = this.getVal(node, 'a', 'href');
298 this.image_src = this.getVal(node, 'img', 'src');
300 this.align = this.getVal(node, 'figure', 'align');
301 this.caption = this.getVal(node, 'figcaption', 'html');
302 //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
303 this.width = this.getVal(node, 'figure', 'style', 'max-width');
304 //this.margin = this.getVal(node, 'figure', 'style', 'margin');
307 removeNode : function()