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',
38 // margin: '2%', not used
40 text_align: 'left', // (left|right) alignment for the text caption default left. - not used at present
43 // used by context menu
44 friendly_name : 'Image with caption',
45 deleteTitle : "Delete Image and Caption",
47 contextMenu : function(toolbar)
50 var block = function() {
51 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
55 var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
57 var syncValue = toolbar.editorcore.syncValue;
65 xns : rooui.Toolbar //Boostrap?
73 keyup : function (combo, e)
75 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
77 b.image_src = this.getValue();
80 toolbar.editorcore.onEditorEvent();
89 xns : rooui.Toolbar //Boostrap?
97 triggerAction : 'all',
103 select : function (combo, r, index)
105 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
107 b.width = r.get('val');
110 toolbar.editorcore.onEditorEvent();
115 xtype : 'SimpleStore',
128 xns : rooui.Toolbar //Boostrap?
133 displayField : 'val',
136 triggerAction : 'all',
142 select : function (combo, r, index)
144 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
146 b.align = r.get('val');
149 toolbar.editorcore.onEditorEvent();
154 xtype : 'SimpleStore',
168 text: 'Hide Caption',
169 name : 'caption_display',
172 setValue : function(v) {
173 this.toggle(v == 'block' ? false : true);
176 toggle: function (btn, state)
179 b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
180 this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
183 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
184 toolbar.editorcore.onEditorEvent();
193 * create a DomHelper friendly object - for use with
194 * Roo.DomHelper.markup / overwrite / etc..
196 toObject : function()
198 var d = document.createElement('div');
199 d.innerHTML = this.caption;
201 var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0;
205 src : this.image_src,
206 alt : d.innerText.replace(/\n/g, " "), // removeHTML..
216 '<div class="{0}" width="420" height="315" src="{1}" frameborder="0" allowfullscreen>' +
218 '<img class="{0}-thumbnail" src="{3}/Images/{4}/{5}#image-{4}" />' +
223 if (this.href.length > 0) {
234 if (this.video_url.length > 0) {
239 allowfullscreen : true,
240 width : 420, // these are for video tricks - that we replace the outer
242 src : this.video_src,
251 'data-block' : 'Figure',
252 contenteditable : 'false',
256 'max-width': this.width,
270 contenteditable : true,
272 'text-align': 'left',
273 'margin-top' : '16px',
274 'font-size' : '16px',
275 'line-height' : '24px',
276 'font-style': 'italic',
277 display : this.caption_display
279 cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
288 readElement : function(node)
290 // this should not really come from the link...
291 this.video_src = this.getVal(node, 'div', 'src');
292 this.cls = this.getVal(node, 'div', 'class');
293 this.href = this.getVal(node, 'a', 'href');
295 this.image_src = this.getVal(node, 'img', 'src');
297 this.align = this.getVal(node, 'figure', 'align');
298 this.caption = this.getVal(node, 'figcaption', 'html');
299 //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
300 this.width = this.getVal(node, 'figure', 'style', 'max-width');
301 //this.margin = this.getVal(node, 'figure', 'style', 'margin');
304 removeNode : function()