Extenson to header menu profile name length setting


define(
    'JJ.headermenu_length.limit'
    , [
        'Header.Profile.View'
    ]
    , function (
        HeaderProfileView
    ) {
        'use strict';

        return {
            mountToApp: function mountToApp(container) {

                /** @type {LayoutComponent} */
                var layout = container.getComponent('Layout');

                if (layout) {
                    /**
                     * add a length based on the screen width.
                     */
                    layout.addToViewContextDefinition("Header.Profile.View", "profileName", "string", function (context) {
                        var name = context.displayName;

                        if (name) {
                            if (screen.width >= 1400) {
                                console.log("this1", screen.width)
                                if (name.length > 12) {
                                    console.log("name.length", name.length)
                                    return name.substr(0, 15) + "...";
                                } else return name;
                            } 
                            else if ((screen.width >= 1100)&&(screen.width <= 1399)) {
                                if (name.length > 12) return name.substr(0, 10) + "...";
                                else return name;
                            }
                            else if ((screen.width >= 992)&&(screen.width <= 1099)) {
                                if (name.length > 12) return name.substr(0, 6) + "...";
                                else return name;
                            }
                            else if (screen.width >= 993) {
                                if (name.length > 4) return name.substr(0, 7) + ".";
                                else return name;
                            } 
                           
                            else if (screen.width >= 992) {
                                if (name.length > 3) return name.substr(0, 2) + ".";
                                else return name;
                            }


                            // if (screen.width >= 1500) {
                            //     if (name.length > 12) {
                            //         return name.substr(0, 10) + "...";
                            //     } else return name;
                            // } else if (screen.width >= 993) {
                            //     if (name.length > 4) return name.substr(0, 5) + ".";
                            //     else return name;
                            // } else if (screen.width >= 992) {
                            //     if (name.length > 3) return name.substr(0, 2) + ".";
                            //     else return name;
                            // }





                        } else {
                            return "";
                        }
                    });


                }
            }
        };
    });

Leave a comment

Your email address will not be published. Required fields are marked *