Beispiel #1
0
        fresh:function(para){
            var m = this;



            m._reqpara = para;


            if(!m.__fresh){
                m.__fresh = cl.throttle(2000,function(){
                    //分离信息面板
                    m.infoCont.detach();

                    m.listCont.empty();


                    m.sq.doo();
                })
            }


            m.__fresh();
            

        }
Beispiel #2
0
        /**
         * @param throttleDelay 节流阀延时,如果为0,或者为true,表示不适用节流阀
         * @param callback 回调function(windowWidth,widnowHeight,$window){}
         * @returns {*|jQuery|HTMLElement}
         */
        function winResize(throttleDelay,callback){
            var delay = 0;
            var _callback = callback;

            if($.isFunction(throttleDelay))
                callback = throttleDelay;
            else
                delay = throttleDelay;

            //delay为0或者true,表示不适用节流阀
            if(delay === 0 || delay === true){
                cb.add(callback);
            }else{
                cb.add(cl.throttle(delay,callback));
                cb.add(cl.debounce(delay,callback));
            }

            //没有找到body时
            if(!document.body){
                cl.run_until(function(){
                    if(document.body){
                        winResize(throttleDelay,callback);
                        return true;
                    }
                });
                return wi;
            }

            /*立即执行一次*/
            function docallback(){
                callback.call(
                    wi,
                    wi.width(),
                    wi.height(),
                    wi
                );
            }

            docallback();
            docallback.delayCall(delay/3);
            return wi;
        }
Beispiel #3
0
            require.async(["_/auto_complete/jquery.autocomplete","_/auto_complete/jquery.autocomplete.css"],function(){
                //搜索文本框
                var search_input = $("#search_input");

                //单击搜索按钮
                var dosearch_btn = search_input.next("em").click(function(){
                    var key = search_input.val();
//                    if(!key){
//                        //请输入关键字进行搜索
//                        return;
//                    }


                    request_key(search_input.val(),function(data){
                        data = cj.tojson(data);
                        EC.emit(EV_SEARCH_COMPLETE,{
                            list:data
                        })

                        mtookit.search_result = data.map(function(el){
                            return {
                                name:el.data.name,
                                geo:el.geometry
                            }
                        });
                    })

                });
                

                //回车搜索
                search_input.keydown(function(e){
                    if(e.keyCode == 13){
                        dosearch_btn.click();
                    }
                });

                mtookit.$watch("search_key",function(val){
//                    if(val){
                    dosearch();
//                    }
                })

                var dosearch = cl.throttle(300,function(){
                    dosearch_btn.click();
                });


                var states = [
                    'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
                    'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
                    'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
                    'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
                    'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
                    'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
                    'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
                    'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
                    'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
                ];
                0 && $("#search_input").autocomplete({
                    valueKey:"text",
                    source:[
                        states
                        /*,{
                         url:"/test.php?query=%QUERY%",
                         type:'remote',
                         getValue:function(item){
                         return item.title
                         },
                         ajax:{
                         dataType : 'jsonp'
                         }
                         }*/
                    ]
                });

                //测试数据
                //mtookit.search_result = states;
            })