3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
11 SamplePanel = Ext.extend(Ext.DataView, {
17 tpl : new Ext.XTemplate(
18 '<div id="sample-ct">',
20 '<div><a name="{id}"></a><h2><div>{title}</div></h2>',
22 '<tpl for="samples">',
23 '<dd ext:url="{url}"><img src="shared/screens/{icon}"/>',
25 '<tpl if="this.isNew(values.status)">',
26 '<span class="new-sample"> (New)</span>',
28 '<tpl if="this.isUpdated(values.status)">',
29 '<span class="updated-sample"> (Updated)</span>',
31 '<tpl if="this.isExperimental(values.status)">',
32 '<span class="new-sample"> (Experimental)</span>',
34 '</h4><p>{desc}</p></div>',
37 '<div style="clear:left"></div></dl></div>',
40 isExperimental: function(status){
41 return status == 'experimental';
43 isNew: function(status){
44 return status == 'new';
46 isUpdated: function(status){
47 return status == 'updated';
52 onClick : function(e){
53 var group = e.getTarget('h2', 3, true);
55 group.up('div').toggleClass('collapsed');
57 var t = e.getTarget('dd', 5, true);
58 if(t && !e.getTarget('a', 2)){
59 var url = t.getAttributeNS('ext', 'url');
63 return SamplePanel.superclass.onClick.apply(this, arguments);
66 Ext.samples.SamplePanel = SamplePanel;
67 Ext.reg('samplespanel', Ext.samples.SamplePanel);
70 Ext.onReady(function() {
72 // Instantiate Ext.App instance
73 App = new Ext.App({});
75 var catalog = Ext.samples.samplesCatalog;
77 for (var i = 0, c; c = catalog[i]; i++) {
81 var store = new Ext.data.JsonStore({
83 fields : ['id', 'title', 'samples'],
87 var panel = new Ext.Panel({
89 renderTo : Ext.get('all-demos'),
92 items : new SamplePanel({
97 var tpl = new Ext.XTemplate(
98 '<tpl for="."><li><a href="#{id}">{title:stripTags}</a></li></tpl>'
100 tpl.overwrite('sample-menu', catalog);
102 Ext.select('#sample-spacer').remove();
104 var headerEl = Ext.get('hd'),
105 footerEl = Ext.get('ft'),
106 bodyEl = Ext.get('bd'),
107 sideBoxEl = bodyEl.child('div[class=side-box]'),
108 titleEl = bodyEl.child('h1#pagetitle');
110 var doResize = function() {
111 var windowHeight = Ext.getDoc().getViewSize(false).height;
113 var footerHeight = footerEl.getHeight() + footerEl.getMargins().top,
114 titleElHeight = titleEl.getHeight() + titleEl.getMargins().top,
115 headerHeight = headerEl.getHeight() + titleElHeight;
117 var warnEl = Ext.get('fb');
118 var warnHeight = warnEl ? warnEl.getHeight() : 0;
120 var availHeight = windowHeight - ( footerHeight + headerHeight + 14) - warnHeight;
121 var sideBoxHeight = sideBoxEl.getHeight();
123 panel.setHeight((availHeight > sideBoxHeight) ? availHeight : sideBoxHeight);
127 Ext.EventManager.onWindowResize(doResize);
129 var firebugWarning = function () {
130 var cp = new Ext.state.CookieProvider();
132 if(window.console && window.console.firebug && ! cp.get('hideFBWarning')){
133 var tpl = new Ext.Template(
134 '<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>'
136 var newEl = tpl.insertFirst('all-demos');
138 Ext.fly('hideWarning').on('click', function() {
139 Ext.fly(newEl).slideOut('t',{remove:true});
140 cp.set('hideFBWarning', true);
143 Ext.fly(newEl).slideIn();
148 var hideMask = function () {
149 Ext.get('loading').remove();
150 Ext.fly('loading-mask').fadeOut({
152 callback : firebugWarning