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} size (xs|sm|md|md-left|md-right|tall|wide)
65 * @cfg {String} placetitle (center|bottom)
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 cls += ' mask-inverse';
104 if(!this.html.length && !this.maskInverse){
105 cls += ' enable-mask';
109 cls += ' masonry-' + this.size + '-brick';
112 if(this.placetitle.length){
114 switch (this.placetitle) {
116 cls += ' masonry-center-title';
119 cls += ' masonry-bottom-title';
126 if(!this.html.length && !this.bgimage.length){
127 cls += ' masonry-center-title';
130 if(!this.html.length && this.bgimage.length){
131 cls += ' masonry-bottom-title';
136 cls += ' ' + this.cls;
140 tag: (this.href.length) ? 'a' : 'div',
145 cls: 'masonry-brick-paragraph',
151 if(this.href.length){
152 cfg.href = this.href;
155 var cn = cfg.cn[0].cn;
157 if(this.title.length){
160 cls: 'masonry-brick-title',
165 if(this.html.length){
168 cls: 'masonry-brick-text',
172 if (!this.title.length && !this.html.length) {
173 cfg.cn[0].cls += ' hide';
176 if(this.bgimage.length){
179 cls: 'masonry-brick-image-view',
184 if(this.videourl.length){
185 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
186 // youtube support only?
189 cls: 'masonry-brick-image-view',
192 allowfullscreen : true
200 cls: 'masonry-brick-mask'
207 getSplitAutoCreate : function()
209 var cls = 'masonry-brick masonry-brick-split';
211 if(this.href.length){
212 cls += ' masonry-brick-link';
215 if(this.bgimage.length){
216 cls += ' masonry-brick-image';
220 cls += ' masonry-' + this.size + '-brick';
223 switch (this.placetitle) {
225 cls += ' masonry-center-title';
228 cls += ' masonry-bottom-title';
231 if(!this.bgimage.length){
232 cls += ' masonry-center-title';
235 if(this.bgimage.length){
236 cls += ' masonry-bottom-title';
242 cls += ' ' + this.cls;
246 tag: (this.href.length) ? 'a' : 'div',
251 cls: 'masonry-brick-split-head',
255 cls: 'masonry-brick-paragraph',
262 cls: 'masonry-brick-split-body',
268 if(this.href.length){
269 cfg.href = this.href;
272 if(this.title.length){
273 cfg.cn[0].cn[0].cn.push({
275 cls: 'masonry-brick-title',
280 if(this.html.length){
283 cls: 'masonry-brick-text',
288 if(this.bgimage.length){
291 cls: 'masonry-brick-image-view',
296 if(this.videourl.length){
297 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
298 // youtube support only?
299 cfg.cn[0].cn.cn.push({
301 cls: 'masonry-brick-image-view',
304 allowfullscreen : true
311 initEvents: function()
346 this.el.on('touchstart', this.onTouchStart, this);
347 this.el.on('touchmove', this.onTouchMove, this);
348 this.el.on('touchend', this.onTouchEnd, this);
349 this.el.on('contextmenu', this.onContextMenu, this);
351 this.el.on('mouseenter' ,this.enter, this);
352 this.el.on('mouseleave', this.leave, this);
353 this.el.on('click', this.onClick, this);
356 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
357 this.parent().bricks.push(this);
362 onClick: function(e, el)
364 var time = this.endTimer - this.startTimer;
373 if(!this.preventDefault){
378 this.fireEvent('click', this);
381 enter: function(e, el)
385 if(!this.isFitContainer || this.maskInverse){
389 if(this.bgimage.length && this.html.length){
390 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
394 leave: function(e, el)
398 if(!this.isFitContainer || this.maskInverse){
402 if(this.bgimage.length && this.html.length){
403 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
407 onTouchStart: function(e, el)
409 // e.preventDefault();
411 this.touchmoved = false;
413 if(!this.isFitContainer){
417 if(!this.bgimage.length || !this.html.length){
421 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
423 this.timer = new Date().getTime();
427 onTouchMove: function(e, el)
429 this.touchmoved = true;
432 onContextMenu : function(e,el)
439 onTouchEnd: function(e, el)
441 // e.preventDefault();
443 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
450 if(!this.bgimage.length || !this.html.length){
452 if(this.href.length){
453 window.location.href = this.href;
459 if(!this.isFitContainer){
463 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
465 window.location.href = this.href;