/* HTML5STICKY (http://github.com/sarfraznawaz2005/HTML5Sticky) ================================================================ Author : Sarfraz Ahmed (sarfraznawaz2005@gmail.com) Twitter : @sarfraznawaz Blog : http://sarfraznawaz.wordpress.com/ LICENSE : MIT ================================================================ */ var stickywidth = 200; // width of sticky note (can't be less than 200) var stickyheight = 200; // height of sticky note (can't be less than 200) var max_notes = 500; // maximum number of notes one can store var allowed_tags = '

  1. '; var html5sticky = {}; var note_index = 0; // add a note html5sticky.addNote = function(){ // count total present notes var tnotes = $('.note_common').length; if (tnotes === max_notes){ html5sticky.showMessage('#FFE16B', 'black', 'You can not add any more notes, please delete some to add more.'); return false; } // unique localstorage identifier for this sticky note var nindex = ++note_index + 'stickynote'; var dated = html5sticky.getDateTime(); var dateStr = new Date(); // get random color var bgcolor = html5sticky.getColor(); var stickynote = $('
    ').appendTo($('#main')); // add tape to stickynote html5sticky.addPin(stickynote); $(stickynote).append($('

    ' + dated + '

    ')); $(stickynote).append($('

    Text here...

    ')); // append identifier $(stickynote).append($('')); // set width and height of the sticky note $('.note_common').css({width: stickywidth + 'px', height:stickyheight + 'px'}); $('.note_common p').css({height:(stickyheight - 60) + 'px', width:(stickywidth + 9) + 'px'}); if (! $("#removenotes").is(':visible')){ $('#removenotes').slideDown('slow'); } //$(stickynote).find('h2').attr('contentEditable', true); //$(stickynote).find('p').attr('contentEditable', true); // add utility buttons //html5sticky.addUtilityButtons(stickynote); // scroll to newly added sticky note $('html, body').animate({ scrollTop:$(stickynote).offset().top }); // store note info local storage if (Modernizr.localstorage){ localStorage.setItem(nindex, nindex); localStorage.setItem(nindex + '|pos', parseInt($(stickynote).offset().left, 10) + '|' + parseInt($(stickynote).offset().top, 10)); localStorage.setItem(nindex + '|text', $(stickynote).find('h2').text() + '|' + $(stickynote).find('p').text()); localStorage.setItem(nindex + '|bgcolor', bgcolor); localStorage.setItem(nindex + '|dated', dated + '|' + html5sticky.getISODateTime(dateStr)); } else { html5sticky.nohtml5(); } }; // no html5 ? html5sticky.nohtml5 = function(){ html5sticky.showMessage('#FFE16B', 'black', 'Your browser does not support html5, please upgrade your browser.'); }; // adds utility buttons on note footer html5sticky.addUtilityButtons = function(el){ $el = $(el); $el.append('