PageSourceSearch

https://www.hopichamber.com/public/static/portal/js/distpicker.js

js hopichamber.com collected 2026-10-06 13:49:21 UTC 4,219 bytes, 27 lines download raw bytes

1/*!
2* Distpicker v1.0.4
3* http://github.com/fengyuanchen/distpicker
4*
5* Copyright (c) 2014-2016 Fengyuan Chen
6* Released under the MIT license
7*
8* Date: 2016-06-01T15:05:52.606Z
9*/(function(factory){if(typeof define==='function'&&define.amd){define(['jquery','ChineseDistricts'],factory);}else if(typeof exports==='object'){factory(require('jquery'),require('ChineseDistricts'));}else{factory(jQuery,ChineseDistricts);}})(function($,ChineseDistricts){'use strict';if(typeof ChineseDistricts==='undefined'){throw new Error('The file "distpicker.data.js" must be included first!');}
10var NAMESPACE='distpicker';var EVENT_CHANGE='change.'+NAMESPACE;var PROVINCE='province';var CIRY='city';var DISTRICT='district';function Distpicker(element,options){this.$element=$(element);this.options=$.extend({},Distpicker.DEFAULTS,$.isPlainObject(options)&&options);this.placeholders=$.extend({},Distpicker.DEFAULTS);this.active=false;this.init();}
11Distpicker.prototype={constructor:Distpicker,init:function(){var options=this.options;var $select=this.$element.find('select');var length=$select.length;var data={};$select.each(function(){$.extend(data,$(this).data());});$.each([PROVINCE,CIRY,DISTRICT],$.proxy(function(i,type){if(data[type]){options[type]=data[type];this['$'+type]=$select.filter('[data-'+type+']');}else{this['$'+type]=length>i?$select.eq(i):null;}},this));this.bind();this.reset();this.active=true;},bind:function(){if(this.$province){this.$province.on(EVENT_CHANGE,(this._changeProvince=$.proxy(function(){this.output(CIRY);this.output(DISTRICT);},this)));}
12if(this.$city){this.$city.on(EVENT_CHANGE,(this._changeCity=$.proxy(function(){this.output(DISTRICT);},this)));}},unbind:function(){if(this.$province){this.$province.off(EVENT_CHANGE,this._changeProvince);}
13if(this.$city){this.$city.off(EVENT_CHANGE,this._changeCity);}},output:function(type){var options=this.options;var placeholders=this.placeholders;var $select=this['$'+type];var districts={};var data=[];var code;var matched;var value;if(!$select||!$select.length){return;}
14value=options[type];code=(type===PROVINCE?86:type===CIRY?this.$province&&this.$province.find(':selected').data('code'):type===DISTRICT?this.$city&&this.$city.find(':selected').data('code'):code);districts=$.isNumeric(code)?ChineseDistricts[code]:null;if($.isPlainObject(districts)){$.each(districts,function(code,address){var selected=address===value;if(selected){matched=true;}
15data.push({code:code,address:address,selected:selected});});}
16if(!matched){if(data.length&&(options.autoSelect||options.autoselect)){data[0].selected=true;}
17if(!this.active&&value){placeholders[type]=value;}}
18if(options.placeholder){data.unshift({code:'',address:placeholders[type],selected:false});}
19$select.html(this.getList(data));},getList:function(data){var list=[];$.each(data,function(i,n){list.push('<option'+
20' value="'+(n.address&&n.code?n.address:'')+'"'+
21' data-code="'+(n.code||'')+'"'+
22(n.selected?' selected':'')+
23'>'+
24(n.address||'')+
25'</option>');});return list.join('');},reset:function(deep){if(!deep){this.output(PROVINCE);this.output(CIRY);this.output(DISTRICT);}else if(this.$province){this.$province.find(':first').prop('selected',true).trigger(EVENT_CHANGE);}},destroy:function(){this.unbind();this.$element.removeData(NAMESPACE);}};Distpicker.DEFAULTS={autoSelect:true,placeholder:true,province:'—— 省 ——',city:'—— 市 ——',district:'—— 区 ——'};Distpicker.setDefaults=function(options){$.extend(Distpicker.DEFAULTS,options);};Distpicker.other=$.fn.distpicker;$.fn.distpicker=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;}
26options=$.extend({},$this.data(),$.isPlainObject(option)&&option);$this.data(NAMESPACE,(data=new Distpicker(this,options)));}
27if(typeof option==='string'&&$.isFunction(fn=data[option])){fn.apply(data,args);}});};$.fn.distpicker.Constructor=Distpicker;$.fn.distpicker.setDefaults=Distpicker.setDefaults;$.fn.distpicker.noConflict=function(){$.fn.distpicker=Distpicker.other;return this;};$(function(){$('[data-toggle="distpicker"]').distpicker();});});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.