1/** 2 * @version 1.1.0 3 */ 4 5/** 6 * @type Boolean 7 */ 8window.mcc_debug = true; 9 10function mcc_assocArraySize( obj ) 11{ 12 var size = 0, key; 13 for( key in obj ) 14 { 15 if( obj.hasOwnProperty( key ) ) 16 { 17 size++; 18 } 19 } 20 return size; 21} 22jQuery( document ).ready( function() 23{ 24 document.oncopy = window.mcc_ui_oncopy; 25 26 window.mcc_ui_onready(); 27 window.mcc_ui_resize(); 28} ); 29 30jQuery( window ).resize( function() 31{ 32 window.mcc_ui_resize(); 33} ); 34 35window.mcc_ui_oncopy = function() 36{ 37 var body_element = document.getElementsByTagName( 'body' )[0]; 38 39 var html = ""; 40 if( typeof window.getSelection != "undefined" ) 41 { 42 var sel = window.getSelection(); 43 if( sel.rangeCount ) 44 { 45 var container = document.createElement( "div" ); 46 for( var i = 0, len = sel.rangeCount; i < len; ++i ) 47 { 48 container.appendChild( sel.getRangeAt( i ).cloneContents() ); 49 } 50 selection = container; 51 } 52 } 53 54 55 html = jQuery( selection ).html(); 56 57 var selection; 58 59 selection = window.getSelection(); 60 61 var pagelink = "\n [ЧиÑаÑÑ Ð´Ð°Ð»ÐµÐµ на " + document.location.href + "]"; 62 63 var copytext = html + pagelink; 64 65 var newdiv = document.createElement( 'div' ); 66 67 newdiv.style.position = 'absolute'; 68 newdiv.style.left = '-99999px'; 69 body_element.appendChild( newdiv ); 70 newdiv.innerHTML = copytext; 71 selection.selectAllChildren( newdiv ); 72 window.setTimeout( function() { 73 body_element.removeChild( newdiv ); 74 }, 0 ); 75} 76 77/** 78 * @deprecated 1.1.0 79 */ 80window.mcc_ui_resize = function() 81{ 82 return false; 83 jQuery( '.mcc_form_countryicon' ).each( function( index ) 84 { 85 /* 86 var input = jQuery(this).parent().find('.mcc-select-country'); 87 var img_offset = {}; 88 var img_height=input.height(); 89 img_offset.top = input.offset().top; 90 //img_offset.left = input.offset().left + input.innerWidth() * 0.885 - 0; 91 img_offset.left = input.offset().left + input.innerWidth() - img_height - 0; 92 93 jQuery(this).css('top',img_height/4).offset(img_offset).height(img_height); 94 */ 95 var input = jQuery( this ).parent().find( '.mcc-select-country' ); 96 97 if( input.length == 0 ) 98 { 99 return; 100 } 101 102 var img_height = input.innerHeight() + 2; 103 var margin_top = parseInt( input.css( 'margin-top' ).replace( 'px', '' ) ); 104 var top = margin_top > 0 ? margin_top : 2; 105 var left = input.innerWidth() - img_height - 0; 106 107 jQuery( this ).css( 'position', 'absolute' ).css( 'top', top ).css( 'left', left ).height( img_height ); 108 } ); 109 110 jQuery( '.mcc_form_cityicon' ).each( function( index ) 111 { 112 var input = jQuery( this ).parent().find( '.mcc-select-city' ); 113 114 if( input.length == 0 ) 115 { 116 return; 117 } 118 119 var img_height = input.innerHeight() + 2; 120 var margin_top = parseInt( input.css( 'margin-top' ).replace( 'px', '' ) ); 121 var top = margin_top > 0 ? margin_top : 2; 122 var left = input.innerWidth() - img_height - 0; 123 124 jQuery( this ).css( 'position', 'absolute' ).css( 'top', top ).css( 'left', left ).height( img_height ); 125 } ); 126} 127 128/** 129 * 130 */ 131window.mcc_captcha_check = function( param ) 132{ 133 return true; 134 if( typeof param['server_param']['key'] == 'undefined' ) 135 { 136 param['server_param']['key'] = ''; 137 } 138 139 var ret = false;
140 jQuery.ajax( 141 { 142 url : param['server'], 143 data : param['server_param'], 144 cache : false, 145 async : false, 146 success : function( data ) 147 { 148 ret = data; 149 } 150 } ); 151 152 return ret; 153} 154 155/** 156 * 157 */ 158window.mcc_captcha_new = function( prefiks, param ) 159{ 160 jQuery.ajax( 161 { 162 url : param['server'], 163 data : param['server_tpl'], 164 cache : false, 165 async : false, 166 success : function( data ) 167 { 168 jQuery( prefiks + '#' + param['server_tpl']['captcha_id'] ).parent().html( data ); 169 } 170 } ); 171 172 return true; 173} 174 175/** 176 * 177 */ 178window.mcc_ui_onready = function() 179{ 180 var maskList = jQuery.masksSort( jQuery.masksLoad( window.mcc_directory + "UI/jquery-inputmask-multi-phone-codes.json" ), [ '#' ], /[0-9]|#/, "mask" ); 181 var maskOpts = { 182 inputmask : { 183 definitions : { 184 '#' : { 185 validator : "[0-9]", 186 cardinality : 1 187 } 188 }, 189 //clearIncomplete: true, 190 showMaskOnHover : false, 191 autoUnmask : true 192 }, 193 match : /[0-9]/, 194 replace : '#', 195 list : maskList, 196 listKey : "mask", 197 onMaskChange : function( maskObj, determined ) 198 { 199 //$( this ).attr( "placeholder", $( this ).inputmask( "getemptymask" ) ); 200 } 201 }; 202 203 jQuery( '.mcc-value-phone .mcc-form-input' ).inputmasks( maskOpts ); 204 205 return; 206 setTimeout( function() 207 { 208 jQuery( '.mcc_form_countryicon' ).click( function( event ) 209 { 210 //var v = jQuery(this).parent().find('.mcc-select-country').autocomplete_mcc_country("widget").is(":visible"); 211 var id = jQuery( this ).parent().find( '.mcc-select-country' ).autocomplete_mcc_country( 'widget' ).attr( 'id' ); 212 var v = window.mcc_ui_temp[id + '_visible']; 213 214 if( v ) 215 { 216 jQuery( this ).parent().find( '.mcc-select-country' ).autocomplete_mcc_country( "close" ); 217 } 218 else 219 { 220 jQuery( this ).parent().find( '.mcc-select-country' ).focus(); 221 } 222 223 event.stopPropagation(); 224 return false; 225 } ); 226 227 // 228 jQuery( '.mcc_form_cityicon' ).click( function() 229 { 230 var id = jQuery( this ).parent().find( '.mcc-select-city' ).autocomplete( 'widget' ).attr( 'id' ); 231 var v = window.mcc_ui_temp[id + '_visible']; 232 233 if( v ) 234 { 235 jQuery( this ).parent().find( '.mcc-select-city' ).autocomplete( "close" ); 236 } 237 else 238 { 239 jQuery( this ).parent().find( '.mcc-select-city' ).focus(); 240 } 241 242 } ); 243 }, 100 ); 244} 245 246window.mcc_ui_temp = {} 247 248/** 249 * @class mcc_exception 250 */ 251window.mcc_exception = function( message ) 252{ 253 this.message = message; 254 this.code = null; 255 this.stack = ( new Error() ).stack; 256} 257window.mcc_exception.prototype = new Error(); 258 259/** 260 * @class 261 */ 262window.mcc_class_ui_handlers = function() 263{ 264 /** 265 * @private 266 * @type {mcc_class_ui_handlers} 267 */ 268 var self = this; 269 270 /** 271 * Handlers 272 * @private 273 * @type {Object} 274 */ 275 var H = {}; 276 277 /** 278 * Getter 279 * @public 280 * @param {string} key 281 * @return {function|null} 282 */ 283 this.get = function( key ) 284 { 285 return typeof H[key] == 'undefined' ? null : H[key]; 286 } 287 288 /** 289 * Setter 290 * @public 291 * @param {string} key 292 * @param {function} func 293 * @return {bool} 294 */ 295 this.set = function( key, func ) 296 { 297 if( typeof func == 'function' ) 298 { 299 H[key] = func; 300 return true; 301 } 302 else 303 { 304 return false; 305 } 306 } 307 308 /** 309 * Execer :) 310 * @public 311 * @param {string} key 312 * @param {Object} params 313 * @param {bool|true} t throw exception on error? 314 * @exception {mcc_exception} 315 * @return {mixed} 316 */ 317 this.exec = function( key, params, t ) 318 { 319 var e = self.get( key ); 320 321 t = typeof t == 'undefined' ? true : t; 322 params = typeof params == 'undefined' ? null : params; 323 324 if( typeof e != 'function' ) 325 { 326 if( t ) 327 { 328 throw new window.mcc_exception( 'Exec error "' + key + '"' ); 329 } 330 else 331 { 332 return null; 333 } 334 335 } 336 else 337 { 338 return e( params ); 339 } 340 } 341} 342 343window.mcc_ui_handler_form = new window.mcc_class_ui_handlers(); 344window.mcc_ui_handler_formOCC = new window.mcc_class_ui_handlers(); 345 346/**
347 * Error counter 348 */ 349window.mcc_error_counter = 0; 350 351/** 352 * 353 */ 354window.mcc_in_error = false; 355 356/** 357 * Error message 358 * @function 359 * @param {Object} params 360 * @return {bool|null} 361 */ 362window.mcc_ui_form_error_message = function( params ) 363{ 364 if( window.mcc_in_error ) 365 { 366 return null; 367 } 368 369 var id; 370 var text; 371 var prefiks; 372 var focus; 373 374 if( typeof params.text != 'undefined' ) 375 { 376 text = params.text; 377 } 378 else 379 { 380 text = params.text = 'Unknow error'; 381 } 382 383 if( typeof params.id != 'undefined' ) 384 { 385 id = params.id; 386 } 387 else 388 { 389 alert( text ); 390 return false; 391 } 392 393 if( typeof params.prefiks != 'undefined' ) 394 { 395 prefiks = params.prefiks; 396 } 397 else 398 { 399 alert( text ); 400 return false; 401 } 402 403 focus = typeof params.focus == 'undefined' ? true : params.focus; 404 405 if( jQuery( prefiks + '#' + id ).length == 0 ) 406 { 407 alert( text ); 408 return false; 409 } 410 411 window.mcc_in_error = true; 412 var box = window.mcc_ui_handler_form.exec( 'ErrorBox', params ); 413 414 jQuery( prefiks + "#" + id ).css( 'border', '2px solid red' ).parent().append( box.box ); 415 416 jQuery( prefiks + "#" + box.id ).slideDown( 'slow' ).delay( 2000 ).slideUp( 'slow', function() 417 { 418 jQuery( prefiks + "#" + box.id ).remove(); 419 jQuery( prefiks + "#" + id ).css( 'border', '' ); 420 421 window.mcc_in_error = false; 422 } ); 423 424 if( focus ) 425 { 426 jQuery( prefiks + "#" + id ).focus(); 427 } 428 429 return true; 430} 431 432/** 433 * Error Box 434 * @function 435 * @param {Object} params 436 * @return {Object} 437 */ 438window.mcc_ui_form_error_box = function( params ) 439{ 440 window.mcc_error_counter++; 441 var identificator = 'mcc_error' + window.mcc_error_counter; 442 return { 443 box : "<div class='mcc_error' id='" + identificator + "' style='display:none;'>" + params.text + "</div>", 444 id : identificator 445 }; 446} 447 448/* Widgets */ 449window.mcc_widget_create_country = function( selector, D_CountryTop, D_CountryList, D_CountryLang, D_CityList ) 450{ 451 var isDeprecated = !( typeof D_CountryTop === 'undefined' ); 452 453 var CountryList, CountryLang, RegionList, CityList, CountryTop; 454 455 if( isDeprecated ) 456 { 457 if( window.mcc_debug ) 458 { 459 console.log( 'mcc_widget_create_country mode Deprecated' ); 460 } 461 462 CountryList = D_CountryList; 463 CountryLang = D_CountryLang; 464 CityList = D_CityList; 465 CountryTop = D_CountryTop; 466 } 467 else 468 { 469 if( window.mcc_debug ) 470 { 471 console.log( 'mcc_widget_create_country mode Normal' ); 472 } 473 474 CountryList = window.mcc_country_data.countryGetList(); 475 CountryLang = window.mcc_country_data.countryGetLang(); 476 RegionList = window.mcc_country_data.regionGetList(); 477 CountryTop = window.mcc_country_data.countryGetTop(); 478 } 479 480 jQuery.widget( "custom.autocomplete_mcc_country", jQuery.ui.autocomplete, { 481 _renderMenu : function( ul, items ) { 482 var that = this; 483 var found = false; 484 485 jQuery.each( items, function( index, item ) 486 { 487 if( items.length > 1 ) 488 { 489 if( found === false ) 490 { 491 if( jQuery.inArray( item.value, CountryTop ) == -1 ) 492 { 493 ul.append( "<li class='ui-autocomplete-mcc-hr'><hr /></li>" ); 494 found = true; 495 } 496 } 497 } 498 499 that._renderItemData( ul, item ); 500 } ); 501 502 jQuery( ul ).find( 'li a:lt(3)' ).css( 'font-weight', 'bold' ); 503 }, 504 _renderItem : function( ul, item ) 505 { 506 var country = mcc_form_get_country( this.element ); 507 if( item.value == country ) 508 { 509 return jQuery( "<li>" ).append( jQuery( "<a style='font-weight:bold;'>" ).text( item.label ) ).appendTo( ul ); 510 } 511 else 512 { 513 return jQuery( "<li>" ).append( jQuery( "<a>" ).text( item.label ) ).appendTo( ul ); 514 } 515 } 516 } ); 517 518 if( isDeprecated ) 519 {
520 jQuery( selector ).autocomplete_mcc_country( { 521 change : mcc_form_CountryChangeAutocompleteDeprecated, 522 open : mcc_form_CountryOpenAutocomplete, 523 close : mcc_form_CountryCloseAutocomplete, 524 source : CountryList, 525 minLength : 0 526 } ); 527 528 jQuery( selector ).focus( function() 529 { 530 mcc_form_CountryFocusDeprecated( this, true, CountryLang, CityList, CountryList ); 531 } ); 532 jQuery( selector ).blur( function() 533 { 534 mcc_form_CountryBlurDeprecated( this, CountryLang, CountryList ); 535 } ); 536 } 537 else 538 { 539 jQuery( selector ).autocomplete_mcc_country( { 540 change : mcc_form_CountryChangeAutocomplete, 541 open : mcc_form_CountryOpenAutocomplete, 542 close : mcc_form_CountryCloseAutocomplete, 543 source : CountryList, 544 minLength : 0 545 } ); 546 547 jQuery( selector ).focus( function() 548 { 549 mcc_form_CountryFocus( this, true, CountryLang, RegionList, CountryList ); 550 } ); 551 jQuery( selector ).blur( function() 552 { 553 mcc_form_CountryBlur( this, CountryLang, CountryList ); 554 } ); 555 } 556 557 558} 559 560/** 561 * @deprecated 1.1.0 562 * @param {type} selector 563 * @param {type} MccCityList 564 * @param {type} CountryFull 565 * @param {type} MccCountryList 566 * @param {type} CountryLang 567 * @returns {undefined} 568 */ 569window.mcc_widget_create_city = function( selector, MccCityList, CountryFull, MccCountryList, CountryLang ) 570{ 571 this.mcc_form_CityChangeAutocomplete = function( event, ui ) 572 { 573 mcc_form_CityFocus( event.target, false, CountryFull, MccCountryList, CountryLang ); 574 } 575 576 jQuery( selector ).autocomplete( { 577 change : this.mcc_form_CityChangeAutocomplete, 578 close : mcc_form_CityCloseAutocomplete, 579 source : MccCityList, 580 minLength : 0 581 } ); 582 583 jQuery( selector ).focus( function() 584 { 585 mcc_form_CityFocus( this, true, CountryFull, MccCountryList, CountryLang ); 586 } ); 587 jQuery( selector ).blur( function() 588 { 589 mcc_form_CityFocus( this, false, CountryFull, MccCountryList, CountryLang ); 590 } ); 591 592 593} 594 595/** 596 * 597 * @param {string} selector 598 * @param {array} MccRegionList 599 * @param {array} CountryFull 600 * @param {array} MccCountryList 601 * @param {array} CountryLang 602 * @returns {undefined} 603 */ 604window.mcc_widget_create_region = function( selector ) 605{ 606 var RegionSelectAnother = window.mcc_country_data.regionGetOther(); 607 var CountryFull = window.mcc_country_data.countryGetFull(); 608 var CountryList = window.mcc_country_data.countryGetList(); 609 var CountryLang = window.mcc_country_data.countryGetLang(); 610 var RegionList = window.mcc_country_data.regionGetList(); 611 612 jQuery.widget( "custom.autocomplete_mcc_region", jQuery.ui.autocomplete, { 613 _renderMenu : function( ul, items ) { 614 var that = this; 615 616 /* 617 var _another = { 618 label : RegionSelectAnother, 619 value : RegionSelectAnother 620 }; 621 that._renderItemData( ul, _another ); 622 */ 623 624 jQuery.each( items, function( index, item ) 625 { 626 that._renderItemData( ul, item ); 627 } ); 628 }, 629 _renderItem : function( ul, item ) 630 { 631 return jQuery( "<li>" ).append( jQuery( "<a>" ).text( item.label ) ).appendTo( ul ); 632 } 633 } ); 634 635 this.mcc_form_RegionChangeAutocomplete = function( event, ui ) 636 { 637 mcc_form_RegionFocus( event.target, false, CountryFull, CountryList, CountryLang ); 638 } 639 640 jQuery( selector ).autocomplete_mcc_region( { 641 change : this.mcc_form_RegionChangeAutocomplete, 642 close : mcc_form_RegionCloseAutocomplete, 643 source : RegionList, 644 minLength : 0 645 } ); 646 647 jQuery( selector ).focus( function() 648 { 649 mcc_form_RegionFocus( this, true, CountryFull, CountryList, CountryLang ); 650 } ); 651 jQuery( selector ).blur( function() 652 { 653 mcc_form_RegionFocus( this, false, CountryFull, CountryList, CountryLang ); 654 } ); 655} 656 657/* Autocomplete Events */ 658 659/** 660 * @deprecated 1.1.0 661 * @param {type} event 662 * @param {type} ui 663 * @returns {undefined} 664 */ 665function mcc_form_CountryChangeAutocompleteDeprecated( event, ui ) 666{ 667 var _country = mcc_form_get_country( event.target ); 668 var _cities = mcc_form_get_cities_by_country( mcc_form_get_country_id_by_name( _country ) ); 669 670 if( _cities.length == 0 ) 671 { 672 jQuery( event.target ).parents( 'form' ).find( '.mcc_form_cityicon' ).slide
672Up( 'fast' ); 673 } 674 else 675 { 676 jQuery( event.target ).parents( 'form' ).find( '.mcc_form_cityicon' ).slideDown( 'fast' ); 677 } 678 679 window.mcc_ui_handler_form.exec( 'AutocompleteCountryChange', { 680 e : event, 681 u : ui, 682 country : _country, 683 cities : _cities, 684 deprecated : true 685 }, false ); 686} 687 688/** 689 * @param {type} event 690 * @param {type} ui 691 * @returns {undefined} 692 */ 693function mcc_form_CountryChangeAutocomplete( event, ui ) 694{ 695 var _country = mcc_form_get_country( event.target ); 696 var _regions = mcc_form_get_regions_by_country( mcc_form_get_country_data_by_name( _country ) ); 697 698 window.mcc_ui_handler_form.exec( 'AutocompleteCountryChange', { 699 e : event, 700 u : ui, 701 country : _country, 702 regions : _regions, 703 deprecated : false 704 }, false ); 705} 706 707function mcc_form_CountryOpenAutocomplete( event, ui ) 708{ 709 var w = jQuery( event.target ).autocomplete_mcc_country( "widget" ); 710 var e = event.target; 711 712 jQuery( w ).innerWidth( jQuery( e ).innerWidth() ); 713 jQuery( w ).innerHeight( jQuery( e ).innerWidth() ); 714 715 window.mcc_ui_handler_form.exec( 'AutocompleteCountryOpen', { 716 e : event, 717 u : ui 718 }, false ); 719} 720 721function mcc_form_CountryCloseAutocomplete( event, ui ) 722{ 723 var id = jQuery( event.target ).autocomplete_mcc_country( 'widget' ).attr( 'id' ); 724 window.mcc_ui_temp[id + '_visible'] = true; 725 726 setTimeout( function() 727 { 728 window.mcc_ui_temp[id + '_visible'] = false; 729 730 window.mcc_ui_handler_form.exec( 'AutocompleteCountryClose', { 731 e : event, 732 u : ui 733 }, false ); 734 }, 150 ); 735} 736 737/** 738 * Country. Focus 739 * @deprecated 1.1.0 740 * @param element DOM_Element 741 * @param search bool 742 * @param CountryLang Object 743 * @param MccCityList array 744 * @param MccCountryList array 745 * @return void 746 */ 747function mcc_form_CountryFocusDeprecated( element, search, CountryLang, MccCityList, MccCountryList ) 748{ 749 var _value = mcc_form_get_country( element ); 750 var _cities; 751 var _country = _value; 752 753 search = typeof search == 'undefined' ? true : search; 754 755 if( _value ) 756 { 757 if( search && jQuery.inArray( _value, MccCountryList ) == -1 ) 758 { 759 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 760 id : jQuery( element ).attr( 'id' ), 761 text : CountryLang.errors.UnknowCountry, 762 prefiks : mcc_form_get_prefiks( element ), 763 focus : false 764 } ); 765 } 766 else 767 { 768 var _countries = mcc_form_get_cities_by_country( mcc_form_get_country_id_by_name( _value ) ); 769 770 jQuery( element ).parents( 'form' ).find( '#mcc-city-select' ).autocomplete_mcc_country( "option", "source", _countries ); 771 } 772 773 if( search ) 774 { 775 jQuery( element ).autocomplete_mcc_country( 'search', '' ); 776 } 777 } 778 else 779 { 780 jQuery( element ).parents( 'form' ).find( '#mcc-city-select' ).autocomplete_mcc_country( "option", "source", MccCityList ); 781 782 if( search ) 783 { 784 jQuery( element ).autocomplete_mcc_country( 'search', '' ); 785 } 786 } 787 788 _cities = mcc_form_get_cities_by_country( mcc_form_get_country_id_by_name( _country ) ); 789 790 window.mcc_ui_handler_form.exec( 'AutocompleteCountyFocus', { 791 country : _country, 792 list : MccCountryList, 793 cities : _cities, 794 deprecated : true 795 }, false ); 796} 797 798/** 799 * Country. Focus 800 * @param element DOM_Element 801 * @param search bool 802 * @param CountryLang Object 803 * @param MccCityList array 804 * @param MccCountryList array 805 * @return void 806 */ 807function mcc_form_CountryFocus( element, search, CountryLang, RegionList, CountryList ) 808{ 809 var _value = mcc_form_get_country( element ); 810 var _regions; 811 var _country = _value; 812 813 search = typeof search === 'undefined' ? true : search; 814 815 if( _value ) 816 { 817 if( search && jQuery.inArray( _value, CountryList ) == -1 ) 818 { 819 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 820 id : jQuery( element ).attr( 'id' ),
821 text : CountryLang.errors.UnknowCountry, 822 prefiks : mcc_form_get_prefiks( element ), 823 focus : false 824 } ); 825 } 826 else 827 { 828 _regions = mcc_form_get_regions_by_country( mcc_form_get_country_data_by_name( _value ) ); 829 830 jQuery( element ).parents( 'form' ).find( '#mcc-city-select' ).autocomplete_mcc_country( "option", "source", _regions ); 831 } 832 833 if( search ) 834 { 835 jQuery( element ).autocomplete_mcc_country( 'search', '' ); 836 } 837 } 838 else 839 { 840 jQuery( element ).parents( 'form' ).find( '#mcc-region-select' ).autocomplete_mcc_country( "option", "source", RegionList ); 841 842 if( search ) 843 { 844 jQuery( element ).autocomplete_mcc_country( 'search', '' ); 845 } 846 } 847 848 _regions = mcc_form_get_regions_by_country( mcc_form_get_country_data_by_name( _country ) ); 849 850 window.mcc_ui_handler_form.exec( 'AutocompleteCountyFocus', { 851 country : _country, 852 list : CountryList, 853 regions : _regions, 854 deprecated : false 855 }, false ); 856} 857 858function mcc_form_CountryBlurDeprecated( element, CountryLang, MccCountryList ) 859{ 860 var _country = mcc_form_get_country( element ); 861 var _cities; 862 863 if( jQuery.inArray( _country, MccCountryList ) == -1 ) 864 { 865 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 866 id : jQuery( element ).attr( 'id' ), 867 text : CountryLang.errors.CityUnknowCountry, 868 prefiks : mcc_form_get_prefiks( element ), 869 focus : false 870 } ); 871 } 872 873 _cities = mcc_form_get_cities_by_country( mcc_form_get_country_id_by_name( _country ) ); 874 875 window.mcc_ui_handler_form.exec( 'AutocompleteCountyBlur', { 876 country : _country, 877 list : MccCountryList, 878 cities : _cities, 879 deprecated : true 880 }, false ); 881} 882 883function mcc_form_CountryBlur( element, CountryLang, CountryList ) 884{ 885 var _country = mcc_form_get_country( element ); 886 var _regions; 887 888 if( jQuery.inArray( _country, CountryList ) == -1 ) 889 { 890 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 891 id : jQuery( element ).attr( 'id' ), 892 text : CountryLang.errors.CityUnknowCountry, 893 prefiks : mcc_form_get_prefiks( element ), 894 focus : false 895 } ); 896 } 897 898 _regions = mcc_form_get_regions_by_country( mcc_form_get_country_data_by_name( _country ) ); 899 900 window.mcc_ui_handler_form.exec( 'AutocompleteCountyBlur', { 901 country : _country, 902 list : CountryList, 903 regions : _regions 904 }, false ); 905} 906 907 908/** 909 * @deprecated 1.1.0 910 * @param {type} event 911 * @param {type} ui 912 * @returns {undefined} 913 */ 914function mcc_form_CityCloseAutocomplete( event, ui ) 915{ 916 var id = jQuery( event.target ).autocomplete( 'widget' ).attr( 'id' ); 917 window.mcc_ui_temp[id + '_visible'] = true; 918 919 setTimeout( function() 920 { 921 window.mcc_ui_temp[id + '_visible'] = false; 922 923 window.mcc_ui_handler_form.exec( 'AutocompleteCityClose', { 924 e : event, 925 u : ui 926 }, false ); 927 928 }, 150 ); 929} 930 931/** 932 * @deprecated 1.1.0 933 * @param {type} element 934 * @param {type} search 935 * @param {type} CountryFull 936 * @param {type} MccCountryList 937 * @param {type} CountryLang 938 * @returns {undefined} 939 */ 940function mcc_form_CityFocus( element, search, CountryFull, MccCountryList, CountryLang ) 941{ 942 var key = null; 943 var _country = mcc_form_get_country( element ); 944 945 var _city = jQuery( element ).val(); 946 var city = mcc_form_get_city_full( _city ); 947 var _countries = CountryFull; 948 949 var _cities; 950 951 if( city != null ) 952 { 953 for( key in _countries ) 954 { 955 if( _countries[key]['id'] == city['id_country'] ) 956 { 957 mcc_form_set_country( element, _countries[key]['name'] ); 958 break; 959 } 960 } 961 } 962 963 964 search = typeof search == 'undefined' ? true : search; 965 966 window.temp = [ _country, MccCountryList ]; 967 968 if( _country ) 969 { 970 if( jQuery.inArray( _country, MccCountryList ) == -1 ) 971 { 972 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 973 id : jQuery( element ).attr( 'id' ),
974 text : CountryLang.errors.CityUnknowCountry, 975 prefiks : mcc_form_get_prefiks( element ), 976 focus : false 977 } ); 978 } 979 else 980 { 981 if( search == true ) 982 { 983 _cities = mcc_form_get_cities_by_country( mcc_form_get_country_id_by_name( _country ) ); 984 985 if( _cities.length == 0 ) 986 { 987 jQuery( element ).parent().find( '.mcc_form_cityicon' ).slideUp( 'fast' ); 988 } 989 else 990 { 991 jQuery( element ).parent().find( '.mcc_form_cityicon' ).slideDown( 'fast' ); 992 } 993 994 jQuery( element ).autocomplete( "option", "source", _cities ); 995 jQuery( element ).autocomplete( 'search', '' ); 996 } 997 } 998 } 999 else 1000 { 1001 if( search == true ) 1002 { 1003 jQuery( element ).autocomplete( 'search', '' ); 1004 } 1005 } 1006 1007 window.mcc_ui_handler_form.exec( 'AutocompleteCityFocus', { 1008 country : _country, 1009 list : MccCountryList 1010 }, false ); 1011} 1012 1013function mcc_form_RegionCloseAutocomplete( event, ui ) 1014{ 1015 var id = jQuery( event.target ).autocomplete_mcc_region( 'widget' ).attr( 'id' ); 1016 window.mcc_ui_temp[id + '_visible'] = true; 1017 1018 setTimeout( function() 1019 { 1020 window.mcc_ui_temp[id + '_visible'] = false; 1021 1022 window.mcc_ui_handler_form.exec( 'AutocompleteRegionClose', { 1023 e : event, 1024 u : ui 1025 }, false ); 1026 1027 }, 150 ); 1028} 1029 1030function mcc_form_RegionFocus( element, search, CountryFull, CountryList, CountryLang ) 1031{ 1032 var key = null; 1033 var _country = mcc_form_get_country( element ); 1034 1035 var _region = jQuery( element ).val(); 1036 var region = mcc_form_get_region_full( _region ); 1037 var _countries = CountryFull; 1038 var RegionSelectAnother = window.mcc_country_data.regionGetOther(); 1039 1040 var _regions; 1041 /* 1042 if( region !== null ) 1043 { 1044 for( key in _countries ) 1045 { 1046 if( _countries[key]['id'] == region['id_country'] ) 1047 { 1048 mcc_form_set_country( element, _countries[key]['name'] ); 1049 break; 1050 } 1051 } 1052 } 1053 */ 1054 1055 search = typeof search === 'undefined' ? true : search; 1056 1057 window.temp = [ _country, CountryList ]; 1058 1059 if( _country ) 1060 { 1061 if( jQuery.inArray( _country, CountryList ) == -1 ) 1062 { 1063 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 1064 id : jQuery( element ).attr( 'id' ), 1065 text : CountryLang.errors.CityUnknowCountry, 1066 prefiks : mcc_form_get_prefiks( element ), 1067 focus : false 1068 } ); 1069 } 1070 else 1071 { 1072 if( search == true ) 1073 { 1074 _regions = mcc_form_get_regions_by_country( mcc_form_get_country_data_by_name( _country ) ); 1075 _regions.push( { 1076 label : RegionSelectAnother, 1077 value : RegionSelectAnother 1078 } ); 1079 1080 jQuery( element ).autocomplete_mcc_region( "option", "source", _regions ); 1081 jQuery( element ).autocomplete_mcc_region( 'search', '' ); 1082 } 1083 } 1084 } 1085 else 1086 { 1087 if( search == true ) 1088 { 1089 jQuery( element ).autocomplete_mcc_region( 'search', '' ); 1090 } 1091 } 1092 1093 window.mcc_ui_handler_form.exec( 'AutocompleteRegionFocus', { 1094 country : _country 1095 }, false ); 1096} 1097 1098/* */ 1099 1100/** 1101 * 1102 * @param element DOM_Element 1103 * @return string 1104 */ 1105function mcc_form_get_prefiks( element ) 1106{ 1107 var J = jQuery( element ).parents( 'form.mcc-form' ); 1108 var F = J.get( 0 ); 1109 1110 if( typeof F.id != 'undefined' ) 1111 { 1112 return "#" + F.id + " "; 1113 } 1114 1115 return null; 1116 1117 1118} 1119 1120/** 1121 * 1122 * @param element DOM_Element 1123 * @return string 1124 */ 1125function mcc_form_get_country( element ) 1126{ 1127 var Form = jQuery( mcc_form_get_prefiks( element ) ); 1128 var Find = Form.find( '.mcc-select-country' ); 1129 1130 return Find.val(); 1131} 1132 1133/** 1134 * 1135 * @param element DOM_Element 1136 * @param value string 1137 * @return void 1138 */ 1139function mcc_form_set_country( element, value ) 1140{ 1141 jQuery( element ).parents( 'form' ).find( '.mcc-select-country' ).val( value ); 1142} 1143 1144/* Std country */ 1145 1146function mcc_StdCountrySelect( element ) 1147{ 1148 1149} 1150 1151function mcc_form_get_region_full( region ) 1152{ 1153 var key = null; 1154 var _regions = window.mcc_country_data.regionGetFull(); 1155 1156 for( key in _regions ) 1157 { 1158 if( _regions[key]['name'] == region || _regions[key]['id'] == region ) 1159 { 1160 return _regions[key]; 1161 } 1162 } 1163 1164 return null; 1165} 1166 1167function mcc_form_get_country_data_by_name( country, k ) 1168{ 1169 var key = null; 1170 var _country = window.mcc_country_data.countryGetFull(); 1171 1172 k = typeof k === 'undefined' ? 'id' : k; 1173 1174 for( key in _country ) 1175 { 1176 if( _country[key]['name'] == country ) 1177 { 1178 return _country[key][k]; 1179 } 1180 } 1181 1182 return null; 1183} 1184 1185/** 1186 * 1187 * @param {int} country 1188 * @param {bool} structured 1189 * @returns {array} 1190 */ 1191function mcc_form_get_regions_by_country( country, structured ) 1192{ 1193 var key = null; 1194 var _regions = window.mcc_country_data.regionGetStructured(); 1195 var _region; 1196 var _return = [ ]; 1197 1198 structured = typeof structured === 'undefined' ? false : structured; 1199 1200 for( key in _regions ) 1201 { 1202 for( _region in _regions[key] ) 1203 { 1204 if( _regions[key][_region]['id_country'] == country ) 1205 { 1206 if( structured ) 1207 { 1208 _return.push( _regions[key][_region] ); 1209 } 1210 else 1211 { 1212 _return.push( _regions[key][_region]['region'] ); 1213 } 1214 } 1215 } 1216 1217 } 1218 1219 return _return; 1220} 1221 1222window.mcc_ui_handler_form.set( 'ErrorBox', window.mcc_ui_form_error_box ); 1223window.mcc_ui_handler_form.set( 'ErrorMessage', window.mcc_ui_form_error_message ); 1224 1225/* OCC */ 1226 1227function mcc_OrderCertificateSubmitOCC( form, fields ) 1228{ 1229 if( window.mcc_debug ) 1230 { 1231 console.log( 'mcc_OrderCertificateSubmitOCC Start' ); 1232 } 1233 1234 var key; 1235 var prefiks = "#" + form.id + " "; 1236 var temp; 1237 var value; 1238 var langReqiuredTextEmpty = mcc_OrderCertificateOCC_Api( 'Lang.ReqiuredTextEmpty' ); 1239 var p = mcc_OrderCertificateOCC_Api( 'Prefiks' ); 1240 1241 for( key in fields ) 1242 { 1243 //If script Mootools.js exists in variable "fields" may contains functions 1244 temp = typeof fields[key]; 1245 1246 if( temp == 'object' ) 1247 { 1248 temp = typeof fields[key]['id']; 1249 1250 if( temp == 'string' ) 1251 { 1252 if( fields[key]['is_required'] == 1 ) 1253 { 1254 temp = prefiks + '#' + p + fields[key]['html']; 1255 value = jQuery( temp ).val(); 1256 1257 if( !value ) 1258 { 1259 try 1260 { 1261 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 1262 id : p + fields[key]['html'], 1263 text : langReqiuredTextEmpty[ fields[key]['type'] ], 1264 prefiks : prefiks 1265 } ); 1266 1267 if( window.mcc_debug ) 1268 { 1269 console.log( 'mcc_OrderCertificateSubmitOCC. Required. prefiks=%s id=%s text=%s', prefiks, p + fields[key]['html'], langReqiuredTextEmpty[ fields[key]['type'] ] ); 1270 } 1271 1272 return false;
1273 } 1274 catch( e ) 1275 { 1276 if( window.mcc_debug ) 1277 { 1278 console.log( 'mcc_OrderCertificateSubmitOCC Error' ); 1279 console.log( e ); 1280 console.log( fields[key] ); 1281 } 1282 } 1283 } 1284 } 1285 } 1286 else 1287 { 1288 1289 } 1290 } 1291 else 1292 { 1293 1294 } 1295 } 1296 1297 var captcha_text = jQuery( form ).find( 'input[name = "mcc_captcha"]' ).val(); 1298 var captcha_params = mcc_OrderCertificateOCC_Api( 'Captcha' ); 1299 var captcha_counter = jQuery( form ).find( 'input[name = "counter"]' ).val(); 1300 1301 captcha_params['server_param']['word'] = captcha_text; 1302 captcha_params['server_param']['key'] = 'MCC_Captcha_OrderCertificateOCC' + captcha_counter; 1303 captcha_params['server_tpl']['key'] = captcha_params['server_param']['key']; 1304 1305 var ret = mcc_captcha_check( captcha_params ); 1306 1307 if( window.mcc_debug ) 1308 { 1309 console.log( 'mcc_OrderCertificateSubmitOCC mcc_captcha_check = ' + ret ); 1310 } 1311 1312 if( ret == '0' ) 1313 { 1314 mcc_captcha_new( prefiks, captcha_params ); 1315 1316 window.mcc_ui_handler_form.exec( 'ErrorMessage', { 1317 id : captcha_params['id'], 1318 text : captcha_params['error_text'], 1319 prefiks : prefiks 1320 } ); 1321 1322 return false; 1323 } 1324 1325 return true; 1326} 1327 1328function mcc_order_certificate_occ_form_captcha_reload( element, capkey ) 1329{ 1330 var prefiks = mcc_form_get_prefiks( element ); 1331 var send = mcc_OrderCertificateOCC_Api( 'Captcha' ); 1332 var key = jQuery( jQuery( element ).parents( 'form.mcc-form' ).get( 0 ) ).find( 'input[name="counter"]' ).val(); 1333 1334 send['server_param']['word'] = jQuery( prefiks + '#mcc_captcha' ).val(); 1335 send['server_param']['key'] = capkey; 1336 send['server_tpl']['key'] = mcc_OrderCertificateOCC_Api( 'Captcha.Key' ) + key; 1337 1338 var ret = mcc_captcha_check( send ); 1339 1340 if( ret == '0' ) 1341 { 1342 mcc_captcha_new( prefiks, send ); 1343 1344 return true; 1345 } 1346 1347 return false; 1348} 1349 1350/** 1351 * @class 1352 * @returns {undefined} 1353 */ 1354window.mcc_class_country_data = function() 1355{ 1356 var _regionFull = [ ]; 1357 var _regionStructured = {}; 1358 var _regionList = {}; 1359 var _regionOther = ''; 1360 1361 var _countryFull = {}; 1362 var _countryMini = [ ]; 1363 var _countryTop = [ ]; 1364 var _countryLang = {}; 1365 1366 //----- 1367 1368 this.regionNeed = function() 1369 { 1370 return mcc_assocArraySize( _regionFull ) === 0; 1371 } 1372 1373 //----- 1374 1375 this.regionSetFull = function( data ) 1376 { 1377 _regionFull = data; 1378 } 1379 1380 this.regionGetFull = function() 1381 { 1382 return _regionFull; 1383 } 1384 1385 //----- 1386 1387 this.regionSetStructured = function( data ) 1388 { 1389 _regionStructured = data; 1390 } 1391 1392 this.regionGetStructured = function() 1393 { 1394 return _regionStructured; 1395 } 1396 1397 //----- 1398 1399 this.regionSetFull = function( data ) 1400 { 1401 _regionFull = data; 1402 } 1403 1404 this.regionGetFull = function() 1405 { 1406 return _regionFull; 1407 } 1408 1409 //----- 1410 1411 this.regionSetList = function( data ) 1412 { 1413 _regionList = data; 1414 } 1415 1416 this.regionGetList = function() 1417 { 1418 return _regionList; 1419 } 1420 1421 //----- 1422 1423 this.regionSetOther = function( data ) 1424 { 1425 _regionOther = data; 1426 } 1427 1428 this.regionGetOther = function() 1429 { 1430 return _regionOther; 1431 } 1432 1433 //-----\\ 1434 1435 this.countryNeed = function() 1436 { 1437 return mcc_assocArraySize( _countryFull ) === 0; 1438 } 1439 1440 this.countrySetFull = function( data ) 1441 { 1442 _countryFull = data; 1443 } 1444 1445 this.countryGetFull = function() 1446 { 1447 return _countryFull; 1448 } 1449 1450 //----- 1451 1452 this.countrySetMini = function( data ) 1453 { 1454 _countryMini = data; 1455 } 1456 1457 this.countryGetMini = function() 1458 { 1459 return _countryMini; 1460 } 1461 1462 this.countryGetList = function() 1463 { 1464 return _countryMini; 1465 } 1466 1467 this.countrySetTop = function( data ) 1468 { 1469 _countryTop = data; 1470 } 1471 1472 this.countryGetTop = function() 1473 { 1474 return _countryTop; 1475 } 1476 1477 //----- 1478 1479 this.countrySetLang = function( data ) 1480 { 1481 _countryLang = data; 1482 } 1483 1484 this.countryGetLang = function() 1485 { 1486 return _countryLang; 1487 } 1488} 1489 1490window.mcc_country_data = new window.mcc_class_country_data();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.