<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>YUI Coder &#187; inDocument()</title>
	<atom:link href="http://www.yuicoder.com/tag/indocument/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yuicoder.com</link>
	<description>Manipulating the Yahoo User Interface to your will!</description>
	<lastBuildDate>Mon, 16 Aug 2010 22:52:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Creating a FIXED element with re-size and scroll detection using YUI dom and event</title>
		<link>http://www.yuicoder.com/2009/03/creating-a-fixed-element-with-re-size-and-scroll-detection-using-yui-dom-and-event/</link>
		<comments>http://www.yuicoder.com/2009/03/creating-a-fixed-element-with-re-size-and-scroll-detection-using-yui-dom-and-event/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 00:05:05 +0000</pubDate>
		<dc:creator>Jeffrey Cobb</dc:creator>
				<category><![CDATA[YUI Loader]]></category>
		<category><![CDATA[YUI Mish Mash]]></category>
		<category><![CDATA[YUI Util DOM]]></category>
		<category><![CDATA[createElement]]></category>
		<category><![CDATA[Get]]></category>
		<category><![CDATA[getPreviousSibling()]]></category>
		<category><![CDATA[getViewPortHeight()]]></category>
		<category><![CDATA[getViewPortWidth()]]></category>
		<category><![CDATA[inDocument()]]></category>
		<category><![CDATA[insertAfter]]></category>
		<category><![CDATA[setStyle()]]></category>
		<category><![CDATA[window.resize]]></category>
		<category><![CDATA[YAHOO.Dom.Event]]></category>
		<category><![CDATA[YAHOO.util.Event.addListner]]></category>
		<category><![CDATA[YUI Event]]></category>

		<guid isPermaLink="false">http://www.yuicoder.com/?p=85</guid>
		<description><![CDATA[We have all see them and some of us love them. It&#8217;s those elements that seem to float on the page like hovering little angels. Ok enough with the sappy crap&#8230;down to business. So you need to create a browser independent simple script to position an element on a page. I put together a simple [...]]]></description>
			<content:encoded><![CDATA[<p>We have all see them and some of us love them. It&#8217;s those elements that seem to float on the page like hovering little angels. Ok enough with the sappy crap&#8230;down to business. So you need to create a browser independent simple script to position an element on a page. I put together a simple script that will handle such a task and is flexible enough for even a newbie to configure. </p>
<p>In this example my task is to create a footer element that will stay on the bottom of the browser window during re-size and scroll events.<a href="http://yuicoder.com/examples/fixedFooter.html" target="blank">View the completed project</a>\n</p>
<h2>CSS</h2>
<p>First you will need to specify the position and size of your element.</p>
<pre>
<textarea name="code" class="css" cols="60" rows="10">#screenFooter {
  position: absolute;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 25px;}
</textarea>
</pre>
<h2>HTML</h2>
<p>Assign your element an ID!</p>
<pre>
<textarea name="code" class="html" cols="60" rows="10">
<div id="screenFooter">YuiCoder.com</div>

</textarea>
</pre>
<h2>Javascript</h2>
<p>Insert the following code to the bottom of the page just before the body tag.<br />
In this example I am using the YUI Loader to speed up deployment of my examples. You do not need to user YUI Loader but remember you will need to load the yahoo, dom and event scripts from the YUI Library in order for this to work.</p>
<pre>
<textarea name="code" class="javascript" cols="60" rows="10">
<!--
var loader = new YAHOO.util.YUILoader({
    require: ["dom","event"],
    loadOptional: true,
    onSuccess: function() {
    Ydom = YAHOO.util.Dom;

// Start LoadFooter Code
// Fires of the LoadFooter function when the browser dom is ready
Yevent.onDOMReady(LoadFooter);

// Scroll event listner
YAHOO.util.Event.addListener(window, 'scroll',
    function(){
       var Ydom = YAHOO.util.Dom;
       Ydom.setStyle(Ydom.get('screenFooter'),'visibility','hidden');
       LoadFooter();
      }
);

YAHOO.util.Event.addListener(window, 'resize', LoadFooter );
},
    timeout: 10000,
    combine: true
});
loader.insert();

function LoadFooter(){
// Get the footer element as an object
var footer = Ydom.get('screenFooter');
// Get the element loaded BEFORE the footer
var footer2 = Ydom.getPreviousSibling(footer);

    // Create an element just before the footer. This will ensure the footer does not hide anything
	//on the bottom of your page
    if(!Ydom.inDocument('footerBreak') ){
      var b = document.createElement('div');
          b.style.height = '37px';
          b.id = 'footerBreak';
       Ydom.insertAfter(b,footer2);
    }

    // Get the document scroll TOP position
    var sfS = Ydom.getDocumentScrollTop();
	// Get the document ViewPort size - subtract the footer size then add the scroll top position
    var sfH = Ydom.getViewportHeight() - 37 + sfS;
	// Note if you are dealing with an element that is smaller than 100% of the document viewport
	// add calculations for the getViewportWidth() for horizonal scrolling detection

	// Here we set the style properties of the footer
    Ydom.setStyle(footer,'position','absolute');
    Ydom.setStyle(footer,'top',sfH+'px');
    Ydom.setStyle(footer,'visibility','visible');
}

-->
</textarea>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yuicoder.com/2009/03/creating-a-fixed-element-with-re-size-and-scroll-detection-using-yui-dom-and-event/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

