<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Gonzalo Silverio's Weblog &#187; jquery</title>
	<atom:link href="http://gonzalosilverio.wordpress.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://gonzalosilverio.wordpress.com</link>
	<description>Web presentation technologies, flyfishing, Nahuatl Court Poetry, pest control</description>
	<lastBuildDate>Wed, 20 May 2009 13:08:44 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='gonzalosilverio.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/1ab63a470b01e0b22db39181eeabdc88?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Gonzalo Silverio's Weblog &#187; jquery</title>
		<link>http://gonzalosilverio.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gonzalosilverio.wordpress.com/osd.xml" title="Gonzalo Silverio&#8217;s Weblog" />
		<item>
		<title>Print previews on the cheap</title>
		<link>http://gonzalosilverio.wordpress.com/2008/08/22/print-previews-on-the-cheap/</link>
		<comments>http://gonzalosilverio.wordpress.com/2008/08/22/print-previews-on-the-cheap/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 17:25:49 +0000</pubDate>
		<dc:creator>gonzalosilverio</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[sakai]]></category>

		<guid isPermaLink="false">http://gonzalosilverio.wordpress.com/?p=42</guid>
		<description><![CDATA[1. Put this in the document (as well as a link to the jquery file).
&#60;script type="text/javascript"&#62;
  $(document).ready(function(){
    setupLinks();
    setupPrintPreview();
  });
&#60;/script&#62;
2. Put this in your external javascript:
function setupLinks(){
  $('a.print-window').click(function(){
     var w = window.open(this.href, 'printwindow', 'width=600,
         [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gonzalosilverio.wordpress.com&blog=3110789&post=42&subd=gonzalosilverio&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>1. Put this in the document (as well as a link to the jquery file).</p>
<pre>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
    setupLinks();
    setupPrintPreview();
  });
&lt;/script&gt;</pre>
<p>2. Put this in your external javascript:</p>
<pre>function setupLinks(){
  $('a.print-window').click(function(){
     var w = window.open(this.href, 'printwindow', 'width=600,
          height=400,scrollbars=yes,resizable=yes');
     w.focus();
     return false;
  });
}</pre>
<p>3. And this</p>
<pre>function setupPrintPreview(){
  if (window.name == 'printwindow') {
   // all the settings below would need to be edited
    $('.portletBody *').css({
        color: '#000'
    });
    $('.bookList').show();
    $('.collapse').show();
    $('.expand').hide();
    $('.noPrint').hide();
    $('.portletBody').css({
        padding: '1em',
        fontSize: '.85em'
    });
    // provide a print link
    $("h3").append('a link with an
        'javascript:window.print()' href value);
  }
}</pre>
<p>In (1) we are calling a function (2) that bind the onclick event to any link with a class of &#8216;print-window&#8217; &#8211; opening the current document in a named window. In (3) &#8211; if a window  matches the given name, then massage the elements for the print medium, hide elements that were classed as &#8216;noPrint&#8217; (formish things, whatever), and add a link with an &#8216;javascript:window.print()&#8217; href value to the DOM.</p>
<p>The end.  Lots of room for improvement, of course &#8211; the massaging would be done best by swapping the stylesheets, for example.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gonzalosilverio.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gonzalosilverio.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gonzalosilverio.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gonzalosilverio.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gonzalosilverio.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gonzalosilverio.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gonzalosilverio.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gonzalosilverio.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gonzalosilverio.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gonzalosilverio.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gonzalosilverio.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gonzalosilverio.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gonzalosilverio.wordpress.com&blog=3110789&post=42&subd=gonzalosilverio&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gonzalosilverio.wordpress.com/2008/08/22/print-previews-on-the-cheap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53c44f824ee4db9d068fdd4f8c6de656?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gonzalosilverio</media:title>
		</media:content>
	</item>
		<item>
		<title>A better select one or many</title>
		<link>http://gonzalosilverio.wordpress.com/2008/04/07/a-better-select-one-or-many/</link>
		<comments>http://gonzalosilverio.wordpress.com/2008/04/07/a-better-select-one-or-many/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 15:14:02 +0000</pubDate>
		<dc:creator>gonzalosilverio</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[sakai]]></category>

		<guid isPermaLink="false">http://gonzalosilverio.wordpress.com/?p=23</guid>
		<description><![CDATA[&#8220;Better&#8221; is an exaggeration.  It may be that occasionally it is more appropriate.
At issue is presenting a control to the user where she can select one of many, or several of many. When the selection is fairly small (arbitrary at 7 items) &#8211; radio and checkbox groups are standard. But when the choice number [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gonzalosilverio.wordpress.com&blog=3110789&post=23&subd=gonzalosilverio&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8220;Better&#8221; is an exaggeration.  It may be that occasionally it is more appropriate.</p>
<p>At issue is presenting a control to the user where she can select one of many, or several of many. When the selection is fairly small (arbitrary at 7 items) &#8211; radio and checkbox groups are standard. But when the choice number goes over a certain number, there are various mechanisms to be seen, of which the most common are single select <code>&lt;select /&gt;</code> and multiple select <code>&lt;select /&gt;</code> &#8211; the problem  is how to fit large number of choices into a cramped area.</p>
<p>This came up in the context of the Sakai Course Evaluation tool,  where any number of question types need to be constructed and presented to the user. One of these questions, used in a  Cambridge course evaluation, involved a really long list of choices.</p>
<p>Occasionally you might want a control that is a bit friendlier and stylable than a &lt;select /&gt;. A colleague alerted me to: <a href="http://c82.net/posts.php?id=25" target="_blank">http://c82.net/posts.php?id=25</a></p>
<p>Here is an example from C82:</p>
<p><a href="http://gonzalosilverio.files.wordpress.com/2008/04/multi-select.jpg"><img class="alignnone size-medium wp-image-24" src="http://gonzalosilverio.files.wordpress.com/2008/04/multi-select.jpg?w=450&#038;h=154" alt="" width="450" height="154" /></a></p>
<p>Nice! The clickable area indicated by the dark green hover is created by the <code>&lt;label /&gt; </code>element, wrapping the <code>&lt;input /&gt;</code> and the text and set to display:block.  The height and width of the top container (a <code>&lt;ul /&gt;</code>) are fixed and the overflow:auto for the scroll.</p>
<p>There are three possible improvements to the excellent widget.</p>
<ol>
<li>Having the overflow and height attributes set  only if the height goes over a certain number (template or system set) &#8211; so scrollbars appear after a certain height, and groups of less than that height size automatically.</li>
<li>Having the &#8220;checked&#8221; attribute of the input  reflected in the style of the parent label</li>
<li>Having a message display of the &#8220;you have made x selections&#8221; or something like that.</li>
</ol>
<p><strong>Setting the scroll and height dynamically</strong></p>
<p>The markup looks like this:</p>
<pre>&lt;ol class="multchoiceholder"&gt;
&lt;li&gt;
&lt;label for="1"&gt;
&lt;input value="1" name="1" id="1" type="checkbox"&gt;
&lt;/label&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;label for="2"&gt;
&lt;input value="2" name="2" id="2" type="checkbox"&gt;
&lt;/label&gt;
&lt;/li&gt;
(etc)
&lt;/ol&gt;</pre>
<p>And the CSS is pretty much what the C82 article above is using, except no height is set for the container, allowing it to grow to fit the contents. To get the &#8220;intelligence&#8221; about the height I added jquery.js to the &lt;head /&gt;</p>
<pre>&lt;<span class="start-tag">script</span><span class="attribute-name"> src</span>=<span class="attribute-value">"jquery.js" </span><span class="attribute-name">language</span>=<span class="attribute-value">"JavaScript" </span><span class="attribute-name">type</span>=<span class="attribute-value">"text/javascript"</span>&gt;</pre>
<p>And the following at the end of the document:</p>
<pre>&lt;script type="text/javascript"&gt;
$(".multchoiceholder").each(function(){
if ($(this).height() &gt; 180) {
// if ($(this).children("li").size()  &gt;  9) {
$(this).addClass("oversize")
}
})
&lt;/script&gt;</pre>
<p>This essentially adds the &#8220;oversize&#8221; class to the parent container if the parent container contents go over 180 pixels in height. This class, below, sets the height and the overflow that we need. I played around with counting the &lt;li /&gt; child nodes (commented above), but since a given list item could span multiple lines the pixel height seemed best.</p>
<pre>ol.oversize{
border: 1px solid #ccc !important;
height: 12em !important;
overflow: auto !important
}</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gonzalosilverio.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gonzalosilverio.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gonzalosilverio.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gonzalosilverio.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gonzalosilverio.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gonzalosilverio.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gonzalosilverio.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gonzalosilverio.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gonzalosilverio.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gonzalosilverio.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gonzalosilverio.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gonzalosilverio.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gonzalosilverio.wordpress.com&blog=3110789&post=23&subd=gonzalosilverio&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gonzalosilverio.wordpress.com/2008/04/07/a-better-select-one-or-many/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53c44f824ee4db9d068fdd4f8c6de656?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gonzalosilverio</media:title>
		</media:content>

		<media:content url="http://gonzalosilverio.files.wordpress.com/2008/04/multi-select.jpg?w=450" medium="image" />
	</item>
	</channel>
</rss>