/* 2020-9-22 15:23:27 | 版权所有 军懋国兴 */ function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t){"function"==typeof define&&define.amd?define(["jquery","ChineseDistricts"],t):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?t(require("jquery"),require("ChineseDistricts")):t(jQuery,ChineseDistricts)}(function(a,h){"use strict";if(void 0===h)throw new Error('The file "city-picker.data.js" must be included first!');var o="citypicker",s="change."+o,l="province",p="city",u="district";function d(t,e){this.$element=a(t),this.$dropdown=null,this.options=a.extend({},d.DEFAULTS,a.isPlainObject(e)&&e),this.active=!1,this.dems=[],this.needBlur=!1,this.init()}d.prototype={constructor:d,init:function(){this.codeRender(),this.defineDems(),this.render(),this.bind(),this.active=!0},codeRender:function(){var t=this.$element.attr("code");void 0===t||""===t||isNaN(Number(t))||this.$element.val(a.fn.citypicker.getAddressbyCodeId(t))},render:function(){var t=this.getPosition(),e=this.$element.attr("placeholder")||this.options.placeholder,i=''+(e?''+e+"":"")+'
',s='
省份'+(this.includeDem("city")?'城市':"")+(this.includeDem("district")?'区县':"")+'
'+(this.includeDem("city")?'
':"")+(this.includeDem("district")?'
':"")+"
";this.$element.addClass("city-picker-input"),this.$textspan=a(i).insertAfter(this.$element),this.$dropdown=a(s).insertAfter(this.$textspan);var n=this.$dropdown.find(".city-select");a.each(this.dems,a.proxy(function(t,e){this["$"+e]=n.filter("."+e)},this)),this.refresh()},refresh:function(i){this.$dropdown.find(".city-select").data("item",null);var s=(s=this.$element.val()||"").split("/");a.each(this.dems,a.proxy(function(t,e){s[t]&&t").appendTo(a("body"))).css({position:"absolute !important",visibility:"hidden !important",display:"block !important"}),s={width:(i=t.clone().appendTo(e)).outerWidth(),height:i.outerHeight()},e.remove()),s},getWidthStyle:function(t,e){return this.options.responsive&&!a.isNumeric(t)?"width:"+t+";":"width:"+(e?Math.max(320,t):t)+"px;"},bind:function(){var c=this;a(document).on("click",this._mouteclick=function(t){var e,i,s,n=a(t.target);n.is(".city-picker-span")?i=n:n.is(".city-picker-span *")&&(i=n.parents(".city-picker-span")),n.is(".city-picker-input")&&(s=n),n.is(".city-picker-dropdown")?e=n:n.is(".city-picker-dropdown *")&&(e=n.parents(".city-picker-dropdown")),(!s&&!i&&!e||i&&i.get(0)!==c.$textspan.get(0)||s&&s.get(0)!==c.$element.get(0)||e&&e.get(0)!==c.$dropdown.get(0))&&c.close(!0)}),this.$element.on("change",this._changeElement=a.proxy(function(){this.close(!0),this.refresh(!0)},this)).on("focus",this._focusElement=a.proxy(function(){this.needBlur=!0,this.open()},this)).on("blur",this._blurElement=a.proxy(function(){this.needBlur&&(this.needBlur=!1,this.close(!0))},this)),this.$textspan.on("click",function(t){var e,i=a(t.target);c.needBlur=!1,i.is(".select-item")?(e=i.data("count"),c.open(e)):c.$dropdown.is(":visible")?c.close():c.open()}).on("mousedown",function(){c.needBlur=!1}),this.$dropdown.on("click",".city-select a",function(){var t=a(this).parents(".city-select"),e=t.find("a.active"),i=0===t.next().length;e.removeClass("active"),a(this).addClass("active"),e.data("code")!==a(this).data("code")&&(t.data("item",{address:a(this).attr("title"),code:a(this).data("code")}),a(this).trigger(s),c.feedText(),c.feedVal(!0),i&&c.close())}).on("click",".city-select-tab a",function(){var t;a(this).hasClass("active")||(t=a(this).data("count"),c.tab(t))}).on("mousedown",function(){c.needBlur=!1}),this.$province&&this.$province.on(s,this._changeProvince=a.proxy(function(){this.output(p),this.output(u),this.tab(p)},this)),this.$city&&this.$city.on(s,this._changeCity=a.proxy(function(){this.output(u),this.tab(u)},this))},open:function(t){t=t||l,this.$dropdown.show(),this.$textspan.addClass("open").addClass("focus"),this.tab(t)},close:function(t){this.$dropdown.hide(),this.$textspan.removeClass("open"),t&&this.$textspan.removeClass("focus")},unbind:function(){a(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"),this.$province&&this.$province.off(s,this._changeProvince),this.$city&&this.$city.off(s,this._changeCity)},getText:function(){var i="";return this.$dropdown.find(".city-select").each(function(){var t=a(this).data("item"),e=a(this).data("count");t&&(i+=(a(this).hasClass("province")?"":"/")+''+t.address+"")}),i},getPlaceHolder:function(){return this.$element.attr("placeholder")||this.options.placeholder},feedText:function(){this.getText()?(this.$textspan.find(">.placeholder").hide(),this.$textspan.find(">.title").html(this.getText()).show()):(this.$textspan.find(">.placeholder").text(this.getPlaceHolder()).show(),this.$textspan.find(">.title").html("").hide())},getCode:function(){var i={},s=[];return this.$textspan.find(".select-item").each(function(){var t=a(this).data("code"),e=a(this).data("count");i[e]=t,s.push(t)}),s[s.length-1]},getVal:function(){var e="";return this.$dropdown.find(".city-select").each(function(){var t=a(this).data("item");t&&(e+=(a(this).hasClass("province")?"":"/")+t.address)}),e},feedVal:function(t){this.$element.val(this.getVal()),t&&this.$element.trigger("cp:updated")},output:function(n){var t,e,i,c,s=this.options,o=this["$"+n],d=n===l?{}:[],r=null;o&&o.length&&(t=o.data("item"),c=(t?t.address:null)||s[n],i=n===l?86:n===p?this.$province&&this.$province.find(".active").data("code"):n===u?this.$city&&this.$city.find(".active").data("code"):i,e=a.isNumeric(i)?h[i]:null,a.isPlainObject(e)&&a.each(e,function(t,e){var i;if(n===l){i=[];for(var s=0;s'),i.push("
"+t+"
"),a.each(e,function(t,e){i.push(''+(n?s.simplize(e.address,l):e.address)+"")}),i.push("
")}),i.join("")},getList:function(t,i){var s=[],n=this,c=this.options.simple;return s.push('
'),a.each(t,function(t,e){s.push(''+(c?n.simplize(e.address,i):e.address)+"")}),s.push("
"),s.join("")},simplize:function(t,e){return t=t||"",e===l?t.replace(/[省,市,自治区,壮族,回族,维吾尔]/g,""):e===p?t.replace(/[市,地区,回族,蒙古,苗族,白族,傣族,景颇族,藏族,彝族,壮族,傈僳族,布依族,侗族]/g,"").replace("哈萨克","").replace("自治州","").replace(/自治县/,""):e===u?2 a"),s=this["$"+t],n=this.$dropdown.find('.city-select-tab > a[data-count="'+t+'"]');s&&(e.hide(),s.show(),i.removeClass("active"),n.addClass("active"))},reset:function(){this.$element.val(null).trigger("change")},destroy:function(){this.unbind(),this.$element.removeData(o).removeClass("city-picker-input"),this.$textspan.remove(),this.$dropdown.remove()}},d.DEFAULTS={simple:!1,responsive:!1,placeholder:"请选择省/市/区",level:"district",province:"",city:"",district:""},d.setDefaults=function(t){a.extend(d.DEFAULTS,t)},d.other=a.fn.citypicker,a.fn.citypicker=function(n){var c=[].slice.call(arguments,1);return this.each(function(){var t,e,i=a(this),s=i.data(o);if(!s){if(/destroy/.test(n))return;t=a.extend({},i.data(),a.isPlainObject(n)&&n),i.data(o,s=new d(this,t))}"string"==typeof n&&a.isFunction(e=s[n])&&e.apply(s,c)})},a.fn.citypicker.Constructor=d,a.fn.citypicker.setDefaults=d.setDefaults,a.fn.citypicker.noConflict=function(){return a.fn.citypicker=d.other,this},a.fn.citypicker.getAddressbyCodeId=function(i){var t,e=h,s=e[""+i],n="",c="",o="",d="";if("44"===i.substring(0,2)?(c="广东省",o="440000"):a.each(e[86],function(t,e){a.each(e,function(t,e){if(e.code===i.substring(0,2)+"0000")return c=e.address,o=e.code,!1})}),-1==i.substring(2,4).indexOf("00")&&(t=i.substring(0,4)+"00",d=e[o][t]),void 0===s){if(null==e[s=i.substring(0,4)+"00"])return;return n=e[s][i],c+"/"+d+"/"+n}if(-1!=i.substring(2,4).indexOf("00"))return c;var r=e[i.substring(0,2)+"0000"];return c+"/"+r[i]},a(function(){a('[data-toggle="city-picker"]').citypicker()})});