var uid = 0; var tabPanel = null; function actPnlHndlr(tree, record) { var actPnl = tree.up('actpnl'); //console.log(record.get('panel_id')); return; if(!record.get('panel_id') || record.get('panel_id') == 1 ) return; Ext.Ajax.request({ url: '../sys_cms/loadAuxParams.php', params: { action_id: record.get('id'), DATABASE: DATABASE, config: 1 },// config: 1 - просим расшифровать, например по id - имя файла success: function(xhr) { try { var obj = Ext.decode(xhr.responseText); } catch(e) { Ext.Msg.show({ title: '', msg: 'Не определен контент для выбранного узла сайта (' + e + ')', icon: Ext.Msg.INFO, minWidth: 200, buttons: Ext.Msg.OK }); return; } if( obj.success == false) { Ext.Msg.alert("Ошибка", obj.err); return; } if(actPnl.PNL) { actPnl.CNTR.remove(actPnl.PNL); actPnl.PNL = null; } var config = obj.data; Ext.apply(config, {flex: 1, noTitle: true, noId: true, action_id: this.action_id, cms_uid: uid}); try { //console.log(obj.jsclass); console.log(config); actPnl.PNL = Ext.create( obj.jsclass, config); } catch(e) { Ext.Msg.show({ title: '', msg: 'Не удалось создать панель класс "' + obj.jsclass + '", контент для выбранного узла сайта не определен (' + e + ')', icon: Ext.Msg.INFO, minWidth: 200, buttons: Ext.Msg.OK }); return; } //console.log(actPnl.PNL.getId()); actPnl.CNTR.add(actPnl.PNL); }, failure: function(response, opts) { Ext.Msg.show({ title: "Ошибка ...", msg: "Не удалось загрузить скрипт '../sys_cms/loadAuxParams.php'" + '(Status: ' + response.status + ' Status text: ' + response.statusText + ")", icon: Ext.Msg.INFO, minWidth: 200, buttons: Ext.Msg.OK }); }, scope: this }); } function showImg(ttl, img) { var win = new Ext.Window({ layout:'fit', width: 900, height: 400, items: new Ext.Panel({ title: ttl, autoScroll: true, html: "" }) }); win.show(); } function showHtml(ttl, html) { var win = new Ext.Window({ title: ttl, layout:'fit', width: 800, height: 300, border: false, frame: false, padding: '0', bodyStyle: cfgObj.bodyStyle ? cfgObj.bodyStyle : {}, items: new Ext.Panel({ border: false, frame: false, padding: '0 10', bodyStyle: cfgObj.bodyStyle ? cfgObj.bodyStyle : {}, autoScroll: true, html: html }) }); win.show(); } function setTab(tabId) { if(tabPanel) { var tab = tabPanel.down("#" + tabId); if(tab) { tabPanel.setActiveTab(tab); } } } Ext.onReady(function() { var loading = Ext.get('loading'); if(loading) loading.hide(); var loading_mask = Ext.get('loading-mask'); if(loading_mask) loading_mask.fadeOut({remove:false}); //var loading = Ext.get('loading'); if(loading) { loading.remove(); Ext.get('loading-mask').fadeOut({remove:true}); } Ext.QuickTips.init(); tabPanel = new Ext.tab.Panel({ id: 'MAIN_TAB_PNL', tools: cfgObj.cabinet ? [{ type: 'gear', regionTool: true, tooltip: uid?'Выход из кабинета':'Вход в личный кабинет', listeners: { click: function(tool) { var cabinetMenu = null; if(uid == 0) { cabinetMenu = this.regionMenu || (this.regionMenu = Ext.widget({ xtype: 'menu', items: [{ text: 'Войти', iconCls: 'user_in', handler: function (btn) { var pnl = Ext.create('CMgmtS.pnls.Login'); var win = Ext.create('Ext.Window', { width: 250, y: 200, header: false, closable: false, resizable: false, modal: true, plain: true, border: false, items: [ pnl ] }); win.show(btn); } },{ text: 'Регистрация', iconCls: 'add_user', handler: function (btn) { var pnl = Ext.create('CMgmtS.pnls.Registration'); var win = Ext.create('Ext.Window', { //y: 200, header: false, width: 520, closable: false, resizable: false, modal: true, plain: true, border: false, items: [ pnl ] }); win.show(btn); } }] })); } else { cabinetMenu = this.regionMenu || (this.regionMenu = Ext.widget({ xtype: 'menu', items: [{ text: 'Выйти', iconCls: 'user_exit', handler: function (btn) { Ext.Ajax.request({ url: '../sys_cms/logout.php', success: function(response) { try { var obj = Ext.JSON.decode(response.responseText); } catch(exc) { alert(exc.description); return; } Ext.get('loading-mask').fadeIn({ callback: function() { window.document.location.reload(); //document.location.href = document.location.href; } }); Ext.get('loading').show(); }, failure: function(response) { Ext.Msg.show({ title: 'Error', msg: "Не удалось закрыть сессию 'logout.php' Status: " + response.status + ' Status text: ' + response.statusText, icon: Ext.Msg.INFO, minWidth: 200, buttons: Ext.Msg.OK }); }, scope: this }); } }] })); } cabinetMenu.showBy(tool.el); }, scope: this } }] : null, region: 'center', //flex: 2.5, margin: '0 0 0 0', //minTabWidth: 150, tabWidth: 150, enableTabScroll: true, frame: true, border: false, bodyStyle: { backgroundColor: cfgObj.bgclr }, bodyPadding: 10, activeTab: 0, listeners: { add: function(tabpnl, component, index, eOpts) { var xtype = component.getXType(); //if(xtype == 'menuactpnl') { if(xtype == 'actpnl') { var tabbar = tabpnl.getTabBar(); var tab = tabbar.items.get(index); //console.log(tab.getText()); tab.on('click', function(thistab, e, eOpts) { if(this.AUXPNL) { if( this.PNL ) { this.CNTR.remove(this.PNL); this.PNL = null; } try { //console.log(this.AUXPNL); this.PNL = eval(this.AUXPNL); //this.PNL = this.AUXPNL; } catch(e) { Ext.Msg.show({ title: '', msg: 'Не определен контент для выбранного узла сайта!!! (' + e.description + ')', icon: Ext.Msg.INFO, minWidth: 200, buttons: Ext.Msg.OK }); return; } this.CNTR.add(this.PNL); return; } if( this.PNL ) return; var treeList = this.down('treelist'), treeListStore = treeList.getStore(); //treeList.fireEvent('selectionchange', treeList, treeList.getSelection( ) ); if( treeListStore.isLoaded() ) { treeList.setSelection(treeListStore.first()); this.selectFirstAfterLoad = false; } else { this.selectFirstAfterLoad = true; } }, component); } }, afterrender: function(tabpnl, eOpts ) { var tabbar = tabpnl.getTabBar(); var tab = tabbar.items.get(0); if(tab) tab.fireEvent('click'); } }, items: [ Ext.create( 'CMgmtS.pnls.ActPnl', 3, 'Центр профпатологии', null, 168, 'x-fa fa-home' ), Ext.create( 'CMgmtS.pnls.ActPnl', 24, 'Профосмотры', null, 410, 'x-fa fa-ambulance' ), Ext.create( 'CMgmtS.pnls.HTMLDoc',{cms_uid: uid, title: 'ЛМК(медкнижки)', id: 'MyPnl_8', iconCls: 'x-fa fa-book', file: './pub/file_161013221412.html', action_id: 8}), Ext.create( 'CMgmtS.pnls.HTMLDoc',{cms_uid: uid, title: 'Водительская комиссия', id: 'MyPnl_28', iconCls: 'x-fa fa-car', file: './pub/file_161021151506.html', action_id: 28}), Ext.create( 'CMgmtS.pnls.HTMLDoc',{cms_uid: uid, title: 'Справки', id: 'MyPnl_31', iconCls: 'x-fa fa-pencil-square-o', file: './pub/file_161013223511.html', action_id: 31}), Ext.create( 'CMgmtS.pnls.ActPnl', 32, 'Контакты', null, 200, 'x-fa fa-users' ), Ext.create( 'CMgmtS.pnls.HTMLDoc',{cms_uid: uid, title: 'Лицензия', id: 'MyPnl_29', iconCls: 'x-fa fa-certificate', file: './pub/pdfLicense.html', action_id: 29}), Ext.create( 'CMgmtS.pnls.ActPnl', 5, 'Нормативные документы', null, 200, 'x-fa fa-exclamation' ), Ext.create( 'CMgmtS.pnls.Photo',{cms_uid: uid, title: 'Фотоальбом', id: 'MyPnl_33', iconCls: 'x-fa fa-camera', photo_cfg: 3, action_id: 33}) ] }); /*****************************/ var newsPnl = cfgObj.news ? new Ext.panel.Panel({ region: 'east', collapsible: true, //collapseMode: 'mini', collapsed: true, split: true, width: 250, minSize: 175, maxSize: 500, //flex: 1, title: 'Новости', autoScroll: true, margins: '0 0 0 5', frame: true,// border: false, bodyStyle: cfgObj.bodyStyle ? cfgObj.bodyStyle : {}, loader: { url: '../sys_cms/news.php?DATABASE=' + DATABASE, autoLoad: true, loadMask: true } }) : null; /****************************/ var mainPnl = null; if(cfgObj.news) mainPnl = new Ext.panel.Panel({ region: 'center', margins: '0 0 0 0', bodyStyle: { backgroundColor: cfgObj.mainbgclr /*'#C6F3F7'*/ }, frame: false, border: false, //layout: { type: 'hbox', align: 'stretch', padding: 5 }, layout: 'border', items: [tabPanel, newsPnl] }); else mainPnl = new Ext.panel.Panel({ region: 'center', margins: '0 0 0 0', bodyStyle: { backgroundColor: cfgObj.mainbgclr /*'#C6F3F7'*/ }, frame: false, border: false, //layout: { type: 'hbox', align: 'stretch', padding: 5 }, layout: 'border', items: tabPanel }) var viewport = new Ext.container.Viewport({ renderTo: Ext.getBody(), //style: { backgroundColor: '#E6F3F5' }, style: { backgroundColor: cfgObj.bgclr }, layout: 'border', items:[{ height: parseInt(cfgObj.header_height), region: 'north', xtype: 'box', loader: { url: cfgObj.header_pnl_url, autoLoad: true, loadMask: true }, frame: false, border: false, margins: '0 0 0 0' }, mainPnl, { height: parseInt(cfgObj.bottom_height), region: 'south', xtype: 'box', loader: { url: cfgObj.bottom_pnl_url, autoLoad: true, loadMask: true }, frame: false, border: false, margins: '0 0 0 0' }] }); });