Mercurial > wiki
view wiki.js @ 2:1d3d91674bbe
Users must hold down shift while clicking to edit.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 01 Feb 2009 12:51:45 -0800 |
parents | dd457cc7c596 |
children | ac7e15dcee69 |
line wrap: on
line source
function makeEditable(aEvt) { if (!aEvt.shiftKey) return; var item = this; var newItem = $('<textarea class="wikiedit"></textarea>'); $(newItem).attr("value", $(item).html()); function setScrollHeight() { var scrollHeight = $(newItem).get(0).scrollHeight; $(newItem).height(scrollHeight); } $(newItem).blur( function() { var html = $(newItem).attr("value"); $(item).html(html); $(item).click(makeEditable); $(newItem).replaceWith(item); }); $(newItem).keyup(setScrollHeight); $(item).replaceWith(newItem); setScrollHeight(); $(newItem).focus(); } function onLoad() { $(".wiki").click(makeEditable); } $(window).ready(onLoad);