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(!this.html.length && !this.maskInverse){
101 cls += ' enable-mask';
105 cls += ' masonry-' + this.size + '-brick';
108 if(this.placetitle.length){
110 switch (this.placetitle) {
112 cls += ' masonry-center-title';
115 cls += ' masonry-bottom-title';
122 if(!this.html.length && !this.bgimage.length){
123 cls += ' masonry-center-title';
126 if(!this.html.length && this.bgimage.length){
127 cls += ' masonry-bottom-title';
132 cls += ' ' + this.cls;
136 tag: (this.href.length) ? 'a' : 'div',
141 cls: 'masonry-brick-paragraph',
147 if(this.href.length){
148 cfg.href = this.href;
151 var cn = cfg.cn[0].cn;
153 if(this.title.length){
156 cls: 'masonry-brick-title',
161 if(this.html.length){
164 cls: 'masonry-brick-text',
168 if (!this.title.length && !this.html.length) {
169 cfg.cn[0].cls += ' hide';
172 if(this.bgimage.length){
175 cls: 'masonry-brick-image-view',
180 if(this.videourl.length){
181 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
182 // youtube support only?
185 cls: 'masonry-brick-image-view',
188 allowfullscreen : true
196 cls: 'masonry-brick-mask'
203 getSplitAutoCreate : function()
205 var cls = 'masonry-brick masonry-brick-split';
207 if(this.href.length){
208 cls += ' masonry-brick-link';
211 if(this.bgimage.length){
212 cls += ' masonry-brick-image';
216 cls += ' masonry-' + this.size + '-brick';
219 switch (this.placetitle) {
221 cls += ' masonry-center-title';
224 cls += ' masonry-bottom-title';
227 if(!this.bgimage.length){
228 cls += ' masonry-center-title';
231 if(this.bgimage.length){
232 cls += ' masonry-bottom-title';
238 cls += ' ' + this.cls;
242 tag: (this.href.length) ? 'a' : 'div',
247 cls: 'masonry-brick-split-head',
251 cls: 'masonry-brick-paragraph',
258 cls: 'masonry-brick-split-body',
264 if(this.href.length){
265 cfg.href = this.href;
268 if(this.title.length){
269 cfg.cn[0].cn[0].cn.push({
271 cls: 'masonry-brick-title',
276 if(this.html.length){
279 cls: 'masonry-brick-text',
284 if(this.bgimage.length){
287 cls: 'masonry-brick-image-view',
292 if(this.videourl.length){
293 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
294 // youtube support only?
295 cfg.cn[0].cn.cn.push({
297 cls: 'masonry-brick-image-view',
300 allowfullscreen : true
307 initEvents: function()
342 this.el.on('touchstart', this.onTouchStart, this);
343 this.el.on('touchmove', this.onTouchMove, this);
344 this.el.on('touchend', this.onTouchEnd, this);
345 this.el.on('contextmenu', this.onContextMenu, this);
347 this.el.on('mouseenter' ,this.enter, this);
348 this.el.on('mouseleave', this.leave, this);
349 this.el.on('click', this.onClick, this);
352 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
353 this.parent().bricks.push(this);
358 onClick: function(e, el)
360 var time = this.endTimer - this.startTimer;
369 if(!this.preventDefault){
374 this.fireEvent('click', this);
377 enter: function(e, el)
381 if(!this.isFitContainer){
385 if(this.bgimage.length && this.html.length){
386 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
390 leave: function(e, el)
394 if(!this.isFitContainer){
398 if(this.bgimage.length && this.html.length){
399 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
403 onTouchStart: function(e, el)
405 // e.preventDefault();
407 this.touchmoved = false;
409 if(!this.isFitContainer){
413 if(!this.bgimage.length || !this.html.length){
417 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
419 this.timer = new Date().getTime();
423 onTouchMove: function(e, el)
425 this.touchmoved = true;
428 onContextMenu : function(e,el)
435 onTouchEnd: function(e, el)
437 // e.preventDefault();
439 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
446 if(!this.bgimage.length || !this.html.length){
448 if(this.href.length){
449 window.location.href = this.href;
455 if(!this.isFitContainer){
459 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
461 window.location.href = this.href;