9 * @class Roo.bootstrap.MasonryBrick
10 * @extends Roo.bootstrap.Component
11 * Bootstrap MasonryBrick class
14 * Create a new MasonryBrick
15 * @param {Object} config The config object
18 Roo.bootstrap.MasonryBrick = function(config){
19 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
25 * When a MasonryBrick is clcik
26 * @param {Roo.bootstrap.MasonryBrick} this
27 * @param {Roo.EventObject} e
33 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
44 * @cfg {String} bgimage
48 * @cfg {String} videourl
60 * @cfg {String} (xs|sm|md|md-left|md-right|tall|wide) size
65 * @cfg {String} (center|bottom) placetitle
70 * @cfg {Boolean} isFitContainer defalut true
72 isFitContainer : true,
74 getAutoCreate : function()
76 if(!this.isFitContainer){
77 return this.getSplitAutoCreate();
80 var cls = 'masonry-brick';
83 cls += ' masonry-brick-link';
86 if(this.bgimage.length){
87 cls += ' masonry-brick-image';
91 cls += ' masonry-' + this.size + '-brick';
94 if(this.placetitle.length){
96 switch (this.placetitle) {
98 cls += ' masonry-center-title';
101 cls += ' masonry-bottom-title';
108 if(!this.html.length && !this.bgimage.length){
109 cls += ' masonry-center-title';
112 if(!this.html.length && this.bgimage.length){
113 cls += ' masonry-bottom-title';
118 cls += ' ' + this.cls;
122 tag: (this.href.length) ? 'a' : 'div',
127 cls: 'masonry-brick-paragraph',
133 if(this.href.length){
134 cfg.href = this.href;
137 var cn = cfg.cn[0].cn;
139 if(this.title.length){
142 cls: 'masonry-brick-title',
147 if(this.html.length){
150 cls: 'masonry-brick-text',
154 if (!this.title.length && !this.html.length) {
155 cfg.cn[0].cls += ' hide';
158 if(this.bgimage.length){
161 cls: 'masonry-brick-image-view',
165 if(this.videourl.length){
166 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
167 // youtube support only?
170 cls: 'masonry-brick-image-view',
173 allowfullscreen : true
182 getSplitAutoCreate : function()
184 var cls = 'masonry-brick masonry-brick-split';
186 if(this.href.length){
187 cls += ' masonry-brick-link';
190 if(this.bgimage.length){
191 cls += ' masonry-brick-image';
195 cls += ' masonry-' + this.size + '-brick';
198 switch (this.placetitle) {
200 cls += ' masonry-center-title';
203 cls += ' masonry-bottom-title';
206 if(!this.bgimage.length){
207 cls += ' masonry-center-title';
210 if(this.bgimage.length){
211 cls += ' masonry-bottom-title';
217 cls += ' ' + this.cls;
221 tag: (this.href.length) ? 'a' : 'div',
226 cls: 'masonry-brick-split-head',
230 cls: 'masonry-brick-paragraph',
237 cls: 'masonry-brick-split-body',
243 if(this.href.length){
244 cfg.href = this.href;
247 if(this.title.length){
248 cfg.cn[0].cn[0].cn.push({
250 cls: 'masonry-brick-title',
255 if(this.html.length){
258 cls: 'masonry-brick-text',
263 if(this.bgimage.length){
266 cls: 'masonry-brick-image-view',
271 if(this.videourl.length){
272 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
273 // youtube support only?
274 cfg.cn[0].cn.cn.push({
276 cls: 'masonry-brick-image-view',
279 allowfullscreen : true
286 initEvents: function()
323 this.el.on('touchstart', this.onTouchStart, this);
324 this.el.on('touchmove', this.onTouchMove, this);
325 this.el.on('touchend', this.onTouchEnd, this);
326 this.el.on('contextmenu', this.onContextMenu, this);
328 this.el.on('mouseenter' ,this.enter, this);
329 this.el.on('mouseleave', this.leave, this);
332 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
333 this.parent().bricks.push(this);
338 onClick: function(e, el)
344 var time = this.endTimer - this.startTimer;
355 enter: function(e, el)
359 if(!this.isFitContainer){
363 if(this.bgimage.length && this.html.length){
364 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
368 leave: function(e, el)
372 if(!this.isFitContainer){
376 if(this.bgimage.length && this.html.length){
377 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
381 onTouchStart: function(e, el)
383 // e.preventDefault();
385 this.touchmoved = false;
387 if(!this.isFitContainer){
391 if(!this.bgimage.length || !this.html.length){
395 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
397 this.timer = new Date().getTime();
401 onTouchMove: function(e, el)
403 this.touchmoved = true;
406 onContextMenu : function(e,el)
413 onTouchEnd: function(e, el)
415 // e.preventDefault();
417 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
424 if(!this.bgimage.length || !this.html.length){
426 if(this.href.length){
427 window.location.href = this.href;
433 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
435 window.location.href = this.href;