<?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>Pearl Tech &#187; jQuery</title>
	<atom:link href="http://blog.pearltechnology.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pearltechnology.com</link>
	<description></description>
	<lastBuildDate>Tue, 25 May 2010 14:37:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Printer Friendly jQuery</title>
		<link>http://blog.pearltechnology.com/printer-friendly-jquery/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/printer-friendly-jquery/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 13:39:46 +0000</pubDate>
		<dc:creator>AaronH</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery print tabs]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[jQuery widgets]]></category>
		<category><![CDATA[printer friendly]]></category>
		<category><![CDATA[Sharepoint Web Parts]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=344</guid>
		<description><![CDATA[Building websites to support different browsers is easy business when you&#8217;re relying on the jQuery framework. However, building printer friendly web content is another hurdle for application developers. I recently came across some useful jQuery for printing Sharepoint web parts. The idea was pure genius &#8211; wrap the bit of HTML you want to print [...]]]></description>
			<content:encoded><![CDATA[<p>Building websites to support different browsers is easy business when you&#8217;re relying on the <a href="http://jquery.com/">jQuery framework</a>. However, building printer friendly web content is another hurdle for application developers. I recently came across some <a href="http://www.endusersharepoint.com/2009/04/06/jquery-for-everyone-print-any-web-parts-plugin/">useful jQuery</a> for printing Sharepoint web parts. The idea was pure genius &#8211; wrap the bit of HTML you want to print into its own document window and inform the browser of your intentions to print. The key idea here is that we want to print <em>a portion of a webpage</em>, not the entire web page. If we wanted to print the entire webpage, I would recommend going the route of using the @media tag <a href="http://www.w3.org/TR/CSS2/media.html">found in CSS 2.0</a>. However, you will eventually run into printing quirks when you are building interactive websites.</p>
<p>Although I wasn&#8217;t using Sharepoint for this website, I was using jQuery, so I leveraged this idea to print specific portions of a website instead of only Sharepoint specific content. This site was also using <a href="http://jqueryui.com/">jQuery UI</a> for creating rich internet content, specifically the <a href="http://jqueryui.com/demos/tabs/">tabs</a>, <a href="http://jqueryui.com/demos/accordion/">accordion</a>, and <a href="http://jqueryui.com/demos/dialog/">dialog</a> widgets. The incredible thing about widgets is that they allow for highly interactive sites, yet the trouble with widgets is that they are not conducive to easily printing their content.</p>
<p>If you tried printing the <a href="http://jqueryui.com/demos/tabs/default.html">default tabs example</a> using jQuery UI, you end up with something that looks like this&#8230;</p>
<p><center><a href="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-default-functionality.PNG#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-355" title="jquery tabs default functionality" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-default-functionality-300x119.PNG" alt="jquery tabs default functionality" width="300" height="119" /></a></center></p>
<p>At first glance, you may not realize the problem with this. The content of the inactive tabs is hidden from the print view. In our requirements, we needed to print all the content for each tab, whether it was active or not. Now you begin to see the clash between interactive content and printer friendly widgets.</p>
<p>There is a solution to this problem, but it varies depending on how you setup your widgets. Here are some tips to setup the print view. For printed tabs to work, you need to create some hidden panel headers and utilize some CSS to display the hidden tabs contents. The solution I came up with contains a &#8220;Printer Friendly&#8221; link which triggers the dynamic CSS changes for printing all the tabs contents.</p>
<p><center><a href="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-printer-friendly.PNG#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-372" title="jquery tabs printer friendly" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-printer-friendly-300x47.PNG" alt="jquery tabs printer friendly" width="300" height="47" /></a></center></p>
<p>Add the following HTML to your page where you want the locate the &#8220;Printer Friendly&#8221; link for the tab widgets.</p>
<pre name="code" language="html">
<div id="dialog-1">
<h3>Printer Friendly Here</h3>
</div>
</pre>
<p>Here is the printer friendly window that is created after clicking on the &#8220;Printer Friendly&#8221; link.</p>
<p><center><a href="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-printer-friendly-dialog.PNG#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-375" title="jquery tabs printer friendly dialog" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquery-tabs-printer-friendly-dialog-299x111.PNG" alt="jquery tabs printer friendly dialog" width="299" height="111" /></a></center></p>
<p>Here is the jQuery script that enables the printer-friendly jQuery UI tabs to happen.</p>
<pre name="code" language="jscript">$(function() {
	        $("#tabs").tabs();

	        // remove any print headers that we may have added
	        $("div.printHeader").remove();

	        // assign our id for print navigation removal
	        $("#tabs&gt;ul").each(function() {
	            $(this).addClass("tab-nav");
	        });

	        // create printer friendly tab view
	        $("#tabs&gt;ul&gt;li&gt;a").each(function() {
	            // what tab is this?
	            var tabNum = $(this).attr("href").replace("#", "");

	            // get our content for this tab
	            var tabContent = $("div[id=" + tabNum + "]");

	            // prepend our print header along with tab theme style
	            $(tabContent).before("
<div class="printHeader &quot; + $(this).parent().parent().parent().attr(&quot;class&quot;) + &quot;">\n" +
    	                            "
<ul class="&quot; + $(this).parent().parent().attr(&quot;class&quot;).replace(&quot;tab-nav&quot;, &quot;&quot;) + &quot;">\n" +
	                                    "
<li>" + $(this).text() + "

\n" +
	                                "</li>
</ul>

\n" +
	                            "</div>

\n");
	        });

	        drawPrinterFriendly(); // creates printer friendly links
	    });

	    // Prints contents of a dialog
	    // source: http://www.endusersharepoint.com/2008/12/09/jquery-for-everyone-print-any-web-part/
	    // remarks: added removal of printer friendly link
	    function printDialog(tagid, title) {
	        if (tagid) {
	            var CSSContent = ".printInfo,.tab-nav { display:none;}\n.ui-tabs .ui-tabs-hide,.printHeader { display: block !important; }\n";
	            var printCss = "
<!--
\n" + CSSContent + "
-->

";
	            // build html for print page
	            // remarks: we use parent here since the dialog is in a wrapped container
	            var html = "\n\n" + $("head").html() + "\n" + printCss + "\n\n\n" + $("#" + tagid).parent().html() +
                    "\n\n";
	            var printWP = window.open("", "printWebPart"); //open new window
	            printWP.document.open();
	            //insert content
	            printWP.document.write(html);
	            printWP.document.close();
	            //open print dialog
	            printWP.print();
	        }
	    }

	    // creates printer friendly link for matching dialog H3 tags
	    function drawPrinterFriendly() {
	        // find all dialogs by their TD
	        var tags = $("*[id^='dialog-']");
	        // loop through dialogs
	        tags.each(function() {
	            //get id for print function
	            var tagid = $(this).attr("id");
	            //append an image with onClick event
	            $(this).find("h3").html("").append(
                        "
<div class="printInfo">" +
                        "  <a onclick="printDialog(&quot; + " href="##utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Printer Friendly" +
                        "  </a>" +
                        "</div>

"
                    );
	        });
	    }</pre>
<p>You can find the entire solution <a href="http://blog.pearltechnology.com/wp-content/uploads/2009/09/printer-friendly-jquery.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a>. This solution can easily be adapted to work with other widgets (dialogs, accordions, etc.) with the inclusion of the H3 tag inside a div with id prefix &#8220;dialog-&#8221;. Possibly in the future I will create a <a href="http://plugins.jquery.com/">jQuery plugin</a> that encapsulates this functionality for simple integration into your site. Have you found a better approach for printing select portions of a page containing jQuery widgets?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/printer-friendly-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Developer Bookmarklets</title>
		<link>http://blog.pearltechnology.com/web-developer-bookmarklets/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/web-developer-bookmarklets/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 14:00:48 +0000</pubDate>
		<dc:creator>AaronH</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[bookmarklets]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=144</guid>
		<description><![CDATA[Bookmarklets can be powerful aids for web development. With jQuery providing so much innovation in the browser landscape, many bookmarklets are pushing the bar. Here are some interesting ones that I&#8217;ve found incredibly useful and use in conjunction with (or absence of) the built-in browser developer tools.

jQuerify is a simple way to inject the jQuery [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Bookmarklet">Bookmarklets</a> can be powerful aids for web development. With jQuery providing so much innovation in the browser landscape, many bookmarklets are pushing the bar. Here are some interesting ones that I&#8217;ve found incredibly useful and use in conjunction with (<em>or absence of</em>) the built-in browser developer tools.</p>
<ul>
<li><a href="http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet">jQuerify</a> is a simple way to inject the jQuery framework into any website and enable immediate DOM manipulation. To try it out, just drag <a href="javascript:%20(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px%2010px%205px%2010px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof%20jQuery!='undefined'){msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;return%20showMsg();}else%20if(typeof%20$=='function'){otherlib=true;}%20function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&amp;&amp;(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();}};head.appendChild(script);}%20getScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',function(){if(typeof%20jQuery=='undefined'){msg='Sorry,%20but%20jQuery%20wasn\'t%20able%20to%20load';}else{msg='This%20page%20is%20now%20jQuerified%20with%20v'+jQuery.fn.jquery;if(otherlib){msg+='%20and%20noConflict().%20Use%20$jq(),%20not%20$().';}}%20return%20showMsg();});function%20showMsg(){el.innerHTML=msg;b.appendChild(el);window.setTimeout(function(){if(typeof%20jQuery=='undefined'){b.removeChild(el);}else{jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});if(otherlib){$jq=jQuery.noConflict();}}},2500);}})();#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">this link</a> to your bookmark list. Depending on the browser you&#8217;re using, you can then enter any javascript commands via the console window in Firebug, IE 8 Developer Tools, or Chrome Developer Tools.
<p><img class="alignnone size-full wp-image-151" title="jquerified" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquerified.PNG" alt="jquerified" width="239" height="31" /></p>
<p>If the website you are visiting already has jQuery installed, the bookmarklet will not inject the framework again.</p>
<p><img class="alignnone size-full wp-image-154" title="jquerified-ignored" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/jquerified-ignored.PNG" alt="jquerified-ignored" width="241" height="27" /></p>
<p>Here is some sample jQuery code which would highlight a post in red, the blog entry in blue, and perform some simple animation to the sidebar on this website. Click <a href="javascript:%20(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px%2010px%205px%2010px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof%20jQuery!='undefined'){msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;return%20showMsg();}else%20if(typeof%20$=='function'){otherlib=true;}%20function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&amp;&amp;(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();}};head.appendChild(script);}%20getScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',function(){if(typeof%20jQuery=='undefined'){msg='Sorry,%20but%20jQuery%20wasn\'t%20able%20to%20load';}else{msg='This%20page%20is%20now%20jQuerified%20with%20v'+jQuery.fn.jquery;if(otherlib){msg+='%20and%20noConflict().%20Use%20$jq(),%20not%20$().';}}%20return%20showMsg();});function%20showMsg(){el.innerHTML=msg;b.appendChild(el);window.setTimeout(function(){if(typeof%20jQuery=='undefined'){b.removeChild(el);}else{jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});if(otherlib){$jq=jQuery.noConflict();}}},2500);$('div[class=post]:first').css('border','2px%20solid%20red');$('div[class=entry]:first').css('border','2px%20solid%20blue');$('div[class=sidebg]').slideToggle(4000).fadeIn('fast');}})();#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a> to see it in action.</p>
<pre name="code" class="jscript">$("div[class=post]:first").css("border", "2px solid red");
$("div[class=entry]:first").css("border", "2px solid blue");
$("div[class=sidebg]").slideToggle(4000).fadeIn("fast");</pre>
</li>
<li><a href="http://getfirebug.com/lite.html">Firebug Lite</a> is another useful bookmarklet if you&#8217;re currently using a browser that doesn&#8217;t support plugins or have its own set of developer tools. It has support for both online and offline integration. Click <a href="javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a> to see an example or simply drag and drop <a href="javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">this link</a> into your bookmarks.
<p><a href="http://blog.pearltechnology.com/wp-content/uploads/2009/09/firebug-lite.PNG#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-174" title="Firebug Lite" src="http://blog.pearltechnology.com/wp-content/uploads/2009/09/firebug-lite-300x111.PNG" alt="Firebug Lite" width="300" height="111" /></a></p>
<p>You can now enter commands into the console and manipulate the DOM just like you were using an assisted native browser extension. Enjoy!</li>
</ul>
<p>Do you have any great developer bookmarklets that you&#8217;d like to share? Please comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/web-developer-bookmarklets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery notifications using jGrowl</title>
		<link>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 14:23:45 +0000</pubDate>
		<dc:creator>AaronH</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=40</guid>
		<description><![CDATA[When creating rich internet applications (RIA), having good communication back to the end user is critical. jGrowl is an excellent tool to provide instant notifications messages to the client using the jQuery framework. jGrowl is simple to use and easy to configure. Here is a quick introduction on how to get started with it. This [...]]]></description>
			<content:encoded><![CDATA[<p><span>When creating rich <span>internet</span> applications (RIA), having good communication back to the end user is critical. </span><a title="jGrowl" href="http://stanlemon.net/projects/jgrowl.html" target="_blank"><span><span>jGrowl</span></span></a> is an excellent tool to provide instant notifications messages to the client using the <a title="jQuery" href="http://jquery.com/" target="_blank"><span><span>jQuery</span></span></a><span> framework. <span>jGrowl</span> is simple to use and easy to configure. Here is a quick introduction on how to get started with it. This article assumes you are already using the jQuery framework in your existing site.</span></p>
<p>First, you need to download the jGrowl extension from <a href="http://plugins.jquery.com/project/jgrowl">here</a>. After including the JavaScript reference to your source, you can begin creating messages by adding the following JavaScript to your page.</p>
<pre name="code" class="jscript">$.jGrowl("Customer order successfully submitted!");</pre>
<p>jGrowl notifications can be sticky (<em>i.e. you must close them</em>) and they can also accumulate if you want to post several notifications at once. Here&#8217;s a quick glimpse of how these notifications can appear with some enhanced styling applied.<br />
<center><br />
<div id="attachment_105" class="wp-caption aligncenter" style="width: 270px"><img class="size-full wp-image-105 " title="Sample jGrowl Notification" src="http://blog.pearltechnology.com/wp-content/uploads/2009/08/jGrowl.PNG" alt="jGrowl Sample Notification" width="260" height="317" /><p class="wp-caption-text">jGrowl Sample Notification</p></div><br />
</center><br />
The first notice above is using HTML to render the message, while the second notice is using purely text to notify the user of an action or interaction with the page. Happy growling!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
