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
181 cls: 'masonry-brick-mask'
188 getSplitAutoCreate : function()
190 var cls = 'masonry-brick masonry-brick-split';
192 if(this.href.length){
193 cls += ' masonry-brick-link';
196 if(this.bgimage.length){
197 cls += ' masonry-brick-image';
201 cls += ' masonry-' + this.size + '-brick';
204 switch (this.placetitle) {
206 cls += ' masonry-center-title';
209 cls += ' masonry-bottom-title';
212 if(!this.bgimage.length){
213 cls += ' masonry-center-title';
216 if(this.bgimage.length){
217 cls += ' masonry-bottom-title';
223 cls += ' ' + this.cls;
227 tag: (this.href.length) ? 'a' : 'div',
232 cls: 'masonry-brick-split-head',
236 cls: 'masonry-brick-paragraph',
243 cls: 'masonry-brick-split-body',
249 if(this.href.length){
250 cfg.href = this.href;
253 if(this.title.length){
254 cfg.cn[0].cn[0].cn.push({
256 cls: 'masonry-brick-title',
261 if(this.html.length){
264 cls: 'masonry-brick-text',
269 if(this.bgimage.length){
272 cls: 'masonry-brick-image-view',
277 if(this.videourl.length){
278 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
279 // youtube support only?
280 cfg.cn[0].cn.cn.push({
282 cls: 'masonry-brick-image-view',
285 allowfullscreen : true
292 initEvents: function()
329 this.el.on('touchstart', this.onTouchStart, this);
330 this.el.on('touchmove', this.onTouchMove, this);
331 this.el.on('touchend', this.onTouchEnd, this);
332 this.el.on('contextmenu', this.onContextMenu, this);
334 this.el.on('mouseenter' ,this.enter, this);
335 this.el.on('mouseleave', this.leave, this);
338 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
339 this.parent().bricks.push(this);
344 onClick: function(e, el)
350 var time = this.endTimer - this.startTimer;
361 enter: function(e, el)
365 if(!this.isFitContainer){
369 if(this.bgimage.length && this.html.length){
370 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
374 leave: function(e, el)
378 if(!this.isFitContainer){
382 if(this.bgimage.length && this.html.length){
383 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
387 onTouchStart: function(e, el)
389 // e.preventDefault();
391 this.touchmoved = false;
393 if(!this.isFitContainer){
397 if(!this.bgimage.length || !this.html.length){
401 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
403 this.timer = new Date().getTime();
407 onTouchMove: function(e, el)
409 this.touchmoved = true;
412 onContextMenu : function(e,el)
419 onTouchEnd: function(e, el)
421 // e.preventDefault();
423 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
430 if(!this.bgimage.length || !this.html.length){
432 if(this.href.length){
433 window.location.href = this.href;
439 if(!this.isFitContainer){
443 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
445 window.location.href = this.href;