<?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>delusionworld blog &#187; Milkbox</title>
	<atom:link href="http://www.delusionworld.com/tag/milkbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.delusionworld.com</link>
	<description>my MooTools, TYPO3 and FLOW3 experiences</description>
	<lastBuildDate>Sun, 01 Nov 2009 11:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MPR Best Practice &#8211; Plugin MultiOverlays</title>
		<link>http://www.delusionworld.com/mootools/mpr-best-practice-plugin-multioverlays/</link>
		<comments>http://www.delusionworld.com/mootools/mpr-best-practice-plugin-multioverlays/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 13:04:44 +0000</pubDate>
		<dc:creator>daKmoR</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Milkbox]]></category>
		<category><![CDATA[MultiOverlays]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Repository]]></category>

		<guid isPermaLink="false">http://www.delusionworld.com/?p=93</guid>
		<description><![CDATA[So now we have this local part of MPR to help us using MooTools Plugins. But howto create such Plugins and what should you use&#8230;
(bad) Examples
At first let me show you some examples why it&#8217;s not so easy currently to work with MooTools. I think the main reason is that it&#8217;s pretty hard to use [...]]]></description>
			<content:encoded><![CDATA[<p>So now we have this local part of MPR to help us using MooTools Plugins. But <strong>howto create</strong> such Plugins and what should you use&#8230;</p>
<h2>(bad) Examples</h2>
<p>At first let me show you some examples why it&#8217;s not so easy currently to work with MooTools. I think the main reason is that <strong>it&#8217;s pretty hard to use multiple files</strong> (js, css, img&#8230;) so people <strong>try to do everything in ONE file</strong>.</p>
<h3>Example <a href="http://mpr.mooforum.net/MprAdmin.php?mode=demo&#038;file=./Galleries/Milkbox/Demos/Milkbox.html">Milkbox</a>:</h3>
<p>Whenever you add it you will <strong>automatically add an Event to domready</strong> to create a milkbox with the default params&#8230; But what if I don&#8217;t want to use it on a page, I <strong>can&#8217;t easily disable it</strong> as I would <strong>need to edit the file</strong>.<br />
[don't get me wrong - milkbox is cool, I'm just saying it might be even better this way...]<br />
It would be nicer if separate in more files:</p>
<ul>
<li>Milkbox.js // class Milkbox &#8211; with the milkbox effect</li>
<li>Milkboxes.js // class Milkboxes &#8211; create multiple Milkboxes and has the logic for &#8220;galleries&#8221;</li>
<li>AutoMilkboxes.js // will require Milkboxes and will add it&#8217;s creation to the domready event</li>
</ul>
<p>With that now we can decide what we want to include. For the <strong>&#8220;basic&#8221; user</strong> its just $require( AutoMilkbox ); and people who know can decide if they either want one or multiple milkboxes. However as I said above <strong>using 3 files for one plugin</strong> without MPR is pretty inconvenient so people don&#8217;t do it. [and by inconvenient I mean <strong>it's freaking crazy</strong> to use 3 script tags for one little plugin - no no no; and yeah we all don't want to build our own script.json for each plugin... (little side kick to the devs..) :p]<br />
<strong>Now you can, just use MPR <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p>
<h3>Example <a href="http://www.clientcide.com/wiki/cnet-libraries/07-ui/11-waiter">clientcide Waiter</a>:</h3>
<p>[again, the waiter is cool, but it might be better this way]<br />
As you can see in it&#8217;s docs there if you have this &#8221; baseHref: &#8216;&#8230;&#8217; &#8221; which means that if you use the class the <strong>image will be by default loaded</strong> from this location: <a href="http://www.cnet.com/html/rb/assets/global/waiter/waiter.gif">http://www.cnet.com/html/rb/assets/global/waiter/waiter.gif</a> I think this is another &#8220;hack&#8221; around the <strong>MooTools policy</strong> &#8220;<em>don&#8217;t use more than one file in your Plugin</em>&#8221; *<em>hehe</em> offending people here&#8230;*.<br />
I mean what happens if this file gets forgotten? server upgrade &#8211; do we still need this waiter.gif? no, just delete it&#8230; :p ok that might be not the actual process but there is surely the<strong> possibility</strong> that <strong>this file will just vanish</strong> without a notice&#8230; why not deliver the file with the Plugin?<br />
It would gives me again a few benefits</p>
<ul>
<li>I can easily replace the image to my own (no need to change any js/css; just replace the file)</li>
<li>I can define/override the url in my css (if uses as background image) so again no need to change any javascript</li>
<li>What if I have multiple image files? I mean if I have a Plugin that uses some images from the cnet server; some from the plugin server; and some from my own server.. pretty hard to maintain right?</li>
</ul>
<h2>use of MPR within the Plugin <a href="http://mpr.mooforum.net/MprAdmin.php?mode=demo&#038;file=./Visual/MultiOverlays/Demos/MultiOverlays.html">MultiOverlays</a></h2>
<p>So now let&#8217;s take a closer look at a Plugin and a way I think it should be done. </p>
<h3>File MultiOverlay.js</h3>
<pre class="brush: javascript;">
$require(MPR.path + 'Core/Fx.Tween/Fx.Tween.js');
$require(MPR.path + 'More/Class.Occlude/Class.Occlude.js');
var MultiOverlay = new Class({
  ...
});
</pre>
<p>ok, here we define the <strong>requirements and the logic</strong> for one MultiOverlay. now if you want to use it I need to use it with an id and create the Class instance myself. If you know how it&#8217;s easy&#8230;</p>
<pre class="brush: javascript;">var myMultiOverlay = new MultiOverlay( $('imageWithId') );</pre>
<h3>File MultiOverlays.js</h3>
<p>this file is so short I will post it&#8217;s full code here&#8230;</p>
<pre class="brush: javascript;">
$require(MPR.path + 'Visual/MultiOverlays/MultiOverlay.js');
var MultiOverlays = new Class({
	multiOverlays: [],
	initialize: function(elements, options) {
		$$(elements).each( function(el) {
			this.multiOverlays.include( new MultiOverlay(el, options) );
		}, this);
	},
	getMultiOverlays: function() {
		return this.multiOverlays;
	}
});
</pre>
<p>So what do we get here, it just gives you the possibility to create <strong>Multiple MultiOverlay(s)</strong>&#8230; So now you can give the image(s) a class and for each image it will create a MultiOverlay instance which get&#8217;s saved in an array (if you may need it any time later&#8230;)</p>
<h3>File AutoMultiOverlays.js</h3>
<p>again such a short file&#8230; here is it&#8217;s code&#8230;</p>
<pre class="brush: javascript;">
$require(MPR.path + 'Visual/MultiOverlays/MultiOverlays.js');
var Auto = Auto || {};
window.addEvent('domready', function() {
	Auto.MultiOverlays = new MultiOverlays( '.MultiOverlay' );
});
</pre>
<p>basically it just creates a <strong>new MultiOverlays</strong> with a <strong>hard coded &#8220;default&#8221; value</strong>&#8230; so if you require this file you don&#8217;t need to write any javascript code at all, just give the CSS-class to your images and your done! <strong>It&#8217;s the easiest way you can do it&#8230; </strong>[here the value get's saved in the Auto variable as I might still want to use it later... the Auto variable is globally here]</p>
<h3>So why all this files?</h3>
<p>As I said above I think it&#8217;s vital to <strong>separate logic</strong> to where it belongs. And for me that means if I want to have a single MultiOverlay I should be able to. So the logic for Multiple MultiOverlays shouldn&#8217;t be in it, as it&#8217;s just more stuff I don&#8217;t need&#8230; :p<br />
And while we are at it, now that we need a Folder for it let&#8217;s add the <a href="http://mpr.mooforum.net/MprAdmin.php?mode=docu&#038;file=./Visual/MultiOverlays/Docu/MultiOverlays.md">Docu</a>. So now we got <strong>demos, docu, Resources</strong>(css, images) all in a single <a href="http://mpr.mooforum.net/MprAdmin.php?mode=zip&#038;file=Visual/MultiOverlays">Plugin Zip file</a>.<br />
It&#8217;s just <strong>easy to send</strong> it to someone and <strong>he get&#8217;s everything</strong> &#8211; I don&#8217;t need to explain what css image files he has to manually include&#8230; If you have a local MPR you can just <strong>install it in the admin area</strong>&#8230;.  (talking about easy&#8230; <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p>What do you want to hear next? more MPR best Pratice?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.delusionworld.com/mootools/mpr-best-practice-plugin-multioverlays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
