<?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>Notes Log &#187; Metaobjects</title>
	<atom:link href="http://noteslog.com/category/metaobjects/feed/" rel="self" type="application/rss+xml" />
	<link>http://noteslog.com</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 13:31:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Metaobjects 1.5 Released</title>
		<link>http://noteslog.com/post/metaobjects-15-released/</link>
		<comments>http://noteslog.com/post/metaobjects-15-released/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 22:10:23 +0000</pubDate>
		<dc:creator>Andrea Ercolino</dc:creator>
				<category><![CDATA[Metaobjects]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://noteslog.com/post/metaobjects-15-released/</guid>
		<description><![CDATA[Changes Added support for easy namespacing Added support for jQuery 1.2.3 cache Rewritten the manual from scratch Download You can download metaobjects from Google Code]]></description>
			<content:encoded><![CDATA[<h5>Changes</h5>
<ul>
<li>Added support for easy namespacing</li>
<li>Added support for jQuery 1.2.3 cache</li>
<li>Rewritten the <a href="metaobjects">manual</a> from scratch</li>
</ul>
<h5>Download</h5>
<p>You can <a href="http://code.google.com/p/jquery-metaobjects-js/" target="_blank">download metaobjects</a> from Google Code</p>
]]></content:encoded>
			<wfw:commentRss>http://noteslog.com/post/metaobjects-15-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Share Source Code using Chili in IE</title>
		<link>http://noteslog.com/post/how-to-share-source-code-using-chili-in-ie/</link>
		<comments>http://noteslog.com/post/how-to-share-source-code-using-chili-in-ie/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 10:14:03 +0000</pubDate>
		<dc:creator>Andrea Ercolino</dc:creator>
				<category><![CDATA[Chili]]></category>
		<category><![CDATA[Metaobjects]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://noteslog.com/?p=146</guid>
		<description><![CDATA[I&#8217;ve recently realized that copying to the clipboardÂ a snippet highlighted by Chili works differently in Internet Explorer (IE)Â and in Mozilla Firefox (FF). They both copy two versions of the selected section: TEXT and HTML. IE TEXT HTML entities resolved HTML stripped off result copied FF TEXT HTML entities resolved BR elements replaced by new lines [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently realized that copying to the clipboardÂ a snippet highlighted by Chili works differently in Internet Explorer (IE)Â and in Mozilla Firefox (FF). They both copy two versions of the selected section: TEXT and HTML.</p>
<dl>
<dt>IE TEXT</dt>
<dd>HTML entities resolved<br />
HTML stripped off</dd>
<dd>result copied</dd>
<dt>FF TEXT</dt>
<dd>HTML entities resolved<br />
BR elements replaced by new lines<br />
HTML stripped off</dd>
<dd>result copied</dd>
<dt>IE HTML</dt>
<dd>HEAD element copied<br />
containment path elements copied<br />
selected text with HTML in place copied</dd>
<dt>FF HTML</dt>
<dd>selected text with HTML in place copied</dd>
</dl>
<p>The net result of all this is that IE does the right thing with HTML while FF does the right thing with TEXT, and neither is completely right or wrong.</p>
<ul>
<li>copying from IE to Notepad you getÂ an awful long line, but copying to Word you get all wonderfully colored</li>
<li>copying from FF to Notepad you getÂ aÂ properly formattedÂ section, but copying to Word you get all sadly monochromatic</li>
</ul>
<p><font color="#ff0000">UPDATE (2007/02/24): What follows is obsolete, because I&#8217;ve implemented a transparent methodÂ in Chili 1.7</font></p>
<p>In Chili 1.6 I&#8217;ve implemented aÂ workaround for IE, so that IE TEXT isÂ like FF TEXT. It&#8217;s a workaround because you need to add a button to each highlighted section, and it will copy all the text in that section when clicked.</p>
<p>The button can be as simple as a DIV placed before the PRE, likeÂ this: <div class="ie_copy" title="copy this snippet to the clipboard">
copy all
</div>
<pre><code class="javascript">
alert( "Hello World!" );
</code></pre></p>
<p>Chili will hideÂ any element with a class <u>ie_copy</u> in any browser but IE, where insteadÂ it willÂ associate a click handler to it,Â forÂ copying all the next PRE content as a properly formatted section. You can style the button element as you like, because Chili uses the class onlyÂ forÂ accessing the element.</p>
<p>You can alsoÂ place the button wherever you like. If so, i.e. if the button element is not the element preceding the PRE section, then you have to feed Chili the method for getting the PRE content. You can do it globally or locally.</p>
<p>When Chili associates the handler to the button, it will look for a <u>getPRE</u> method inside the button element. If there is one, then it will be used, else Chili will look for a <u>getPRE</u> method inside the global ChiliBook object. If there is one, then it will be used, else Chili will give up and not associate a handler.</p>
<p>You can change the global behavior by changing the declaration of the <u>getPRE</u> method inside the ChiliBook object, and you can change the local behavior by adding a <u>chili</u> metaobject (an object with aÂ class <u>chili</u>)Â inside the button element, with a <u>getPRE</u>Â param whose value isÂ the function declaration.</p>
<p>The <u>getPRE</u> function shipped with Chili 1.6 is the following, where theÂ button element is passedÂ intoÂ <u>this</u>Â and the PRE destination is found starting fromÂ that origin:</p>
<p>function() { return $( this ).next( "pre" )[0]; }</p>
<p>A button element after the PRE element could then be locally configured like this: <pre><code class="javascript">
alert( "Hello World!" );
</code></pre>
<div class="ie_copy" title="copy this snippet to the clipboard">
<object class="chili">
	<param name="getPRE" value="function() { return $( this ).prev( 'pre' )[0]; }"/>
</object>
copy all
</div></p>
]]></content:encoded>
			<wfw:commentRss>http://noteslog.com/post/how-to-share-source-code-using-chili-in-ie/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chili 1.5 Released Today</title>
		<link>http://noteslog.com/post/chili-15-released-today/</link>
		<comments>http://noteslog.com/post/chili-15-released-today/#comments</comments>
		<pubDate>Fri, 26 Jan 2007 18:30:12 +0000</pubDate>
		<dc:creator>Andrea Ercolino</dc:creator>
				<category><![CDATA[Chili]]></category>
		<category><![CDATA[Metaobjects]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://noteslog.com/?p=106</guid>
		<description><![CDATA[UPDATE: Chili 1.6 has been released Changes Changed the recipes format to JSON. Previous recipes need a small conversion. Just compare to a JSON recipe and you&#8217;ll see how to Improved support for dynamic setups, by means of metaobjects, which allow a clean configuration on a per element basis Improved support for static setups New [...]]]></description>
			<content:encoded><![CDATA[<h4><span style="color: #ff0000;"><strong>UPDATE</strong>: <a href="/post/chili-16-released-today" target="_self">Chili 1.6</a> has been released</span></h4>
<p><strong>Changes</strong></p>
<ul>
<li>Changed the recipes format to JSON. Previous recipes need a small conversion. Just compare to a JSON recipe and you&#8217;ll see how to</li>
<li>Improved support for dynamic setups, by means of metaobjects, which allow a clean configuration on a per element basis</li>
<li>Improved support for static setups</li>
<li>New examples show how to configure static and dynamic setups
<ul>
<li>static: recipes and stylesheets linked from the page</li>
<li>dynamic: recipes and stylesheets downloaded on demand</li>
</ul>
</li>
<li>The examples also show how to mix languages in the same page, manually configure a mixed language setup, use metaobjects, use a dynamic download in a static setup</li>
<li>Added an option for preventing CSS downloading on demand</li>
<li>Added a new recipe and example for pure HTML</li>
<li>Updated the bundled jQuery library to version 1.1.1</li>
<li>Dropped support for Code Highlighter styleSets. It&#8217;s very easy to convert a styleSet to a JSON recipe, though</li>
<li>Fixed a bug in the white space&#8217;s rendering</li>
<li>Improved the white space&#8217;s rendering in Opera9.1</li>
<li>Added scope protection to all the Chili code</li>
<li>Tested with IE7, FF1.5, Opera9.1</li>
</ul>
<p><strong>Files</strong></p>
<ul>
<li>download all in a zip</li>
<li><a href="/?page_id=79">read the manual</a></li>
<li>Examples (static)</li>
<li>Examples (dynamic)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://noteslog.com/post/chili-15-released-today/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Metaobjects 1.1 Released Today</title>
		<link>http://noteslog.com/post/metaobjects-11-released-today/</link>
		<comments>http://noteslog.com/post/metaobjects-11-released-today/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 23:13:16 +0000</pubDate>
		<dc:creator>Andrea Ercolino</dc:creator>
				<category><![CDATA[Metaobjects]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://noteslog.com/?p=100</guid>
		<description><![CDATA[The Metaobjects plugin is going to become a jQuery official plugin, starting from the next jQuery 1.1 release, due out in a week or so. Meanwhile I&#8217;ve come up with some improvements that I&#8217;m going to share with you, releasing a new version of Metaobjects. Changes Added a new option for selecting the metaobjects to [...]]]></description>
			<content:encoded><![CDATA[<p><strike>The Metaobjects plugin is going to become a jQuery official plugin, starting from the next jQuery 1.1 release, due out in a week or so. Meanwhile</strike> I&#8217;ve come up with some improvements that I&#8217;m going to share with you, releasing a new version of Metaobjects.</p>
<h4>Changes</h4>
<ul>
<li>Added a new option for selecting the metaobjects to process. The option name is &#8220;selector&#8221; and its value is a jQuery selector, which defaults to &#8220;object.metaobject&#8221;, i.e. an OBJECT element with a &#8216;metaobject&#8217; class (the metaobject definition).</li>
</ul>
<p>Example: process metaobjects selected by &#8220;object.bar&#8221;<br />
$.metaobjects({selector: 'object.bar'});</p>
<ul>
<li>Added the concept of metaparam for configuring options local to a metaobject. If a PARAM element is given the &#8216;metaparam&#8217; id, then it is treated as a configuration element, not a metadata element. Either one or none of the PARAM elements can be a metaparam. Its name is needed but not used. A good choice could be &#8216;options&#8217; or &#8216;configuration&#8217;, anyway the &#8216;metaparam&#8217; id garantees that it won&#8217;t clash with a metadata name you might need.</li>
<li>Fixed a bug that didn&#8217;t allow metaobjects to add metadata to elements without a closing tag, like images (thanks to John Resig for pointing it out). Now this is possible by means of the &#8216;target&#8217; metaparam option, whose value is a jQuery selector, which defaults to the parent of the metaobject. The selector takes the document as its context.</li>
</ul>
<p>Example: add this metadata to all the elements selected by &#8220;img.foo&#8221;<br />
<div><object class="metaobject bar">
	<param name='options' value='{target: "img.foo"}' id='metaparam' />
	<param name='title'   value='"What a Foo!"' />
</object></div></p>
<h4>Code of Metaobjects 1.1</h4>
<p>/* 
=============================================================================== 
Metaobjects is a jQuery plugin for setting properties of DOM elements  by means 
of metaobjects (OBJECT elements with a 'metaobject' class) 
...............................................................................                                                
                                               Copyright 2007 / Andrea Ercolino 
------------------------------------------------------------------------------- 
LICENSE: http://www.opensource.org/licenses/mit-license.php UPDATES: 
http://noteslog.com/metaobjects/ 
=============================================================================== 
*/

/** 
 * The metadata is added to the XHTML page by means of metaobjects whose PARAM  
 * elements define name/value pairs. The given 'value' attribute is evaluated and  
 * added to the metaobject's parent as a property with the given 'name' attribute.  
 * Finally the metaobject is removed from the DOM. 
 * 
 * Is possible to configure the target of a metaobject by means of a metaparam, 
 * i.e. a PARAM element with a 'metaparam' id, (one for each metaobject). The name 
 * of the metaparam is required, but currently not used, so it can be anything not 
 * null, like 'options'. The value of the metaparam must be an object like this: 
 * {target: selector}. The selector is a jQuery selector used for finding the 
 * target inside the document. For example this is used for targeting all the 
 * images in the current document
 * 
 * <param id='metaparam' name='options' value='{target: "img"}'>
 *  
 * @signature 
 * |* jQuery *| $.metaobjects(  
 *   |* Object *| options = { 
 *     |* Element *| context: document,  
 *     |* Boolean *|   clean: true,
 *     |* String *| selector: "object.metaobject" 
 *   }  
 * ) 
 * 
 * @type  
 *   jQuery 
 * @name 
 *   $.metaobjects 
 * @param 
 *   Object options = {context: document, clean: true, selector: "object.metaobject"} 
 * @option  
 *     Element context The context where the metaobjects are 
 * @option  
 *     Boolean   clean True means 'remove metaobjects after processing' 
 * @option  
 *     String selector The jQuery selector used for finding metaobjects to process
 * @cat  
 *   Plugins/Metadata 
 * 
 * @example  
 *   $.metaobjects(); 
 * @desc  
 *   load meta data from all of the meta objects in the document and remove them 
 *  
 * @before  
 * <html><head><title>Hi There</title> 
 * ... 
 * <script type="text/javascript"> 
 * $( function() {  
 *   $.metaobjects();  
 *   var p1 = $('#one')[0]; 
 *   $( 'body' ) 
 *     .append(  
 *         '<p>'  
 *       + 'width = ' + p1.meta_size.width 
 *       + '<br />' 
 *       + 'height = ' + p1.meta_size.height 
 *       + '</p>' 
 *     ); 
 * } ); 
 * </script> 
 * </head><body> 
 * <p id="one"> 
 *   <object class="metaobject"> 
 *     <param name  = 'meta_size'  
 *            value = '{ width: 400, height: "auto" }' /> 
 *     <param name  = 'title'  
 *            value = 'document.title' /> 
 *   </object> 
 *   Hello World 
 * </p> 
 * </body></html> 
 *  
 * @after 
 * <html><head><title>Hi There</title> 
 * ... 
 * <script type="text/javascript"> 
 * ... 
 * </script> 
 * </head><body> 
 * <p id="one" title="Hi There"> 
 *   Hello World 
 * </p> 
 * <p> 
 * width = 400 
 * <br/> 
 * height = auto 
 * </p> 
 * </body></html> 
 *  
 * @author Andrea Ercolino (http://noteslog.com/) 
 * @version 1.1  
 */ 

( function($) {
	$.metaobjects = function( options ) {

		function getParam( elem ) {
			var $param = $( elem );
			var pName = $param.attr( 'name' );
			if ( '' == pName) return null;
			var pValue = $param.attr( 'value' );
			var data;
			eval( 'data = ' + pValue + ';' );
			return { name: pName, value: data };
		}

		var global_settings = { 
			  context: document
			, clean: true
			, selector: 'object.metaobject' 
		};
		$.extend( global_settings, options );
		var $metaobjects = $( global_settings.selector, global_settings.context );
		$metaobjects.each( function() {
			var settings = {};
			$( '> param#metaparam', this )
				.each( function() {

					var p = getParam( this );
					if( ! p ) return;
					$.extend( settings, p.value );

				} );
			var $target;
			if( settings.target ) {
				$target = $( settings.target );
				if( 0 == $target.length ) {
					return;
				}
			}
			else {
				$target = $( this.parentNode );
			}
			$( '> param', this )
				.not( '#metaparam' )
				.each( function() {
				
					var p = getParam( this ); 
					if( ! p ) return;
					$.map( $target.get(), function( elem ) {
						elem[ p.name ] = p.value;
						return elem;
					} );

				} );
			if( global_settings.clean ) {
				$( this ).remove();
			}
		} );
		return $metaobjects;
	} 
} ) ( jQuery );</p>
<h5>Tests</h5>
<p>These tests show what happens when the <u>metaobjects()</u> function is called with different options on the same page. (only the name of the file changes)</p>
<ul>
<li>test.hml</li>
<li>test1.hml</li>
<li>test2.hml</li>
<li>test3.hml</li>
</ul>
<p>XHTML page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head><title>Hi There</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-891.pack.js"></script>
<script type="text/javascript" src="metaobjects.js"></script>
<script type="text/javascript" src="setup.js"></script>
<style type="text/css">
p#comment {
	border: 1px dashed silver;
	padding: 10px;
}
</style>
</head><body>

<p id="one">
	<object class="metaobject">
		<param name='meta_size' value='{ width: 400, height: "auto" }' />
		<param name='title'     value='document.title' />
	</object>
	Hello World
</p>

<p><img class="foo" src="jquery-icon.png" alt="jquery icon" /></p>

<p id="two">
	<object class="metaobject bar">
		<param name='meta_size' value='{ width: "auto", height: 300 }' />
		<param name='title'     value='"Goodbye!"' />
	</object>
	See you soon
</p>

<div><object class="metaobject bar">
	<param name='options' value='{target: "img.foo"}' id='metaparam' />
	<param name='title'   value='"What a Foo!"' />
</object></div>

<p id="comment"></p>

<p>
	<a href="http://validator.w3.org/check?uri=referer"><img
		src="http://www.w3.org/Icons/valid-xhtml10"
		alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>

</body></html></p>
<p>setup.js $( function() { 
	var loc = document.location.href;
	$( '#comment' ).html( "what happens if $.metaobjects() is not called" );

	if( loc.indexOf( "test1.html" ) >= 0 ) {
		$( '#comment' ).html( "what happens after calling: $.metaobjects()" );
		$.metaobjects();
//		$.metaobjects({selector: 'object.bar'});
//		$.metaobjects({clean: false}).hide(); 
		var p1 = $('#one')[0];
		var p2 = $('#two')[0];
		$( 'body' )
			.append( '<p>' + 'width = ' + p1.meta_size.width + '<br />'
				+ 'height = ' + p1.meta_size.height + '</p>'
			)
			.append( '<p>' + 'width = ' + p2.meta_size.width + '<br />'
				+ 'height = ' + p2.meta_size.height + '</p>'
			)
		;
	}

	if( loc.indexOf( "test2.html" ) >= 0 ) {
		$( '#comment' ).html( "what happens after calling: $.metaobjects({selector: 'object.bar'});" );
//		$.metaobjects();
		$.metaobjects({selector: 'object.bar'});
//		$.metaobjects({clean: false}).hide(); 
		var p1 = $('#one')[0];
		var p2 = $('#two')[0];
		$( 'body' )
//			.append( '<p>' + 'width = ' + p1.meta_size.width + '<br />'
//				+ 'height = ' + p1.meta_size.height + '</p>'
//			)
			.append( '<p>' + 'width = ' + p2.meta_size.width + '<br />'
				+ 'height = ' + p2.meta_size.height + '</p>'
			)
		;
	}

	if( loc.indexOf( "test3.html" ) >= 0 ) {
		$( '#comment' ).html( "what happens after calling: $.metaobjects({clean: false}).hide();" );
//		$.metaobjects();
//		$.metaobjects({selector: 'object.bar'});
		$.metaobjects({clean: false}).hide(); 
		var p1 = $('#one')[0];
		var p2 = $('#two')[0];
		$( 'body' )
			.append( '<p>' + 'width = ' + p1.meta_size.width + '<br />'
				+ 'height = ' + p1.meta_size.height + '</p>'
			)
			.append( '<p>' + 'width = ' + p2.meta_size.width + '<br />'
				+ 'height = ' + p2.meta_size.height + '</p>'
			)
		;
	}


} );</p>
]]></content:encoded>
			<wfw:commentRss>http://noteslog.com/post/metaobjects-11-released-today/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Metaobjects 1.0 Released Today &#8211; updated</title>
		<link>http://noteslog.com/post/metaobjects-10-released-today/</link>
		<comments>http://noteslog.com/post/metaobjects-10-released-today/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 12:07:06 +0000</pubDate>
		<dc:creator>Andrea Ercolino</dc:creator>
				<category><![CDATA[Metaobjects]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://noteslog.com/?p=99</guid>
		<description><![CDATA[Metaobjects is a jQuery plugin for setting properties of DOM elements by means of metaobjects (OBJECT elements with a &#8216;metaobject&#8217; class). Metadata plugin There is an official Metadata plugin which lets you add metadata to elements by means of three alternative methods, always providing a JSON object to plug the data in: Class attribute Hello [...]]]></description>
			<content:encoded><![CDATA[<p><u>Metaobjects</u> is a jQuery plugin for setting properties of DOM elements by means of metaobjects (OBJECT elements with a &#8216;metaobject&#8217; class).</p>
<h4>Metadata plugin</h4>
<p>There is an official Metadata plugin which lets you add metadata to elements by means of three alternative methods, always providing a JSON object to plug the data in:</p>
<h5>Class attribute</h5>
<p><p id="one" class="some_class {width: 400, height: 'auto'}">
	Hello World
</p></p>
<h5>Custom attribute</h5>
<p><p id="one" class="some_class" data="{width: 400, height: 'auto'}">
	Hello World
</p></p>
<h5>Element content</h5>
<p><p id="one" class="some_class">
	<script>
		{width: 400, height: 'auto'}
	</script>
	Hello World
</p></p>
<h5>Access</h5>
<p>To access a piece of metadata, you write something like this</p>
<p>$( function() { 
	var p1 = $('#one')[0];
	$( 'body' )
		.append( 
			  '<p>' 
			+ 'width = ' + p1.width
			+ '<br />'
			+ 'height = ' + p1.height
			+ '</p>'
		);
} );</p>
<h4>Drawbacks</h4>
<p>Each method available in the Metadata plugin has a drawback.</p>
<ol>
<li>The &#8216;class attribute&#8217; method may generate a conflict with an existing class declaration. In fact any word in any position inside the JSON object (be it the name or value of a JSON property it doesn&#8217;t matter) is treated by the browser as a class name. A careful wording mitigates the problem, though. Instead of { a : &#8220;b&#8221; }, which could clash with an &#8216;a&#8217; class, you write { a: &#8220;b&#8221; }. But if you need { a: &#8220;b is a char&#8221; }, this method is not safe, because it can clash with an &#8216;a&#8217; and an &#8216;is&#8217; classes.</li>
<li>The &#8216;custom attribute&#8217; method generates markup which is not valid XHTML, unless you use an attribute which is defined for the element, but in that case you are exposed to any sort of clashes.</li>
<li>The &#8216;element content&#8217; method is easily used with a SCRIPT element, because its content stays automatically hidden, but it can clash with your regular scripts. So it should be used with an element like a SPAN whose style be &#8216;display:none&#8217;, but you must remember to add a class or an inline style to each. Another problem is the DOM pollution: if you use this feature frequently then your meta element is like spam for your DOM, you simply cannot take care of all of them.</li>
</ol>
<h4>Metaobjects plugin</h4>
<p>My <u>metaobjects.js</u> plugin tries to solve all those problems introducing metaobjects, i.e. OBJECT elements with a &#8216;metaobject&#8217; class.</p>
<p>The metadata is added to the XHTML page by means of metaobjects whose PARAM elements define name/value pairs. The given &#8216;value&#8217; attribute is evaluated and added to the metaobject&#8217;s parent as a property with the given &#8216;name&#8217; attribute. Finally the metaobject is removed from the DOM.</p>
<p>One of the best positions to place the call to the <u>metaobjects()</u> function is inside the jQuery &#8220;document ready&#8221; setup, possibly before any use of a clean DOM.</p>
<h5>Exampe 1</h5>
<p>Here is how you make jQuery load metadata and clean the DOM afterwards<br />
$( function() { 
	$.metaobjects(); 
... 
} );</p>
<h5>Before executing $.metaobjects()</h5>
<p><html><head><title>Hi There</title>
...
</head><body>
<p id="one">
	<object class="metaobject">
	<param   name='meta_size' 
		value='{ width: 400, height: "auto" }' />
	<param   name='title' 
		value='document.title' />
	</object>
	Hello World
</p>
</body></html></p>
<h5>After executing $.metaobjects()</h5>
<p><html><head><title>Hi There</title>
...
</head><body>
<p id="one" title="Hi There">
	Hello World
</p>
</body></html></p>
<h5>Access</h5>
<p>To access a piece of metadata, you write something like this</p>
<p>$( function() { 
	var p1 = $('#one')[0];
	$( 'body' )
		.append( 
			  '<p>' 
			+ 'width = ' + p1.meta_size.width
			+ '<br />'
			+ 'height = ' + p1.meta_size.height
			+ '</p>'
		);
} );</p>
<h4>Signature</h4>
<p>/* jQuery */ $.metaobjects( 
	/* Object */ options = {
		/* Element */ context: document, 
		/* Boolean */ clean: true
	} 
)The <u>metaobjects()</u> function gets a JSON <u>options</u> argument, with members <u>context</u> and <u>clean</u>. <u>context</u> is a DOM element whose metaobjects you want to process. <u>clean</u> is a boolean which tells wether the metaobjects are to be removed (true) or not (false). <u>options</u> is an optional argument and it defaults to { <u>context</u>: document, <u>clean</u>: true }</p>
<p>The <u>metaobjects()</u> function returns an array containing processed metaobjects (DOM elements) belonging to <u>context</u>. If <u>clean</u> was true, then the metaobjects returned have been removed from the DOM. Else if <u>clean</u> was false, you have a chance to <u>hide()</u> them (e.g. if you didn&#8217;t add a CSS definition like &#8220;.metaobject {display: none;}&#8221;)</p>
<h5>Example 2</h5>
<p>Here is how you make jQuery load metadata without cleaning the DOM afterwards. In this case you also <u>hide()</u> the objects (in IE you need to, but in FF they&#8217;re already hidden)<br />
$( function() { 
	$.metaobjects( {clean: false} ).hide(); 
... 
} );</p>
<h4>Code of Metaobjects 1.0</h4>
<p>(see: <a href="/?p=100">http://noteslog.com/?p=100</a>)</p>
<p>There is a bug (#750) in jQuery 1.0.4 (Rev 696) that makes this plugin not usable. I&#8217;ve found a simple fix, though.</p>
<p>Find the following snippet in the source (lines 49-56) // See if an extra function was provided
	var fn = arguments[ arguments.length - 1 ];

	// If so, execute it in context
	if ( fn && typeof fn == "function" )
		this.each(fn);

	return this; and make it like this one // See if an extra function was provided
	var fn = arguments[ arguments.length - 1 ];

	// If so, execute it in context
	if ( fn && typeof fn == "function" && fn.nodeType == undefined )
		this.each(fn);

	return this;</p>
]]></content:encoded>
			<wfw:commentRss>http://noteslog.com/post/metaobjects-10-released-today/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
