Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

javascript help

edited July 2006 in Vanilla 1.0 Help
hey can someone edit this edit in place so the person has to hold their mouse down for 3 seconds before it will work

Event.observe(window, 'load', init, false); function init(){ makeEditable('desc'); makeEditable('pizza'); } function makeEditable(id){ Event.observe(id, 'mousedown', function(){edit($(id))}, false); Event.observe(id, 'mouseover', function(){showAsEditable($(id))}, false); Event.observe(id, 'mouseout', function(){showAsEditable($(id), true)}, false); } function edit(obj){ Element.hide(obj); var textarea = '<div id="''_editor"><textarea id="''_edit" name="''" rows="4" cols="60">'+obj.innerHTML+'</textarea>'; var button = '<div class="save"><input id="''_cancel" type="button" value="CANCEL" /><input id="''_save" type="button" value="SAVE" /></div></div>'; new Insertion.After(obj, textarea+button); Event.observe('_save', 'click', function(){saveChanges(obj)}, false); Event.observe('_cancel', 'click', function(){cleanUp(obj)}, false); } function showAsEditable(obj, clear){ if (!clear){ Element.addClassName(obj, 'editable'); }else{ Element.removeClassName(obj, 'editable'); } } function saveChanges(obj){ var new_content = escape($F('_edit')); obj.innerHTML = "Saving..."; cleanUp(obj, true); var success = function(t){editComplete(t, obj);} var failure = function(t){editFailed(t, obj);} var url = 'edit.php'; var pars = 'id=''&content='+new_content; var myAjax = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:success, onFailure:failure}); } function cleanUp(obj, keepEditable){ Element.remove('_editor');; if (!keepEditable) showAsEditable(obj, true); } function editComplete(t, obj){ obj.innerHTML = t.responseText; showAsEditable(obj, true); } function editFailed(t, obj){ obj.innerHTML = 'Sorry, the update failed.'; cleanUp(obj); }
This discussion has been closed.