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
56 * @cfg {String} (xs|sm|md|md-left|md-right|tall|wide) size
61 * @cfg {String} (center|bottom) placetitle
65 getAutoCreate : function()
67 var cls = 'masonry-brick';
70 cls += ' masonry-brick-link';
73 if(this.bgimage.length){
74 cls += ' masonry-brick-image';
78 cls += ' masonry-' + this.size + '-brick';
81 if(this.placetitle.length){
83 switch (this.placetitle) {
85 cls += ' masonry-center-title';
88 cls += ' masonry-bottom-title';
95 if(!this.html.length && !this.bgimage.length){
96 cls += ' masonry-center-title';
99 if(!this.html.length && this.bgimage.length){
100 cls += ' masonry-bottom-title';
105 cls += ' ' + this.cls;
109 tag: (this.href.length) ? 'a' : 'div',
114 cls: 'masonry-brick-paragraph',
120 if(this.href.length){
121 cfg.href = this.href;
124 var cn = cfg.cn[0].cn;
126 if(this.title.length){
129 cls: 'masonry-brick-title',
134 if(this.html.length){
137 cls: 'masonry-brick-text',
142 if(this.bgimage.length){
145 cls: 'masonry-brick-image-view',
154 initEvents: function()
191 this.el.on('touchstart', this.onTouchStart, this);
192 this.el.on('touchmove', this.onTouchMove, this);
193 this.el.on('touchend', this.onTouchEnd, this);
195 this.el.on('mouseenter' ,this.enter, this);
196 this.el.on('mouseleave', this.leave, this);
199 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
200 this.parent().bricks.push(this);
205 onClick: function(e, el)
213 var time = this.endTimer - this.startTimer;
224 enter: function(e, el)
228 if(this.bgimage.length && this.html.length){
229 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
233 leave: function(e, el)
237 if(this.bgimage.length && this.html.length){
238 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
242 onTouchStart: function(e, el)
244 // e.preventDefault();
246 if(!this.bgimage.length || !this.html.length){
250 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
252 this.timer = new Date().getTime();
254 this.touchmoved = false;
257 onTouchMove: function(e, el)
259 this.touchmoved = true;
262 onTouchEnd: function(e, el)
264 // if(!this.touchmoved){
268 if(!this.bgimage.length || !this.html.length){
270 if(this.href.length){
271 window.location.href = this.href;
277 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
279 alert(this.touchmoved ? 'yes' : 'no');
281 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
285 window.location.href = this.href;