Skip to content

Instantly share code, notes, and snippets.

@jordanthomas
Created December 13, 2012 21:05
Show Gist options
  • Save jordanthomas/4279862 to your computer and use it in GitHub Desktop.
Save jordanthomas/4279862 to your computer and use it in GitHub Desktop.
Deal With It for the web
(function ( $, window, document, undefined ) {
var pluginName = 'dealWithIt',
defaults = {
speed: 7000
};
function DealWithIt( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = pluginName;
this.$body = $('body').first();
this.$image = $('<img alt="DEAL WITH IT" width="674" height="106" src="data:image/gif;base64,R0lGODlhogJqAOZ2AGpqanBwcHR0dAwMDHNzc25ubnFxcW9vb2lpaQ8PD0RERF9fX1xcXEJCQigoKF1dXSYmJioqKmtra0FBQSsrK2FhYQcHBy0tLWNjYz4+PkBAQGxsbG1tbQsLCwkJCS8vLzs7OycnJ3JycmVlZQEBATIyMgUFBUdHRxERETk5OSQkJHZ2diwsLA0NDVlZWSkpKRAQEHV1dXp6enx8fGZmZnh4eAgICEhISEVFRQ4ODj8/P0ZGRiUlJQICAnl5eS4uLnt7e35+fmdnZ15eXnd3dzAwMICAgElJSRISEoGBgUxMTFdXV0pKSgQEBDMzMwYGBjw8PGRkZH19fTc3Nzo6OgoKChgYGENDQzU1NRYWFlpaWhMTE2JiYlVVVSEhITg4OD09PRwcHB8fHwMDAyIiImBgYEtLS01NTR0dHTExMX9/f1hYWFRUVE9PT1JSUjQ0NBcXFzY2NiAgIBsbG2hoaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjEgNjQuMTQwOTQ5LCAyMDEwLzEyLzA3LTEwOjU3OjAxICAgICAgICAiPiA8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HXN8/2Ano+9v2gRetaN/hKlP33qV9/6LQ+V87IP/kxAb7nBYU4TuUe9pFTP+r2/E/jCj75XiC/mPB0/E8nfffNd//y+S//7hLhF7Y3fOtKbXvmHYn7vY0xU6IMf/OIvvkqvb37dL5/3znen+98v/fhXv0n0h3vnp33rJ1RgtX/8J3z+Z1hPFYCWkH33t32+t3nel4DRt4AF44CVAIHph3/cp38VaIHBh4ExwwkcGCjql3+9hIAi6HkkKHomOIARWIBfdYAh2IIuSP99DNhcGkgJJ4gnKfiBK3iDOPh3L2h7MWh/HSiB7Pd7RFiEYneE5Hd7DyiDS0iDluWEsAeFICeF81d+AqiEKOiBE/h6mcOFUWgLFFAGkIZqwHMhDUCFlcADWrACHOCGAGAAInADWAhfNriFaBhoONI/bEcAhniIiIiIA3QDHaIJDoABSUAEiTiJiAgEM9AGXyeEvMSCgchttwABSwAAFbAApFiKpniKQjACUNABnOAFbgAAXHCKsmiKNCAEEzBQZdh9gNiJ8NcJKBACRcACPjeMxFiMFPADFzAHjpcJCcADwWiM0OhzP/ADaDBsy8CL2JiNcbaL2tiN3nhZT/iN4jh/jloYN+R4jugIgmeYjuzYjlQTju4Yj/J4LPA4j/Z4jwRSj/i4j/z4WuvYjwAZkCqhjwJZkAY5DAR5kAq5kOHHjQz5kAqZkBA5kQApkRR5kfdokRi5ke6okRz5kefokSA5kt4okiR5krxokii5klCokiz5khbokjA5kzRZkx8ZCAA7">');
this.$deal = $('<div>DEAL WITH IT</div>');
this.imageStyles = {
position: 'fixed',
top: '-106px',
left: '0',
}
this.dealStyles = {
position: 'fixed',
bottom: '10px',
width: '100%',
textAlign: 'center',
fontSize: '80px',
color: '#000',
fontWeight: 'bold'
}
this.init();
}
DealWithIt.prototype.init = function () {
this.$image.css(this.imageStyles);
this.$body.append(this.$image);
this.$deal.css(this.dealStyles);
this.animate();
};
DealWithIt.prototype.animate = function () {
var top, left, width, self;
self = this;
top = $(window).height() / 2.5;
left = $(window).width() / 2;
width = this.$image.width() / 2;
height = this.$image.height() / 2;
this.$image.css({
left: left - width
});
this.$image.animate({
top: top - height
}, this.options.speed, function() {
self.$body.append(self.$deal);
});
};
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName,
new DealWithIt( this, options ));
}
});
}
})( jQuery, window, document );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment