// vim: sw=4:ts=4:nu:nospell:fdc=4
/**
 * extjs.eu application
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2008, by Ing. Jozef Sakáloš
 * @date      5. April 2008
 * @version   $Id: main.js 109 2009-01-15 17:43:38Z jozo $
 */
 
/*global Ext, Web */

Ext.ns('Web.Extensions');
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';

// {{{
Web.Extensions.catalog = [{
	 title:'File Upload and Management'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'FileTreePanel'
		,desc:'Server file system management tool. Client side user interface for server file system management. All basic file operations such as open, delete, drag &amp; drop, new foler and other are supported.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=29090'
		,demo:'http://filetree.extjs.eu'
		,thumb:'filetree-thumb.png'
	},{
		 title:'UploadPanel'
		,desc:'User interface for file uploading. Files are first added to an upload queue and then they are uploaded to the server. Status and results of uploads are displayed by icons and tooltips.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=29090'
		,demo:'http://filetree.extjs.eu'
		,thumb:'uploadpanel-thumb.png'
	},{
		 title:'FileUploader'
		,desc:'Low level class without its own user interface that handles file upload client server communication and provides status and progress information to upper level classes.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=29090'
		,demo:'http://filetree.extjs.eu'
		,thumb:'noui-thumb.png'
	}]
},{
	 title:'Form Extensions and Plugins'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'DateTime'
		,desc:'Combined Date and Time Field for applications where entering both date and time is required. Suitable also as Grid Editor. Contains renderer directly usable by grids.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=22661'
		,demo:'#'
		,thumb:'datetime-thumb.png'
	},{
		 title:'MetaForm'
		,desc:'Form auto-configured byt meta data received from server. Suitable for simple forms that have fields generarated by server.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=25551'
		,demo:'#'
		,thumb:'metaform-thumb.png'
	},{
		 title:'IconCombo'
		,desc:'Combo with icon in input part and dropdown list. Step by step tutorial on extending Ext 2.x classes. Suitable as country or language selector or others.'
		,iconCls:'icon-extension'
		,forum:'../learn/Tutorial:Extending_Ext2_Class'
		,demo:'#'
		,thumb:'iconcombo-thumb.png'
	},{
		 title:'IconCombo'
		,desc:'Combo with icon in input part and dropdown list. Step by step tutorial on writing Ext 2.x plugins. Suitable as country or language selector or others.'
		,iconCls:'icon-plugin'
		,forum:'../learn/Tutorial:Writing_Ext_2_Plugins'
		,demo:'#'
		,thumb:'iconcombo-thumb.png'
	},{
		 title:'LovCombo'
		,desc:'Simple LOV (List Of Values) Combo'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=32692'
		,demo:'http://lovcombo.extjs.eu'
		,thumb:'lovcombo-thumb.png'
	},{
		 title:'Remote Validator'
		,desc:'Plugin for remote field value validation. Field value is sent for validation to server while typing. Reason why field is invalid given by server is displayed.'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=19112'
		,demo:'#'
		,thumb:'rfvalidate-thumb.png'
	},{
		 title:'XCheckbox'
		,desc:'Nicer checkbox always submitted. Solves the problem of standard HTML behavior when unchecked checkbox is not submitted to server. Also looks better than standard checbox.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=25924'
		,demo:'#'
		,thumb:'xcheckbox-thumb.png'
	},{
		 title:'XDateField'
		,desc:'XDateField has a configurable submit format, independent of display format, to make it easier to process the submitted value on the server.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=25900'
		,demo:'#'
		,thumb:'xdate-thumb.png'
	},{
		 title:'XTimeField'
		,desc:'XTimeField has a configurable submit format, independent of display format, to make it easier to process the submitted value on the server.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=25927'
		,demo:'#'
		,thumb:'xtime-thumb.png'
	}]
},{
	 title:'Grid Extensions and Plugins'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'CellActions'
		,desc:'Plugin that puts icons to cells and fires events'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=30411'
		,demo:'http://cellactions.extjs.eu'
		,thumb:'cellactions-thumb.png'
	},{
		 title:'Grid Search'
		,desc:'Allows searching for a text in selected columns both in local and remote mode.'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=23615'
		,demo:'http://gridsearch.extjs.eu'
		,thumb:'gridsearch-thumb.png'
	},{
		 title:'RecordForm'
		,desc:'Implements possibility to edit a grid record via automatically generated form that displays itself in a popup window. Can edit also fields that are not displayed in the grid.'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=31341'
		,demo:'http://recordform.extjs.eu'
		,thumb:'recordform-thumb.png'
	},{
		 title:'RowActions'
		,desc:'Plugin that puts icons to a column and fires events'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=29961'
		,demo:'http://rowactions.extjs.eu'
		,thumb:'rowactions-thumb2.png'
	}]
},{
	 title:'Tree Extensions and Plugins'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'ArrayTree'
		,desc:'TreePanel extension that creates a tree from static array of children'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=32059'
		,demo:'http://arraytree.extjs.eu'
		,thumb:'arraytree-thumb.png'
	},{
		 title:'RemoteTreePanel'
		,desc:'TreePanel extension that implements basic server-stored tree operations'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=55102'
		,demo:'http://remotetree.extjs.eu'
		,thumb:'remotetree-thumb.png'
	},{
		 title:'TreeFilterX'
		,desc:'Tree filter that correctly works at all levels of a deep tree as opposed to default TreeFilter that filters only first level.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=55489'
		,demo:'http://remotetree.extjs.eu'
		,thumb:'noui-thumb.png'
	},{
		 title:'CheckTreePanel'
		,desc:'Tree panel with checkboxes for nodes with advanced handling of checkbox clicks and with getValue/setValue methods.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=56875'
		,demo:'http://checktree.extjs.eu'
		,thumb:'checktree-thumb.png'
	}]
},{
	 title:'Miscellaneous'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'HttpProvider'
		,desc:'State Provider that sends the state information such as windows sizes and positions to a server for storing in a database. Server and database backend transparent.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=24970'
		,demo:'http://rowactions.extjs.eu'
		,thumb:'httpprovider-thumb.png'
	},{
		 title:'IconMenu'
		,desc:'Plugin for Window or Panel that adds menu to title bar icon. There are default items such as <i>Minimize, Maximize, Restore</i> and <i>Close</i>. Other items are user definable.'
		,iconCls:'icon-plugin'
		,forum:'showthread.php?t=30677'
		,demo:'http://iconmenu.extjs.eu'
		,thumb:'iconmenu-thumb.png'
	},{
		 title:'ThemeCombo'
		,desc:'Easy theme selector that does not require the page reload when changing themes. Keeps state if a state provider is available. Very easy installation, just three lines of code.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=25564'
		,demo:'http://rowactions.extjs.eu'
		,thumb:'themecombo-thumb.png'
	},{
		 title:'Cloning Function'
		,desc:'Objects and arrays cloning function. It clones deeply nested objects or arrays.'
		,iconCls:'icon-copy'
		,forum:'showthread.php?t=26644'
		,demo:'#'
		,thumb:'noui-thumb.png'
	}]
},{
	 title:'Ext 1.x Extensions'
	,links:[]
	,otherlinks:[]
	,extensions:[{
		 title:'Accordion'
		,desc:'Accordion widget with many features such as Drag &amp; Drop operations, pinnable, dockable panels and many more.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=6388'
		,demo:'http://aariadne.com/accordion-preview'
		,thumb:'accordion-thumb.png'
	},{
		 title:'InfoPanel'
		,desc:'Collapsible draggable info panel mainly, but not only, for Accordion. Content can be either statically defined or dynamically loaded from server.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=6388'
		,demo:'http://aariadne.com/accordion-preview'
		,thumb:'infopanel-thumb.png'
	},{
		 title:'FileTreePanel'
		,desc:'Previous implementation of FileTreePanel for Ext 1.x. Provides same features as the current version and contains the Client-Server Interface Specification.'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=8894'
		,demo:'http://aariadne.com/filetree'
		,thumb:'filetree1-thumb.png'
	},{
		 title:'UploadForm'
		,desc:'Previous similar functionality as current implementation of UploadPanel and FileUploader. Files are first queued and then uploaded to the server'
		,iconCls:'icon-extension'
		,forum:'showthread.php?t=9305'
		,demo:'http://aariadne.com/uploadform'
		,thumb:'uploadform-thumb.png'
	}]
},{
	 title:'Saki\'s Forum Posts'
	,extensions:[]
	,otherlinks:[]
	,links:[{
		 iconCls:'icon-bulb'
		,text:'Application Design Based On Pre-Configured Classes'
		,href:'http://extjs.com/forum/showthread.php?p=125476'
	},{
		 iconCls:'icon-bulb'
		,text:'call(this, ...) vs apply(this, ...)'
		,href:'http://extjs.com/forum/showthread.php?p=135619'
	},{
		 iconCls:'icon-bulb'
		,text:'Ext.fly() explanation'
		,href:'http://extjs.com/forum/showthread.php?p=140648'
	},{
		 iconCls:'icon-bulb'
		,text:'How to add tooltips to form fields'
		,href:'http://extjs.com/forum/showthread.php?p=138606'
	},{
		 iconCls:'icon-bulb'
		,text:'How to capture events'
		,href:'http://extjs.com/forum/showthread.php?p=145874'
	},{
		 iconCls:'icon-bulb'
		,text:'How to setup server cache'
		,href:'http://extjs.com/forum/showthread.php?p=146280'
	},{
		 iconCls:'icon-bulb'
		,text:'How to solve encoding problem'
		,href:'http://extjs.com/forum/showthread.php?p=134032'
	},{
		 iconCls:'icon-bulb'
		,text:'How to get reply to your question quickly?'
		,href:'http://extjs.com/forum/showthread.php?t=6272'
	},{
		 iconCls:'icon-bulb'
		,text:'I want Saki\'s FileTree backend'
		,href:'http://extjs.com/forum/showthread.php?p=147056'
	},{
		 iconCls:'icon-bulb'
		,text:'Lazy Instantiating/Rendering Explanation'
		,href:'http://extjs.com/forum/showthread.php?p=138612'
	},{
		 iconCls:'icon-bulb'
		,text:'Login Form Security Talk'
		,href:'http://extjs.com/forum/showthread.php?p=35163'
	},{
		 iconCls:'icon-bulb'
		,text:'Paging Grid Example with PHP 5.x Backend'
		,href:'http://extjs.com/forum/showthread.php?p=132092'
	},{
		 iconCls:'icon-bulb'
		,text:'Private Messaging, The use of'
		,href:'http://extjs.com/forum/showthread.php?t=6459'
	},{
		 iconCls:'icon-bulb'
		,text:'Rendering grid to an inactive tab'
		,href:'http://extjs.com/forum/showthread.php?p=142387'
	},{
		 iconCls:'icon-bulb'
		,text:'Simple File Upload Example'
		,href:'http://extjs.com/forum/showthread.php?p=141677'
	},{
		 iconCls:'icon-bulb'
		,text:'Why to load store from grid render event'
		,href:'http://extjs.com/forum/showthread.php?p=140715'
	}]
},{
	 title:'Saki\'s Tutorials &amp; Know-How'
	,extensions:[]
	,otherlinks:[]
	,links:[{
		 iconCls:'icon-bulb-off'
		,text:'Application Layout for Beginners'
		,href:'http://extjs.com/learn/Tutorial:Application_Layout_for_Beginners'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Advanced Custom Drag and Drop Series'
		,href:'http://extjs.com/learn/Tutorial:Advanced_Custom_Drag_and_Drop_Part_1'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Designing a 3 column web page using TableLayout'
		,href:'http://blog.extjs.eu/know-how/designing-a-3-columns-web-page-using-tablelayout'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Custom Drag and Drop Series'
		,href:'http://extjs.com/learn/Tutorial:Custom_Drag_and_Drop_Part_1'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Extending Classes in Ext'
		,href:'http://extjs.com/learn/Tutorial:Extending_Ext_Class'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Extending Ext 2 Class (IconCombo)'
		,href:'http://extjs.com/learn/Tutorial:Extending_Ext2_Class'
	},{
		 iconCls:'icon-bulb-off'
		,text:'How to build a Tree from static data'
		,href:'http://blog.extjs.eu/know-how/how-to-build-a-tree-from-static-data/'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Linked Combos Tutorial for Ext 2'
		,href:'http://extjs.com/learn/Tutorial:Linked_Combos_Tutorial_for_Ext_2'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Localizing Ext'
		,href:'http://extjs.com/learn/Tutorial:Localizing_Ext'
	},{
		 iconCls:'icon-bulb-off'
		,text:'What is that Scope all about'
		,href:'http://extjs.com/learn/Tutorial:What_is_that_Scope_all_about'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Writing a Big Application in Ext'
		,href:'http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/'
	},{
		 iconCls:'icon-bulb-off'
		,text:'Writing Ext 2 Plugins (IconCombo)'
		,href:'http://extjs.com/learn/Tutorial:Writing_Ext_2_Plugins'
	}]
},{
	 title:'Other Forum Posts'
	,extensions:[]
	,links:[]
	,otherlinks:[{
		 text:'contentEl, applyTo, renderTo'
		,author:'<a href="http://extjs.com/forum/member.php?u=802" target="_blank" class="know-how icon-user">aconran</a>'
		,href:'http://extjs.com/forum/showthread.php?p=106622'
		,iconCls:'icon-star'
	},{
		 text:'Date autocorrection override'
		,author:'<a href="http://extjs.com/forum/member.php?u=5" target="_blank" class="know-how icon-user">brian.moeskau</a>'
		,href:'http://extjs.com/forum/showthread.php?p=76950'
		,iconCls:'icon-star'
	},{
		 text:'Extending an Ext Class'
		,author:'<a href="http://extjs.com/forum/member.php?u=6834" target="_blank" class="know-how icon-user">mjlecomte</a>'
		,href:'http://extjs.com/forum/showthread.php?t=28085'
		,iconCls:'icon-star'
	},{
		 text:'FAQ: Form'
		,author:'<a href="http://extjs.com/forum/member.php?u=6834" target="_blank" class="know-how icon-user">mjlecomte</a>'
		,href:'http://extjs.com/forum/showthread.php?p=135403'
		,iconCls:'icon-star'
	},{
		 text:'FAQ: Grid'
		,author:'<a href="http://extjs.com/forum/member.php?u=6834" target="_blank" class="know-how icon-user">mjlecomte</a>'
		,href:'http://extjs.com/forum/showthread.php?p=130451'
		,iconCls:'icon-star'
	},{
		 text:'FAQ: Layout'
		,author:'<a href="http://extjs.com/forum/member.php?u=6834" target="_blank" class="know-how icon-user">mjlecomte</a>'
		,href:'http://extjs.com/forum/showthread.php?p=135397'
		,iconCls:'icon-star'
	},{
		 text:'Improved menu behavior patch (untested)'
		,author:'<a href="http://extjs.com/forum/member.php?u=9022" target="_blank" class="know-how icon-user">Rob_mac</a>'
		,href:'http://extjs.com/forum/showthread.php?p=128616'
		,iconCls:'icon-star'
	},{
		 text:'How to add multiple toolbars to a Panel'
		,author:'<a href="http://extjs.com/forum/member.php?u=2" target="_blank" class="know-how icon-user">jack.slocum</a>'
		,href:'http://extjs.com/forum/showthread.php?p=57883'
		,iconCls:'icon-star'
	},{
		 text:'How to clear combo hidden value'
		,author:'<a href="http://extjs.com/forum/member.php?u=12" target="_blank" class="know-how icon-user">VinylFox</a>'
		,href:'http://extjs.com/forum/showthread.php?p=145931'
		,iconCls:'icon-star'
	},{
		 text:'How to copy tree node'
		,author:'<a href="http://extjs.com/forum/member.php?u=2" target="_blank" class="know-how icon-user">jack.slocum</a>'
		,href:'http://extjs.com/forum/showthread.php?p=24223'
		,iconCls:'icon-star'
	},{
		 text:'How to set default font of HtmlEditor'
		,author:'<a href="http://extjs.com/forum/member.php?u=5" target="_blank" class="know-how icon-user">brian.moeskau</a>'
		,href:'http://extjs.com/forum/showthread.php?p=143688'
		,iconCls:'icon-star'
	},{
		 text:'How to set dimensions'
		,author:'<a href="http://extjs.com/forum/member.php?u=2" target="_blank" class="know-how icon-user">jack.slocum</a>'
		,href:'http://extjs.com/forum/showthread.php?p=127818'
		,iconCls:'icon-star'
	},{
		 text:'render/onRender explanation (Template Method)'
		,author:'<a href="http://extjs.com/forum/member.php?u=2" target="_blank" class="know-how icon-user">jack.slocum</a>'
		,href:'http://extjs.com/forum/showthread.php?p=33312'
		,iconCls:'icon-star'
	}]
}];
// }}}
// {{{
Web.Extensions.Panel = Ext.extend(Ext.Panel, {
	 autoHeight:true
	,frame:true
	,collapsible:true
	,cls:'panel-extensions'
	,tpl:new Ext.XTemplate(
		 '<dl>'
		,'<tpl for="extensions">'
			,'<dt>'
			,'<a href="{demo}" <tpl if="\'#\'!==demo">target="_blank"</tpl>><img src="images/{thumb}"></a>'
			,'<div>'
			,'<h3 class="{iconCls}"><a target="_blank" href="http://extjs.com/forum/{forum}" qtip="Forum Thread">{title}</a></h3>'
			,'<p>{desc}</p>'
			,'</div>'
			,'</dt>'
		,'</tpl>'
		,'</dl>'
		,'<tpl for="links">'
		,'<a class="know-how {iconCls}" href="{href}" target="_blank">{text}</a>'
		,'</tpl>'
		,'<tpl for="otherlinks">'
		,'<a class="know-how {iconCls}" href="{href}" target="_blank">{text}</a>{author}'
		,'</tpl>'
		,'<div class="cleaner">'
	)
	,afterRender:function() {
		Web.Extensions.Panel.superclass.afterRender.apply(this, arguments);
		this.tpl.overwrite(this.body, this);

		this.scroll.defer(250, this);
	}

	,stateEvents:['collapse', 'expand']

	,scroll:function() {
		if(window.location.hash && this.id === window.location.hash.substr(1)) {
			var top = this.getEl().getOffsetsTo(Ext.getBody())[1];
			Ext.getBody().scrollTo('top', top - 25, {duration:.75, callback:this.hlPanel.createDelegate(this)});
		}
	} // eo function scroll

	,hlPanel:function() {
		this.body.highlight();
	} // eo function hlPanel

	,getState:function() {
		return {
			collapsed:this.collapsed
		}
	} // eo function getState

}); // eo extend
// }}}

// application main entry point
Ext.onReady(function() {
    Ext.QuickTips.init();
 
	var adsenseHost = 
		   'extjs.eu' === window.location.host 
		|| 'www.extjs.eu' === window.location.host
		|| 'extjseu.localhost' === window.location.host
	;
	var page = new WebPage({
		 westContent:'west-content'
		,adRowContent: adsenseHost ? 'adrow-content' : undefined
	});

	var ads = Ext.getBody().select('div.adsense');
	if(adsenseHost) {
		ads.removeClass('x-hidden');
	}
	else {
		ads.remove();
	}

	// create panels
	Ext.each(Web.Extensions.catalog, function(c, i) {
		c.id = 'extension-' + i;
		new Web.Extensions.Panel(c).render(page.center);
	});

	// create menu
	var menuTpl = new Ext.XTemplate('<dl><tpl for="."><dt><a href="#{id}">{title:stripTags}</a></dt></tpl></dl>');
	menuTpl.overwrite(Ext.get('menu'), Web.Extensions.catalog);

 
}); // eo function onReady
 
// eof
