First of all thank you for your valuable comment on the forum. I'm working on a "live" demo 
Ok this is hard to understand with only explanations, here is an example 
HTML Code:
<div id="daDiv" editaction="edit_data.php" editparams="editedArea=theDiv&value=" editcond="isAdmin" edittype="textarea">Some text</div>
First, the editcond is checked, here it just looks the value of the JavaScript variable "isAdmin". If it is true, it allows the user to edit the area. How the user understands he/she can edit the area? The script automatically changes the editable element's class to "editableElement" when the user hovers the cursor on it. So you should define a good looking editableElement class in your CSS. You can enter any JavaScript expression in the editcond parameter for evaluation. But do not forget that you still have to check user rights from serverside.
Then the edittype. If you write 'edittype="textarea"' when the user clicks on the editable element, he/she will see a textarea instead of a textbox which is the default.
Ok, the editaction and the editparams should be considered together I think.
When user edits the text, the scripts makes a POST call like this "edit_data.php?editedArea=theDiv&value=[Newly entered text]" and waits a "1" as a response. If the page sends back a different response, it shows an error message to the user which indicates that the operation was not successful.
OK this was the text part, image part is similar. Let's look at an example again.
HTML Code:
<img id="daImg" editaction="edit_image.php" editparams="imageID=3&image=" editcond="isAdmin" editfade="0.5" />
Actually nearly everything is here. editcond defines whether the user can change the image or not. But this time, to take more attention from the user we add the editfade parameter. When the user gets the cursor over our image if he/she has right to change the image it will both change its class to "editableElement" and will fade to 0.5 opacity(50%).
editaction and editparams are the same as the text based ones, only the response from the page should be different. The script waits a response in the following format:
path=[the path to the new image]
If the response is anyhow different from the above format the script informs the user that the operation has failed, else it sets the images path to the path given in the response.
If there is any unclear point please do not hesitate to ask.
Note: This script also requires the visual_main.js for fade effects. I forgot to mention this in the first post, sorry
Bookmarks