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 masonry-brick-full';
83 cls += ' masonry-brick-link';
86 if(this.bgimage.length){
87 cls += ' masonry-brick-image';
90 if(!this.html.length){
91 cls += ' enable-mask';
95 cls += ' masonry-' + this.size + '-brick';
98 if(this.placetitle.length){
100 switch (this.placetitle) {
102 cls += ' masonry-center-title';
105 cls += ' masonry-bottom-title';
112 if(!this.html.length && !this.bgimage.length){
113 cls += ' masonry-center-title';
116 if(!this.html.length && this.bgimage.length){
117 cls += ' masonry-bottom-title';
122 cls += ' ' + this.cls;
126 tag: (this.href.length) ? 'a' : 'div',
131 cls: 'masonry-brick-paragraph',
137 if(this.href.length){
138 cfg.href = this.href;
141 var cn = cfg.cn[0].cn;
143 if(this.title.length){
146 cls: 'masonry-brick-title',
151 if(this.html.length){
154 cls: 'masonry-brick-text',
158 if (!this.title.length && !this.html.length) {
159 cfg.cn[0].cls += ' hide';
162 if(this.bgimage.length){
165 cls: 'masonry-brick-image-view',
170 if(this.videourl.length){
171 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
172 // youtube support only?
175 cls: 'masonry-brick-image-view',
178 allowfullscreen : true
186 cls: 'masonry-brick-mask'
193 getSplitAutoCreate : function()
195 var cls = 'masonry-brick masonry-brick-split';
197 if(this.href.length){
198 cls += ' masonry-brick-link';
201 if(this.bgimage.length){
202 cls += ' masonry-brick-image';
206 cls += ' masonry-' + this.size + '-brick';
209 switch (this.placetitle) {
211 cls += ' masonry-center-title';
214 cls += ' masonry-bottom-title';
217 if(!this.bgimage.length){
218 cls += ' masonry-center-title';
221 if(this.bgimage.length){
222 cls += ' masonry-bottom-title';
228 cls += ' ' + this.cls;
232 tag: (this.href.length) ? 'a' : 'div',
237 cls: 'masonry-brick-split-head',
241 cls: 'masonry-brick-paragraph',
248 cls: 'masonry-brick-split-body',
254 if(this.href.length){
255 cfg.href = this.href;
258 if(this.title.length){
259 cfg.cn[0].cn[0].cn.push({
261 cls: 'masonry-brick-title',
266 if(this.html.length){
269 cls: 'masonry-brick-text',
274 if(this.bgimage.length){
277 cls: 'masonry-brick-image-view',
282 if(this.videourl.length){
283 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
284 // youtube support only?
285 cfg.cn[0].cn.cn.push({
287 cls: 'masonry-brick-image-view',
290 allowfullscreen : true
297 initEvents: function()
332 this.el.on('touchstart', this.onTouchStart, this);
333 this.el.on('touchmove', this.onTouchMove, this);
334 this.el.on('touchend', this.onTouchEnd, this);
335 this.el.on('contextmenu', this.onContextMenu, this);
337 this.el.on('mouseenter' ,this.enter, this);
338 this.el.on('mouseleave', this.leave, this);
341 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
342 this.parent().bricks.push(this);
347 onClick: function(e, el)
353 var time = this.endTimer - this.startTimer;
364 enter: function(e, el)
368 if(!this.isFitContainer){
372 if(this.bgimage.length && this.html.length){
373 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
377 leave: 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, true);
390 onTouchStart: function(e, el)
392 // e.preventDefault();
394 this.touchmoved = false;
396 if(!this.isFitContainer){
400 if(!this.bgimage.length || !this.html.length){
404 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
406 this.timer = new Date().getTime();
410 onTouchMove: function(e, el)
412 this.touchmoved = true;
415 onContextMenu : function(e,el)
422 onTouchEnd: function(e, el)
424 // e.preventDefault();
426 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
433 if(!this.bgimage.length || !this.html.length){
435 if(this.href.length){
436 window.location.href = this.href;
442 if(!this.isFitContainer){
446 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
448 window.location.href = this.href;