<?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>Broken Bytes &#187; javascript</title>
	<atom:link href="http://blog.brokenbytes.info/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brokenbytes.info</link>
	<description></description>
	<lastBuildDate>Tue, 17 May 2011 20:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>ASP.NET Masterpage, JavaScript, and ResolveUrl</title>
		<link>http://blog.brokenbytes.info/2010/10/asp-net-masterpage-javascript-and-resolveurl/</link>
		<comments>http://blog.brokenbytes.info/2010/10/asp-net-masterpage-javascript-and-resolveurl/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 04:06:48 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[data binding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[master page]]></category>
		<category><![CDATA[masterpage]]></category>
		<category><![CDATA[ResolveUrl]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.brokenbytes.info/?p=239</guid>
		<description><![CDATA[Today was an interesting day for many reasons. The one I&#8217;m going to share with you has to do with javascript and the ResolveUrl method in ASP.NET Masterpage. I recently added jQuery to our web project at work. We have a strange setup and using /Script/jQuery.js in the script tags src attribute won&#8217;t work. For [...]]]></description>
			<content:encoded><![CDATA[<p>Today was an interesting day for many reasons. The one I&#8217;m going to share with you has to do with javascript and the ResolveUrl method in ASP.NET Masterpage. I recently added jQuery to our web project at work. We have a strange setup and using /Script/jQuery.js in the script tags src attribute won&#8217;t work. For that reason I decided to use ResolveUrl() which gets the URL of a file you pass it (i.e. ResolveUrl(&#8220;~/Script/jQuery.js&#8221;) ). This worked great until I was going through the application working on something else and randomly received this error message:</p>
<p>System.Web.HttpException:The Controls collection cannot be modifiedbecause the control contains code blocks (i.e. &lt;% &#8230; %&gt;).</p>
<p>It only happened on a couple of pages and the others would load fine which added to the confusion. Honestly, this error made little to no sense when I first saw it, so I did what any resourceful individual would. I googled it. Luckily the first result was the answer to my issue! The fix is to use data binding (&lt;%#)  instead of writing it out (&lt;%=). It is strange, but it resolves the problem. This is the wonderful explanation and solution: <a href="http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/">http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenbytes.info/2010/10/asp-net-masterpage-javascript-and-resolveurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny MCE Comments &#8211; Problems on iPhone</title>
		<link>http://blog.brokenbytes.info/2010/03/tiny-mce-comments-problems-on-iphone/</link>
		<comments>http://blog.brokenbytes.info/2010/03/tiny-mce-comments-problems-on-iphone/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 22:54:26 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MCEComments]]></category>
		<category><![CDATA[tincymcecomments]]></category>
		<category><![CDATA[tiny MCE]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.brokenbytes.info/?p=179</guid>
		<description><![CDATA[Today at work we realized that Tiny MCE doesn&#8217;t work properly on the iPhone. At least MCEComments for WordPress doesn&#8217;t This prevented users from commenting from a mobile device on the MSU blogs. I fixed this pretty simply by doing browser detection in PHP before loading the files for MCEComments. I modified the loaders for [...]]]></description>
			<content:encoded><![CDATA[<p>Today at work we realized that Tiny MCE doesn&#8217;t work properly on the iPhone. At least MCEComments for WordPress doesn&#8217;t This prevented users from commenting from a mobile device on the MSU blogs. I fixed this pretty simply by doing browser detection in PHP before loading the files for MCEComments. I modified the loaders for the plugin. Only two modifications of the tinyMCEComments.php was neccesary.</p>
<pre class="brush: php; title: ; notranslate">
// Line 311
function mcecomment_init() {
    global $post;
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), &quot;iphone&quot;) === false) {
        $loadJS = false;
        if (is_plugin_page()) {
        $loadJS = true;
        } else if (is_singular()) {
            if (comments_open() &amp;&amp; ( !get_option('comment_registration') || is_user_logged_in() )) {
                $loadJS = true;
            }
        }
        if ($loadJS)
        	mcecomment_getInitJS();
    }
}
</pre>
<pre class="brush: php; title: ; notranslate">
// Line 350
function mcecomment_loadCoreJS() {
    global $post, $mce_locale;
    if (is_singular() &amp;&amp; (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), &quot;iphone&quot;) === false))
    {
        if (comments_open() &amp;&amp; ( !get_option('comment_registration') || is_user_logged_in() )) {
            wp_enqueue_script('tiny_mce', get_option('siteurl') .
            	'/wp-includes/js/tinymce/tiny_mce.js', false, '20081129');
            wp_enqueue_script('tiny_mce_lang', get_option('siteurl') .
                '/wp-includes/js/tinymce/langs/wp-langs-' . $mce_locale . '.js',
                false, '20081129');
            wp_deregister_script('comment-reply');
            wp_enqueue_script( 'comment-reply', get_option('siteurl') .
                '/wp-content/plugins/' . plugin_basename ( dirname ( __FILE__ ) ) .
                &quot;/comment-reply.dev.js&quot;, false, '20090102');
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenbytes.info/2010/03/tiny-mce-comments-problems-on-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; MCEComments and Threaded Comments Fix</title>
		<link>http://blog.brokenbytes.info/2010/02/wordpress-tinymcecomments-and-threaded-comments-fix/</link>
		<comments>http://blog.brokenbytes.info/2010/02/wordpress-tinymcecomments-and-threaded-comments-fix/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 02:21:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MCEComments]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[threaded comments]]></category>
		<category><![CDATA[TinyMCE]]></category>
		<category><![CDATA[tinymcecomments]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.brokenbytes.info/?p=123</guid>
		<description><![CDATA[Edit: After further investigation it looks like the only real problem was problem number 2 (hidden field and iframe named the same). All you have to do is implement the fix for problem 2 discussed below and it should work fine. Problem number 2 was more of a conflict and wasn&#8217;t really anyones fault, but [...]]]></description>
			<content:encoded><![CDATA[<hr />
Edit: After further investigation it looks like the only real problem was problem number 2 (hidden field and iframe named the same). All you have to do is implement the fix for problem 2 discussed below and it should work fine.<br />
Problem number 2 was more of a conflict and wasn&#8217;t really anyones fault, but was rather troublesome to fix. We thought it would be easier to change the TinyMCEComments plugin then modify the install of WordPress. We also had already modified the plugin to remove/insert TinyMCE boxes correctly so we might as well keep working with that. To fix the problem before TinyMCE is initialized we change the hidden field with id=&#8221;comment_parent&#8221; so it is id=&#8221;comment_parent_hf&#8221;. This doesn&#8217;t effect WordPress comment submission because form submissions use the name field server side to identify an attribute.</p>
<p>Change in tinyMCEComments.php</p>
<p>Before (start line 295):</p>
<pre class="brush: jscript; title: ; notranslate">
if (subBtn != null) {
	subBtn.onclick=function() {
		var inst = tinyMCE.getInstanceById(&quot;comment&quot;);
		document.getElementById(&quot;comment&quot;).value = inst.getContent();
		document.getElementById(&quot;commentform&quot;).submit();
		return false;
	}
}
tinyMCEPreInit.go();
tinyMCE.init(tinyMCEPreInit.mceInit);
</pre>
<p>After:</p>
<pre class="brush: jscript; title: ; notranslate">
var subBtn = document.getElementById(&quot;submit&quot;);
	if (subBtn != null) {
	subBtn.onclick=function() {
		var inst = tinyMCE.getInstanceById(&quot;comment&quot;);
		document.getElementById(&quot;comment&quot;).value = inst.getContent();
		document.getElementById(&quot;commentform&quot;).submit();
		return false;
	}
}
tinyMCEPreInit.go();
tinymce.dom.Event.add(window, &quot;load&quot;, function() {
	// Change the hidden fields id
	var pId = document.getElementById(&quot;comment_parent&quot;);
	if(pId) pId.id = &quot;comment_parent_hf&quot;;
	tinyMCE.init(tinyMCEPreInit.mceInit);
});
</pre>
<p>The last thing that was changed in the script was a hard coded name of the comment_parent hidden filed inside comment-reply.dev.js in the TinyMCEComments plugin folder. Change parent = t.I(&#8216;comment_parent&#8217;) to parent = t.I(&#8216;comment_parent_hf&#8217;) to reflect the change we make on the load of TinyMCEComments:</p>
<p>Before (line 3):</p>
<pre class="brush: jscript; title: ; notranslate">
var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
</pre>
<p>After:</p>
<pre class="brush: jscript; title: ; notranslate">
var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent_hf'), post = t.I('comment_post_ID');
</pre>
<p>Now it works! Woohoo! I&#8217;m going to try to contact the other and have these changes included in the next release so everyone can enjoy threaded comments with TinyMCEComments. Thanks for reading and hopefully someone will find this helpful.</p>
<hr />
<p>Today at work I was trying to convert our blog theme to a wider stance for an upcoming template switch, I thought this would be a very simple task. Little did I know the long day that would ensue. Our blog system at work used to use a plugin to create threaded functionality for posts. My boss decided that since WordPress now supports threaded comments we would switch over to that. I thought this would be a great idea (the less code, the less complex, the better). I began to convert our comments template to the new version required for <a href="http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display" target="_blank">Threaded Comments</a>. After this was done I tried it out. It wouldn&#8217;t work with <a href="http://wordpress.org/extend/plugins/tinymcecomments/" target="_blank">TinyMCEComments</a> (plugin) enabled, but worked fine with it off. When <a href="http://wordpress.org/extend/plugins/tinymcecomments/" target="_blank">TinyMCEComments</a> was enabled it created two TinyMCE textareas whenever you tried to do a threaded reply. This seemed very odd to me but I had a feeling it had to do with moving the comment box below the comment that you&#8217;re replying too. After quite awhile and a little bit of help from my boss I was able to figure out all the issues and get <a href="http://wordpress.org/extend/plugins/tinymcecomments/" target="_blank">TinyMCEComments</a> working with the new threaded comments feature. There were two main issues:</p>
<ol>
<li>Double insertion of TinyMCE editors.</li>
<li>TinyMCE has a bug where if create an editor with an id, then destroy that editor, and then try to create a new editor with that same id it will not work.</li>
<li>TinyMCE names its iframe the id of the textarea concatenated with &#8220;_parent&#8221;. So when you add TinyMCE functionality to a textare with id=&#8221;comments&#8221; you get an iframe with id=&#8221;comments_parent&#8221;. Unfortunately, WordPress uses &#8220;comment_parent&#8221; as the id for a hidden field used to transfer information about where your new comment should be added in the threading (or to the base comments). The hidden fields are output by the function comment_id_fields(). Also WordPress says <a href="http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display" target="_blank">&#8220;the comment textarea, it MUST have an id=&#8221;comment&#8221;. The JavaScript expects it for focus purposes. If you used anything else, change it. Note that because of this, no other element on your page can have the &#8220;comment&#8221; ID&#8221;</a>.</li>
</ol>
<p>Before I explain the fixes let me first say that <a href="http://wordpress.org/extend/plugins/tinymcecomments/" target="_blank">TinyMCEComments</a> overrides the addComment.moveForm function that is used by WordPress to move the comment box under the comment you want to reply too. It has the same code except that it has the added functionality for enabling TinyMCE on the comment box. Unfortunately it doesn&#8217;t work out of the box with WordPress&#8217; thread comments.</p>
<p>Problem 1 was an issue with the TinyMCEComments plugin and TinyMCE. Using the remove method doesn&#8217;t remove the the TinyMCE&#8217;s iframe from the DOM. This was fixed with Problem 2. The removing and adding method being used doesn&#8217;t work correctly for Problem number 2 is a TinyMCE problem and we can&#8217;t really do to much about it other then implementing a name change when we reinsert the comment box. So we modified the TinyMCEComments plugin to rename the text area on reinsertion.</p>
<p>Before</p>
<p>Remove TinyMCE Comment box:</p>
<pre class="brush: jscript; title: ; notranslate">
try {
   tinyMCE.triggerSave();
   tinyMCE.execCommand('mceFocus', false,'comment');
   tinyMCE.execCommand('mceRemoveControl', false,'comment');
} catch(el) { console.error(el); }
</pre>
<p>Add TinyMCE Comment box code:</p>
<pre class="brush: jscript; title: ; notranslate">
addTiny : function() {
   try { tinyMCE.execCommand('mceAddControl', false, 'comment');
   } catch (e) { console.error(e); }
}
</pre>
<p>After:</p>
<p>Remove TinyMCE Comment box:</p>
<pre class="brush: jscript; title: ; notranslate">
// **** Remove the TinyMCE Editor
var editor = tinymce.EditorManager.activeEditor;
var editorId = editor.getParam('elements');
editor.remove();
tinymce.DOM.remove(editor.getContainer());
editor.destroy();
tinymce.EditorManager.activeEditor = null;
</pre>
<p>Add TinyMCE Comment box code:</p>
<pre class="brush: jscript; title: ; notranslate">
var commentElement = document.getElementById(editorId);
if (editorId == &quot;comment&quot;)
	editorId = &quot;comment_1&quot;;
else {
	var count = parseInt(editorId.replace(/comment_/, &quot;&quot;), 10) + 1;
	editorId = &quot;comment_&quot; + count;
}
commentElement.id = editorId;
tinyMCEPreInit.mceInit.elements = editorId;
tinyMCE.init(tinyMCEPreInit.mceInit);
</pre>
<p>Problem number 2 was more of a conflict and wasn&#8217;t really anyones fault, but was rather troublesome to fix. We thought it would be easier to change the TinyMCEComments plugin then modify the install of WordPress. We also had already modified the plugin to remove/insert TinyMCE boxes correctly so we might as well keep working with that. To fix the problem before TinyMCE is initialized we change the hidden field with id=&#8221;comment_parent&#8221; so it is id=&#8221;comment_parent_hf&#8221;. This doesn&#8217;t effect WordPress comment submission because form submissions use the name field server side to identify an attribute.</p>
<p>Change in tinyMCEComments.php</p>
<p>Before (start line 295):</p>
<pre class="brush: jscript; title: ; notranslate">
if (subBtn != null) {
	subBtn.onclick=function() {
		var inst = tinyMCE.getInstanceById(&quot;comment&quot;);
		document.getElementById(&quot;comment&quot;).value = inst.getContent();
		document.getElementById(&quot;commentform&quot;).submit();
		return false;
	}
}
tinyMCEPreInit.go();
tinyMCE.init(tinyMCEPreInit.mceInit);
</pre>
<p>After:</p>
<pre class="brush: jscript; title: ; notranslate">
var subBtn = document.getElementById(&quot;submit&quot;);
	if (subBtn != null) {
	subBtn.onclick=function() {
		var inst = tinyMCE.getInstanceById(&quot;comment&quot;);
		document.getElementById(&quot;comment&quot;).value = inst.getContent();
		document.getElementById(&quot;commentform&quot;).submit();
		return false;
	}
}
tinyMCEPreInit.go();
tinymce.dom.Event.add(window, &quot;load&quot;, function() {
	// Change the hidden fields id
	var pId = document.getElementById(&quot;comment_parent&quot;);
	if(pId) pId.id = &quot;comment_parent_hf&quot;;
	tinyMCE.init(tinyMCEPreInit.mceInit);
});
</pre>
<p>The last thing that was changed in the script was a hard coded name of the comment_parent hidden filed inside comment-reply.dev.js in the TinyMCEComments plugin folder. Change parent = t.I(&#8216;comment_parent&#8217;) to parent = t.I(&#8216;comment_parent_hf&#8217;) to reflect the change we make on the load of TinyMCEComments:</p>
<p>Before (line 3):</p>
<pre class="brush: jscript; title: ; notranslate">
var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
</pre>
<p>After:</p>
<pre class="brush: jscript; title: ; notranslate">
var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent_hf'), post = t.I('comment_post_ID');
</pre>
<p>Now it works! Woohoo! I&#8217;m going to try to contact the other and have these changes included in the next release so everyone can enjoy threaded comments with TinyMCEComments. Thanks for reading and hopefully someone will find this helpful.</p>
<p>Completed Files in Zip: <a title="Zipped Modified TinyMCEComments" href="http://blog.brokenbytes.info/wp-content/uploads/2010/02/devtinymcecomments.zip">DevTinyMCEComments</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenbytes.info/2010/02/wordpress-tinymcecomments-and-threaded-comments-fix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>easySlider for jQuery</title>
		<link>http://blog.brokenbytes.info/2010/02/easyslider-for-jquery/</link>
		<comments>http://blog.brokenbytes.info/2010/02/easyslider-for-jquery/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 19:58:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[custom flickr slideshow]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery plugin]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://blog.brokenbytes.info/?p=104</guid>
		<description><![CDATA[Yesterday my supervisor and I used EasySlider (a jQuery plugin) created by Alen Grakalic to make a Flickr slideshow that uses external controls to control the slideshow. It uses the Flickr feed to return a photoset in JSON to get the photos then a slightly modified version of EasySlider to do this. All that was [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday my supervisor and I used <a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding" target="_blank">EasySlider</a> (a jQuery plugin) created by <a title="Alen Grakalic" href="http://grakalic.com" target="_blank">Alen Grakalic </a>to make a Flickr slideshow that uses external controls to control the slideshow. It uses the<a title="JSON Flickr API" href="http://www.flickr.com/services/api/response.json.html" target="_blank"> Flickr feed to return a photoset in JSON</a> to get the photos then a slightly modified version of <a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding" target="_blank">EasySlider</a> to do this. All that was added was a way to have a callback function on slide changes. The function is used by passing the function to trigger with the rest of options by setting onChangedCallBack to the function name. The rest of the script is unchanged. I am sending the code to author for possible future releases. The page it was used on is not currently public, but later I might update this post with a link to it. This is the page that it was used on: <a href="http://www.missouristate.edu/presidentialsearch/missouristate.htm">http://www.missouristate.edu/presidentialsearch/missouristate.htm</a> Here is the code and at the end I will link the actual .js file.</p>
<pre class="brush: plain; title: ; notranslate">/*
 * 	Easy Slider 1.7 - jQuery plugin
 *	written by Alen Grakalic
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */

/*
 *	markup example for $(&quot;#slider&quot;).easySlider();
 *
 * 	&lt;div id=&quot;slider&quot;&gt;
 *		&lt;ul&gt;
 *			&lt;li&gt;&lt;img src=&quot;images/01.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
 *			&lt;li&gt;&lt;img src=&quot;images/02.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
 *			&lt;li&gt;&lt;img src=&quot;images/03.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
 *			&lt;li&gt;&lt;img src=&quot;images/04.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
 *			&lt;li&gt;&lt;img src=&quot;images/05.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
 *		&lt;/ul&gt;
 *	&lt;/div&gt;
 *
 */

(function($) {

    $.fn.easySlider = function(options) {

        // default configuration properties
        var defaults = {
            prevId: 'prevBtn',
            prevText: 'Previous',
            nextId: 'nextBtn',
            nextText: 'Next',
            controlsShow: true,
            controlsBefore: '',
            controlsAfter: '',
            controlsFade: true,
            firstId: 'firstBtn',
            firstText: 'First',
            firstShow: false,
            lastId: 'lastBtn',
            lastText: 'Last',
            lastShow: false,
            vertical: false,
            speed: 800,
            auto: false,
            pause: 2000,
            continuous: false,
            numeric: false,
            numericId: 'controls',
            onChangedCallback: null
        };

        var options = $.extend(defaults, options);

        this.each(function() {
            var obj = $(this);
            var s = $(&quot;li&quot;, obj).length;
            var w = $(&quot;li&quot;, obj).width();
            var h = $(&quot;li&quot;, obj).height();
            var clickable = true;
            obj.width(w);
            obj.height(h);
            obj.css(&quot;overflow&quot;, &quot;hidden&quot;);
            var ts = s - 1;
            var t = 0;
            $(&quot;ul&quot;, obj).css('width', s * w);

            if (options.continuous) {
                $(&quot;ul&quot;, obj).prepend($(&quot;ul li:last-child&quot;, obj).clone().css(&quot;margin-left&quot;, &quot;-&quot; + w + &quot;px&quot;));
                $(&quot;ul&quot;, obj).append($(&quot;ul li:nth-child(2)&quot;, obj).clone());
                $(&quot;ul&quot;, obj).css('width', (s + 1) * w);
            };

            if (!options.vertical) $(&quot;li&quot;, obj).css('float', 'left');

            if (options.controlsShow) {
                var html = options.controlsBefore;
                if (options.numeric) {
                    html += '&lt;ol id=&quot;' + options.numericId + '&quot;&gt;&lt;/ol&gt;';
                } else {
                    if (options.firstShow) html += '&lt;span id=&quot;' + options.firstId + '&quot;&gt;&lt;a href=\&quot;javascript:void(0);\&quot;&gt;' + options.firstText + '&lt;/a&gt;&lt;/span&gt;';
                    html += ' &lt;span id=&quot;' + options.prevId + '&quot;&gt;&lt;a href=\&quot;javascript:void(0);\&quot;&gt;' + options.prevText + '&lt;/a&gt;&lt;/span&gt;';
                    html += ' &lt;span id=&quot;' + options.nextId + '&quot;&gt;&lt;a href=\&quot;javascript:void(0);\&quot;&gt;' + options.nextText + '&lt;/a&gt;&lt;/span&gt;';
                    if (options.lastShow) html += ' &lt;span id=&quot;' + options.lastId + '&quot;&gt;&lt;a href=\&quot;javascript:void(0);\&quot;&gt;' + options.lastText + '&lt;/a&gt;&lt;/span&gt;';
                };

                html += options.controlsAfter;
                $(obj).after(html);
            };

            if (options.numeric) {
                for (var i = 0; i &lt; s; i++) {
                    $(document.createElement(&quot;li&quot;))
						.attr('id', options.numericId + (i + 1))
						.html('&lt;a rel=' + i + ' href=\&quot;javascript:void(0);\&quot;&gt;' + (i + 1) + '&lt;/a&gt;')
						.appendTo($(&quot;#&quot; + options.numericId))
						.click(function() {
						    animate($(&quot;a&quot;, $(this)).attr('rel'), true);
						});
                };
            } else {
                $(&quot;a&quot;, &quot;#&quot; + options.nextId).click(function() {
                    animate(&quot;next&quot;, true);
                });
                $(&quot;a&quot;, &quot;#&quot; + options.prevId).click(function() {
                    animate(&quot;prev&quot;, true);
                });
                $(&quot;a&quot;, &quot;#&quot; + options.firstId).click(function() {
                    animate(&quot;first&quot;, true);
                });
                $(&quot;a&quot;, &quot;#&quot; + options.lastId).click(function() {
                    animate(&quot;last&quot;, true);
                });
            };

            function setCurrent(i) {
                i = parseInt(i) + 1;
                $(&quot;li&quot;, &quot;#&quot; + options.numericId).removeClass(&quot;current&quot;);
                $(&quot;li#&quot; + options.numericId + i).addClass(&quot;current&quot;);
            };

            function showMeta(i) {
                document.getElementById(&quot;fss_meta&quot;).style.display = &quot;block&quot;;
                debugger;
                var a = $(&quot;ul&quot;, obj);
                $(&quot;#fss_meta h3&quot;).html($(&quot;#fss ul:nth-child(&quot; + i + &quot;) img&quot;).attr(&quot;alt&quot;));
                $(&quot;#fss_meta p&quot;).html(options.metaInfo[i - 1]);
            };

            function adjust() {
                if (t &gt; ts) t = 0;
                if (t &lt; 0) t = ts;
                if (!options.vertical) {
                    $(&quot;ul&quot;, obj).css(&quot;margin-left&quot;, (t * w * -1));
                } else {
                    $(&quot;ul&quot;, obj).css(&quot;margin-left&quot;, (t * h * -1));
                }
                clickable = true;
                if (options.numeric) setCurrent(t);
                if (options.onChangedCallback) options.onChangedCallback(t);
            };

            function animate(dir, clicked) {
                if (clickable) {
                    clickable = false;
                    var ot = t;
                    switch (dir) {
                        case &quot;next&quot;:
                            t = (ot &gt;= ts) ? (options.continuous ? t + 1 : ts) : t + 1;
                            break;
                        case &quot;prev&quot;:
                            t = (t &lt;= 0) ? (options.continuous ? t - 1 : 0) : t - 1;
                            break;
                        case &quot;first&quot;:
                            t = 0;
                            break;
                        case &quot;last&quot;:
                            t = ts;
                            break;
                        default:
                            t = dir;
                            break;
                    };
                    var diff = Math.abs(ot - t);
                    var speed = diff * options.speed;
                    if (!options.vertical) {
                        p = (t * w * -1);
                        $(&quot;ul&quot;, obj).animate(
							{ marginLeft: p },
							{ queue: false, duration: speed, complete: adjust }
						);
                    } else {
                        p = (t * h * -1);
                        $(&quot;ul&quot;, obj).animate(
							{ marginTop: p },
							{ queue: false, duration: speed, complete: adjust }
						);
                    };

                    if (!options.continuous &amp;&amp; options.controlsFade) {
                        if (t == ts) {
                            $(&quot;a&quot;, &quot;#&quot; + options.nextId).hide();
                            $(&quot;a&quot;, &quot;#&quot; + options.lastId).hide();
                        } else {
                            $(&quot;a&quot;, &quot;#&quot; + options.nextId).show();
                            $(&quot;a&quot;, &quot;#&quot; + options.lastId).show();
                        };
                        if (t == 0) {
                            $(&quot;a&quot;, &quot;#&quot; + options.prevId).hide();
                            $(&quot;a&quot;, &quot;#&quot; + options.firstId).hide();
                        } else {
                            $(&quot;a&quot;, &quot;#&quot; + options.prevId).show();
                            $(&quot;a&quot;, &quot;#&quot; + options.firstId).show();
                        };
                    };

                    if (clicked) clearTimeout(timeout);
                    if (options.auto &amp;&amp; dir == &quot;next&quot; &amp;&amp; !clicked) {
                        ;
                        timeout = setTimeout(function() {
                            animate(&quot;next&quot;, false);
                        }, diff * options.speed + options.pause);
                    };

                };

            };
            // init
            var timeout;
            if (options.auto) {
                ;
                timeout = setTimeout(function() {
                    animate(&quot;next&quot;, false);
                }, options.pause);
            };

            if (options.numeric) setCurrent(0);
            if (options.onChangedCallback)
                options.onChangedCallback(0);

            if (!options.continuous &amp;&amp; options.controlsFade) {
                $(&quot;a&quot;, &quot;#&quot; + options.prevId).hide();
                $(&quot;a&quot;, &quot;#&quot; + options.firstId).hide();
            };

        });

    };

})(jQuery);</pre>
<p>File: <a href="http://blog.brokenbytes.info/wp-content/uploads/2010/02/easySlider1.7.js">easySlider1.7-Callback</a></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">/*<br />
*     Easy Slider 1.7 &#8211; jQuery plugin<br />
*    written by Alen Grakalic<br />
*    http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding<br />
*<br />
*    Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)<br />
*    Dual licensed under the MIT (MIT-LICENSE.txt)<br />
*    and GPL (GPL-LICENSE.txt) licenses.<br />
*<br />
*    Built for jQuery library<br />
*    http://jquery.com<br />
*<br />
*//*<br />
*    markup example for $(&#8220;#slider&#8221;).easySlider();<br />
*<br />
*     &lt;div id=&#8221;slider&#8221;&gt;<br />
*        &lt;ul&gt;<br />
*            &lt;li&gt;&lt;img src=&#8221;images/01.jpg&#8221; alt=&#8221;" /&gt;&lt;/li&gt;<br />
*            &lt;li&gt;&lt;img src=&#8221;images/02.jpg&#8221; alt=&#8221;" /&gt;&lt;/li&gt;<br />
*            &lt;li&gt;&lt;img src=&#8221;images/03.jpg&#8221; alt=&#8221;" /&gt;&lt;/li&gt;<br />
*            &lt;li&gt;&lt;img src=&#8221;images/04.jpg&#8221; alt=&#8221;" /&gt;&lt;/li&gt;<br />
*            &lt;li&gt;&lt;img src=&#8221;images/05.jpg&#8221; alt=&#8221;" /&gt;&lt;/li&gt;<br />
*        &lt;/ul&gt;<br />
*    &lt;/div&gt;<br />
*<br />
*/</p>
<p>(function($) {</p>
<p>$.fn.easySlider = function(options) {</p>
<p>// default configuration properties<br />
var defaults = {<br />
prevId: &#8216;prevBtn&#8217;,<br />
prevText: &#8216;Previous&#8217;,<br />
nextId: &#8216;nextBtn&#8217;,<br />
nextText: &#8216;Next&#8217;,<br />
controlsShow: true,<br />
controlsBefore: &#8221;,<br />
controlsAfter: &#8221;,<br />
controlsFade: true,<br />
firstId: &#8216;firstBtn&#8217;,<br />
firstText: &#8216;First&#8217;,<br />
firstShow: false,<br />
lastId: &#8216;lastBtn&#8217;,<br />
lastText: &#8216;Last&#8217;,<br />
lastShow: false,<br />
vertical: false,<br />
speed: 800,<br />
auto: false,<br />
pause: 2000,<br />
continuous: false,<br />
numeric: false,<br />
numericId: &#8216;controls&#8217;,<br />
onChangedCallback: null<br />
};</p>
<p>var options = $.extend(defaults, options);</p>
<p>this.each(function() {<br />
var obj = $(this);<br />
var s = $(&#8220;li&#8221;, obj).length;<br />
var w = $(&#8220;li&#8221;, obj).width();<br />
var h = $(&#8220;li&#8221;, obj).height();<br />
var clickable = true;<br />
obj.width(w);<br />
obj.height(h);<br />
obj.css(&#8220;overflow&#8221;, &#8220;hidden&#8221;);<br />
var ts = s &#8211; 1;<br />
var t = 0;<br />
$(&#8220;ul&#8221;, obj).css(&#8216;width&#8217;, s * w);</p>
<p>if (options.continuous) {<br />
$(&#8220;ul&#8221;, obj).prepend($(&#8220;ul li:last-child&#8221;, obj).clone().css(&#8220;margin-left&#8221;, &#8220;-&#8221; + w + &#8220;px&#8221;));<br />
$(&#8220;ul&#8221;, obj).append($(&#8220;ul li:nth-child(2)&#8221;, obj).clone());<br />
$(&#8220;ul&#8221;, obj).css(&#8216;width&#8217;, (s + 1) * w);<br />
};</p>
<p>if (!options.vertical) $(&#8220;li&#8221;, obj).css(&#8216;float&#8217;, &#8216;left&#8217;);</p>
<p>if (options.controlsShow) {<br />
var html = options.controlsBefore;<br />
if (options.numeric) {<br />
html += &#8216;&lt;ol id=&#8221;&#8216; + options.numericId + &#8216;&#8221;&gt;&lt;/ol&gt;&#8217;;<br />
} else {<br />
if (options.firstShow) html += &#8216;&lt;span id=&#8221;&#8216; + options.firstId + &#8216;&#8221;&gt;&lt;a href=\&#8221;javascript:void(0);\&#8221;&gt;&#8217; + options.firstText + &#8216;&lt;/a&gt;&lt;/span&gt;&#8217;;<br />
html += &#8216; &lt;span id=&#8221;&#8216; + options.prevId + &#8216;&#8221;&gt;&lt;a href=\&#8221;javascript:void(0);\&#8221;&gt;&#8217; + options.prevText + &#8216;&lt;/a&gt;&lt;/span&gt;&#8217;;<br />
html += &#8216; &lt;span id=&#8221;&#8216; + options.nextId + &#8216;&#8221;&gt;&lt;a href=\&#8221;javascript:void(0);\&#8221;&gt;&#8217; + options.nextText + &#8216;&lt;/a&gt;&lt;/span&gt;&#8217;;<br />
if (options.lastShow) html += &#8216; &lt;span id=&#8221;&#8216; + options.lastId + &#8216;&#8221;&gt;&lt;a href=\&#8221;javascript:void(0);\&#8221;&gt;&#8217; + options.lastText + &#8216;&lt;/a&gt;&lt;/span&gt;&#8217;;<br />
};</p>
<p>html += options.controlsAfter;<br />
$(obj).after(html);<br />
};</p>
<p>if (options.numeric) {<br />
for (var i = 0; i &lt; s; i++) {<br />
$(document.createElement(&#8220;li&#8221;))<br />
.attr(&#8216;id&#8217;, options.numericId + (i + 1))<br />
.html(&#8216;&lt;a rel=&#8217; + i + &#8216; href=\&#8221;javascript:void(0);\&#8221;&gt;&#8217; + (i + 1) + &#8216;&lt;/a&gt;&#8217;)<br />
.appendTo($(&#8220;#&#8221; + options.numericId))<br />
.click(function() {<br />
animate($(&#8220;a&#8221;, $(this)).attr(&#8216;rel&#8217;), true);<br />
});<br />
};<br />
} else {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.nextId).click(function() {<br />
animate(&#8220;next&#8221;, true);<br />
});<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.prevId).click(function() {<br />
animate(&#8220;prev&#8221;, true);<br />
});<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.firstId).click(function() {<br />
animate(&#8220;first&#8221;, true);<br />
});<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.lastId).click(function() {<br />
animate(&#8220;last&#8221;, true);<br />
});<br />
};</p>
<p>function setCurrent(i) {<br />
i = parseInt(i) + 1;<br />
$(&#8220;li&#8221;, &#8220;#&#8221; + options.numericId).removeClass(&#8220;current&#8221;);<br />
$(&#8220;li#&#8221; + options.numericId + i).addClass(&#8220;current&#8221;);<br />
};</p>
<p>function showMeta(i) {<br />
document.getElementById(&#8220;fss_meta&#8221;).style.display = &#8220;block&#8221;;<br />
debugger;<br />
var a = $(&#8220;ul&#8221;, obj);<br />
$(&#8220;#fss_meta h3&#8243;).html($(&#8220;#fss ul:nth-child(&#8221; + i + &#8220;) img&#8221;).attr(&#8220;alt&#8221;));<br />
$(&#8220;#fss_meta p&#8221;).html(options.metaInfo[i - 1]);<br />
};</p>
<p>function adjust() {<br />
if (t &gt; ts) t = 0;<br />
if (t &lt; 0) t = ts;<br />
if (!options.vertical) {<br />
$(&#8220;ul&#8221;, obj).css(&#8220;margin-left&#8221;, (t * w * -1));<br />
} else {<br />
$(&#8220;ul&#8221;, obj).css(&#8220;margin-left&#8221;, (t * h * -1));<br />
}<br />
clickable = true;<br />
if (options.numeric) setCurrent(t);<br />
if (options.onChangedCallback) options.onChangedCallback(t);<br />
};</p>
<p>function animate(dir, clicked) {<br />
if (clickable) {<br />
clickable = false;<br />
var ot = t;<br />
switch (dir) {<br />
case &#8220;next&#8221;:<br />
t = (ot &gt;= ts) ? (options.continuous ? t + 1 : ts) : t + 1;<br />
break;<br />
case &#8220;prev&#8221;:<br />
t = (t &lt;= 0) ? (options.continuous ? t &#8211; 1 : 0) : t &#8211; 1;<br />
break;<br />
case &#8220;first&#8221;:<br />
t = 0;<br />
break;<br />
case &#8220;last&#8221;:<br />
t = ts;<br />
break;<br />
default:<br />
t = dir;<br />
break;<br />
};<br />
var diff = Math.abs(ot &#8211; t);<br />
var speed = diff * options.speed;<br />
if (!options.vertical) {<br />
p = (t * w * -1);<br />
$(&#8220;ul&#8221;, obj).animate(<br />
{ marginLeft: p },<br />
{ queue: false, duration: speed, complete: adjust }<br />
);<br />
} else {<br />
p = (t * h * -1);<br />
$(&#8220;ul&#8221;, obj).animate(<br />
{ marginTop: p },<br />
{ queue: false, duration: speed, complete: adjust }<br />
);<br />
};</p>
<p>if (!options.continuous &amp;&amp; options.controlsFade) {<br />
if (t == ts) {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.nextId).hide();<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.lastId).hide();<br />
} else {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.nextId).show();<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.lastId).show();<br />
};<br />
if (t == 0) {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.prevId).hide();<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.firstId).hide();<br />
} else {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.prevId).show();<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.firstId).show();<br />
};<br />
};</p>
<p>if (clicked) clearTimeout(timeout);<br />
if (options.auto &amp;&amp; dir == &#8220;next&#8221; &amp;&amp; !clicked) {<br />
;<br />
timeout = setTimeout(function() {<br />
animate(&#8220;next&#8221;, false);<br />
}, diff * options.speed + options.pause);<br />
};</p>
<p>};</p>
<p>};<br />
// init<br />
var timeout;<br />
if (options.auto) {<br />
;<br />
timeout = setTimeout(function() {<br />
animate(&#8220;next&#8221;, false);<br />
}, options.pause);<br />
};</p>
<p>if (options.numeric) setCurrent(0);<br />
if (options.onChangedCallback)<br />
options.onChangedCallback(0);</p>
<p>if (!options.continuous &amp;&amp; options.controlsFade) {<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.prevId).hide();<br />
$(&#8220;a&#8221;, &#8220;#&#8221; + options.firstId).hide();<br />
};</p>
<p>});</p>
<p>};</p>
<p>})(jQuery);</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenbytes.info/2010/02/easyslider-for-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

