npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mobile-select-area

v3.0.5

Published

选择地区

Downloads

67

Readme

mobile-select-area

手机联动选择地区 效果图如下:

mobile-select-area

mobile-select-area

例子见[DEMO] (http://tianxiangbing.github.io/mobile-select-area/)

或 (http://www.lovewebgames.com/jsmodule/mobile-select-area.html)

npm install mobile-select-area --save-dev

用法

node http.js

或者

打开start.bat

注:依赖于dialog

<!DOCTYPE>
<html>
	<head>
		<title>选择日期</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" type="text/css" href="../dist/mobile-select-area.css">
		<link rel="stylesheet" type="text/css" href="../dist/dialog.min.css">
		<script type="text/javascript" src="../dist/zepto.js"></script>
		<script type="text/javascript" src="../dist/dialog.js"></script>
		<script type="text/javascript" src="../dist/mobile-select-area.js"></script>
	</head>
	<body>
		<input type="text" id="txt_area" value="浙江省 杭州市 滨江区"/>
		<input type="hidden" id="hd_area" value="1,1,1"/>
		<script>
		var selectArea = new MobileSelectArea();
		selectArea.init({trigger:$('#txt_area'),value:$('#hd_area').val(),data:'data.json'});
		</script>
	</body>
</html>

属性及方法

position:'bottom'

当这个值为bottom时,弹层固定显示在底部,不传时居中显示,默认居中.

default:0||1

0为空,true时默认选中第一项,默认1

trigger:

触发弹窗的DOM元素 ,可以是input或其他

value:

初始值,

level: int

级别数,默认是3级的,省、市、区。

separator: ,

id值分隔符

eventName:tap|click

触发事件名称,默认click,使用zeptojs的可以用tap事件

data:

当data为json对象时可以直接解析,此时直接接收数组
当data为string发送ajax请求后返回json,格式如下:
{
	"data": [{
		"id": 1,
		"name": "浙江省",
		"child": [{
			"id": "1",
			"name": "杭州市",
			"child": [{
				"id": 1,
				"name": "滨江区"
			}]
		}]
	}, {
		"id": 2,
		"name": "江苏省",
		"child": [{
			"id": "1",
			"name": "南京",
			"child": [{
				"id": 1,
				"name": "解放区"
			}]
		}]
	}, {
		"id": 3,
		"name": "湖北省"
	}]
}

show:function()

直接显示弹窗的方法
selectArea2.show();

callback:function(scroller,text,value)

第一个是容器,第二个是选中后的text值,第三个参数是选中后的id。
并且this指向当前对象。
选中后的回调,默认有填充trigger的value值,以及赋值它后面紧跟着的hidden的value值,以逗号分隔id,空格分隔文字

cancelCallback(scroller,text,value)

点击取消时的回调,与`callback`参数相同,`this`指向当前对象

autoHide : bool

点击遮罩层时退出窗口,与取消同样,默认为true.