This commit is contained in:
2025-04-26 11:07:05 +08:00
commit abf553c41b
4942 changed files with 930993 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
{
"name": "fastadmin-citypicker",
"description": "A simple jQuery plugin for picking provinces, cities and districts of China.",
"main": [
"dist/js/city-picker.js"
],
"keywords": [
"中国",
"省份",
"城市",
"行政区",
"省市区",
"三级联动",
"地址选择器",
"China",
"province",
"provinces",
"city",
"cities",
"district",
"districts",
"pick",
"picker",
"picking",
"jquery",
"plugin",
"html",
"css",
"javascript",
"front-end",
"web",
"development"
],
"authors": [
"Tao Shi"
],
"homepage": "https://github.com/karsonzhang/fastadmin-citypicker",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"docs"
],
"dependencies": {
"jquery": ">= 1.9.1"
},
"version": "1.3.6",
"_release": "1.3.6",
"_resolution": {
"type": "version",
"tag": "v1.3.6",
"commit": "bfe61733415ea9904caaf923d5c85fe824417856"
},
"_source": "https://github.com/karsonzhang/fastadmin-citypicker.git",
"_target": "~1.3.1",
"_originalSource": "fastadmin-citypicker"
}

View File

@@ -0,0 +1,6 @@
# Changelog
### 1.0.0 (Feb 26, 2016)
- Inital create.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2015 Tao Shi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,232 @@
# City Picker
> A simple jQuery plugin for picking provinces, cities and districts of China.
- [Demo](http://tshi0912.github.io/city-picker)
##Release History
###v1.1.0
Add function to get the code
```javascript
// type: null or undefined(get the full code path, separated with /), province, city, district
$('.city-picker').data('citypicker').getCode(type);
```
## Main
```
dist/
├── city-picker.js ( 7 KB)
├── city-picker.min.js ( 4 KB)
├── city-picker.data.js (98 KB)
└── city-picker.data.min.js (68 KB)
```
## Getting started
### Quick start
Four quick start options are available:
- [Download the latest release](https://github.com/tshi0912/city-picker/archive/master.zip).
- Clone the repository: `git clone https://github.com/tshi0912/city-picker.git`.
- Install with [NPM](http://npmjs.org): `npm install city-picker`.
- Install with [Bower](http://bower.io): `bower install city-picker`.
### Installation
Include files:
```html
<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<script src="/path/to/city-picker.data.js"></script>
<script src="/path/to/city-picker.js"></script>
```
Create HTML elements:
```html
<div style="position:relative;"><!-- container -->
<input readonly type="text">
</div>
```
### Usage
#### Initialize with `data-toggle="city-picker"` attribute
Basic
```html
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker">
</div>
```
Custom placeholders
```html
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" placeholder="customized placeholder...">
</div>
```
Responsive width
```html
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" data-responsive="true" style="width:50%;">
</div>
```
Custom province/city/district
```html
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" value="江苏省/常州市/溧阳市">
</div>
```
#### Initialize with `$.fn.city-picker` method
Basic
```js
$('#target').citypicker();
```
Custom districts
```js
$('#target').citypicker({
province: '江苏省',
city: '常州市',
district: '溧阳市'
});
```
## Options
- Change the default options with `$().citypicker(options)`.
- Change the global default options with `$.fn.citypicker.setDefaults(options)`.
### simple
- Type: `Boolean`
- Default: `false`
Make the address level more simple, e.g. `内蒙古` instead of `内蒙古自治区`.
### level
- Type: `String`
- Default: `district`
Only province, province + city, or province + city + district.
### responsive
- Type: `Boolean`
- Default: `false`
make the drop down and mask span responsive on width.
### placeholder
- Type: `Boolean`
- Default: `请输入省/市/区`
Show placeholder (with an `<option>` element).
### province
- Type: `String`
- Default: `null`
Defines the initial value of province. If it is a existing province in `city-picker.data.js`, it will be selected. If not, it will be used as a placeholder.
### city
- Type: `String`
- Default: `null`
Defines the initial value of city. If it is a existing city under the selected province, it will be selected. If not, it will be used as a placeholder.
### district
- Type: `String`
- Default: `null`
Defines the initial value of district. If it is a existing district under the selected city, it will be selected. If not, it will be used as a placeholder.
## Methods
### reset()
Reset the selects to the initial states (Undo changed).
**Examples:**
```js
$().citypicker('reset');
```
### destroy()
Destroy the city-picker instance, but keep the selected districts.
If you want to remove the selected districts, you can call `reset` method first and then call this method.
## No conflict
If you have to use other plugin with the same namespace, just call the `$.fn.city-picker.noConflict` method to revert to it.
```html
<script src="other-plugin.js"></script>
<script src="city-picker.js"></script>
<script>
$.fn.citypicker.noConflict();
// Code that uses other plugin's "$().citypicker" can follow here.
</script>
```
## Browser support
- Chrome (latest 2)
- Firefox (latest 2)
- Internet Explorer 8+
- Opera (latest 2)
- Safari (latest 2)
As a jQuery plugin, you also need to see the [jQuery Browser Support](http://jquery.com/browser-support/).
## License
[MIT](http://opensource.org/licenses/MIT) © [Tao Shi](http://shitao.me)

View File

@@ -0,0 +1,48 @@
{
"name": "fastadmin-citypicker",
"description": "A simple jQuery plugin for picking provinces, cities and districts of China.",
"main": [
"dist/js/city-picker.js"
],
"keywords": [
"中国",
"省份",
"城市",
"行政区",
"省市区",
"三级联动",
"地址选择器",
"China",
"province",
"provinces",
"city",
"cities",
"district",
"districts",
"pick",
"picker",
"picking",
"jquery",
"plugin",
"html",
"css",
"javascript",
"front-end",
"web",
"development"
],
"authors": [
"Tao Shi"
],
"homepage": "https://github.com/karsonzhang/fastadmin-citypicker",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"docs"
],
"dependencies": {
"jquery": ">= 1.9.1"
}
}

View File

@@ -0,0 +1,162 @@
.city-picker-input {
opacity: 0 !important;
top: -9999px;
left: -9999px;
position: absolute;
}
.city-picker-span {
position: relative;
display: block;
outline: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
border-bottom: 1px solid #ccc;
background-color: #fff;
color: #ccc;
cursor: pointer;
}
.city-picker-span > .placeholder {
color: #aaa;
}
.city-picker-span > .arrow {
position: absolute;
top: 50%;
right: 8px;
width: 10px;
margin-top: -3px;
height: 5px;
background: url(../images/drop-arrow.png) -10px -25px no-repeat;
}
.city-picker-span.focus,
.city-picker-span.open {
border-bottom-color: #46A4FF;
}
.city-picker-span.open > .arrow {
background-position: -10px -10px;
}
.city-picker-span > .title > span {
color: #333;
padding: 5px;
border-radius: 3px;
}
.city-picker-span > .title > span:hover {
background-color: #f1f8ff;
}
.city-picker-dropdown {
position: absolute;
width: 315px;
left: -9999px;
top: -9999px;
outline: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
z-index: 999999;
display: none;
min-width: 330px;
margin-bottom: 20px;
}
.city-select-wrap {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}
.city-select-tab {
border-bottom: 1px solid #ccc;
background: #f0f0f0;
font-size: 13px;
}
.city-select-tab > a {
display: inline-block;
padding: 8px 22px;
border-left: 1px solid #ccc;
border-bottom: 1px solid transparent;
color: #4D4D4D;
text-align: center;
outline: 0;
text-decoration: none;
cursor: pointer;
font-size: 14px;
margin-bottom: -1px;
}
.city-select-tab > a.active {
background: #fff;
border-bottom: 1px solid #fff;
color: #46A4FF;
}
.city-select-tab > a:first-child {
border-left: none;
}
.city-select-tab > a:last-child.active {
border-right: 1px solid #ccc;
}
.city-select-content {
width: 100%;
min-height: 10px;
background-color: #fff;
padding: 10px 15px;
box-sizing: border-box;
}
.city-select {
font-size: 13px;
}
.city-select dl {
line-height: 2;
clear: both;
padding: 3px 0;
margin: 0;
}
.city-select dt {
position: absolute;
width: 2.5em;
font-weight: 500;
text-align: right;
line-height: 2;
}
.city-select dd {
margin-left: 0;
line-height: 2;
}
.city-select.province dd {
margin-left: 3em;
}
.city-select a {
display: inline-block;
padding: 0 10px;
outline: 0;
text-decoration: none;
white-space: nowrap;
margin-right: 2px;
text-decoration: none;
color: #333;
cursor: pointer;
}
.city-select a:hover,
.city-select a:focus {
background-color: #f1f8ff;
border-radius: 2px;
color: #46A4FF;
}
.city-select a.active {
background-color: #46A4FF;
color: #fff;
border-radius: 2px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,662 @@
/*!
* CityPicker v1.3.2
* https://github.com/tshi0912/citypicker
*
* Copyright (c) 2015-2019 Tao Shi
* Released under the MIT license
*
* Date: 2019-10-19T17:21:49.592Z
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery', 'ChineseDistricts'], factory);
} else if (typeof exports === 'object') {
// Node / CommonJS
factory(require('jquery'), require('ChineseDistricts'));
} else {
// Browser globals.
factory(jQuery, ChineseDistricts);
}
})(function ($, ChineseDistricts) {
'use strict';
if (typeof ChineseDistricts === 'undefined') {
throw new Error('The file "city-picker.data.js" must be included first!');
}
var NAMESPACE = 'citypicker';
var EVENT_CHANGE = 'change.' + NAMESPACE;
var PROVINCE = 'province';
var CITY = 'city';
var DISTRICT = 'district';
function CityPicker(element, options) {
this.$element = $(element);
this.$dropdown = null;
this.options = $.extend({}, CityPicker.DEFAULTS, $.isPlainObject(options) && options);
this.active = false;
this.dems = [];
this.needBlur = false;
this.init();
}
CityPicker.prototype = {
constructor: CityPicker,
init: function () {
this.codeRender();
this.defineDems();
this.render();
this.bind();
this.active = true;
},
codeRender: function () {
var code = this.$element.attr('code');
var value = this.$element.val();
if (code !== undefined && code !== '' && !isNaN(Number(code))) this.$element.val($.fn.citypicker.getAddressbyCodeId(code));
if (value !== undefined && value !== '' && !isNaN(Number(value))) this.$element.val($.fn.citypicker.getAddressbyCodeId(value));
},
render: function () {
var p = this.getPosition(),
placeholder = this.$element.attr('placeholder') || this.options.placeholder,
textspan = '<span class="city-picker-span" style="' +
this.getWidthStyle(p.width) + 'height:' +
p.height + 'px;line-height:' + (p.height - 1) + 'px;">' +
(placeholder ? '<span class="placeholder">' + placeholder + '</span>' : '') +
'<span class="title"></span><div class="arrow"></div>' + '</span>',
dropdown = '<div class="city-picker-dropdown" style="left:0px;top:100%;' +
this.getWidthStyle(p.width, true) + '">' +
'<div class="city-select-wrap">' +
'<div class="city-select-tab">' +
'<a class="active" data-count="province">省份</a>' +
(this.includeDem('city') ? '<a data-count="city">城市</a>' : '') +
(this.includeDem('district') ? '<a data-count="district">区县</a>' : '') + '</div>' +
'<div class="city-select-content">' +
'<div class="city-select province" data-count="province"></div>' +
(this.includeDem('city') ? '<div class="city-select city" data-count="city"></div>' : '') +
(this.includeDem('district') ? '<div class="city-select district" data-count="district"></div>' : '') +
'</div></div>';
this.$element.addClass('city-picker-input');
this.$textspan = $(textspan).insertAfter(this.$element);
this.$dropdown = $(dropdown).insertAfter(this.$textspan);
var $select = this.$dropdown.find('.city-select');
// setup this.$province, this.$city and/or this.$district object
$.each(this.dems, $.proxy(function (i, type) {
this['$' + type] = $select.filter('.' + type + '');
}, this));
this.refresh();
},
refresh: function (force) {
// clean the data-item for each $select
var $select = this.$dropdown.find('.city-select');
$select.data('item', null);
// parse value from value of the target $element
var val = this.$element.val() || '';
val = val.split('/');
$.each(this.dems, $.proxy(function (i, type) {
if (val[i] && i < val.length) {
this.options[type] = val[i];
} else if (force) {
this.options[type] = '';
}
this.output(type);
}, this));
this.tab(PROVINCE);
this.feedText();
this.feedVal();
},
defineDems: function () {
var stop = false;
$.each([PROVINCE, CITY, DISTRICT], $.proxy(function (i, type) {
if (!stop) {
this.dems.push(type);
}
if (type === this.options.level) {
stop = true;
}
}, this));
},
includeDem: function (type) {
return $.inArray(type, this.dems) !== -1;
},
getPosition: function () {
var p, h, w, s, pw;
p = this.$element.position();
s = this.getSize(this.$element);
h = s.height;
w = s.width;
if (this.options.responsive) {
pw = this.$element.offsetParent().width();
if (pw) {
w = w / pw;
if (w > 0.99) {
w = 1;
}
w = w * 100 + '%';
}
}
return {
top: p.top || 0,
left: p.left || 0,
height: h,
width: w
};
},
getSize: function ($dom) {
var $wrap, $clone, sizes;
if (!$dom.is(':visible')) {
$wrap = $("<div />").appendTo($("body"));
$wrap.css({
"position": "absolute !important",
"visibility": "hidden !important",
"display": "block !important"
});
$clone = $dom.clone().appendTo($wrap);
sizes = {
width: $clone.outerWidth(),
height: $clone.outerHeight()
};
$wrap.remove();
} else {
sizes = {
width: $dom.outerWidth(),
height: $dom.outerHeight()
};
}
return sizes;
},
getWidthStyle: function (w, dropdown) {
if (this.options.responsive && !$.isNumeric(w)) {
return 'width:' + w + ';';
} else {
return 'width:' + (dropdown ? Math.max(320, w) : w) + 'px;';
}
},
bind: function () {
var $this = this;
$(document).on('click', (this._mouteclick = function (e) {
var $target = $(e.target);
var $dropdown, $span, $input;
if ($target.is('.city-picker-span')) {
$span = $target;
} else if ($target.is('.city-picker-span *')) {
$span = $target.parents('.city-picker-span');
}
if ($target.is('.city-picker-input')) {
$input = $target;
}
if ($target.is('.city-picker-dropdown')) {
$dropdown = $target;
} else if ($target.is('.city-picker-dropdown *')) {
$dropdown = $target.parents('.city-picker-dropdown');
}
if ((!$input && !$span && !$dropdown) ||
($span && $span.get(0) !== $this.$textspan.get(0)) ||
($input && $input.get(0) !== $this.$element.get(0)) ||
($dropdown && $dropdown.get(0) !== $this.$dropdown.get(0))) {
$this.close(true);
}
}));
this.$element.on('change', (this._changeElement = $.proxy(function () {
this.close(true);
this.refresh(true);
}, this))).on('focus', (this._focusElement = $.proxy(function () {
this.needBlur = true;
this.open();
}, this))).on('blur', (this._blurElement = $.proxy(function () {
if (this.needBlur) {
this.needBlur = false;
this.close(true);
}
}, this)));
this.$textspan.on('click', function (e) {
var $target = $(e.target), type;
$this.needBlur = false;
if ($target.is('.select-item')) {
type = $target.data('count');
$this.open(type);
} else {
if ($this.$dropdown.is(':visible')) {
$this.close();
} else {
$this.open();
}
}
}).on('mousedown', function () {
$this.needBlur = false;
});
this.$dropdown.on('click', '.city-select a', function () {
var $select = $(this).parents('.city-select');
var $active = $select.find('a.active');
var last = $select.next().length === 0;
$active.removeClass('active');
$(this).addClass('active');
if ($active.data('code') !== $(this).data('code')) {
$select.data('item', {
address: $(this).attr('title'), code: $(this).data('code')
});
$(this).trigger(EVENT_CHANGE);
$this.feedText();
$this.feedVal(true);
if (last) {
$this.close();
}
}
}).on('click', '.city-select-tab a', function () {
if (!$(this).hasClass('active')) {
var type = $(this).data('count');
$this.tab(type);
}
}).on('mousedown', function () {
$this.needBlur = false;
});
if (this.$province) {
this.$province.on(EVENT_CHANGE, (this._changeProvince = $.proxy(function () {
this.output(CITY);
this.output(DISTRICT);
this.tab(CITY);
}, this)));
}
if (this.$city) {
this.$city.on(EVENT_CHANGE, (this._changeCity = $.proxy(function () {
this.output(DISTRICT);
this.tab(DISTRICT);
}, this)));
}
},
open: function (type) {
type = type || PROVINCE;
this.$dropdown.show();
this.$textspan.addClass('open').addClass('focus');
this.tab(type);
},
close: function (blur) {
this.$dropdown.hide();
this.$textspan.removeClass('open');
if (blur) {
this.$textspan.removeClass('focus');
}
},
unbind: function () {
$(document).off('click', this._mouteclick);
this.$element.off('change', this._changeElement);
this.$element.off('focus', this._focusElement);
this.$element.off('blur', this._blurElement);
this.$textspan.off('click');
this.$textspan.off('mousedown');
this.$dropdown.off('click');
this.$dropdown.off('mousedown');
if (this.$province) {
this.$province.off(EVENT_CHANGE, this._changeProvince);
}
if (this.$city) {
this.$city.off(EVENT_CHANGE, this._changeCity);
}
},
getText: function () {
var text = '';
this.$dropdown.find('.city-select')
.each(function () {
var item = $(this).data('item'),
type = $(this).data('count');
if (item) {
text += ($(this).hasClass('province') ? '' : '/') + '<span class="select-item" data-count="' +
type + '" data-code="' + item.code + '">' + item.address + '</span>';
}
});
return text;
},
getPlaceHolder: function () {
return this.$element.attr('placeholder') || this.options.placeholder;
},
feedText: function () {
var text = this.getText();
if (text) {
this.$textspan.find('>.placeholder').hide();
this.$textspan.find('>.title').html(this.getText()).show();
} else {
this.$textspan.find('>.placeholder').text(this.getPlaceHolder()).show();
this.$textspan.find('>.title').html('').hide();
}
},
getCode: function (count) {
var obj = {}, arr = [];
this.$textspan.find('.select-item')
.each(function () {
var code = $(this).data('code');
var count = $(this).data('count');
obj[count] = code;
arr.push(code);
});
return count ? obj[count] : arr.join('/');
},
getVal: function () {
var text = '';
var code = '';
this.$dropdown.find('.city-select')
.each(function () {
var item = $(this).data('item');
if (item) {
code = item.code;
text += ($(this).hasClass('province') ? '' : '/') + item.address;
}
});
return this.options.render == 'code' ? code : text;
},
feedVal: function (trigger) {
this.$element.val(this.getVal());
if (trigger) {
this.$element.trigger('cp:updated');
}
},
output: function (type) {
var options = this.options;
//var placeholders = this.placeholders;
var $select = this['$' + type];
var data = type === PROVINCE ? {} : [];
var item;
var districts;
var code;
var matched = null;
var value;
if (!$select || !$select.length) {
return;
}
item = $select.data('item');
value = (item ? item.address : null) || options[type];
code = (
type === PROVINCE ? 86 :
type === CITY ? this.$province && this.$province.find('.active').data('code') :
type === DISTRICT ? this.$city && this.$city.find('.active').data('code') : code
);
districts = $.isNumeric(code) ? ChineseDistricts[code] : null;
if ($.isPlainObject(districts)) {
$.each(districts, function (code, address) {
var provs;
if (type === PROVINCE) {
provs = [];
for (var i = 0; i < address.length; i++) {
if (address[i].address === value) {
matched = {
code: address[i].code,
address: address[i].address
};
}
provs.push({
code: address[i].code,
address: address[i].address,
selected: address[i].address === value
});
}
data[code] = provs;
} else {
if (address === value) {
matched = {
code: code,
address: address
};
}
data.push({
code: code,
address: address,
selected: address === value
});
}
});
}
$select.html(type === PROVINCE ? this.getProvinceList(data) :
this.getList(data, type));
$select.data('item', matched);
},
getProvinceList: function (data) {
var list = [],
$this = this,
simple = this.options.simple;
$.each(data, function (i, n) {
list.push('<dl class="clearfix">');
list.push('<dt>' + i + '</dt><dd>');
$.each(n, function (j, m) {
list.push(
'<a' +
' title="' + (m.address || '') + '"' +
' data-code="' + (m.code || '') + '"' +
' class="' +
(m.selected ? ' active' : '') +
'">' +
(simple ? $this.simplize(m.address, PROVINCE) : m.address) +
'</a>');
});
list.push('</dd></dl>');
});
return list.join('');
},
getList: function (data, type) {
var list = [],
$this = this,
simple = this.options.simple;
list.push('<dl class="clearfix"><dd>');
$.each(data, function (i, n) {
list.push(
'<a' +
' title="' + (n.address || '') + '"' +
' data-code="' + (n.code || '') + '"' +
' class="' +
(n.selected ? ' active' : '') +
'">' +
(simple ? $this.simplize(n.address, type) : n.address) +
'</a>');
});
list.push('</dd></dl>');
return list.join('');
},
simplize: function (address, type) {
address = address || '';
if (type === PROVINCE) {
return address.replace(/[省,市,自治区,壮族,回族,维吾尔,特别行政区]/g, '');
} else if (type === CITY) {
return address.replace(/[市,地区,回族,蒙古,苗族,白族,傣族,景颇族,藏族,彝族,壮族,傈僳族,布依族,侗族]/g, '')
.replace('哈萨克', '').replace('自治州', '').replace(/自治县/, '');
} else if (type === DISTRICT) {
return address.length > 2 ? address.replace(/[市,区,县,旗]/g, '') : address;
}
},
tab: function (type) {
var $selects = this.$dropdown.find('.city-select');
var $tabs = this.$dropdown.find('.city-select-tab > a');
var $select = this['$' + type];
var $tab = this.$dropdown.find('.city-select-tab > a[data-count="' + type + '"]');
if ($select) {
$selects.hide();
$select.show();
$tabs.removeClass('active');
$tab.addClass('active');
}
},
reset: function () {
this.$element.val(null).trigger('change');
},
destroy: function () {
this.unbind();
this.$element.removeData(NAMESPACE).removeClass('city-picker-input');
this.$textspan.remove();
this.$dropdown.remove();
}
};
CityPicker.DEFAULTS = {
simple: false,
responsive: true,
render: 'text',//填充为代码还是文本可选code或text
placeholder: '请选择省/市/区',
level: 'district',
province: '',
city: '',
district: ''
};
CityPicker.setDefaults = function (options) {
$.extend(CityPicker.DEFAULTS, options);
};
// Save the other citypicker
CityPicker.other = $.fn.citypicker;
// Register as jQuery plugin
$.fn.citypicker = function (option) {
var args = [].slice.call(arguments, 1);
return this.each(function () {
var $this = $(this);
var data = $this.data(NAMESPACE);
var options;
var fn;
if (!data) {
if (/destroy/.test(option)) {
return;
}
options = $.extend({}, $this.data(), $.isPlainObject(option) && option);
$this.data(NAMESPACE, (data = new CityPicker(this, options)));
}
if (typeof option === 'string' && $.isFunction(fn = data[option])) {
fn.apply(data, args);
}
});
};
$.fn.citypicker.Constructor = CityPicker;
$.fn.citypicker.setDefaults = CityPicker.setDefaults;
// No conflict
$.fn.citypicker.noConflict = function () {
$.fn.citypicker = CityPicker.other;
return this;
};
// 根据code查询地址
$.fn.citypicker.getAddressbyCodeId = function (code_id) {
var city = ChineseDistricts;
var code = city['' + code_id];
var addr = '';
var province = '';
var province_code = '';
var city_str = '';
var county = '';
if (code_id.substring(0, 2) === '44') {
province = '广东省';
province_code = '440000';
} else {
$.each(city['86'], function (i, item) {
$.each(item, function (j, index) {
if (index['code'] === code_id.substring(0, 2) + '0000') {
province = index['address'];
province_code = index['code'];
return false;
}
});
});
}
if (code_id.substring(2, 4).indexOf('00') == -1) {
if (code_id.length > 6) {
var city_code = code_id.substring(0, 6);
if (typeof city[province_code][city_code] !== 'undefined') {
city_str = city[province_code][city_code];
}
}
if (!city_str) {
var city_code = code_id.substring(0, 4) + '00';
if (typeof city[province_code][city_code] === 'undefined') {
city_code = code_id.substring(0, 3) + '100';
}
if (typeof city[province_code][city_code] !== 'undefined') {
city_str = city[province_code][city_code];
}
}
}
if (code === undefined) {
addr = city[city_code][code_id];
return addr = province + '/' + city_str + '/' + addr;
} else {
if (code_id.substring(2, 4).indexOf('00') != -1) {
//440000
return addr = province;
} else {
//440100
var city_city = city[code_id.substring(0, 2) + '0000'];
return addr = province + '/' + city_city[code_id];
}
}
}
$(function () {
$('[data-toggle="city-picker"]').citypicker();
});
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,102 @@
'use strict';
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
pkg = require('./package'),
scripts = {
all: [
'src/*.js',
'gulpfile.js',
'docs/js/main.js'
],
src: 'src/*.js',
docs: 'docs/js',
dest: 'dist/js'
},
styles = {
src: 'src/css/*.css',
docs: 'docs/css',
dest: 'dist/css'
},
images = {
src: 'src/images/*.png',
docs: 'docs/images',
dest: 'dist/images'
};
gulp.task('jshint', function () {
return gulp.src(scripts.all)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'));
});
gulp.task('jscs', function () {
return gulp.src(scripts.all)
.pipe(plugins.jscs());
});
gulp.task('js', ['jshint', 'jscs', 'copy'], function () {
return gulp.src(scripts.src)
.pipe(plugins.replace(/@\w+/g, function (placeholder) {
switch (placeholder) {
case '@VERSION':
placeholder = pkg.version;
break;
case '@YEAR':
placeholder = (new Date()).getFullYear();
break;
case '@DATE':
placeholder = (new Date()).toISOString();
break;
}
return placeholder;
}))
.pipe(gulp.dest(scripts.docs))
.pipe(gulp.dest(scripts.dest))
.pipe(plugins.rename({
suffix: '.min'
}))
.pipe(plugins.uglify({
preserveComments: 'license'
}))
.pipe(gulp.dest(scripts.dest));
});
gulp.task('jscopy', function () {
return gulp.src(scripts.src)
.pipe(gulp.dest(scripts.docs))
.pipe(gulp.dest(scripts.dest));
});
gulp.task('csscopy', function () {
return gulp.src(styles.src)
.pipe(gulp.dest(styles.docs))
.pipe(gulp.dest(styles.dest));
});
gulp.task('imagecopy', function () {
return gulp.src(images.src)
.pipe(gulp.dest(images.docs))
.pipe(gulp.dest(images.dest));
});
gulp.task('copy', ['jscopy', 'csscopy', 'imagecopy'], function () {
});
gulp.task('docs', function () {
return gulp.src('docs/**')
.pipe(gulp.dest('_gh_pages'));
});
gulp.task('release', ['js', 'docs'], function () {
return gulp.src('dist/**/*')
.pipe(gulp.dest('_releases/' + pkg.version));
});
gulp.task('watch', function () {
gulp.watch(scripts.src, ['jscopy']);
gulp.watch(styles.src, ['csscopy']);
});
gulp.task('default', ['watch']);

View File

@@ -0,0 +1,52 @@
{
"name": "fastadmin-citypicker",
"description": "A simple jQuery plugin for picking provinces, cities and districts of China.",
"version": "1.3.6",
"main": "dist/city-picker.js",
"license": "MIT",
"repository": "karsonzhang/fastadmin-citypicker",
"homepage": "http://tshi0912.github.io/city-picker",
"author": {
"name": "Tao Shi",
"url": "http://shitao.me"
},
"keywords": [
"中国",
"省份",
"城市",
"行政区",
"省市区",
"三级联动",
"地址选择器",
"China",
"province",
"provinces",
"city",
"cities",
"district",
"districts",
"pick",
"picker",
"picking",
"jquery",
"plugin",
"html",
"css",
"javascript",
"front-end",
"web",
"development"
],
"dependencies": {
"jquery": ">= 1.9.1"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^1.12.0",
"gulp-load-plugins": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-uglify": "^1.5.1"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,662 @@
/*!
* CityPicker v@VERSION
* https://github.com/tshi0912/citypicker
*
* Copyright (c) 2015-@YEAR Tao Shi
* Released under the MIT license
*
* Date: @DATE
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery', 'ChineseDistricts'], factory);
} else if (typeof exports === 'object') {
// Node / CommonJS
factory(require('jquery'), require('ChineseDistricts'));
} else {
// Browser globals.
factory(jQuery, ChineseDistricts);
}
})(function ($, ChineseDistricts) {
'use strict';
if (typeof ChineseDistricts === 'undefined') {
throw new Error('The file "city-picker.data.js" must be included first!');
}
var NAMESPACE = 'citypicker';
var EVENT_CHANGE = 'change.' + NAMESPACE;
var PROVINCE = 'province';
var CITY = 'city';
var DISTRICT = 'district';
function CityPicker(element, options) {
this.$element = $(element);
this.$dropdown = null;
this.options = $.extend({}, CityPicker.DEFAULTS, $.isPlainObject(options) && options);
this.active = false;
this.dems = [];
this.needBlur = false;
this.init();
}
CityPicker.prototype = {
constructor: CityPicker,
init: function () {
this.codeRender();
this.defineDems();
this.render();
this.bind();
this.active = true;
},
codeRender: function () {
var code = this.$element.attr('code');
var value = this.$element.val();
if (code !== undefined && code !== '' && !isNaN(Number(code))) this.$element.val($.fn.citypicker.getAddressbyCodeId(code));
if (value !== undefined && value !== '' && !isNaN(Number(value))) this.$element.val($.fn.citypicker.getAddressbyCodeId(value));
},
render: function () {
var p = this.getPosition(),
placeholder = this.$element.attr('placeholder') || this.options.placeholder,
textspan = '<span class="city-picker-span" style="' +
this.getWidthStyle(p.width) + 'height:' +
p.height + 'px;line-height:' + (p.height - 1) + 'px;">' +
(placeholder ? '<span class="placeholder">' + placeholder + '</span>' : '') +
'<span class="title"></span><div class="arrow"></div>' + '</span>',
dropdown = '<div class="city-picker-dropdown" style="left:0px;top:100%;' +
this.getWidthStyle(p.width, true) + '">' +
'<div class="city-select-wrap">' +
'<div class="city-select-tab">' +
'<a class="active" data-count="province">省份</a>' +
(this.includeDem('city') ? '<a data-count="city">城市</a>' : '') +
(this.includeDem('district') ? '<a data-count="district">区县</a>' : '') + '</div>' +
'<div class="city-select-content">' +
'<div class="city-select province" data-count="province"></div>' +
(this.includeDem('city') ? '<div class="city-select city" data-count="city"></div>' : '') +
(this.includeDem('district') ? '<div class="city-select district" data-count="district"></div>' : '') +
'</div></div>';
this.$element.addClass('city-picker-input');
this.$textspan = $(textspan).insertAfter(this.$element);
this.$dropdown = $(dropdown).insertAfter(this.$textspan);
var $select = this.$dropdown.find('.city-select');
// setup this.$province, this.$city and/or this.$district object
$.each(this.dems, $.proxy(function (i, type) {
this['$' + type] = $select.filter('.' + type + '');
}, this));
this.refresh();
},
refresh: function (force) {
// clean the data-item for each $select
var $select = this.$dropdown.find('.city-select');
$select.data('item', null);
// parse value from value of the target $element
var val = this.$element.val() || '';
val = val.split('/');
$.each(this.dems, $.proxy(function (i, type) {
if (val[i] && i < val.length) {
this.options[type] = val[i];
} else if (force) {
this.options[type] = '';
}
this.output(type);
}, this));
this.tab(PROVINCE);
this.feedText();
this.feedVal();
},
defineDems: function () {
var stop = false;
$.each([PROVINCE, CITY, DISTRICT], $.proxy(function (i, type) {
if (!stop) {
this.dems.push(type);
}
if (type === this.options.level) {
stop = true;
}
}, this));
},
includeDem: function (type) {
return $.inArray(type, this.dems) !== -1;
},
getPosition: function () {
var p, h, w, s, pw;
p = this.$element.position();
s = this.getSize(this.$element);
h = s.height;
w = s.width;
if (this.options.responsive) {
pw = this.$element.offsetParent().width();
if (pw) {
w = w / pw;
if (w > 0.99) {
w = 1;
}
w = w * 100 + '%';
}
}
return {
top: p.top || 0,
left: p.left || 0,
height: h,
width: w
};
},
getSize: function ($dom) {
var $wrap, $clone, sizes;
if (!$dom.is(':visible')) {
$wrap = $("<div />").appendTo($("body"));
$wrap.css({
"position": "absolute !important",
"visibility": "hidden !important",
"display": "block !important"
});
$clone = $dom.clone().appendTo($wrap);
sizes = {
width: $clone.outerWidth(),
height: $clone.outerHeight()
};
$wrap.remove();
} else {
sizes = {
width: $dom.outerWidth(),
height: $dom.outerHeight()
};
}
return sizes;
},
getWidthStyle: function (w, dropdown) {
if (this.options.responsive && !$.isNumeric(w)) {
return 'width:' + w + ';';
} else {
return 'width:' + (dropdown ? Math.max(320, w) : w) + 'px;';
}
},
bind: function () {
var $this = this;
$(document).on('click', (this._mouteclick = function (e) {
var $target = $(e.target);
var $dropdown, $span, $input;
if ($target.is('.city-picker-span')) {
$span = $target;
} else if ($target.is('.city-picker-span *')) {
$span = $target.parents('.city-picker-span');
}
if ($target.is('.city-picker-input')) {
$input = $target;
}
if ($target.is('.city-picker-dropdown')) {
$dropdown = $target;
} else if ($target.is('.city-picker-dropdown *')) {
$dropdown = $target.parents('.city-picker-dropdown');
}
if ((!$input && !$span && !$dropdown) ||
($span && $span.get(0) !== $this.$textspan.get(0)) ||
($input && $input.get(0) !== $this.$element.get(0)) ||
($dropdown && $dropdown.get(0) !== $this.$dropdown.get(0))) {
$this.close(true);
}
}));
this.$element.on('change', (this._changeElement = $.proxy(function () {
this.close(true);
this.refresh(true);
}, this))).on('focus', (this._focusElement = $.proxy(function () {
this.needBlur = true;
this.open();
}, this))).on('blur', (this._blurElement = $.proxy(function () {
if (this.needBlur) {
this.needBlur = false;
this.close(true);
}
}, this)));
this.$textspan.on('click', function (e) {
var $target = $(e.target), type;
$this.needBlur = false;
if ($target.is('.select-item')) {
type = $target.data('count');
$this.open(type);
} else {
if ($this.$dropdown.is(':visible')) {
$this.close();
} else {
$this.open();
}
}
}).on('mousedown', function () {
$this.needBlur = false;
});
this.$dropdown.on('click', '.city-select a', function () {
var $select = $(this).parents('.city-select');
var $active = $select.find('a.active');
var last = $select.next().length === 0;
$active.removeClass('active');
$(this).addClass('active');
if ($active.data('code') !== $(this).data('code')) {
$select.data('item', {
address: $(this).attr('title'), code: $(this).data('code')
});
$(this).trigger(EVENT_CHANGE);
$this.feedText();
$this.feedVal(true);
if (last) {
$this.close();
}
}
}).on('click', '.city-select-tab a', function () {
if (!$(this).hasClass('active')) {
var type = $(this).data('count');
$this.tab(type);
}
}).on('mousedown', function () {
$this.needBlur = false;
});
if (this.$province) {
this.$province.on(EVENT_CHANGE, (this._changeProvince = $.proxy(function () {
this.output(CITY);
this.output(DISTRICT);
this.tab(CITY);
}, this)));
}
if (this.$city) {
this.$city.on(EVENT_CHANGE, (this._changeCity = $.proxy(function () {
this.output(DISTRICT);
this.tab(DISTRICT);
}, this)));
}
},
open: function (type) {
type = type || PROVINCE;
this.$dropdown.show();
this.$textspan.addClass('open').addClass('focus');
this.tab(type);
},
close: function (blur) {
this.$dropdown.hide();
this.$textspan.removeClass('open');
if (blur) {
this.$textspan.removeClass('focus');
}
},
unbind: function () {
$(document).off('click', this._mouteclick);
this.$element.off('change', this._changeElement);
this.$element.off('focus', this._focusElement);
this.$element.off('blur', this._blurElement);
this.$textspan.off('click');
this.$textspan.off('mousedown');
this.$dropdown.off('click');
this.$dropdown.off('mousedown');
if (this.$province) {
this.$province.off(EVENT_CHANGE, this._changeProvince);
}
if (this.$city) {
this.$city.off(EVENT_CHANGE, this._changeCity);
}
},
getText: function () {
var text = '';
this.$dropdown.find('.city-select')
.each(function () {
var item = $(this).data('item'),
type = $(this).data('count');
if (item) {
text += ($(this).hasClass('province') ? '' : '/') + '<span class="select-item" data-count="' +
type + '" data-code="' + item.code + '">' + item.address + '</span>';
}
});
return text;
},
getPlaceHolder: function () {
return this.$element.attr('placeholder') || this.options.placeholder;
},
feedText: function () {
var text = this.getText();
if (text) {
this.$textspan.find('>.placeholder').hide();
this.$textspan.find('>.title').html(this.getText()).show();
} else {
this.$textspan.find('>.placeholder').text(this.getPlaceHolder()).show();
this.$textspan.find('>.title').html('').hide();
}
},
getCode: function (count) {
var obj = {}, arr = [];
this.$textspan.find('.select-item')
.each(function () {
var code = $(this).data('code');
var count = $(this).data('count');
obj[count] = code;
arr.push(code);
});
return count ? obj[count] : arr.join('/');
},
getVal: function () {
var text = '';
var code = '';
this.$dropdown.find('.city-select')
.each(function () {
var item = $(this).data('item');
if (item) {
code = item.code;
text += ($(this).hasClass('province') ? '' : '/') + item.address;
}
});
return this.options.render == 'code' ? code : text;
},
feedVal: function (trigger) {
this.$element.val(this.getVal());
if(trigger) {
this.$element.trigger('cp:updated');
}
},
output: function (type) {
var options = this.options;
//var placeholders = this.placeholders;
var $select = this['$' + type];
var data = type === PROVINCE ? {} : [];
var item;
var districts;
var code;
var matched = null;
var value;
if (!$select || !$select.length) {
return;
}
item = $select.data('item');
value = (item ? item.address : null) || options[type];
code = (
type === PROVINCE ? 86 :
type === CITY ? this.$province && this.$province.find('.active').data('code') :
type === DISTRICT ? this.$city && this.$city.find('.active').data('code') : code
);
districts = $.isNumeric(code) ? ChineseDistricts[code] : null;
if ($.isPlainObject(districts)) {
$.each(districts, function (code, address) {
var provs;
if (type === PROVINCE) {
provs = [];
for (var i = 0; i < address.length; i++) {
if (address[i].address === value) {
matched = {
code: address[i].code,
address: address[i].address
};
}
provs.push({
code: address[i].code,
address: address[i].address,
selected: address[i].address === value
});
}
data[code] = provs;
} else {
if (address === value) {
matched = {
code: code,
address: address
};
}
data.push({
code: code,
address: address,
selected: address === value
});
}
});
}
$select.html(type === PROVINCE ? this.getProvinceList(data) :
this.getList(data, type));
$select.data('item', matched);
},
getProvinceList: function (data) {
var list = [],
$this = this,
simple = this.options.simple;
$.each(data, function (i, n) {
list.push('<dl class="clearfix">');
list.push('<dt>' + i + '</dt><dd>');
$.each(n, function (j, m) {
list.push(
'<a' +
' title="' + (m.address || '') + '"' +
' data-code="' + (m.code || '') + '"' +
' class="' +
(m.selected ? ' active' : '') +
'">' +
( simple ? $this.simplize(m.address, PROVINCE) : m.address) +
'</a>');
});
list.push('</dd></dl>');
});
return list.join('');
},
getList: function (data, type) {
var list = [],
$this = this,
simple = this.options.simple;
list.push('<dl class="clearfix"><dd>');
$.each(data, function (i, n) {
list.push(
'<a' +
' title="' + (n.address || '') + '"' +
' data-code="' + (n.code || '') + '"' +
' class="' +
(n.selected ? ' active' : '') +
'">' +
( simple ? $this.simplize(n.address, type) : n.address) +
'</a>');
});
list.push('</dd></dl>');
return list.join('');
},
simplize: function (address, type) {
address = address || '';
if (type === PROVINCE) {
return address.replace(/[省,市,自治区,壮族,回族,维吾尔,特别行政区]/g, '');
} else if (type === CITY) {
return address.replace(/[市,地区,回族,蒙古,苗族,白族,傣族,景颇族,藏族,彝族,壮族,傈僳族,布依族,侗族]/g, '')
.replace('哈萨克', '').replace('自治州', '').replace(/自治县/, '');
} else if (type === DISTRICT) {
return address.length > 2 ? address.replace(/[市,区,县,旗]/g, '') : address;
}
},
tab: function (type) {
var $selects = this.$dropdown.find('.city-select');
var $tabs = this.$dropdown.find('.city-select-tab > a');
var $select = this['$' + type];
var $tab = this.$dropdown.find('.city-select-tab > a[data-count="' + type + '"]');
if ($select) {
$selects.hide();
$select.show();
$tabs.removeClass('active');
$tab.addClass('active');
}
},
reset: function () {
this.$element.val(null).trigger('change');
},
destroy: function () {
this.unbind();
this.$element.removeData(NAMESPACE).removeClass('city-picker-input');
this.$textspan.remove();
this.$dropdown.remove();
}
};
CityPicker.DEFAULTS = {
simple: false,
responsive: true,
render: 'text',//填充为代码还是文本可选code或text
placeholder: '请选择省/市/区',
level: 'district',
province: '',
city: '',
district: ''
};
CityPicker.setDefaults = function (options) {
$.extend(CityPicker.DEFAULTS, options);
};
// Save the other citypicker
CityPicker.other = $.fn.citypicker;
// Register as jQuery plugin
$.fn.citypicker = function (option) {
var args = [].slice.call(arguments, 1);
return this.each(function () {
var $this = $(this);
var data = $this.data(NAMESPACE);
var options;
var fn;
if (!data) {
if (/destroy/.test(option)) {
return;
}
options = $.extend({}, $this.data(), $.isPlainObject(option) && option);
$this.data(NAMESPACE, (data = new CityPicker(this, options)));
}
if (typeof option === 'string' && $.isFunction(fn = data[option])) {
fn.apply(data, args);
}
});
};
$.fn.citypicker.Constructor = CityPicker;
$.fn.citypicker.setDefaults = CityPicker.setDefaults;
// No conflict
$.fn.citypicker.noConflict = function () {
$.fn.citypicker = CityPicker.other;
return this;
};
// 根据code查询地址
$.fn.citypicker.getAddressbyCodeId = function(code_id){
var city = ChineseDistricts;
var code = city[''+code_id];
var addr = '';
var province = '';
var province_code = '';
var city_str = '';
var county = '';
if(code_id.substring(0,2)==='44'){
province = '广东省';
province_code = '440000';
}else{
$.each(city['86'], function(i,item) {
$.each(item, function(j,index) {
if(index['code']===code_id.substring(0,2)+'0000'){
province = index['address'];
province_code = index['code'];
return false;
}
});
});
}
if (code_id.substring(2, 4).indexOf('00') == -1) {
if (code_id.length > 6) {
var city_code = code_id.substring(0, 6);
if (typeof city[province_code][city_code] !== 'undefined') {
city_str = city[province_code][city_code];
}
}
if (!city_str) {
var city_code = code_id.substring(0, 4) + '00';
if (typeof city[province_code][city_code] === 'undefined') {
city_code = code_id.substring(0, 3) + '100';
}
if (typeof city[province_code][city_code] !== 'undefined') {
city_str = city[province_code][city_code];
}
}
}
if (code === undefined) {
addr = city[city_code][code_id];
return addr = province + '/' + city_str + '/' + addr;
} else {
if (code_id.substring(2, 4).indexOf('00') != -1) {
//440000
return addr = province;
}else{
//440100
var city_city = city[code_id.substring(0,2)+'0000'];
return addr = province +'/'+city_city[code_id];
}
}
}
$(function () {
$('[data-toggle="city-picker"]').citypicker();
});
});

View File

@@ -0,0 +1,162 @@
.city-picker-input {
opacity: 0 !important;
top: -9999px;
left: -9999px;
position: absolute;
}
.city-picker-span {
position: relative;
display: block;
outline: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
border-bottom: 1px solid #ccc;
background-color: #fff;
color: #ccc;
cursor: pointer;
}
.city-picker-span > .placeholder {
color: #aaa;
}
.city-picker-span > .arrow {
position: absolute;
top: 50%;
right: 8px;
width: 10px;
margin-top: -3px;
height: 5px;
background: url(../images/drop-arrow.png) -10px -25px no-repeat;
}
.city-picker-span.focus,
.city-picker-span.open {
border-bottom-color: #46A4FF;
}
.city-picker-span.open > .arrow {
background-position: -10px -10px;
}
.city-picker-span > .title > span {
color: #333;
padding: 5px;
border-radius: 3px;
}
.city-picker-span > .title > span:hover {
background-color: #f1f8ff;
}
.city-picker-dropdown {
position: absolute;
width: 315px;
left: -9999px;
top: -9999px;
outline: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
z-index: 999999;
display: none;
min-width: 330px;
margin-bottom: 20px;
}
.city-select-wrap {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}
.city-select-tab {
border-bottom: 1px solid #ccc;
background: #f0f0f0;
font-size: 13px;
}
.city-select-tab > a {
display: inline-block;
padding: 8px 22px;
border-left: 1px solid #ccc;
border-bottom: 1px solid transparent;
color: #4D4D4D;
text-align: center;
outline: 0;
text-decoration: none;
cursor: pointer;
font-size: 14px;
margin-bottom: -1px;
}
.city-select-tab > a.active {
background: #fff;
border-bottom: 1px solid #fff;
color: #46A4FF;
}
.city-select-tab > a:first-child {
border-left: none;
}
.city-select-tab > a:last-child.active {
border-right: 1px solid #ccc;
}
.city-select-content {
width: 100%;
min-height: 10px;
background-color: #fff;
padding: 10px 15px;
box-sizing: border-box;
}
.city-select {
font-size: 13px;
}
.city-select dl {
line-height: 2;
clear: both;
padding: 3px 0;
margin: 0;
}
.city-select dt {
position: absolute;
width: 2.5em;
font-weight: 500;
text-align: right;
line-height: 2;
}
.city-select dd {
margin-left: 0;
line-height: 2;
}
.city-select.province dd {
margin-left: 3em;
}
.city-select a {
display: inline-block;
padding: 0 10px;
outline: 0;
text-decoration: none;
white-space: nowrap;
margin-right: 2px;
text-decoration: none;
color: #333;
cursor: pointer;
}
.city-select a:hover,
.city-select a:focus {
background-color: #f1f8ff;
border-radius: 2px;
color: #46A4FF;
}
.city-select a.active {
background-color: #46A4FF;
color: #fff;
border-radius: 2px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B