<?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>bassistance.de &#187; Plugin Parade</title>
	<atom:link href="http://bassistance.de/category/jquery/plugin-parade/feed/" rel="self" type="application/rss+xml" />
	<link>http://bassistance.de</link>
	<description>Jörn Zaefferer on Bass, Geeks and Rock'n'Roll</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:34:50 +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>Plugin Parade #4: Chili</title>
		<link>http://bassistance.de/2007/05/23/plugin-parade-4-chili/</link>
		<comments>http://bassistance.de/2007/05/23/plugin-parade-4-chili/#comments</comments>
		<pubDate>Wed, 23 May 2007 21:51:29 +0000</pubDate>
		<dc:creator>Jörn</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugin Parade]]></category>

		<guid isPermaLink="false">http://bassistance.de/2007/05/23/plugin-parade-4-chili/</guid>
		<description><![CDATA[See http://noteslog.com/category/chili/ One of the most interesting and useful jQuery plugins for a developer posting code snippets on the web is Chili. Chilli stands for &#8220;code highlighter&#8221;, is written and maintained by Andrea Ercolino and published under the MIT opensource license. To use the plugin, you need to include the plugin itself and all the [...]]]></description>
			<content:encoded><![CDATA[<p><em>See <a href="http://noteslog.com/category/chili/">http://noteslog.com/category/chili/</a></em></p>
<p>One of the most interesting and useful jQuery plugins for a developer posting code snippets on the web is <a href="http://noteslog.com/category/chili/">Chili</a>. Chilli stands for &#8220;code highlighter&#8221;, is written and maintained by Andrea Ercolino and published under the MIT opensource license.</p>
<p>To use the plugin, you need to include the plugin itself and all the recipse you&#8217;d like to use. A recipe consists of JavaScript to parse code and add elements and classes and some CSS to format that code. Version 1.8 is delivered with recipse for C++, C#, CSS, Delphi, HTML, Java, JavaScript, Lotusscript (lo and behold), Mysql (I guess SQL with MySQL specifc extensions) and PHP. More details and lots of example can be found in the <a href="http://noteslog.com/chili/">Chili manual</a>.</p>
<p>You should chose which recipse you need on your side and include both .js and .css files. On this site I&#8217;ve added recipes for Java, HTML, CSS and JavaScript, packing all recipse together with jQuery and plugins and putting the recipes CSS into my main stylesheet. It&#8217;s a bit work, but a one-trime process, and definitely worth the trouble, because:</p>
<p>Once you have Chili loaded, it does its work in the background, at least that is the mode I prefer. When I post some snippet of code, I just have to add a class=&#8221;css&#8221; to the code-element to get Chili do its work. For example:</p>
<pre><code class="html">&lt;pre&gt;&lt;code class="html"&gt;some html&lt;/code&gt;&lt;/pre&gt;</code></pre>
<p>If I&#8217;d use class=&#8221;css&#8221; instead, the outcome would be different:</p>
<pre><code class="css">&lt;pre&gt;&lt;code class="css"&gt;some html&lt;/code&gt;&lt;/pre&gt;</code></pre>
<p>Chili still recognizes &#8220;pre&#8221; and &#8220;code&#8221; as keywords and &#8220;css&#8221; as a string, but uses a different classes and styles.</p>
<p>For reference, I use this CSS to format pre and code elements:</p>
<pre><code class="css">pre code {
	display: block;
	padding: 5px;
	background-color: #eee;
	border: 1px solid #d3d3d6;
	border-left-width: 5px;
	white-space: pre;
	overflow-x: auto;
	width: 98%;
}
code {
	color: #666;
	font-family: 'lucida console', 'Courier New', monospace;
	font-size: 0.9em;
	font-size: 1em;
}</code></pre>
<p>Again nicely fomatted thanks to Chili.</p>
<p>Coming up next on this series of the plugin parade: Masked input plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://bassistance.de/2007/05/23/plugin-parade-4-chili/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Plugin parade #3: methods</title>
		<link>http://bassistance.de/2007/01/05/plugin-parde-3-methods/</link>
		<comments>http://bassistance.de/2007/01/05/plugin-parde-3-methods/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 22:32:51 +0000</pubDate>
		<dc:creator>Jörn</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugin Parade]]></category>

		<guid isPermaLink="false">http://bassistance.de/2007/01/05/plugin-parde-3-methods/</guid>
		<description><![CDATA[Take a look at this code snippets: String.prototype.trim = function(){ return this.replace(/(^\\s+&#124;\\s+$)/g, ""); }; It provides a very powerful method, it can often be useful when working with Strings, eg. when formatting text from form inputs. Adding it as String method via the String.prototype makes the usage easier then a class global function. Instead of [...]]]></description>
			<content:encoded><![CDATA[<p>Take a look at this code snippets:</p>
<pre><code>String.prototype.trim = function(){
	return this.replace(/(^\\s+|\\s+$)/g, "");
};</code></pre>
<p>It provides a very powerful method, it can often be useful when working with Strings, eg. when formatting text from form inputs. Adding it as String method via the String.prototype makes the usage easier then a class global function. Instead of trim(&#8220;somestring&#8221;), you can simply call &#8220;somestring&#8221;.trim().</p>
<p>So what&#8217;s the problem? Why not just add all kind of stuff to different prototypes? We could add all the new Array methods supported by Firefox, which are missing in other browsers, like forEach. Add while we are at it, we could add some useful methods to the Object prototype, and use these methods with all our objects. Like this debug method:</p>
<pre><code>// don't try this at home!
Object.prototype.debug = function(){
	console.debug("debugging " + this);
	for(key in this) {
		console.debug("key: " + key);
		console.debug(this[key]);
	}
};</code></pre>
<p>Adding the above to your scripts would shatter jQuery and every other script, library or framework that relies on for(key in object) loops. Something that you&#8217;d rather avoid to do.</p>
<p>Consider the debug method above, and this example:</p>
<pre><code>var myObject = {
  name: "peter",
  age: 21
};
myObject.debug();</code></pre>
<p>What do you expect what be logged on your <a href="http://getfirebug.com/cl.html">Firebug console</a>? This?</p>
<pre><code>debugging [object Object]
key: name
peter
key: age
21</code></pre>
<p>Close, and wrong. You get this:</p>
<pre><code>debugging [object Object]
key: name
peter
key: age
21
key: debug
function()</code></pre>
<p>Ok, nothing to worry about, eh? We added the debug method to the Object prototype, so it makes sense that it appears there.</p>
<p>But it also appears everywhere else, something we definitely don&#8217;t want.</p>
<p>So no Object.prototype, what about problems with String or Array prototypes? The same problem applies: When you use a for(key in object) loop on Strings or Arrays, you&#8217;d also find the added methods. As there is basically no need to use that loop on Strings or Arrays, it&#8217;s more up to your enviroment. To you work with others or with code from others, that you don&#8217;t control? Is there any chance that there is a loop on an extended object? Bad. Go to <a href="#prison">prison</a>. Do you work alone and/or you have control over all code involved? Fine. Read on.</p>
<p>Whew, that was a rather long introduction. Now only sugar for the rest of the day: The &#8220;methods&#8221; plugin!</p>
<p>Currently it provides six sexy String methods (trim, camelize, startsWith, endsWith, truncate and stripTags) and seven sexy Array methods (forEach, every, some, map, filter, indexOf and unique). Apart from unique, the Array methods are already provided by Firefox as &#8220;Javascript 1.7&#8243;. For that reason, both plugins add only methods that don&#8217;t already exists. To guarantee compability, an extensive testsuite tests for both native and new methods.</p>
<p><a href="http://jquery.com/dev/svn/trunk/plugins/methods/jquery.array.js?format=txt">Array methods plugin source (contains documentation)</a><br />
<a href="http://jquery.com/dev/svn/trunk/plugins/methods/jquery.string.js?format=txt">String methods plugin source (contains documentation)</a><br />
<a href="TODO/methodsTest.html">Testsuite</a><br />
<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array">Mozzila&#8217;s  documentation for the new Array methods</a></p>
<p>In case you don&#8217;t want to use the complete package or can&#8217;t use the prototype approach: Feel free to pick only those methods that you need or only the involved regular expressions (from trim, camlize and stripTags).</p>
<p>If you have useful methods that you&#8217;d like to provide: Just let me know. Some additional Date methods are very appreciated.</p>
<p><strong id="prison">Prison</strong></p>
<p>So you are in prison, need some array/object iterators and can&#8217;t or don&#8217;t want to use prototype extensions? Try these, posted by Michael Geary on the jQuery discussion list:</p>
<pre><code>function objectEach( obj, fn ) {
    for( var name in obj )
        if( fn( obj[name], name ) === false )
            break;
}

function arrayEach( ary, fn ) {
    for( var i = 0, n = ary.length;  i < n;  i++ )
        if( fn( ary[i], i ) === false )
            break;
}</code></pre>
<p>He also posted examples how they work:</p>
<pre><code>objectEach(
    { a:'ay', b:'bee', c:'see' },
    function( value, name ) {
        return confirm( name + ': ' + value );
    }
);

arrayEach(
    [ 'ay', 'bee', 'see' ],
    function( value, index ) {
        return confirm( index + ': ' + value );
    }
);</code></pre>
<p>In each one you can cancel the iteration by clicking cancel on the confirm dialog.</p>
<p>For simple iterations that you'd like to stop at some point these are much better then jQuery's $.each (which is mostly for internal usage).</p>
]]></content:encoded>
			<wfw:commentRss>http://bassistance.de/2007/01/05/plugin-parde-3-methods/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Plugin parade #2: form</title>
		<link>http://bassistance.de/2007/01/01/plugin-parade-2-form/</link>
		<comments>http://bassistance.de/2007/01/01/plugin-parade-2-form/#comments</comments>
		<pubDate>Mon, 01 Jan 2007 15:38:17 +0000</pubDate>
		<dc:creator>Jörn</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugin Parade]]></category>

		<guid isPermaLink="false">http://bassistance.de/2007/01/01/plugin-parade-2-form/</guid>
		<description><![CDATA[You started with a simple HTML form, maybe for registering new users. Now someone asked you to put all kinds of other stuff on that page, and you don&#8217;t want the user to reload all that when the form is submitted. But you also don&#8217;t want to gather all the input fields, serialize and send [...]]]></description>
			<content:encoded><![CDATA[<p>You started with a simple HTML form, maybe for registering new users. Now someone asked you to put all kinds of other stuff on that page, and you don&#8217;t want the user to reload all that when the form is submitted. But you also don&#8217;t want to gather all the input fields, serialize and send them via AJAX. So far, the browser did the serializing pretty well for you, and also you don&#8217;t want to change your server-side code.</p>
<p>In that case, and lots of others, you need the form plugin.</p>
<p><a href="http://jquery.com/dev/svn/trunk/plugins/form/form.js?format=txt">Form plugin source (contains detailed documentation)</a><br />
<a href="http://visualjquery.com/index.xml">Documentation on Visual jQuery (Plugins/Form), though a bit outdated</a></p>
<p>Similar to the metadata plugin, it has evolved from the jQuery mailing list. A lot of people have worked on it and it is currently maintained by Mike Alsup.</p>
<p>The form plugin provides several methods to submit your form via AJAX. The easiest one is ajaxForm():</p>
<p><code>$("#myformid").ajaxForm();</code></p>
<p>This replaces the normal browser submit with an AJAX submit: It registers for the submit event of the form (allowing the user to use the submit button or plain keyboard events), serializes all input fields inside the form, uses the action property as the URL to send the form to and the method property for the method (GET or POST). </p>
<p>Though what we are missing here is a way to display the response. Again the easiest aproach is to provide an expression that selects an element where the response is displayed. May sound complicated at first, but it isn&#8217;t:</p>
<pre><code>$("#myformid").ajaxForm({
  target: "#responseContainer"
});</code></pre>
<p>Here we select an element with the id &#8220;responseContainer&#8221; to display the response.</p>
<p>Maybe this is a bit too simple: You&#8217;d want some validation before the submit, and do a few actions after the submit, using the response. You also need to send the form to a different URL, to be able to return JSON instead of a full HTML page. We pick a few of the available options, and throw them together:</p>
<pre><code>function pre(formdata) {
  if( !formdata.length ) {
    alert("Please fill out the form");
    return false;
  }
}
function post(response) {
  if( response.status != "error" ) {
    $("#reponse").html(reponse.message);
  } else {
    alert("Your form submission was not succesful");
  }
}
$("#myformid").ajaxForm({
  beforeSubmit: pre,
  success: post,
  dataType: "json",
  url: "ajax.php"
});</code></pre>
<p>The pre function checks if there are any succesful elements, in other words, if anything at least one field contains something to submit. The post function checks the JSON response, allowing a different handling of succesful and failed submits.</p>
<p>Both the pre and post function are passed to the ajaxForm method as options. The dataType option is the same as for $.ajax(), it&#8217;s just passed through. We set it to JSON because we want to work with the response as JSON (eg. access response.status).</p>
<p>We also define the URL to submit the form to. This makes it easier for the server-side to distinguish between a normal and an AJAX submit. The more elegant version would be to check for the &#8220;X-Requested-With&#8221; HTTP header on the server-side.</p>
<p>The form plugin also provides very useful methods when working with other aspects of forms. You can use clearForm() and resetForm() to clear and reset forms. Getting the actual value of certain form fields can be quite complicated, caused why certain browser-differences. fieldValue() takes the burden to lift this issue from you. It even returns the correct value for option elements with no value attribute specified, which can be quite tricky in IE.</p>
<p><strong>Update:</strong><br />
Mike pointed out some minor issues and an update: before and after callbacks are deprecated in favor of beforeSubmit and success, and the validation must be for &#8220;!formdata.length&#8221;, I forgot the invertion. The explanation for ajaxForm was inaccurate, that is fixed, too. Updated above. Thanks Mike!</p>
]]></content:encoded>
			<wfw:commentRss>http://bassistance.de/2007/01/01/plugin-parade-2-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Plugin parade #1: metadata</title>
		<link>http://bassistance.de/2006/12/29/plugin-parade-1-metadata/</link>
		<comments>http://bassistance.de/2006/12/29/plugin-parade-1-metadata/#comments</comments>
		<pubDate>Fri, 29 Dec 2006 14:32:47 +0000</pubDate>
		<dc:creator>Jörn</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugin Parade]]></category>

		<guid isPermaLink="false">http://bassistance.de/2006/12/29/plugin-parade-1-metadata/</guid>
		<description><![CDATA[A common problem when developing web applications is to provide some data from your server-side to client-side scripts. Consider a client-side form validation: You don&#8217;t want to generate tons of inline scripts and you don&#8217;t want to dynamically generate your javascript files. So you need a way to provide and read metadata from the HTML [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem when developing web applications is to provide some data from your server-side to client-side scripts. Consider a client-side form validation: You don&#8217;t want to generate tons of inline scripts and you don&#8217;t want to dynamically generate your javascript files. So you need a way to provide and read metadata from the HTML markup. And of course as unobtrusive as possible.</p>
<p>After a longer discussion about this matter on the jQuery mailing list, John Resig developed the initial version of the metadata plugin. Afterwards, Yehuda Katz wrote the first documentation and I improved both some more and wrote some tests.</p>
<p><a href="http://jquery.com/dev/svn/trunk/plugins/metadata/metadata.js?format=txt">Metadata plugin source (requires jQuery 1.0.4+, contains detailed documentation)</a><br />
<a href="http://joern.jquery.com/metadata/metadataTest.html">Metdata Testsuite</a><br />
<a href="http://visualjquery.com/index.xml">Documentation on Visual jQuery (Plugins/Metadata), though a bit outdated</a></p>
<p>The default usage is to put javascript objects inside the class attribute of your elements. Once the metadata plugin is loaded and you access an element, the plugin reads the data and provides it as a property on the element.</p>
<p>I&#8217;m using the plugin for the yet-to-be-released version of my validation plugin. You define an input that requires an email address to be entered with this code:</p>
<p><code>&lt;input id="email" name="email" class="<b>{email:true}</b>" /&gt;</code></p>
<p>The validation plugin searches for all input elements inside the form that it validates and reads the metadata via the data() method:</p>
<p><code>data = $(element).data();</code></p>
<p>I highly recommend using the class attribute for metadata. As long as you put the data inside {}-brackets and avoid any spaces, you won&#8217;t produce any problems with stylesheets. And according to the HTML specification, the purpose of the class attribute is for both CSS classes and other data.</p>
]]></content:encoded>
			<wfw:commentRss>http://bassistance.de/2006/12/29/plugin-parade-1-metadata/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
