1. #1
    Ext User
    Join Date
    Nov 2008
    Posts
    3
    Vote Rating
    0
    p_leon is on a distinguished road

      0  

    Default Problem with desktop

    Problem with desktop


    Hi

    i'm working on desktop example, but i need other icon to open other window. what i have to do?,

    this is my code.

    you can see the new icon that i draw, but when clik to him, it doesn't show me nothing. how i can open other window??

    thanks for your help


    MyDesktop = new Ext.app.App({
    init :function(){
    Ext.QuickTips.init();
    },
    getModules : function(){
    return [
    new MyDesktop.GridWindow(),
    new MyDesktop.TabWindow(),
    new MyDesktop.AccordionWindow(),
    new MyDesktop.BogusMenuModule(),
    new MyDesktop.BogusModule()
    ];
    },
    // config for the start menu
    getStartConfig : function(){
    return {
    title: '<?php echo $zNomUserFinal ?>',
    iconCls: 'user',
    toolItems: [{
    text:'Settings',
    iconCls:'settings',
    scope:this
    },'-',{
    text:'Salir',
    iconCls:'logout',
    scope:this
    }]
    };
    }



    });

    /*
    * Example windows
    */
    MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
    id:'grid-win',
    init : function(){
    this.launcher = {
    text: 'Empresa',
    iconCls:'icon-grid',
    handler : this.createWindow,
    scope: this
    }
    },
    createWindow : function(){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('grid-win');
    if(!win){
    win = desktop.createWindow({
    id: 'grid-win',
    title:'Empresa',
    width:740,
    height:480,
    iconCls: 'icon-grid',
    shim:false,
    animCollapse:false,
    constrainHeader:true,
    html : '<iframe src="../empresa/frframep.php" "..." allowtransparency="true" id="Docs" style="background-color:#F9F8F8" name="programacion1" scrolling="yes" hscrolling="yes" frameborder="0" width="740" height="480" align="center"> </iframe>'
    });
    }
    win.show();
    }




    });

    MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {
    id:'tab-win',
    init : function(){
    this.launcher = {
    text: 'Tab Window',
    iconCls:'tabs',
    handler : this.createWindow,
    scope: this
    }
    },
    createWindow : function(){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('tab-win');
    if(!win){
    win = desktop.createWindow({
    id: 'tab-win',
    title:'Tab Window',
    width:740,
    height:480,
    iconCls: 'tabs',
    shim:false,
    animCollapse:false,
    border:false,
    constrainHeader:true,
    layout: 'fit',
    items:
    new Ext.TabPanel({
    activeTab:0,
    items: [{
    title: 'Tab Text 1',
    header:false,
    html : '<p>Something useful would be in here.</p>',
    border:false
    },{
    title: 'Tab Text 2',
    header:false,
    html : '<p>Something useful would be in here.</p>',
    border:false
    },{
    title: 'Tab Text 3',
    header:false,
    html : '<p>Something useful would be in here.</p>',
    border:false
    },{
    title: 'Tab Text 4',
    header:false,
    html : '<p>Something useful would be in here.</p>',
    border:false
    }]
    })
    });
    }
    win.show();
    }
    });


    MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, {
    id:'acc-win',
    init : function(){
    this.launcher = {
    text: 'Accordion Window',
    iconCls:'accordion',
    handler : this.createWindow,
    scope: this
    }
    },
    createWindow : function(){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('acc-win');
    if(!win){
    win = desktop.createWindow({
    id: 'acc-win',
    title:'Catalogo de Cuentas',
    width:740,
    height:520,
    iconCls: 'icon-grid',
    shim:false,
    animCollapse:false,
    constrainHeader:true,
    html : '<iframe src="../puc/frframep.php" "..." allowtransparency="true" id="Docs" style="background-color:#F9F8F8" name="programacion1" scrolling="yes" hscrolling="yes" frameborder="0" width="740" height="480" align="center"> </iframe>'
    });
    }
    win.show();
    }
    });
    // for example purposes
    var windowIndex = 0;
    MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
    init : function(){
    this.launcher = {
    text: 'Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId:windowIndex
    }
    },
    createWindow : function(src){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('bogus'+src.windowId);
    if(!win){
    win = desktop.createWindow({
    id: 'bogus'+src.windowId,
    titlerc.text,
    width:640,
    height:520,
    html : '<p>Something useful would be in here.</p>',
    iconCls: 'bogus',
    shim:false,
    animCollapse:false,
    constrainHeader:true
    });
    }
    win.show();
    }
    });

    MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, {
    init : function(){
    this.launcher = {
    text: 'Bogus Submenu',
    iconCls: 'bogus',
    handler: function() {
    return false;
    },
    menu: {
    items:[{
    text: 'Bogus Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId: windowIndex
    },{
    text: 'Bogus Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId: windowIndex
    },{
    text: 'Bogus Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId: windowIndex
    },{
    text: 'Bogus Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId: windowIndex
    },{
    text: 'Bogus Window '+(++windowIndex),
    iconCls:'bogus',
    handler : this.createWindow,
    scope: this,
    windowId: windowIndex
    }]
    }
    }
    }
    });

    // Array data for the grid
    Ext.grid.dummyData = [
    ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
    ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
    ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
    ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
    ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
    ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
    ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
    ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
    ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
    ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
    ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
    ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
    ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
    ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
    ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
    ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
    ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
    ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
    ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
    ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
    ];
    Ext.ux.TaskBar = function(app){
    this.app = app;
    this.init();
    }
    Ext.extend(Ext.ux.TaskBar, Ext.util.Observable, {
    init : function(){
    this.startMenu = new Ext.ux.StartMenu(Ext.apply({
    iconCls: 'user',
    height: 300,
    shadow: true,
    title: '<?php echo $zNomUserFinal ?>',
    width: 300
    }, this.app.startConfig));

    this.startBtn = new Ext.Button({
    text: 'Start',
    id: 'ux-startbutton',
    iconCls:'start',
    menu: this.startMenu,
    menuAlign: 'bl-tl',
    renderTo: 'ux-taskbar-start',
    clickEvent: 'mousedown',
    template: new Ext.Template(
    '<table cellspacing="0" class="x-btn {3}"><tbody><tr>',
    '<td class="ux-startbutton-left"><i> </i></td>',
    '<td class="ux-startbutton-center"><em class="{5} unselectable="on">',
    '<button class="x-btn-text {2}" type="{1}" style="height:30px;">{0}</button>',
    '</em></td>',
    '<td class="ux-startbutton-right"><i> </i></td>',
    "</tr></tbody></table>")
    });
    var width = this.startBtn.getEl().getWidth()+10;

    var sbBox = new Ext.BoxComponent({
    el: 'ux-taskbar-start',
    id: 'TaskBarStart',
    minWidth: width,
    region:'west',
    split: true,
    width: width
    });

    this.tbPanel = new Ext.ux.TaskButtonsPanel({
    el: 'ux-taskbuttons-panel',
    id: 'TaskBarButtons',
    region:'center'
    });

    var container = new Ext.ux.TaskBarContainer({
    el: 'ux-taskbar',
    layout: 'border',
    items: [sbBox,this.tbPanel]
    });

    return this;
    },

    addTaskButton : function(win){
    return this.tbPanel.addButton(win, 'ux-taskbuttons-panel');
    },

    removeTaskButton : function(btn){
    this.tbPanel.removeButton(btn);
    },

    setActiveButton : function(btn){
    this.tbPanel.setActiveButton(btn);
    }
    });

    /**
    * @class Ext.ux.TaskBarContainer
    * @extends Ext.Container
    */
    Ext.ux.TaskBarContainer = Ext.extend(Ext.Container, {
    initComponent : function() {
    Ext.ux.TaskBarContainer.superclass.initComponent.call(this);

    this.el = Ext.get(this.el) || Ext.getBody();
    this.el.setHeight = Ext.emptyFn;
    this.el.setWidth = Ext.emptyFn;
    this.el.setSize = Ext.emptyFn;
    this.el.setStyle({
    overflow:'hidden',
    margin:'0',
    border:'0 none'
    });
    this.el.dom.scroll = 'no';
    this.allowDomMove = false;
    this.autoWidth = true;
    this.autoHeight = true;
    Ext.EventManager.onWindowResize(this.fireResize, this);
    this.renderTo = this.el;
    },
    fireResize : function(w, h){
    this.fireEvent('resize', this, w, h, w, h);
    }
    });

    /**
    * @class Ext.ux.TaskButtonsPanel
    * @extends Ext.BoxComponent
    */
    Ext.ux.TaskButtonsPanel = Ext.extend(Ext.BoxComponent, {
    activeButton: null,
    enableScroll: true,
    scrollIncrement: 0,
    scrollRepeatInterval: 400,
    scrollDuration: .35,
    animScroll: true,
    resizeButtons: true,
    buttonWidth: 168,
    minButtonWidth: 118,
    buttonMargin: 2,
    buttonWidthSet: false,

    initComponent : function() {
    Ext.ux.TaskButtonsPanel.superclass.initComponent.call(this);
    this.on('resize', this.delegateUpdates);
    this.items = [];

    this.stripWrap = Ext.get(this.el).createChild({
    cls: 'ux-taskbuttons-strip-wrap',
    cn: {
    tag:'ul', cls:'ux-taskbuttons-strip'
    }
    });
    this.stripSpacer = Ext.get(this.el).createChild({
    cls:'ux-taskbuttons-strip-spacer'
    });
    this.strip = new Ext.Element(this.stripWrap.dom.firstChild);

    this.edge = this.strip.createChild({
    tag:'li',
    cls:'ux-taskbuttons-edge'
    });
    this.strip.createChild({
    cls:'x-clear'
    });
    },

    addButton : function(win){
    var li = this.strip.createChild({tag:'li'}, this.edge); // insert before the edge
    var btn = new Ext.ux.TaskBar.TaskButton(win, li);

    this.items.push(btn);

    if(!this.buttonWidthSet){
    this.lastButtonWidth = btn.container.getWidth();
    }

    this.setActiveButton(btn);
    return btn;
    },

    removeButton : function(btn){
    var li = document.getElementById(btn.container.id);
    btn.destroy();
    li.parentNode.removeChild(li);

    var s = [];
    for(var i = 0, len = this.items.length; i < len; i++) {
    if(this.items[i] != btn){
    s.push(this.items[i]);
    }
    }
    this.items = s;

    this.delegateUpdates();
    },

    setActiveButton : function(btn){
    this.activeButton = btn;
    this.delegateUpdates();
    },

    delegateUpdates : function(){
    /*if(this.suspendUpdates){
    return;
    }*/
    if(this.resizeButtons && this.rendered){
    this.autoSize();
    }
    if(this.enableScroll && this.rendered){
    this.autoScroll();
    }
    },

    autoSize : function(){
    var count = this.items.length;
    var ow = this.el.dom.offsetWidth;
    var aw = this.el.dom.clientWidth;
    if(!this.resizeButtons || count < 1 || !aw){ // !aw for display:none
    return;
    }

    var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.buttonMargin, this.buttonWidth), this.minButtonWidth); // -4 for float errors in IE
    var btns = this.stripWrap.dom.getElementsByTagName('button');

    this.lastButtonWidth = Ext.get(btns[0].id).findParent('li').offsetWidth;

    for(var i = 0, len = btns.length; i < len; i++) {
    var btn = btns[i];

    var tw = Ext.get(btns[i].id).findParent('li').offsetWidth;
    var iw = btn.offsetWidth;

    btn.style.width = (each - (tw-iw)) + 'px';
    }
    },

    autoScroll : function(){
    var count = this.items.length;
    var ow = this.el.dom.offsetWidth;
    var tw = this.el.dom.clientWidth;

    var wrap = this.stripWrap;
    var cw = wrap.dom.offsetWidth;
    var pos = this.getScrollPos();
    var l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;

    if(!this.enableScroll || count < 1 || cw < 20){ // 20 to prevent display:none issues
    return;
    }

    wrap.setWidth(tw); // moved to here because of problem in Safari

    if(l <= tw){
    wrap.dom.scrollLeft = 0;
    //wrap.setWidth(tw); moved from here because of problem in Safari
    if(this.scrolling){
    this.scrolling = false;
    this.el.removeClass('x-taskbuttons-scrolling');
    this.scrollLeft.hide();
    this.scrollRight.hide();
    }
    }else{
    if(!this.scrolling){
    this.el.addClass('x-taskbuttons-scrolling');
    }
    tw -= wrap.getMargins('lr');
    wrap.setWidth(tw > 20 ? tw : 20);
    if(!this.scrolling){
    if(!this.scrollLeft){
    this.createScrollers();
    }else{
    this.scrollLeft.show();
    this.scrollRight.show();
    }
    }
    this.scrolling = true;
    if(pos > (l-tw)){ // ensure it stays within bounds
    wrap.dom.scrollLeft = l-tw;
    }else{ // otherwise, make sure the active button is still visible
    this.scrollToButton(this.activeButton, true); // true to animate
    }
    this.updateScrollButtons();
    }
    },
    createScrollers : function(){
    var h = this.el.dom.offsetHeight; //var h = this.stripWrap.dom.offsetHeight;

    // left
    var sl = this.el.insertFirst({
    cls:'ux-taskbuttons-scroller-left'
    });
    sl.setHeight(h);
    sl.addClassOnOver('ux-taskbuttons-scroller-left-over');
    this.leftRepeater = new Ext.util.ClickRepeater(sl, {
    interval : this.scrollRepeatInterval,
    handler: this.onScrollLeft,
    scope: this
    });
    this.scrollLeft = sl;
    // right
    var sr = this.el.insertFirst({
    cls:'ux-taskbuttons-scroller-right'
    });
    sr.setHeight(h);
    sr.addClassOnOver('ux-taskbuttons-scroller-right-over');
    this.rightRepeater = new Ext.util.ClickRepeater(sr, {
    interval : this.scrollRepeatInterval,
    handler: this.onScrollRight,
    scope: this
    });
    this.scrollRight = sr;
    },

    getScrollWidth : function(){
    return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
    },
    getScrollPos : function(){
    return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
    },
    getScrollArea : function(){
    return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
    },
    getScrollAnim : function(){
    return {
    duration: this.scrollDuration,
    callback: this.updateScrollButtons,
    scope: this
    };
    },
    getScrollIncrement : function(){
    return (this.scrollIncrement || this.lastButtonWidth+2);
    },

    /* getBtnEl : function(item){
    return document.getElementById(item.id);
    }, */

    scrollToButton : function(item, animate){
    item = item.el.dom.parentNode; // li
    if(!item){ return; }
    var el = item; //this.getBtnEl(item);
    var pos = this.getScrollPos(), area = this.getScrollArea();
    var left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos;
    var right = left + el.offsetWidth;
    if(left < pos){
    this.scrollTo(left, animate);
    }else if(right > (pos + area)){
    this.scrollTo(right - area, animate);
    }
    },

    scrollTo : function(pos, animate){
    this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
    if(!animate){
    this.updateScrollButtons();
    }
    },

    onScrollRight : function(){
    var sw = this.getScrollWidth()-this.getScrollArea();
    var pos = this.getScrollPos();
    var s = Math.min(sw, pos + this.getScrollIncrement());
    if(s != pos){
    this.scrollTo(s, this.animScroll);
    }
    },
    onScrollLeft : function(){
    var pos = this.getScrollPos();
    var s = Math.max(0, pos - this.getScrollIncrement());
    if(s != pos){
    this.scrollTo(s, this.animScroll);
    }
    },

    updateScrollButtons : function(){
    var pos = this.getScrollPos();
    this.scrollLeft[pos == 0 ? 'addClass' : 'removeClass']('ux-taskbuttons-scroller-left-disabled');
    this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('ux-taskbuttons-scroller-right-disabled');
    }
    });

    /**
    * @class Ext.ux.TaskBar.TaskButton
    * @extends Ext.Button
    */
    Ext.ux.TaskBar.TaskButton = function(win, el){
    this.win = win;
    Ext.ux.TaskBar.TaskButton.superclass.constructor.call(this, {
    iconCls: win.iconCls,
    text: Ext.util.Format.ellipsis(win.title, 12),
    renderTo: el,
    handler : function(){
    if(win.minimized || win.hidden){
    win.show();
    }else if(win == win.manager.getActive()){
    win.minimize();
    }else{
    win.toFront();
    }
    },
    clickEvent:'mousedown',
    template: new Ext.Template(
    '<table cellspacing="0" class="x-btn {3}"><tbody><tr>',
    '<td class="ux-taskbutton-left"><i> </i></td>',
    '<td class="ux-taskbutton-center"><em class="{5} unselectable="on">',
    '<button class="x-btn-text {2}" type="{1}" style="height:28px;">{0}</button>',
    '</em></td>',
    '<td class="ux-taskbutton-right"><i> </i></td>',
    "</tr></tbody></table>")
    });
    };
    Ext.extend(Ext.ux.TaskBar.TaskButton, Ext.Button, {
    onRender : function(){
    Ext.ux.TaskBar.TaskButton.superclass.onRender.apply(this, arguments);
    this.cmenu = new Ext.menu.Menu({
    items: [{
    text: 'Restore',
    handler: function(){
    if(!this.win.isVisible()){
    this.win.show();
    }else{
    this.win.restore();
    }
    },
    scope: this
    },{
    text: 'Minimize',
    handler: this.win.minimize,
    scope: this.win
    },{
    text: 'Maximize',
    handler: this.win.maximize,
    scope: this.win
    }, '-', {
    text: 'Close',
    handler: this.closeWin.createDelegate(this, this.win, true),
    scope: this.win
    }]
    });
    this.cmenu.on('beforeshow', function(){
    var items = this.cmenu.items.items;
    var w = this.win;
    items[0].setDisabled(w.maximized !== true && w.hidden !== true);
    items[1].setDisabled(w.minimized === true);
    items[2].setDisabled(w.maximized === true || w.hidden === true);
    }, this);
    this.el.on('contextmenu', function(e){
    e.stopEvent();
    if(!this.cmenu.el){
    this.cmenu.render();
    }
    var xy = e.getXY();
    xy[1] -= this.cmenu.el.getHeight();
    this.cmenu.showAt(xy);
    }, this);
    },

    closeWin : function(cMenu, e, win){
    if(!win.isVisible()){
    win.show();
    }else{
    win.restore();
    }
    win.close();
    }
    });


    </script>
    <body scroll="no">
    <a href="../../index.php" target="_self" style="margin:5px; float:right;"><br><img src="../../graphics/standar/appkey_problem.gif" />&nbsp;&nbsp;<font color="#ffffff">Salir</font></a>
    <div id="x-desktop">
    <dl id="x-shortcuts">
    <?php if($_COOKIE['kBD']=="_0001"){?>
    <dt id="grid-win-shortcut">
    <a href="#"><img src="../../libs/js/extjs/examples/desktop/images/s.gif" />
    <div>Empresa</div></a>
    </dt>
    <?php } ?>
    <?php if($_COOKIE['kBD']!="_0001"){?>
    <dt id="acc-win-shortcut">
    <a href="#"><img src="../../libs/js/extjs/examples/desktop/images/s.gif" />
    <div>Catalogo de Cuentas</div></a>
    </dt>
    <dt id="ter-win-shortcut">
    <a href="#"><img src="../../libs/js/extjs/examples/desktop/images/s.gif" />
    <div>Terceros</div></a>
    </dt>
    <?php } ?>
    </dl>
    </div>
    <div id="ux-taskbar">
    <div id="ux-taskbar-start"></div>
    <div id="ux-taskbuttons-panel"></div>
    <div class="x-clear"></div>
    </div>

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    You're not going to get help when posting code like this. You will need to learn to use code tags and only post relevant code.

Thread Participants: 1