<?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>DemiLane &#187; Javascript</title>
	<atom:link href="http://demilane.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://demilane.com</link>
	<description>Pages of Rogelio Calamaya</description>
	<lastBuildDate>Sun, 20 Jun 2010 19:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Toggle Grid in Blueprint CSS</title>
		<link>http://demilane.com/toggle-grid-in-blueprint-css/</link>
		<comments>http://demilane.com/toggle-grid-in-blueprint-css/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 20:41:15 +0000</pubDate>
		<dc:creator>Rogelio</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[blueprint]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.demilane.com/?p=242</guid>
		<description><![CDATA[I started coding with the Blueprint CSS this night and since I&#8217;m a newbie, I am not yet familiar with the framework. So, I tend to manually toggle the showgrid class in the code. The showgrid class is an additional class that when present it shows a background of grids, it can be placed along ]]></description>
			<content:encoded><![CDATA[<p>I started coding with the <a href="http://www.blueprintcss.org/">Blueprint CSS</a> this night and since I&#8217;m a newbie, I am not yet familiar with the framework. So, I tend to manually toggle the <code>showgrid</code> class in the code. The <code>showgrid</code> class is an additional class that when present it shows a background of grids, it can be placed along with the <code>container</code> class. Which is handy when working with alignments. The sad part is the toggling, so I&#8217;ve written this simple script to toggle the grid of the Blueprint CSS and to please my laziness.</p>
<p>Put the script below inside the <code>&lt;head&gt;</code> element.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>  
  <span style="color: #003366; font-weight: bold;">function</span> toggleGrid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> toggle <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'toggleGrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> container<span style="color: #339933;">;</span>			
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>toggle.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Hide Grid'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      toggle.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Show Grid'</span><span style="color: #339933;">;</span>
      ripClass<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>toggle.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Show Grid'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      toggle.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Hide Grid'</span><span style="color: #339933;">;</span>
      ripClass<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' showgrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">function</span> ripClass<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByClassName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      container <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'container'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> container.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        container<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'container'</span> <span style="color: #339933;">+</span> c<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      container <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> container.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>container<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'container'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          container<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'container'</span> <span style="color: #339933;">+</span> c<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>container<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'container showgrid'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          container<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'container'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Next the style.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span>
div<span style="color: #cc00cc;">#toggleGrid</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>	
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>		
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#toggleGrid</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FF6F6F</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>		
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div>

<p>Then after that, we need to create a <code>&lt;div&gt;</code> element inside the body with the <code>id="toggleGrid"</code> and <code>onclick()</code> event calling the <code>toggleGrid()</code> function that we created above. It should look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>55
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;toggleGrid&quot; onclick=&quot;toggleGrid();&quot;&gt;Show Grid&lt;/div&gt;</pre></td></tr></table></div>

<p>The <code>&lt;div&gt;</code> element will be position as fixed in the top left of the browser. Tested in Mozilla Firefox 3, Google Chrome, Opera 9, Apple Safari(win) and IE6/7.<br />
Check the <strong><a href="http://demilane.com/dl/blueprint-toggle-grid/">demo</a></strong>.</p>


<p>Related posts:<ol><li><a href='http://demilane.com/absolute-and-relative-positioning/' rel='bookmark' title='Permanent Link: Absolute and Relative Positioning'>Absolute and Relative Positioning</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://demilane.com/toggle-grid-in-blueprint-css/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
