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 this.getSplitAutoCreate();
81 var cls = 'masonry-brick';
84 cls += ' masonry-brick-link';
87 if(this.bgimage.length){
88 cls += ' masonry-brick-image';
92 cls += ' masonry-' + this.size + '-brick';
95 if(this.placetitle.length){
97 switch (this.placetitle) {
99 cls += ' masonry-center-title';
102 cls += ' masonry-bottom-title';
109 if(!this.html.length && !this.bgimage.length){
110 cls += ' masonry-center-title';
113 if(!this.html.length && this.bgimage.length){
114 cls += ' masonry-bottom-title';
119 cls += ' ' + this.cls;
123 tag: (this.href.length) ? 'a' : 'div',
128 cls: 'masonry-brick-paragraph',
134 if(this.href.length){
135 cfg.href = this.href;
138 var cn = cfg.cn[0].cn;
140 if(this.title.length){
143 cls: 'masonry-brick-title',
148 if(this.html.length){
151 cls: 'masonry-brick-text',
155 if (!this.title.length && !this.html.length) {
156 cfg.cn[0].cls += ' hide';
159 if(this.bgimage.length){
162 cls: 'masonry-brick-image-view',
166 if(this.videourl.length){
167 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
168 // youtube support only?
171 cls: 'masonry-brick-image-view',
174 allowfullscreen : true
183 getSplitAutoCreate : function()
185 Roo.log('run????????!!!!!!!!!!!!!!!!!!');
187 var cls = 'masonry-brick';
189 if(this.href.length){
190 cls += ' masonry-brick-link';
193 if(this.bgimage.length){
194 cls += ' masonry-brick-image';
198 cls += ' masonry-' + this.size + '-brick';
201 switch (this.placetitle) {
203 cls += ' masonry-center-title';
206 cls += ' masonry-bottom-title';
209 if(!this.bgimage.length){
210 cls += ' masonry-center-title';
213 if(this.bgimage.length){
214 cls += ' masonry-bottom-title';
220 cls += ' ' + this.cls;
224 tag: (this.href.length) ? 'a' : 'div',
229 cls: 'masonry-brick-paragraph',
235 if(this.href.length){
236 cfg.href = this.href;
239 var cn = cfg.cn[0].cn;
241 if(this.title.length){
244 cls: 'masonry-brick-title',
249 if(this.html.length){
252 cls: 'masonry-brick-text',
256 if (!this.title.length && !this.html.length) {
257 cfg.cn[0].cls += ' hide';
260 if(this.bgimage.length){
263 cls: 'masonry-brick-image-view',
267 if(this.videourl.length){
268 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
269 // youtube support only?
272 cls: 'masonry-brick-image-view',
275 allowfullscreen : true
284 initEvents: function()
327 this.el.on('touchstart', this.onTouchStart, this);
328 this.el.on('touchmove', this.onTouchMove, this);
329 this.el.on('touchend', this.onTouchEnd, this);
330 this.el.on('contextmenu', this.onContextMenu, this);
332 this.el.on('mouseenter' ,this.enter, this);
333 this.el.on('mouseleave', this.leave, this);
336 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
337 this.parent().bricks.push(this);
342 onClick: function(e, el)
348 var time = this.endTimer - this.startTimer;
359 enter: function(e, el)
363 if(this.bgimage.length && this.html.length){
364 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
368 leave: function(e, el)
372 if(this.bgimage.length && this.html.length){
373 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
377 onTouchStart: function(e, el)
379 // e.preventDefault();
381 this.touchmoved = false;
383 if(!this.bgimage.length || !this.html.length){
387 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
389 this.timer = new Date().getTime();
393 onTouchMove: function(e, el)
395 this.touchmoved = true;
398 onContextMenu : function(e,el)
405 onTouchEnd: function(e, el)
407 // e.preventDefault();
409 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
416 if(!this.bgimage.length || !this.html.length){
418 if(this.href.length){
419 window.location.href = this.href;
425 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
427 window.location.href = this.href;