Mercurial > wiki
comparison wiki.js @ 3:ac7e15dcee69
Activate edits on mousedown instead of click to prevent default selection behavior.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 01 Feb 2009 12:53:25 -0800 |
parents | 1d3d91674bbe |
children | 01313b55ed09 |
comparison
equal
deleted
inserted
replaced
2:1d3d91674bbe | 3:ac7e15dcee69 |
---|---|
1 function makeEditable(aEvt) { | 1 function makeEditable(aEvt) { |
2 if (!aEvt.shiftKey) | 2 if (!aEvt.shiftKey) |
3 return; | 3 return; |
4 | |
5 aEvt.preventDefault(); | |
4 | 6 |
5 var item = this; | 7 var item = this; |
6 var newItem = $('<textarea class="wikiedit"></textarea>'); | 8 var newItem = $('<textarea class="wikiedit"></textarea>'); |
7 $(newItem).attr("value", $(item).html()); | 9 $(newItem).attr("value", $(item).html()); |
8 | 10 |
13 | 15 |
14 $(newItem).blur( | 16 $(newItem).blur( |
15 function() { | 17 function() { |
16 var html = $(newItem).attr("value"); | 18 var html = $(newItem).attr("value"); |
17 $(item).html(html); | 19 $(item).html(html); |
18 $(item).click(makeEditable); | 20 $(item).mousedown(makeEditable); |
19 $(newItem).replaceWith(item); | 21 $(newItem).replaceWith(item); |
20 }); | 22 }); |
21 | 23 |
22 $(newItem).keyup(setScrollHeight); | 24 $(newItem).keyup(setScrollHeight); |
23 $(item).replaceWith(newItem); | 25 $(item).replaceWith(newItem); |
25 | 27 |
26 $(newItem).focus(); | 28 $(newItem).focus(); |
27 } | 29 } |
28 | 30 |
29 function onLoad() { | 31 function onLoad() { |
30 $(".wiki").click(makeEditable); | 32 $(".wiki").mousedown(makeEditable); |
31 } | 33 } |
32 | 34 |
33 $(window).ready(onLoad); | 35 $(window).ready(onLoad); |