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,
75 * @cfg {Boolean} preventDefault defalut false
77 preventDefault : false,
80 * @cfg {Boolean} inverse defalut false
84 getAutoCreate : function()
86 if(!this.isFitContainer){
87 return this.getSplitAutoCreate();
90 var cls = 'masonry-brick masonry-brick-full';
93 cls += ' masonry-brick-link';
96 if(this.bgimage.length){
97 cls += ' masonry-brick-image';
100 if(!Roo.isTouch && this.maskInverse){
101 Roo.log('mask inverse');
102 cls += ' mask-inverse';
105 if(!this.html.length && !this.maskInverse){
106 Roo.log('enable mask');
107 cls += ' enable-mask';
111 cls += ' masonry-' + this.size + '-brick';
114 if(this.placetitle.length){
116 switch (this.placetitle) {
118 cls += ' masonry-center-title';
121 cls += ' masonry-bottom-title';
128 if(!this.html.length && !this.bgimage.length){
129 cls += ' masonry-center-title';
132 if(!this.html.length && this.bgimage.length){
133 cls += ' masonry-bottom-title';
138 cls += ' ' + this.cls;
142 tag: (this.href.length) ? 'a' : 'div',
147 cls: 'masonry-brick-paragraph',
153 if(this.href.length){
154 cfg.href = this.href;
157 var cn = cfg.cn[0].cn;
159 if(this.title.length){
162 cls: 'masonry-brick-title',
167 if(this.html.length){
170 cls: 'masonry-brick-text',
174 if (!this.title.length && !this.html.length) {
175 cfg.cn[0].cls += ' hide';
178 if(this.bgimage.length){
181 cls: 'masonry-brick-image-view',
186 if(this.videourl.length){
187 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
188 // youtube support only?
191 cls: 'masonry-brick-image-view',
194 allowfullscreen : true
202 cls: 'masonry-brick-mask'
209 getSplitAutoCreate : function()
211 var cls = 'masonry-brick masonry-brick-split';
213 if(this.href.length){
214 cls += ' masonry-brick-link';
217 if(this.bgimage.length){
218 cls += ' masonry-brick-image';
222 cls += ' masonry-' + this.size + '-brick';
225 switch (this.placetitle) {
227 cls += ' masonry-center-title';
230 cls += ' masonry-bottom-title';
233 if(!this.bgimage.length){
234 cls += ' masonry-center-title';
237 if(this.bgimage.length){
238 cls += ' masonry-bottom-title';
244 cls += ' ' + this.cls;
248 tag: (this.href.length) ? 'a' : 'div',
253 cls: 'masonry-brick-split-head',
257 cls: 'masonry-brick-paragraph',
264 cls: 'masonry-brick-split-body',
270 if(this.href.length){
271 cfg.href = this.href;
274 if(this.title.length){
275 cfg.cn[0].cn[0].cn.push({
277 cls: 'masonry-brick-title',
282 if(this.html.length){
285 cls: 'masonry-brick-text',
290 if(this.bgimage.length){
293 cls: 'masonry-brick-image-view',
298 if(this.videourl.length){
299 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
300 // youtube support only?
301 cfg.cn[0].cn.cn.push({
303 cls: 'masonry-brick-image-view',
306 allowfullscreen : true
313 initEvents: function()
348 this.el.on('touchstart', this.onTouchStart, this);
349 this.el.on('touchmove', this.onTouchMove, this);
350 this.el.on('touchend', this.onTouchEnd, this);
351 this.el.on('contextmenu', this.onContextMenu, this);
353 this.el.on('mouseenter' ,this.enter, this);
354 this.el.on('mouseleave', this.leave, this);
355 this.el.on('click', this.onClick, this);
358 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
359 this.parent().bricks.push(this);
364 onClick: function(e, el)
366 var time = this.endTimer - this.startTimer;
375 if(!this.preventDefault){
380 this.fireEvent('click', this);
383 enter: function(e, el)
387 if(!this.isFitContainer || this.maskInverse){
391 if(this.bgimage.length && this.html.length){
392 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
396 leave: function(e, el)
400 if(!this.isFitContainer || this.maskInverse){
404 if(this.bgimage.length && this.html.length){
405 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
409 onTouchStart: function(e, el)
411 // e.preventDefault();
413 this.touchmoved = false;
415 if(!this.isFitContainer){
419 if(!this.bgimage.length || !this.html.length){
423 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
425 this.timer = new Date().getTime();
429 onTouchMove: function(e, el)
431 this.touchmoved = true;
434 onContextMenu : function(e,el)
441 onTouchEnd: function(e, el)
443 // e.preventDefault();
445 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
452 if(!this.bgimage.length || !this.html.length){
454 if(this.href.length){
455 window.location.href = this.href;
461 if(!this.isFitContainer){
465 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
467 window.location.href = this.href;