*/
Roo.bootstrap.MasonryBrick = function(config){
+
Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
+ Roo.bootstrap.MasonryBrick.register(this);
+
this.addEvents({
// raw events
/**
*/
href : '',
/**
- * @cfg {String} (xs|sm|md|md-left|md-right|tall|wide) size
+ * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
*/
size : 'xs',
/**
- * @cfg {String} (center|bottom) placetitle
+ * @cfg {String} placetitle (center|bottom)
*/
placetitle : '',
*/
isFitContainer : true,
+ /**
+ * @cfg {Boolean} preventDefault defalut false
+ */
+ preventDefault : false,
+
+ /**
+ * @cfg {Boolean} inverse defalut false
+ */
+ maskInverse : false,
+
getAutoCreate : function()
{
if(!this.isFitContainer){
cls += ' masonry-brick-image';
}
- if(!this.html.length){
+ if(this.maskInverse){
+ cls += ' mask-inverse';
+ }
+
+ if(!this.html.length && !this.maskInverse && !this.videourl.length){
cls += ' enable-mask';
}
tag: (this.href.length) ? 'a' : 'div',
cls: cls,
cn: [
+ {
+ tag: 'div',
+ cls: 'masonry-brick-mask'
+ },
{
tag: 'div',
cls: 'masonry-brick-paragraph',
cfg.href = this.href;
}
- var cn = cfg.cn[0].cn;
+ var cn = cfg.cn[1].cn;
if(this.title.length){
cn.push({
cls: 'masonry-brick-text',
html: this.html
});
- }
+ }
+
if (!this.title.length && !this.html.length) {
- cfg.cn[0].cls += ' hide';
+ cfg.cn[1].cls += ' hide';
}
if(this.bgimage.length){
frameborder : 0,
allowfullscreen : true
});
-
-
}
- cfg.cn.push({
- tag: 'div',
- cls: 'masonry-brick-mask'
- });
-
return cfg;
},
} else {
this.el.on('mouseenter' ,this.enter, this);
this.el.on('mouseleave', this.leave, this);
+ this.el.on('click', this.onClick, this);
}
if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
onClick: function(e, el)
{
- if(!Roo.isTouch){
- return;
- }
-
var time = this.endTimer - this.startTimer;
+ // Roo.log(e.preventDefault());
+ if(Roo.isTouch){
+ if(time > 1000){
+ e.preventDefault();
+ return;
+ }
+ }
- //alert(time);
-
- if(time < 1000){
+ if(!this.preventDefault){
return;
}
e.preventDefault();
+
+ if (this.activeClass != '') {
+ this.selectBrick();
+ }
+
+ this.fireEvent('click', this, e);
},
enter: function(e, el)
{
e.preventDefault();
- if(!this.isFitContainer){
+ if(!this.isFitContainer || this.maskInverse || this.videourl.length){
return;
}
{
e.preventDefault();
- if(!this.isFitContainer){
+ if(!this.isFitContainer || this.maskInverse || this.videourl.length){
return;
}
this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
window.location.href = this.href;
- }
+ },
+ //selection on single brick only
+ selectBrick : function() {
+
+ if (!this.parentId) {
+ return;
+ }
+
+ var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
+ var index = m.selectedBrick.indexOf(this.id);
+
+ if ( index > -1) {
+ m.selectedBrick.splice(index,1);
+ this.el.removeClass(this.activeClass);
+ return;
+ }
+
+ for(var i = 0; i < m.selectedBrick.length; i++) {
+ var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
+ b.el.removeClass(b.activeClass);
+ }
+
+ m.selectedBrick = [];
+
+ m.selectedBrick.push(this.id);
+ this.el.addClass(this.activeClass);
+ return;
+ },
+
+ isSelected : function(){
+ return this.el.hasClass(this.activeClass);
+
+ }
});
-
+Roo.apply(Roo.bootstrap.MasonryBrick, {
+
+ //groups: {},
+ groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
+ /**
+ * register a Masonry Brick
+ * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
+ */
+
+ register : function(brick)
+ {
+ //this.groups[brick.id] = brick;
+ this.groups.add(brick.id, brick);
+ },
+ /**
+ * fetch a masonry brick based on the masonry brick ID
+ * @param {string} the masonry brick to add
+ * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
+ */
+
+ get: function(brick_id)
+ {
+ // if (typeof(this.groups[brick_id]) == 'undefined') {
+ // return false;
+ // }
+ // return this.groups[brick_id] ;
+
+ if(this.groups.key(brick_id)) {
+ return this.groups.key(brick_id);
+ }
+
+ return false;
+ }
+
+
+
+});
\ No newline at end of file