3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.ns('Ext.samples');
12 SamplePanel = Ext.extend(Ext.DataView, {
18 tpl : new Ext.XTemplate(
19 '<div id="sample-ct">',
21 '<div><a name="{id}"></a><h2><div>{title}</div></h2>',
23 '<tpl for="samples">',
24 '<dd ext:url="{url}"><img src="shared/screens/{icon}"/>',
26 '<tpl if="this.isNew(values.status)">',
27 '<span class="new-sample"> (New)</span>',
29 '<tpl if="this.isUpdated(values.status)">',
30 '<span class="updated-sample"> (Updated)</span>',
32 '<tpl if="this.isExperimental(values.status)">',
33 '<span class="new-sample"> (Experimental)</span>',
35 '</h4><p>{desc}</p></div>',
38 '<div style="clear:left"></div></dl></div>',
41 isExperimental: function(status){
42 return status == 'experimental';
44 isNew: function(status){
45 return status == 'new';
47 isUpdated: function(status){
48 return status == 'updated';
53 onClick : function(e){
54 var group = e.getTarget('h2', 3, true);
56 group.up('div').toggleClass('collapsed');
58 var t = e.getTarget('dd', 5, true);
59 if(t && !e.getTarget('a', 2)){
60 var url = t.getAttributeNS('ext', 'url');
64 return SamplePanel.superclass.onClick.apply(this, arguments);
67 Ext.samples.SamplePanel = SamplePanel;
68 Ext.reg('samplespanel', Ext.samples.SamplePanel);
71 Ext.onReady(function(){
74 // Instantiate Ext.App instance
75 App = new Ext.App({});
77 var catalog = Ext.samples.samplesCatalog;
79 for(var i = 0, c; c = catalog[i]; i++){
83 var store = new Ext.data.JsonStore({
85 fields : ['id', 'title', 'samples'],
89 var panel = new Ext.Panel({
91 renderTo : 'all-demos',
94 items : new SamplePanel({
99 var tpl = new Ext.XTemplate(
100 '<tpl for="."><li><a href="#{id}">{title:stripTags}</a></li></tpl>'
102 tpl.overwrite('sample-menu', catalog);
104 Ext.select('#sample-spacer').remove();
106 var headerEl = Ext.get('hd'),
107 footerEl = Ext.get('ft'),
108 bodyEl = Ext.get('bd'),
109 sideBoxEl = bodyEl.child('div[class=side-box]'),
110 titleEl = bodyEl.child('h3:first-child');
112 var doResize = function() {
113 var windowHeight = Ext.getDoc().getViewSize().height;
115 var footerHeight = footerEl.getHeight() + footerEl.getMargins().top,
116 titleElHeight = titleEl.getHeight() + titleEl.getMargins().top,
117 brElHeight = bodyEl.child('br').getHeight(),
118 headerHeight = headerEl.getHeight() + titleElHeight + brElHeight;
120 var warnEl = Ext.get('fb');
121 var warnHeight = warnEl ? warnEl.getHeight() : 0;
123 var availHeight = windowHeight - ( footerHeight + headerHeight + 14) - warnHeight;
124 var sideBoxHeight = sideBoxEl.getHeight();
126 panel.setHeight((availHeight > sideBoxHeight) ? availHeight : sideBoxHeight);
130 Ext.EventManager.onWindowResize(doResize);
132 var firebugWarning = function () {
133 var cp = new Ext.state.CookieProvider();
135 if(window.console && window.console.firebug && ! cp.get('hideFBWarning')){
136 var tpl = new Ext.Template(
137 '<div id="fb" style="border: 1px solid #FF0000; background-color:#FFAAAA; display:none; padding:15px; color:#000000;"><b>Warning: </b> Firebug is known to cause performance issues with Ext JS. <a href="#" id="hideWarning">[ Hide ]</a></div>'
139 var newEl = tpl.insertFirst('all-demos');
141 Ext.fly('hideWarning').on('click', function() {
142 Ext.fly(newEl).slideOut('t',{remove:true});
143 cp.set('hideFBWarning', true);
146 Ext.fly(newEl).slideIn();
151 var hideMask = function () {
152 Ext.get('loading').remove();
153 Ext.fly('loading-mask').fadeOut({
155 callback : firebugWarning