├── LICENSE ├── README.md ├── custom ├── assets │ ├── css │ │ └── suggestions.css │ └── js │ │ ├── jquery.suggestions.min.js │ │ └── jquery.xdomainrequest.min.js ├── custom.js ├── functions.php └── style.css ├── demo.gif └── woocommerce-dadata.php /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WooCommerce DaData 2 | Быстрый ввод адресов, ФИО и e-mail при оформлении заказа. 3 | 4 | ![Demo](https://github.com/troyanov/woocommerce-dadata/raw/master/demo.gif) 5 | 6 | # Описание 7 | Использование данного плагина значительно сокращает время ввода информации, а также снижает количество ошибок. Плагин добавляет функцию автодополнения к следующим полям при оформлении заказа: 8 | 9 | * Имя 10 | * Фамилия 11 | * Email 12 | * Адрес 13 | 14 | После выбора предложенного варианта для поля Адрес, автоматически заполняются поля: 15 | 16 | * Населённый пункт 17 | * Область/регион 18 | * Почтовый индекс 19 | 20 | **Важно!** 21 | Данный функционал работает только для адресов Российской Федерации. 22 | 23 | # Дополнительные подсказки 24 | ## Название компании 25 | Поиск осуществляется путем ввода любых из перечисленных данных в поле с названием `billing_company`: 26 | * Название компании (либо ФИО для ИП) 27 | * Адрес компании 28 | * ИНН 29 | * КПП 30 | * ОГРН 31 | 32 | После выбора организации из подсказки, следующие поля формы будут автоматически заполнены: 33 | * `billing_company` 34 | * `billing_address` 35 | * `billing_inn` 36 | * `billing_kpp` 37 | * `billing_ogrn` 38 | 39 | ## Наименование банка 40 | Поиск осуществляется путем ввода любых из перечисленных данных в поле с идентификатором `billing_bank`: 41 | * Наименование банка 42 | * Адрес 43 | * БИК 44 | * SWIFT 45 | * Корреспондентский счет в ЦБ РФ 46 | 47 | После выбора банка из подсказки, следующие поля формы будут автоматически заполнены: 48 | 49 | * `billing_bank` 50 | * `billing_bank_address` 51 | * `billing_bank_bic` 52 | * `billing_bank_swift` 53 | * `billing_bank_correspondent_account` 54 | 55 | 56 | # Установка 57 | Следуйте общим инструкциям установки плагинов для WordPress. После активации необходимо настроить плагин (вкладка **DaData** в меню настроек WooCommerce). 58 | Для получения API-ключа необходимо зарегистрироваться в [DaData](https://dadata.ru/api/suggest/). 59 | 60 | # Совместимость 61 | * WordPress = 4.7 62 | * WooCommerce = 2.6.11 63 | * Storefront* = 2.1.6 64 | 65 | **Плагин разрабатывался под конкретную задачу, для бесплатной темы WooCommerce Storefront и не тестировался с другими темами.* 66 | -------------------------------------------------------------------------------- /custom/assets/css/suggestions.css: -------------------------------------------------------------------------------- 1 | .suggestions-nowrap { 2 | white-space: nowrap; 3 | } 4 | .suggestions-input { 5 | -ms-box-sizing: border-box; 6 | -moz-box-sizing: border-box; 7 | -webkit-box-sizing: border-box; 8 | box-sizing: border-box; 9 | width: 100%; 10 | } 11 | .suggestions-input::-ms-clear { 12 | display: none; 13 | } 14 | .suggestions-wrapper { 15 | position: relative; 16 | margin: 0; 17 | padding: 0; 18 | vertical-align: top; 19 | -webkit-text-size-adjust: 100%; 20 | } 21 | .suggestions-addon { 22 | display: none; 23 | opacity: 0; 24 | position: absolute; 25 | } 26 | .suggestions-addon[data-addon-type="spinner"] { 27 | background: rgba(255, 255, 255, 0.75) url("data:image/gif;base64,R0lGODlhEAAQAKUAABwaHI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fBwaHISGhMTGxOTm5KSmpFxeXNTW1PT29GxubHR2dDQyNMzOzOzu7KyurNze3Pz+/Ly+vJyenP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaWQJRwiJIoiEgUZ3NAfSooESiU7GwoTugH1CGSIqhJYRC4cCwj1KEhXHwaJUpGSAqUCBaG8EBIPJILAB4ORAOESBwcQxMPDwhJQiGSHAgjGo+QBiENikIiTUgHoEIdAhQYSZQGYCgEGhAlHF1qHCUDExNCDl0DCAchBgcIcxEiRCUTBigNVCETrEQiE12bKBETxpBCiZBBADs=") 50% 50% no-repeat; 28 | -webkit-border-radius: 50%; 29 | -moz-border-radius: 50%; 30 | border-radius: 50%; 31 | } 32 | .suggestions-addon[data-addon-type="clear"] { 33 | background: transparent url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMTAwJyBoZWlnaHQ9JzEwMCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz48Zz48cGF0aCBkPSdtMjAsMjBtMTAsMGwyMCwyMGwyMCwtMjBsMTAsMTBsLTIwLDIwbDIwLDIwbC0xMCwxMGwtMjAsLTIwbC0yMCwyMGwtMTAsLTEwbDIwLC0yMGwtMjAsLTIwbDEwLC0xMCcgZmlsbD0nIzk5OScvPjwvZz48L3N2Zz4=") 50% 50% no-repeat; 34 | background-size: contain; 35 | cursor: pointer; 36 | opacity: 0.8; 37 | } 38 | .suggestions-addon[data-addon-type="clear"]:hover { 39 | opacity: 1; 40 | } 41 | .suggestions-suggestions { 42 | background: #ffffff; 43 | border: 1px solid #999; 44 | -ms-box-sizing: border-box; 45 | -moz-box-sizing: border-box; 46 | -webkit-box-sizing: border-box; 47 | box-sizing: border-box; 48 | cursor: default; 49 | z-index: 9999; 50 | -webkit-text-size-adjust: 100%; 51 | } 52 | .suggestions-suggestions strong { 53 | font-weight: normal; 54 | color: #3399FF; 55 | } 56 | .suggestions-suggestions.suggestions-mobile { 57 | border-style: none; 58 | } 59 | .suggestions-suggestions.suggestions-mobile .suggestions-suggestion { 60 | border-bottom: 1px solid #ddd; 61 | } 62 | .suggestions-suggestion { 63 | padding: 4px 4px; 64 | overflow: hidden; 65 | } 66 | .suggestions-suggestion:hover { 67 | background: #f7f7f7; 68 | } 69 | .suggestions-selected { 70 | background: #f0f0f0; 71 | } 72 | .suggestions-selected:hover { 73 | background: #f0f0f0; 74 | } 75 | .suggestions-hint { 76 | padding: 4px 4px; 77 | white-space: nowrap; 78 | overflow: hidden; 79 | color: #777; 80 | font-size: 85%; 81 | } 82 | .suggestions-constraints { 83 | list-style: none !important; 84 | margin: 0 !important; 85 | padding: 0 !important; 86 | position: absolute !important; 87 | white-space: nowrap !important; 88 | } 89 | .suggestions-constraints:empty { 90 | display: none !important; 91 | } 92 | .suggestions-constraints li { 93 | background: #f8f8f8; 94 | border: 1px solid #ccc; 95 | -webkit-border-radius: 3px; 96 | -moz-border-radius: 3px; 97 | border-radius: 3px; 98 | cursor: default; 99 | display: inline-block; 100 | margin: 0 4px 0 0; 101 | padding: 0 0.5em; 102 | } 103 | .suggestions-constraints li .suggestions-remove { 104 | height: 1em; 105 | width: 1em; 106 | display: inline-block; 107 | margin: 0 0 0 0.25em; 108 | background: transparent url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMTAwJyBoZWlnaHQ9JzEwMCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz48Zz48cGF0aCBkPSdtMjAsMjBtMTAsMGwyMCwyMGwyMCwtMjBsMTAsMTBsLTIwLDIwbDIwLDIwbC0xMCwxMGwtMjAsLTIwbC0yMCwyMGwtMTAsLTEwbDIwLC0yMGwtMjAsLTIwbDEwLC0xMCcgZmlsbD0nIzk5OScvPjwvZz48L3N2Zz4=") 50% 50% no-repeat; 109 | background-size: contain; 110 | cursor: pointer; 111 | opacity: 0.8; 112 | } 113 | .suggestions-constraints li .suggestions-remove:hover { 114 | opacity: 1; 115 | } 116 | .suggestions-constraints li span { 117 | vertical-align: middle; 118 | } 119 | .suggestions-subtext { 120 | color: #777777; 121 | white-space: nowrap; 122 | overflow: hidden; 123 | text-overflow: ellipsis; 124 | } 125 | .suggestions-subtext_inline { 126 | display: inline-block; 127 | min-width: 6em; 128 | vertical-align: bottom; 129 | margin: 0 0.5em 0 0; 130 | } 131 | .suggestions-subtext-delimiter { 132 | display: inline-block; 133 | width: 2px; 134 | } 135 | .suggestions-subtext_label { 136 | margin: 0 0 0 0.25em; 137 | -webkit-border-radius: 3px; 138 | -moz-border-radius: 3px; 139 | border-radius: 3px; 140 | padding: 0 3px; 141 | background: #f5f5f5; 142 | font-size: 85%; 143 | } 144 | .suggestions-value[data-suggestion-status="LIQUIDATED"] { 145 | position: relative; 146 | } 147 | .suggestions-value[data-suggestion-status="LIQUIDATED"]:after { 148 | position: absolute; 149 | left: 0; 150 | right: 0; 151 | top: 50%; 152 | border-top: 1px solid rgba(0, 0, 0, 0.4); 153 | content: ''; 154 | } 155 | -------------------------------------------------------------------------------- /custom/assets/js/jquery.suggestions.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DaData.ru Suggestions jQuery plugin, version 16.8.9 3 | * 4 | * DaData.ru Suggestions jQuery plugin is freely distributable under the terms of MIT-style license 5 | * Built on DevBridge Autocomplete for jQuery (https://github.com/devbridge/jQuery-Autocomplete) 6 | * For details, see https://github.com/hflabs/suggestions-jquery 7 | */ 8 | !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){"use strict";function b(b,c){var d=this;d.element=b,d.el=a(b),d.suggestions=[],d.badQueries=[],d.selectedIndex=-1,d.currentValue=d.element.value,d.intervalId=0,d.cachedResponse={},d.enrichmentCache={},d.currentRequest=null,d.inputPhase=a.Deferred(),d.fetchPhase=a.Deferred(),d.enrichPhase=a.Deferred(),d.onChangeTimeout=null,d.triggering={},d.$wrapper=null,d.options=a.extend({},k,c),d.classes={hint:"suggestions-hint",mobile:"suggestions-mobile",nowrap:"suggestions-nowrap",selected:"suggestions-selected",suggestion:"suggestions-suggestion",subtext:"suggestions-subtext",subtext_inline:"suggestions-subtext suggestions-subtext_inline",subtext_delimiter:"suggestions-subtext-delimiter",subtext_label:"suggestions-subtext suggestions-subtext_label",removeConstraint:"suggestions-remove",value:"suggestions-value"},d.disabled=!1,d.selection=null,d.$viewport=a(window),d.$body=a(document.body),d.type=null,d.status={},d.setupElement(),d.initializer=a.Deferred(),d.el.is(":visible")?d.initializer.resolve():d.deferInitialization(),d.initializer.done(a.proxy(d.initialize,d))}var c={ENTER:13,ESC:27,TAB:9,SPACE:32,UP:38,DOWN:40},d={},e=".suggestions",f="suggestions",g="\\s\"'~\\*\\.,:\\|\\[\\]\\(\\)\\{\\}<>№",h=new RegExp("["+g+"]+","g"),i="\\-\\+\\/\\\\\\?!@#$%^&",j=new RegExp("["+i+"]+","g"),k={autoSelectFirst:!1,serviceUrl:null,onSearchStart:a.noop,onSearchComplete:a.noop,onSearchError:a.noop,onSuggestionsFetch:null,onSelect:null,onSelectNothing:null,onInvalidateSelection:null,minChars:1,deferRequestBy:100,params:{},paramName:"query",timeout:3e3,formatResult:null,formatSelected:null,noCache:!1,containerClass:"suggestions-suggestions",tabDisabled:!1,triggerSelectOnSpace:!1,triggerSelectOnEnter:!0,triggerSelectOnBlur:!0,preventBadQueries:!1,hint:"Выберите вариант или продолжите ввод",type:null,requestMode:"suggest",count:5,$helpers:null,headers:null,scrollOnFocus:!0,mobileWidth:980,initializeInterval:100},l={chains:{},on:function(a,b){return this.get(a).push(b),this},get:function(a){var b=this.chains;return b[a]||(b[a]=[])}},m=function(){var b=0;return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},escapeHtml:function(b){var c={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return b&&a.each(c,function(a,c){b=b.replace(new RegExp(a,"g"),c)}),b},getDefaultType:function(){return a.support.cors?"POST":"GET"},getDefaultContentType:function(){return a.support.cors?"application/json":"application/x-www-form-urlencoded"},fixURLProtocol:function(b){return a.support.cors?b:b.replace(/^https?:/,location.protocol)},addUrlParams:function(b,c){return b+(/\?/.test(b)?"&":"?")+a.param(c)},serialize:function(b){return a.support.cors?JSON.stringify(b,function(a,b){return null===b?void 0:b}):a.param(b,!0)},compact:function(b){return a.grep(b,function(a){return!!a})},delay:function(a,b){return setTimeout(a,b||0)},uniqueId:function(a){return(a||"")+ ++b},slice:function(a,b){return Array.prototype.slice.call(a,b)},indexBy:function(b,c,d){var e={};return a.each(b,function(b,f){var g=f[c],h={};d&&(h[d]=b),e[g]=a.extend(!0,h,f)}),e},areSame:function c(b,d){var e=!0;return typeof b!=typeof d?!1:"object"==typeof b&&null!=b&&null!=d?(a.each(b,function(a,b){return e=c(b,d[a])}),e):b===d},arrayMinus:function(b,c){return c?a.grep(b,function(b,d){return-1===a.inArray(b,c)}):b},arrayMinusWithPartialMatching:function(b,c){return c?a.grep(b,function(a,b){return!c.some(function(b){return 0===b.indexOf(a)})}):b},getWords:function(a,b){a=a.replace(/(\d+)([а-яА-ЯёЁ]{2,})/g,"$1 $2").replace(/([а-яА-ЯёЁ]+)(\d+)/g,"$1 $2");var c=this.compact(a.split(h)),d=c.pop(),e=this.arrayMinus(c,b);return e.push(d),e},normalize:function(a,b){var c=this;return c.getWords(a,b).join(" ")},stringEncloses:function(a,b){return a.length>b.length&&-1!==a.indexOf(b)},fieldsNotEmpty:function(b,c){if(!a.isPlainObject(b))return!1;var d=!0;return a.each(c,function(a,c){return d=!!b[c]}),d},getDeepValue:function d(a,b){var c=b.split("."),e=c.shift();return a&&(c.length?d(a[e],c.join(".")):a[e])},reWordExtractor:function(){return new RegExp("([^"+g+"]*)(["+g+"]*)","g")},formatToken:function(a){return a&&a.toLowerCase().replace(/[ёЁ]/g,"е")},withSubTokens:function(b){var c=[];return a.each(b,function(a,b){var d=b.split(j);c.push(b),d.length>1&&(c=c.concat(m.compact(d)))}),c}}}(),n=function(){function b(b){return function(c){if(0===c.length)return!1;if(1===c.length)return!0;var d=b(c[0].value),e=a.grep(c,function(a){return 0===b(a.value).indexOf(d)},!0);return 0===e.length}}var c=b(function(a){return a}),d=b(function(a){return a.replace(/, (?:д|вл|двлд|к) .+$/,"")});return{matchByNormalizedQuery:function(b,c){var d=b.toLowerCase(),e=this&&this.stopwords,f=m.normalize(d,e),g=[];return a.each(c,function(a,b){var c=b.value.toLowerCase();return m.stringEncloses(d,c)?!1:c.indexOf(f)>0?!1:void(f===m.normalize(c,e)&&g.push(a))}),1===g.length?g[0]:-1},matchByWords:function(b,d){var e,f=this&&this.stopwords,g=b.toLowerCase(),h=[];return c(d)&&(e=m.withSubTokens(m.getWords(g,f)),a.each(d,function(a,b){var c=b.value.toLowerCase();if(m.stringEncloses(g,c))return!1;var d=m.withSubTokens(m.getWords(c,f));0===m.arrayMinus(e,d).length&&h.push(a)})),1===h.length?h[0]:-1},matchByWordsAddress:function(b,c){var e,f=this&&this.stopwords,g=b.toLowerCase(),h=-1;return d(c)&&(e=m.withSubTokens(m.getWords(g,f)),a.each(c,function(a,b){var c=b.value.toLowerCase();if(m.stringEncloses(g,c))return!1;var d=m.withSubTokens(m.getWords(c,f));return 0===m.arrayMinus(e,d).length?(h=a,!1):void 0})),h},matchByFields:function(b,c){var d=this&&this.stopwords,e=this&&this.fieldsStopwords,f=m.withSubTokens(m.getWords(b.toLowerCase(),d)),g=[];return 1===c.length&&(e&&a.each(e,function(a,b){var d=m.getDeepValue(c[0],a),e=d&&m.withSubTokens(m.getWords(d.toLowerCase(),b));e&&e.length&&(g=g.concat(e))}),0===m.arrayMinusWithPartialMatching(f,g).length)?0:-1}}}();!function(){function b(a,b){var c=a.data&&a.data[b];return c&&new RegExp("^"+m.escapeRegExChars(c)+"(["+g+"]|$)","i").test(a.value)}function c(a,b){return i.test(b)&&!i.test(a)?b:a}function e(a,b,d,e,f){var g=this,h=g.highlightMatches(a,d,e,f),i=g.highlightMatches(b,d,e,f);return c(h,i)}var f=["ао","аобл","дом","респ","а/я","аал","автодорога","аллея","арбан","аул","б-р","берег","бугор","вал","вл","волость","въезд","высел","г","городок","гск","д","двлд","днп","дор","дп","ж/д_будка","ж/д_казарм","ж/д_оп","ж/д_платф","ж/д_пост","ж/д_рзд","ж/д_ст","жилзона","жилрайон","жт","заезд","заимка","зона","к","казарма","канал","кв","кв-л","км","кольцо","комн","кордон","коса","кп","край","линия","лпх","м","массив","местность","мкр","мост","н/п","наб","нп","обл","округ","остров","оф","п","п/о","п/р","п/ст","парк","пгт","пер","переезд","пл","пл-ка","платф","погост","полустанок","починок","пр-кт","проезд","промзона","просек","просека","проселок","проток","протока","проулок","р-н","рзд","россия","рп","ряды","с","с/а","с/мо","с/о","с/п","с/с","сад","сквер","сл","снт","спуск","ст","ст-ца","стр","тер","тракт","туп","у","ул","уч-к","ф/х","ферма","х","ш","бульвар","владение","выселки","гаражно-строительный","город","деревня","домовладение","дорога","квартал","километр","комната","корпус","литер","леспромхоз","местечко","микрорайон","набережная","область","переулок","платформа","площадка","площадь","поселение","поселок","проспект","разъезд","район","республика","село","сельсовет","слобода","сооружение","станица","станция","строение","территория","тупик","улица","улус","участок","хутор","шоссе"],h=[{id:"kladr_id",fields:["kladr_id"],forBounds:!1,forLocations:!0},{id:"postal_code",fields:["postal_code"],forBounds:!1,forLocations:!0},{id:"country",fields:["country"],forBounds:!1,forLocations:!0},{id:"region",fields:["region","region_type","region_type_full","region_with_type"],forBounds:!0,forLocations:!0,kladrFormat:{digits:2,zeros:11}},{id:"area",fields:["area","area_type","area_type_full","area_with_type"],forBounds:!0,forLocations:!0,kladrFormat:{digits:5,zeros:8}},{id:"city",fields:["city","city_type","city_type_full","city_with_type"],forBounds:!0,forLocations:!0,kladrFormat:{digits:8,zeros:5}},{id:"city_district",fields:["city_district","city_district_type","city_district_type_full","city_district_with_type"],forBounds:!1,forLocations:!1},{id:"settlement",fields:["settlement","settlement_type","settlement_type_full","settlement_with_type"],forBounds:!0,forLocations:!0,kladrFormat:{digits:11,zeros:2}},{id:"street",fields:["street","street_type","street_type_full","street_with_type"],forBounds:!0,forLocations:!0,kladrFormat:{digits:15,zeros:2}},{id:"house",fields:["house","house_type","house_type_full","block","block_type"],forBounds:!0,forLocations:!1,kladrFormat:{digits:19}}],i=//,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 | --------------------------------------------------------------------------------