Proxy Your Requests With Grunt

Probably you’re already using grunt to serve your local frontend code. Everything is fine, but if you’re developing your backend with something different than JavaScript (Being a Java developer I heard that might happen), you will have problems accessing this backend while running grunt server. With grunt-connect-proxy there exists a grunt module to help you out. It basically delegates requests that match a given URL to a different backend of your choice....

March 13, 2015 · 2 min · admin

How to detect whether an element is in a scrollable parent

Just think of having an element in a scrollable parent (the CSS property overflow is set to scroll) and you want to test whether the element is visible or not. Using this little function you can do the trick: function isInView(node){ var offsetParent = node.offsetParent; var top = offsetParent.scrollTop; var height = offsetParent.offsetHeight; var y = node.offsetTop; return y >= top && y <= (top + height); } And here’s a small use case - this one scrolls the element into the visible region, if it is not already in the view:...

November 2, 2009 · 1 min · admin

Let the user select an item in a modal dialog

After having used the shiny new YUI3 library for a project, it’s about time to share my YUI3 experiences with you. For the project I built an item selector: A modal dialog is openend and the user has to select an item. After selection the dialog is closed and the selected item is passed to a callback function. Here you can find the full source for the item selector. An example to use the selector can be as simple as this:...

August 5, 2009 · 1 min · admin

Using Axis2 services from Javascript (by removing the XML namespaces)

If you want to call an Axis2 service from Javascript you will face the problem that the XML response of an Axis2 service call contains XML namespaces - something Javascript doesn’t like in cross-browser-friendly way. The idea to fix this issue is to make an XSLT transformation directly from Axis2 that removes the unnecessary namespaces. First we need an XSLT transformation that will do the job: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="no" method="xml"></xsl:output> <xsl:template match="/|comment()|processing-instruction()"> <xsl:copy> <xsl:apply-templates></xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*|node()"></xsl:apply-templates> </xsl:element> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="....

January 27, 2009 · 2 min · admin