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 click: function (btn, state)
79 title : "Image Source URL",
80 msg : "Enter the url for the image",
81 buttons: this.OKCANCEL,
83 block().image_src = val;
84 block().updateElement();
86 toolbar.editorcore.onEditorEvent();
90 //multiline: multiline,
92 value : block().image_src
105 keyup : function (combo, e)
107 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
109 b.image_src = this.getValue();
112 toolbar.editorcore.onEditorEvent();
121 xns : rooui.Toolbar //Boostrap?
126 displayField : 'val',
129 triggerAction : 'all',
135 select : function (combo, r, index)
137 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
139 b.width = r.get('val');
142 toolbar.editorcore.onEditorEvent();
147 xtype : 'SimpleStore',
160 xns : rooui.Toolbar //Boostrap?
165 displayField : 'val',
168 triggerAction : 'all',
174 select : function (combo, r, index)
176 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
178 b.align = r.get('val');
181 toolbar.editorcore.onEditorEvent();
186 xtype : 'SimpleStore',
200 text: 'Hide Caption',
201 name : 'caption_display',
204 setValue : function(v) {
205 this.toggle(v == 'block' ? false : true);
208 toggle: function (btn, state)
211 b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
212 this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
215 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
216 toolbar.editorcore.onEditorEvent();
225 * create a DomHelper friendly object - for use with
226 * Roo.DomHelper.markup / overwrite / etc..
228 toObject : function()
230 var d = document.createElement('div');
231 d.innerHTML = this.caption;
233 var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0;
237 contenteditable : 'false',
238 src : this.image_src,
239 alt : d.innerText.replace(/\n/g, " ").replace(/\s+/g, ' ').trim(), // removeHTML and reduce spaces..
249 '<div class="{0}" width="420" height="315" src="{1}" frameborder="0" allowfullscreen>' +
251 '<img class="{0}-thumbnail" src="{3}/Images/{4}/{5}#image-{4}" />' +
256 if (this.href.length > 0) {
260 contenteditable : 'true',
268 if (this.video_url.length > 0) {
273 allowfullscreen : true,
274 width : 420, // these are for video tricks - that we replace the outer
276 src : this.video_url,
285 'data-block' : 'Figure',
286 contenteditable : 'false',
290 'max-width': this.width,
304 contenteditable : true,
306 'text-align': 'left',
307 'margin-top' : '16px',
308 'font-size' : '16px',
309 'line-height' : '24px',
310 'font-style': 'italic',
311 display : this.caption_display
313 cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
322 readElement : function(node)
324 // this should not really come from the link...
325 this.video_url = this.getVal(node, 'div', 'src');
326 this.cls = this.getVal(node, 'div', 'class');
327 this.href = this.getVal(node, 'a', 'href');
329 this.image_src = this.getVal(node, 'img', 'src');
331 this.align = this.getVal(node, 'figure', 'align');
332 this.caption = this.getVal(node, 'figcaption', 'html');
333 //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
334 this.width = this.getVal(node, 'figure', 'style', 'max-width');
335 //this.margin = this.getVal(node, 'figure', 'style', 'margin');
338 removeNode : function()