lib/Ext/viewport/Default.js
function(menu, config) {
        var me = this;
        config = config || {};

        // Temporary workaround for body shifting issue
        if (Ext.os.is.iOS && !this.hasiOSOrientationFix) {
            this.hasiOSOrientationFix = true;
            this.on('orientationchange', function() {
                window.scrollTo(0, 0);
            }, this);
        }

        if (!menu) {
            //<debug error>
            Ext.Logger.error("You must specify a side to dock the menu.");
            //</debug>
            return;
        }

        if (!config.side) {
            //<debug error>
            Ext.Logger.error("You must specify a side to dock the menu.");
            //</debug>
            return;
        }

        if (['left', 'right', 'top', 'bottom'].indexOf(config.side) == -1) {
            //<debug error>
            Ext.Logger.error("You must specify a valid side (left, right, top or botom) to dock the menu.");
            //</debug>
            return;
        }

        var menus = me.getMenus();

        if (!menus) {
            menus = {};
        }

        // Add a listener to show this menu on swipe
        if (!me.addedSwipeListener) {
            me.addedSwipeListener = true;

            me.element.on({
                tap: me.onTap,
                swipestart: me.onSwipeStart,
                edgeswipestart: me.onEdgeSwipeStart,
                edgeswipe: me.onEdgeSwipe,
                edgeswipeend: me.onEdgeSwipeEnd,
                scope: me
            });

            // Add BB10 webworks API for swipe down.
            if (window.blackberry) {
                var toggleMenu = function() {
                    var menus = me.getMenus(),
                        menu = menus['top'];

                    if (!menu) {
                        return;
                    }

                    if (menu.isHidden()) {
                        me.showMenu('top');
                    } else {
                        me.hideMenu('top');
                    }
                };

                if (blackberry.app && blackberry.app.event && blackberry.app.event.onSwipeDown) {
                    blackberry.app.event.onSwipeDown(toggleMenu); // PlayBook
                }
                else if (blackberry.event && blackberry.event.addEventListener) {
                    blackberry.event.addEventListener("swipedown", toggleMenu); // BB10
                }
            }
        }

        menus[config.side] = menu;
        menu.$reveal = Boolean(config.reveal);
        menu.$cover = config.cover !== false && !menu.$reveal;
        menu.$side = config.side;

        me.fixMenuSize(menu, config.side);

        if (config.side == 'left') {
            menu.setLeft(0);
            menu.setRight(null);
            menu.setTop(0);
            menu.setBottom(0);
        }
        else if (config.side == 'right') {
            menu.setLeft(null);
            menu.setRight(0);
            menu.setTop(0);
            menu.setBottom(0);
        }
        else if (config.side == 'top') {
            menu.setLeft(0);
            menu.setRight(0);
            menu.setTop(0);
            menu.setBottom(null);
        }
        else if (config.side == 'bottom') {
            menu.setLeft(0);
            menu.setRight(0);
            menu.setTop(null);
            menu.setBottom(0);
        }

        me.setMenus(menus);
    }
function(menu, config) {
        var me = this;
        config = config || {};

        // Temporary workaround for body shifting issue
        if (Ext.os.is.iOS && !this.hasiOSOrientationFix) {
            this.hasiOSOrientationFix = true;
            this.on('orientationchange', function() {
                window.scrollTo(0, 0);
            }, this);
        }

        if (!menu) {
            //<debug error>
            Ext.Logger.error("You must specify a side to dock the menu.");
            //</debug>
            return;
        }

        if (!config.side) {
            //<debug error>
            Ext.Logger.error("You must specify a side to dock the menu.");
            //</debug>
            return;
        }

        if (['left', 'right', 'top', 'bottom'].indexOf(config.side) == -1) {
            //<debug error>
            Ext.Logger.error("You must specify a valid side (left, right, top or botom) to dock the menu.");
            //</debug>
            return;
        }

        var menus = me.getMenus();

        if (!menus) {
            menus = {};
        }

        // Add a listener to show this menu on swipe
        if (!me.addedSwipeListener) {
            me.addedSwipeListener = true;

            me.element.on({
                tap: me.onTap,
                swipestart: me.onSwipeStart,
                edgeswipestart: me.onEdgeSwipeStart,
                edgeswipe: me.onEdgeSwipe,
                edgeswipeend: me.onEdgeSwipeEnd,
                scope: me
            });

            // Add BB10 webworks API for swipe down.
            if (window.blackberry) {
                var toggleMenu = function() {
                    var menus = me.getMenus(),
                        menu = menus['top'];

                    if (!menu) {
                        return;
                    }

                    if (menu.isHidden()) {
                        me.showMenu('top');
                    } else {
                        me.hideMenu('top');
                    }
                };

                if (blackberry.app && blackberry.app.event && blackberry.app.event.onSwipeDown) {
                    blackberry.app.event.onSwipeDown(toggleMenu); // PlayBook
                }
                else if (blackberry.event && blackberry.event.addEventListener) {
                    blackberry.event.addEventListener("swipedown", toggleMenu); // BB10
                }
            }
        }

        menus[config.side] = menu;
        menu.$reveal = Boolean(config.reveal);
        menu.$cover = config.cover !== false && !menu.$reveal;
        menu.$side = config.side;

        me.fixMenuSize(menu, config.side);

        if (config.side == 'left') {
            menu.setLeft(0);
            menu.setRight(null);
            menu.setTop(0);
            menu.setBottom(0);
        }
        else if (config.side == 'right') {
            menu.setLeft(null);
            menu.setRight(0);
            menu.setTop(0);
            menu.setBottom(0);
        }
        else if (config.side == 'top') {
            menu.setLeft(0);
            menu.setRight(0);
            menu.setTop(0);
            menu.setBottom(null);
        }
        else if (config.side == 'bottom') {
            menu.setLeft(0);
            menu.setRight(0);
            menu.setTop(null);
            menu.setBottom(0);
        }

        me.setMenus(menus);
    }
function ( menu , config ) { var me = this ; config = config || { } ; // Temporary workaround for body shifting issue if ( Ext . os . is . iOS && ! this . hasiOSOrientationFix ) { this . hasiOSOrientationFix = true ; this . on ( 'orientationchange' , function ( ) { window . scrollTo ( 0 , 0 ) ; } , this ) ; } if ( ! menu ) { //<debug error> Ext . Logger . error ( "You must specify a side to dock the menu." ) ; //</debug> return ; } if ( ! config . side ) { //<debug error> Ext . Logger . error ( "You must specify a side to dock the menu." ) ; //</debug> return ; } if ( [ 'left' , 'right' , 'top' , 'bottom' ] . indexOf ( config . side ) == - 1 ) { //<debug error> Ext . Logger . error ( "You must specify a valid side (left, right, top or botom) to dock the menu." ) ; //</debug> return ; } var menus = me . getMenus ( ) ; if ( ! menus ) { menus = { } ; } // Add a listener to show this menu on swipe if ( ! me . addedSwipeListener ) { me . addedSwipeListener = true ; me . element . on ( { tap : me . onTap , swipestart : me . onSwipeStart , edgeswipestart : me . onEdgeSwipeStart , edgeswipe : me . onEdgeSwipe , edgeswipeend : me . onEdgeSwipeEnd , scope : me } ) ; // Add BB10 webworks API for swipe down. if ( window . blackberry ) { var toggleMenu = function ( ) { var menus = me . getMenus ( ) , menu = menus [ 'top' ] ; if ( ! menu ) { return ; } if ( menu . isHidden ( ) ) { me . showMenu ( 'top' ) ; } else { me . hideMenu ( 'top' ) ; } } ; if ( blackberry . app && blackberry . app . event && blackberry . app . event . onSwipeDown ) { blackberry . app . event . onSwipeDown ( toggleMenu ) ; // PlayBook } else if ( blackberry . event && blackberry . event . addEventListener ) { blackberry . event . addEventListener ( "swipedown" , toggleMenu ) ; // BB10 } } } menus [ config . side ] = menu ; menu . $reveal = Boolean ( config . reveal ) ; menu . $cover = config . cover !== false && ! menu . $reveal ; menu . $side = config . side ; me . fixMenuSize ( menu , config . side ) ; if ( config . side == 'left' ) { menu . setLeft ( 0 ) ; menu . setRight ( null ) ; menu . setTop ( 0 ) ; menu . setBottom ( 0 ) ; } else if ( config . side == 'right' ) { menu . setLeft ( null ) ; menu . setRight ( 0 ) ; menu . setTop ( 0 ) ; menu . setBottom ( 0 ) ; } else if ( config . side == 'top' ) { menu . setLeft ( 0 ) ; menu . setRight ( 0 ) ; menu . setTop ( 0 ) ; menu . setBottom ( null ) ; } else if ( config . side == 'bottom' ) { menu . setLeft ( 0 ) ; menu . setRight ( 0 ) ; menu . setTop ( null ) ; menu . setBottom ( 0 ) ; } me . setMenus ( menus ) ; }
Sets a menu for a given side of the Viewport.

Adds functionality to show the menu by swiping from the side of the screen from the given side.

If a menu is already set for a given side, it will be removed.

Available sides are: `left`, `right`, `top`, and `bottom`.

@param {Ext.Menu} menu The menu to assign to the viewport
@param {Object} config The configuration for the menu.
@param {String} config.side The side to put the menu on.
@param {Boolean} config.cover True to cover the viewport content. Defaults to `true`.
Sets a menu for a given side of the Viewport .