<?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>bavotasan.com &#187; var</title>
	<atom:link href="http://bavotasan.com/tag/var/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Use jQuery to Replace a Word with a Link</title>
		<link>http://bavotasan.com/2010/jquery-replace-word-with-link/</link>
		<comments>http://bavotasan.com/2010/jquery-replace-word-with-link/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 20:54:46 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2615</guid>
		<description><![CDATA[If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all [...]]]></description>
			<content:encoded><![CDATA[<p>If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all it took was a small piece of code. </p>
<p>If you don&#8217;t already have jQuery loaded into your page, include this before your closing <code>&lt;head&gt;</code>.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div 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;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>That will load up jQuery from Google.</p>
<p>Now you just need to include this in your site&#8217;s footer, before the closing <code>&lt;body&gt;</code>. (Why in the footer? Because including your JavaScript after all of your code is the efficient way to do it.)</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div 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: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><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> thePage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/jQuery/ig</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://jquery.com&quot;&gt;jQuery&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Since jQuery doesn&#8217;t have a core function for replacing text, we will use the JavaScript <code><a href="http://www.w3schools.com/jsref/jsref_replace.asp">replace()</a></code> function. The <code>i</code> after the slash makes the search and replace case-insensitive, and the <code>g</code> makes it global. </p>
<p>I have the script working on this page to replace every instance of the word jQuery with a link to the jQuery Web site.</p>
<p><script type="text/javascript">
(function($) {
  $(".posttop p").each(function() {
    $(this).html($(this).html().replace(/jQuery/ig, '<a href="http://jquery.com">jQuery</a>')); 
  });
})(jQuery)
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/jquery-replace-word-with-link/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Easy Overlay Modal Window jQuery Plugin</title>
		<link>http://bavotasan.com/2010/easy-overlay-modal-window-jquery-plugin/</link>
		<comments>http://bavotasan.com/2010/easy-overlay-modal-window-jquery-plugin/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:04:24 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[ccc]]></category>
		<category><![CDATA[Click]]></category>
		<category><![CDATA[face kits]]></category>
		<category><![CDATA[fff]]></category>
		<category><![CDATA[fn]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[Padding]]></category>
		<category><![CDATA[panel]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[px]]></category>
		<category><![CDATA[text decoration]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[visibility]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1729</guid>
		<description><![CDATA[I developed the following jQuery plugin for the Design options admin panel of Magazine Premium. All it needed to do is display an example of all of the @font-face kits that are available with the theme. It is pretty simple and just fades in a centered modal window containing an image when you click on [...]]]></description>
			<content:encoded><![CDATA[<p>I developed the following jQuery plugin for the Design options admin panel of <a href="http://themes.bavotasan.com/our-themes/premium-themes/magazine-premium">Magazine Premium</a>. All it needed to do is display an example of all of the @font-face kits that are available with the theme. It is pretty simple and just fades in a centered modal window containing an image when you click on a link.<br />
<span id="more-1729"></span><br />
There are just a few things you need to put in place in order to get it working. First, there is the plugin iteself.</p>
<p>Here is the jQuery code:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">easyOverlay</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>	
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<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>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#easyOverlay&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#easyOverlay&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;p id='easyOverlay'&gt;&lt;a href='javascript:void(0)' class='closeit'&gt;X&lt;/a&gt;&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;img src='&quot;</span><span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rel</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;' alt='' /&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#easyOverlay'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><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> wide <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009966; font-style: italic;">/ 2) - ($(this).width() /</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> high <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009966; font-style: italic;">/ 2) - ($(this).height() /</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
	<span style="color: #003366; font-weight: bold;">var</span> scrollTop <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#easyOverlay&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
          top<span style="color: #339933;">:</span> high <span style="color: #339933;">+</span> scrollTop <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">,</span>
          left<span style="color: #339933;">:</span> wide <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">,</span>
		  display<span style="color: #339933;">:</span> <span style="color: #3366CC;">'none'</span><span style="color: #339933;">,</span>
          visibility<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;visible&quot;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.closeit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#easyOverlay&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span></pre></div></td></tr></table></div>

<p>Here is the CSS you need:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#easyOverlay</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</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;">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;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#easyOverlay</span> <span style="color: #6666ff;">.closeit</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</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;">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;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2000</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p>You can easily change some of the design CSS elements but a few thins need to stay in place to make it work. Don&#8217;t change the following styles:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#easyOverlay</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</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;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1000</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#easyOverlay</span> <span style="color: #6666ff;">.closeit</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</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;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2000</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p>Now comes the HTML markup:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;javascript:void(0)&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;screenshot&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;link-to-your-image.jpg&quot;</span><span style="color: #339933;">&gt;</span>Name of Image<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>To call the plugin all you need to do is this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.screenshot&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">easyOverlay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>There aren&#8217;t any options so all you pretty much get is a centered modal window that fades in when you click the link, and fades out when you click the X.</p>
<p>Test it out below:</p>
<p><a href="javascript:void(0)" class="screenshot" rel="http://bavotasan.com/wp-content/uploads/2010/07/adler.jpg">Adler</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:void(0)" class="screenshot" rel="http://bavotasan.com/wp-content/uploads/2010/07/chunkfive.jpg">Chunkfive</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:void(0)" class="screenshot" rel="http://bavotasan.com/wp-content/uploads/2010/07/galatia.jpg">Galatia</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:void(0)" class="screenshot" rel="http://bavotasan.com/wp-content/uploads/2010/07/riesling.jpg">Riesling</a></p>
<p><small>All the images used were provided by <a href="http://www.fontsquirrel.com/">Font Squirrel</a>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/easy-overlay-modal-window-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Using jQuery to make an Expandable Code Box for WP-Syntax</title>
		<link>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/</link>
		<comments>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 17:43:00 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[background color]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[box]]></category>
		<category><![CDATA[Chris Coyier]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[fan]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[highlighter]]></category>
		<category><![CDATA[horizontal]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[minor changes]]></category>
		<category><![CDATA[overflow]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Plugin Code]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[Syntax Highlighter]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[Width]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress plugin]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1440</guid>
		<description><![CDATA[You may have noticed that I&#8217;m using a new syntax highlighter for my code snippets. I installed Ryan McGeary&#8216;s WordPress plugin WP-Syntax which uses GeSHi (Generic Syntax Highlighter), a simple highlighting class that supports multiple coding languages. It&#8217;s great but I&#8217;m not a fan of the horizontal scrollbar that appears if code extends past your [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2009/07/jquery.png" alt="jquery" title="jquery" width="200" height="150" class="alignright size-full wp-image-726" />You may have noticed that I&#8217;m using a new syntax highlighter for my code snippets. I installed <a href="http://ryan.mcgeary.org/">Ryan McGeary</a>&#8216;s WordPress plugin <a href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a> which uses <a href="http://qbnz.com/highlighter/">GeSHi</a> (Generic Syntax Highlighter), a simple highlighting class that supports multiple coding languages. It&#8217;s great but I&#8217;m not a fan of the horizontal scrollbar that appears if code extends past your site&#8217;s width. Instead, I decided to use <a href="http://jquery.com/">jQuery</a> to expand the box when you hover over it.<br />
<span id="more-1440"></span><br />
We need to make a few minor changes to the plugin code to get this to work. After you have downloaded, installed and activated the plugin, open up <code>wp-syntax.php</code> and go to line #113:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>113
114
115
116
117
118
119
120
121
122
123
124
125
126
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> wp_syntax_line_numbers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>We need to add a table to the second output.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">    if <span style="color: #00AA00;">&#40;</span>$line<span style="color: #00AA00;">&#41;</span>
    <span style="color: #00AA00;">&#123;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> wp_syntax_line_numbers<span style="color: #00AA00;">&#40;</span>$code<span style="color: #00AA00;">,</span> $line<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> $geshi-<span style="color: #00AA00;">&gt;</span>parse_code<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    else
    <span style="color: #00AA00;">&#123;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> $geshi-<span style="color: #00AA00;">&gt;</span>parse_code<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Next we need to open up <code>wp-syntax.css</code> to change a few of the styles. Change this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</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;">#100</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f9f9f9</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">silver</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1.5em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>to:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</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;">#100</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f9f9f9</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">silver</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1.5em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">590px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>I put a fixed width of 590px because I have set that as the maximum width of my single posts.</p>
<p>Now comes the <a href="http://jquery.com">jQuery</a>. Open up your theme&#8217;s <code>header.php</code> file and add the following between  your &lt;head&gt; tags.:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;?php wp_enqueue_script(&quot;jquery&quot;); ?&gt;
<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>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.wp_syntax&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><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> width <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;table&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> pad <span style="color: #339933;">=</span> width <span style="color: #339933;">+</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>width <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">590</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				zIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100&quot;</span><span style="color: #339933;">,</span>
				position<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;relative&quot;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				width<span style="color: #339933;">:</span> pad <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				width<span style="color: #339933;">:</span> <span style="color: #CC0000;">590</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>What we are doing above is creating an effect that will only occur when you hover over the code box. It finds the width of the table and animates the expansion to the full width. When you hover out, the box returns to the fixed width of your post. Be sure that you set the two references to <em>590</em> to whatever you set your width to in the CSS.</p>
<p>Done and done!</p>
<p>To see this in action check out <a href="http://bavotasan.com/tutorials/how-to-create-a-twitter-feed-on-your-web-site/">How to Create a Twitter Feed on Your Web Site</a>.</p>
<p><strong>Resource</strong>: <a href="http://digwp.com/2009/07/making-an-expanding-code-box/">Making an Expanding Code Box by Chris Coyier</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Adding a Simple Quicktag to the HTML Editor in WordPress</title>
		<link>http://bavotasan.com/2009/adding-a-simple-quicktag-to-the-html-editor-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/adding-a-simple-quicktag-to-the-html-editor-in-wordpress/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 16:01:19 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[Functionality]]></category>
		<category><![CDATA[html editor]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[Location]]></category>
		<category><![CDATA[quicktag]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[type]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=158</guid>
		<description><![CDATA[When you are editing a post or writing a new post in WordPress, you might have noticed those buttons above the editing box. They add WYSIWYG type functionality to the WordPress editor for common functions such as bolding, italics and linking. WordPress refers to these buttons as Quicktags. They should look something like this if [...]]]></description>
			<content:encoded><![CDATA[<p>When you are editing a post or writing a new post in WordPress, you might have noticed those buttons above the editing box. They add WYSIWYG type functionality to the WordPress editor for common functions such as bolding, italics and linking. WordPress refers to these buttons as Quicktags.<br />
<span id="more-158"></span><br />
They should look something like this if you use the HTML editor.</p>
<p><a class="highslide" href="http://bavotasan.com/wp-content/uploads/2009/01/quicktags.jpg"><img class="aligncenter size-medium wp-image-159" title="quicktags" src="http://bavotasan.com/wp-content/uploads/2009/01/quicktags-580x32.jpg" alt="quicktags" width="580" height="32" /></a></p>
<p>If you use the Visual editor they should look something like this.</p>
<p><a class="highslide" href="http://bavotasan.com/wp-content/uploads/2009/01/quicktags2.jpg"><img class="aligncenter size-full wp-image-160" title="quicktags2" src="http://bavotasan.com/wp-content/uploads/2009/01/quicktags2.jpg" alt="quicktags2" width="459" height="33" /></a></p>
<p>If you have a function that you use often it is very simple to add it to the Quicktag bar. For this example, I am going to add a button that creates a span tag and asks for a class to the HTML editor Quicktag bar.</p>
<p>The file we need to work with is under <code>wp-includes/js/quicktags.js</code>.</p>
<p>First we need to create the button, so go to around line 36 and enter the following.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">edButtons<span style="color: #009900;">&#91;</span>edButtons<span style="color: #339933;">.</span>length<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>
<span style="color: #000000; font-weight: bold;">new</span> edButton<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ed_class'</span>
<span style="color: #339933;">,</span><span style="color: #0000ff;">'span'</span>
<span style="color: #339933;">,</span><span style="color: #0000ff;">''</span>
<span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;/span&gt;'</span>
<span style="color: #339933;">,</span><span style="color: #0000ff;">'p'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// special case</span></pre></td></tr></table></div>

<p>Then we need to add the part that actually makes it call the function that asks the user to enter a class name. Find this part around line 166.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>166
167
168
169
170
171
172
173
174
175
176
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> edShowButton<span style="color: #009900;">&#40;</span>button<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>button<span style="color: #339933;">.</span>id <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ed_img'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertImage(edCanvas);&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>button<span style="color: #339933;">.</span>id <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ed_link'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertLink(edCanvas, '</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">');&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertTag(edCanvas, '</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">');&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot;  /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And make it this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>166
167
168
169
170
171
172
173
174
175
176
177
178
179
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> edShowButton<span style="color: #009900;">&#40;</span>button<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>button<span style="color: #339933;">.</span>id <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ed_img'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertImage(edCanvas);&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>button<span style="color: #339933;">.</span>id <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ed_link'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertLink(edCanvas, '</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">');&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>button<span style="color: #339933;">.</span>id <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ed_class'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertClass(edCanvas, '</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">');&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
document<span style="color: #339933;">.</span>write<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;input type=&quot;button&quot; id=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>id <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; accesskey=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>access <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; class=&quot;ed_button&quot; onclick=&quot;edInsertTag(edCanvas, '</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">');&quot; value=&quot;'</span> <span style="color: #339933;">+</span> button<span style="color: #339933;">.</span>display <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot;  /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And it needs one last part, the actual function, to work properly, so go to the end of the file and add this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>403
404
405
406
407
408
409
410
411
412
413
414
415
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> edInsertClass<span style="color: #009900;">&#40;</span>myField<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> defaultValue<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>defaultValue<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
defaultValue <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>edCheckOpenTags<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000000; font-weight: bold;">CLASS</span> <span style="color: #339933;">=</span> prompt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enter the Image location'</span> <span style="color: #339933;">,</span>defaultValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CLASS</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
edButtons<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>tagStart <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;span class=&quot;'</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">CLASS</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span> edInsertTag<span style="color: #009900;">&#40;</span>myField<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
edInsertTag<span style="color: #009900;">&#40;</span>myField<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>v <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>When it comes down to it, this might actually be a little bit more complicated of a  Quicktag to create but there you go.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/adding-a-simple-quicktag-to-the-html-editor-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making &lt;p&gt; and &lt;br&gt; Tags Work with htmlText in ActionScript 3.0</title>
		<link>http://bavotasan.com/2008/making-line-break-tags-work-with-htmltext-in-actionscript-3/</link>
		<comments>http://bavotasan.com/2008/making-line-break-tags-work-with-htmltext-in-actionscript-3/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 23:54:44 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Break]]></category>
		<category><![CDATA[everything]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[Paragraph]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[Place]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[working]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=30</guid>
		<description><![CDATA[I had one hell of a time trying to figure out why my paragraph breaks (&#60;p&#62;) and line breaks (&#60;br&#62;) were not working when I was using htmlText in Flash CS3 with ActionScript 3.0. All of the other HTML tags that are allowed by Flash worked fine, but those two break tags just would do [...]]]></description>
			<content:encoded><![CDATA[<p><a class="highslide" href="http://bavotasan.com/wp-content/uploads/2008/10/actionscript-multiline.jpg"><img src="http://bavotasan.com/wp-content/uploads/2008/10/actionscript-multiline-200x159.jpg" alt="" title="actionscript-multiline" class="alignright size-thumbnail wp-image-31" /></a>I had one hell of a time trying to figure out why my paragraph breaks (&lt;p&gt;) and line breaks (&lt;br&gt;) were not working when I was using htmlText in Flash CS3 with ActionScript 3.0. All of the other HTML tags that are allowed by Flash worked fine, but those two break tags just would do anything. I had created a TextField variable called &#8220;info&#8221; and all the code checked out but there was one very important thing that I needed to put in place before it would all work the way I needed it to. <span id="more-30"></span></p>
<p>Here is the code that wouldn&#8217;t work:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">htmlText</span> = <span style="color: #990000;">&quot;First line. &lt;br&gt; Second line. &lt;br&gt; Third line.&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></td></tr></table></div>

<p>Here is what is should have looked like:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">htmlText</span> = <span style="color: #990000;">&quot;First line. &lt;br&gt; Second line. &lt;br&gt; Third line.&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></td></tr></table></div>

<p>Why wasn&#8217;t my original code working? Well, to make sure that the HTML tags for paragraph breaks and line breaks would function properly, I needed to set the TextField&#8217;s multiline parameter to &#8220;true&#8221;. Just one tiny line of code and then everything worked perfectly. I hate it when that happens!</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2008/making-line-break-tags-work-with-htmltext-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>How to Draw a Rectangle with ActionScript 3.0</title>
		<link>http://bavotasan.com/2008/how-to-draw-a-rectangle-with-actionscript-30/</link>
		<comments>http://bavotasan.com/2008/how-to-draw-a-rectangle-with-actionscript-30/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 20:48:07 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[Cs4]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Headache]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[Little Bit]]></category>
		<category><![CDATA[OBJECT]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=18</guid>
		<description><![CDATA[I spent the last weekend working on a Flash animation for a client and I came across a few things that gave me a headache and other things that I thought I should share with the world that I thought were just intereting. If you have ever messed around with ActionScript in Flash then you [...]]]></description>
			<content:encoded><![CDATA[<p>I spent the last weekend working on a Flash animation for a client and I came across a few things that gave me a headache and other things that I thought I should share with the world that I thought were just intereting.</p>
<p>If you have ever messed around with ActionScript in Flash then you understand just how powerful scripting in Flash could be. I know they just released CS4 but the ActionScript version it uses is still 3.0, so whether you are using CS3 or CS4 this will still work for you.</p>
<p>Sure drawing a rectangle is no big feat but there are a few little things that make it a little bit complicated when trying to draw one entirely in ActionScript.<br />
<span id="more-18"></span><br />
The following code is how you were draw a rectangle as a Shape object. It would also be the same if you were drawing it as a MovieClip.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> rectangle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Shape</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Shape</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// initializing the variable named rectangle</span>
rectangle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xFF0000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// choosing the colour for the fill, here it is red</span>
rectangle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// (x spacing, y spacing, width, height)</span>
rectangle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// not always needed but I like to put it in to end the fill</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>rectangle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// adds the rectangle to the stage</span></pre></div></td></tr></table></div>

<p><a class="highslide" href="http://bavotasan.com/wp-content/uploads/2008/10/flash-rect1.png"><img src="http://bavotasan.com/wp-content/uploads/2008/10/flash-rect1-200x187.png" alt="flash-rect" title="flash-rect" width="200" height="187" class="alignleft size-thumbnail wp-image-1079" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2008/how-to-draw-a-rectangle-with-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

