1. #1
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    12
    Vote Rating
    0
    schmoboy is on a distinguished road

      0  

    Default InactivityMonitor Updated for 4.x

    InactivityMonitor Updated for 4.x


    Updated the very nice InactivityMonitor from harley.333 as seen in this thread for ExtJS 4.x.

    PHP Code:
    Ext.define('Ext.ux.InactivityMonitor', {
        
    mixins: {
            
    observable'Ext.util.Observable'
        
    },
        
        
    requires: [
            
    'Ext.window.MessageBox',
            
    'Ext.util.*',
            
    'Ext.Ajax'
        
    ],
        
        
    ONEMINUTE: (1000 60),
        
        
    inactivityTimeout: (this.ONEMINUTE 5),  // Five minutes
        
    pollActionParam"a",
        
    pollAction"StayAlive",
        
    pollInterval: (this.ONEMINUTE 10),  // ten minutes
        
    pollUrl"pingsession",
        
    messageBoxConfig: {}, // allows developers to override the appearance of the messageBox
        
    messageBoxCountdown60// how long should the messageBox wait (in seconds)?

        
    constructor: function(config) {
            
    this.mixins.observable.constructor.call(thisconfig);
            
    this.addEvents({timeouttrue});

            if (
    this.inactivityTimeout >= this.ONEMINUTE) {
                
    this.resetTimeout();
                
    this._pollTask Ext.util.TaskManager.start({
                    
    run: function () {
                        var 
    params = {};
                        
    params[this.pollActionParam] = this.pollAction;
                        
    Ext.Ajax.request({paramsparamsurlthis.pollUrl});
                    },
                    
    intervalthis.pollInterval,
                    
    scopethis
                
    });
                var 
    body Ext.get(document.body);
                
    body.on("click"this.resetTimeoutthis);
                
    body.on("keypress"this.resetTimeoutthis);
            }
        },

        
    destroy: function() {
            var 
    body Ext.get(document.body);
            
    body.un("click"this.resetTimeoutthis);
            
    body.un("keypress"this.resetTimeoutthis);
            
    Ext.util.TaskManager.stop(this._pollTask);
            
    this._inactivityTask.cancel();
            
    Ext.util.TaskManager.stop(this._countdownTask);
        },

        
    resetTimeout: function () {
            if (!
    this._inactivityTask) {
                
    this._inactivityTask = new Ext.util.DelayedTask(this._beginCountdownthis);
            }
            
    this._inactivityTask.delay(this.inactivityTimeout);
        },

        
    // private stuff
        
    _pollTasknull// task to poll server
        
    _countdownTasknull// ONESECOND interval task for updating countdown MessageBox
        
    _countdownMessagenull// countdown MessageBox
        
    _inactivityTasknull// task to start countdown
        
        
    _beginCountdown: function () {
            var 
    config Ext.apply({
                
    buttonsExt.MessageBox.YES,
                
    buttonText: { yes'Keep Working'},
                
    closablefalse,
                
    draggablefalse,
                
    fn: function (btn) {
                    
    Ext.util.TaskManager.stop(this._countdownTask);
                    
    this.resetTimeout();
                },
                
    msg"Your session has been idle for too long.  Signing out...",
                
    progresstrue,
                
    scopethis,
                
    title"Inactivity Warning"
            
    }, this.messageBoxConfig);
            
            if (!
    this._countdownMessage) {
                
    // only create the MessageBox once
                
    this._countdownMessage Ext.Msg.show(config);
            }
            
            var 
    win this._countdownMessage;
            if (!
    win.isVisible()) {
                
    win.show(config);
            }
            
            
    win.updateProgress(0);
            
    win.seconds 0;
            
    this._countdownTask Ext.util.TaskManager.start({
                
    run: function () {
                    
    win.seconds += 1;
                    if (
    win.seconds this.messageBoxCountdown) {
                        
    Ext.util.TaskManager.stop(this._countdownTask);
                        
    this.fireEvent("timeout"thiswin);
                    } else {
                        
    win.updateProgress(win.seconds this.messageBoxCountdown);
                    }
                },
                
    scopethis,
                
    interval1000  // one second
            
    });
        }
    }); 
    Sample use in Ext.app.Application launch function...

    PHP Code:
        launch: function(profile)
        {
            
    // Start the inactivity monitor
            // log the user out after twenty minutes of inactivity
            
    this.inactivityMonitor Ext.create('Ext.ux.InactivityMonitor', {
                
    inactivityTimeout: (1000 60  20),  // 20 minutes
                
    listeners: {
                    
    timeout: function(objwin) {
                         
    // Send the user to logout url
                         // to close the session
                        
    window.location "logout";
                    }
                },
                
    pollUrl"pingsession"
            
    });
        } 

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Nice update!
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi