// Sticky v1.0 by Daniel Raftery // http://thrivingkings.com/sticky // http://twitter.com/ThrivingKings ;(function($) { // Using it without an object $.sticky = function(note, options, callback) { return $.fn.sticky(note, options, callback); }; $.fn.sticky = function(note, options, callback) { var settings = { 'speed' : 'fast', // animations: fast, slow, or integer 'duplicates' : false, // true or false 'autoclose' : 5000, // integer or false 'position' : 'top-right', // top-center, top-left, top-right, bottom-left, or bottom-right 'type' : '' // st-success, st-info, st-error }; if(options) { $.extend(settings, options); } // Passing in the object instead of specifying a note if(!note) { note = this.html(); } // Variables var display = true, duplicate = 'no'; // Somewhat of a unique ID var uniqID = Math.floor(Math.random()*99999); // Handling duplicate notes and IDs $('.sticky-note').each(function() { if($(this).html() == note && $(this).is(':visible')) { duplicate = 'yes'; if(!settings['duplicates']) { display = false; } } if($(this).attr('id')==uniqID) { uniqID = Math.floor(Math.random()*9999999); } }); // Make sure the sticky queue exists if(!$('body').find('.sticky-queue.'+settings.position).html()) { $('body').append('
'); } // Can it be displayed? if(display) { // Building and inserting sticky note $('.sticky-queue.'+settings.position).prepend(''); $('#' + uniqID).append('×'); $('#' + uniqID).append('