zoukankan      html  css  js  c++  java
  • MUI

    ##打开页面默认弹出键盘及返回关闭键盘 http://www.cnblogs.com/phillyx/

    (function(keyboard) {
    	var openSoftKeyboard = function() {
    		if (mui.os.ios) {
    			var webView = plus.webview.currentWebview().nativeInstanceObject();
    			webView.plusCallMethod({
    				"setKeyboardDisplayRequiresUserAction": false
    			});
    		} else {
    			var Context = plus.android.importClass("android.content.Context");
    			var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
    			var main = plus.android.runtimeMainActivity();
    			var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
    			imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    		}
    	};
    	var autoFocus = function(obj) {
    		if (mui.os.ios) {
    			setTimeout(function() {
    				openSoftKeyboard();
    				obj.focus();
    				if (obj.tagName.toLowerCase() == 'textarea') {
    					moveEnd(obj);
    				}
    			}, 300);
    		} else {
    			//安卓的获取不到焦点,暂时不自动弹出
    		}
    	};
    	keyboard.autoFocus = autoFocus;
    	/**
    	 * 预加载页面返回时为隐藏,不会自动关闭输入法,可以通过blur来关闭
    	 * @param {Object} isRemoveValue
    	 */
    	function blur(isRemoveValue) {
    		var ac = document.activeElement;
    		ac.blur();
    		if (isRemoveValue && ac.value) {
    			ac.value = '';
    		}
    	};
    	keyboard.blur = blur;
    	/**
    	 * @description ios下textarea.onfocus 时,默认在字首,添加该方法移动到尾部
    	 * @param {Object} obj
    	 */
    
    	function moveEnd(obj) {
    		var len = obj.value.length;
    		if (document.selection) {
    			var sel = obj.createTextRange();
    			sel.moveStart('character', len);
    			sel.collapse();
    			sel.select();
    		} else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
    			obj.selectionStart = obj.selectionEnd = len;
    		}
    	};
    	//			mui.plusReady(function() {
    	//				if (mui.os.android) {
    	//					Array.prototype.forEach.call(document.querySelectorAll(".mui-input-group input[type='text']"), function(ip) {
    	//						ip.setAttribute('autofocus', 'autofocus');
    	//					});
    	//				}
    	//			});
    }(window.mykeyboard = {}));
    
  • 相关阅读:
    SpringMvc@RequestParam 来映射请求参数
    SpringMvc中@PathVariable注解简单的用法
    SpringMvc的学习之路
    平常的操作函数以及回调
    关于弹窗 取消 确定清空按钮的事件
    判断主表里子表不能添加相同的字段
    选择company回显appname
    树形菜单数据源
    .NET为什么要使用异步(async)编程?⭐⭐⭐⭐⭐
    通过HttpClient的方式去Curd数据⭐⭐⭐⭐
  • 原文地址:https://www.cnblogs.com/phillyx/p/4745963.html
Copyright © 2011-2022 走看看