protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            var sb = new StringBuilder();

            sb.AppendFormat("<div id='{0}'>", _jsObjName);

            if (IsMobileVersion)
            {
                sb.AppendFormat("<select class='comboBox' style='width:{0}px;' onchange='javascript:{1}.SelectUser(this);' >", InputWidth, _jsObjName);
                sb.AppendFormat("<option style='max-width:300px;' value='{0}' {2}>{1}</option>",
                                -1,
                                _linkText.HtmlEncode(),
                                Guid.Empty.Equals(SelectedUserId) ? "selected = 'selected'" : string.Empty);

                var accounts = CoreContext.Authentication.GetUserAccounts().OrderBy(a => a.Department).ThenBy(a => a.Name);

                var department = "";
                foreach (var account in accounts)
                {
                    if (!String.Equals(account.Department, department, StringComparison.InvariantCultureIgnoreCase) &&
                        !String.IsNullOrEmpty(account.Department.HtmlEncode()))
                    {
                        if (department != "")
                        {
                            sb.Append("</optgroup>");
                        }

                        department = account.Department;
                        sb.AppendFormat("<optgroup label='{0}' style='max-width:300px;'>", department.HtmlEncode());
                    }
                    sb.AppendFormat("<option style='max-width:300px;' value='{0}' {2}>{1}</option>",
                                    account.ID,
                                    account.Name.HtmlEncode(),
                                    Equals(account.ID, SelectedUserId) ? "selected = 'selected'" : string.Empty);
                }

                sb.AppendFormat("</select>");
            }
            else
            {
                var valueForInput = Guid.Empty.Equals(SelectedUserId) ? string.Empty : CoreContext.UserManager.GetUsers(SelectedUserId).DisplayUserName().ReplaceSingleQuote();

                if (IsLinkView)
                {
                    sb.AppendFormat("<div><span class='addUserLink' onclick='{0}.OnInputClick({0}, event);'><a class='baseLinkAction linkMedium'>{1}</a><img src='{2}' align='absmiddle' style='margin-left:3px'></span></div>",
                                    _jsObjName,
                                    LinkText.HtmlEncode(),
                                    Page.ClientScript.GetWebResourceUrl(GetType(), "ASC.Web.Controls.AdvancedUserSelector.images.sort_down_black.png"));
                }
                else
                {
                    var peopleImgStyle = valueForInput.Trim() == string.Empty ? "display:none;" : "display:block;";
                    var searchImgStyle = valueForInput.Trim() == string.Empty ? "display:block;" : "display:none;";

                    sb.AppendFormat(@"
                        <table cellspacing='0' cellpadding='1' class='borderBase adv-userselector-inputContainer' width='{0}px'>
                            <tbody>
                                <tr>
                                    <td width='16px'>
                                        <img align='absmiddle' src='{1}' id='peopleImg' style='margin:2px;{7}'/>
                                        <img align='absmiddle' src='{2}' id='searchImg' style='{8}'/>
                                    </td>
                                    <td>
                                        <input type='text' id='inputUserName' autocomplete='off'
                                            oninput='{3}.SuggestUser(event);' onpaste='{3}.SuggestUser(event);' onkeyup='{3}.SuggestUser(event);'
	                                        onclick='{3}.OnInputClick({3}, event);' onkeydown='{3}.ChangeSelection(event);'
                                            class='textEdit' style='width:100%;' value='{5}'/>
                                        <input id='login' name='login' value='{6}' type='hidden'/>
                                    </td>
                                    <td width='20px' onclick='{3}.OnInputClick({3}, event);'>
                                        <img align='absmiddle' src='{4}' style='cursor:pointer;'/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>",
                                    InputWidth + 8,
                                    Page.ClientScript.GetWebResourceUrl(GetType(), "ASC.Web.Controls.AdvancedUserSelector.images.people_icon.png"),
                                    Page.ClientScript.GetWebResourceUrl(GetType(), "ASC.Web.Controls.AdvancedUserSelector.images.search.png"),
                                    _jsObjName,
                                    Page.ClientScript.GetWebResourceUrl(GetType(), "ASC.Web.Controls.AdvancedUserSelector.images.collapse_down_dark.png"),
                                    valueForInput,
                                    SelectedUserId,
                                    peopleImgStyle,
                                    searchImgStyle);
                }


                sb.AppendFormat("<div id='DepsAndUsersContainer' class='adv-userselector-DepsAndUsersContainer' {0}>", IsLinkView ? "style='height:230px'" : string.Empty);

                if (IsLinkView)
                {
                    sb.Append("<div style='margin-bottom: 10px;'>");
                    sb.Append("<div style=width:50%;'>");
                    sb.AppendFormat(@"
                        <table cellspacing='0' cellpadding='1' class='borderBase adv-userselector-inputContainer' width='100%' style='height: 18px;'>
                            <tbody>
                                <tr>
                                    <td>
                                        <input type='text' id='inputUserName' autocomplete='off'
                                            oninput='javascript:{0}.SuggestUser(event);' onpaste='javascript:{0}.SuggestUser(event);' onkeyup='javascript:{0}.SuggestUser(event);'
	                                        onclick='{0}.OnInputClick({0}, event);' onkeydown='{0}.ChangeSelection(event);'
                                            class='textEdit' style='width:100%;' value='{1}'/>
                                    </td>
                                    <td width='16px'>
                                        <img align='absmiddle' src='{2}'
                                         onclick='{0}.ClearFilter();'   
                                         style='cursor:pointer;' title='{3}'/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>",
                                    _jsObjName,
                                    valueForInput,
                                    Page.ClientScript.GetWebResourceUrl(GetType(), "ASC.Web.Controls.AdvancedUserSelector.images.cross_grey.png"),
                                    Resources.AdvancedUserSelectorResource.ClearFilter);

                    sb.AppendFormat("<input id='login' name='login' value='{0}' type='hidden'/>", SelectedUserId);
                    sb.Append("</div>");
                    sb.Append("</div>");
                }

                sb.Append("  <div id='divUsers' class='adv-userselector-users'></div>");
                sb.Append("  <div id='divDepartments' class='adv-userselector-deps'></div>");
                sb.Append("</div>");
            }
            sb.Append("</div>");

            writer.Write(sb.ToString());
        }
Example #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            if (String.IsNullOrEmpty(ParentContainerHtmlSelector))
            {
                var sb = new StringBuilder();
                sb.AppendFormat("<div id='{0}'>", _jsObjName);

                if (MobileDetector.IsMobile)
                {
                    sb.AppendFormat("<select class='comboBox' style='width:{0}px;' onchange='javascript:{1}.SelectUser(this);' >", InputWidth, _jsObjName);
                    sb.AppendFormat("<option style='max-width:300px;' value='{0}' {2}>{1}</option>",
                                    -1,
                                    _linkText.HtmlEncode(),
                                    Guid.Empty.Equals(SelectedUserId) ? "selected = 'selected'" : string.Empty);

                    var accounts = CoreContext.Authentication.GetUserAccounts().OrderBy(a => a.Name);

                    foreach (var account in accounts)
                    {
                        sb.AppendFormat("<option style='max-width:300px;' value='{0}' {2}>{1}</option>",
                                        account.ID,
                                        account.Name.HtmlEncode(),
                                        Equals(account.ID, SelectedUserId) ? "selected = 'selected'" : string.Empty);
                    }

                    sb.AppendFormat("</select>");
                }
                else
                {
                    var valueForInput = Guid.Empty.Equals(SelectedUserId) ? string.Empty : CoreContext.UserManager.GetUsers(SelectedUserId).DisplayUserName().ReplaceSingleQuote();

                    if (IsLinkView)
                    {
                        sb.AppendFormat("<span class='addUserLink' onclick='{0}.OnInputClick({0}, event);'><a class='link dotline'>{1}</a><span class='sort-down-black'></span></span>",
                                        _jsObjName,
                                        LinkText.HtmlEncode());
                    }
                    else
                    {
                        var peopleImgStyle = valueForInput.Trim() == string.Empty ? "display:none;" : "display:block;";
                        var searchImgStyle = valueForInput.Trim() == string.Empty ? "display:block;" : "display:none;";

                        sb.AppendFormat(@"
                            <table cellspacing='0' cellpadding='1' class='borderBase adv-userselector-inputContainer' width='{0}px'>
                                <tbody>
                                    <tr>
                                        <td width='16px'>
                                            <img align='absmiddle' src='{1}' id='peopleImg' style='margin:2px;{7}'/>
                                            <img align='absmiddle' src='{2}' id='searchImg' style='{8}'/>
                                        </td>
                                        <td>
                                            <input type='text' autocomplete='off'
                                                oninput='{3}.SuggestUser(event);' onpaste='{3}.SuggestUser(event);' onkeyup='{3}.SuggestUser(event);'
                                                onclick='{3}.OnInputClick({3}, event);' onkeydown='{3}.ChangeSelection(event);'
                                                class='textEdit inputUserName' style='width:100%;' value='{5}'/>
                                            <input class='loginhidden' name='login' value='{6}' type='hidden'/>
                                        </td>
                                        <td width='20px' onclick='{3}.OnInputClick({3}, event);'>
                                            <img align='absmiddle' src='{4}' style='cursor:pointer;'/>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>",
                                        InputWidth + 8,
                                        WebImageSupplier.GetAbsoluteWebPath("people_icon.png"),
                                        WebImageSupplier.GetAbsoluteWebPath("search.png"),
                                        _jsObjName,
                                        WebImageSupplier.GetAbsoluteWebPath("collapse_down_dark.png"),
                                        valueForInput,
                                        SelectedUserId,
                                        peopleImgStyle,
                                        searchImgStyle);
                    }

                    sb.AppendFormat("<div class='adv-userselector-DepsAndUsersContainer' {0}>", IsLinkView ? "style='height:230px'" : string.Empty);

                    if (IsLinkView)
                    {
                        sb.Append("<div style='margin-bottom: 10px;'>");
                        sb.Append("<div style='width:50%;'>");
                        sb.AppendFormat(@"
                            <table cellspacing='0' cellpadding='1' class='borderBase adv-userselector-inputContainer' width='100%' style='height: 18px;'>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type='text' autocomplete='off'
                                                oninput='javascript:{0}.SuggestUser(event);' onpaste='javascript:{0}.SuggestUser(event);' onkeyup='javascript:{0}.SuggestUser(event);'
                                                onclick='{0}.OnInputClick({0}, event);' onkeydown='{0}.ChangeSelection(event);'
                                                class='textEdit inputUserName' style='width:100%;' value='{1}'/>
                                        </td>
                                        <td width='16px'>
                                            <img align='absmiddle' src='{2}'
                                             onclick='{0}.ClearFilter();'
                                             style='cursor:pointer;' title='{3}'/>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>",
                                        _jsObjName,
                                        valueForInput,
                                        WebImageSupplier.GetAbsoluteWebPath("cross_grey.png"),
                                        UserControlsCommonResource.ClearFilter);

                        sb.AppendFormat("<input class='loginhidden' name='login' value='{0}' type='hidden'/>", SelectedUserId);
                        sb.Append("</div>");
                        sb.Append("</div>");
                    }

                    sb.Append("  <div class='adv-userselector-users'></div>");
                    sb.Append("  <div class='adv-userselector-deps'></div>");
                    sb.Append("</div>");
                }
                sb.Append("</div>");

                writer.Write(sb.ToString());
            }
        }