Easter eggs jQuery plugin
I decided that a project I was working in needed more monsters so I created a quick jQuery plugin to add them, have fun.
//Change image
//<div data-swapcss-value='url("imageurl.png")'>
//Full options
//<div data-swapcss-property='background-color' data-swapcss-value='red' data-swapcss-count="3">
var swapCssConfig = {}
var swapCssConfig.currentCount = 0;
(function ($) {
$.fn.swapCSS = function (options) {
var settings = jQuery.extend({
clickCount: 6,
property: 'background-image'
}, options);
var currentElement = this;
currentElement.click(function () {
warningClickCount++;
if (swapCssConfig.currentCount > (settings.clickCount - 1)) {
currentElement.css(settings.property, settings.value);
currentElement.unbind('click');
}
});
};
$(document).ready(function () {
$('[data-swapcss-value]').each(function (index) {
var item = $(this);
var options = { value: item.attr('data-swapcss-value') };
if (item.attr('data-swapcss-count') !== undefined)
options.clickCount = item.attr('data-swapcss-count');
if (item.attr('data-swapcss-property') !== undefined)
options.property = item.attr('data-swapcss-property');
item.swapCSS(options);
});
});
})(jQuery);