SearchApe.js 1.7 KB
//人员搜索
import Loger from "../Loger";
import Ape from "./Ape";
import ClassDataProxy from "proxy/ClassDataProxy";
import $ from "jquery";
let loger = Loger.getLoger('PC-SearchApe');

class SearchApe extends Ape {
    constructor(){
        super();
        this.init();
        this.isShowRoster=false;
    }
    init(){
        $("#searchName").on('keyup',this._showSelectRosterChange.bind(this));
        $("#rosterIcon").on('click',this._showSelectBox.bind(this));
        $("#clearInput").on('click',this._clearInputInfo.bind(this));

    }
    _showSelectRosterChange(){
        var txt=$("#searchName").val();
        if($.trim(txt)!=""){
            $(".nameDiv").each(function () {
                var title = $(this).attr("title");
                if (title.indexOf(txt) != -1) {
                    $(this).parent().parent().show();
                } else {
                    $(this).parent().parent().hide();
                }
            });

        }else{
            $(".userListInfo").show();
        }
    }
    _showSelectBox(){
        if(ClassDataProxy.userRole==ClassDataProxy.USER_HOST||ClassDataProxy.userRole==ClassDataProxy.USER_INVISIBLE){
            if(!this.isShowRoster){
                $('#searchBox').show();
                $('#searchName').focus();
                this.isShowRoster=true;
                $('.curClassUserList').css("top","42px");
            }
            else{
                $('#searchBox').hide();
                this.isShowRoster=false;
                $('.curClassUserList').css("top","0px");
                this._clearInputInfo();
            }
        }
    }
    _clearInputInfo(){
        $("#searchName").val("");
        this._showSelectRosterChange();
    }
}
export default SearchApe;