InfoModule.js 2.2 KB
/** 
 * Project  : AMDA-NG4
 * Name     : InfoModule.js
 * @class   amdaDesktop.InfoModule 
 * @extends amdaDesktop.AmdaModule
 * @brief   Info Module controller definition
 * This Module describe new functionalities of AMDA-NG4
 * @author  CDA
 * @version $Id: InfoModule.js 2397 2014-06-03 10:21:28Z elena $
 */

Ext.define('amdaDesktop.InfoModule', 
{
	extend: 'amdaDesktop.AmdaModule',
	contentId : 'infoUI',
	file : 'releaseNotes.md',

	createWindow : function(type)
	{             
		var desktop = myDesktopApp.getDesktop();            
		var win = desktop.getWindow(this.id);

        if (!win) {	     
			win = desktop.createWindow({
				id: this.id,
				width: 650,
				height: 570,
				autoScroll : true,
				minimizable: false,
				maximizable: false,
				bodyStyle: 'background:#ffffee; padding:15px 15px 15px 15px;',
				bodyCls : 'infoWindow',         
				iconCls: this.icon,
				animCollapse:false,
				constrainHeader:true
			});

            win.on({
				show : function(win, eOpts) {
                    this.updateInfo(win, type);
                },
				scope : this
			});

            win.show();
		}
        else {
            this.updateInfo(win, type);
        }
        
        win.toFront();
	},

    updateInfo : function(win, type) {
        var file = '';
        var title = '';

        switch (type) {
            case 'release-notes':
                file = 'releaseNotes.md';
                title = 'AMDA Release Notes';
                break;
            default:
                file = 'about';
                title = "About AMDA";
        }


        Ext.Ajax.request({
            url: helpDir + file,
            success: function(response){
                var text = response.responseText;
                switch (type) {
                    case 'release-notes':
                        var converter = new showdown.Converter(),
                        text      = converter.makeHtml(text);
                        break;
                    default:
                        text = text.replace('{AMDA_VERSION}', AMDA_VERSION).replace('{AMDA_RELEASE_DATE}', AMDA_RELEASE_DATE);
                }
                win.update(text);
                win.setTitle(title);
            }
        });
    }
});