<?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>Sanjeev Shrestha &#187; Mootools</title>
	<atom:link href="http://www.sanjeevshrestha.com.np/category/mootools/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sanjeevshrestha.com.np</link>
	<description>Blogging on Joomla Development /Codeigniter/JQuery/Mootools/Wordpress - All Related to Web</description>
	<lastBuildDate>Sun, 09 May 2010 08:15:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating Color Element in Joomla for custom parameter type</title>
		<link>http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/</link>
		<comments>http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:14:58 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[color element]]></category>
		<category><![CDATA[color element for joomla]]></category>
		<category><![CDATA[color picker for joomla]]></category>
		<category><![CDATA[custom parameters]]></category>
		<category><![CDATA[Joomla element]]></category>
		<category><![CDATA[moorainbow]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/</guid>
		<description><![CDATA[Elements are of utmost importance in Joomla development. Elements allows you to create custom parameter type that you can use in your metadata files. Metadata files are xml files that are used to provide configuration parameters to your component, module, plugin or even views. Metadata files for your views are used configure menu links that [...]]]></description>
			<content:encoded><![CDATA[<p><img style="max-width: 800px; float: right; margin-top: 10px; margin-bottom: 10px; margin-left: 10px;" src="http://www.sanjeevshrestha.com.np/wp-content/uploads/2009/04/joomla-ogo.png" alt="" />Elements are of utmost importance in Joomla development. Elements allows you to create custom parameter type that you can use in your metadata files. Metadata files are xml files that are used to provide configuration parameters to your component, module, plugin or even views. Metadata files for your views are used configure menu links that that will use that view.</p>
<p>In this short tutorial, I will tell about creating elements and using it differently on different places. Elements are special files that generally adds value to parameters. For this tutorial, I will create a color element that  can be used in different components, modules, plugins where color selection is done through a color picker. I will use <a href="http://moorainbow.woolly-sheep.net" target="_blank">moorainbow</a> as web color picker. <!-- more --><span id="more-351"></span><br />
Also note, I am creating this element for my <a href="http://www.gobingoo.com" target="_blank">adsensebingo module</a>. Hence this code has been tested and used.</p>
<h1>Creating Color Element File</h1>
<p>Element file are generally single php file that has element class that extends JElement base class. The class overrides fetchElement method  of JElement Base class to provide color picker.<br />
Let us create a folder that will hold all files necessary for color element.  Let us call this folder &#8220;element&#8221;. Download the latest moorainbow library and place it in a subfolder directly below the elements folder. Now create a color.php file . This file is the element file and has a class JElementColor that extends JElement base class.<br />
Now override fetchElement method of JElement base class.  The important part of element is the fetchElement method. This method actually returns data that can be used by parameters.</p>
<p>A little explanation about fetchElement is necessary. method fetchElement requires 4 arguments namely<br />
$name &#8211; is the unique name of the parameter, from the <strong>name</strong> argument.<br />
$value &#8211; is the current value of the parameter.<br />
$node &#8211; is a <em>JSimpleXMLElement</em> object representing the <em>&lt;param&gt;</em> element.<br />
$control_name &#8211; is the parameter type from the <strong>type</strong> argument (eg. &#8216;category&#8217; or &#8216;color&#8217;).</p>
<p>The fetchElement method for Color element is as below</p>
<pre class="brush:php">function fetchElement($name, $value, &amp;$node, $control_name)
{
        ob_start();
        $img=JUri::root()."modules/mod_adsensebingo/elements/moorainbow/images/rainbow.png";
        $imgx=JUri::root()."modules/mod_adsensebingo/elements/moorainbow/images/";
        static $embedded;
                if(!$embedded)
        {
            $css2=JUri::root()."modules/mod_adsensebingo/elements/moorainbow/css/mooRainbow.css";
            $jspath=JUri::root()."modules/mod_adsensebingo/elements/moorainbow/js/mooRainbow.js";
             ?&gt;
&lt;link
    href="&lt;?php echo $css2;?&gt;" type="text/css" rel="stylesheet" /&gt;
&lt;script src="&lt;?php echo $jspath;?&gt;"&gt;&lt;/script&gt;

            &lt;?php
            $embedded=true;

        ?&gt;
&lt;script&gt;

            window.addEvent('domready',function(){
//Get sibling function from http://www.sanjeevshrestha.com.np
                Element.extend({
                    getSiblings: function() {
                        return this.getParent().getChildren().remove(this);
                    }
                });
            $('.rainbowbtn').each(function(item){

         item.color=new MooRainbow(item.id, {
                    startColor: [58, 142, 246],
                    wheel: true,
                    id:item.id+'x',
                    onChange: function(color) {

                    item.getSiblings()[0].value = color.hex;
                    },
                    onComplete: function(color) {

                    item.getSiblings()[0].value = color.hex;
                    },

                    imgPath: '&lt;?php echo $imgx;?&gt;'

                });

                });
            });
            &lt;/script&gt;
            &lt;?php
        }
            ?&gt;
            &lt;label&gt;
&lt;input
    name="&lt;?php echo $control_name;?////&gt;[&lt;?php echo $name;?&gt;]" type="text"
    class="inputbox" id="&lt;?php echo  $control_name.$name ?&gt;"
    value="&lt;?php echo $value;?&gt;" size="10" /&gt;
&lt;img
    src="&lt;?php echo $img;? /&gt;" id="img&lt;?php echo $name; ?&gt;" alt="[r]"
    class="rainbowbtn" width="16" height="16" /&gt;&lt;/label&gt;
        &lt;?php

        $content=ob_get_contents();

        ob_end_clean();
        return $content;

    }</pre>
<p>That is it.</p>
<h1>Using it in Module Parameters.</h1>
<p>Now let us use this in module parameter. Parameters are generally written in<br />
element block. For these params block to render our color element we need to specify path to our elements folder in this params element node as below</p>
<pre class="brush:xml">&lt;params addpath="[path]/elements"&gt; &lt;/param&gt;
--- list of &lt;param&gt; elements ---
&lt;/params&gt;</pre>
<p>In our case this is written as</p>
<pre class="brush:xml">&lt;params addpath="/modules/mod_adsensebingo/elements"&gt; &lt;/param&gt;
&lt;param name="foreground" type="color" default="#CC0000" label="Foreground Color" description="Select foreground color for your google ad" &gt; &lt;/param&gt;
-- other &lt;param&gt; elements
&lt;/params&gt;</pre>
<p><img style="max-width: 800px; float: right; margin-top: 10px; margin-bottom: 10px; margin-left: 10px;" src="http://www.sanjeevshrestha.com.np/wp-content/uploads/2010/01/shot.jpg" alt="" />Now this block is aware of new elment type and knows where to find the element rendering code. The parameter section of module setting page now correctly shows a color picker.<br />
You can create any kind of elments, from a simple integer list to a complex color element or elements that shows records from your component. The usage is limitless.</p>
<p>That is all for color element. More to come on element tutorials till then happy reading.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=6b5df7d5-8092-87e7-9ea2-5ad121049b12" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Mootools 1.2 in Joomla1.5.x</title>
		<link>http://www.sanjeevshrestha.com.np/2009/07/using-mootools-12-in-joomla15x/</link>
		<comments>http://www.sanjeevshrestha.com.np/2009/07/using-mootools-12-in-joomla15x/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 03:46:04 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools 1.2]]></category>
		<category><![CDATA[Using mootools 1.2.x with joomla]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/2009/07/using-mootools-12-in-joomla15x/</guid>
		<description><![CDATA[Yes! Joomla 1.5.x comes with mootools 1.1.x and it is a pity when you cannot use best of the latest mootools widgets with joomla 1.5.x.  To make the matter worse, you will rarely find forums and blogs that discusses about mootools 1.1. In this case you will definitely want to use mootools 1.2.x with Joomla [...]]]></description>
			<content:encoded><![CDATA[<p><img style="max-width: 800px; float: right; margin-top: 10px; margin-bottom: 10px; margin-left: 10px;" src="http://www.sanjeevshrestha.com.np/wp-content/uploads/2009/06/mootools-new-logo.jpg" alt="" />Yes! <strong>Joomla 1.5.x</strong> comes with <strong>mootools 1.1.x</strong> and it is a pity when you cannot use best of the latest mootools widgets with joomla 1.5.x.  To make the matter worse, you will rarely find forums and blogs that discusses about mootools 1.1. In this case you will definitely want to use mootools 1.2.x with Joomla in the frontend. So in this small tutorial, we will talk about how to use mootools1.2.x with Joomla 1.5.x. Remember the admin panel of Joomla will still use mootools 1.1.x.</p>
<p>I have written a post about how to use <a href="http://www.sanjeevshrestha.com.np/2009/05/using-jquery-with-joomla/">jQuery with Joomla</a> earlier. This tutorial is just a slight modification of the codes from the earlier post.<br />
<span id="more-253"></span>To use <strong>mootools 1.2.x</strong> with <strong>Joomla 1.5.x</strong>, follow the following steps.</p>
<ol>
<li>Download the mootools core from the mootools <a href="http://mootools.net/core">core builder site</a></li>
<li>Also Download the additional plugins you will use with your installation from <a href="http://mootools.net/more">more builder</a>. I recommend downloading both compressed and uncompressed files from the mootools builder. We may need uncompressed files in debuggin mode.</li>
<li>Copy these files in a folder that can be accessed by Joomla. I recommend media-&gt;system-&gt;js folder of joomla installation. The choice is yours! <img src='http://www.sanjeevshrestha.com.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ol>
<p>I copied four <strong>files mootools-1.2.3-core.js</strong>, <strong>mootools-1.2.3-core-compressed.js</strong>, <strong>mootools-1.2.3.1-more.js</strong> and <strong>mootools-1.2.3.1-more-compressed.js</strong> to <strong>media-&gt;system-&gt;js</strong> folder. Now locate and open a file named <strong>behavior.php</strong> which is inside <strong>libraries-&gt;joomla-&gt;html-&gt;html</strong> folder. Now find a method named <strong>mootools($debug=null) </strong>and modify it as below.</p>
<blockquote><p>function mootools($debug = null)<br />
{<br />
static $loaded;<br />
$mainframe=&amp;JFactory::getApplication();<br />
// Only load once<br />
if ($loaded) {<br />
return;<br />
}</p>
<p>// If no debugging value is set, use the configuration setting<br />
if ($debug === null) {<br />
$config = &amp;JFactory::getConfig();<br />
$debug = $config-&gt;getValue(&#8216;config.debug&#8217;);<br />
}</p>
<p>$konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), &#8220;konqueror&#8221;) : null;</p>
<p>if($mainframe-&gt;isSite())<br />
{<br />
if ($debug || $konkcheck)<br />
{<br />
JHTML::script(&#8216;mootools-1.2.3-core.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
JHTML::script(&#8216;mootools-1.2.3.1-more.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
}<br />
else<br />
{<br />
JHTML::script(&#8216;mootools-1.2.3-core-compressed.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
JHTML::script(&#8216;mootools-1.2.3.1-more-compressed.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
}<br />
$loaded = true;<br />
return;</p>
<p>}<br />
else<br />
{</p>
<p>if ($debug || $konkcheck)<br />
{<br />
JHTML::script(&#8216;mootools-uncompressed.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
}<br />
else<br />
{<br />
JHTML::script(&#8216;mootools.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />
}<br />
$loaded = true;<br />
return;<br />
}<br />
}</p></blockquote>
<p>This modified mootools behavior checks if the site is accessed from frontend or is it admin. if it is frontend it loads the mootools 1.2.x depending upon the debug mode. It will load uncompressed files in debug mode. This will load both core and more files in frontend. The admin still uses mootools 1.1.x as it heavily depends on it.</p>
<p>This is all! It worked for me. Let me know if it did or not for you. Happy reading!</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=80c86ad4-b30e-8266-8f30-316fefe92af5" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2009/07/using-mootools-12-in-joomla15x/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Implementing Element.getSiblings() in mootools1.1</title>
		<link>http://www.sanjeevshrestha.com.np/2009/06/implementing-elementgetsiblings-in-mootools11/</link>
		<comments>http://www.sanjeevshrestha.com.np/2009/06/implementing-elementgetsiblings-in-mootools11/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 05:43:18 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[getSiblings()]]></category>
		<category><![CDATA[mootools 1.1]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/2009/06/implementing-elementgetsiblings-in-mootools11/</guid>
		<description><![CDATA[I found a nice mootools code in David Walsh&#8217;s Blog. This code gathers all the siblings of an element but this code is compatible with mootools1.2 and above. I have modified the code a little to implement it in mootools1.1. Why mootools 1.1? because Joomla1.5 still uses mootools1.1. (Joomla1.6 will have mootools1.2). So here is [...]]]></description>
			<content:encoded><![CDATA[<p>I found a nice mootools code in <a href="http://davidwalsh.name/mootools-element-siblings">David Walsh&#8217;s Blog</a>. This code gathers all the siblings of an element but this code is compatible with mootools1.2 and above. I have modified the code a little to implement it in mootools1.1. Why mootools 1.1? because Joomla1.5 still uses mootools1.1. (Joomla1.6 will have mootools1.2). So here is the little modification of the code as presented by <a href="http://davidwalsh.name">David Walsh</a>.</p>
<blockquote><p>Element.extend({<br />&nbsp;&nbsp;&nbsp; getSiblings: function() {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.getParent().getChildren().remove(this);<br />&nbsp;&nbsp;&nbsp; }<br />});</p></blockquote>
<p>Yes, this small code gathers all the siblings of the element except for itself. Isn&#8217;t it simple? <img src='http://www.sanjeevshrestha.com.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2009/06/implementing-elementgetsiblings-in-mootools11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajaxifying Joomla Links with Mootools</title>
		<link>http://www.sanjeevshrestha.com.np/2009/06/ajaxifying-joomla-links-with-mootools/</link>
		<comments>http://www.sanjeevshrestha.com.np/2009/06/ajaxifying-joomla-links-with-mootools/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 18:21:21 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Ajaxifying joomla]]></category>
		<category><![CDATA[Implementing ajax in joomla]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/2009/06/ajaxifying-joomla-links-with-mootools/</guid>
		<description><![CDATA[
Have you ever wanted to automatically ajaxify joomla links? This is to say if you ever wished that all the links would open with ajax request in your main component area! If yes, then read on! This small tutorial will teach you how to automatically implement ajax requests in every link on a joomla page.
To [...]]]></description>
			<content:encoded><![CDATA[<div align="left"><img style="max-width: 800px; float: left; margin-top: 10px; margin-bottom: 10px; margin-right: 10px;" src="http://www.sanjeevshrestha.com.np/wp-content/uploads/2009/06/mootools-new-logo.jpg" /></div>
<p>Have you ever wanted to automatically ajaxify joomla links? This is to say if you ever wished that all the links would open with ajax request in your main component area! If yes, then read on! This small tutorial will teach you how to automatically implement ajax requests in every link on a joomla page.</p>
<p>To implement Ajax request in every link in a joomla page you need to modify index.php of joomla template. <span id="more-227"></span></p>
<p>Add the code below in index.php</p>
<blockquote><p>&lt;script&gt;<br/><!--<br/>window.addEvent(&#8216;domready&#8217;,function(){<br/>ajaxify();<br/>});<br/><br/>function ajaxify()<br/>{<br/>&nbsp;&nbsp;&nbsp; $$(&#8216;a&#8217;).addEvent(&#8216;click&#8217;,function(e){<br/><br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var e=new Event(e);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; e.stop();<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $(&#8216;ajaxstage&#8217;).setHTML(&#8216;Loading&#8230;&#8217;);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; req=new Ajax(this.href+&#8217;&amp;tmpl=component&#8217;,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; update:&#8217;ajaxstage&#8217;,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; method:&#8217;get&#8217;,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; onComplete:ajaxify<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; req.request();<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; }<br/>&#8211;><br/>&lt;/script&gt;
</p></blockquote>
<p>This code will implement ajax in every link it finds in a page. The function is recursive, in the sense it will call itself to ajaxify the newly added links by ajax request. Wait, you need to wrap the component in a div to make this work. Find a code similar to </p>
<blockquote><p>
&lt;jdoc:include type=&#8221;component&#8221; /&gt;
</p></blockquote>
<p>and replace it with</p>
<blockquote><p>&lt;div id=&#8221;ajaxstage&#8221;&gt;<br />
&lt;jdoc:include type=&#8221;component&#8221;><br />
&lt;/jdoc:include&gt;&lt;/div&gt;
</p></blockquote>
<p>This div is the stage where the content that is fetched with ajax is updated with. Yes it is this simple. But make sure you have mootools included in your template. If not add the code below to add mootools support in your template.</p>
<blockquote><p>
&lt;?php JHTML::_(&#8216;behavior.mootools&#8217;); ?&gt;
</p></blockquote>
<p>Yes, this concludes the tutorial. Isn&#8217;t it a nifty hack to implement ajax in a joomla page.<br />
Keep coming back for more tips and tricks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2009/06/ajaxifying-joomla-links-with-mootools/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using jQuery with Joomla!</title>
		<link>http://www.sanjeevshrestha.com.np/2009/05/using-jquery-with-joomla/</link>
		<comments>http://www.sanjeevshrestha.com.np/2009/05/using-jquery-with-joomla/#comments</comments>
		<pubDate>Fri, 08 May 2009 09:49:50 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[jquery conflict]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/?p=203</guid>
		<description><![CDATA[Joomla ! (till Ver 1.5.10)&#160; by default supports mootools 1.11. The core is still not updated to use mootools 1.2x version. 
Now back to the topic. jQuery and Mootools are known to produce conflicts when used together. jQuery is more reliable and robust than mootools (It is my personal view)&#160; but it is however not [...]]]></description>
			<content:encoded><![CDATA[<p><img style="max-width: 800px; float: right; margin-top: 10px; margin-bottom: 10px; margin-left: 10px;" src="http://www.sanjeevshrestha.com.np/wp-content/uploads/2009/05/jquery-on-white.gif" />Joomla ! (till Ver 1.5.10)&nbsp; by default supports mootools 1.11. The core is still not updated to use mootools 1.2x version. </p>
<p>Now back to the topic. jQuery and Mootools are known to produce conflicts when used together. jQuery is more reliable and robust than mootools (It is my personal view)&nbsp; but it is however not provided with core joomla installation. So how to use jQuery with Mootools without any conflicts.&nbsp; <br /><span id="more-203"></span></p>
<p>To use jQuery with joomla, 
<ul>
<li>Download the latest jQuery release or any releast the best fit your requirements, </li>
<li>Save it to an accessible folder (e.g. /media/system/js/)</li>
<li>Now include the library from within your view. i.e. include the jquery library in layout file (normally default.php) of your view. </li>
</ul>
<blockquote><p>
<div class="codecontent">$document = &amp;JFactory::getDocument();<br />$document-&gt;addScript(JPATH_SITE.&#8217;/media/system/js/jquery.js&#8217; );<br />$document-&gt;<span class="method-title">addScriptDeclaration</span> ( &#8216;jQuery.noConflict();&#8217; );</div>
</blockquote>
<p>You can use jQuery with <b>jQuery.noConflict()</b> method called right after you include the jQuery library as shown above. </p>
<p>This will allow you to use the jQuery without conflicts. But what if you want to replace all the mootools library with jQuery and don&#8217;t want to use mootools at all. But remember the Joomla Administrator section uses mootools heavily so you cannot eliminate mootools from administration panel. So how to use jQuery in frontend. Here is the trick.</p>
<p>Open a file named <b>behavior.php</b>. This is under <b>libraries-&gt;joomla-&gt;html-&gt;html</b>. Now find a method named <b>mootools($debug = null)</b>. Create another function named jQuery(debug=null) and paste the code as below in the body of the function.<br />
<blockquote>function jQuery($debug = null)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static $loaded;</p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; global $mainframe;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Only load once<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($loaded) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // If no debugging value is set, use the configuration setting<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($debug === null) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $config = &amp;JFactory::getConfig();<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $debug = $config-&gt;getValue(&#8216;config.debug&#8217;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $konkcheck = strpos (strtolower($_SERVER['HTTP_USER_AGENT']), &#8220;konqueror&#8221;);</p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($debug || $konkcheck) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; JHTML::script(&#8216;jquery.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if($mainframe-&gt;isSite()) {</p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; JHTML::script(&#8216;jquery.min.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; JHTML::script(&#8216;mootools.js&#8217;, &#8216;media/system/js/&#8217;, false);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $loaded = true;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br />&nbsp;&nbsp;&nbsp; }</p></blockquote>
<p>Now you can use jQuery in the frontend but the admin still uses the mootools. With this method you will not face any conflicts and use jQuery without mootools.</p>
<p>The jquery.min.js is the minified version of jQuery library whereas the jquery.js is uncompressed version. Remember to put these both files under <b>media-&gt;system-&gt;js</b> folder.</p>
<p>To use jQuery in your codes just call <b>JHTML::_(&#8216;behavior.jQuery&#8217;)</b> to import jquery into your page. isn&#8217;t it cool to use jquery with joomla. I dreamt of it for long.</p>
<p>Send me comments and suggestions on this post. Happy reading</p>
<p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=b7b0e418-7211-8bc8-a24e-0359a8d8d492" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2009/05/using-jquery-with-joomla/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Simple Show &amp; Hide with Mootools</title>
		<link>http://www.sanjeevshrestha.com.np/2009/04/simple-show-hide-with-mootools/</link>
		<comments>http://www.sanjeevshrestha.com.np/2009/04/simple-show-hide-with-mootools/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 09:48:24 +0000</pubDate>
		<dc:creator>Sanjeev</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[show]]></category>

		<guid isPermaLink="false">http://www.sanjeevshrestha.com.np/2009/04/simple-show-hide-with-mootools/</guid>
		<description><![CDATA[I see few of my colleagues struggling through long codes, just to implement simple show and&#160; hide. Yes this can be done with simple javascript code, but the implementation is repetitive and cumbersome. Show and hide is used in almost every web site here and there. So this post should be helpful to those people [...]]]></description>
			<content:encoded><![CDATA[<p>I see few of my colleagues struggling through long codes, just to implement simple show and&nbsp; hide. Yes this can be done with simple javascript code, but the implementation is repetitive and cumbersome. Show and hide is used in almost every web site here and there. So this post should be helpful to those people who really want a simple solution to this simple yet tedious problem! <img src='http://www.sanjeevshrestha.com.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Mootools is a gem of javascript libraries. And implementing a simple show hide is even more simpler with mootools. This code snippet can be used anywhere within a webpage to implement a simple Show Hide. Here is the code<span id="more-133"></span></p>
<blockquote>
<p>window.addEvent(&#8216;domready&#8217;,function(){</p>
<p>Element.extend(&nbsp;&nbsp;&nbsp;&nbsp; //Implement the following functions in every element existent in the webpage<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; show:function(e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setStyle(&#8216;display&#8217;,'block&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hide:function(e){&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setStyle(&#8216;display&#8217;,'none&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</p>
<p>});
</p></blockquote>
<p>This mootools snippet implements the custom method show and hide in every element of the webpage. This means we can use the simple $(&#8216;element&#8217;).hide(); and $(&#8216;element&#8217;).show(); to show and hide the element.&nbsp; (A piece of cake, isn&#8217;t it?)</p>
<p>The above code snippet should be written in the script section <img src='http://www.sanjeevshrestha.com.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  yes you know it!!</p>
<p>The remaining html implementation is as below</p>
<blockquote>
<p>&lt;span onclick=&#8221;$(&#8217;stage&#8217;).hide();&#8221;&gt;Hide&lt;/span&gt;</p>
<p>&lt;span onclick=&#8221;$(&#8217;stage&#8217;).show();&#8221;&gt;show&lt;/span&gt;</p>
<p>&lt;div id=&#8221;stage&#8221;&gt;</p>
<p>This is the text to be hidden or shown </p>
<p>This is the text to be hidden or shown </p>
<p>This is the text to be hidden or shown </p>
<p>This is the text to be hidden or shown </p>
<p>&lt;/div&gt;</p>
</blockquote>
<p>The html section shows the general usage of the show hide method we just implemented in every element. This code is handy! just copy and use it in your pages. Yes, you can copy!</p>
<p>I will soon maintain a demo site to see all the codes in action.<br />
Till then happy reading <img src='http://www.sanjeevshrestha.com.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=030995aa-4ed0-8471-9ff5-02a1dad912a2" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sanjeevshrestha.com.np/2009/04/simple-show-hide-with-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
