Skip to content

Instantly share code, notes, and snippets.

@justinobney
Created May 31, 2012 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinobney/2845570 to your computer and use it in GitHub Desktop.
Save justinobney/2845570 to your computer and use it in GitHub Desktop.
JS: MelloBar // HelloBar Rip Off via jQuery
/*
Author: Justin Obney
Website: http://justinobney.com
Example: http://jsfiddle.net/justinobney/aeyqR/
*/
;
(function($, window, undefined) {
var pluginName = 'mellowBar',
document = window.document,
defaults = {
message: "Hello Mello",
css: {}
};
function Plugin(element, options) {
this.element = element;
this.options = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
applyCSS();
}
Plugin.prototype.init = function() {
// Place initialization logic here
// You already have access to the DOM element and the options via the instance,
// e.g., this.element and this.options
var mello_bar_HTML = [
'<div style="display: block; " class="mellobar-wrapper">',
'<div class="mellobar-container texture">',
'<h2>' + this.options.message + '</h2>',
'<div class="mellobar-shadow"></div>',
'</div>',
'</div>'
];
mello_bar_compiled = mello_bar_HTML.join('');
$(this.element).prepend(mello_bar_compiled);
};
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function(options) {
return this.each(function() {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
}
});
};
function applyCSS() {
$('.mellobar-container').css({
'font-family': 'Georgia,Times New Roman,Times,serif',
'background': '#0072BD',
'color': 'white',
'font-size': '14px',
'font-weight': 'normal',
'height': '30px',
'line-height': '30px',
'margin': '0',
'overflow': 'visible',
'padding': '0',
'position': 'relative',
'text-align': 'center',
'width': '100%',
'z-index': '1000',
'border-bottom-width': '3px',
'border-bottom-style': 'solid',
'border-bottom-color': '#000'
});
$('.mellobar-container.texture').css({
'background-image': 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAcCAYAAADm63ZmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlY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p8uOVj/YpUtGJAvLy/Sd0+0RvY+GrNbpJO+fRMTE2RpackD7egnEAwA+AD8u7u7P09OTrrQIFwEz48bxFOh0AX29/dRJgXGyXNzc24u/pzHx8e/APkrk9nb20tG/WzjoaGhH2DOD3EUPDg48B0eHqaAXDK8wT8CtjFPOS4vL3/zer2/Ax0DteP59fXVZrfbv8B4BZRtgJwdNkz3eDwlkAw/QY35F+RwlzuAv9va2v7q7+9Xzs7OgvHx8X/A2kSYf3o/+D0cZMvtdv+ZlJRkg8PjYUoBMLIfUQb+Rz4oirIL9CxtXaBGKFDV3Xl5eR7Y0A4tLwEBBZq815WVlc9FRUWfoVLb4A+Fq7S01AvzDurmrzIh2PA6JibmCk8J3nWCQd6I96oYCAQUkA8B/gKHu3y/smjwnjctLS0SvASu+epCkMED/kOssut7/VsmWNigZcgRpW1UVFSOaCHKS9reHH6z6Ohotbi4WOM3NjYajcoRGfmfAAMA/0VH1CJk/I4AAAAASUVORK5CYII=)',
'background-repeat': 'repeat-x',
'background-position': '0 3px'
});
$('.mellobar-wrapper').css({
'height': '30px',
'margin': '0 0 10px',
'overflow': 'visible',
'padding': '0',
'position': 'relative',
'width': '100%',
'z-index': '2'
});
$('.mellobar-shadow').css({
'position': 'absolute',
'bottom': '-8px',
'left': '0',
'width': '100%',
'height': '8px',
'line-height': '8px',
'overflow': 'hidden'
});
$('.mellobar-wrapper H2').css({
'font-size': '20px'
});
}
}(jQuery, window));
/*
----- usage: -----
$('body').mellowBar();
$('#posBottom').mellowBar({
message: 'Some Other Message'
});
​------------------
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment