How to use the ghost/utils/mobile.addListener function in ghost

To help you get started, we’ve selected a few ghost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TryGhost / Ghost-Admin / views / application.js View on Github external
}

        // #### Listen to the viewport and change user-menu dropdown triangle classes accordingly
        this.set('swapUserMenuDropdownTriangleClasses', Ember.run.bind(this, swapUserMenuDropdownTriangleClasses));

        mobileQuery.addListener(this.get('swapUserMenuDropdownTriangleClasses'));
        swapUserMenuDropdownTriangleClasses(mobileQuery);

        this.set('closeGlobalMobileNavOnDesktop', Ember.run.bind(this, function closeGlobalMobileNavOnDesktop(mq) {
            if (!mq.matches) {
                // Is desktop sized
                this.set('controller.showGlobalMobileNav', false);
            }
        }));

        mobileQuery.addListener(this.get('closeGlobalMobileNavOnDesktop'));
    },
github TryGhost / Ghost-Admin / views / application.js View on Github external
}
            });
        });

        function swapUserMenuDropdownTriangleClasses(mq) {
            if (mq.matches) {
                $('.js-user-menu-dropdown-menu').removeClass('dropdown-triangle-top-right ').addClass('dropdown-triangle-bottom');
            } else {
                $('.js-user-menu-dropdown-menu').removeClass('dropdown-triangle-bottom').addClass('dropdown-triangle-top-right');
            }
        }

        // #### Listen to the viewport and change user-menu dropdown triangle classes accordingly
        this.set('swapUserMenuDropdownTriangleClasses', Ember.run.bind(this, swapUserMenuDropdownTriangleClasses));

        mobileQuery.addListener(this.get('swapUserMenuDropdownTriangleClasses'));
        swapUserMenuDropdownTriangleClasses(mobileQuery);

        this.set('closeGlobalMobileNavOnDesktop', Ember.run.bind(this, function closeGlobalMobileNavOnDesktop(mq) {
            if (!mq.matches) {
                // Is desktop sized
                this.set('controller.showGlobalMobileNav', false);
            }
        }));

        mobileQuery.addListener(this.get('closeGlobalMobileNavOnDesktop'));
    },
github TryGhost / Ghost-Admin / app / views / mobile / parent-view.js View on Github external
attachChangeLayout: function () {
        mobileQuery.addListener(this.changeLayout);
    }.on('didInsertElement'),
github TryGhost / Ghost-Admin / views / mobile / parent-view.js View on Github external
attachChangeLayout: function () {
        mobileQuery.addListener(this.changeLayout);
    }.on('didInsertElement'),