<?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; insertAfter</title>
	<atom:link href="http://www.yuicoder.com/tag/insertafter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yuicoder.com</link>
	<description>Manipulating the Yahoo User Interface to your will!</description>
	<lastBuildDate>Fri, 19 Mar 2010 23:59:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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&nbsp;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&nbsp;project</a>\n</p>
<h2>CSS</h2>
<p>First you will need to specify the position and size of your&nbsp;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&nbsp;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&nbsp;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>
		<item>
		<title>Inserting a new element before the end body tag using Yahoo Util DOM</title>
		<link>http://www.yuicoder.com/2009/03/inserting-a-new-element-before-the-end-body-tag-using-yahoo-util-dom/</link>
		<comments>http://www.yuicoder.com/2009/03/inserting-a-new-element-before-the-end-body-tag-using-yahoo-util-dom/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 13:25:02 +0000</pubDate>
		<dc:creator>Jeffrey Cobb</dc:creator>
				<category><![CDATA[YUI Util DOM]]></category>
		<category><![CDATA[createElement]]></category>
		<category><![CDATA[generateID]]></category>
		<category><![CDATA[getElementsByClassName]]></category>
		<category><![CDATA[getLastChild]]></category>
		<category><![CDATA[insertAfter]]></category>
		<category><![CDATA[YAHOO.Util.Dom]]></category>

		<guid isPermaLink="false">http://www.yuicoder.com/?p=79</guid>
		<description><![CDATA[An example of how to create elements in javascript then attach/append them to other elements using YUI.]]></description>
			<content:encoded><![CDATA[<p>Creating elements like divs, href links, paragraphs and more can be tricky. Suppose you do not have access to modify the html or you are dealing with a template file that is static to the entire application and need to add an element to the page on the fly. Using the YUI DOM utility you can do this simply by searching for an element by class name or id then appending the element to the page just where you want it. The code below gives you an example of how to use the getElementsByClassName method in YUI by searching for a body element with the class name of yui-skin-sam. Check out the YUI api for more helper&nbsp;methods.</p>
<pre name="code" class="JavaScript">
//lets find the elements we need by finding all body elements that have the class yui-skin-sam
var elements = YAHOO.util.Dom.getElementsByClassName('yui-skin-sam', 'body');
//if you body does not have an ID then generate one usign the generateID method.
    var bodyid = YAHOO.util.Dom.generateId(elements[0],'body');
// Get the last child element of the body by searching for the body id we just created above.
    var bodyLastChild = YAHOO.util.Dom.getLastChild(bodyid);

// Now we create a DIV element using the standard javascript method createElement
		var b = document.createElement('div');
// Let YUI create and assign the new div elements id.
		var bottomid = YAHOO.util.Dom.generateId(b,'bottom');
    	b.href='#';
// Put some html in your div
		b.innerHTML = 'TESTER';
// Assign your div a class name of newClass so you can reference it in a style sheet.
		b.className = 'newClass';
// Attach the new DIV id to the element you are creating
		b.id = bottomid;
// Use YUI to insert the new div element afer the last child element of the body tag.
		YAHOO.util.Dom.insertAfter(b ,YAHOO.util.Dom.get(bodyLastChild));
</pre>
<p>Now to learn more on how to create ELEMENTS like divs and paragraphs check out the tutorials at W3cshools. This is sure to be a fun project to play and learn. Give it a&nbsp;try!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yuicoder.com/2009/03/inserting-a-new-element-before-the-end-body-tag-using-yahoo-util-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
