[opencms-dev] javascript

Jonathan Woods jonathan.woods at scintillance.com
Fri Mar 10 06:53:19 CET 2006


Yes, it is, and it's injected when you use <cms:editable />.

Jon 

-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Christian Steinert
Sent: 09 March 2006 20:43
To: The OpenCms mailing list
Subject: Re: [opencms-dev] javascript

Christoph Kukulies wrote:
> In my page (offline) I see a section of javascrip code injected which 
> appears twice in the page source.
>
> What portion or statement is responsible for this javascript 
> insertion?
>
> It is the following piece of code:
> <script type="text/javascript">
> <!--
> window.onresize = showButtonsOcms;
> document.onkeyup = keyUpOcms;
>
> var deButtonsOcms = new Array();
> var ocms_btTimeout;
> var visibleOcmsButtons = true;
>
> function activateOcms(id) {
> 	var el = document.getElementById(id);
> 	if (el.className == "ocms_de_norm") {
> 		el.className = "ocms_de_over";
> 	}
> 	var bt = document.getElementById("bt_" + id);
> 	if (bt != null) {
> 		bt.style.backgroundImage =
"url(/resources/buttons/directedit_op.png)";
> 	}
>
> }
> function deactivateOcms(id) {
> 	var el = document.getElementById(id);
> 	if (el.className == "ocms_de_over") {
> 		el.className = "ocms_de_norm";
> 	}
> 	var bt = document.getElementById("bt_" + id);
> 	if (bt != null) {
> 		bt.style.backgroundImage =
"url(/resources/buttons/directedit_cl.png)";
> 	}
> }
> function submitOcms(id, action, link) {
> 	var form = document.getElementById("form_" + id);
> 	if (form != null) {
> 		if (action == "edit") {
> 			form.submit();
> 			return;
> 		} else if (action == "delete") {
> 			form.action =
"/system/workplace/commons/delete.jsp";
> 			form.closelink.value = "/de/testindex.html";

> 			form.submit();
> 			return;
> 		} else if (action == "new") {	
> 			form.editortitle.value = "Editing (new resource)";

> 			form.newlink.value = link;	
> 			form.submit();
> 			return;
> 		}
> 	}
> 	alert("Unknown form action [" + id + "/" + action + "]"); } function

> registerButtonOcms(id) {
> 	deButtonsOcms[deButtonsOcms.length] = id; 
> 	clearTimeout(ocms_btTimeout);
> 	ocms_btTimeout = setTimeout("showButtonsOcms()", 400); }
> function showButtonsOcms() {	
> 		
> 	var visStyle = "visible";
> 	if (!visibleOcmsButtons) {
> 		visStyle = "hidden";
> 	}
> 		
> 	for (var i = 0; i<deButtonsOcms.length; i++) {
> 		var btid = deButtonsOcms[i];
> 		var deDiv = document.getElementById(btid);
> 		var deButton = document.getElementById("buttons_" + btid);
> 		var deTable = document.getElementById("table_" + btid);
> 		var x = findPosXOcms(deDiv);
> 		var y = findPosYOcms(deDiv);
> 		var w1 = deDiv.offsetWidth; // width of surrounding div
> 		var w2 = deTable.offsetWidth; // width of button table
> 		
> 		x += (w1 - w2);		
> 		deButton.style.left = x + "px";
> 		deButton.style.top =  y + "px";				
> 		deButton.style.visibility = visStyle;
> 	}
> }
> function findPosXOcms(obj) {
>     var curleft = 0; 
>     if (obj.offsetParent) {
>         while (obj.offsetParent) {
>             curleft += obj.offsetLeft - obj.scrollLeft; 
>             obj = obj.offsetParent; 
>         } 
>     } else if (obj.x) {
>         curleft += obj.x; 
>     }
>     return curleft;
> }
> function findPosYOcms(obj) {
>     var curtop = 0; 
>     if (obj.offsetParent) {
>         while (obj.offsetParent) { 
>             curtop += obj.offsetTop - obj.scrollTop; 
>             obj = obj.offsetParent; 
>         }
>     } else if (obj.y) {
>         curtop += obj.y;
>     }
>     return curtop;
> }
> function toggleVisibleOcms() {
> 	if (visibleOcmsButtons) {
> 		visibleOcmsButtons = false;
> 	} else {
> 		visibleOcmsButtons = true;
> 	}
> 	showButtonsOcms();
> }
> function keyUpOcms(evt) {
> 	if (!evt) {
> 		evt = window.event;
> 	}
> 	if ((evt.type == "keyup") && (evt.keyCode == 32) && evt.ctrlKey) {
> 		toggleVisibleOcms();
> 	}
> }
> //-->
> </script>
>
>   
I am only guessing, but it looks very much  as if it is connected with the
online editing feature, isn't it?

Christian

_______________________________________________
This mail is sent to you from the opencms-dev mailing list To change your
list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev





More information about the opencms-dev mailing list