Hybrid View

  1. #1
    Sencha User willf1976's Avatar
    Join Date
    May 2009
    Location
    carpinteria, ca
    Posts
    84
    Vote Rating
    0
    willf1976 is on a distinguished road

      0  

    Default Ext.ux.window.StayOnScreen

    Ext.ux.window.StayOnScreen


    Hi All

    I have been going through the classes we have developed over the last few years and sharing back with the community some of them that I think will be useful to others. These components have been tested extensively in ext-3.2.1.

    Here is: Ext.ux.window.StayOnScreen

    A plug in to keep a window from going off the top of the screen (a common problem we have had with large windows).

    Code:
    /**
     * @author Will Ferrer, Ethan Brooks
     * @copyright (c) 2012, Intellectual Property Private Equity Group
     * @licensee 2012 developed under license for Switchsoft LLC http://www.switchsoft.com a "Direct response telephony company" as part of it's "VOIP Call distribution, ROI analysis platform, call recording, and IVR for inbound and outbound sales" and Run the Business Systems LLC a "Technology development investment group" as part of it's "PHP, Javascript rapid application development framework and MySQL analysis tools"
     * @license licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open
    Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * <p>License details: <a href="http://www.gnu.org/licenses/lgpl.html"
     * target="_blank">http://www.gnu.org/licenses/lgpl.html</a></p>
    * We are pretty nice just ask. We want to meet our licensees
    */
    /**
     * @class Ext.ux.window.StayOnScreen
     * @extends Ext.util.Observable
     * A plug in to keep a window from going off the top of the screen (a common problem we have had with large windows). 
    * @param {Object} config The config object
     * @ptype ux-window-stayonscreen
     */
    Ext.ns('Ext.ux.window');
    Ext.ux.window.StayOnScreen = function(config){
        Ext.apply(this, config);
        Ext.ux.window.StayOnScreen.superclass.constructor.call(this);
    };
    Ext.extend(Ext.ux.window.StayOnScreen, Ext.util.Observable, {
        // @private
        parent : null,
        // @private
        init: function(parent) {
            this.parent = parent;
            this.parent.on('move', this.stayOnScreen, this);
            this.parent.on('show', this.stayOnScreen, this);
            this.parent.on('restore', this.stayOnScreen, this);
        },
        // @private
        stayOnScreen : function () {
            var xy = this.parent.getPosition();
            if (xy[1]<0) {
                this.parent.setPosition(xy[0], 0);
            }
        }
    });
    Ext.preg('ux-window-stayonscreen', Ext.ux.window.StayOnScreen);
    Best regards

    Will Ferrer (Run the Business)

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    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


    Kind of sounds like constrain should take care of this
    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.

  3. #3
    Sencha User willf1976's Avatar
    Join Date
    May 2009
    Location
    carpinteria, ca
    Posts
    84
    Vote Rating
    0
    willf1976 is on a distinguished road

      0  

    Default


    Hi Mitchel

    Would you accomplish this by setting a renderTo of the view port and then turning on constraint?

    That sounds like a viable solution as well.

    Thank you for the tip.

    Best regards

    Will Ferrer

  4. #4
    Sencha User willf1976's Avatar
    Join Date
    May 2009
    Location
    carpinteria, ca
    Posts
    84
    Vote Rating
    0
    willf1976 is on a distinguished road

      0  

    Default


    Hi Mitchel

    I just wanted to let you know I did some experiments with your suggestion and constrain set to true on the window worked perfectly for our needs even with out the renderTo functionality assigned. Very good tip.

    I hope this message finds you well.

    Best regards

    Will Ferrer

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    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


    Fantastic! Glad I could help!
    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

Tags for this Thread