<?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>Ionut Staicu - Webdeveloper Blog &#187; Experiments</title>
	<atom:link href="http://dev.iamntz.com/category/experiments/feed" rel="self" type="application/rss+xml" />
	<link>http://dev.iamntz.com</link>
	<description>Stuff about CSS, XHTML, Javascript and jQuery</description>
	<lastBuildDate>Thu, 26 May 2011 05:43:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Add some html to your images in that lightbox!</title>
		<link>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox</link>
		<comments>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox#comments</comments>
		<pubDate>Thu, 30 Jul 2009 12:53:50 +0000</pubDate>
		<dc:creator>Staicu IonuČ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=230</guid>
		<description><![CDATA[One of the biggest drawback of the lightbox-style plugins are that you are not allowed to use html code in your image description. If you need to bold or emphasize some part of the description title you are kinda screwed. &#8230; <a href="http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the biggest drawback of the <a href="http://leandrovieira.com/projects/jquery/lightbox/">lightbox</a>-style plugins are that you are not allowed to use html code in your image description. If you need to bold or emphasize some part of the description title you are kinda screwed. Of course, you don&#8217;t want to use a long and boring description, but if you want to make a list (for example) you are some how limited. Not by lightbox plugin but the html language itself. </p>
<h3>How image description works?</h3>
<pre lang="html">
<a href="image.jpg" title="some extra-long description" rel="lightbox"><img src [...] /></a>
</pre>
<p>This is the basic structure for lightbox-enabled links. The lightbox plugin use that title to add a small description when the big image is showed. What if &#8211; let&#8217;s say &#8211; you need to emphasize the word &#8216;extra&#8217;? How would you proceed? You could use some html tags ( <code>&lt;em&gt;</code> ) but with some validation error and maybe some unpredictible result on various browsers (or parsers, if you use xhtml). The solution? Use <a href="http://en.wikipedia.org/wiki/BBCode">BBcode</a>!</p>
<h3>BBcode for the rescue!</h3>
<p>The above code is transformed to:</p>
<pre lang="html">
<a href="image.jpg" title="some [i]extra[/i]-long [b]description[/b]" rel="lightbox"><img src [...] /></a>
</pre>
<p>And some js magic:</p>
<pre lang="javascript">
String.prototype.replaceAll = function(strTarget, strSubString){
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );
		while (intIndexOfMatch != -1){
 		strText = strText.replace( strTarget, strSubString )
		intIndexOfMatch = strText.indexOf( strTarget );
 	};
	return( strText );
};
</pre>
<p>The reason that we use this custom function is that the javascript internal <code>replace</code> function will work only for first item found. Now, if you use jQuery, you have to do this:</p>
<pre lang="javascript">
$('a[rel=lightbox]').each(function(){
	var t=$(this);
	t.attr( 'title', t.attr('title').replaceAll('[i]', '<em>').replaceAll('[/i]', '</em>').replaceAll('[b]', '<strong>').replaceAll('[/b]', '</strong>') )
}).lightBox();
</pre>
<p>What&#8217;s just happened? The BB code was replaced with html tags. Of course, if you need more tags, you can add it below <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Be careful!</h3>
<p>I didn&#8217;t test it on large sets of images (i had only 6 to 12 images per page) so I have no idea if will affect the performance in any way!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Very *effective* antispam trick on blogs</title>
		<link>http://dev.iamntz.com/87/very-effective-antispam-trick-on-blogs</link>
		<comments>http://dev.iamntz.com/87/very-effective-antispam-trick-on-blogs#comments</comments>
		<pubDate>Tue, 21 Oct 2008 11:13:56 +0000</pubDate>
		<dc:creator>Staicu IonuČ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=87</guid>
		<description><![CDATA[Most of bloggers have a problem with spam. Of course, there is Akismet, but sometimes Akismet is not good enough because he doesn&#8217;t catch all spam messages. So, with this in mind, i wanted only to get rid of all &#8230; <a href="http://dev.iamntz.com/87/very-effective-antispam-trick-on-blogs">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Most of bloggers have a problem with spam. Of course, there is Akismet, but sometimes Akismet is not good enough because he doesn&#8217;t catch all spam messages. So, with this in mind, i wanted only to get rid of all automated messages.</p>
<p>So, look what i did:</p>
<p>First of all, i go with „robots fills ALL fields with something” in my mind. I&#8217;ve added only TWO lines of code: one in <code>comments.php</code> from your theme folder and one in <code>wp-comments-post.php</code> from your root folder.</p>
<p>Ok, how you do it?</p>
<p>First of all you need a ftp client and a text editor. <a href="http://e-texteditor.com">E-texteditor</a> is 2 in 1 so you can download a trial version for doing this. Ofcourse, you can use the old and ugly notepad (or whatever your OS has default). </p>
<p>Open <code>comments.php</code> (which is in your <code>wp-content/themes/your_theme_name</code> folder) then find this line:</p>
<pre lang="html">
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
</pre>
<p>Some things can vary (like <code>ID</code> of the form), but 90% in cases you won&#8217;t need to look for something else <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Just AFTER this line you add:</p>
<pre lang="html">
<p style="position:absolute; left:-9999px;">Don't fill this!
<input type="text" name="name2" />
</pre>
<p>We put a form here and hide it. I didn&#8217;t use <code>display:none</code> because i wanted to be sure that field will be showed up, even is on the left side of the screen (you should actually turn you head to left to see it <img src='http://dev.iamntz.com/wp-includes/images/smilies/tongue.gif' alt=':P' class='wp-smiley' />  ) So the bot will actually SEE that form and will fill. Normal user won&#8217;t.</p>
<p>Save and upload (or just save if you work directly on ftp) then open <code>wp-comments-post.php</code> from your root folder. Just after the </p>
<pre lang="php">
<?php
/**
 * Handles Comment Post to WordPress and prevents duplicate comment posting.
 *
 * @package WordPress
 */
</pre>
<p>beginning part, just add this:</p>
<pre lang="php">
if( $_POST['name2']!= ''){
	die('Spammer!');
}
</pre>
<p>Save and upload.</p>
<p>Next you need to... Hmm... You don't need to do anything else ! Now empty your Akismet queue and wait to see if you get any other spam messages <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Note that is possible to not catch ALL spams, but those are automated you won't get it anymore <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' />  Also, when you upgrade wordpress make sure you make those changes again. And finally, BACK UP FIRST!</p>
<p>Update.</p>
<h1>READ THIS!</h1>
<p>Verry annoying thing that i had recently noticed: even if this small plugin do a great job for spamm *comments*, will NOT work on trackback spam. </p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/87/very-effective-antispam-trick-on-blogs/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>A VERY nice Modal box</title>
		<link>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative</link>
		<comments>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative#comments</comments>
		<pubDate>Thu, 25 Sep 2008 22:16:00 +0000</pubDate>
		<dc:creator>Staicu IonuČ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=52</guid>
		<description><![CDATA[How many times did you need a light modal box? To display an error mesage, a picture or even another web page inside of the current page? And every single time, you ended with using a large-full-of-useless-options script. Yeah, i &#8230; <a href="http://dev.iamntz.com/52/jquery-modal-lightbox-alternative">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How many times did you need a light modal box? To display an error mesage, a picture or even another web page inside of the current page? And every single time, you ended with using a large-full-of-useless-options script. Yeah, i know the feeling. Seriously, i know it VERY well. That&#8217;s why i wrote this piece of code to display modal boxes <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' />  Anyhow, this works BEST with AJAX content <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>UPDATES: known issues</h2>
<p>If you need to display more content than fit into a screen height, you won&#8217;t see the content after the fold. To fix this, just remove the scroll bind on document:</p>
<pre lang="javascript">
(document).bind('scroll', function(){
		$('#ntz_modal').css({
			top:$(document).scrollTop()
		});
	});
</pre>
<h2>How to use?</h2>
<p>Just call with <code>modalBox('content', 200)</code> where <em>content</em> is what do you want to display (which can be an ajax result) and 200 is the width of the modal box. If you don&#8217;t specify any width, the default value (350) is used.</p>
<h2>How to close the modal box?</h2>
<p>Well&#8230; Just call the function <code>modalBox()</code>. When no parameter is passed, then the modal goes off. Nice, isn&#8217;t it? <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>Browser compatibility</h2>
<p>The script was tested in FF 2, FF 3, IE 6, IE 7, Safari (on Win), Opera 9.5. If you don&#8217;t know what these letter means, there is a very high probability to don&#8217;t need this snippet <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Selectboxes on IE6 &#8211; how they are managed?</h2>
<p>Very simple: i hide ALL selects when modal is shown and i show them back when modal is destroyed. Ofcourse, you can use bgiframe plugin. Which is </p>
<h2>Requirements</h2>
<p>The script is tested with last version of jQuery (1.2.6) but should work fine with previous (and ofcourse next) versions. If you use an ancient version, you may need some extra plugins (like dimensions)</p>
<h2>What&#8217;s the cost?</h2>
<p>Prepare you credit card, prepare you paypal account or whatever you want. Because this is totally FREE. You may use, modify and distribute whatever you like. A small link back would be nice (but <strong>NOT</strong> mandatory).</p>
<p>You bastard! You use your name in modal elements! Yeah, so? No, seriously, i used this way because there is no way to know what div did you use. And the chance to have a div called <code>ntz_modal</code> in your code is kinda.. hmm&#8230; Right! ZERO! Of course, you can change these ID&#8217;s whatever you like it <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>How do I get the code?</h2>
<p>Keep reading!<br />
<!--adsense--></p>
<pre lang="javascript" line="1">
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
function modalBox(content, width, callback) {
	if(!content){
		$('#ntz_modal').remove();
		$('#ntz_overlay').fadeOut(function(){$(this).remove();});
		try{if(IE6){$('body').find('select.unhideThis').removeClass('unhideThis').visibility('visible');}}catch(err){};
		$('embed.unhideThis, object.unhideThis').removeClass('unhideThis').css('visibility', 'visible');
		return false;
	}
	try{if(IE6){$('body').find('select:visible').addClass('unhideThis').visibility('hidden');}}catch(err){};
	$('embed:visible, object:visible').addClass('unhideThis').css('visibility', 'hidden');
	$('body').append('
<div id="ntz_overlay"></div>

');
	$('#ntz_overlay').css({
		width		:	'100%',
		height		:	$(document).height(),
		position	:	'absolute',
		left		:	0,
		top		:	0,
		backgroundColor	:	'#FFFFFF',
		zIndex		:	9990,
		opacity		:	0
	}).fadeTo(200, 0.5);
	$('body').append('
<div id="ntz_modal"></div>

');
	$('#ntz_modal').css({
		border		:	'1px solid #2d7abb',
		width		:	width ? width : 350,
		backgroundColor	:	'#FFFFFF',
		position	:	'absolute',
		left		:	'50%',
		top		:	$(document).scrollTop(),
		zIndex		:	9995,
		marginLeft	:	-(Math.ceil((width ? width : 800)/2))
	}).append(content);
	$('#ntz_modal a:eq(0), #ntz_modal input, #ntz_modal textarea').focus();
	try{
		callback.call();
	}catch(err){};
	$(document).bind('scroll', function(){
		$('#ntz_modal').css({
			top:$(document).scrollTop()
		});
	});
};
</pre>
<p><a href="http://iamntz.com/experiments/modal.html"><img src="http://www.iamntz.com/demo.jpg" alt="" /></a><br />
Note: the example is VERY intrusive <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Who need flash, anyway? No, really!</title>
		<link>http://dev.iamntz.com/43/who-need-flash-anyway-no-really</link>
		<comments>http://dev.iamntz.com/43/who-need-flash-anyway-no-really#comments</comments>
		<pubDate>Mon, 01 Sep 2008 02:01:20 +0000</pubDate>
		<dc:creator>Staicu IonuČ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=43</guid>
		<description><![CDATA[Today i made a nice gallery/carousel for a customer who didn&#8217;t want to use flash. Why? Beats me! Anyway, take a look HERE and tell me what do you think? I made this very quickly (and very, VERY messy!) and &#8230; <a href="http://dev.iamntz.com/43/who-need-flash-anyway-no-really">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today i made a nice gallery/carousel for a customer who didn&#8217;t want to use flash. Why? Beats me! Anyway, take a look <a href="http://iamntz.com/experiments/newKindOfCarousel/">HERE </a>and tell me what do you think?</p>
<p>I made this very quickly (and very, VERY messy!) and i didn&#8217;t have enough time to test in other browsers than firefox and ie7.</p>
<p>Soon i will post the last part of carousel &#8211; the autoslider part &#8211; and after that i will show you how i made this carousel.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/43/who-need-flash-anyway-no-really/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

