/,j={LEGAL:[2,2,5,1],INDIVIDUAL:[2,2,6,2]};d.NAME={urlSuffix:"fio",matchers:[n.matchByNormalizedQuery,n.matchByWords],fieldNames:{surname:"фамилия",name:"имя",patronymic:"отчество"},alwaysContinueSelecting:!0,isDataComplete:function(c){var d,e=this,f=e.options.params,g=c.data;return a.isFunction(f)&&(f=f.call(e.element,c.value)),f&&f.parts?d=a.map(f.parts,function(a){return a.toLowerCase()}):(d=["surname","name"],b(c,"surname")&&d.push("patronymic")),m.fieldsNotEmpty(g,d)},composeValue:function(a){return m.compact([a.surname,a.name,a.patronymic]).join(" ")}},d.ADDRESS={urlSuffix:"address",matchers:[a.proxy(n.matchByNormalizedQuery,{stopwords:f}),a.proxy(n.matchByWordsAddress,{stopwords:f})],dataComponents:h,dataComponentsById:m.indexBy(h,"id","index"),unformattableTokens:f,enrichmentEnabled:!0,geoEnabled:!0,isDataComplete:function(b){var c=[this.bounds.to||"flat"],d=b.data;return!a.isPlainObject(d)||m.fieldsNotEmpty(d,c)},composeValue:function(b,c){return m.compact([b.region_with_type||m.compact([b.region,b.region_type]).join(" "),b.area_with_type||m.compact([b.area_type,b.area]).join(" "),b.city_with_type||m.compact([b.city_type,b.city]).join(" "),a.inArray("city_district",c)>=0&&(b.city_district_with_type||m.compact([b.city_district_type,b.city_district]).join(" ")),b.settlement_with_type||m.compact([b.settlement_type,b.settlement]).join(" "),b.street_with_type||m.compact([b.street_type,b.street]).join(" "),m.compact([b.house_type,b.house,b.block_type,b.block]).join(" "),m.compact([b.flat_type,b.flat]).join(" "),b.postal_box&&"а/я "+b.postal_box]).join(", ")},formatResult:function(){var b=[],c=!1;return a.each(h,function(){c&&b.push(this.id),"city_district"===this.id&&(c=!0)}),function(c,d,e,f){var g=this,h=e.data&&e.data.city_district_with_type;return c=g.highlightMatches(c,d,e,f),c=g.wrapFormattedValue(c,e),h&&(!g.bounds.own.length||g.bounds.own.indexOf("street")>=0)&&!a.isEmptyObject(g.copyDataComponents(e.data,b))&&(c+=''+g.highlightMatches(h,d,e)+"
"),c}}()},d.PARTY={urlSuffix:"party",matchers:[a.proxy(n.matchByFields,{fieldsStopwords:{value:null,"data.address.value":f,"data.inn":null,"data.ogrn":null}})],dataComponents:h,geoEnabled:!0,formatResult:function(a,b,d,h){var i=this,j=i.type.formatResultInn.call(i,d,b),k=i.highlightMatches(m.getDeepValue(d.data,"ogrn"),b,d),l=c(j,k),n=i.highlightMatches(m.getDeepValue(d.data,"management.name"),b,d),o=m.getDeepValue(d.data,"address.value")||"";return i.isMobile&&((h||(h={})).maxLength=50),a=e.call(i,a,m.getDeepValue(d.data,"name.latin"),b,d,h),a=i.wrapFormattedValue(a,d),o&&(o=o.replace(/^(\d{6}?\s+|Россия,\s+)/i,""),o=i.isMobile?o.replace(new RegExp("^([^"+g+"]+["+g+"]+[^"+g+"]+).*"),"$1"):i.highlightMatches(o,b,d,{unformattableTokens:f})),(l||o||n)&&(a+=''+(l||"")+""+(c(o,n)||"")+"
"),a},formatResultInn:function(b,c){var d,e,f=this,g=b.data&&b.data.inn,h=j[b.data&&b.data.type],i=/\d/;return g?(e=f.highlightMatches(g,c,b),h&&(e=e.split(""),d=a.map(h,function(a){for(var b,c="";a&&(b=e.shift());)c+=b,i.test(b)&&a--;return c}),e=d.join('')+e.join("")),e):void 0}},d.EMAIL={urlSuffix:"email",matchers:[n.matchByNormalizedQuery],isQueryRequestable:function(a){return this.options.suggest_local||a.indexOf("@")>=0}},d.BANK={urlSuffix:"bank",matchers:[a.proxy(n.matchByFields,{fieldsStopwords:{value:null,"data.bic":null,"data.swift":null}})],formatResult:function(a,b,c,d){var e=this,h=e.highlightMatches(m.getDeepValue(c.data,"bic"),b,c),i=m.getDeepValue(c.data,"address.value")||"";return a=e.highlightMatches(a,b,c,d),a=e.wrapFormattedValue(a,c),i&&(i=i.replace(/^\d{6}( РОССИЯ)?, /i,""),i=e.isMobile?i.replace(new RegExp("^([^"+g+"]+["+g+"]+[^"+g+"]+).*"),"$1"):e.highlightMatches(i,b,c,{unformattableTokens:f})),(h||i)&&(a+=''+h+""+i+"
"),a},formatSelected:function(a){return m.getDeepValue(a,"data.name.payment")}},a.extend(k,{suggest_local:!0})}();var o={suggest:{defaultParams:{type:m.getDefaultType(),dataType:"json",contentType:m.getDefaultContentType()},addTypeInUrl:!0},detectAddressByIp:{defaultParams:{type:"GET",dataType:"json"},addTypeInUrl:!1},status:{defaultParams:{type:"GET",dataType:"json"},addTypeInUrl:!0},findById:{defaultParams:{type:m.getDefaultType(),dataType:"json",contentType:m.getDefaultContentType()},addTypeInUrl:!0}},p={suggest:{method:"suggest",userSelect:!0,updateValue:!0,enrichmentEnabled:!0},findById:{method:"findById",userSelect:!1,updateValue:!1,enrichmentEnabled:!1}};b.utils=m,b.defaultOptions=k,b.version="16.8.9",a.Suggestions=b,b.prototype={initialize:function(){var a=this;a.uniqueId=m.uniqueId("i"),a.createWrapper(),a.notify("initialize"),a.bindWindowEvents(),a.setOptions(),a.fixPosition()},deferInitialization:function(){var a,b=this,c="mouseover focus keydown",d=function(){b.initializer.resolve(),b.enable()};b.initializer.always(function(){b.el.off(c,d),clearInterval(a)}),b.disabled=!0,b.el.on(c,d),a=setInterval(function(){b.el.is(":visible")&&d()},b.options.initializeInterval)},isInitialized:function(){return"resolved"===this.initializer.state()},dispose:function(){var a=this;a.initializer.reject(),a.notify("dispose"),a.el.removeData(f).removeClass("suggestions-input"),a.unbindWindowEvents(),a.removeWrapper(),a.el.trigger("suggestions-dispose")},notify:function(b){var c=this,d=m.slice(arguments,1);return a.map(l.get(b),function(a){return a.apply(c,d)})},createWrapper:function(){var b=this;b.$wrapper=a(''),b.el.after(b.$wrapper),b.$wrapper.on("mousedown"+e,a.proxy(b.onMousedown,b))},removeWrapper:function(){var b=this;b.$wrapper&&b.$wrapper.remove(),a(b.options.$helpers).off(e)},onMousedown:function(b){var c=this;b.preventDefault(),c.cancelBlur=!0,m.delay(function(){delete c.cancelBlur}),0==a(b.target).closest(".ui-menu-item").length&&m.delay(function(){a(document).one("mousedown",function(b){var d=c.el.add(c.$wrapper).add(c.options.$helpers);c.options.floating&&(d=d.add(c.$container)),d=d.filter(function(){return this===b.target||a.contains(this,b.target)}),d.length||c.hide()})})},bindWindowEvents:function(){var b=this,c=a.proxy(b.fixPosition,b);b.$viewport.on("resize"+e+b.uniqueId,c).on("scroll"+e+b.uniqueId,c)},unbindWindowEvents:function(){this.$viewport.off("resize"+e+this.uniqueId).off("scroll"+e+this.uniqueId)},scrollToTop:function(){var b=this,c=b.options.scrollOnFocus;c===!0&&(c=b.el),c instanceof a&&c.length>0&&a("body,html").animate({scrollTop:c.offset().top},"fast")},setOptions:function(b){var c=this;a.extend(c.options,b),a.each({type:d,requestMode:p},function(b,d){if(c[b]=d[c.options[b]],!c[b])throw c.disable(),"`"+b+"` option is incorrect! Must be one of: "+a.map(d,function(a,b){return'"'+b+'"'}).join(", ")}),a(c.options.$helpers).off(e).on("mousedown"+e,a.proxy(c.onMousedown,c)),c.isInitialized()&&c.notify("setOptions")},fixPosition:function(b){var c,d,e=this,f={};e.isMobile=e.$viewport.width()<=e.options.mobileWidth,e.isInitialized()&&(!b||"scroll"!=b.type||e.options.floating||e.isMobile)&&(e.$container.appendTo(e.options.floating?e.$body:e.$wrapper),e.notify("resetPosition"),e.el.css("paddingLeft",""),e.el.css("paddingRight",""),f.paddingLeft=parseFloat(e.el.css("paddingLeft")),f.paddingRight=parseFloat(e.el.css("paddingRight")),a.extend(f,e.el.offset()),f.borderTop="none"==e.el.css("border-top-style")?0:parseFloat(e.el.css("border-top-width")),f.borderLeft="none"==e.el.css("border-left-style")?0:parseFloat(e.el.css("border-left-width")),f.innerHeight=e.el.innerHeight(),f.innerWidth=e.el.innerWidth(),f.outerHeight=e.el.outerHeight(),f.componentsLeft=0,f.componentsRight=0,c=e.$wrapper.offset(),d={top:f.top-c.top,left:f.left-c.left},e.notify("fixPosition",d,f),f.componentsLeft>f.paddingLeft&&e.el.css("paddingLeft",f.componentsLeft+"px"),f.componentsRight>f.paddingRight&&e.el.css("paddingRight",f.componentsRight+"px"))},clearCache:function(){this.cachedResponse={},this.enrichmentCache={},this.badQueries=[]},clear:function(){var a=this;a.isInitialized()&&(a.clearCache(),a.currentValue="",a.selection=null,a.hide(),a.suggestions=[],a.el.val(""),a.el.trigger("suggestions-clear"),a.notify("clear"))},disable:function(){var a=this;a.disabled=!0,a.abortRequest(),a.visible&&a.hide()},enable:function(){this.disabled=!1},isUnavailable:function(){return this.disabled},update:function(){var a=this,b=a.el.val();a.isInitialized()&&(a.currentValue=b,a.isQueryRequestable(b)?a.updateSuggestions(b):a.hide())},setSuggestion:function(b){var c,d,e=this;a.isPlainObject(b)&&a.isPlainObject(b.data)&&(b=a.extend(!0,{},b),e.bounds.own.length&&(e.checkValueBounds(b),c=e.copyDataComponents(b.data,e.bounds.all),b.data.kladr_id&&(c.kladr_id=e.getBoundedKladrId(b.data.kladr_id,e.bounds.all)),b.data=c),e.selection=b,e.suggestions=[b],d=e.getSuggestionValue(b)||"",e.currentValue=d,e.el.val(d),e.abortRequest(),e.el.trigger("suggestions-set"))},fixData:function(){var b=this,c=b.extendedCurrentValue(),d=b.el.val(),e=a.Deferred();e.done(function(a){b.selectSuggestion(a,0,d,{hasBeenEnriched:!0}),b.el.trigger("suggestions-fixdata",a)}).fail(function(){b.selection=null,b.currentValue="",b.el.val(b.currentValue),b.el.trigger("suggestions-fixdata")}),b.isQueryRequestable(c)?(b.currentValue=c,b.getSuggestions(c,{count:1,from_bound:null,to_bound:null}).done(function(a){var b=a[0];b?e.resolve(b):e.reject()}).fail(function(){e.reject()})):e.reject()},extendedCurrentValue:function(){var b=this,c=b.getParentInstance(),d=c&&c.extendedCurrentValue(),e=a.trim(b.el.val());return m.compact([d,e]).join(" ")},getAjaxParams:function(c,d){var e=this,f=a.trim(e.options.token),g=a.trim(e.options.partner),h=e.options.serviceUrl,i=o[c],j=a.extend({timeout:e.options.timeout},i.defaultParams),k={};return/\/$/.test(h)||(h+="/"),h+=c,i.addTypeInUrl&&(h+="/"+e.type.urlSuffix),h=m.fixURLProtocol(h),a.support.cors?(f&&(k.Authorization="Token "+f),g&&(k["X-Partner"]=g),k["X-Version"]=b.version,j.headers||(j.headers={}),a.extend(j.headers,e.options.headers,k)):(f&&(k.token=f),g&&(k.partner=g),k.version=b.version,h=m.addUrlParams(h,k)),j.url=h,a.extend(j,d)},isQueryRequestable:function(a){var b,c=this;return b=a.length>=c.options.minChars,b&&c.type.isQueryRequestable&&(b=c.type.isQueryRequestable.call(c,a)),b},constructRequestParams:function(b,c){var d=this,e=d.options,f=a.isFunction(e.params)?e.params.call(d.element,b):a.extend({},e.params);return d.type.constructRequestParams&&a.extend(f,d.type.constructRequestParams.call(d)),a.each(d.notify("requestParams"),function(b,c){a.extend(f,c)}),f[e.paramName]=b,a.isNumeric(e.count)&&e.count>0&&(f.count=e.count),a.extend(f,c)},updateSuggestions:function(a){var b=this;b.fetchPhase=b.getSuggestions(a).done(function(c){b.assignSuggestions(c,a)})},getSuggestions:function(b,c,d){var e,f=this,g=f.options,h=d&&d.noCallbacks,i=d&&d.useEnrichmentCache,j=f.constructRequestParams(b,c),k=a.param(j||{}),l=a.Deferred();return e=f.cachedResponse[k],e&&a.isArray(e.suggestions)?l.resolve(e.suggestions):f.isBadQuery(b)?l.reject():h||g.onSearchStart.call(f.element,j)!==!1?f.doGetSuggestions(j).done(function(a){f.processResponse(a)&&b==f.currentValue?(g.noCache||(i?f.enrichmentCache[b]=a.suggestions[0]:(f.enrichResponse(a,b),f.cachedResponse[k]=a,g.preventBadQueries&&0===a.suggestions.length&&f.badQueries.push(b))),l.resolve(a.suggestions)):l.reject(),h||g.onSearchComplete.call(f.element,b,a.suggestions)}).fail(function(a,c,d){l.reject(),h||"abort"===c||g.onSearchError.call(f.element,b,a,c,d)}):l.reject(),l},doGetSuggestions:function(b){var c=this,d=a.ajax(c.getAjaxParams(c.requestMode.method,{data:m.serialize(b)}));return c.abortRequest(),c.currentRequest=d,c.notify("request"),d.always(function(){c.currentRequest=null,c.notify("request")}),d},isBadQuery:function(b){if(!this.options.preventBadQueries)return!1;var c=!1;return a.each(this.badQueries,function(a,d){return!(c=0===b.indexOf(d))}),c},abortRequest:function(){var a=this;a.currentRequest&&a.currentRequest.abort()},processResponse:function(b){var c,d=this;return b&&a.isArray(b.suggestions)?(d.verifySuggestionsFormat(b.suggestions),d.setUnrestrictedValues(b.suggestions),a.isFunction(d.options.onSuggestionsFetch)&&(c=d.options.onSuggestionsFetch.call(d.element,b.suggestions),a.isArray(c)&&(b.suggestions=c)),!0):!1},verifySuggestionsFormat:function(b){"string"==typeof b[0]&&a.each(b,function(a,c){b[a]={value:c,data:null}})},getSuggestionValue:function(b,c){var d,e=this,f=e.options.formatSelected||e.type.formatSelected,g=c&&c.hasSameValues,h=c&&c.hasBeenEnriched;return a.isFunction(f)&&(d=f.call(e,b)),("string"!=typeof d||0==d.length)&&(d=b.value,e.type.composeValue&&(h?e.options.restrict_value?d=e.type.composeValue(e.getUnrestrictedData(b.data),g&&["city_district"]):e.bounds.own.indexOf("street")>=0&&(d=e.type.composeValue(e.copyDataComponents(b.data,e.bounds.own.concat(["city_district"])),g&&["city_district"])):g&&(d=e.options.restrict_value?e.type.composeValue(e.getUnrestrictedData(b.data),["city_district"]):e.bounds.own.indexOf("street")>=0?e.type.composeValue(e.copyDataComponents(b.data,e.bounds.own.concat(["city_district"])),["city_district"]):b.unrestricted_value))),d},hasSameValues:function(b){var c=!1;return a.each(this.suggestions,function(a,d){return d.value===b.value&&d!==b?(c=!0,!1):void 0}),c},assignSuggestions:function(a,b){var c=this;c.suggestions=a,c.notify("assignSuggestions",b)},shouldRestrictValues:function(){var a=this;return a.options.restrict_value&&a.constraints&&1==Object.keys(a.constraints).length},setUnrestrictedValues:function(b){var c=this,d=c.shouldRestrictValues(),e=c.getFirstConstraintLabel();a.each(b,function(a,b){b.unrestricted_value||(b.unrestricted_value=d?e+", "+b.value:b.value)})},areSuggestionsSame:function(a,b){return a&&b&&a.value===b.value&&m.areSame(a.data,b.data)}},function(){var d={setupElement:function(){this.el.attr("autocomplete","off").addClass("suggestions-input").css("box-sizing","border-box")},bindElementEvents:function(){var b=this;b.el.on("keydown"+e,a.proxy(b.onElementKeyDown,b)),b.el.on(["keyup"+e,"cut"+e,"paste"+e,"input"+e].join(" "),a.proxy(b.onElementKeyUp,b)),b.el.on("blur"+e,a.proxy(b.onElementBlur,b)),b.el.on("focus"+e,a.proxy(b.onElementFocus,b))},unbindElementEvents:function(){this.el.off(e)},onElementBlur:function(){var a=this;return a.cancelBlur?void(a.cancelBlur=!1):(a.options.triggerSelectOnBlur?a.isUnavailable()||a.selectCurrentValue({noSpace:!0}).always(function(){a.hide()}):a.hide(),void(a.fetchPhase.abort&&a.fetchPhase.abort()))},onElementFocus:function(){var b=this;b.cancelFocus||m.delay(a.proxy(b.completeOnFocus,b)),b.cancelFocus=!1},onElementKeyDown:function(a){var b=this;if(!b.isUnavailable())if(b.visible){switch(a.which){case c.ESC:b.el.val(b.currentValue),b.hide(),b.abortRequest();break;case c.TAB:if(b.options.tabDisabled===!1)return;break;case c.ENTER:b.options.triggerSelectOnEnter&&b.selectCurrentValue();break;case c.SPACE:return void(b.options.triggerSelectOnSpace&&b.isCursorAtEnd()&&(a.preventDefault(),b.selectCurrentValue({continueSelecting:!0,dontEnrich:!0}).fail(function(){b.currentValue+=" ",b.el.val(b.currentValue),b.proceedChangedValue()})));case c.UP:b.moveUp();break;case c.DOWN:b.moveDown();break;default:return}a.stopImmediatePropagation(),a.preventDefault()}else switch(a.which){case c.DOWN:b.suggest();break;case c.ENTER:b.options.triggerSelectOnEnter&&b.triggerOnSelectNothing()}},onElementKeyUp:function(a){var b=this;if(!b.isUnavailable()){switch(a.which){case c.UP:case c.DOWN:case c.ENTER:return}clearTimeout(b.onChangeTimeout),b.inputPhase.reject(),b.currentValue!==b.el.val()&&b.proceedChangedValue()}},proceedChangedValue:function(){var b=this;b.abortRequest(),b.inputPhase=a.Deferred().done(a.proxy(b.onValueChange,b)),b.options.deferRequestBy>0?b.onChangeTimeout=m.delay(function(){b.inputPhase.resolve()},b.options.deferRequestBy):b.inputPhase.resolve()},onValueChange:function(){var a,b=this;b.selection&&(a=b.selection,b.selection=null,b.trigger("InvalidateSelection",a)),b.selectedIndex=-1,b.update(),b.notify("valueChange")},completeOnFocus:function(){var a=this;a.isUnavailable()||a.isElementFocused()&&(a.fixPosition(),a.update(),a.isMobile&&(a.setCursorAtEnd(),a.scrollToTop()))},isElementFocused:function(){return document.activeElement===this.element},isCursorAtEnd:function(){var a,b,c=this,d=c.el.val().length;try{if(a=c.element.selectionStart,"number"==typeof a)return a===d}catch(e){}return document.selection?(b=document.selection.createRange(),b.moveStart("character",-d),d===b.text.length):!0},setCursorAtEnd:function(){var a=this.element;try{a.selectionEnd=a.selectionStart=a.value.length,a.scrollLeft=a.scrollWidth}catch(b){a.value=a.value}}};a.extend(b.prototype,d),l.on("initialize",d.bindElementEvents).on("dispose",d.unbindElementEvents)}(),function(){function c(){a.each(d,function(){this.abort()}),d={}}var d={};c();var e={checkStatus:function(){function b(b){a.isFunction(c.options.onSearchError)&&c.options.onSearchError.call(c.element,null,g,"error",b)}var c=this,e=a.trim(c.options.token),f=c.options.type+e,g=d[f];g||(g=d[f]=a.ajax(c.getAjaxParams("status"))),g.done(function(d){d.search?a.extend(c.status,d):b("Service Unavailable")}).fail(function(){b(g.statusText)})}};b.resetTokens=c,a.extend(b.prototype,e),l.on("setOptions",e.checkStatus)}(),function(){function c(){d=null,b.defaultOptions.geoLocation=e}if("GET"!=m.getDefaultType()){var d,e=!0,f={checkLocation:function(){var b=this,c=b.options.geoLocation;b.type.geoEnabled&&c&&(b.geoLocation=a.Deferred(),a.isPlainObject(c)||a.isArray(c)?b.geoLocation.resolve(c):(d||(d=a.ajax(b.getAjaxParams("detectAddressByIp"))),d.done(function(a){var c=a&&a.location&&a.location.data;c&&c.kladr_id?b.geoLocation.resolve(c):b.geoLocation.reject()}).fail(function(){b.geoLocation.reject()})))},getGeoLocation:function(){return this.geoLocation},constructParams:function(){var b=this,c={};return b.geoLocation&&a.isFunction(b.geoLocation.promise)&&"resolved"==b.geoLocation.state()&&b.geoLocation.done(function(b){c.locations_boost=a.makeArray(b)}),c}};a.extend(k,{geoLocation:e}),a.extend(b,{resetLocation:c}),a.extend(b.prototype,{getGeoLocation:f.getGeoLocation}),l.on("setOptions",f.checkLocation).on("requestParams",f.constructParams)}}(),function(){var c={enrichSuggestion:function(b,c){var d=this,e=a.Deferred();return!d.status.enrich||!d.type.enrichmentEnabled||!d.requestMode.enrichmentEnabled||c&&c.dontEnrich?e.resolve(b):b.data&&null!=b.data.qc?e.resolve(b):(d.disableDropdown(),d.currentValue=b.unrestricted_value,d.enrichPhase=d.getSuggestions(b.unrestricted_value,{count:1,locations:null,locations_boost:null,from_bound:null,to_bound:null},{noCallbacks:!0,useEnrichmentCache:!0}).always(function(){d.enableDropdown()}).done(function(a){var c=a&&a[0];e.resolve(c||b,!!c)}).fail(function(){e.resolve(b)}),e)},enrichResponse:function(b,c){var d=this,e=d.enrichmentCache[c];e&&a.each(b.suggestions,function(a,d){return d.value===c?(b.suggestions[a]=e,!1):void 0})}};a.extend(b.prototype,c)}(),function(){function c(b){return a.map(b,function(a){var b=m.escapeHtml(a.text);return b&&a.matched&&(b=""+b+""),b}).join("")}function d(b,c){var d=b.split(", ");return 1===d.length?b:a.map(d,function(a){return''+a+""}).join(", ")}function f(b,c){var d=!1;return a.each(b,function(a,b){return d=b.value==c.value&&b!=c,d?!1:void 0}),d}var g={width:"auto",floating:!1},j={createContainer:function(){var b=this,c="."+b.classes.suggestion,d=b.options,f=a("").addClass(d.containerClass).css({position:"absolute",display:"none"});b.$container=f,f.on("click"+e,c,a.proxy(b.onSuggestionClick,b))},removeContainer:function(){var a=this;a.options.floating&&a.$container.remove()},setContainerOptions:function(){var b=this,c="mousedown"+e;b.$container.off(c),b.options.floating&&b.$container.on(c,a.proxy(b.onMousedown,b))},onSuggestionClick:function(b){var c,d=this,e=a(b.target);if(!d.dropdownDisabled){for(d.cancelFocus=!0,d.el.focus();e.length&&!(c=e.attr("data-index"));)e=e.closest("."+d.classes.suggestion);c&&!isNaN(c)&&d.select(+c)}},setDropdownPosition:function(a,b){var c,d=this,e=d.$viewport.scrollLeft();d.isMobile?(c=d.options.floating?{left:e+"px",top:b.top+b.outerHeight+"px"}:{left:a.left-b.left+e+"px",top:a.top+b.outerHeight+"px"},c.width=d.$viewport.width()+"px"):(c=d.options.floating?{left:b.left+"px",top:b.top+b.borderTop+b.innerHeight+"px"}:{left:a.left+"px",top:a.top+b.borderTop+b.innerHeight+"px"},m.delay(function(){var a=d.options.width;"auto"===a&&(a=d.el.outerWidth()),d.$container.outerWidth(a)})),d.$container.toggleClass(d.classes.mobile,d.isMobile).css(c),d.containerItemsPadding=b.left+b.borderLeft+b.paddingLeft-e},setItemsPositions:function(){var a=this,b=a.getSuggestionsItems();b.css("paddingLeft",a.isMobile?a.containerItemsPadding+"px":"")},getSuggestionsItems:function(){return this.$container.children("."+this.classes.suggestion)},toggleDropdownEnabling:function(a){this.dropdownDisabled=!a,this.$container.attr("disabled",!a)},disableDropdown:function(){this.toggleDropdownEnabling(!1)},enableDropdown:function(){this.toggleDropdownEnabling(!0)},hasSuggestionsToChoose:function(){var b=this;return b.suggestions.length>1||1===b.suggestions.length&&(!b.selection||a.trim(b.suggestions[0].value)!==a.trim(b.selection.value))},suggest:function(){var b,c,d=this,e=d.options;if(d.requestMode.userSelect){if(!d.hasSuggestionsToChoose())return void d.hide();b=e.formatResult||d.type.formatResult||d.formatResult,c=[],!d.isMobile&&e.hint&&d.suggestions.length&&c.push(''+e.hint+"
"),d.selectedIndex=-1,a.each(d.suggestions,function(a,e){var f=d.makeSuggestionLabel(d.suggestions,e);e==d.selection&&(d.selectedIndex=a),c.push(''),c.push(b.call(d,e.value,d.currentValue,e,{unformattableTokens:d.type.unformattableTokens})),f&&c.push(''+m.escapeHtml(f)+""),c.push("
")}),d.$container.html(c.join("")),e.autoSelectFirst&&-1===d.selectedIndex&&(d.selectedIndex=0),-1!==d.selectedIndex&&d.getSuggestionsItems().eq(d.selectedIndex).addClass(d.classes.selected),a.isFunction(e.beforeRender)&&e.beforeRender.call(d.element,d.$container),d.$container.show(),d.visible=!0,d.fixPosition(),d.setItemsPositions()}},wrapFormattedValue:function(a,b){var c=this,d=m.getDeepValue(b.data,"state.status");return'"+a+""},formatResult:function(a,b,c,d){var e=this;return a=e.highlightMatches(a,b,c,d),e.wrapFormattedValue(a,c)},highlightMatches:function(b,e,f,g){var j,k,l,n,o,p,q,r,s=this,t=[],u=g&&g.unformattableTokens,v=g&&g.maxLength,w=m.reWordExtractor();if(!b)return"";for(j=m.compact(m.formatToken(e).split(h)),l=m.arrayMinus(j,u),j=m.withSubTokens(l.concat(m.arrayMinus(j,l))),k=a.map(j,function(a){return new RegExp("^((.*)(["+i+"]+))?("+m.escapeRegExChars(a)+")([^"+i+"]*["+i+"]*)","i")});(n=w.exec(b))&&n[0];)o=n[1],
9 | t.push({text:o,hasUpperCase:o.toLowerCase()!==o,formatted:m.formatToken(o),matchable:!0}),n[2]&&t.push({text:n[2]});for(p=0;pc&&(t.splice(e,0,{text:q.text.substr(c),formatted:q.formatted.substr(c),matchable:!0}),q.text=q.text.substr(0,c),q.formatted=q.formatted.substr(0,c)),d.after&&(c=d.text.length,t.splice(e,0,{text:q.text.substr(c),formatted:q.formatted.substr(c)}),q.text=q.text.substr(0,c),q.formatted=q.formatted.substr(0,c)),q.matched=!0,!1):void 0});if(v){for(p=0;p=0;p++)q=t[p],v-=q.text.length,0>v&&(q.text=q.text.substr(0,q.text.length+v)+"...");t.length=p}return r=c(t),d(r,s.classes.nowrap)},makeSuggestionLabel:function(b,c){var d,e,g=this,h=g.type.fieldNames,i={},j=m.reWordExtractor(),k=[];if(h&&f(b,c)&&c.data&&(a.each(h,function(a){var b=c.data[a];b&&(i[a]=m.formatToken(b))}),!a.isEmptyObject(i))){for(;(d=j.exec(m.formatToken(c.value)))&&(e=d[1]);)a.each(i,function(a,b){return b==e?(k.push(h[a]),delete i[a],!1):void 0});if(k.length)return k.join(", ")}},hide:function(){var a=this;a.visible=!1,a.selectedIndex=-1,a.$container.hide().empty()},activate:function(a){var b,c,d=this,e=d.classes.selected;return!d.dropdownDisabled&&(c=d.getSuggestionsItems(),c.removeClass(e),d.selectedIndex=a,-1!==d.selectedIndex&&c.length>d.selectedIndex)?(b=c.eq(d.selectedIndex),b.addClass(e),b):null},deactivate:function(a){var b=this;b.dropdownDisabled||(b.selectedIndex=-1,b.getSuggestionsItems().removeClass(b.classes.selected),a&&b.el.val(b.currentValue))},moveUp:function(){var a=this;if(!a.dropdownDisabled)return-1===a.selectedIndex?void(a.suggestions.length&&a.adjustScroll(a.suggestions.length-1)):0===a.selectedIndex?void a.deactivate(!0):void a.adjustScroll(a.selectedIndex-1)},moveDown:function(){var a=this;if(!a.dropdownDisabled)return a.selectedIndex===a.suggestions.length-1?void a.deactivate(!0):void a.adjustScroll(a.selectedIndex+1)},adjustScroll:function(a){var b,c,d,e=this,f=e.activate(a),g=e.$container.scrollTop();f&&f.length&&(b=f.position().top,0>b?e.$container.scrollTop(g+b):(c=b+f.outerHeight(),d=e.$container.innerHeight(),c>d&&e.$container.scrollTop(g-d+c)),e.el.val(e.suggestions[a].value))}};a.extend(k,g),a.extend(b.prototype,j),l.on("initialize",j.createContainer).on("dispose",j.removeContainer).on("setOptions",j.setContainerOptions).on("fixPosition",j.setDropdownPosition).on("fixPosition",j.setItemsPositions).on("assignSuggestions",j.suggest)}(),function(){var b="addon",c=50,d=1e3,e={addon:null},f={NONE:"none",SPINNER:"spinner",CLEAR:"clear"},g=function(b){var c=this,d=a('');c.owner=b,c.$el=d,c.type=f.NONE,c.visible=!1,c.initialPadding=null,d.on("click",a.proxy(c,"onClick"))};g.prototype={checkType:function(){var b=this,c=b.owner.options.addon,d=!1;a.each(f,function(a,b){return d=b==c,d?!1:void 0}),d||(c=b.owner.isMobile?f.CLEAR:f.SPINNER),c!=b.type&&(b.type=c,b.$el.attr("data-addon-type",c),b.toggle(!0))},toggle:function(a){var b,c=this;switch(c.type){case f.CLEAR:b=!!c.owner.currentValue;break;case f.SPINNER:b=!!c.owner.currentRequest;break;default:b=!1}b!=c.visible&&(c.visible=b,b?c.show(a):c.hide(a))},show:function(a){var b=this,d={opacity:1};a?(b.$el.show().css(d),b.showBackground(!0)):b.$el.stop(!0,!0).delay(c).queue(function(){b.$el.show(),b.showBackground(),b.$el.dequeue()}).animate(d,"fast")},hide:function(a){var b=this,c={opacity:0};a&&b.$el.hide().css(c),b.$el.stop(!0).animate(c,{duration:"fast",complete:function(){b.$el.hide(),b.hideBackground()}})},fixPosition:function(a,b){var c=this,d=b.innerHeight;c.checkType(),c.$el.css({left:a.left+b.borderLeft+b.innerWidth-d+"px",top:a.top+b.borderTop+"px",height:d,width:d}),c.initialPadding=b.paddingRight,c.width=d,c.visible&&(b.componentsRight+=d)},showBackground:function(a){var c=this,d=c.owner.el,e={paddingRight:c.width};c.width>c.initialPadding&&(c.stopBackground(),a?d.css(e):d.animate(e,{duration:"fast",queue:b}).dequeue(b))},hideBackground:function(a){var c=this,e=c.owner.el,f={paddingRight:c.initialPadding};c.width>c.initialPadding&&(c.stopBackground(!0),a?e.css(f):e.delay(d,b).animate(f,{duration:"fast",queue:b}).dequeue(b))},stopBackground:function(a){this.owner.el.stop(b,!0,a)},onClick:function(a){var b=this;b.type==f.CLEAR&&b.owner.clear()}};var h={createAddon:function(){var a=this,b=new g(a);a.$wrapper.append(b.$el),a.addon=b},fixAddonPosition:function(a,b){this.addon.fixPosition(a,b)},checkAddonType:function(){this.addon.checkType()},checkAddonVisibility:function(){this.addon.toggle()},stopBackground:function(){this.addon.stopBackground()}};a.extend(k,e),l.on("initialize",h.createAddon).on("setOptions",h.checkAddonType).on("fixPosition",h.fixAddonPosition).on("clear",h.checkAddonVisibility).on("valueChange",h.checkAddonVisibility).on("request",h.checkAddonVisibility).on("resetPosition",h.stopBackground)}(),function(){function c(b,c){var d=c.selection,e=d&&d.data&&c.bounds;return e&&a.each(c.bounds.all,function(a,c){return e=d.data[c]===b.data[c]}),e}var d={constraints:null,restrict_value:!1},e=function(b,c){var d=this;d.instance=c,d.fields={},d.specificity=-1,a.isPlainObject(b)&&c.type.dataComponents&&a.each(c.type.dataComponents,function(a,c){var e=c.id;c.forLocations&&b[e]&&(d.fields[e]=b[e],d.specificity=a)}),d.fields.kladr_id&&(d.fields={kladr_id:d.fields.kladr_id},d.specificity=d.getKladrSpecificity(d.fields.kladr_id))};a.extend(e.prototype,{getLabel:function(){return this.instance.type.composeValue(this.fields)},getFields:function(){return this.fields},isValid:function(){return!a.isEmptyObject(this.fields)},getKladrSpecificity:function(b){var c,d=-1;return this.significantKladr=b.replace(/^(\d{2})(\d*?)(0+)$/g,"$1$2"),c=this.significantKladr.length,a.each(this.instance.type.dataComponents,function(a,b){b.kladrFormat&&c===b.kladrFormat.digits&&(d=a)}),d},containsData:function(b){var c=!0;return this.fields.kladr_id?!!b.kladr_id&&0===b.kladr_id.indexOf(this.significantKladr):(a.each(this.fields,function(a,d){return c=!!b[a]&&b[a].toLowerCase()===d.toLowerCase()}),c)}}),b.ConstraintLocation=e;var f=function(b,c){this.id=m.uniqueId("c"),this.deletable=!!b.deletable,this.instance=c,this.locations=a.map(a.makeArray(b&&(b.locations||b.restrictions)),function(a){return new e(a,c)}),this.locations=a.grep(this.locations,function(a){return a.isValid()}),this.label=b.label,null==this.label&&c.type.composeValue&&(this.label=a.map(this.locations,function(a){return a.getLabel()}).join(", ")),this.label&&this.isValid()&&(this.$el=a(document.createElement("li")).append(a(document.createElement("span")).text(this.label)).attr("data-constraint-id",this.id),this.deletable&&this.$el.append(a(document.createElement("span")).addClass(c.classes.removeConstraint)))};a.extend(f.prototype,{isValid:function(){return this.locations.length>0},getFields:function(){return a.map(this.locations,function(a){return a.getFields()})}});var g={createConstraints:function(){var b=this;b.constraints={},b.$constraints=a(''),b.$wrapper.append(b.$constraints),b.$constraints.on("click","."+b.classes.removeConstraint,a.proxy(b.onConstraintRemoveClick,b))},setConstraintsPosition:function(a,b){var c=this;c.$constraints.css({left:a.left+b.borderLeft+b.paddingLeft+"px",top:a.top+b.borderTop+Math.round((b.innerHeight-c.$constraints.height())/2)+"px"}),b.componentsLeft+=c.$constraints.outerWidth(!0)+b.paddingLeft},onConstraintRemoveClick:function(b){var c=this,d=a(b.target).closest("li"),e=d.attr("data-constraint-id");delete c.constraints[e],c.update(),d.fadeOut("fast",function(){c.removeConstraint(e)})},setupConstraints:function(){var b,c=this,d=c.options.constraints;return d?void(d instanceof a||"string"==typeof d||"number"==typeof d.nodeType?(b=a(d),b.is(c.constraints)||(c.unbindFromParent(),b.is(c.el)||(c.constraints=b,c.bindToParent()))):(c._constraintsUpdating=!0,a.each(c.constraints,a.proxy(c.removeConstraint,c)),a.each(a.makeArray(d),function(a,b){c.addConstraint(b)}),c._constraintsUpdating=!1,c.fixPosition())):void c.unbindFromParent()},filteredLocation:function(b){var c=[],d={};return a.each(this.type.dataComponents,function(){this.forLocations&&c.push(this.id)}),a.isPlainObject(b)&&a.each(b,function(a,b){b&&c.indexOf(a)>=0&&(d[a]=b)}),a.isEmptyObject(d)?void 0:d.kladr_id?{kladr_id:d.kladr_id}:d},addConstraint:function(a){var b=this;a=new f(a,b),a.isValid()&&(b.constraints[a.id]=a,a.$el&&(b.$constraints.append(a.$el),b._constraintsUpdating||b.fixPosition()))},removeConstraint:function(a){var b=this;delete b.constraints[a],b.$constraints.children('[data-constraint-id="'+a+'"]').remove(),b._constraintsUpdating||b.fixPosition()},constructConstraintsParams:function(){for(var b,c,d=this,f=[],g=d.constraints,h={};g instanceof a&&(b=g.suggestions())&&!(c=m.getDeepValue(b,"selection.data"));)g=b.constraints;return g instanceof a?(c=new e(c,b).getFields(),c&&(h.locations=[c],h.restrict_value=!0)):g&&(a.each(g,function(a,b){f=f.concat(b.getFields())}),f.length&&(h.locations=f,h.restrict_value=d.options.restrict_value)),h},getFirstConstraintLabel:function(){var b=this,c=a.isPlainObject(b.constraints)&&Object.keys(b.constraints)[0];return c?b.constraints[c].label:""},bindToParent:function(){var b=this;b.constraints.on(["suggestions-select."+b.uniqueId,"suggestions-invalidateselection."+b.uniqueId,"suggestions-clear."+b.uniqueId].join(" "),a.proxy(b.onParentSelectionChanged,b)).on("suggestions-dispose."+b.uniqueId,a.proxy(b.onParentDispose,b))},unbindFromParent:function(){var b=this,c=b.constraints;c instanceof a&&c.off("."+b.uniqueId)},onParentSelectionChanged:function(a,b,c){("suggestions-select"!==a.type||c)&&this.clear()},onParentDispose:function(a){this.unbindFromParent()},getParentInstance:function(){return this.constraints instanceof a&&this.constraints.suggestions()},shareWithParent:function(a){var b=this.getParentInstance();b&&b.type===this.type&&!c(a,b)&&(b.shareWithParent(a),b.setSuggestion(a))},getUnrestrictedData:function(b){var c=this,d=[],e={},f=-1;return a.each(c.constraints,function(c,d){a.each(d.locations,function(a,c){c.containsData(b)&&c.specificity>f&&(f=c.specificity)})}),f>=0?(b.region_kladr_id&&b.region_kladr_id===b.city_kladr_id&&d.push.apply(d,c.type.dataComponentsById.city.fields),a.each(c.type.dataComponents.slice(0,f+1),function(a,b){d.push.apply(d,b.fields)}),a.each(b,function(a,b){-1===d.indexOf(a)&&(e[a]=b)})):e=b,e}};a.extend(k,d),a.extend(b.prototype,g),"GET"!=m.getDefaultType()&&l.on("initialize",g.createConstraints).on("setOptions",g.setupConstraints).on("fixPosition",g.setConstraintsPosition).on("requestParams",g.constructConstraintsParams).on("dispose",g.unbindFromParent)}(),function(){var c={proceedQuery:function(a){var b=this;a.length>=b.options.minChars?b.updateSuggestions(a):b.hide()},selectCurrentValue:function(b){var c=this,d=a.Deferred();return c.inputPhase.resolve(),c.fetchPhase.done(function(){var a;c.selection&&!c.visible?d.reject():(a=c.findSuggestionIndex(),c.select(a,b),-1===a?d.reject():d.resolve(a))}).fail(function(){d.reject()}),d},selectFoundSuggestion:function(){var a=this;a.requestMode.userSelect||a.select(0)},findSuggestionIndex:function(){var b,c=this,d=c.selectedIndex;return-1===d&&(b=a.trim(c.el.val()),b&&a.each(c.type.matchers,function(a,e){return d=e(b,c.suggestions),-1===d})),d},select:function(b,c){var d,e=this,f=e.suggestions[b],g=c&&c.continueSelecting,h=e.currentValue;if(!e.triggering.Select){if(!f)return g||e.selection||e.triggerOnSelectNothing(),void e.onSelectComplete(g);d=e.hasSameValues(f),e.enrichSuggestion(f,c).done(function(f,g){e.selectSuggestion(f,b,h,a.extend({hasBeenEnriched:g,hasSameValues:d},c))})}},selectSuggestion:function(a,b,c,d){var e=this,f=d.continueSelecting,g=!e.type.isDataComplete||e.type.isDataComplete.call(e,a),h=e.selection;e.triggering.Select||(e.type.alwaysContinueSelecting&&(f=!0),g&&(f=!1),d.hasBeenEnriched&&e.suggestions[b]&&(e.suggestions[b].data=a.data),e.requestMode.updateValue&&(e.checkValueBounds(a),e.currentValue=e.getSuggestionValue(a,d),!e.currentValue||d.noSpace||g||(e.currentValue+=" "),e.el.val(e.currentValue)),e.currentValue?(e.selection=a,e.areSuggestionsSame(a,h)||e.trigger("Select",a,e.currentValue!=c),e.requestMode.userSelect&&e.onSelectComplete(f)):(e.selection=null,e.triggerOnSelectNothing()),e.shareWithParent(a))},onSelectComplete:function(a){var b=this;a?(b.selectedIndex=-1,b.updateSuggestions(b.currentValue)):b.hide()},triggerOnSelectNothing:function(){var a=this;a.triggering.SelectNothing||a.trigger("SelectNothing",a.currentValue)},trigger:function(b){var c=this,d=m.slice(arguments,1),e=c.options["on"+b];c.triggering[b]=!0,a.isFunction(e)&&e.apply(c.element,d),c.el.trigger.call(c.el,"suggestions-"+b.toLowerCase(),d),c.triggering[b]=!1}};a.extend(b.prototype,c),l.on("assignSuggestions",c.selectFoundSuggestion)}(),function(){var b={bounds:null},c={setupBounds:function(){this.bounds={from:null,to:null}},setBoundsOptions:function(){var b,c,d=this,e=[],f=a.trim(d.options.bounds).split("-"),g=f[0],h=f[f.length-1],i=[],j=[];d.type.dataComponents&&a.each(d.type.dataComponents,function(){this.forBounds&&e.push(this.id)}),-1===a.inArray(g,e)&&(g=null),c=a.inArray(h,e),(-1===c||c===e.length-1)&&(h=null),(g||h)&&(b=!g,a.each(e,function(a,c){return c==g&&(b=!0),j.push(c),b&&i.push(c),c==h?!1:void 0})),d.bounds.from=g,d.bounds.to=h,d.bounds.all=j,d.bounds.own=i},constructBoundsParams:function(){var a=this,b={};return a.bounds.from&&(b.from_bound={value:a.bounds.from}),a.bounds.to&&(b.to_bound={value:a.bounds.to}),b},checkValueBounds:function(a){var b,c=this;c.bounds.own.length&&c.type.composeValue&&(b=c.copyDataComponents(a.data,c.bounds.own),a.value=c.type.composeValue(b))},copyDataComponents:function(b,c){var d={},e=this.type.dataComponentsById;return e&&a.each(c,function(c,f){a.each(e[f].fields,function(a,c){null!=b[c]&&(d[c]=b[c])})}),d},getBoundedKladrId:function(b,c){var d,e=c[c.length-1];return a.each(this.type.dataComponents,function(a,b){return b.id===e?(d=b.kladrFormat,!1):void 0}),b.substr(0,d.digits)+new Array((d.zeros||0)+1).join("0")}};a.extend(k,b),a.extend(a.Suggestions.prototype,c),l.on("initialize",c.setupBounds).on("setOptions",c.setBoundsOptions).on("requestParams",c.constructBoundsParams)}(),a.fn.suggestions=function(c,d){return 0===arguments.length?this.first().data(f):this.each(function(){var e=a(this),g=e.data(f);"string"==typeof c?g&&"function"==typeof g[c]&&g[c](d):(g&&g.dispose&&g.dispose(),g=new b(this,c),e.data(f,g))})}});
--------------------------------------------------------------------------------
/custom/assets/js/jquery.xdomainrequest.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * jQuery-ajaxTransport-XDomainRequest - v1.0.1 - 2013-10-17
3 | * https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
4 | * Copyright (c) 2013 Jason Moon (@JSONMOON)
5 | * Licensed MIT (/blob/master/LICENSE.txt)
6 | */
7 | (function($){if(!$.support.cors&&$.ajaxTransport&&window.XDomainRequest){var n=/^https?:\/\//i;var o=/^get|post$/i;var p=new RegExp('^'+location.protocol,'i');var q=/text\/html/i;var r=/\/json/i;var s=/\/xml/i;$.ajaxTransport('* text html xml json',function(i,j,k){if(i.crossDomain&&i.async&&o.test(i.type)&&n.test(i.url)&&p.test(i.url)){var l=null;var m=(j.dataType||'').toLowerCase();return{send:function(f,g){l=new XDomainRequest();if(/^\d+$/.test(j.timeout)){l.timeout=j.timeout}l.ontimeout=function(){g(500,'timeout')};l.onload=function(){var a='Content-Length: '+l.responseText.length+'\r\nContent-Type: '+l.contentType;var b={code:200,message:'success'};var c={text:l.responseText};try{if(m==='html'||q.test(l.contentType)){c.html=l.responseText}else if(m==='json'||(m!=='text'&&r.test(l.contentType))){try{c.json=$.parseJSON(l.responseText)}catch(e){b.code=500;b.message='parseerror'}}else if(m==='xml'||(m!=='text'&&s.test(l.contentType))){var d=new ActiveXObject('Microsoft.XMLDOM');d.async=false;try{d.loadXML(l.responseText)}catch(e){d=undefined}if(!d||!d.documentElement||d.getElementsByTagName('parsererror').length){b.code=500;b.message='parseerror';throw'Invalid XML: '+l.responseText;}c.xml=d}}catch(parseMessage){throw parseMessage;}finally{g(b.code,b.message,c,a)}};l.onprogress=function(){};l.onerror=function(){g(500,'error',{text:l.responseText})};var h='';if(j.data){h=($.type(j.data)==='string')?j.data:$.param(j.data)}l.open(i.type,i.url);l.send(h)},abort:function(){if(l){l.abort()}}}}})}})(jQuery);
--------------------------------------------------------------------------------
/custom/custom.js:
--------------------------------------------------------------------------------
1 | jQuery(document).ready(function ($) {
2 | $("#billing_address_1").suggestions({
3 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
4 | token: php_vars.dadata_suggest_token,
5 | type: "ADDRESS",
6 | count: 5,
7 | onSelect: function (suggestion) {
8 | $("#billing_city").val(suggestion.data.city);
9 | $("#billing_state").val(suggestion.data.region);
10 | $("#billing_postcode").val(suggestion.data.postal_code);
11 | }
12 | });
13 |
14 | $("#shipping_address_1").suggestions({
15 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
16 | token: php_vars.dadata_suggest_token,
17 | type: "ADDRESS",
18 | count: 5,
19 | onSelect: function (suggestion) {
20 | $("#shipping_city").val(suggestion.data.city);
21 | $("#shipping_state").val(suggestion.data.region);
22 | $("#shipping_postcode").val(suggestion.data.postal_code);
23 | }
24 | });
25 |
26 | $("#billing_email").suggestions({
27 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
28 | token: php_vars.dadata_suggest_token,
29 | type: "EMAIL",
30 | count: 5,
31 | });
32 |
33 | $("#billing_first_name").suggestions({
34 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
35 | token: php_vars.dadata_suggest_token,
36 | type: "NAME",
37 | params: {
38 | parts: ["NAME"]
39 | },
40 | count: 5,
41 | });
42 |
43 | $("#billing_last_name").suggestions({
44 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
45 | token: php_vars.dadata_suggest_token,
46 | type: "NAME",
47 | params: {
48 | parts: ["SURNAME"]
49 | },
50 | count: 5,
51 | });
52 |
53 | $("#shipping_first_name").suggestions({
54 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
55 | token: php_vars.dadata_suggest_token,
56 | type: "NAME",
57 | params: {
58 | parts: ["NAME"]
59 | },
60 | count: 5,
61 | });
62 |
63 | $("#shipping_last_name").suggestions({
64 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
65 | token: php_vars.dadata_suggest_token,
66 | type: "NAME",
67 | params: {
68 | parts: ["SURNAME"]
69 | },
70 | count: 5,
71 | });
72 |
73 | $("#shipping_last_name").suggestions({
74 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
75 | token: php_vars.dadata_suggest_token,
76 | type: "NAME",
77 | params: {
78 | parts: ["SURNAME"]
79 | },
80 | count: 5,
81 | });
82 |
83 | $("#billing_company").suggestions({
84 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
85 | token: php_vars.dadata_suggest_token,
86 | type: "PARTY",
87 | count: 5,
88 | onSelect: function(suggestion) {
89 | $('#billing_company').val(suggestion.unrestricted_value);
90 | $('#billing_address').val(suggestion.data.address.value);
91 | $('#billing_inn').val(suggestion.data.inn);
92 | $('#billing_kpp').val(suggestion.data.kpp);
93 | $('#billing_ogrn').val(suggestion.data.ogrn);
94 | }
95 | });
96 |
97 | $("#billing_bank").suggestions({
98 | serviceUrl: "https://suggestions.dadata.ru/suggestions/api/4_1/rs",
99 | token: php_vars.dadata_suggest_token,
100 | type: "BANK",
101 | count: 5,
102 | onSelect: function(suggestion) {
103 | $('#billing_bank').val(suggestion.value);
104 | $('#billing_bank_address').val(suggestion.data.address.unrestricted_value);
105 | $('#billing_bank_bic').val(suggestion.data.bic);
106 | $('#billing_bank_swift').val(suggestion.data.swift);
107 | $('#billing_bank_correspondent_account').val(suggestion.data.correspondent_account);
108 | }
109 | });
110 | });
--------------------------------------------------------------------------------
/custom/functions.php:
--------------------------------------------------------------------------------
1 | get_option('wc_settings_tab_wcddc_dadata_suggest_token')
82 | );
83 |
84 | wp_localize_script( 'custom-js', 'php_vars', $dataToBePassed );
85 | }
86 |
87 | /**
88 | * Look in this plugin for template files first.
89 | * This works for the top level templates (IE single.php, page.php etc). However, it doesn't work for
90 | * template parts yet (content.php, header.php etc).
91 | *
92 | * Relevant trac ticket; https://core.trac.wordpress.org/ticket/13239
93 | *
94 | * @param string $template template string.
95 | * @return string $template new template string.
96 | */
97 | public function WooCommerce_DaData_template( $template ) {
98 | if ( file_exists( untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/custom/templates/' . basename( $template ) ) ) {
99 | $template = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/custom/templates/' . basename( $template );
100 | }
101 |
102 | return $template;
103 | }
104 |
105 | /**
106 | * Look in this plugin for WooCommerce template overrides.
107 | *
108 | * For example, if you want to override woocommerce/templates/cart/cart.php, you
109 | * can place the modified template in /custom/templates/woocommerce/cart/cart.php
110 | *
111 | * @param string $located is the currently located template, if any was found so far.
112 | * @param string $template_name is the name of the template (ex: cart/cart.php).
113 | * @return string $located is the newly located template if one was found, otherwise
114 | * it is the previously found template.
115 | */
116 | public function WooCommerce_DaData_wc_get_template( $located, $template_name, $args, $template_path, $default_path ) {
117 | $plugin_template_path = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/custom/templates/woocommerce/' . $template_name;
118 |
119 | if ( file_exists( $plugin_template_path ) ) {
120 | $located = $plugin_template_path;
121 | }
122 |
123 | return $located;
124 | }
125 |
126 | public function add_settings_tab( $settings_tabs ) {
127 | $settings_tabs['settings_tab_wcddc'] = __( 'DaData', 'woocommerce-settings-tab-wcddc' );
128 | return $settings_tabs;
129 | }
130 |
131 | public function settings_tab() {
132 | woocommerce_admin_fields( $this->get_settings() );
133 | }
134 |
135 | public function update_settings() {
136 | woocommerce_update_options( $this->get_settings() );
137 | }
138 |
139 | public function get_settings() {
140 | $wcddc_settings = array(
141 | 'section_title' => array(
142 | 'name' => __( 'DaData Подсказки', 'woocommerce-settings-tab-wcddc' ),
143 | 'type' => 'title',
144 | 'desc' => '',
145 | 'id' => 'wc_settings_tab_wcddc_section_title'
146 | ),
147 | 'wc_settings_tab_wcddc_dadata_suggest_token' => array(
148 | 'name' => __( 'API-ключ', 'woocommerce-settings-tab-wcddc' ),
149 | 'type' => 'text',
150 | 'desc' => __( 'Где взять ключ?', 'woocommerce-settings-tab-wcddc' ),
151 | 'id' => 'wc_settings_tab_wcddc_dadata_suggest_token'
152 | ),
153 | 'section_end' => array(
154 | 'type' => 'sectionend',
155 | 'id' => 'wc_settings_tab_wcddc_section_end'
156 | )
157 | );
158 | return apply_filters( 'wc_settings_tab_wcddc_settings', $wcddc_settings );
159 | }
160 | } // End Class
161 |
162 | /**
163 | * The 'main' function
164 | *
165 | * @return void
166 | */
167 | function WooCommerce_DaData_main() {
168 | new WooCommerce_DaData();
169 | }
170 |
171 | /**
172 | * Initialise the plugin
173 | */
174 | add_action( 'plugins_loaded', 'WooCommerce_DaData_main' );
175 |
--------------------------------------------------------------------------------