1if (typeof(app)=='undefined') var app = {}; 2 3/** 4 * Check if variable is defined 5 */ 6app.defined = function() { 7 var result = false; 8 var typeofthis = ''; 9 for (a = 0; a < arguments.length; a++) { 10 typeofthis = typeof(arguments[a]); 11 if (typeofthis.toLowerCase() != 'undefined') { 12 result = true; 13 } else { 14 return false; 15 } 16 } 17 return result; 18}; 19 20if (app.defined(ENV_TEST)) { 21 if (ENV_TEST === true) app.debugging = true; 22} else { 23 app.debugging = false; 24} 25 26/** 27 * Debug given variables. Add them to console.log 28 */ 29app.debug = function() { 30 if (typeof(console) != 'undefined' && app.debugging === true) { 31 for (x = 0; x < arguments.length; x++) { 32 console.log(arguments[x]); 33 } 34 } 35 else if(app.debugging === true) 36 { 37 for (x = 0; x < arguments.length; x++) { 38 pr(arguments[x]); 39 } 40 } 41}; 42 43/* 44app.reg = new Object(); 45app.reg.vars = new Object(); 46 47app.reg.get =function(key) 48{ 49 50} 51*/ 52 53 54app.fade_toggle = function(selector) { 55 56 element = $(selector); 57 58 if (element.css('display') == 'none') 59 { 60 61 element.fadeIn(); 62 } 63 else 64 { 65 element.fadeOut(); 66 } 67}; 68 69/** 70 * Prevent default behaviour 71 * @param e_prevent 72 */ 73app.prevent = function(e_prevent) { 74 e_prevent.preventDefault(); 75 return false; 76}; 77 78/** 79 * Get object size 80 * @param obj 81 */ 82app.objectsize = function(obj) { 83 var size = 0, key; 84 for (key in obj) { 85 if (obj.hasOwnProperty(key)) size++; 86 } 87 return size; 88}; 89 90/** 91 * Document ready function 92 */ 93$(document).ready(function(){ 94 95 // setup ajax requests 96 $.ajaxSetup({ 97 //url: "/xmlhttp/", 98 global: true 99 //type: "POST" 100 }); 101 102 /* 103 * Bind and fire functions for each successful ajax request 104 */ 105 app.ajax_success = { 106 binds: {}, 107 add: function(id, func) { 108 app.ajax_success.binds[id] = func; 109 }, 110 fire: function(scope) { 111 for (var id in app.ajax_success.binds) { 112 if (app.defined(app.ajax_success.binds[id])) { 113 if (typeof (app.ajax_success.binds[id]) == 'function') { 114 app.debug('firing ajax_success function for '+id); 115 app.ajax_success.binds[id](); 116 } 117 } 118 } 119 } 120 }; 121 122 /** 123 * Update all required page elements after page success 124 */ 125 app.ajax_update_elements = function(data) { 126 // fire all binded functions 127 for (var id in app.ajax_success.binds) { 128 if (app.defined(app.ajax_success.binds[id])) { 129 if (typeof (app.ajax_success.binds[id]) == 'function') { 130 app.debug('firing ajax_success function for '+id); 131 app.ajax_success.binds[id](); 132 } 133 } 134 } 135 return false; 136 }; 137 138 app.total_uri_params = 0;//app.objectsize(uri); 139 140 $(window).load( function() { 141 if (app.fullyready.timer) { 142 clearTimeout(app.fullyready.timer); 143 app.fullyready.timer = null; 144 } 145 //else 146 app.fullyready.fire(); 147 }); 148 149 app.fullyready = { 150 timer: setTimeout( function() { 151 if (app.fullyready.check_available()) { 152 app.fullyready.fire(); 153 } 154 }, 100), 155 156 check_available: function() { 157 var available = true; 158 $('img').each( function() { 159 try { 160 if (app.defined(this.height)) { 161 if (this.height == 0) { 162 available = false; 163 return false; 164 } 165 } 166 } 167 catch (e) { 168 available = false; 169 return false; 170 } 171 }); 172 return available; 173 }, 174 binds: {}, 175 add: function(id, func) { 176 app.fullyready.binds[id] = func; 177 }, 178 fire: function(scope) { 179 for (var id in app.fullyready.binds) { 180 if (app.defined(app.fullyready.binds[id])) { 181 if (typeof (app.fullyready.binds[id]) == 'function') { 182 //app.debug('firing fullyready function for '+id); 183 app.fullyready.binds[id](); 184 } 185 } 186 } 187 } 188 }; 189 190 if (!app.defined(app.uri)) app.uri = {}; 191 192 // get an uri path from uri segment start to uri segment end 193 app.uri.segments = function segments(start, end) { 194 if (!app.defined(end)) end = 0; 195 if (end > 0) { 196 var length = end-start+1; // length is calculated for array_slice function 197 } else { 198 if (app.defined(app.total_uri_params)) { 199 var length = app.total_uri_params - start+1; 200 end = app.total_uri_params; 201 } else { 202 end = app.objectsize(uri); 203 } 204 } 205 206 var return_str = ''; 207 for (a = start; a < end+1; a++) { 208 return_str += uri[a]; 209 if (a < end) return_str += '/'; 210 } 211 app.debug('app.uri.segments: i was asked for segments '+start+' to '+end+' ... i think this means: '+return_str); 212 return return_str; // sliced array, imploded with / is returned 213 }; 214 215 216 // ads 217// app.ads = { 218// fetch: function(scope, limit) { 219// if (!app.defined(scope)) scope = '#side_col'; 220// if (!app.defined(limit)) limit = 1; 221// app.debug('app.ads.fetch: fetching ads...'); 222// 223// if (!app.defined(uri['1'])) 224// var first_uri_param = '/'+uri['1']; 225// else 226// var first_uri_param = '/'+LANG; 227// 228// $.post(first_uri_param+'/ads/'+app.uri.segments(2), { limit: limit }, function(data) { 229// var possible_ads_container = $(scope); 230// if (possible_ads_container.size() > 0 && possible_ads_container.find('.ads').size() == 0) { 231// if (uri['2'] == 'home' && $('#membership_box').size() > 0) { 232// $('#membership_box').before(data); 233// } else { 234// $(data).appendTo(possible_ads_container); 235// } 236// } 237// }); 238// } 239// }; 240// 241// if (app.defined(uri['2'])) { 242// if (uri['2']!='pat') app.ads.fetch('#side_col', 2); 243// } 244 // end of ads 245 246 247// app.pinger = { 248// time: 45000, 249// url: '/'+uri['1']+'/pinger/do_ping', 250// ping: function() { 251// app.ajaxloader.disable(); 252// $.get(app.pinger.url, function(reply) { 253// app.ajaxloader.enable(); 254// if (reply > 0) { 255// app.debug('app.pinger.ping: ping sent and was OK!'); 256// } else { 257// app.debug('app.pinger.ping: ping sent but was NOT OK!'); 258// } 259// }); 260// }, 261// interval: '', 262// init: function() { 263// app.pinger.interval = setInterval(app.pinger.ping, app.pinger.time); 264// }, 265// stop: function() { 266// if (app.pinger.interval != '') clearInterval(app.pinger.interval); 267// app.pinger.interval = ''; 268// } 269// }; 270// 271// app.tracker = { 272// track_pageview: function(url) { 273// if ((typeof(pageTracker)).toLowerCase() != 'undefined') { 274// if ((typeof(pageTracker._trackPageview)).toLowerCase() != 'undefined') { 275// pageTracker._trackPageview(url); 276// app.debug('app.tracker.track_pageview: pageview tracked for url '+url); 277// } 278// } 279// } 280// }; 281 282 /** 283 * Translate function 284 */ 285 app.lang.t = function(str, replace_what, replace_with) { 286 287 if(typeof str_replace == 'function') 288 return str_replace(replace_what, replace_with, app.lang.keys[str]); 289 else 290 return str; 291 }; 292 293// app.global_signin = { 294// open_function: function(e) { 295// $(this).addClass('open'); 296// var position = $(this).position(); 297// $('.remove_with_signin_form').hide(); 298// app.debug('global_signin.open_function: '+position.left+' - '+parseInt($('#global_signin_form').css('width'))+' + '+$(this).width()+' + '+parseInt($(this).css('marginRight'))+' + ('+parseInt($(this).css('borderLeftWidth'))+' + '+parseInt($(this).css('borderRightWidth'))+')');
299// position.left = Math.ceil(position.left) - parseInt($('#global_signin_form').css('width')) + $(this).width() + parseInt($(this).css('marginRight')) + (parseInt($(this).css('borderLeftWidth')) + parseInt($(this).css('borderRightWidth'))); 300// position.top = position.top + parseInt($(this).css('marginTop')) + $(this).height() + (parseInt($(this).css('borderTopWidth')) + parseInt($(this).css('borderBottomWidth'))); 301// if ($.browser.mozilla) { 302// position.left+=1; 303// app.debug('global_signin.open_function: added 1 to position.left'); 304// } 305// 306// $('#global_signin_form').css({ 307// left: position.left+'px', 308// top: position.top+'px' 309// }).show().find('input[name=username]').focus(); 310// 311// $(document).mouseup(function(e) { 312// if ($(e.target).parents('#global_signin_form').size() == 0) { 313// app.global_signin.close_function(e); 314// } 315// }); 316// 317// $(this).unbind('click').bind('click', app.global_signin.close_function) 318// 319// e.preventDefault(); 320// return false; 321// }, 322// close_function: function(e) { 323// $('#global_signin_form').hide(); 324// $('.remove_with_signin_form').show(); 325// $('#global_signin_button').removeClass('open').unbind('click').bind('click', app.global_signin.open_function); 326// e.preventDefault(); 327// return false; 328// }, 329// init: function() { 330// $('#global_signin_button').unbind('click').bind('click', app.global_signin.open_function); 331// $('#global_signin_form form').bind('submit', function() { 332// app.ajaxloader.start(); 333// $('#global_login_button_submit').css('opacity', '0.5').bind('click', function(e) { 334// $(this).unbind('click'); 335// e.preventDefault(); 336// return false; 337// }); 338// }); 339// } 340// }; 341 342 343 app.singlesubmit = { 344 onsubmit_form: function(e_submit) { 345 app.debug('submit happened for singlesubmit form!'); 346 app.ajaxloader.start(); 347 $(this).find('input[type="submit"], button[type="submit"]').addClass('disabled').bind('click', app.prevent); 348 $(this).unbind('submit').bind('submit', app.prevent); 349 }, 350 init: function(scope) { 351 $(scope).find('.singlesubmit').bind('submit', app.singlesubmit.onsubmit_form); 352 } 353 }; 354 355 /** 356 * Confirm messages and submit 357 */ 358 app.confirm = { 359 init: function(scope) { 360 $(scope).find('.confirm').bind('click', function(e) { 361 var elem = this; 362 var additional_msg = ''; 363 364 if (app.defined($(elem).attr('id'))) { 365 if ($(elem).attr('id') != '' && $('#text_'+$(elem).attr('id')).html() != null) { 366 additional_msg = $('#text_'+$(elem).attr('id')).html() + " \n"; 367 } 368 } 369 370 if (window.confirm(additional_msg + app.lang.t('MESSAGES::Are you sure?'))) { 371 return true; 372 } else { 373 e.preventDefault(); 374 return false; 375 } 376 }); 377 $(scope).find('.confirm_remove').bind('click', function(e) { 378 379 var elem = this; 380 var additional_msg = ''; 381 382 if (app.defined($(elem).attr('id'))) { 383 if ($(elem).attr('id') != '') { 384 additional_msg = $('#text_'+$(elem).attr('id')).html() + " \n"; 385 } 386 } 387 if (window.confirm(additional_msg + app.lang.t('MESSAGES::Are you sure you want to delete this?'))) { 388 389 //app.debug('confirm_remove', app.defined($(elem).attr('href')), app.defined($(elem).attr('rel'))); 390 if (app.defined($(elem).attr('href')) && app.defined($(elem).attr('rel'))) { 391 $.post($(elem).attr('href'),'', function(data) { 392 if ($(elem).attr('rel') != '') { 393 $('#'+$(elem).attr('rel')).remove(); 394 395 } 396 }); 397 e.preventDefault(); 398 return false; 399 } 400 } else { 401 e.preventDefault(); 402 return false; 403 } 404 }); 405// $(scope).find('.confirm_flag').bind('click', function(e) { 406// if (window.confirm(app.lang.t('camp_are_you_sure'))) { 407// var elem = this; 408// $.get($(elem).attr('href'), function() { 409// alert('Thank you for your feedback!'); 410// }); 411// } 412// e.preventDefault(); 413// return false; 414// }); 415 } 416 }; 417 418 app.local_pagination = { 419 init: function(pagination_elem, scope) { 420 $(pagination_elem).find('a').unbind('click').bind('click', function(e) { 421 $.get($(this).attr('href'), function(data) { 422 $(scope).replaceWith($(data).find(scope)); 423 app.generic_init.fire(); 424 }); 425 e.preventDefault(); 426 return false;
427 }); 428 } 429 }; 430 431 /* 432 * Toggle type links 433 */ 434 app.toggle_links = { 435 init: function(scope) { 436 $(scope).find('.toggle[rel!=""]').each(function() { 437 var rel = $(this).attr('rel'); 438 if (!$(this).hasClass('opened')) { 439 $('#'+rel).hide(); 440 } else { 441 if (!$(this).hasClass('closed')) { 442 $('a.toggle[rel="'+rel+'"]').addClass('closed'); 443 } 444 } 445 $(this).bind('click', function(e) { 446 if ($(this).hasClass('opened')) { 447 $('#'+rel).slideUp('fast', function() { 448 if ( $('#'+rel).find('input[type!="hidden"][type!="submit"], textarea').size() == 1) { 449 $('#'+rel).find('input[type!="hidden"][type!="submit"]:first, textarea:first').focus(); 450 } 451 }); 452 $('a.toggle[rel="'+rel+'"]').addClass('closed').removeClass('opened'); 453 } else { 454 $('#'+rel).slideDown('fast', function() { 455 if ( $('#'+rel).find('input[type!="hidden"][type!="submit"], textarea').size() == 1) { 456 if ( $('#'+rel).find('iframe').size() == 1 ) { 457 var iframe = $('#'+rel).find('iframe').eq(0); 458 if (app.defined(iframe[0].contentWindow.focus)) { 459 iframe[0].contentWindow.focus(); 460 } 461 } else { 462 $('#'+rel).find('input[type!="hidden"][type!="submit"]:first, textarea:first').focus(); 463 } 464 } 465 }); 466 $('a.toggle[rel="'+rel+'"]').addClass('opened').removeClass('closed'); 467 } 468 e.preventDefault(); 469 return false; 470 }); 471 }); 472 } 473 }; 474 475 /** 476 * Add a global event or fire it 477 */ 478 app.globalevent = { 479 binds: {}, 480 add: function(trigger, new_binds) { 481 app.globalevent.binds[trigger] = new_binds; 482 }, 483 fire: function(event) { 484 if (typeof(app.globalevent.binds[event.type]) != 'undefined') { 485 if (typeof(app.globalevent.binds[event.type][event.keyCode]) == 'function') { 486 app.globalevent.binds[event.type][event.keyCode](event); 487 } 488 } 489 } 490 }; 491 492 /** 493 * Ajax links. Search for all <A>, where we have a class = ajax 494 */ 495 app.ajaxlinks = { 496 init: function(scope) { 497 $(scope).find('a.ajax[rel!=""]').bind('click', function(e) { 498 var elem = this; 499 var target = $(elem).attr('rel'); 500 $.get($(this).attr('href'), function(data) { 501 //app.debug('received ajaxlink content:', data); 502 if ($(data).filter('#'+target).size() > 0) { 503 var elem_from_data = $(data).filter('#'+target); 504 } else if ($(data).find('#'+target).size()) { 505 var elem_from_data = $(data).find('#'+target); 506 } 507 508 if ($(elem).hasClass('catchall')) { 509 $('#'+target).html(data); 510 app.generic_init.fire('#'+target); 511 } else { 512 if (app.defined(elem_from_data)) { 513 if (elem_from_data.size() > 0) { 514 app.debug('ajaxlinks.init: data received... rel-elements (#'+target+') found: '+elem_from_data.size()); 515 $('#'+target).html(elem_from_data.html()); 516 app.generic_init.fire('#'+target); 517 } else { 518 app.debug('ajaxlinks.init: ERROR! the requested element (#'+target+') was not found in ajax content'); 519 } 520 } 521 } 522 }); 523 e.preventDefault(); 524 return false; 525 }); 526 } 527 }; 528 529// app.tabs = { 530// init: function(scope) { 531// $(scope).find('a.tab').bind('click', function(e) { 532// $(this).parents('.tabs').children('a.tab').not(this).removeClass('active'); 533// $(this).addClass('active'); 534// }); 535// } 536// }; 537 538 /** 539 * Ajax loader div 540 */ 541 app.ajaxloader = { 542 loader: $('<div id="global_loader"><div id="global_loader2"><img src="/assets/templates/radicenter3/images/loading.gif" alt="'+app.lang.t('MESSAGES::Loading...')+'" /><br />' + app.lang.t('MESSAGES::Loading...') + '</div></div>'), 543 hideTimer: '', 544 timeOut: 500, 545 start: function() { 546 if (app.ajaxloader.enabled === true) { 547 $(app.ajaxloader.loader).show(); 548 app.ajaxloader.loading = true; 549 if (app.ajaxloader.hideTimer != '') { 550 clearTimeout(app.ajaxloader.hideTimer); 551 } 552 } 553 }, 554 stop: function() { 555 $(app.ajaxloader.loader).fadeOut('fast'); 556 if (app.ajaxloader.enabled === true) { 557 app.ajaxloader.loading = false; 558 if (app.ajaxloader.hideTimer != '') { 559 app.ajaxloader.hideTimer = setTimeout(function() { 560 $(app.ajaxloader.loader).fadeOut('fast'); 561 }, app.ajaxloader.timeOut); 562 } 563 } 564 }, 565 enabled: true, 566 enable: function() { 567 app.ajaxloader.enabled = true; 568 }, 569 disable: function() { 570 app.ajaxloader.enabled = false;
571 }, 572 loading: false, 573 init: function() { 574 app.ajaxloader.loader = $(app.ajaxloader.loader) 575 .appendTo('body') 576 .hide() 577 .ajaxStart(app.ajaxloader.start) 578 .ajaxStop(app.ajaxloader.stop); 579 } 580 }; 581 582 /** 583 * Ajax loader div 584 */ 585 app.domainloader = { 586 loader: $('<div id="global_loaderD"><div id="global_loaderD2"><img src="/assets/templates/radicenter3/images/loading.gif" alt="'+app.lang.t('MESSAGES(2019)::Contacting domain registry - please wait...')+'" /><br />' + app.lang.t('MESSAGES(2019)::Contacting domain registry - please wait...') + '</div></div>'), 587 hideTimer: '', 588 timeOut: 500, 589 start: function() { 590 if (app.domainloader.enabled === true) { 591 $(app.domainloader.loader).show(); 592 app.domainloader.loading = true; 593 if (app.domainloader.hideTimer != '') { 594 clearTimeout(app.domainloader.hideTimer); 595 } 596 } 597 }, 598 stop: function() { 599 $(app.domainloader.loader).fadeOut('fast'); 600 if (app.domainloader.enabled === true) { 601 app.domainloader.loading = false; 602 if (app.domainloader.hideTimer != '') { 603 app.domainloader.hideTimer = setTimeout(function() { 604 $(app.domainloader.loader).fadeOut('fast'); 605 }, app.domainloader.timeOut); 606 } 607 } 608 }, 609 enabled: true, 610 enable: function() { 611 app.domainloader.enabled = true; 612 }, 613 disable: function() { 614 app.domainloader.enabled = false; 615 }, 616 loading: false, 617 init: function() { 618 app.domainloader.loader = $(app.domainloader.loader) 619 .appendTo('body') 620 .hide() 621 .ajaxStart(app.domainloader.start) 622 .ajaxStop(app.domainloader.stop); 623 } 624 }; 625 626 /** 627 * jQuery Dialog sonfirmation box with custom message 628 * @param {string} message 629 * @return {Boolean} 630 */ 631 app.confirmed = function(message) { 632 633 $('#service_request').live('click', function (e) { 634 e.preventDefault(); 635 }); 636 637 if($('#service_request').attr('rel')==='webhosting'){ 638 let datex = new Date(); 639 // add a day 640 datex.setDate(datex.getDate() + 1); 641 var dateFormat = datex.getFullYear() + "-" +((datex.getMonth()+1).toString().length != 2 ? "0" + (datex.getMonth() + 1) : (datex.getMonth()+1)) + "-" + (datex.getDate().toString().length != 2 ?"0" + datex.getDate() : datex.getDate()); 642 643 let datex2 = $('#service_request').attr('rel2'); 644 645 message = message + '<div><br />' + app.lang.t('CLIENTENV(2023)::Please select removal date:') + '<form><input type="radio" id="del-sel-1" name="del-sel" value="opt1"> <label for="del-sel-1"> ' + dateFormat + ' (' + app.lang.t('CLIENTENV(2023)::Next date') + ')</label><br /> <input type="radio" id="del-sel-2" name="del-sel" value="opt2" checked><label for="del-sel-2"> ' + datex2 + ' (' + app.lang.t('CA_TABLE_COLUMN::Exp. date') + ')</label><br /><br /><br />'+ app.lang.t('CLIENTENV(2024)::NB! Account and all associated data will be permanently deleted!') +'</form></div>' 646 } 647 648 $('<div></div>').appendTo('body') 649 .html('<div>' + message + '</div>') 650 .dialog({ 651 modal: true, 652 zIndex: 10000, 653 autoOpen: true, 654 width: 'auto', 655 resizable: false, 656 buttons: [{ 657 id: "okButton", 658 text: "OK", 659 "class": "confirm_delete_yes_btn button small green ui-state-hover", 660 "click": function () { 661 let wloc = $('#service_request').attr('href'); 662 if($('#service_request').attr('rel')==='webhosting'){ 663 wloc = wloc + '?datex='+$("input[name='del-sel']:checked").val(); 664 } 665 666 window.location = wloc; 667 }}, 668 { 669 id: "cancelButton", 670 text: "Cancel", 671 "class": "confirm_delete_no_btn button small orange", 672 "click": function (elem) { 673 if ($(".ui-dialog").is(":visible")) { 674 $(".ui-dialog").children('.ui-dialog-content').dialog('destroy').remove(); 675 } 676 elem.preventDefault(); 677 return false;
678 }}], 679 close: function(event, ui) { 680 if ($(".ui-dialog").is(":visible")) { 681 $(".ui-dialog").children('.ui-dialog-content').dialog('destroy').remove(); 682 } 683 } 684 }).prev(".ui-dialog-titlebar").css({"padding": "0.4em 1em", "position": "relative"}).next(".ui-dialog-content").css("color", "black"); 685 $('#okButton').before().removeClass("ui-button ui-widget ui-state-default"); 686 $('#cancelButton').removeClass("ui-button ui-widget ui-state-default ui-state-hover"); 687 688 //}); 689 690 return false; 691 }; 692 693 /** 694 * Ajax loader div 695 */ 696 app.ddsignloader = { 697 loader: $('<div id="global_loaderD"><div id="global_loaderD2"><img src="/assets/templates/radicenter3/images/loading.gif" alt="'+app.lang.t('DOKU(2020)::Managing application - please wait...')+'" /><br />' + app.lang.t('DOKU(2020)::Managing application - please wait...') + '</div></div>'), 698 hideTimer: '', 699 timeOut: 500, 700 start: function() { 701 if (app.ddsignloader.enabled === true) { 702 $(app.ddsignloader.loader).show(); 703 app.ddsignloader.loading = true; 704 if (app.ddsignloader.hideTimer != '') { 705 clearTimeout(app.ddsignloader.hideTimer); 706 } 707 } 708 }, 709 stop: function() { 710 $(app.ddsignloader.loader).fadeOut('fast'); 711 if (app.ddsignloader.enabled === true) { 712 app.ddsignloader.loading = false; 713 if (app.ddsignloader.hideTimer != '') { 714 app.ddsignloader.hideTimer = setTimeout(function() { 715 $(app.ddsignloader.loader).fadeOut('fast'); 716 }, app.ddsignloader.timeOut); 717 } 718 } 719 }, 720 enabled: true, 721 enable: function() { 722 app.ddsignloader.enabled = true; 723 }, 724 disable: function() { 725 app.ddsignloader.enabled = false; 726 }, 727 loading: false, 728 init: function() { 729 app.ddsignloader.loader = $(app.ddsignloader.loader) 730 .appendTo('body') 731 .hide() 732 .ajaxStart(app.ddsignloader.start) 733 .ajaxStop(app.ddsignloader.stop); 734 } 735 }; 736 737 $.fn.equals = function(compareTo) { 738 if (!compareTo || !compareTo.length || this.length!=compareTo.length) { 739 return false; 740 } 741 for (var i=0; i<this.length; i++) { 742 if (this[i]!==compareTo[i]) { 743 return false; 744 } 745 } 746 return true; 747 }; 748 749 $.fn.isScrolledIntoView = function(elem) { 750 return this.each(function(){ 751 var docViewTop = $(window).scrollTop(); 752 var docViewBottom = docViewTop + $(window).height(); 753 754 var elemTop = $(elem).offset().top; 755 var elemBottom = elemTop + $(elem).height(); 756 757 return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)); 758 }); 759 }; 760 761 /* 762 * Check, if SHIFT + SOMEKEY was pressed 763 */ 764 $.fn.chkShiftPlusKeyPress = function (evt,chk_keyCode) { 765 766 var mykey, shift; 767 if (window.Event) { 768 //evt.shiftKey(); 769 mykey = evt.which; //alert('geee'+mykey); 770 shift = evt.shiftKey; //(evt.modifiers & Event.SHIFT_MASK) ? true : false; 771 //alert('geee:'+evt.shiftKey); 772 } else { 773 //alert('geee2'); 774 mykey = event.keyCode; 775 shift = event.shiftKey; 776 } 777 if(shift && mykey == chk_keyCode) { 778 return true; 779 } 780 else {return false;} 781 }; 782 783 /* 784 * Check, if ALT + SOMEKEY was pressed 785 */ 786 $.fn.chkAltPlusKeyPress = function (evt,chk_keyCode) { 787 var mykey, alt; 788 if (window.Event) { 789 mykey = evt.which; 790 alt = evt.altKey;//(evt.modifiers & Event.ALT_MASK) ? true : false; 791 } else { 792 mykey = event.keyCode; 793 alt = event.altKey; 794 } 795 if(alt && mykey == chk_keyCode) { 796 return true; 797 } 798 else {return false;} 799 }; 800 801 /* 802 * Check, if CTRL + SOMEKEY was pressed 803 */ 804 $.fn.chkCtrlPlusKeyPress = function (evt,chk_keyCode) { 805 var mykey, ctrl; 806 if (window.Event) { 807 mykey = evt.which; 808 ctrl = evt.ctrlKey;//(evt.modifiers & Event.CONTROL_MASK) ? true : false; 809 } else { 810 mykey = event.keyCode; 811 ctrl = event.ctrlKey; 812 } 813 if(ctrl && mykey == chk_keyCode) { 814 return true; 815 } 816 else {return false;} 817 }; 818 819// app.sharelinks = { 820// init: function(scope) { 821// $(scope).find('.sharelink').unbind('change keypress keyup keydown click') 822// .bind('change keypress keyup keydown click', function(e) { 823// $(this).select(); 824// e.preventDefault(); 825// return false;
826// }); 827// } 828// }; 829// 830// 831// app.hash = { 832// value: str_replace('#', '', location.hash), 833// value_parts: [], 834// poll: '', 835// binds: {}, 836// empty: function() { 837// var status = false; 838// if (app.hash.value == '' || app.hash.value == '#' || app.hash.value == '#/' || app.hash.value == '/') status = true; 839// return status; 840// }, 841// update: function(new_hash) { 842// location.hash = new_hash; 843// app.debug('app.hash.update: updating hash to: '+new_hash); 844// 845// // if the hash changes, update the language dropdown links to change as well 846// var lang_selection_links = $('#lang_selection_area .submenu li.l2 a'); 847// if (lang_selection_links.size() > 0) { 848// lang_selection_links.each(function() { 849// if ($(this).attr('href').indexOf('#') === -1) 850// $(this).attr('href', $(this).attr('href')+'#'+new_hash); 851// else 852// $(this).attr('href', str_replace('#'+app.hash.value, '#'+new_hash, $(this).attr('href'))); 853// }); 854// } 855// 856// // if the hash changes, update the global signin form action url as well 857// var gsif = $('#global_signin_form form'); 858// if (gsif.size() > 0) { 859// if (gsif.attr('action').indexOf('#') === -1) 860// gsif.attr('action', gsif.attr('action')+'#'+new_hash); 861// else 862// gsif.attr('action', str_replace('#'+app.hash.value, '#'+new_hash, gsif.attr('action'))); 863// } 864// app.hash.value = str_replace('#','',location.hash); 865// }, 866// set: function(new_hash) { app.hash.update(new_hash); }, // use app.hash.set or app.hash.update to bypass app.hash.poll! 867// init: function() { 868// app.hash.poll = setInterval(function() { 869// if (app.hash.value != str_replace('#','',location.hash)) { 870// app.hash.set(location.hash); 871// app.hash.value_parts = explode('/', app.hash.value); 872// if (typeof(app.hash.binds.change) == 'function') { 873// app.hash.binds.change(); 874// } 875// } 876// }, 200); 877// 878// if (!app.hash.empty) 879// app.hash.update(app.hash.value); 880// } 881// }; 882// 883// 884// app.langselection_init = function() { 885// $('#lang_selection_area form').hide().parent().children('ul').show(); 886// $('#lang_selection_area a.l1').live('click', function(e) { app.menu.reveal(); return false; e.preventDefault(); }); 887// }; 888 889 /** 890 * Generic initialisation method 891 */ 892 app.generic_init = { 893 binds: {}, 894 add: function(id, func) { 895 app.generic_init.binds[id] = func; 896 }, 897 fire: function(scope, data) { 898 if (typeof(scope) == 'undefined') scope = '#content'; 899 900 // fix png 901 //$(document).pngFix(); 902 903 app.init_system_messages(); 904 905 var date_now = new Date(); 906 907// $(scope).find('.datepicker').datepicker({ 908// dateFormat: 'yy-mm-dd', 909// changeMonth: true, 910// changeYear: true, 911// yearRange: '1901:'+(parseInt(date_now.getFullYear())+1), 912// monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] 913// }); 914// $(scope).find('.nofuture_datepicker').datepicker({ 915// dateFormat: 'yy-mm-dd', 916// changeMonth: true, 917// changeYear: true, 918// minDate: new Date(1901, 1-1, 1), // 1-1 is for January 919// maxDate: '+0D', 920// monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] 921// }); 922 923// if(LANG != 'en') // load localisation for datepicker 924// { 925// $.getScript("/assets/templates/default/js/jquery.ui.datepicker/jquery.ui.datepicker-" + LANG + ".js", function(){ 926// $.datepicker.setDefaults($.datepicker.regional[LANG]); 927// $.datepicker.setDefaults( 928// { 929// dateFormat: 'dd.mm.yy', 930// changeMonth: true, 931// changeYear: true, 932// yearRange: 'c-100:c+20' 933// } 934// ); 935// 936// }); 937// $.getScript("/assets/templates/default/js/jquery.ui.datepicker/jquery.ui.datepicker-" + LANG + ".js", function(){ 938// }); 939// } 940 941 // set default settings for datepickers 942 $.datepicker.setDefaults($.datepicker.regional[LANG]); 943 $.datepicker.setDefaults( 944 { 945 buttonImage: "/assets/templates/default/images/ui/bits/cal.png", 946 dateFormat: 'dd.mm.yy', 947 changeMonth: true, 948 changeYear: true, 949 yearRange: 'c-100:c+20' 950// ,create: function(event, ui) { 951//// app.debug(ui); 952// app.debug('created'); 953// } 954 } 955 ); 956 957 $('.error_messages_box > .close_box').bind('click', function(e){ 958 $('#message_box').fadeOut(); 959 }); 960 961 // automatic logout on some time 962 app.auto_logout(); 963 964 if($.simpleautogrow) 965 { 966 //app.debug('simpleautogrow exists'); 967 $(scope).find('textarea.autogrow').simpleautogrow(); 968 } 969
970 //$(scope).find(".timestamp").prettyDate(); 971 972// if ($('.flash_message').size() > 0) { 973// var hideFlashMessageTmr = setTimeout(function() { 974// $('.flash_message').slideUp('fast'); 975// }, 4000); 976// } 977// 978// if ($.fn.htmlarea){ 979// app.debug('generic_init.fire: Found jHtmlArea plugin... trying to initialize areas'); 980// $(scope).find('textarea.htmlarea').htmlarea({ 981// toolbar: ["bold", "italic", "|", "orderedlist", "unorderedlist", "|", "indent", "outdent", "|", "link", "unlink", "image", "|","html"], 982// css: 'http://'+UISERVER+'/css/text.css' 983// }); 984// } 985 986 app.confirm.init(scope); 987 app.ajaxlinks.init(scope); 988 //app.tabs.init(scope); 989 //app.input_placeholder.init(scope); 990 app.toggle_links.init(scope); 991 app.singlesubmit.init(scope); 992 993 for (var id in app.generic_init.binds) { 994 if (typeof (app.generic_init.binds[id]) == 'function') { 995 //app.debug('app.generic_init.fire: firing generic init for '+id); 996 app.generic_init.binds[id](scope, data); 997 } 998 } 999 1000 autofocus_elem = $(scope).find('.autofocus:first'); 1001 if (autofocus_elem.size() == 1) { 1002 autofocus_elem.focus(); 1003 } 1004 } 1005 }; 1006 1007 /** 1008 * Update message box element from given page HTML 1009 */ 1010 app.update_message_box = function(data, dataType) 1011 { 1012 1013 //console.log('Errorz in: '+ dataType);
1014 if(dataType != 'json' && dataType != 'JSON') 1015 { 1016 sys_msg_box_el = $('#message_box'); 1017 1018 if(typeof sys_msg_box_el != 'undefined') 1019 { 1020 new_msg_box_el = $(data).find('#message_box'); 1021 if(typeof new_msg_box_el != 'undefined') 1022 { 1023 if(new_msg_box_el.html() != null) 1024 { 1025 sys_msg_box_el.replaceWith(new_msg_box_el); 1026 sys_msg_box_el = $('#message_box'); 1027 sys_msg_box_el.hide(); 1028 1029 app.init_system_messages(); 1030 1031 // make close button work 1032 $('.error_messages_box > .close_box').bind('click', function(e){ 1033 $('#message_box').fadeOut(); 1034 }); 1035 } 1036 } 1037 } 1038 } 1039 }; 1040 1041 /** 1042 * Translit and prepare string for url compliant 1043 */ 1044 app.convert_String_to_url = function(strTitle) 1045 { 1046 var replaces=new Object(); 1047 replaces['ä']=['a']; 1048 replaces['ü']=['u']; 1049 replaces['õ']=['o']; 1050 replaces['ö']=['o']; 1051 replaces['Å¡']=['s']; 1052 replaces['ž']=['z']; 1053 replaces['Ñ']=['e']; 1054 replaces['й']=['j']; 1055 replaces['Ñ']=['c']; 1056 replaces['Ñ']=['u']; 1057 replaces['к']=['k']; 1058 replaces['е']=['e']; 1059 replaces['н']=['n']; 1060 replaces['г']=['g']; 1061 replaces['Ñ']=['sh']; 1062 replaces['Ñ']=['sch']; 1063 replaces['з']=['z']; 1064 replaces['Ñ ']=['x']; 1065 replaces['Ñ']=['']; 1066 replaces['Ñ']=['f']; 1067 replaces['Ñ']=['y']; 1068 replaces['в']=['v']; 1069 replaces['а']=['a']; 1070 replaces['п']=['p']; 1071 replaces['Ñ']=['r']; 1072 replaces['о']=['o']; 1073 replaces['л']=['l']; 1074 replaces['д']=['d']; 1075 replaces['ж']=['zh']; 1076 replaces['Ñ']=['e']; 1077 replaces['Ñ']=['ja']; 1078 replaces['Ñ']=['ch']; 1079 replaces['Ñ']=['s']; 1080 replaces['м']=['m']; 1081 replaces['и']=['i']; 1082 replaces['Ñ']=['t']; 1083 replaces['Ñ']=['']; 1084 replaces['б']=['b']; 1085 replaces['Ñ']=['ju']; 1086 replaces['Ã']=['A']; 1087 replaces['Ã']=['U']; 1088 replaces['Ã']=['O']; 1089 replaces['Ã']=['O']; 1090 replaces['Å ']=['S']; 1091 replaces['Ž']=['Z']; 1092 replaces['Ð']=['E']; 1093 replaces['Ð']=['J']; 1094 replaces['Ц']=['C']; 1095 replaces['У']=['U']; 1096 replaces['Ð']=['K']; 1097 replaces['Ð']=['E']; 1098 replaces['Ð']=['N']; 1099 replaces['Ð']=['G']; 1100 replaces['Ш']=['SH']; 1101 replaces['Щ']=['SCH']; 1102 replaces['Ð']=['Z']; 1103 replaces['Ð¥']=['X']; 1104 replaces['Ъ']=['']; 1105 replaces['Ф']=['F']; 1106 replaces['Ы']=['Y']; 1107 replaces['Ð']=['V']; 1108 replaces['Ð']=['A']; 1109 replaces['Ð']=['P']; 1110 replaces['Ð ']=['R']; 1111 replaces['Ð']=['O']; 1112 replaces['Ð']=['L']; 1113 replaces['Ð']=['D']; 1114 replaces['Ð']=['ZH']; 1115 replaces['Ð']=['E']; 1116 replaces['Я']=['JA']; 1117 replaces['Ч']=['CH']; 1118 replaces['С']=['S']; 1119 replaces['Ð']=['M']; 1120 replaces['Ð']=['I']; 1121 replaces['Т']=['T']; 1122 replaces['Ь']=['']; 1123 replaces['Ð']=['B']; 1124 replaces['Ю']=['JU']; 1125 1126 var reg_search;
1127 for(var repl in replaces) 1128 { 1129 regSearch=new RegExp(repl,"g"); 1130 strTitle=strTitle.replace(regSearch,replaces[repl]); 1131 } 1132 regSearch=new RegExp("[^A-Za-z0-9\-]","g"); 1133 strTitle=strTitle.replace(regSearch,"-"); 1134 if(strTitle.length>2) 1135 { 1136 if(strTitle.substr(-1,1)=="-") 1137 { 1138 if(strTitle.substr(-2,1)=="-") {} 1139 else 1140 { strTitle=strTitle.substr(0,strTitle.length-1); } 1141 } 1142 } 1143 return strTitle; 1144 }; 1145 1146 /** 1147 * Switch tab and execute given callback function (optional) 1148 * See menu js for an example usage 1149 * 1150 * @param string item_id - tab id 1151 * @param string tabs_class - tab css class name 1152 * @param string content_class - tab content css class name 1153 * @param function content_load_callback 1154 */ 1155 app.switch_tab = function(item_id, tabs_class, content_class, switch_tab_callback) 1156 { 1157 $('.'+tabs_class).removeClass('active'); 1158 $('.'+content_class).css('display','none'); 1159 1160 var act_tab = $('#'+item_id); 1161 1162 act_tab.addClass('active'); 1163 $('#'+item_id+'_content').css('display','block'); 1164 1165 // fire callback
1166 if(typeof switch_tab_callback == 'function') 1167 { switch_tab_callback(); } 1168 }; 1169 1170 /** 1171 * Show nice system messages JS way 1172 */ 1173 app.init_system_messages = function() 1174 { 1175 if($('#message_box .message').length == 0) 1176 { 1177 $('#message_box').hide(); 1178 } 1179 else 1180 { 1181 if(app.check_old_browser() == false) 1182 { 1183 $('#message_box').hide(); 1184 var el_msgs_boxes = $('#message_box .message'); 1185 1186 if(el_msgs_boxes != 'undefined') 1187 { 1188 $.each(el_msgs_boxes, function(index, value) 1189 { 1190 var msg_type = ''; 1191 //msg_class = ''; 1192 if($(this).hasClass('message_error')) 1193 { msg_type = 'error'; } 1194 else if($(this).hasClass('message_success')) 1195 { msg_type = 'success'; } 1196 else if($(this).hasClass('message_success2')) 1197 { msg_type = 'stable_success'; } 1198 else if($(this).hasClass('message_info')) 1199 { msg_type = 'info'; } 1200 else if($(this).hasClass('message_warning')) 1201 { msg_type = 'warning'; } 1202 1203 //lifetime = (msg_class == '' || msg_class == 'message_error' || msg_class == 'message_warning' ? 0 : 3000); 1204 1205 var msg_name = $(this).attr('data-name'); 1206 var msg_body = $(this).html(); 1207 // if we have a named message, then try to show scroll to icon 1208 if(typeof msg_name != 'undefined' && msg_name != '') 1209 { 1210 var el_by_name = $(document.getElementsByName(msg_name)); 1211 if(el_by_name.length > 0) 1212 { 1213 if(typeof window.scrollBy == 'function') 1214 { 1215 msg_body += '<span> </span> <span onclick="app.scrollWindowToXY(0, ' + el_by_name.offset().top + ', 0, -50);" class="icon size16x16 icon_goto_field" alt="Go" title="Go"> </span>'; 1216 } 1217 } 1218 } 1219 1220 app.say(msg_body, msg_type); 1221 msg_body = null; 1222 }); 1223 } 1224 } 1225 else 1226 { $('#message_box').show(); } 1227 } 1228 }; 1229 1230 /** 1231 * Scroll main window to given X and Y 1232 * @param x 1233 * @param y 1234 */ 1235 app.scrollWindowToXY = function(x, y, x_offset, y_offset) 1236 { 1237 if(typeof x == 'undefined') x = 0; 1238 if(typeof y == 'undefined') y = 0; 1239 if(typeof x_offset == 'undefined') x_offset = 0; 1240 if(typeof y_offset == 'undefined') y_offset = 0; 1241 1242 x += x_offset; 1243 y += y_offset; 1244 1245 // TODO: check if compute right x scroll value according to current window scrollX is OK 1246 if(window.scrollX > 0 && window.scrollX < x) 1247 { x = x - window.scrollX; } 1248 else if(window.scrollX > 0 && window.scrollX == x) 1249 { x = 0; } 1250 else if(window.scrollX > 0 && window.scrollX > x) 1251 { x = x - window.scrollX; } 1252 1253 // compute right y scroll value according to current window scrollY 1254 if(window.scrollY > 0 && window.scrollY < y) 1255 { y = y - window.scrollY; } 1256 else if(window.scrollY > 0 && window.scrollY == y) 1257 { y = 0; } 1258 else if(window.scrollY > 0 && window.scrollY > y) 1259 { y = y - window.scrollY; } 1260 1261 window.scrollBy(x, y); 1262 } 1263 1264 /** 1265 * Show message to user 1266 */ 1267 app.say = function(msg, type, lifetime) 1268 { 1269 if(app.check_old_browser() == false) 1270 { 1271 if(typeof type == 'undefined' || type == '') 1272 msg_class = 'success'; 1273 else 1274 msg_class = 'message_' + type; 1275 1276 if(typeof lifetime == 'undefined' || typeof lifetime == 'null') 1277 lifetime = (msg_class == '' || msg_class == 'message_error' || msg_class == 'message_stable_success' || msg_class == 'message_warning' ? 0 : 6000); 1278 1279 app.show_jmessage('', '<span class="icon"></span>' + msg, lifetime, 'jm_' + msg_class); 1280 } 1281 else 1282 { alert(msg); } 1283 }; 1284 1285 1286 /** 1287 * @version Dirty 1288 * @param {type} header 1289 * @param {type} message 1290 * @param {type} lifetime 1291 * @param {type} class_name 1292 * @returns {undefined} 1293 */ 1294 app.show_jmessage = function(header, message, lifetime, class_name) { 1295 // main jmessage stack box container 1296 var stack_box = $('#jm_stack_box'); 1297 1298 // if no container found, make it 1299 if(!$(stack_box).length) { 1300 stack_box = $('<div id="jm_stack_box"></div>').prependTo(document.body); 1301 } 1302 1303 // create current message container 1304 var message_box = $('<div class="jm_message ' + class_name + '">' + ( header != '' ? '<h3>' + header + '</h3>' : '' ) + message + '</div>'); 1305 1306 // add our message to stack 1307 //$(message_box).css('opacity', 0).appendTo('#jm_stack_box').animate({opacity: 1}, 300); 1308 $(message_box).appendTo('#jm_stack_box').hide().fadeIn(500); // sergei fix: another animation, cause we dont want to put opacity as a style to element 1309
1310 // bind onclick event handler to close/remove the message 1311 $(message_box).click(function() { 1312 $(this).animate({opacity: 0}, 300, function() 1313 { 1314 $(this).remove(); 1315 }); 1316 }); 1317 1318 // if we have message lifetime set, then prepare a timeout to close/remove it 1319 if((lifetime = parseInt(lifetime)) > 0) { 1320 setTimeout(function() 1321 { 1322 $(message_box).animate({opacity: 0}, 300, function() { 1323 $(this).remove(); 1324 }); 1325 }, 1326 lifetime); 1327 } 1328 }; 1329 1330 /** 1331 * Display an OLD browser box warning 1332 */ 1333 app.old_browser_box = function() { 1334 if (app.check_old_browser()) { 1335 $('<div />') 1336 .attr('id', 'old_browser_box').prependTo('body') 1337 .html('<h1>'+app.lang.t('notice')+'</h1><p>'+app.lang.t('MESSAGES::You are using a VERY old browser!')+' '+app.lang.t('MESSAGES::Please, [upgrade_link_p1]UPGRADE[upgrade_link_p2]!', ['[upgrade_link_p1]','[upgrade_link_p2]'], ['<a href="'+RECOMMENDED_BROWSER_URL+'">','</a>'])+'</p>'); 1338 } 1339 }; 1340 1341 app.check_old_browser = function() { 1342 if ($.browser.msie && $.browser.version < 10) 1343 return true; 1344 else 1345 return false; 1346 }; 1347 1348 /** 1349 * Redirect ot given URL 1350 */ 1351 app.redirect = function(url) { 1352 document.location.href = url; 1353 }; 1354 1355 /** 1356 * Get current document location hostname 1357 */ 1358 app.get_hostname = function() { 1359 return document.location.hostname; 1360 }; 1361 1362 /** 1363 * Logs out on some period of time of inactivity 1364 */ 1365 app.auto_logout = function () 1366 { 1367 if (!USER_ID) return; 1368 1369 var last_activity_time = new Date().getTime(); 1370 1371 a = setInterval(function(){ 1372 if (new Date().getTime() - last_activity_time > session_timeout*1000) 1373 { 1374 app.redirect(site_protocol + '://' + site_domain + '/' + LANG + '/' + ((IS_CA_REQUEST)?'ca/':'') + 'logout/?return='+current_url_encoded); 1375 } 1376 }, session_check_time * 1000); 1377 }; 1378 1379 /** 1380 * init pretty checkboxes and radios 1381 */ 1382 app.init_ui_pretty_checkboxes = function(scope) 1383 { 1384 // make all checkboxes pretty 1385 if( $.isFunction($.fn.prettyCheckboxes) ) 1386 { 1387 if(typeof scope == 'undefined' || !scope) 1388 scope = ''; 1389 else 1390 scope = scope + ' '; 1391 1392// app.debug(scope + ' .prettycb'); 1393 1394 $(scope + '.prettycb').each(function(i,v){ 1395 if(!$(this).hasClass('ui_changed')) 1396 { 1397 $(this).addClass('ui_changed').prettyCheckboxes({ 1398 checkboxWidth: 16, // The width of your custom checkbox 1399 checkboxHeight: 16 // The height of your custom checkbox) 1400 }); 1401 } }); 1402 } 1403 }; 1404 1405 /** 1406 * init pretty overlabels 1407 */ 1408 app.init_ui_overlabels = function(scope) 1409 { 1410 if(typeof scope == 'undefined' || !scope) 1411 scope = ''; 1412 else 1413 scope = scope + ' '; 1414 1415 // make all overlabels pretty 1416 if( $.isFunction($.fn.overlabel) ) 1417 { 1418 $(scope + 'label.overlabel').each(function(i,v){ 1419 if(!$(this).hasClass('ui_changed')) 1420 { $(this).addClass('ui_changed').overlabel(); } 1421 }); 1422 } 1423 }; 1424 1425 /** 1426 * wrap all datepickers with jui div 1427 */ 1428 app.init_ui_jui_datepicker_wrap = function(scope) 1429 { 1430 if(typeof scope == 'undefined' || !scope) 1431 scope = ''; 1432// else 1433// scope = scope + ' '; 1434 1435 //app.debug(scope + '.ui-datepicker.ui-widget.ui-widget-content'); 1436 1437 // wrap all datepickers with jui div 1438 $('.ui-datepicker.ui-widget.ui-widget-content').each(function(i,v){ 1439 if(!$(this).hasClass('ui_changed')) 1440 { $(this).addClass('ui_changed').wrap('<div class="jui"></div>'); } 1441 }); 1442 }; 1443 1444 // init pretty comboboxes 1445 app.init_ui_comboboxes = function(scope) 1446 { 1447 if(typeof scope == 'undefined' || !scope) 1448 scope = ''; 1449 else 1450 scope = scope + ' '; 1451 1452 // jQuery UI combobox 1453 if( $.isFunction($.fn.combobox) ) 1454 { 1455 // Popup form SELECTs 1456 $(scope + '.popup_form_container select').each(function(i,v){ 1457 if(!$(this).hasClass('ui_changed')) 1458 { $(this).addClass('ui_changed').addClass('to-parent auto-width').combobox(); } 1459 }); 1460 1461 // table_public SELECTs 1462 $(scope + '.table_public select').each(function(i,v){ 1463 if(!$(this).hasClass('ui_changed')) 1464 { $(this).addClass('ui_changed').addClass('to-parent auto-width').combobox(); } 1465 }); 1466 1467 // pub_form SELECTs 1468 $(scope + '.pub_form select').each(function(i,v){ 1469 if(!$(this).hasClass('ui_changed')) 1470 { $(this).addClass('ui_changed').addClass('to-parent auto-width').combobox(); } 1471 }); 1472 1473 // All other with parent .combo 1474 $(scope + '.combo select').each(function(i,v){ 1475 if(!$(this).hasClass('ui_changed')) 1476 { 1477 $(this).addClass('ui_changed').combobox(); 1478 } 1479 }); 1480 } 1481 }; 1482 1483 /** 1484 * Set value of ui combobox programmatically 1485 * @param id 1486 * @param value 1487 */ 1488 app.set_combobox_value = function (id, value) 1489 { 1490 $('#'+id).val(value); 1491 $('#'+id+' option').each(function(index, item){ 1492 if ($(item).attr('value') == value) 1493 { 1494 $('#'+id).next().val($(item).html()); 1495 } 1496 }); 1497 }; 1498 1499 /** 1500 * Init all pretty ui elements if not set already 1501 */ 1502 app.init_pretty_ui = function(scope) 1503 { 1504 if(typeof scope == 'undefined' || !scope) 1505 scope = ''; 1506 else 1507 scope = ' ' + scope; 1508 1509 //app.init_ui_pretty_checkboxes(scope); 1510 app.init_ui_overlabels(scope); 1511 app.init_ui_jui_datepicker_wrap(scope); 1512 app.init_ui_comboboxes(scope); 1513 }; 1514 1515 /** 1516 * Bind init pretty UI function after document full ready 1517 */ 1518 app.fullyready.add('init_pretty_ui', function(){ app.init_pretty_ui(); }); 1519 // init once (NB!!! popups not covered) 1520 //app.fullyready.add('init_ui_pretty_checkboxes', function(){ app.init_ui_pretty_checkboxes(); }); 1521 1522 1523 // initialize global elements (those outside #content) 1524 app.old_browser_box(); 1525 //app.menu.init('.mainmenu ul'); 1526 //app.global_signin.init(); 1527 //app.menu.init('#lang_selection_area'); 1528 //app.tipper.init('.mainmenu'); 1529 app.ajaxloader.init();
1530 //app.langselection_init(); 1531 //app.hash.init(); 1532 //app.pinger.init(); 1533 $(document).bind('keyup keydown keypress', app.globalevent.fire); 1534 1535 // then apply the generic_init function which enables all stuff inside #content 1536 app.generic_init.fire(); 1537 1538 $(document).bind("ajaxSuccess", function(e, xhr, settings){ 1539 1540 if(typeof settings.dataType == 'undefined' ) 1541 dataType = ''; 1542 else 1543 dataType = settings.dataType; 1544 1545 //app.debug(settings); 1546 //app.ajax_success.add('message_box', function(){ app.update_message_box(xhr.responseText, dataType); }); 1547 // show message from server if any (works only if response text contains full page html) 1548 app.update_message_box(xhr.responseText, dataType); 1549 app.ajax_update_elements(xhr.responseText); 1550 1551 }); 1552 1553 // UI dialogs 1554 1555 /** 1556 * Fix ui dialogs css 1557 */ 1558 app.fix_dialog_css = function() 1559 {}; 1560 1561 /** 1562 * Fix dialog position and overlay size 1563 * @param delay 1564 */ 1565 app.fix_dialog_after_change = function(delay) 1566 { 1567 if (typeof delay == 'undefined') delay = 180; 1568 delay = parseInt(delay); 1569 1570 if (delay) 1571 { 1572 setTimeout(function(){ 1573 1574 app.fix_dialog_for_IE(); 1575 app.init_pretty_ui('.ui-dialog'); 1576 //$('.ui-dialog').vAlignWithAnimation(350); 1577 $('.ui-dialog').vAlign(); 1578 $(".ui-widget-overlay").resize(); 1579 1580 },delay); 1581 } 1582 else 1583 { 1584 app.fix_dialog_for_IE(); 1585 app.init_pretty_ui('.ui-dialog'); 1586 //$('.ui-dialog').vAlignWithAnimation(350); 1587 $('.ui-dialog').vAlign(); 1588 $(".ui-widget-overlay").resize(); 1589 1590 } 1591 1592 1593 }; 1594 1595 /** 1596 * Fix dialog for IE <= 7 1597 */ 1598 app.fix_dialog_for_IE = function() 1599 { 1600 // If the browser is <= IE7, 1601 if( $.browser.msie && parseInt($.browser.version, 10) <= 7 ) 1602 { //app.debug('Fixing dialog for IE'); 1603 var zIndexNumber = 1500; 1604 // Put your target element(s) in the selector below! 1605 $("div.buble_block").each(function() { 1606 $(this).css('z-index', zIndexNumber); 1607 zIndexNumber -= 10; 1608 }); 1609 1610 // $("input[type=radio], input[type=checkbox]").css('z-index', 1100).css('position', 'relative'); 1611 1612// 1613// // fix for checkbox and radio to be able to click on them 1614// $("div.buble_block input[type=radio]").css('z-index', 1100).css('position', 'relative'); 1615// $("div.buble_block input[type=checkbox]").css('z-index', 1100).css('position', 'relative'); 1616 1617 //$("input[type=radio], input[type=checkbox]").css('z-index', 1100).css('position', 'relative'); 1618 } 1619 }; 1620 1621 /** 1622 * Fix ui dialogs overlay height after dialog resized 1623 */ 1624 app.fix_dialog_overlay = function(delay) 1625 { 1626 app.fix_dialog_after_change(delay); 1627 }; 1628 1629 /** 1630 * Prepare popup box hidden div 1631 */ 1632 app.draw_popup_box = function(id) 1633 { 1634 if(typeof id == 'undefined') 1635 id = 'popupBox'; 1636 1637 if($('#' + id).length == 0){ 1638 $('<div style=\"display:none\"><div id=\"' + id + '\"></div></div>').appendTo('body'); 1639 return id; 1640 } 1641 return false; 1642 }; 1643 1644 app.init_select_combos = function(parent_el_id) 1645 { 1646 // init pretty comboboxes 1647 // jQuery UI combobox 1648 if( $.isFunction($.fn.combobox) ) 1649 { 1650// // Shoppingcart edit Popup form SELECTs 1651// $('#shoppingcart_edit_form .popup_form_container select') 1652// .addClass('to-parent') 1653// .combobox(); 1654// 1655// // Popup form SELECTs 1656// $('.popup_form_container select') 1657// .addClass('to-parent auto-width') 1658// .combobox(); 1659// 1660// // table_public SELECTs 1661// $('.table_public select') 1662// .addClass('to-parent auto-width') 1663// .combobox(); 1664// 1665// // pub_form SELECTs 1666// $('.pub_form select') 1667// .addClass('to-parent') 1668// .combobox(); 1669 1670 // All other with parent .combo 1671 if(typeof parent_el_id == 'undefined') 1672 $('.combo select').combobox(); 1673 else 1674 $('#' + parent_el_id + ' .combo select').combobox(); 1675 } 1676 }; 1677 1678 app.load_multiple_blocks = function (html_ids_to_get, url) 1679 { 1680 if (!url) url = location.href; 1681 1682 if (!html_ids_to_get) return {}; 1683 1684 $.get(url, {'load_as_full_html':true}, function(data) { 1685 $.each(html_ids_to_get, function(index,value){ 1686 $('#'+value).html($(data).find('#'+value).html()); 1687 }); 1688 }); 1689 }; 1690 1691 1692 //app.ajax_success.add('init_select_combos', function () { app.init_select_combos();}); 1693 1694});
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.