<?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>Saki's Blog &#187; extension</title>
	<atom:link href="http://blog.extjs.eu/tag/extension/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.extjs.eu</link>
	<description>For good of all productive developers</description>
	<lastBuildDate>Sun, 21 Nov 2010 01:36:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Writing a Big Application in Ext (Part 3)</title>
		<link>http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-3/</link>
		<comments>http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-3/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 12:53:34 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[extjs]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=234</guid>
		<description><![CDATA[<br/>Important
If you have not already done so, study Writing a Big Application in Ext (Part 1) and Writing a Big Application in Ext (Part 2)before you read this article. It would be very hard, if not impossible, to understand concepts explained here before you fully understand the first and second part.
Introduction
Helping on the forum and [...]]]></description>
			<content:encoded><![CDATA[<br/><h2 style="margin-top:30px"><em>Important</em></h2>
<p>If you have not already done so, study <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/" style="font-size:125%;">Writing a Big Application in Ext (Part 1)</a> and <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-2/" style="font-size:125%;">Writing a Big Application in Ext (Part 2)</a>before you read this article. It would be very hard, if not impossible, to understand concepts explained here before you fully understand the first and second part.</p>
<h1>Introduction</h1>
<p>Helping on the <a href="http://extjs.com/forum" target="_blank">forum</a> and reading code of others that failed to extend Ext classes, revealed more errors that users, especially beginners, commonly make. Therefore, I&#8217;ve decided to start this article that will collect these errors and will explain why the errors <i>are</i> errors. I mean it as loosely ended as I may discover more errors and ways of avoiding them so I plan just to add them to <i>this</i> article, not endlessly create parts 4, 5, etc&#8230;</p>
<h1><span style="font-size:12px">&#8230; continued:</span> Most Common Sources of Troubles</h1>
<p>Here we go:</p>
<ol>
<li><a href="#unnecessary-extending">Unnecessary Extending</a></li>
<li><a href="#adding-objects-to-prototype">Adding Objects to Prototype</a></li>
<li><a href="#hard-coding-ids">Hard Coding ids</a></li>
</ol>
<p>&nbsp;</p>
<h2 id="unnecessary-extending">Unnecessary Extending</h2>
<p>The main reasons for extending are:</p>
<ul>
<li>re-usability</li>
<li>adding functionality</li>
<li>combination of them</li>
</ul>
<p>so we extend if we need a re-usable component <b>or</b> we need to add a functionality (new methods) or both. If we are after <b>re-usability</b> the extension can be as simple as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">MyPortlet <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Panel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     anchor<span style="color: #339933;">:</span><span style="color: #3366CC;">'100%'</span>
    <span style="color: #339933;">,</span>draggable<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #339933;">,</span>defaultType<span style="color: #339933;">:</span><span style="color: #3366CC;">'mygraph'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You see what happens? We are going to use MyPortlet many times so instead of scatter the above configuration in 10,000 lines application code 100 times, we create this simple extension and we save 297 lines of code. </p>
<p>The other aspect is that if we upgrade our &#8216;mygraph&#8217; to &#8216;mygraph_new&#8217; the only place where to change it is our extension saving us searching out code for all occurrences of &#8216;mygraph&#8217; (100 times) and replacing it with &#8216;mygraph_new&#8217; 100 times.</p>
<p>(Well, 100 is exaggerated, but you get the point, right?)</p>
<p>If we are after <b>adding functionality</b>, which can be also simple, we add some &#8220;logic&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">MyPanel <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Panel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    onRender<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        MyPanel.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">onRender</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Rendered'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here we add some logic to Panel, it <b>does more</b> that it did before. </p>
<p><b>There is no need to extend in all other cases.</b></p>
<p>&nbsp;</p>
<h2 id="adding-objects-to-prototype">Adding Objects to Prototype</h2>
<p>Run this code first:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/resources/css/ext-all.css&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/adapter/ext/ext-base.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/ext-all-debug.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page-title&quot;</span>&gt;</span>Extending Error: Object in prototype<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
  Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
  Ext.onReady(function() {
    MyPanel = Ext.extend(Ext.Panel, {
         layout:'fit'
        ,panelConfig: {
            bodyBg:'red'
        }
&nbsp;
        ,initComponent:function() {
            var config = {
                bodyStyle:'background-color:' + this.panelConfig.bodyBg
            }; // eo config object
&nbsp;
            // apply config
            Ext.apply(this, Ext.apply(this.initialConfig, config));
&nbsp;
            MyPanel.superclass.initComponent.apply(this, arguments);
        } // eo function initComponent
&nbsp;
        ,applyBackground:function(color) {
            this.panelConfig.bodyBg = color;
            this.body.applyStyles({'background-color':color});
        } // eo function applyBackground
&nbsp;
    }); // eo extend
&nbsp;
    var p1 = new MyPanel({
         title:'Panel with Blue Background'
        ,renderTo:Ext.getBody()
        ,width:240
        ,height:160
    });
&nbsp;
    p1.applyBackground('blue');
&nbsp;
    var p2 = new MyPanel({
         title:'Panel with Red Background'
        ,renderTo:Ext.getBody()
        ,width:240
        ,height:160
    });
&nbsp;
  });
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>What do we expect? It is written in titles of panels: Top panel (p1) should have <b>blue</b> body background because we set it to it after it is created. And bottom panel (p2) should have <b>red</b> because we just create default <code>MyPanel</code>.</p>
<p><b>But it is blue too!!! Why?</b> The reason is simple: <code>panelConfig</code> is object that is created during <i>class definition</i> and it is added to MyPanel prototype. Objects (arrays too) are accessed by reference so p1 and p2 <b>share the same instance of <code>panelConfig</code></b>. Setting <code>bodyBg</code> property in <code>applyBackground</code> method changes this single instance of <code>panelConfig</code> object. So we create p2 with blue background too.</p>
<p>You see, here it is clearly and immediately visible that something went wrong but making this error can lead to weeks of wasted debugging time in real applications. Imagine you have a store in prototype&#8230;</p>
<p>&nbsp;</p>
<h2 id="hard-coding-ids">Hard Coding ids</h2>
<p>Very simple, but deadly mistake is to set ids in the extension either to the main extension object or on its items, toolbars, buttons, etc. If a hard coded ids are set we cannot create two or more instances of our extension, can we?</p>
<h1>Loose End</h1>
<p>That&#8217;s all for now but if I discover more errors I will add them above. </p>
<p>Stay tuned!</p>
<p><strong><em>Do not forget to read <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/">Part 1</a> and <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-2/">Part 2</a> of this article. </em></strong></p>
<p>Follow up: <strong><a href="http://blog.extjs.eu/know-how/factory-functions-in-ext-extensions/">Factory Functions in Ext Extensions (Abstract Classes)</a></strong></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-3/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>New Example</title>
		<link>http://blog.extjs.eu/examples/new-example-6/</link>
		<comments>http://blog.extjs.eu/examples/new-example-6/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 07:31:36 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=201</guid>
		<description><![CDATA[<br/>Hi,
I&#8217;ve just uploaded the example of populating a combo with data loaded from server on form load.
http://examples.extjs.eu
Enjoy!
]]></description>
			<content:encoded><![CDATA[<br/><p>Hi,</p>
<p>I&#8217;ve just uploaded the example of populating a combo with data loaded from server on form load.</p>
<p><a target="_blank" href="http://examples.extjs.eu?ex=popcombo">http://examples.extjs.eu</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/examples/new-example-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extension or Plugin?</title>
		<link>http://blog.extjs.eu/know-how/extension-or-plugin/</link>
		<comments>http://blog.extjs.eu/know-how/extension-or-plugin/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 01:05:26 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=64</guid>
		<description><![CDATA[<br/>Preface
I believe that many of Ext users have already thought about adding some custom functionality that is not present in core Ext Library to a class. Something that is specific to their applications or not that specific so that others could also be interested in such feature.
OK, we have the idea, we know what the [...]]]></description>
			<content:encoded><![CDATA[<br/><h1>Preface</h1>
<p>I believe that many of Ext users have already thought about adding some custom functionality that is not present in core Ext Library to a class. Something that is specific to their applications or not that specific so that others could also be interested in such feature.</p>
<p>OK, we have the idea, we know what the new code should do, we even know how to write it, but <i>what</i> should we write? An Extension or a Plugin?</p>
<h1>Extensions and Plugins</h1>
<p>The fact we are talking about them together and the fact that we can be even indecisive which one to use infers that they must have something in common. True, they have. They both <i>add</i> some functionality to an existing library or <i>modify</i> a feature of the library.</p>
<p>Neither extension nor plugin can exist standalone; they have to have a component, a class, they extend or plug into.</p>
<h1>Extension</h1>
<p>An extension (in Ext world) is a <a href="http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29" target="_blank">derived class</a> in fact. Let&#8217;s imagine we have a basic class with some general methods to which we want to add some more specific methods. So, using the inheritance framework of an library or a language we <b>create new class</b> that contains methods of both basic class and new added methods.</p>
<p>We choose an <b>existing</b> Ext class, we extend it using <b><code>Ext.extend</code></b> function and the result is <b>new</b> class with <b>new</b> name. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">MyExtension <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Panel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* object with new properties and methods */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Later on, when we need an object:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myExtension <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> MyExtension<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* optional configuration object */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Plugin</h1>
<p>Plugin does not need any exiting Ext class to exist. Although plugins often extend <b><code>Ext.util.Observable</code></b> it is not a must; they can be written from scratch. Sure, writing a plugin without having a target we want to plug it in has no sense so we always write plugins <b>for an existing</b> Ext class: panel, form, grid, data view, etc.</p>
<p>For example, we create plugin as:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">MyPlugin <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* code */</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And then we use it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myPanel <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Panel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
     plugins<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #003366; font-weight: bold;">new</span> MyPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* optional config object */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span>
    <span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">// rest of myPanel configuration</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Extension or Plugin?</h1>
<p>It depends&#8230; You can often achieve same result with extension or with plugin. Sometimes it is only that programmer likes plugins more so he writes a plugin or he likes extensions more so he writes an extension. However, plugins are more suitable for adding smaller features and extensions are more suitable for adding more complex functionalities. Plugins can be easily removed from components, extensions are usually more tied to applications.</p>
<h1>Summary</h1>
<ul>
<li>
An <b>extension</b> is a <b>new</b> class with a <b>new</b> name, based on an existing base class and created at <b>definition</b> time. Extension must be <b>instantiated</b> as any other class to work.</li>
<li><b>Plugin</b> plugs into an existing class, is easily removed, is defined during definition time and is initialized during base class <b>initialization</b>.</li>
</ul>
<h1>Further reading</h1>
<ul>
<li><a href="http://extjs.com/learn/Tutorial:Extending_Ext2_Class" target="_blank">Extending an Ext Class</a></lil>
<li><a href="http://extjs.com/learn/Tutorial:Writing_Ext_2_Plugins" target="_blank">Writing an Ext Plugin</a></li>
</ul>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/know-how/extension-or-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript Extension File Pattern</title>
		<link>http://blog.extjs.eu/patterns/file-patters/javascript-extension-file-pattern/</link>
		<comments>http://blog.extjs.eu/patterns/file-patters/javascript-extension-file-pattern/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 02:13:35 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[File Patters]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=15</guid>
		<description><![CDATA[<br/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// vim: ts=4:sw=4:nu:fdc=4:nospell
/*global Ext, AnExtension */
/**
 * @class AnExtension
 * @extends Ext.Panel
 *
 * AnExtension description
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2010, by Ing. Jozef Sakáloš
 * @date      &#60;ul&#62;
 * &#60;li&#62;11. March 2010&#60;/li&#62;
 * &#60;/ul&#62;
 * @version   1.0
 * @revision  [...]]]></description>
			<content:encoded><![CDATA[<br/>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// vim: ts=4:sw=4:nu:fdc=4:nospell</span>
<span style="color: #009966; font-style: italic;">/*global Ext, AnExtension */</span>
<span style="color: #006600; font-style: italic;">/**
 * @class AnExtension
 * @extends Ext.Panel
 *
 * AnExtension description
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2010, by Ing. Jozef Sakáloš
 * @date      &lt;ul&gt;
 * &lt;li&gt;11. March 2010&lt;/li&gt;
 * &lt;/ul&gt;
 * @version   1.0
 * @revision  $Id$
 *
 * @license AnExtension.js is released under the 
 * &lt;a target=&quot;_blank&quot; href=&quot;http://www.gnu.org/licenses/gpl.html&quot;&gt;GNU GPL 3.0&lt;/a&gt;
 * license. It’s free for use in GPL and GPL compatible open source software, 
 * but if you want to use the component in a commercial software (closed source),
 * you have to get a commercial license.
 */</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// create namespace</span>
Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'AnExtension'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Creates new AnExtension
 * @constructor
 * @param {Object} config A config object
 */</span>
AnExtension <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Panel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// default config (it can be changed while instantiating)</span>
    border<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #006600; font-style: italic;">// uncomment constructor if you need it, e.g. if you need listeners</span>
<span style="color: #006600; font-style: italic;">//    ,constructor:function(config) {</span>
<span style="color: #006600; font-style: italic;">//        // parent constructor call pre-processing - configure listeners here</span>
<span style="color: #006600; font-style: italic;">//        config = config || {};</span>
<span style="color: #006600; font-style: italic;">//        config.listeners = config.listeners || {};</span>
<span style="color: #006600; font-style: italic;">//        Ext.applyIf(config.listeners, {</span>
<span style="color: #006600; font-style: italic;">//            // add listeners config here</span>
<span style="color: #006600; font-style: italic;">//        });</span>
<span style="color: #006600; font-style: italic;">//</span>
<span style="color: #006600; font-style: italic;">//        // call parent constructor</span>
<span style="color: #006600; font-style: italic;">//        AnExtension.superclass.constructor.call(this, config);</span>
<span style="color: #006600; font-style: italic;">//</span>
<span style="color: #006600; font-style: italic;">//        // parent constructor call post-processing</span>
<span style="color: #006600; font-style: italic;">//</span>
<span style="color: #006600; font-style: italic;">//    } // eo function constructor</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// hard coded config (it cannot be changed while instantiating)</span>
        <span style="color: #006600; font-style: italic;">// {{{</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo config object</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// }}}</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        AnExtension.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// parent call post-processing, e.g. install event handlers</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #339933;">,</span>afterRender<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// parent call pre-processing</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        AnExtension.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">afterRender</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// parent call post-processing, e.g. install event handlers on rendered components</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function afterRender</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// any other added/overriden methods</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// register xtype</span>
Ext.<span style="color: #660066;">reg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'anextension'</span><span style="color: #339933;">,</span> AnExtension<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></td></tr></table></div>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/patterns/file-patters/javascript-extension-file-pattern/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

