addClassName will add a CSS class to the specified element. A class attribute does not have to be on the element. If the element has an existing class applied, this function will add it to the element, not replace it.
Spry.Utils.addClassName(element,classname);
element
classname
<style type="text/css">
<!--
.dada {
background-color: #FFCC33;
}
-->
</style> <script> function setClass(ele,class){
Spry.Utils.addClassName(ele,class);
} </script> <a href="#" onclick="setClass('content','dada');">Add Class</a> <div id="content">Change This Text</div>
addEventListener registers a non-destructive event handler on the specified element. See also removeEventListener.
Spry.Utils.addEventListener = function(element, eventType, handler, capture)
element
eventType
handler
capture
<div id="myDiv">Click me!</div> ... <script type="text/javascript> function myClickHandler(event) { alert("myClickHandler was called!"); } Spry.Utils.addEventListener("myDiv", "click", myClickHandler, false); </script>
addLoadListener add non-destructive event listener to the onLoad event.
Spry.Utils.addLoadListener = function(handler)
Handler
Spry.Utils.addLoadListener(function() { setTimeout(function() { Spry.Data.initRegions(); }, 0); });
Call this method from your JS function when you don't want the JS expression to access or interfere with any local variables in your JS function. A standard js eval.
Spry.Utils.eval(string);
String
Spry.Utils.eval("alert('Run Eval');";
Returns the text of the specified Element
Spry.Utils.getNodeText(elementID);
elementiD
<script>
function getText(node){
var x = Spry.Utils.getNodeText(node)
alert(x);
}
</script>
<p><a href="#" onclick="getText('removeMe');">Get Inner Text</a></p>
<div id="removeMe">This is the Inner Text</div>
loadURL gets the actual XMLHTTPRequest to the server and handles the returned value.
Spry.Utils.loadURL = function(method, url, async, callback, opts)
method
url
async
N/A
var req = Spry.Utils.loadURL("GET", "/app/book.php?id=1&code=54321", true);
removeClassName will remove a CSS class to the specified element. A class attribute does not have to be defined on the element, it can remove a class that has been set with addClassName(). If the element has an existing class applied, this function will remove the class name to the element.
Spry.Utils.removeClassName(element,classname);
element
classname
<style type="text/css">
<!--
.dada {
background-color: #FFCC33;
}
-->
</style> <script> function removeClass(ele,class){
Spry.Utils.removeClassName(ele,class);
} </script> <a href="#" onclick="removeClass('content','dada');">Remove Class</a> <div id="content" class="dada">Change This Text</div>
removeEventListener removes the non-destructive event listener specified. See addEventListener
Spry.Utils.removeEventListener = function(element, eventType, handler, capture)
element
eventType
handler
<script type="text/javascript> function myClickHandler(event) { alert("myClickHandler was called!"); } Spry.Utils.removeEventListener("myDiv", "click", myClickHandler, false); script>
stringToXMLDoc converts a string that is XML into an actual XML DOM object. This object can now be used as a source for a data set.
Spry.Utils.stringToXMLDoc(xmlStr);
xmlStr
var xmlStr = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> \
<employees xmlns=\"http://www.foo.com/employees\"> \
<employee id=\"123456\"> \
<lastname>Smith</lastname> \
<firstname>Edward</firstname> \
<phone>(415) 333-0235 </phone> \
<username>esmith</username> \
</employee> \
<employee id=\"127937\"> \
<lastname>Johnson</lastname> \
<firstname>Neil</firstname> \
<phone>(415) 333-9475 </phone> \
<username>njohnson</username> \
</employee> \ </employees>"; var dsEmployees = new Spry.Data.XMLDataSet(null, "/employees/employee"); var xmlDOMDocument = Spry.Utils.stringToXMLDoc(xmlStr); dsEmployees.setDataFromDoc(xmlDOMDocument);
Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.