...
|
...
|
@@ -33,34 +33,40 @@ var settings = { |
|
|
};
|
|
|
|
|
|
// 显示或隐藏下拉区域
|
|
|
function toggleDistItem() {
|
|
|
function toggleDistItem(event) {
|
|
|
var $this = $(this),
|
|
|
resetHeight = $this.css('height'),
|
|
|
openHeight = (parseInt(resetHeight.match(/\d*/)[0], 10) + 5) + 'px',
|
|
|
openAndResetHeight = (parseInt(resetHeight.match(/\d*/)[0], 10) - 5) + 'px';
|
|
|
|
|
|
var e = event || window.event;
|
|
|
|
|
|
e.preventDefault && e.preventDefault();
|
|
|
e.stopPropagation && e.stopPropagation();
|
|
|
e.cancelBubble = true;
|
|
|
|
|
|
if ($this.hasClass('closed')) {
|
|
|
// 如果有其他开着,先关掉
|
|
|
$('.items-indicator .open').each(function() {
|
|
|
$(this).find('.iconfont').replaceWith('<span class="iconfont up"></span>')
|
|
|
.end()
|
|
|
.removeClass('open')
|
|
|
.addClass('closed')
|
|
|
.css({
|
|
|
height: resetHeight
|
|
|
}).next().hide();
|
|
|
.end()
|
|
|
.removeClass('open')
|
|
|
.addClass('closed')
|
|
|
.css({
|
|
|
height: resetHeight
|
|
|
}).next().hide();
|
|
|
});
|
|
|
|
|
|
// open
|
|
|
$this.find('.iconfont').replaceWith('<span class="iconfont up"></span>')
|
|
|
.end()
|
|
|
.removeClass('closed')
|
|
|
.addClass('open')
|
|
|
.css({
|
|
|
height: openHeight
|
|
|
})
|
|
|
.next()
|
|
|
.show();
|
|
|
.end()
|
|
|
.removeClass('closed')
|
|
|
.addClass('open')
|
|
|
.css({
|
|
|
height: openHeight
|
|
|
})
|
|
|
.next()
|
|
|
.show();
|
|
|
|
|
|
// 有视觉差
|
|
|
// setTimeout(function(){
|
...
|
...
|
@@ -69,12 +75,12 @@ function toggleDistItem() { |
|
|
} else {
|
|
|
// close
|
|
|
$this.find('.iconfont').replaceWith('<span class="iconfont up"></span>')
|
|
|
.end()
|
|
|
.removeClass('open')
|
|
|
.addClass('closed')
|
|
|
.css({
|
|
|
height: openAndResetHeight
|
|
|
}).next().hide();
|
|
|
.end()
|
|
|
.removeClass('open')
|
|
|
.addClass('closed')
|
|
|
.css({
|
|
|
height: openAndResetHeight
|
|
|
}).next().hide();
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -92,8 +98,8 @@ function resetNextLevel(level, config) { |
|
|
.addClass('empty')
|
|
|
.text(config.defaultDes)
|
|
|
.prev().find('.indicator-name')
|
|
|
.text(config.indicators[config.levels - level - 1])
|
|
|
.next().val('');
|
|
|
.text(config.indicators[config.levels - level - 1])
|
|
|
.next().val('');
|
|
|
}
|
|
|
|
|
|
// 选择特定省份,城市,或区县
|
...
|
...
|
@@ -117,9 +123,9 @@ function selectDistItem(options) { |
|
|
currPanel.find('span.checked').removeClass('checked').prev().hide();
|
|
|
distElement.addClass('checked').prev().show();
|
|
|
distItem.find('.indicator-name')
|
|
|
.html(distElement.text())
|
|
|
.next()
|
|
|
.val(currAreaId);
|
|
|
.html(distElement.text())
|
|
|
.next()
|
|
|
.val(currAreaId);
|
|
|
|
|
|
// 填充下一级
|
|
|
if (level < 0) {
|
...
|
...
|
@@ -277,7 +283,7 @@ function setAddress(evt, config, level, areaId) { |
|
|
// 设置label文本 和 设置areaId
|
|
|
currPanel = $('#level_' + level + '_panel');
|
|
|
currPanel.prev().find('.indicator-name').text(label)
|
|
|
.next().val(distVal);
|
|
|
.next().val(distVal);
|
|
|
|
|
|
// 侦听选择
|
|
|
currPanel.off('click', '.dist-name').on('click', '.dist-name', function() {
|
...
|
...
|
@@ -399,6 +405,18 @@ CascadingAddress.prototype.init = function() { |
|
|
|
|
|
// 初始化完成,提供回调执行
|
|
|
el.trigger('ca.onCreated');
|
|
|
|
|
|
$(document).click(function() {
|
|
|
$('.items-indicator .open').each(function() {
|
|
|
$(this).find('.iconfont').replaceWith('<span class="iconfont up"></span>')
|
|
|
.end()
|
|
|
.removeClass('open')
|
|
|
.addClass('closed')
|
|
|
.css({
|
|
|
height: (parseInt($(this).css('height').match(/\d*/)[0], 10) - 5) + 'px'
|
|
|
}).next().hide();
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取地址文本
|
...
|
...
|
@@ -474,9 +492,9 @@ CascadingAddress.prototype.reset = function() { |
|
|
|
|
|
items.each(function(index, item) {
|
|
|
$(item).find('span.indicator-name').text(labels[index])
|
|
|
.next().val('')
|
|
|
.parent().next()
|
|
|
.find('span.checked').removeClass('checked').prev().hide();
|
|
|
.next().val('')
|
|
|
.parent().next()
|
|
|
.find('span.checked').removeClass('checked').prev().hide();
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|