浏览代码

软键盘打开问题

jack 8 年之前
父节点
当前提交
5671294704
共有 1 个文件被更改,包括 64 次插入37 次删除
  1. 64 37
      app/js/searchfirst.js

+ 64 - 37
app/js/searchfirst.js

@ -1,5 +1,30 @@
1 1
mui.plusReady(function() {
2
		document.getElementById("searchval").focus();
2
	document.getElementById("searchval").focus()
3
	if(mui.os.ios) {
4
		var webView = plus.webview.currentWebview().nativeInstanceObject();
5
		webView.plusCallMethod({
6
			"setKeyboardDisplayRequiresUserAction": false
7
		});
8
	} else {
9
		var webview = plus.android.currentWebview();
10
		plus.android.importClass(webview);
11
		webview.requestFocus();
12
		var Context = plus.android.importClass("android.content.Context");
13
		var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
14
		var main = plus.android.runtimeMainActivity();
15
		var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
16
		imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
17
	}
18
	var fff=1;
19
	document.getElementById("searchval").addEventListener("blur",aa,false);
20
	function aa() {
21
		if(fff==1) {
22
			this.focus();
23
			fff=0;
24
			this.blur()
25
		}
26
		document.getElementById("searchval").removeEventListener("blur",aa,false);
27
	}
3 28
	var search = {
4 29
		oAjaxGet: function(url, obj, oType, oFun) {
5 30
			mui.ajax(url, {
@ -10,8 +35,12 @@ mui.plusReady(function() {
10 35
				traditional: true,
11 36
				success: function(data) {
12 37
					if(data.success) {
38
						setTimeout(function() {
39
							document.getElementById("searchval").focus()
40
						}, 500)
41

13 42
						oFun(data.data);
14
					} 
43
					}
15 44
				},
16 45
				error: function(xhr, type, errorThrown) {
17 46
					//异常处理;
@ -19,47 +48,45 @@ mui.plusReady(function() {
19 48
				}
20 49
			});
21 50
		},
22
		keyWord:function(data){
23
			if(data.lennth==0) {
51
		keyWord: function(data) {
52
			if(data.lennth == 0) {
24 53
				return;
25 54
			}
26
			for(var i=0;i<data.length;i++) {
27
				var li=document.createElement('li');
28
				li.innerHTML=data[i].caption;
55
			for(var i = 0; i < data.length; i++) {
56
				var li = document.createElement('li');
57
				li.innerHTML = data[i].caption;
29 58
				document.getElementsByClassName("hotsearchNew")[0].appendChild(li);
30 59
			}
31 60
		},
32
		createWin:function(keyValue) {
61
		createWin: function(keyValue) {
33 62
			mui.openWindow({
34
					url: '../html/searchListNew.html',
35
					id: '../html/searchListNew.html',
36
					show:{
37
				      autoShow:false,
38
				      aniShow:"fade-in",
39
				    },
40
					extras:{
41
				      key:keyValue,
42
				      qiFlag:1
43
				    }
44
				});
63
				url: '../html/searchListNew.html',
64
				id: '../html/searchListNew.html',
65
				show: {
66
					autoShow: false,
67
					aniShow: "fade-in",
68
				},
69
				extras: {
70
					key: keyValue,
71
					qiFlag: 1
72
				}
73
			});
45 74
		}
46 75
	}
47
	
48
		search.oAjaxGet(baseUrl + "/ajax/dataDict/qlHotKey", {
49
		}, "get", search.keyWord); 
50
		
51
		mui(".hotsearchNew").on("tap","li",function(){
52
			search.createWin(this.innerHTML);
53
		})
54
		
55
		/*按键字搜索*/
56
		document.getElementById("searchval").addEventListener("keyup", function() {
57
			var e = event || window.event || arguments.caller.arguments[0];
58
			if(e.keyCode == 13) {
59
				search.createWin(this.value);
60
				
61
			}
62
		})
63
		
64
		
76

77
	search.oAjaxGet(baseUrl + "/ajax/dataDict/qlHotKey", {}, "get", search.keyWord);
78

79
	mui(".hotsearchNew").on("tap", "li", function() {
80
		search.createWin(this.innerHTML);
81
	});
82

83
	/*按键字搜索*/
84
	document.getElementById("searchval").addEventListener("keyup", function() {
85
		var e = event || window.event || arguments.caller.arguments[0];
86
		if(e.keyCode == 13) {
87
			search.createWin(this.value);
88

89
		}
90
	})
91

65 92
})