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();
88 //multiline: multiline,
90 value : block().image_src
103 keyup : function (combo, e)
105 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
107 b.image_src = this.getValue();
110 toolbar.editorcore.onEditorEvent();
119 xns : rooui.Toolbar //Boostrap?
124 displayField : 'val',
127 triggerAction : 'all',
133 select : function (combo, r, index)
135 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
137 b.width = r.get('val');
140 toolbar.editorcore.onEditorEvent();
145 xtype : 'SimpleStore',
158 xns : rooui.Toolbar //Boostrap?
163 displayField : 'val',
166 triggerAction : 'all',
172 select : function (combo, r, index)
174 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
176 b.align = r.get('val');
179 toolbar.editorcore.onEditorEvent();
184 xtype : 'SimpleStore',
198 text: 'Hide Caption',
199 name : 'caption_display',
202 setValue : function(v) {
203 this.toggle(v == 'block' ? false : true);
206 toggle: function (btn, state)
209 b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
210 this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
213 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
214 toolbar.editorcore.onEditorEvent();
223 * create a DomHelper friendly object - for use with
224 * Roo.DomHelper.markup / overwrite / etc..
226 toObject : function()
228 var d = document.createElement('div');
229 d.innerHTML = this.caption;
231 var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0;
235 contenteditable : 'false',
236 src : this.image_src,
237 alt : d.innerText.replace(/\n/g, " ").replace(/\s+/g, ' ').trim(), // removeHTML and reduce spaces..
247 '<div class="{0}" width="420" height="315" src="{1}" frameborder="0" allowfullscreen>' +
249 '<img class="{0}-thumbnail" src="{3}/Images/{4}/{5}#image-{4}" />' +
254 if (this.href.length > 0) {
258 contenteditable : 'true',
266 if (this.video_url.length > 0) {
271 allowfullscreen : true,
272 width : 420, // these are for video tricks - that we replace the outer
274 src : this.video_url,
283 'data-block' : 'Figure',
284 contenteditable : 'false',
288 'max-width': this.width,
302 contenteditable : true,
304 'text-align': 'left',
305 'margin-top' : '16px',
306 'font-size' : '16px',
307 'line-height' : '24px',
308 'font-style': 'italic',
309 display : this.caption_display
311 cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
320 readElement : function(node)
322 // this should not really come from the link...
323 this.video_url = this.getVal(node, 'div', 'src');
324 this.cls = this.getVal(node, 'div', 'class');
325 this.href = this.getVal(node, 'a', 'href');
327 this.image_src = this.getVal(node, 'img', 'src');
329 this.align = this.getVal(node, 'figure', 'align');
330 this.caption = this.getVal(node, 'figcaption', 'html');
331 //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
332 this.width = this.getVal(node, 'figure', 'style', 'max-width');
333 //this.margin = this.getVal(node, 'figure', 'style', 'margin');
336 removeNode : function()