github.com/tybenz // @tybenz // tybenz.com
Blackbox
Framework-based
The Sweet Spot
Blackbox
Framework-based
The Sweet Spot
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
$.fn.secret = function() {
return this.each(function() {
var $this = $( this );
$this.on( 'mousedown', function() {
$this.addClass( 'show' );
});
$this.on( 'mouseup', function() {
$this.removeClass( 'show' );
});
});
};
$( '#secret' ).secret();
Blackbox
Framework-based
The Sweet Spot
Blackbox
Framework-based
The Sweet Spot
var Secret = Backbone.View.extend({
events: {
'mousedown': 'apply',
'mouseup': 'remove'
},
apply: function() {
this.$el.addClass( 'show' )
},
remove: function() {
this.$el.removeClass( 'show' )
}
});
var Secret = Backbone.View.extend({
events: {
'mousedown': 'apply',
'mouseup': 'remove'
},
apply: function() {
this.$el.addClass( 'show' )
},
remove: function() {
this.$el.removeClass( 'show' )
}
});
var Secret = Backbone.View.extend({
events: {
'mousedown': 'apply',
'mouseup': 'remove'
},
apply: function() {
this.$el.addClass( 'show' )
},
remove: function() {
this.$el.removeClass( 'show' )
}
});
Blackbox
Framework-based
The Sweet Spot
Blackbox
Framework-based
The Sweet Spot
☐ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
☐ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
☐ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
☐ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
$.extend( Secret.prototype, widgetMethods, {
defaultOptions: {
applyClass: 'show',
applyEvent: 'mousedown',
removeEvent: 'mouseup'
},
apply: function() {
this.$el.addClass( this.options.applyClass );
},
remove: function() {
this.$el.removeClass( this.options.applyClass );
}
});
$.extend( Secret.prototype, widgetMethods, {
defaultOptions: {
applyClass: 'show',
applyEvent: 'mousedown',
removeEvent: 'mouseup'
},
apply: function() {
this.$el.addClass( this.options.applyClass );
},
remove: function() {
this.$el.removeClass( this.options.applyClass );
}
});
$.extend( Secret.prototype, widgetMethods, {
defaultOptions: {
applyClass: 'show',
applyEvent: 'mousedown',
removeEvent: 'mouseup'
},
apply: function() {
this.$el.addClass( this.options.applyClass );
},
remove: function() {
this.$el.removeClass( this.options.applyClass );
}
});
var Secret = function( el, options ) {
var widget = this;
this.$el = $( el );
this.options = $.extend( {}, this.defaultOptions, options );
this.$el.on( this.options.applyEvent, function() {
widget.apply();
widget.trigger( 'secret-apply' );
});
this.$el.on( this.options.removeEvent, function() {
widget.remove();
widget.trigger( 'secret-remove' );
});
};
var Secret = function( el, options ) {
var widget = this;
this.$el = $( el );
this.options = $.extend( {}, this.defaultOptions, options );
this.$el.on( this.options.applyEvent, function() {
widget.apply();
widget.trigger( 'secret-apply' );
});
this.$el.on( this.options.removeEvent, function() {
widget.remove();
widget.trigger( 'secret-remove' );
});
};
var Secret = function( el, options ) {
var widget = this;
this.$el = $( el );
this.options = $.extend( {}, this.defaultOptions, options );
this.$el.on( this.options.applyEvent, function() {
widget.apply();
widget.trigger( 'secret-apply' );
});
this.$el.on( this.options.removeEvent, function() {
widget.remove();
widget.trigger( 'secret-remove' );
});
};
var Secret = function( el, options ) {
var widget = this;
this.$el = $( el );
this.options = $.extend( {}, this.defaultOptions, options );
this.$el.on( this.options.applyEvent, function() {
widget.apply();
widget.trigger( 'secret-apply' );
});
this.$el.on( this.options.removeEvent, function() {
widget.remove();
widget.trigger( 'secret-remove' );
});
};
var Secret = function( el, options ) {
var widget = this;
this.$el = $( el );
this.options = $.extend( {}, this.defaultOptions, options );
this.$el.on( this.options.applyEvent, function() {
widget.apply();
widget.trigger( 'secret-apply' );
});
this.$el.on( this.options.removeEvent, function() {
widget.remove();
widget.trigger( 'secret-remove' );
});
};
☐ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
☒ Options
☐ Browser/User Events
☐ Widget logic
☐ External events
☒ Options
☒ Browser/User Events
☐ Widget logic
☐ External events
☒ Options
☒ Browser/User Events
☒ Widget logic
☐ External events
☒ Options
☒ Browser/User Events
☒ Widget logic
☒ External events
var secret1 = new Secret( $( '#window1' ) ),
secret2 = new Secret( $( '#window2' ) );
secret1.on( 'secret-apply', function() {
secret2.apply();
});
secret1.on( 'secret-remove', function() {
secret2.remove();
});
var secret1 = new Secret( $( '#window1' ) ),
secret2 = new Secret( $( '#window2' ) );
secret1.on( 'secret-apply', function() {
secret2.apply();
});
secret1.on( 'secret-remove', function() {
secret2.remove();
});
var secret1 = new Secret( $( '#window1' ) ),
secret2 = new Secret( $( '#window2' ) );
secret1.on( 'secret-apply', function() {
secret2.apply();
});
secret1.on( 'secret-remove', function() {
secret2.remove();
});
$( '.window' ).each( function() {
var secret = new Secret( this, {
applyEvent: 'mouseover',
removeEvent: 'mouseout'
});
});
$( '.window' ).each( function() {
var secret = new Secret( this, {
applyEvent: 'mouseover',
removeEvent: 'mouseout'
});
});
$( '.window' ).each( function() {
var secret = new Secret( this, {
applyEvent: 'mouseover',
removeEvent: 'mouseout'
});
});
$( '.window' ).each( function() {
var secret = new Secret( this, {
applyEvent: 'mouseover',
removeEvent: 'mouseout'
});
});
$( '.window' ).each( function() {
var secret = new Secret( this, {
applyEvent: 'mouseover',
removeEvent: 'mouseout'
});
});
☒ Options
☒ Browser/User Events
☒ Widget logic
☒ External events
github.com/tybenz // @tybenz // tybenz.com